Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: GeoIP doesn't seem to be working?

  1. #1
    Zash's Avatar
    Zash is offline WiredStorm.com - Lightning Fast Web Hosting
    Join Date
    Feb 2009
    Location
    New York, USA
    Posts
    1,137
    Blog Entries
    1
    Thanks
    64
    Thanked 121 Times in 93 Posts

    GeoIP doesn't seem to be working?

    Hey,

    I have GeoIP installed with the following code on my Index:

    PHP Code:
    include('geoip/geoip.inc'); //this file must exist in your directory

    // Uncomment if querying against GeoIP/Lite City.
    // include('geoip/geoip.inc');

    $gi geoip_open('geoip/geoip.dat',GEOIP_STANDARD);

    // get the ip of the visitor
    $addr getenv('REMOTE_ADDR');
    // translate his ip to a country code
    $country geoip_country_name_by_addr($gi$addr);
    // close the geo database
    geoip_close($gi);

    $badcountry = array('Iran','Islamic Republic of Iran','China','Russian Federation','Saudi Arabia');

    if(
    in_array($country$badcountry))
    header('Location: http://www.proxlists.com'); //enter a url or page on your site 
    Lately, a lot of Iran traffic seems to have been slipping past it. Adversal is starting to get annoyed.

    Can anybody help me out? I don't know if I'm doing something wrong.
    WiredStorm Hosting Solutions
    █ Lightning Fast Shared and Reseller Hosting
    █ cPanel with Softaculous and 24/7 Email (Ticket) Support
    Biodegradable Sunscreen - Unblock Facebook

  2. #2
    dtkguy's Avatar
    dtkguy is offline Still Learnin'
    Join Date
    Dec 2008
    Posts
    391
    Thanks
    7
    Thanked 164 Times in 108 Posts
    The GeoIP database uses the following format for Iran's country name :

    Code:
    Iran, Islamic Republic of
    It'd probably just be easier if you used country codes versus country names, I use country code in all my GeoIP stuff, and haven't noticed any problems with it.

    To modify your GeoIP code to use country_codes instead of country_names is below :

    PHP Code:
    include('geoip/geoip.inc'); //this file must exist in your directory 

    // Uncomment if querying against GeoIP/Lite City. 
    // include('geoip/geoip.inc'); 

    $gi geoip_open('geoip/geoip.dat',GEOIP_STANDARD); 

    // get the ip of the visitor 
    $addr getenv('REMOTE_ADDR'); 
    // translate his ip to a country code 
    $country geoip_country_code_by_addr($gi$addr); 
    // close the geo database 
    geoip_close($gi); 

    $badcountry = array('IR','CN','RU','SA'); 

    if(
    in_array($country$badcountry)) 
    header('Location: http://www.proxlists.com'); //enter a url or page on your site 
    see if that helps. best way to test it is to momentarily block your own country, i.e. if your in the United States, add 'US' in the bad country array and make sure you get redirected. Then of course remove 'US' from the array once you confirm it's working.

  3. Thanked by:

    Will.Spencer (22 July, 2009), Zash (22 July, 2009)

  4. #3
    Zash's Avatar
    Zash is offline WiredStorm.com - Lightning Fast Web Hosting
    Join Date
    Feb 2009
    Location
    New York, USA
    Posts
    1,137
    Blog Entries
    1
    Thanks
    64
    Thanked 121 Times in 93 Posts
    Thanks, I actually was thinking that could have been the problem.
    WiredStorm Hosting Solutions
    █ Lightning Fast Shared and Reseller Hosting
    █ cPanel with Softaculous and 24/7 Email (Ticket) Support
    Biodegradable Sunscreen - Unblock Facebook

  5. #4
    Zash's Avatar
    Zash is offline WiredStorm.com - Lightning Fast Web Hosting
    Join Date
    Feb 2009
    Location
    New York, USA
    Posts
    1,137
    Blog Entries
    1
    Thanks
    64
    Thanked 121 Times in 93 Posts
    I got the following traffic yesterday:

    Iran - 229 Visits
    United States - 138 Visits
    Nigeria - 110 Visits

    And a bunch of other unrelated traffic.

    I currently have Iran, Nigeria, China, Russia, and Saudi Arabia blocked, but the first two don't seem to be going away?

    Here's the code I'm using:
    PHP Code:
    include('geoip/geoip.inc'); //this file must exist in your directory 

    $gi geoip_open('geoip/geoip.dat',GEOIP_STANDARD); 

    // get the ip of the visitor 
    $addr getenv('REMOTE_ADDR'); 
    // translate his ip to a country code 
    $country geoip_country_code_by_addr($gi$addr); 
    // close the geo database 
    geoip_close($gi); 

    $badcountry = array('IR','CN','RU','SA','NG'); 

    if(
    in_array($country$badcountry)) 
    header('Location: http://www.proxlists.com'); //enter a url or page on your site 
    WiredStorm Hosting Solutions
    █ Lightning Fast Shared and Reseller Hosting
    █ cPanel with Softaculous and 24/7 Email (Ticket) Support
    Biodegradable Sunscreen - Unblock Facebook

  6. #5
    dtkguy's Avatar
    dtkguy is offline Still Learnin'
    Join Date
    Dec 2008
    Posts
    391
    Thanks
    7
    Thanked 164 Times in 108 Posts
    Make sure you're using the most up to date GeoIP.dat file. The free GeoLiteCountry database is updated monthly (paid is updated far more often), and available here :

    Index of /download/geoip/database/GeoLiteCountry

    New IP ranges, etc could be causing some to get through, I really don't know, hmm.

    Also, if you're using Glype, make sure to have hotlinking off, so they are forced to visit the index page first. Else if they jump straight to a browse page, the geoip code on the index will never get triggered.

  7. Thanked by:

    Will.Spencer (24 July, 2009)

  8. #6
    Zash's Avatar
    Zash is offline WiredStorm.com - Lightning Fast Web Hosting
    Join Date
    Feb 2009
    Location
    New York, USA
    Posts
    1,137
    Blog Entries
    1
    Thanks
    64
    Thanked 121 Times in 93 Posts
    Ah, I didn't know it got updated. Mine hasn't been updated in a while. And yes hotlinking is off. Thanks, I'll report back tomorrow.
    WiredStorm Hosting Solutions
    █ Lightning Fast Shared and Reseller Hosting
    █ cPanel with Softaculous and 24/7 Email (Ticket) Support
    Biodegradable Sunscreen - Unblock Facebook

  9. #7
    Josh Manders's Avatar
    Josh Manders is offline Web Developer Extraordinaire
    Join Date
    Jul 2009
    Location
    Dubuque, Iowa, USA
    Posts
    63
    Thanks
    3
    Thanked 15 Times in 10 Posts
    GeoIP is a good database, but I know someone who has been working on improving it and made a free service, I find it easier using his service in my scripts than GeoIP because I don't have to keep my database updated.

    geoPlugin to geolocate your visitors

    Just do this for yourself:

    PHP Code:
    <?php
    $geoData 
    unserialize(file_get_contents('http://www.geoplugin.net/php.gp?ip='.$_SERVER['REMOTE_ADDR']));
    $bad_countries = array('IR''CN''RU''SA''NG'); 
    if(
    in_array($geoData['geoplugin_countryCode'], $bad_countries))
    {
        
    header('Location: http://www.proxlists.com');
    }
    ?>
    More information on his services for PHP > http://www.geoplugin.com/webservices/php

  10. Thanked by:

    Will.Spencer (24 July, 2009), xrvel (22 October, 2009)

  11. #8
    dtkguy's Avatar
    dtkguy is offline Still Learnin'
    Join Date
    Dec 2008
    Posts
    391
    Thanks
    7
    Thanked 164 Times in 108 Posts
    Quote Originally Posted by Killswitch View Post
    GeoIP is a good database, but I know someone who has been working on improving it and made a free service, I find it easier using his service in my scripts than GeoIP because I don't have to keep my database updated.

    geoPlugin to geolocate your visitors

    -snip-
    That's pretty nice of whomever runs that service. I'd just rather not rely on an external site to be up to process my geolocation. I don't mind the 30 seconds a month to update my GeoIP.dat file

  12. #9
    Zash's Avatar
    Zash is offline WiredStorm.com - Lightning Fast Web Hosting
    Join Date
    Feb 2009
    Location
    New York, USA
    Posts
    1,137
    Blog Entries
    1
    Thanks
    64
    Thanked 121 Times in 93 Posts
    Updated dat file seems to be doing great. Thanks for the help!
    WiredStorm Hosting Solutions
    █ Lightning Fast Shared and Reseller Hosting
    █ cPanel with Softaculous and 24/7 Email (Ticket) Support
    Biodegradable Sunscreen - Unblock Facebook

  13. #10
    Josh Manders's Avatar
    Josh Manders is offline Web Developer Extraordinaire
    Join Date
    Jul 2009
    Location
    Dubuque, Iowa, USA
    Posts
    63
    Thanks
    3
    Thanked 15 Times in 10 Posts
    Quote Originally Posted by dtkguy View Post
    That's pretty nice of whomever runs that service. I'd just rather not rely on an external site to be up to process my geolocation. I don't mind the 30 seconds a month to update my GeoIP.dat file
    It's more than just GeoIP, he has other features like local places, so you can do a lot more.

Page 1 of 2 12 LastLast

Similar Threads

  1. Xanga Doesn't Convert Well
    By gavenecko in forum Social Networks
    Replies: 0
    Last Post: 17 December, 2009, 21:13 PM
  2. GeoIP Globally
    By nux in forum Web Hosting
    Replies: 2
    Last Post: 28 October, 2009, 13:33 PM
  3. atproxy.net doesn't support co.cc domains
    By Greyhound in forum Proxy List Support Forum
    Replies: 2
    Last Post: 21 June, 2009, 03:15 AM
  4. Ice cream that doesn't melt?
    By m42 in forum General Chat
    Replies: 3
    Last Post: 14 June, 2009, 04:38 AM
  5. How to use GeoIP on glype ?
    By WebEvader in forum Web Proxies
    Replies: 6
    Last Post: 15 March, 2009, 18:14 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •