我们有一个注册表,人们可以在其中注册参加调查以获得少量补偿。最近我们发现了很多可疑条目。我找到了一个我通过谷歌翻译的中文网站,它基本上是一个“如何”注册这些网站的方法。从那以后,我一直在努力寻找一种自动过滤掉虚假信息的方法。
注册有一个“验证码”,希望能阻止非人类,但在许多情况下,输入的数据是非常真实的。该调查针对调酒师,所有字段均使用合法位置和地址填写。电话号码可能已关闭,但他们可能正在使用手机并搬到该地区。我一直在尝试通过使用以下功能捕获 IP 信息和国家/地区数据来进行筛选:
// this function is necessary since allow_url_fopen is disabled by default in php.ini in PHP >5.
function my_file_get_contents($file_path) {
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $file_path);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 1);
$buffer = curl_exec($ch);
curl_close($ch);
return $buffer;
}
function getInfoFromIP(){
// get correct IP in case of a proxy
if (!empty($_SERVER['HTTP_CLIENT_IP'])){ // shared ip
$real_ip=$_SERVER['HTTP_CLIENT_IP'];
}
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){ // ip is from proxy
$real_ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
}
else{
$real_ip=$_SERVER['REMOTE_ADDR'];
}
//verify the IP address for the
ip2long($real_ip)== -1 || ip2long($real_ip) === false ? trigger_error("Invalid IP Passed: ", E_USER_ERROR) : "";
$ipDetailArray=array(); //initialize a blank array
$ipDetailArray['ip'] = $real_ip; //assign ip number to the array
//get the XML result from hostip.info using custom lookup function
$xml = my_file_get_contents("http://api.hostip.info/?ip=".$real_ip);
//regex to get the country name from <countryName>INFO</countryName>
preg_match("@<countryName>(.*?)</countryName>@si",$xml,$countryInfoArray);
$ipDetailArray['country'] = $countryInfoArray[1]; //assign country name to the array
//get the country name inside the node <countryName> and </countryName>
preg_match("@<countryAbbrev>(.*?)</countryAbbrev>@si",$xml,$ccInfoArray);
$ipDetailArray['country_code'] = $ccInfoArray[1]; //assign country code to array
//return the array containing ip, country and country code
return $ipDetailArray;
}
然后我一直在手动检查和删除出现在美国以外的那些(这是酒吧和调查员必须参与的地方)。我仍然发现许多带有美国 IP 列表的可疑 IP(我确定这些 IP 是被欺骗的)。
不确定我的代码是否不完整,或者我找不到更好的解决方案。谢谢