PHP头条
热点:

ecshop远程商品详情图片本地化-PHP源码


php代码

无远程图片";
if(preg_match('/(http:\/\/)/i', $row['goods_desc'])){
	$aa="Go Get It";
}
	echo $row['goods_id']." ".$row['goods_name']." ".$aa."
"; } exit(); } sleep(1); $sql="select `goods_desc` from `p_goods` where `goods_id`='$id' limit 1"; $res=mysql_fetch_array(mysql_query($sql)); preg_match_all('/src=[\'|"]([^"|^\']+)[\'|"]/i', $res[0], $picurl); $urlArr=$picurl[1]; /* print_r($urlArr); die(); $urlArr[]="http://static.oschina.net/uploads/user/129/258733_50.jpg"; $urlArr[]="http://static.oschina.net/uploads/img/201302/16195715_kPci.png"; */ $num= isset($_GET['num']) ? $_GET['num'] : 1; $all=count($urlArr); $url=$urlArr[$num-1]; if(!preg_match('/(http:\/\/)/i', $url)){ if($num >= $all) { exit('
all done!'); } echo $url."
已处理"; echo "《script》location.href='?id={$id}&num=".($num+1)."'《script》"; exit(); } $array=@get_headers($url,1); echo $url."

"; if(preg_match('/200/',$array[0])){ ob_start(); readfile($url); $img = ob_get_contents(); ob_end_clean(); $dir="images/goods_desc"; if (!file_exists($dir)) { mkdir($dir, 0777); } $filename=$dir."/".mt_rand(11111,9999999999).time().".jpg"; $f=fopen($filename,'a'); $fres=fwrite($f,$img); fclose($f); if($fres!=false){ $goods_desc=str_replace($url,"/".$filename,$res[0]); $sql="update `p_goods` set `goods_desc` = '$goods_desc' where `goods_id`='$id' limit 1 "; mysql_query($sql); } } echo $num."/".$all; if($num >= $all) { exit('
all done!'); } else{ echo "《script》location.href='?id={$id}&num=".($num+1)."'《script》"; } ?>

www.phpzy.comtrue/php/37792.htmlTechArticleecshop远程商品详情图片本地化-PHP源码 php代码 无远程图片 ";if(preg_match(/(http:\/\/)/i, $row[goods_desc])){$aa="Go Get It";}echo $row[goods_id]." ".$row[goods_name]." ".$aa." ";}exit();}sleep(1);$sql="select `goods_desc`...

相关文章

PHP之友评论

今天推荐