訪問頁面a.php:
<?php
$headers['CLIENT-IP'] = '219.153.191.4';
$headers['X-FORWARDED-FOR'] = '219.153.191.4';
$headerArr = array();
foreach( $headers as $n => $v ) {
$headerArr[] = $n .':' . $v;
}
ob_start();
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, "http://192.168.1.116/b.php");//處理頁面
curl_setopt ($ch, CURLOPT_HTTPHEADER , $headerArr ); //構造IP
curl_setopt($ch, CURLOPT_USERAGENT, "Dalvik/1.6.0 (Linux; U; Android 4.1.2; DROID RAZR HD Build/9.8.1Q-62_VQW_MR-2)");//不模擬手機訪問則註釋此行
curl_setopt ($ch, CURLOPT_REFERER, "http:// "); //構造訪問來源
curl_setopt( $ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close ($ch);
$out = ob_get_contents();
ob_clean();
echo $out;
?>
處理頁面b.php:
<?php
$url = "http://ad.cqjtbbs.com/do.php?id=13452527672&t=5";//目標地址
$ch = curl_init($url); //初始化
curl_setopt($ch, CURLOPT_HEADER, 0); // 不返回header部分
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // 返回字串,而非直接輸出
curl_setopt($ch, CURLOPT_USERAGENT, "Dalvik/1.6.0 (Linux; U; Android 4.1.2; DROID RAZR HD Build/9.8.1Q-62_VQW_MR-2)");//不模擬手機訪問則註釋此行
curl_setopt($ch, CURLOPT_REFERER, "http://");//構造訪問來源
$response = curl_exec($ch);
curl_close($ch);
print_r($response);
function getClientIp() {
if (!empty($_SERVER["HTTP_CLIENT_IP"]))
$ip = $_SERVER["HTTP_CLIENT_IP"];
else if (!empty($_SERVER["HTTP_X_FORWARDED_FOR"]))
$ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
else if (!empty($_SERVER["REMOTE_ADDR"]))
$ip = $_SERVER["REMOTE_ADDR"];
else
$ip = "err";
return $ip;
}
echo "IP: " . getClientIp() . "";
echo "referer: " . $_SERVER["HTTP_REFERER"];
?>
評論(1)