1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Need a simple geo redirect script

Discussion in 'General Scripting Chat' started by SEO Sniper, Dec 4, 2015.

  1. SEO Sniper

    SEO Sniper Registered Member

    Joined:
    May 17, 2015
    Messages:
    80
    Likes Received:
    10
    Hey guys,

    I need a way to filter tier 1 traffic in my landing page. Any geo redirect script you guys can point out? Thanks
     
  2. shesthere

    shesthere Newbie

    Joined:
    Dec 6, 2015
    Messages:
    9
    Likes Received:
    0
    Occupation:
    part time spammer
    Location:
    eu
    Home Page:
    "geo redirect script php" returns a ton of results. Did that not work for you? Anything specific you are looking for?
     
  3. islandman1010

    islandman1010 Elite Member

    Joined:
    May 10, 2008
    Messages:
    1,761
    Likes Received:
    273
  4. itz_styx

    itz_styx Power Member

    Joined:
    May 8, 2012
    Messages:
    675
    Likes Received:
    343
    Occupation:
    CEO / Admin / Developer
    Location:
    /dev/mem
    Home Page:
    here you go:

    Code:
    <?php
    /* quick and dirty GEO cloaking script
       by styx @ argo-content.com 2014 */
    
    
       $geo[0][0]='DE';
       $geo[0][1]='http://google.com';
       $geo[1][0]='US';
       $geo[1][1]='http://aol.com';
    
    
       $cnt=sizeof($geo);
       $ip=$_SERVER['REMOTE_ADDR'];
       if(isset($ip)and&ip2long($ip) !== false) {
          $fp=fsockopen("asn.shadowserver.org",43,$ern,$ers,20);
          if(!$fp) { die("$ern:$ers\n"); }
          $data="begin origin\n$ip\nend\n";
          fwrite($fp,$data);
          while(!feof($fp)) {
             $output.=fgets($fp,255);
          }
          fclose($fp);
          $out=explode('|',$output);
          $match=trim($out[4]);
          for($i=0;$i<$cnt;$i++) {
             if($match===$geo[$i][0]) {
                $u=$geo[$i][1];
                header("Location: $u");
             }
          }
       }
    ?>
    
     
  5. jsmith2

    jsmith2 Newbie

    Joined:
    Jul 27, 2008
    Messages:
    14
    Likes Received:
    3
    Either use a script like above that connects to a third-party lookup server, or grab the free geoip database from MaxMind and roll your own.
     
  6. DDuce

    DDuce Jr. VIP Jr. VIP

    Joined:
    Nov 11, 2011
    Messages:
    226
    Likes Received:
    95
    Location:
    Right here
    You could also try a Geo or latency based DNS solution. You'll need multiple servers for it though.
     
  7. itz_styx

    itz_styx Power Member

    Joined:
    May 8, 2012
    Messages:
    675
    Likes Received:
    343
    Occupation:
    CEO / Admin / Developer
    Location:
    /dev/mem
    Home Page:
    latency is just guess work, its too unreliable..