Permalink
Browse files

Cleanup

  • Loading branch information...
1 parent 538e7fd commit 05d0d8d1b9c6d9b492166b07124c998f35cd50a3 @duckinator committed May 2, 2011
Showing with 1 addition and 24 deletions.
  1. +1 −24 site.rb
View
25 site.rb
@@ -2,7 +2,6 @@
require 'net/http'
require 'json'
-$cache = {}
$useragents = {}
class Site
@@ -11,7 +10,6 @@ def initialize
end
def getinfo(ip)
- #return $cache[ip] unless $cache[ip].nil?
g = GeoIP.new(File.join(File.dirname(__FILE__), 'GeoLiteCity.dat'))
tmp = g.country(ip)
tmp ||= @default
@@ -35,21 +33,7 @@ def getua(raw_useragent)
def call(env)
ip = env['HTTP_X_FORWARDED_FOR'] # Reverse-proxy
- #ip = env['HTTP_X_REAL_IP'] # Reverse-proxy
- #ip ||= env['REMOTE_ADDR'] # Normal
raw_ua = env['HTTP_USER_AGENT']
-=begin
- data = @g.country(ip)
- city = data[7] || "unknown"
- region = data[6] || "unknown"
- country = data[4] || "unknown"
- area_code = data[12] || "unknown"
- time_zone = data[13] || "unknown"
- time_zone.gsub!('_', ' ')
- ua = parse_useragent(raw_ua)
-=end
-
- cached = false #$cache.keys.include?(ip)
data = getinfo(ip)
ua = getua(raw_ua)
@@ -58,12 +42,6 @@ def call(env)
language = ua['agent_language']
language = language.split(' - ')[0] # Remove the ' - United States'/' - United Kingdom' and similar
- if cached
- hidden = ''
- else
- hidden = ' style="display:none;"'
- end
-
str = <<EOF
<html>
<head>
@@ -76,8 +54,7 @@ def call(env)
</style>
</head>
<body>
-<p>DISCLAIMER: No data related to your location is stored. Information on browsers is stored for speed, but there is nothing linking it to a particular person. This site will more than likely not work on mobile devices. Accuracy varies.</p>
-<p#{hidden}>This is using cached results for #{ip}. If you are using a mobile device, it may be inaccurate.</p>
+<p>DISCLAIMER: No data related to your location is stored. Some information about your browser is stored to boost the speed of repeat requests, but there is nothing linking it to a particular person. This site will more than likely not work on mobile devices. Accuracy varies.</p>
<p>You are near #{data[:city]}, #{data[:region]}, #{data[:country]}. Your area code is #{data[:area_code]}. Your time zone is #{data[:time_zone]}.</p>
<p>You are probably using the <em>#{language}</em> version of <em>#{ua['agent_name']} #{ua['agent_version']}</em> on <em>#{os}</em>.</p>
<div>

0 comments on commit 05d0d8d

Please sign in to comment.