dedecms中的:
if(!empty($saveremoteimg))
{
$body = stripslashes($body);
$img_array = array();
preg_match_all(/(src|src)=[\|'| ]{0,}(http:\/\/(.*)\.(gif|jpg|jpeg|bmp|png))/isu,$body,$img_array);
$img_array = array_unique($img_array[2]);
set_time_limit(0);
$imgurl = $img_dir./.strftime(%y%m%d,time());
$imgpath = $base_dir.$imgurl;
$millisecond = strftime(%h%m%s,time());
if(!is_dir($imgpath)) @mkdir($imgpath,0777);
foreach($img_array as $key =>$value)
{
$value = trim($value);
$get_file = @file_get_contents($value);
$rndfilename = $imgpath./.$millisecond.$key...substr($value,-3,3);
$fileurl = $imgurl./.$millisecond.$key...substr($value,-3,3);
if($get_file)
{
$fp = @fopen($rndfilename,w);
@fwrite($fp,$get_file);
@fclose($fp);
}
$body = ereg_replace($value,$fileurl,$body);
}
$body = addslashes($body);
}
http://www.bkjia.com/phpjc/318939.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/318939.htmltecharticle?php functiongrabimage($url,$filename=){ if($url==):returnfalse;endif; if($filename==){ $ext=strrchr($url,.); if($ext!=.gif$ext!=.jpg):returnfalse;endif; $filename=date(...
