Can't gather IP of the visitor using Celular Data

144 views Asked by At

I am trying to gather information about visitors and saving their info to database.

Ive finished database and php part today ( with some help ), when I tested the system, It saves IP address and other information via computers, tablets, phones using WiFi but it doesn't save-gather any information about phones using celular data.

What could be the problem ?

Here are the partial part of the code im using ;

include("counter/counter.php");
    $counter = new counter();


    $conn = mysql_connect($sn,$un,$pw);//server, username and password are your server address and access details

    if(!$conn)
    die("cannot connect to mysql server" . mysql_error());

    mysql_select_db($db, $conn);

    $visitor_browser = getBrowserType();
    $ip_data = get_ip_info($ip);

    require_once("ip.codehelper.io.php");
    require_once("php_fast_cache.php");

    $_ip = new ip_codehelper();

    $real_client_ip_address = $_ip->getRealIP();
    $visitor_location       = $_ip->getLocation($real_client_ip_address);

    $guest_ip   = $visitor_location['IP'];
    $guest_country = $visitor_location['CountryName'];
    $guest_city  = $visitor_location['CityName'];
    $guest_state = $visitor_location['RegionName'];

    $sql = "INSERT INTO `visitor_info` (ipAdresi, browserTuru, sehirIsmi, sehirX, sehirY, bolgeIsmi, ulkeIsmi, ulkeKodu, ulkeX, ulkeY, saatTuruSehir, kitaIsmi, kitaKodu, toplamNufus, aramaKodu, alanCapi, dilTuru, paraBirimi, elektrikTuru) VALUES('".$real_client_ip_address."', '".$_SERVER['HTTP_USER_AGENT']."', '".$visitor_location['CityName']."', '".$visitor_location['CityLatitude']."', '".$visitor_location['CityLongitude']."', '".$visitor_location['RegionName']."', '".$visitor_location['CountryName']."', '".$visitor_location['Country']."', '".$visitor_location['CountryLatitude']."', '".$visitor_location['CountryLongitude']."', '".$visitor_location['LocalTimeZone']."', '".$visitor_location['ContinentName']."', '".$visitor_location['ContinentCode']."', '".$visitor_location['Population']."', '".$visitor_location['CallingCode']."', '".$visitor_location['AreaSqKm']."', '".$visitor_location['Languages']."', '".$visitor_location['Currency']."', '".$visitor_location['Electrical']."')"; 

Why it doesn't gather information of phones using cellular data?

Thanks in advance.

1

There are 1 answers

2
amarjit singh On BEST ANSWER
 protected function getCountryNameFromIP()
     {

        $ip  = $_SERVER['REMOTE_ADDR'];
        $opts = array(
        'http'=>array(
        'method'=>"GET",
        'header'=>"Accept-language: en\r\n" .
                  "Cookie: foo=bar\r\n"
           )
        );

        $context = stream_context_create($opts);
        $answerIP = @file_get_contents("http://api.ipinfodb.com/v3/ip-country/?key=4b585e37503a519a408dc17878e6ec04fa963e1b946c567722538d9431c2d5cb&format=xml&ip=$ip" ,false,$context);

        if(isset($answerIP) && $answerIP !="")
        {
            $theResJ            =   simplexml_load_string($answerIP);
            $last_login_ip_cn   =   $theResJ->countryName;


            /**
            *   $last_login_ip_cc   =   $theResJ->countryCode;
            *   $last_login_ip_rc   =   $theResJ->regionCode;
            *   $last_login_ip_rn   =   $theResJ->regionName;
            *   $last_login_ip_cp   =   $theResJ->cityName;
            *   $last_login_ip_lat  =   $theResJ->latitude;
            *   $last_login_ip_lng  =   $theResJ->longitude;
            *   $last_login_zip_code=   $theResJ->zipCode;
            */
        }
        else
        {
            $last_login_ip_cn   =   "";
            /**
            *   $last_login_ip_cc   =   "";
            *   $last_login_ip_rc   =   "";
            *   $last_login_ip_rn   =   "";
            *   $last_login_ip_cp   =   "";
            * $last_login_ip_lat    =   "";
            *   $last_login_ip_lng  =   "";
            *   $last_login_zip_code=   "";
            */
        }

        return $last_login_ip_cn;
       }

I hope it helps you