少額の報酬で調査にサインアップできる登録フォームがあります。最近、疑わしいエントリが多数見つかりました。Google で翻訳した中国語のサイトを見つけたのですが、基本的にはこの種のサイトにサインアップするための「ハウツー」でした。それ以来、偽物を自動的に除外する方法を突き止めようと取り組んできました。
登録には、うまくいけば人間以外をブロックする「キャプチャ」がありますが、入力されるデータは多くの場合非常に現実的です。調査はバーテンダー向けであり、すべてのフィールドは正当な場所と住所を使用して記入されています. 電話番号はオフになっている可能性がありますが、セルを使用していて、その地域に移動している可能性があります。次の関数を使用して 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 を見つけています (これはスプーフィングされていると確信しています)。
私のコードが不完全なのか、それとも見つけられなかったより良い解決策があるのか わかりません。ありがとう