我正在尝试收集有关访问者的信息并将其信息保存到数据库。
我今天完成了数据库和php部分(有一些帮助),当我测试系统时,它通过计算机,平板电脑,手机使用WiFi保存IP地址和其他信息,但它不保存 - 收集有关手机的任何信息细胞数据。
可能是什么问题?
以下是我正在使用的代码的部分内容;
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']."')";
为什么它不收集使用手机数据的手机信息?
提前致谢。
答案 0 :(得分:1)
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;
}
我希望它可以帮到你