联系官方销售客服

1835022288

028-61286886

应用插件 版主:官方插件技术组
无法获取主站之外的其他站点的分类,无法发布到内容
类型:迅睿CMS 更新时间:2021-10-04 21:37:56
插件 多网站系统 V4.5
应用作者 迅睿官方团队
发布时间 2019-07-08 08:10:35
更新时间 2024-12-18 23:25:58

官网的多网站系统,使用火车头采集器,无法获取主站之外的其他站点的分类,无法发布到内容。

切换到其他站点后台,看到有火车头采集插件,然后拷贝了 dayrui,My 2个目录,把插件也拷贝到了其他站点的站点目录,然后返回到火车头采集插件里再测试获取分类,依然获取不到。



插件版权:官方插件
插件名称:多网站系统

插件教程:https://www.xunruicms.com/doc/app-423.html

回帖
  • 迅睿粉丝
    #1楼    迅睿粉丝
    2021-10-03 16:35:06
    Chrome 0
    $this->_module_init('news', 222); // news 是模块目录,222是站点id
    参考文档:《火车头内容采集范例》
  • 迅睿粉丝
    #2楼    迅睿粉丝
    2021-10-03 17:33:27
    Chrome 0
    第一个问题:下面的代码是我用的火车头采集插件的代码,帮我看看应该怎么改;第二个问题:多站点插件,其他站点是宝塔单独创建,并非主站子目录,所以其他站点的站点目录根本没有火车头采集插件,是否需要把主目录插件的文件按照主目录的结构拷贝过来?官方插件技术-何老师
    <?php
    
    /**
     * 火车采集器接口
     */
    namespace Phpcmf\Controllers;
    
    use Phpcmf\Service;
    use Phpcmf\Table;
    
    class Locomotive extends Table {
    
        protected $model = "news";
        protected $inputip = '';
        protected $u_id = 1;
    
        public $uid = 1;
    
        /**
         * 构造函数
         */
        public function __construct(...$params) {
    
            if (!defined('APP_LOCOMOTIVE')) exit('入口文件错误');
            parent::__construct(...$params);
            $this->is_data = 1;
    
            $config = \Phpcmf\Service::M()->db->table('locomotive_config')
                ->select('code,random,release,draft,contentupdate,hits_min,hits_max,isshare')
                ->get()->getResultArray();
            $this->share = $config[0];
            $this->alone = $config[1];
            $this->book = $config[2];
            $this->bbs = $config[3];
        }
    
        public function getCate(){
            $auth = $this->share['code'];
            $this->input = Service::L('input');
            if ($this->input->get('auth') != $auth) exit('权限认证失败');
    
            $cate = \Phpcmf\Service::M()->db->table(SITE_ID.'_share_category')->get()->getResultArray();
            foreach ($cate as $ca) {
                if($ca['mid'] != '' && $ca['tid'] == 1 && $ca['child'] == 0){
                    echo '<h1>'.$ca['name'].'<=>'.$ca['id'].'</h1>'.PHP_EOL;
                }
            }
        }
    
        /**
         * 采集入库
         */
        public function add() {
            $auth = $this->share['code'];
            $draft = $this->share['draft'];
            $isupdate = $this->share['contentupdate'];
            $hits_min = $this->share['hits_min'];
            $hits_max = $this->share['hits_max'];
    
            $this->input = Service::L('input');
    
            if ($this->input->get('auth') != $auth) exit('权限认证失败');
    
            if ($this->share['release'] != 1) exit('已关闭发布状态');
    
            $add = array();
            $data = $this->input->request('data');
    
            $catename = \Phpcmf\Service::M()->db->table(SITE_ID.'_share_category')
                    ->where('id', (int)$data['catid'])
                    ->get()->getResultArray();
    
            $this->model = $catename[0]['mid'];
            $this->content_model = \Phpcmf\Service::M('Content', $this->model);
            $this->_module_init($this->model, SITE_ID, $this->module['share']);
    
            if (!$data['catid']) exit('栏目不存在');
            if (!$data['catid'] || !$data['title']) exit('数据不完整');
            // 按字段来归类
            $field = $this->get_cache('module-'.SITE_ID.'-'.$this->model, 'field');
            foreach ($field as $t) {
                $name = $t['fieldname'];
                try{
                    //单文件
                    if ($t['fieldtype'] == "File"){
                        if ($data[$name]){
                      $data[$name] = dr_get_file($this->down_file(trim($data[$name])));
                        }
                    }
                    //多文件
                    if ($t['fieldtype'] == "Files"){
                        if (stripos($data[$name],"|") !== false){
                            $data[$name] .= "|";
                        }
                        $url_arr = explode("|",$data[$name]);
                        unset($data[$name]);
    
                        foreach ($url_arr as $k => $v){
                            $url = trim($v);
                            if (!empty($url)){
                               $data[$name]['title'][$k] = $url;
                               $data[$name]['file'][$k] = $this->down_file($url);
                              $data[$name]['description'][$k] = "";
                            }
                        }
                        $data[$name] = json_encode($data[$name]);
                    }
                    if ($t['fieldtype'] == "Image"){
                        if (stripos($data[$name],"|") !== false){
                            $data[$name] .= "|";
                        }
                        $url_arr = explode("|",$data[$name]);
                        unset($data[$name]);
    
                        foreach ($url_arr as $k => $v){
                            $url = trim($v);
                            if (!empty($url)){
                                $data[$name][$k] = $this->down_file($url);
                            }
                        }
    
                        $data[$name] = json_encode($data[$name]);
                    }
                    if ($t['fieldtype'] == "Images"){
                        if (stripos($data[$name],"|") !== false){
                            $data[$name] .= "|";
                        }
                        $url_arr = explode("|",$data[$name]);
                        unset($data[$name]);
    
                        foreach ($url_arr as $k => $v){
                            $url = trim($v);
                            if (!empty($url)){
                                $data[$name][$k] = $this->down_file($url);
                            }
                        }
    
                        $data[$name] = json_encode($data[$name]);
                    }
                    if ($t['fieldtype'] == 'Date'){
                        if ($data[$t['fieldname']]){
                            $data[$t['fieldname']] = strtotime($data[$t['fieldname']]);
                        }
                    }
                    if ($t['fieldtype'] == 'Time'){
                        $data[$name] = $data[$name];
                    }
                    if ($t['fieldtype'] == 'Linkage'){
                        if ($data[$t['fieldname']]) {
                            $datavalue = explode('>', $data[$t['fieldname']]);
                            $linkage = \Phpcmf\Service::M()->db->table('linkage')
                                ->select('id')
                                ->where('code', $t['setting']['option']['linkage'])
                                ->get()->getResultArray();
    
                            if (count($datavalue) > 1){
                                for($i = 0; $i < count($datavalue)-1; $i++){
                                    $linkagelist = \Phpcmf\Service::M()->db->table('linkage_data_'.$linkage[0]['id'])
                                        ->select('id')
                                        ->where('name', $datavalue[$i])
                                        ->get()->getResultArray();
                                    $piddata[$i] = $linkagelist[0]['id'];
                                }
    
                                $arr = array_merge([0],$piddata);
    
                                $linkagevalue = \Phpcmf\Service::M()->db->table('linkage_data_'.$linkage[0]['id'])
                                    ->select('id')
                                    ->where('pids',implode(',', $arr))
                                    ->where('name', $datavalue[count($datavalue)-1])
                                    ->get()->getResultArray();
    
                                $data[$t['fieldname']] = $linkagevalue[0]['id'];
                            }else{
                                $linkagelist1 = \Phpcmf\Service::M()->db->table('linkage_data_' . $linkage[0]['id'])
                                    ->select('id')
                                    ->where('name', $data[$name])
                                    ->get()->getResultArray();
    
                                $data[$t['fieldname']] = $linkagelist1[0]['id'];
                            }
                        }
                    }
                    if ($t['fieldtype'] == 'Linkages'){
                        if ($data[$t['fieldname']]) {
                            $linkdata = explode('|', $data[$t['fieldname']]);
                            $linkage = \Phpcmf\Service::M()->db->table('linkage')
                                ->select('id')
                                ->where('code', $t['setting']['option']['linkage'])
                                ->get()->getResultArray();
                            $linkid = [];
    
                            foreach ($linkdata as $key => $ld){
                                $datavalue = explode('>', $ld);
    
                                if (count($datavalue) > 1){
                                    for($i = 0; $i < count($datavalue)-1; $i++){
                                        $linkagelist = \Phpcmf\Service::M()->db->table('linkage_data_'.$linkage[0]['id'])
                                            ->select('id')
                                            ->where('name', $datavalue[$i])
                                            ->get()->getResultArray();
                                        $piddata[$i] = $linkagelist[0]['id'];
                                    }
    
                                    $arr = array_merge([0],$piddata);
    
                                    $linkagevalue = \Phpcmf\Service::M()->db->table('linkage_data_'.$linkage[0]['id'])
                                        ->select('id')
                                        ->where('pids',implode(',', $arr))
                                        ->where('name', $datavalue[count($datavalue)-1])
                                        ->get()->getResultArray();
                                    $linkid[$key] = $linkagevalue[0]['id'];
                                }else{
                                    $linkid = [];
                                    foreach ($linkdata as $key => $lk){
                                        $linkagelist = \Phpcmf\Service::M()->db->table('linkage_data_' . $linkage[0]['id'])
                                            ->select('id')
                                            ->where('name', $lk)
                                            ->get()->getResultArray();
                                        $linkid[$key] = $linkagelist[0]['id'];
                                    }
                                }
                            }
    
                            $data[$t['fieldname']] = json_encode($linkid);
                        }
                    }
                    if ($t['fieldtype'] == 'Radio' || $t['fieldtype'] == 'Select'){
                        $fieldvalue = dr_field_options($t['id']);
                        foreach ($fieldvalue as $key => $fv) {
                            if ($fv === $data[$name]) {
                                $data[$name] = $key;
                            }
                        }
                    }
                    if ($t['fieldtype'] == 'Checkbox'){
                        if (!empty($data[$name])){
                            $fieldvalue = dr_field_options($t['id']);
                            $datavalue = explode('|',$data[$name]);
                            $colnum = 0;
                            foreach ($datavalue as $dv){
                                foreach ($fieldvalue as $key => $fv) {
                                    if ($fv === $dv) {
                                        $fielddata[$colnum] = $key;
                                        $colnum = $colnum+1;
                                    }
                                }
                            }
                        }
                        $data[$name] = json_encode($fielddata);
                    }
                }catch (\Exception $e){
                    exit('附件下载失败');
                }
                if ($name && isset($data[$name])) {
                    $add[$t['ismain']][$name] = $data[$name];
                }
            }
            $value = $add[0]['content'];
            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) {
                                    // 可以下载文件
                                    // 同步模式
                                    // 下载远程文件
                                    $rt1 = \Phpcmf\Service::L('upload')->down_file([
                                        'url' => $img,
                                        'attachment' => \Phpcmf\Service::M('Attachment')->get_attach_info(intval($field['content']['setting']['option']['attachment'])),
                                    ]);
                                    if ($rt1['code']) {
                                        $att = \Phpcmf\Service::M('Attachment')->save_data($rt1['data'], 'ueditor_down_img');
                                        if ($att['code']) {
                                            // 归档成功
                                            $value = str_replace($img, $rt1['data']['url'], $value);
                                            $img = $att['code'];
                                        }
                                    }
                                }
                            }
                        }
                    }
                    // 缩略图
                    if ($img && !$add[1]['thumb']) {
                        $add[1]['thumb'] = $img;
                    }
                }
            }
            if ($imgs && !$add[1]['thumb']) {
                $add[1]['thumb'] = $imgs[3][0];
            }
            $add[0]['content'] = $value;
    
            if ($this->share['random'] == 1){
                $random_user = $this->add_member();
                $add[1]['uid'] = $random_user['data']['uid'];
                $add[1]['author'] =$random_user['data']['username'];
            }else{
                $uid = $this->u_id;
                $add[1]['uid'] = $uid;
                $member = dr_member_info($uid);
                $add[1]['author'] = $member['username'];
            }
            $add[1]['catid'] = $data['catid'];
            $add[1]['status'] = 9;
    
            if ( empty($data['hits']) ||  $data['hits'] < 0 ){
                if (empty($hits_min) && $hits_max == 1){
                    $add[1]['hits'] = 1;
                }else{
                    $add[1]['hits'] = random_int($hits_min,$hits_max);
                }
            }else{
                $add[1]['hits'] = $data['hits'];
            }
    
            $add[1]['inputip'] = \Phpcmf\Service::L('input')->ip_address();;
            $add[1]['inputtime'] = $add[1]['updatetime'] = SYS_TIME;
    
            $this->_init([
                'table' => $this->content_model->mytable,
                'field' => $field,
                'order_by' => 'id desc',
            ]);
    
            //验证标题重复
            if ($isupdate == 1){
                $model_data = \Phpcmf\Service::M()->table_site($this->model)->where('title', $add[1]['title'])->getAll();
    
                $data = $this->_Data($model_data[0]['id']);
                if ($this->content_model->save_content($model_data[0]['id'],$add,$data)) {;
                    exit('更新成功');
                } else {
                    exit('入库失败');
                }
            }elseif ($this->content_model->table(SITE_ID.'_'.MOD_DIR)->where('title', $add[1]['title'])->counts()) {
                echo '重复';exit;
            }else{
                if ($draft == 1){
                    $add[1]['id'] = 0;
                    $add[1]['content'] = $add[0]['content'];
                    $array['content'] = json_encode($add[1]);
                    $array['cid'] = 0;
                    $array['uid'] = 1;
                    $array['catid'] = $add[1]['catid'];
                    $array['inputtime'] = SYS_TIME;
    
                    $rel = \Phpcmf\Service::M()->table(SITE_ID.'_'.$this->model.'_draft')->insert($array);
                    if ($rel) {
                        exit('成功');
                    }else{
                        exit('入库失败');
                    }
                }
    
                if ($this->content_model->save_content(0,$add,0)) {
                    $locomotive['catid'] = $catename[0]['id'];
                    $locomotive['name'] = $catename[0]['name'];
                    $locomotive['dirname'] = $catename[0]['dirname'];
                    $locomotive['site'] = SITE_ID;
                    $locomotive['title'] = $add[1]['title'];
                    $locomotive['module'] = 'share';
                    \Phpcmf\Service::M()->table('locomotive')->insert($locomotive);
                    exit('成功');
                } else {
                    exit('入库失败');
                }
            }
        }
    
        public function getAloneCate(){
            $auth = $this->alone['code'];
    
            $this->input = Service::L('input');
            if ($this->input->get('auth') != $auth) exit('权限认证失败');
    
            $module = \Phpcmf\Service::M()->db->table('module')->select('dirname')->get()->getResultArray();
    
    
            foreach ($module as $mod) {
                $aloneCate = \Phpcmf\Service::M()->db->table(SITE_ID.'_'.$mod['dirname'].'_category')->select('id,name,child')->get()->getResultArray();
                foreach ($aloneCate as $num => $alone) {
                    $aloneCate[$num]['id'] = $mod['dirname'].'-'.$alone['id'];
                }
                $Category[] = $aloneCate;
            }
            $info = $Category;
    
            $array_cate = [];
    
            foreach ($info as $key => $value) {
                foreach ($value as $k => $v) {
                    array_push($array_cate, $v);
                }
            }
    
            foreach ($array_cate as $ac) {
                if ($ac['child'] == 0) {
                    echo '<h1>'.$ac['name'].'<=>'.$ac['id'].'</h1>'.PHP_EOL;
                }
            }
    
        }
    
        /**
         * 采集入库
         */
        public function addAlone() {
            $auth = $this->alone['code'];
            $draft = $this->alone['draft'];
            $isupdate = $this->alone['contentupdate'];
            $hits_min = $this->alone['hits_min'];
            $hits_max = $this->alone['hits_max'];
    
            $this->input = Service::L('input');
    
            if ($this->input->get('auth') != $auth) exit('权限认证失败');
            if ($this->alone['release'] != 1) exit('已关闭发布状态');
    
            $add = array();
            $data = $this->input->request('data');
    
            $cateinfo = explode('-', $data['catid']);
    
            $data['catid'] = $cateinfo[1];
    
            $catename = \Phpcmf\Service::M()->db->table(SITE_ID.'_'.$cateinfo[0].'_category')
                    ->where('id', (int)$data['catid'])
                    ->get()->getResultArray();
    
            $this->model = $cateinfo[0];
            $this->content_model = \Phpcmf\Service::M('Content', $this->model);
            $this->_module_init($this->model, SITE_ID, $this->module[$cateinfo[0]]);
    
            if (!$data['catid']) exit('栏目不存在');
            if (!$data['catid'] || !$data['title']) exit('数据不完整');
            // 按字段来归类
            $field = $this->get_cache('module-'.SITE_ID.'-'.$this->model, 'field');
    
            foreach ($field as $t) {
                $name = $t['fieldname'];
                try{
                    //单文件
                    if ($t['fieldtype'] == "File"){
                        if ($data[$name]){
                            $data[$name] = dr_get_file($this->down_file(trim($data[$name])));
    
                        }
                    }
                    //多文件
                    if ($t['fieldtype'] == "Files"){
                        if (stripos($data[$name],"|") !== false){
                            $data[$name] .= "|";
                        }
                        $url_arr = explode("|",$data[$name]);
                        unset($data[$name]);
    
                        foreach ($url_arr as $k => $v){
                            $url = trim($v);
                            if (!empty($url)){
                               $data[$name]['title'][$k] = $url;
                               $data[$name]['file'][$k] = $this->down_file($url);
                              $data[$name]['description'][$k] = "";
                            }
                        }
                        $data[$name] = json_encode($data[$name]);
                    }
                    if ($t['fieldtype'] == "Image"){
                        if (stripos($data[$name],"|") !== false){
                            $data[$name] .= "|";
                        }
                        $url_arr = explode("|",$data[$name]);
                        unset($data[$name]);
    
                        foreach ($url_arr as $k => $v){
                            $url = trim($v);
                            if (!empty($url)){
                                $data[$name][$k] = $this->down_file($url);
                            }
                        }
    
                        $data[$name] = json_encode($data[$name]);
                    }
                    if ($t['fieldtype'] == "Images"){
                        if (stripos($data[$name],"|") !== false){
                            $data[$name] .= "|";
                        }
                        $url_arr = explode("|",$data[$name]);
                        unset($data[$name]);
    
                        foreach ($url_arr as $k => $v){
                            $url = trim($v);
                            if (!empty($url)){
                                $data[$name][$k] = $this->down_file($url);
                            }
                        }
    
                        $data[$name] = json_encode($data[$name]);
                    }
                    if ($t['fieldtype'] == 'Date'){
                        if ($data[$t['fieldname']]){
                            $data[$t['fieldname']] = strtotime($data[$t['fieldname']]);
                        }
                    }
                    if ($t['fieldtype'] == 'Time'){
                        $data[$name] = $data[$name];
                    }
                    if ($t['fieldtype'] == 'Linkage'){
                        if ($data[$t['fieldname']]) {
                            $datavalue = explode('>', $data[$t['fieldname']]);
                            $linkage = \Phpcmf\Service::M()->db->table('linkage')
                                ->select('id')
                                ->where('code', $t['setting']['option']['linkage'])
                                ->get()->getResultArray();
    
                            if (count($datavalue) > 1){
                                for($i = 0; $i < count($datavalue)-1; $i++){
                                    $linkagelist = \Phpcmf\Service::M()->db->table('linkage_data_'.$linkage[0]['id'])
                                        ->select('id')
                                        ->where('name', $datavalue[$i])
                                        ->get()->getResultArray();
                                    $piddata[$i] = $linkagelist[0]['id'];
                                }
    
                                $arr = array_merge([0],$piddata);
    
                                $linkagevalue = \Phpcmf\Service::M()->db->table('linkage_data_'.$linkage[0]['id'])
                                    ->select('id')
                                    ->where('pids',implode(',', $arr))
                                    ->where('name', $datavalue[count($datavalue)-1])
                                    ->get()->getResultArray();
    
                                $data[$t['fieldname']] = $linkagevalue[0]['id'];
                            }else{
                                $linkagelist1 = \Phpcmf\Service::M()->db->table('linkage_data_' . $linkage[0]['id'])
                                    ->select('id')
                                    ->where('name', $data[$name])
                                    ->get()->getResultArray();
    
                                $data[$t['fieldname']] = $linkagelist1[0]['id'];
                            }
                        }
                    }
                    if ($t['fieldtype'] == 'Linkages'){
                        if ($data[$t['fieldname']]) {
                            $linkdata = explode('|', $data[$t['fieldname']]);
                            $linkage = \Phpcmf\Service::M()->db->table('linkage')
                                ->select('id')
                                ->where('code', $t['setting']['option']['linkage'])
                                ->get()->getResultArray();
                            $linkid = [];
    
                            foreach ($linkdata as $key => $ld){
                                $datavalue = explode('>', $ld);
    
                                if (count($datavalue) > 1){
                                    for($i = 0; $i < count($datavalue)-1; $i++){
                                        $linkagelist = \Phpcmf\Service::M()->db->table('linkage_data_'.$linkage[0]['id'])
                                            ->select('id')
                                            ->where('name', $datavalue[$i])
                                            ->get()->getResultArray();
                                        $piddata[$i] = $linkagelist[0]['id'];
                                    }
    
                                    $arr = array_merge([0],$piddata);
    
                                    $linkagevalue = \Phpcmf\Service::M()->db->table('linkage_data_'.$linkage[0]['id'])
                                        ->select('id')
                                        ->where('pids',implode(',', $arr))
                                        ->where('name', $datavalue[count($datavalue)-1])
                                        ->get()->getResultArray();
                                    $linkid[$key] = $linkagevalue[0]['id'];
                                }else{
                                    $linkid = [];
                                    foreach ($linkdata as $key => $lk){
                                        $linkagelist = \Phpcmf\Service::M()->db->table('linkage_data_' . $linkage[0]['id'])
                                            ->select('id')
                                            ->where('name', $lk)
                                            ->get()->getResultArray();
                                        $linkid[$key] = $linkagelist[0]['id'];
                                    }
                                }
                            }
    
                            $data[$t['fieldname']] = json_encode($linkid);
                        }
                    }
                    if ($t['fieldtype'] == 'Radio' || $t['fieldtype'] == 'Select'){
                        $fieldvalue = dr_field_options($t['id']);
                        foreach ($fieldvalue as $key => $fv) {
                            if ($fv === $data[$name]) {
                                $data[$name] = $key;
                            }
                        }
                    }
                    if ($t['fieldtype'] == 'Checkbox'){
                        if (!empty($data[$name])){
                            $fieldvalue = dr_field_options($t['id']);
                            $datavalue = explode('|',$data[$name]);
                            $colnum = 0;
                            foreach ($datavalue as $dv){
                                foreach ($fieldvalue as $key => $fv) {
                                    if ($fv === $dv) {
                                        $fielddata[$colnum] = $key;
                                        $colnum = $colnum+1;
                                    }
                                }
                            }
                        }
                        $data[$name] = json_encode($fielddata);
                    }
                }catch (\Exception $e){
                    exit('附件下载失败');
                }
                if ($name && isset($data[$name])) {
                    $add[$t['ismain']][$name] = $data[$name];
                }
            }
    
            $value = $add[0]['content'];
            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) {
                                    // 可以下载文件
                                    // 同步模式
                                    // 下载远程文件
                                    $rt1 = \Phpcmf\Service::L('upload')->down_file([
                                        'url' => $img,
                                        'attachment' => \Phpcmf\Service::M('Attachment')->get_attach_info(intval($field['content']['setting']['option']['attachment'])),
                                    ]);
                                    if ($rt1['code']) {
                                        $att = \Phpcmf\Service::M('Attachment')->save_data($rt1['data'], 'ueditor_down_img');
                                        if ($att['code']) {
                                            // 归档成功
                                            $value = str_replace($img, $rt1['data']['url'], $value);
                                            $img = $att['code'];
                                        }
                                    }
                                }
                            }
                        }
                    }
                    // 缩略图
                    if ($img && !$add[1]['thumb']) {
                        $add[1]['thumb'] = $img;
                    }
                }
            }
            if ($imgs && !$add[1]['thumb']) {
                $add[1]['thumb'] = $imgs[3][0];
            }
            $add[0]['content'] = $value;
    
    
            if ($this->alone['random'] == 1){
                $random_user = $this->add_member();
                $add[1]['uid'] = $random_user['data']['uid'];
                $add[1]['author'] =$random_user['data']['username'];
            }else{
                $uid = $this->u_id;
                $add[1]['uid'] = $uid;
                $member = dr_member_info($uid);
                $add[1]['author'] = $member['username'];
            }
            $add[1]['catid'] = $data['catid'];
            $add[1]['status'] = 9;
    
            if ( empty($data['hits']) ||  $data['hits'] < 0 ){
                if (empty($hits_min) && $hits_max == 1){
                    $add[1]['hits'] = 1;
                }else{
                    $add[1]['hits'] = random_int($hits_min,$hits_max);
                }
            }else{
                $add[1]['hits'] = $data['hits'];
            }
    
            if (empty($data['description'])) {
                $add[1]['description'] = ' ';
            }else{
                $add[1]['description'] = $data['description'];
            }
    
            if ($this->model == 'bbs'){
                $add[1]['color'] = ' ';
                $add[1]['isflag'] = 0;
            }
    
            $add[1]['displayorder'] = 0;
            $add[1]['inputip'] = \Phpcmf\Service::L('input')->ip_address();;
            $add[1]['inputtime'] = $add[1]['updatetime'] = SYS_TIME;
    
            $this->_init([
                'table' => $this->content_model->mytable,
                'field' => $field,
                'order_by' => 'id desc',
            ]);
    
            //验证标题重复
            if ($isupdate == 1){
                $model_data = \Phpcmf\Service::M()->table_site($this->model)->where('title', $add[1]['title'])->getAll();
    
                $data = $this->_Data($model_data[0]['id']);
                if ($this->content_model->save_content($model_data[0]['id'],$add,$data)) {;
                    exit('更新成功');
                } else {
                    exit('入库失败');
                }
            }elseif ($this->content_model->table(SITE_ID.'_'.MOD_DIR)->where('title', $add[1]['title'])->counts()) {
                echo '重复';exit;
            }else{
                if ($draft == 1){
                    $add[1]['id'] = 0;
                    $add[1]['content'] = $add[0]['content'];
                    $array['content'] = json_encode($add[1]);
                    $array['cid'] = 0;
                    $array['uid'] = 1;
                    $array['catid'] = $add[1]['catid'];
                    $array['inputtime'] = SYS_TIME;
    
                    $rel = \Phpcmf\Service::M()->table(SITE_ID.'_'.$this->model.'_draft')->insert($array);
                    if ($rel) {
                        exit('成功');
                    }else{
                        exit('入库失败');
                    }
                }
    
                if ($this->content_model->save_content(0,$add,0)) {
                    $locomotive['catid'] = $catename[0]['id'];
                    $locomotive['name'] = $catename[0]['name'];
                    $locomotive['dirname'] = $catename[0]['dirname'];
                    $locomotive['site'] = SITE_ID;
                    $locomotive['title'] = $add[1]['title'];
                    $locomotive['module'] = 'share';
                    \Phpcmf\Service::M()->table('locomotive')->insert($locomotive);
                    exit('成功');
                } else {
                    exit('入库失败');
                }
            }
        }
    
    ?>
    满意答案
  • 迅睿粉丝
    #3楼    迅睿粉丝
    2021-10-03 18:14:21
    Chrome 0
    官方插件技术-何老师 现在问题应该是,新建的子站,无法发现主站的这个插件,因为子站是独立创建站点目录,目录里根本没有这个插件的安装
  • 迅睿粉丝
    #4楼    迅睿粉丝
    2021-10-04 21:37:56
    Chrome 0
    @老孙头:好了好了好了好了好了好了好了好了