Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar Mark Forums Read
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 11-15-2010, 11:15 PM   #1
Jakez
Confirmed User
 
Jakez's Avatar
 
Industry Role:
Join Date: Jan 2004
Location: oddfuturewolfgangkillthemall!!!!!!!
Posts: 5,656
Anyone using the Maxmind geoip lookup?

This thing is just returning United States for every non-US IP I throw at it.. wtf?

<?php
include_once("geoip.inc");
$open = geoip_open("GeoIP.dat", GEOIP_STANDARD);
print geoip_country_code_by_addr($open, "62.41.77.63");
geoip_close($open);
?>

Should return DE for Germany but it says US from everything..
__________________
[email protected] - jakezdumb - 573689400

Killuminati
Jakez is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-16-2010, 01:43 AM   #2
andrej_NDC
Registered User
 
Industry Role:
Join Date: May 2004
Posts: 7,760
I will have to check some older sites to get you the proper code.
andrej_NDC is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-16-2010, 02:08 AM   #3
SmellyNose
Confirmed User
 
SmellyNose's Avatar
 
Industry Role:
Join Date: Aug 2009
Location: me at smellynose.com
Posts: 206
Code:
$bad_country_codes = Array('CN', 'JP', 'TW');

require_once("geoip.inc");

$gi = geoip_open("/usr/share/GeoIP/GeoIP.dat", GEOIP_STANDARD);
$cc = geoip_country_code_by_addr($gi, $_SERVER['REMOTE_ADDR']);
if(in_array($cc, $bad_country_codes)) {
        exit;
}
The above is what I use on one of my websites, so it looks like you're doing it correctly.

Have you checked you're not giving it a US ip all the time?

You can go to maxmind.com and enter the IP there and it will tell you the location of the IP so you will be able to see whether you've given it a US ip or your code is wrong.
__________________
I'm a PHP developer - 594086663 - [email protected]
SmellyNose is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-16-2010, 02:47 AM   #4
MasterM
Confirmed User
 
Join Date: Oct 2002
Location: netherlands
Posts: 248
i blocked out the following countries also : IR ID KR VE IN
MasterM is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-16-2010, 04:33 AM   #5
iSpyCams
Amateur Gynecologist
 
Industry Role:
Join Date: May 2009
Location: Medellin
Posts: 4,436
I just started using it recently, I wanted to block the Dominican Republic from some of my cascades but it keeps thinking the DR is Canada.
iSpyCams is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-16-2010, 06:32 AM   #6
Barry-xlovecam
It's 42
 
Industry Role:
Join Date: Jun 2010
Location: Global
Posts: 18,083
I use the Perl Binary;

Code:
#!/usr/bin/perl
####################################
#geo_ip_no.cgi
#Specific geo target
#
#
#
#
####################################
use CGI::Carp qw/fatalsToBrowser/;
use CGI qw/:standard/;

$addr ="$ENV{'REMOTE_ADDR'}";
$browser = $ENV{'HTTP_USER_AGENT'};
$geoip_file =  "/usr/share/geo_ip/GeoIP.dat";

print "Content-type: text/html\n\n";

