cURL を使用して、検索エンジンからのものである場合にのみコンテンツを表示できるサイトの HTTP ref を変更しています。
できました!
しかし問題は、サイトが取得する訪問者の IP アドレスが私のものではないということです! これは、ref を変更するために使用しているサイトの IP アドレスです。コードは次のとおりです。
echo geturl('http://example.com', 'http://referring-site.com');
function geturl($url, $referer) {
$headers[] = 'Accept: image/gif, image/x-bitmap, image/jpeg, image/pjpeg,text/html,application/xhtml+xml';
$headers[] = 'Connection: Keep-Alive';
$headers[] = 'Content-type: application/x-www-form-urlencoded;charset=UTF-8';
$useragent = 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.0.3705; .NET CLR 1.1.4322; Media Center PC 4.0)';
$process = curl_init($url);
curl_setopt($process, CURLOPT_HTTPHEADER, $headers);
curl_setopt($process, CURLOPT_HEADER, 0);
curl_setopt($process, CURLOPT_USERAGENT, $useragent);
curl_setopt($process, CURLOPT_REFERER, $referer);
curl_setopt($process, CURLOPT_TIMEOUT, 30);
curl_setopt($process, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($process, CURLOPT_FOLLOWLOCATION, 1);
$return = curl_exec($process);
curl_close($process);
return $return;
}
そのコードを使用するとしましょう
mysite.com
したがって、example.com は HTTP ref として refer-site.com を参照しますが、訪問者の IP は mysite.com と同じであると見なします !!!
コードを使用しているサイトの IP ではなく、訪問者の実際の IP アドレスを取得するにはどうすればよいですか?
交換してみました
return $return;
と
return "<?php
header( 'Location: http://example.com' ) ;
?>";
また
echo '<META HTTP-EQUIV='Refresh' Content='0; URL=http://example.com'>';
しかし、うまくいきません!