ppypp伦理天堂,91手机在线视频,免费在线观看黄色毛片,夜夜穞天天穞狠狠穞AV美女按摩

聯系官方銷售客服

1835022288

028-61286886

投訴 已解決 火車頭發布接口 重復的標題不跳過怎么設置 4 0

描述:

下面這段是火車頭自動遠程圖片本地化,并且提取第一張作為縮略圖的接口代碼(2024年12月4日,4.6.4 親測仍然有效,再次感謝分享的樓主)

問題:
這個接口代碼,會對重復標題進行檢測,并且對重復的內容跳過,這對常規站是好事,,
需求:

我需求有點特殊,,需要不跳過,,請問有沒有懂的大佬,幫看看,要怎么改,謝謝!

解決方案
  • 大兵哥
    #1樓 大兵哥(PHP技術) 免費用戶
    2024-12-04 16:54:47
    Chrome 20分鐘48秒 0
    沒看懂
  • <?php
    
    
    $this->_module_init('news'); // news 是模塊目錄
    
    if ($_GET['action'] == 'category') {
        // 顯示欄目
    
        foreach ($this->module['category'] as $t) {
            if ($t['child'] == 0 && $t['tid'] == 1) {
                echo '<h1>'.$t['name'].'<=>'.$t['id'].'</h1>'.PHP_EOL;
            }
        }
    
    } else {
        // 入庫數據
    
        $data = $_REQUEST;
    
        // 發布者id 1
        $data['uid'] = 1;
    
        // 發布者賬號 admin
        $data['author'] = 'admin';
    
        // 主表字段
        $fields[1] = $this->get_cache('table-'.SITE_ID, $this->content_model->dbprefix(SITE_ID.'_'.MOD_DIR));
        $cache = $this->get_cache('table-'.SITE_ID, $this->content_model->dbprefix(SITE_ID.'_'.MOD_DIR.'_category_data'));
        $cache && $fields[1] = array_merge($fields[1], $cache);
    
        // 附表字段
        $fields[0] = $this->get_cache('table-'.SITE_ID, $this->content_model->dbprefix(SITE_ID.'_'.MOD_DIR.'_data_0'));
        $cache = $this->get_cache('table-'.SITE_ID, $this->content_model->dbprefix(SITE_ID.'_'.MOD_DIR.'_category_data_0'));
        $cache && $fields[0] = array_merge($fields[0], $cache);
    
        // 去重復
        $fields[0] = array_unique($fields[0]);
        $fields[1] = array_unique($fields[1]);
    
        $save = [];
    
        // 主表附表歸類
        foreach ($fields as $ismain => $field) {
            foreach ($field as $name) {
                isset($data[$name]) && $save[$ismain][$name] = $data[$name];
            }
        }
            if (!$data['catid']) {
                exit('欄目為空');
            }
    
    /*隨機發欄目,下面的數字是欄目id
    $arr_1 = array("44","45","46","47","48","49","50","51","52","53","54","55","56","57","58","59","60","61","62","63","64","65","66","67","68","69","70","71","72","73","74","75","76","77","78","79","80","81","82","83","84","85");
    
    $randarr= mt_rand(0,count($arr_1)-1);
    
    $data['catid'] = $arr_1[$randarr];
    */
    
    
    
        $save[1]['uid'] = $save[0]['uid'] = $data['uid'];
        $save[1]['catid'] = $save[0]['catid'] = $data['catid'];
    // 提取內容中第一張圖作為縮略圖
      
        $save[1]['url'] = '';
        $save[1]['status'] = 9; //9表示正常發布,1表示審核里面
         $save[1]['hits'] = random_int(50,900);
        $save[1]['displayorder'] = 0;
        $save[1]['link_id'] = 0;
        //$save[1]['comments'] = 0;
      //  $save[1]['avgsort'] = 0;
        $save[1]['inputtime'] = $save[1]['updatetime'] = SYS_TIME + rand(0, 7200);
        $save[1]['inputip'] = '127.0.0.1';
    
    
    
    function myTrim($str)
    
    {
    $search = array(" "," ","\n","\r","\t");
    
    $replace = array("","","","","");
    
    return str_replace($search, $replace, $str);
    
    }
    
    
    $nr=dr_clearhtml($save[0]['content']);
    
        
    $nr=myTrim($nr);
    
    $save[1]['description']=dr_clearhtml(substr($nr,0,400));
    
    $value=$save[0]['content'];
    
       $formsite = '/'; //相對地址時候目標域名
    
        $value = str_replace('src="/', 'src="'.$formsite, $value);
    
        //exit($value);
    
        if (preg_match_all("/(src)=([\"|']?)([^ \"'>]+\.(gif|jpg|jpeg|png))\\2/i", $value, $imgs)) {
    
            foreach ($imgs[3] as $img) {
    
                if (strpos($img, '/api/ueditor/') !== false
    
                    || strpos($img, '/api/umeditor/') !== false) {
    
                    continue;
    
                }
    
                // 下載圖片
    
                if (strpos($img, 'http') === 0) {
    
                    // 正常下載
    
                    // 判斷域名白名單
    
                    $arr = parse_url($img);
    
                    $domain = $arr['host'];
    
                    if ($domain) {
    
                        $sites = WRITEPATH.'config/domain_site.php';
    
                        if (isset($sites[$domain])) {
    
                            // 過濾站點域名
    
                        } elseif (strpos(SYS_UPLOAD_URL, $domain) !== false) {
    
                            // 過濾附件白名單
    
                        } else {
    
                            $zj = 0;
    
                            $remote = \Phpcmf\Service::C()->get_cache('attachment');
    
                            if ($remote) {
    
                                foreach ($remote as $t) {
    
                                    if (strpos($t['url'], $domain) !== false) {
    
                                        $zj = 1;
    
                                        break;
    
                                    }
    
                                }
    
                            }
    
                            if ($zj == 0) {
    
                                // 可以下載文件
    
                                // 同步模式
    
                                // 下載遠程文件
    
                                $rt = \Phpcmf\Service::L('upload')->down_file([
    
                                    'url' => $img,
    
                                    'attachment' => \Phpcmf\Service::M('Attachment')->get_attach_info(intval($field['content']['setting']['option']['attachment'])),
    
                                ]);
    
                                if ($rt['code']) {
    
                                    $att = \Phpcmf\Service::M('Attachment')->save_data($rt['data'], 'ueditor_down_img');
    
                                    if ($att['code']) {
    
                                        // 歸檔成功
    
                                        $value = str_replace($img, $rt['data']['url'], $value);
    
                                        $img = $att['code'];
    
                                    }
    
                                }
    
                                
    
                            }
    
                        }
    
                    }
    
                    
    
                }
    
              
            }
    
        }
    
    
    $save[0]['content']=$value;
      $imgs = dr_get_content_img($save[0]['content']);
        $save[1]['thumb'] = (string)$imgs[0];
    
    
        // 驗證標題重復
        if ($this->content_model->table(SITE_ID.'_'.MOD_DIR)->where('title', $save[1]['title'])->counts()) {
            echo '重復';exit;
        }
    
    
      //  $rt = $this->content_model->save(0, $save);
    $rt = $this->content_model->save_content(0, $save);
    
    
        if ($rt['code']) {
            exit('成功');
        } else {
            exit('失敗');
        }
    
    }
    
    exit;
  • 回復@大兵哥 你好,大兵哥,剛發帖以審核,,代碼還沒復制上去,,,,

    發布接口的代碼如上,,想改成,即使標題重復,也可以發布(不需要跳過)

  • 好像被我自己測試通了,,把這兩段去掉就行了!

    浪費公共資源啊!

        // 去重復
        $fields[0] = array_unique($fields[0]);
        $fields[1] = array_unique($fields[1]);
    
        // 驗證標題重復
        if ($this->content_model->table(SITE_ID.'_'.MOD_DIR)->where('title', $save[1]['title'])->counts()) {
            echo '重復';exit;
        }
    滿意答案
  • @大於:自己測試OK