我們有一個註冊表單,人們可以註冊參與調查以獲取小額賠償。最近我們發現了很多可疑的條目。我追蹤了一個我通過谷歌翻譯的中文網站,它基本上是一個「如何」註冊這些網站。我一直在努力尋找一種方法來自動過濾掉那些虛假的東西。阻止欺詐表單條目
註冊有一個「驗證碼」來希望阻止非人類,但在許多情況下輸入的數據是非常現實的。調查是調酒師和所有的領域填寫使用合法的地點和地址。電話號碼可能關閉,但他們可能正在使用一個小區並移入該區域。我一直在試圖通過屏幕使用以下功能捕獲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相關的可疑犯罪嫌疑人(我確信這些犯罪都是僞造的)。
不知道我的代碼是否不完整,或者是否有更好的解決方案,我找不到。由於
像http://www.parkansky.com/china.htm和http://www.wizcrafts.net/chinese-blocklist.html可能是值得的讀。 – liftarn 2014-02-07 09:06:04