$qstring = "$ENV{'QUERY_STRING'}";
	if ($qstring =~ s/[^a-zA-Z0-9\_]//g) {print qq~HUH???~;       exit;}

	use Geo::IP;

			$gi = Geo::IP->open( $geoip_file,  GEOIP_STANDARD)||die"died opening";

						$country_code = $gi->country_code_by_addr($addr);


			if ($country_code !~/(AA|BB|CC|DD|EE)/i){
				
				#INSERT
				
				
				
				
}#end geo ip

else{
	exit;
}
Similar variables to the PHP maybe you can see why you are getting that error?
Barry-xlovecam is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-16-2010, 07:41 AM   #7
Davy
Confirmed User
 
Davy's Avatar
 
Industry Role:
Join Date: Apr 2006
Location: Germany
Posts: 4,323
I will also load a probably huge file on every page load.
Do yourself a favor and import the data into a database.
__________________
---
ICQ 14-76-98 <-- I don't use this at all
Davy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-16-2010, 09:06 AM   #8
CrocMint
Confirmed User
 
CrocMint's Avatar
 
Industry Role:
Join Date: Oct 2010
Posts: 227
Quote:
Originally Posted by Davy View Post
I will also load a probably huge file on every page load.
Do yourself a favor and import the data into a database.
I dont think importing in mysql will increase performance...
Mysql DB will be huge enough and searching mysql db will not take less resource than searching their dat file...

I'm using other method to opimize this - caching resolved countries for visitor IP's , so at least when single surfer is visiting page(s) with geo detection multiple times within day or two, it only searches .dat file once for him.
__________________
Our Herbal Supplements for Adult Health - a New Revenue Stream for You - mike[at]crocmint.com
CrocMint is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-16-2010, 09:24 AM   #9
Kiopa_Matt
Confirmed User
 
Industry Role:
Join Date: Oct 2007
Posts: 1,448
I use it all the time, and it works great. Try this instead:

Code:
<?php
include_once("geoip.inc");
include_once("geoipregionvars.php");

$gi = geoip_open("GeoIP.dat", GEOIP_STANDARD);
$record = geoip_record_by_addr($gi, "62.41.77.63");

$country_code = $record->country_code;
$state_code = $record->region;
$city_name = $record->city;

geoip_close($gi);
?>
Should work fine.
__________________
xMarkPro -- Ultimate Blog Network Management
Streamline your marketing operations. Centralize management of domains, pages, Wordpress blogs, sponsors, link codes, media items, sales and traffic statistics, plus more!

Last edited by Kiopa_Matt; 11-16-2010 at 09:26 AM..
Kiopa_Matt is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-16-2010, 09:25 AM   #10
Kiopa_Matt
Confirmed User
 
Industry Role:
Join Date: Oct 2007
Posts: 1,448
Quote:
Originally Posted by Davy View Post
I will also load a probably huge file on every page load.
Do yourself a favor and import the data into a database.
No, don't do that. It works just fine as is, and no need to create a headache for yourself every time Maxmind released an upgrade.
__________________
xMarkPro -- Ultimate Blog Network Management
Streamline your marketing operations. Centralize management of domains, pages, Wordpress blogs, sponsors, link codes, media items, sales and traffic statistics, plus more!
Kiopa_Matt is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-16-2010, 10:19 AM   #11
Jason Voorhees
So Fucking Banned
 
Industry Role:
Join Date: Jul 2010
Location: Camp Crystal Lake.
Posts: 843
http://www.geoplugin.com/ Better, use it. Made by Borked, user here.
Jason Voorhees is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-16-2010, 10:22 AM   #12
myneid
Confirmed User
 
myneid's Avatar
 
Industry Role:
Join Date: Jan 2003
Location: Los Angeles
Posts: 736
best way to optimize maxmind is to use the apache module mod_geoip
__________________
Tanguy 0x7a69 inc. Programmer/President/CEO
http://www.0x7a69.com
A Leader in Programming since 1996
PHP, Ruby on Rails, MySQL, PCI DSS, and any Technical Consulting
myneid is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-16-2010, 11:22 AM   #13
borked
Totally Borked
 
borked's Avatar
 
Industry Role:
Join Date: Feb 2005
Posts: 6,284
Quote:
Originally Posted by Jason Voorhees View Post
http://www.geoplugin.com/ Better, use it. Made by Borked, user here.
Code:
Geolocation results for 62.41.77.63: 

*City:  
*Region:  
*Area Code: 0 
*DMA Code: 0 
*Country Name: Germany 
*Country Code: DE 
*Longitude: 9 
*Latitude: 51 
*Currency Code: EUR 
 Currency Symbol: ? 
 US$ Exchange Rate: 0.7354336098 
(US$ was used here as the base currency.)
(This can be changed for lookups.)

At todays rate, US$100 will cost you ?73.54

Some places you may wish to visit near : 

1:
	 Place: Gemünden an der Wohra
	 Country Code: DE
	 Region: Hesse
	 County: 
	 Latitude: 50.9666667
	 Longitude: 8.9666667
	 Distance (miles): 2.72
	 Distance (km): 4.38
	 Direction (degrees) 142.38
	 Direction (heading) SE
2:
	 Place: Allendorf bei Frankenau
	 Country Code: DE
	 Region: Hesse
	 County: 
	 Latitude: 51.0666667
	 Longitude: 8.9000000
	 Distance (miles): 6.33
	 Distance (km): 10.19
	 Direction (degrees) 45.22
	 Direction (heading) NE
3:
	 Place: Hatzbach
	 Country Code: DE
	 Region: Hesse
	 County: 
	 Latitude: 50.8833333
	 Longitude: 9.0166667
	 Distance (miles): 8.09
	 Distance (km): 13.02
	 Direction (degrees) 173.34
	 Direction (heading) S
4:
	 Place: Allendorf an der Landsburg
	 Country Code: DE
	 Region: Hesse
	 County: 
	 Latitude: 50.9500000
	 Longitude: 9.2166667
	 Distance (miles): 10.04
	 Distance (km): 16.16
	 Direction (degrees) 102.8
	 Direction (heading) ESE
5:
	 Place: Neustadt
	 Country Code: DE
	 Region: Hesse
	 County: 
	 Latitude: 50.8500000
	 Longitude: 9.1166667
	 Distance (miles): 11.54
	 Distance (km): 18.57
	 Direction (degrees) 146.31
	 Direction (heading) SSE
nope, it didn't get the city, but did get the country and lat/lon ...
__________________

For coding work - hit me up on andy // borkedcoder // com
(consider figuring out the email as test #1)



All models are wrong, but some are useful. George E.P. Box. p202
borked is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-16-2010, 11:27 AM   #14
borked
Totally Borked
 
borked's Avatar
 
Industry Role:
Join Date: Feb 2005
Posts: 6,284
Quote:
Originally Posted by Jakez View Post
This thing is just returning United States for every non-US IP I throw at it.. wtf?

<?php
include_once("geoip.inc");
$open = geoip_open("GeoIP.dat", GEOIP_STANDARD);
print geoip_country_code_by_addr($open, "62.41.77.63");
geoip_close($open);
?>

Should return DE for Germany but it says US from everything..
is GeoIP.dat the actual location of the .dat file? Have you tried adding the full server path to the dat file? Sounds to me like it can't find that GeoIP.dat file....
__________________

For coding work - hit me up on andy // borkedcoder // com
(consider figuring out the email as test #1)



All models are wrong, but some are useful. George E.P. Box. p202
borked is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-16-2010, 06:01 PM   #15
Jakez
Confirmed User
 
Jakez's Avatar
 
Industry Role:
Join Date: Jan 2004
Location: oddfuturewolfgangkillthemall!!!!!!!
Posts: 5,656
Tried filling in the full path and it still functions the same, totally weird it just says US for any IP I feed to it..

Thanks Borked the geoplugin works great!
I did have to copy and paste the PHP class source and save it that way because the Winrar download on there (http://www.geoplugin.com/_media/webs...&cache =cache) opens as a corrupt 0kb file for me..?
__________________
[email protected] - jakezdumb - 573689400

Killuminati
Jakez is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-16-2010, 06:10 PM   #16
GrouchyAdmin
Now choke yourself!
 
GrouchyAdmin's Avatar
 
Industry Role:
Join Date: Apr 2006
Posts: 12,085
I can only assume you aren't hard coding the URL, as you seem to have managed to handle things properly.

Are you caching the page with some WP-Supercache or other shit? If you have /any/ form of caching on this, it's not going to re-execute depending on how you are calling it.
__________________
GrouchyAdmin is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-16-2010, 06:36 PM   #17
Nasty
Confirmed User
 
Nasty's Avatar
 
Industry Role:
Join Date: Aug 2002
Location: Sunny Fucking California
Posts: 1,575
Quote:
Originally Posted by myneid View Post
best way to optimize maxmind is to use the apache module mod_geoip
What he said
__________________

“Ours is a world of nuclear giants and ethical infants. We know more about war than we know about peace, more about killing than we know about living. If we continue to develop our technology without wisdom or prudence, our servant may prove to be our executioner.” ― Omar Bradley (1948)
Nasty is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-16-2010, 06:54 PM   #18
gaffg
Confirmed User
 
gaffg's Avatar
 
Industry Role:
Join Date: Jan 2010
Location: Online
Posts: 717
I was asked about maxmind recently, seems popular
__________________
http://gaffg.com/affiliate-programs/
Find all gambling affiliate programs based on categories: casino, poker, sportsbetting, bingo, mobile.
Find forex and binary options affiliate programs.
Listed by revenue share, CPA and sub affiliate commission.
gaffg is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-17-2010, 12:05 AM   #19
borked
Totally Borked
 
borked's Avatar
 
Industry Role:
Join Date: Feb 2005
Posts: 6,284
Quote:
Originally Posted by Jakez View Post
I did have to copy and paste the PHP class source and save it that way because the Winrar download on there (http://www.geoplugin.com/_media/webs...&cache =cache) opens as a corrupt 0kb file for me..?
strange - it downloaded fine for me (mac) - try using the direct URL (none-cached)
http://www.geoplugin.com/_media/webs....class.php.tgz

or download from PHPClasses

the classes from either source will be more up to date than the source you copy/pasted
__________________

For coding work - hit me up on andy // borkedcoder // com
(consider figuring out the email as test #1)



All models are wrong, but some are useful. George E.P. Box. p202
borked is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-17-2010, 01:16 AM   #20
Jakez
Confirmed User
 
Jakez's Avatar
 
Industry Role:
Join Date: Jan 2004
Location: oddfuturewolfgangkillthemall!!!!!!!
Posts: 5,656
Quote:
Originally Posted by borked View Post
strange - it downloaded fine for me (mac) - try using the direct URL (none-cached)
http://www.geoplugin.com/_media/webs....class.php.tgz

or download from PHPClasses

the classes from either source will be more up to date than the source you copy/pasted
Still says it's corrupt. Maybe it's just me and someone else using Windows can try opening it.

Grabbed the one from phpclasses and it works fine just like the one I copy and pasted from your site. Thanks!
__________________
[email protected] - jakezdumb - 573689400

Killuminati
Jakez is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-17-2010, 01:32 AM   #21
KillerK
Confirmed User
 
Join Date: May 2008
Posts: 3,406
Quote:
Originally Posted by Davy View Post
I will also load a probably huge file on every page load.
Do yourself a favor and import the data into a database.
This is the worst advice anyone can follow.

You will take a HUGE performance hit going to mysql. Don't listen to Davy.
KillerK is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks
Thread Tools



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.