SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    SitePoint Member BadCoder's Avatar
    Join Date
    Jan 2012
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Get Country, City of Visitors Easy with PHP 5

    This is full code for PHP

    PHP Code:
    <?php
    // Author: www.easyjquery.com
    $ip $_SERVER['REMOTE_ADDR'];
    // remember chmod 0777 for folder 'cache'
    $file "./cache/".$ip;
    if(!
    file_exists($file)) {
        
    // request
        
    $json file_get_contents("http://api.easyjquery.com/ips/?ip=".$ip."&full=true");
        
    $f fopen($file,"w+");
        
    fwrite($f,$json);
        
    fclose($f);
    } else {
        
    $json file_get_contents($file);
    }

    $json json_decode($json,true);
    echo 
    "<pre>";
    print_r($json);

    ?>
    You can check demo here: [Link To Demo]

    You can use this script to detect spammer, or verify order in shopping cart online, detect IP & Proxy ...

  2. #2
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Gets my region wrong.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  3. #3
    SitePoint Zealot
    Join Date
    May 2007
    Posts
    163
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Gets my region right.

    Hope the site is going to be stable.

  4. #4
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,812
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    That is getting the location of the ISP or proxy server - not the location of your visitor. Your visitor could be on the opposite side of the world.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  5. #5
    SitePoint Member BadCoder's Avatar
    Join Date
    Jan 2012
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Only detect IP by REMOTE_ADDR, in case your visitors use proxy, I have no idea how to check proxy and real ip.


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
  •