迅睿CMS框架是一款PHP8高性能·簡單易用的CMS開源開發(fā)框架,基于MIT開源許可協(xié)議發(fā)布,免費且不限制商業(yè)使用,是免費開源的產(chǎn)品,以萬端互聯(lián)為設計理念,支持的微信公眾號、小程序、APP客戶端、移動端網(wǎng)站、PC網(wǎng)站等多終端式管理系統(tǒng)。
聯(lián)系官方銷售客服
1835022288
028-61286886
后臺有這個欄目 但是火車頭就是獲取不到欄目,我手動填寫了也提示沒有欄目.
這個要查查火車頭軟件設置里面是否寫對了
參考文檔:《火車頭內(nèi)容采集范例》
回復@迅睿開源社區(qū)技術(shù)-小白
<?php $this->_module_init('baike'); // baike 是模塊目錄 if ($_GET['action'] == 'category') { // 顯示欄目 if (!$this->module['category']) { echo '模塊【' . $this->module['dirname'] . '】沒有創(chuàng)建欄目'; } foreach ($this->module['category'] as $t) { if ($t['child'] == 0 && $t['tid'] == 1) { echo '<h1>' . $t['name'] . '<=>' . $t['id'] . '</h1>' . PHP_EOL; } } } else { // 入庫數(shù)據(jù) $data = $_REQUEST; // 發(fā)布者id 1 $data['uid'] = 1; // 發(fā)布者賬號 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')); // 去重復 $fields[0] = array_unique($fields[0]); $fields[1] = array_unique($fields[1]); // 格式化入庫字段 // 一般是格式化非文本類的字段(例如多文件上傳、復選框、聯(lián)動字段等等) // 這里需要按采集資料的格式入庫格式化字段, // 開始歸類存儲 $save = []; // 主表附表歸類 foreach ($fields as $ismain => $field) { foreach ($field as $name) { isset($data[$name]) && $save[$ismain][$name] = $data[$name]; } } if (!$data['catid']) { exit('欄目為空'); } $save[1]['uid'] = $save[0]['uid'] = $data['uid']; $save[1]['catid'] = $save[0]['catid'] = $data['catid']; $save[1]['url'] = ''; $save[1]['status'] = 9; //9表示正常發(fā)布,1表示審核里面 $save[1]['hits'] = 0; $save[1]['displayorder'] = 0; $save[1]['link_id'] = 0; $save[1]['inputtime'] = $save[1]['updatetime'] = SYS_TIME + rand(0, 7200); $save[1]['inputip'] = '127.0.0.1'; //$save[1]['keywords'] = dr_get_keywords( $save[1]['title']); // 按插件提取關(guān)鍵詞 //$save[1]['description'] = dr_get_description( $save[0]['content'], 100); // 在內(nèi)容里面提取100個子作為描述 // 驗證標題重復 if ($this->content_model->table(SITE_ID . '_' . MOD_DIR)->where('title', $save[1]['title'])->counts()) { echo '重復'; exit; } // 文檔內(nèi)容 $value = $data['content']; // 第一張作為縮略圖 $slt = 1; // 是否下載圖片 $yct = 1; $base64 = strpos($value, ';base64,'); // 附件入庫標記字符 $rid = md5(FC_NOW_URL.\Phpcmf\Service::L('input')->get_user_agent().\Phpcmf\Service::L('input')->ip_address().\Phpcmf\Service::C()->uid); // 下載遠程圖片 if ($yct || $slt || $base64) { $temp = preg_replace('/<pre(.*)<\/pre>/siU', '', $value); $temp = preg_replace('/<code(.*)<\/code>/siU', '', $temp); if (preg_match_all("/(src)=([\"|']?)([^ \"'>]+)\\2/i", $temp, $imgs)) { foreach ($imgs[3] as $img) { if ($base64 && preg_match('/^(data:\s*image\/(\w+);base64,)/i', $img, $result)) { // 處理圖片 $ext = strtolower($result[2]); if (!in_array($ext, ['png', 'jpg', 'jpeg', 'gif', 'webp'])) { continue; } $content = base64_decode(str_replace($result[1], '', $img)); if (strlen($content) > 30000000) { continue; } $rt = \Phpcmf\Service::L('upload')->base64_image([ 'ext' => $ext, 'content' => $content, 'watermark' => \Phpcmf\Service::C()->get_cache('site', SITE_ID, 'watermark', 'ueditor') || $field['setting']['option']['watermark'] ? 1 : 0, 'attachment' => \Phpcmf\Service::M('Attachment')->get_attach_info(intval($field['setting']['option']['attachment']), $field['setting']['option']['image_reduce']), ]); if (!$rt['code']) { continue; } $att = \Phpcmf\Service::M('Attachment')->save_data($rt['data'], 'ueditor:'.$rid); if ($att['code']) { // 歸檔成功 $value = str_replace($img, $rt['data']['url'], $value); $img = $att['code']; // 標記附件 \Phpcmf\Service::M('Attachment')->save_ueditor_aid($rid, $att['code']); } } else { $ext = _get_image_ext($img); if (!$ext) { continue; } // 下載圖片 if ($yct && strpos($img, 'http') === 0) { if (dr_is_app('mfile') && \Phpcmf\Service::M('mfile', 'mfile')->check_upload(\Phpcmf\Service::C()->uid)) { //用戶存儲空間已滿 } else { // 正常下載 // 判斷域名白名單 $arr = parse_url($img); $domain = $arr['host']; if ($domain) { $sites = \Phpcmf\Service::R(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, 'timeout' => 5, 'watermark' => \Phpcmf\Service::C()->get_cache('site', SITE_ID, 'watermark', 'ueditor') || $field['setting']['option']['watermark'] ? 1 : 0, 'attachment' => \Phpcmf\Service::M('Attachment')->get_attach_info(intval($field['setting']['option']['attachment']), $field['setting']['option']['image_reduce']), 'file_ext' => $ext, ]); if ($rt['code']) { $att = \Phpcmf\Service::M('Attachment')->save_data($rt['data'], 'ueditor:'.$rid); if ($att['code']) { // 歸檔成功 $value = str_replace($img, $rt['data']['url'], $value); $img = $att['code']; // 標記附件 \Phpcmf\Service::M('Attachment')->save_ueditor_aid($rid, $att['code']); } } } } } } } } // 縮略圖 if ($img && $slt) { $_field = \Phpcmf\Service::L('form')->fields; if (isset($_field['thumb']) && $_field['thumb']['fieldtype'] == 'File' && !\Phpcmf\Service::L('Field')->data[$_field['thumb']['ismain']]['thumb']) { if (!is_numeric($img)) { // 下載縮略圖 // 判斷域名白名單 $arr = parse_url($img); $domain = $arr['host']; if ($domain) { $file = dr_catcher_data($img, 8); if (!$file) { CI_DEBUG && log_message('debug', '服務器無法下載圖片:'.$img); } else { // 嘗試找一找附件庫 $att = \Phpcmf\Service::M()->table('attachment')->like('related', 'ueditor')->where('filemd5', md5($file))->getRow(); if ($att) { $img = $att['id']; } else { // 下載歸檔 $rt = \Phpcmf\Service::L('upload')->down_file([ 'url' => $img, 'timeout' => 5, 'watermark' => \Phpcmf\Service::C()->get_cache('site', SITE_ID, 'watermark', 'ueditor') || $field['setting']['option']['watermark'] ? 1 : 0, 'attachment' => \Phpcmf\Service::M('Attachment')->get_attach_info(intval($field['setting']['option']['attachment']), $field['setting']['option']['image_reduce']), 'file_ext' => $ext, 'file_content' => $file, ]); if ($rt['code']) { $att = \Phpcmf\Service::M('Attachment')->save_data($rt['data'], 'ueditor:'.$rid); if ($att['code']) { // 歸檔成功 $value = str_replace($img, $rt['data']['url'], $value); $img = $att['code']; // 標記附件 \Phpcmf\Service::M('Attachment')->save_ueditor_aid($rid, $att['code']); } } } } } } \Phpcmf\Service::L('Field')->data[$_field['thumb']['ismain']]['thumb'] = $_POST['data']['thumb'] = $img; } } } } } // 最后得到的文檔內(nèi)容 $save[0]['content'] = $value; // 最后得到的縮略圖 $save[1]['thumb'] = $img; $rt = $this->content_model->save_content(0, $save); if ($rt['code']) { /* // 用于發(fā)布成功后生成靜態(tài)文件代碼 //dr_html_auth($_SERVER['SERVER_ADDR']); //dr_catcher_data(SITE_URL.'index.php?s='.MOD_DIR.'&c=html&m=showfile&id='.$rt['id']); $atcode = 'chtml_'.SITE_ID.'_'.MOD_DIR.'_'.$rt['code']; \Phpcmf\Service::L('cache')->set_auth_data($atcode, $rt['code'], SITE_ID); dr_catcher_data(SITE_URL.'index.php?s='.MOD_DIR.'&c=html&m=showfile&id='.$rt['code'].'&atcode='.$atcode); */ // 處理推薦位 if ($data['flag']) { $myflag = explode(',', $data['flag']); foreach ($myflag as $i) { if (isset($this->module['setting']['flag'][$i])) { $this->content_model->insert_flag((int)$i, $rt['code'], $rt['data'][1]['uid'], $rt['data'][1]['catid']); } } } exit('成功'); } else { exit('失敗'); } } // 獲取遠程附件擴展名 function _get_image_ext($url) { if (strlen($url) > 300) { return ''; } $arr = ['gif', 'jpg', 'jpeg', 'png', 'webp']; $ext = str_replace('.', '', trim(strtolower(strrchr($url, '.')), '.')); if ($ext && in_array($ext, $arr)) { return $ext; // 滿足擴展名 } elseif ($ext && strlen($ext) < 4) { //CI_DEBUG && log_message('error', '此路徑不是遠程圖片:'.$url); return ''; // 表示不是圖片擴展名了 } foreach ($arr as $t) { if (stripos($url, $t) !== false) { return $t; } } $rt = getimagesize($url); if ($rt && $rt['mime']) { foreach ($arr as $t) { if (stripos($rt['mime'], $t) !== false) { return $t; } } } CI_DEBUG && log_message('debug', '服務器無法獲取遠程圖片的擴展名:'.dr_safe_replace($url)); return ''; } exit;
回復@迅睿開源社區(qū)技術(shù)-小白 我上個月還能用,中途也沒動過配置,現(xiàn)在也使用不了
回復@SEO優(yōu)化推廣 怎么解決的?
這個要查查火車頭軟件設置里面是否寫對了
參考文檔:《火車頭內(nèi)容采集范例》
回復@迅睿開源社區(qū)技術(shù)-小白
回復@迅睿開源社區(qū)技術(shù)-小白 我上個月還能用,中途也沒動過配置,現(xiàn)在也使用不了
回復@SEO優(yōu)化推廣 怎么解決的?