代码没有语法错误,但是缺少了一些变量的定义。可以参考以下修改:

<input type="text" id="websiteId" placeholder="请输入网站ID"><input type="button" class="btn" value="下载单个id" onClick="downloadSingleWebsite()">

<?php
/** 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>';
}
?>

请注意,代码中的 $action, $type, $start, $options, $fileurl, $table, $DB, save_to_local 都需要根据实际情况进行定义或引入相应的文件

检查下面的代码有没有错误并改成过来input type=text id=websiteId placeholder=请输入网站IDinput type=button class=btn value=下载单个id onClick=downloadSingleWebsite download if $action == down $pagesize = 3; $curpage = $cu

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

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