/** download */ if ($action == 'down') { $pagesize = 3; $curpage = $curpage + 1;

$where = "web_status=3";
if ($type == 'part') {
    $where .= " AND web_pic=''";
}

$id = isset($_GET['id']) ? intval($_GET['id']) : 0; // 获取输入的id

if ($id > 0) {
    $where .= " AND web_id=$id"; // 根据输入的id筛选记录
}

$websites = $DB->fetch_all("SELECT web_id, web_name, web_url FROM $table WHERE $where ORDER BY web_id DESC LIMIT $start, $pagesize");
$totalnum = $DB->get_count($table, $where);
$totalpage = ceil($totalnum / $pagesize);

echo '<div style="font-size: 12px; line-height: 25px; padding: 10px;">';
if ($curpage <= $totalpage) {
    $savepath = '../'.$options['upload_dir'].'/website/';

    echo '<meta http-equiv="refresh" content=3;url="'.$fileurl.'?act='.$action.'&type='.$type.'&page='.$curpage.'">';
    echo '<h3>共需采集 '.$totalpage.' 页,每次下载 '.$pagesize.' 张,当前第 '.$curpage.' 页,正在下载远程图片...</h3>';
    foreach ($websites as $row) {
        $filepath = save_to_local(str_replace('/', '.', $row['web_url']), $savepath);
        $filesize = filesize($filepath);

        if ($filesize < 10240) {
            $newpath = str_replace('../image/', '', $filepath);
            if (!empty($newpath)) {
                $status = '下载成功!';
                $DB->update($table, array('web_pic' => $newpath), array('web_id' => $row['web_id']));
            } else {
                $status = '下载失败!';
            }
        } else {
            $status = '文件大小超过限制!';
        }
        echo $row['web_id'].' - '.$row['web_name'].' ------ '.$status.'<br />';
    }
    echo '<h3>本页已采集完成,5秒后将自动采集下一页...</h3>';
} else {
    echo '<h3>已经将所有的远程图片本地化!</h3>';    
}
echo '</div>';
把下面的代码修改成可以获取单个id的 download if $action == down $pagesize = 3; $curpage = $curpage + 1; $where = web_status=3; if $type == part $where = AND web_pic=; $id = isset$_GETid i

原文地址: http://www.cveoy.top/t/topic/iT5p 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录