class DownAction extends Action{
public function index(){
set_time_limit(0);
$item_mod = M('item');
$start=$_GET['start'];
$where['img']=array('like','%http://%');
$count=$item_mod->count();
$items_info=$item_mod->field('id,img')->where($where)->limit('0,100')->select();
if ($items_info){
$dir=date("Ymd");
mkdir('./Uploads/LocalItems/'.$dir);
foreach ($items_info as $item){
preg_match('/^(http:\/\/)/si',$item['img'],$result);
if ($result){
$type = end(explode( '.', $item['img'] ));
import("@.ORG.Http");
$http=new Http();
$http->curlDownload($item['img'].'_100x1000.jpg','Uploads/LocalItems/'.$dir.'/'.$type.'_100x1000.'.$type);
$http->curlDownload($item['img'].'_210x1000.jpg','Uploads/LocalItems/'.$dir.'/'.$type.'_210x1000.'.$type);
$http->curlDownload($item['img'].'_350x1000.jpg','Uploads/LocalItems/'.$dir.'/'.$type.'_350x1000.'.$type);
$http->curlDownload($item['img'].'_500x1000.jpg','Uploads/LocalItems/'.$dir.'/'.$type.'_500x1000.'.$type);
$data['img']=C('web_path').'Uploads/LocalItems/'.$dir.'/'.$type;
$item_mod->where('id='.$item['id'])->save($data);
}
}
echo '<span style="color:#0099CC;font-size:14px;line-height:20px;">任务完成</span>';
if (($start+100) < 900){
sleep(1);
$start +=100;
$url = C('web_path')."index.php?g=admin&m=Down&a=index&start=$start"; $this->redirect($url);
}
}else {
$this->error('所有远程图片均已下载到本地');
} $this->success('生成本地图片成功');
}
这段代码到底有什么不同啊 怎么就只能采集淘宝这类地址的jpg?http://x.x.x.taobao.com/x/xx/xx/xx.jpg