首页 > CMS > PhpCMS > 正文

【phpcms-v9】phpcms-v9中复制采集节点功能(扩展:专题碎片的

2024-09-10 07:15:55
字体:
来源:转载
供稿:网友

【phpcms-v9】phpcms-v9中复制采集节点功能(扩展:专题碎片的复制).

1.添加采集节点代码:

  1. /**  
  2.      * add node  
  3.      */   
  4.     public function add() {   
  5.         header("Cache-control: private");   
  6.         //添加采集节点   
  7.         if(isset($_POST['dosubmit'])) {   
  8.             //采集节点表单数据   
  9.             $data = isset($_POST['data']) ? $_POST['data'] :  showmessage(L('illegal_parameters'), HTTP_REFERER);   
  10.             //自定义规则   
  11.             $customize_config = isset($_POST['customize_config']) ? $_POST['customize_config'] :  '';   
  12.             //采集节点名称   
  13.             if (!$data['name'] = trim($data['name'])) {   
  14.                 showmessage(L('nodename').L('empty'), HTTP_REFERER);   
  15.             }   
  16.             //提示 节点已存在   
  17.             if ($this->db->get_one(array('name'=>$data['name']))) {   
  18.                 showmessage(L('nodename').L('exists'), HTTP_REFERER);   
  19.             }   
  20.             //网址类型   
  21.             $data['urlpage'] = isset($_POST['urlpage'.$data['sourcetype']]) ? $_POST['urlpage'.$data['sourcetype']] : showmessage(L('illegal_parameters'), HTTP_REFERER);   
  22.             //站点id   
  23.             $data['siteid']= $this->get_siteid();   
  24.             //自定义规则   
  25.             $data['customize_config'] = array();   
  26.             if (is_array($customize_config)) foreach ($customize_config['en_name'as $k => $v) {   
  27.                 if (emptyempty($v) || emptyempty($customize_config['name'][$k])) continue;   
  28.                 $data['customize_config'][] = array('name'=>$customize_config['name'][$k], 'en_name'=>$v'rule'=>$customize_config['rule'][$k], 'html_rule'=>$customize_config['html_rule'][$k]);   
  29.             }   
  30.             $data['customize_config'] = array2string($data['customize_config']);   
  31.             //采集节点信息入库操作   
  32.             if ($this->db->insert($data)) {   
  33.                 showmessage(L('operation_success'), '?m=collection&c=node&a=manage');   
  34.             } else {   
  35.                 showmessage(L('operation_failure'), HTTP_REFERER);   
  36.             }   
  37.         } else {   
  38.             $show_dialog = $show_validator = true;   
  39.             //采集节点信息表单页面   
  40.             include $this->admin_tpl('node_form');   
  41.         }   
  42.            
  43.     } 

2.复制采集节点信息

  1. //复制已有采集节点   
  2.     public function copy() {   
  3.         //采集节点id   
  4.         $nodeid = isset($_GET['nodeid']) ? intval($_GET['nodeid']) : showmessage(L('illegal_parameters'), HTTP_REFERER);   
  5.         //查询当前采集节点信息   
  6.         if ($data = $this->db->get_one(array('nodeid'=>$nodeid))) {   
  7.             //是否确定复制当前采集节点信息   
  8.             if (isset($_POST['dosubmit'])) {   
  9.                 //销毁当前采集节点id   
  10.                 unset($data['nodeid']);   
  11.                 //新采集节点名称   
  12.                 $name = isset($_POST['name']) && trim($_POST['name']) ? trim($_POST['name']) : showmessage(L('illegal_parameters'), HTTP_REFERER);   
  13.                 //查询数据库中是否已存在该新采集节点名称   
  14.                 if ($this->db->get_one(array('name'=>$name), 'nodeid')) {   
  15.                     showmessage(L('nodename').L('exists'), HTTP_REFERER);   
  16.                 }   
  17.                 //新采集节点名称   
  18.                 $data['name'] = $name;   
  19.                 //在特殊字符前加反斜线   
  20.                 $data = new_addslashes($data);   
  21.                 //插入新采集节点到数据库   
  22.                 if ($this->db->insert($data)) {   
  23.                     //插入成功   
  24.                     showmessage(L('operation_success'), '''''test');   
  25.                 } else {  //开源代码Vevb.com 
  26.                     showmessage(L('operation_failure'));   
  27.                 }   
  28.             } else {   
  29.                 $show_validator = $show_header = true;   
  30.                 include $this->admin_tpl('node_copy');//添加采集节点页面   
  31.             }   
  32.         } else {   
  33.             showmessage(L('notfound'));   
  34.         }   
  35.     }

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表