Exemplo n.º 1
0
 /**
  * 测试文章内容采集
  */
 public function public_test_content()
 {
     $url = isset($_GET['url']) ? urldecode($_GET['url']) : exit('0');
     $nodeid = isset($_GET['nodeid']) ? intval($_GET['nodeid']) : showmessage(L('illegal_parameters'), HTTP_REFERER);
     if ($data = $this->db->getby_nodeid($nodeid)) {
         Loader::lib('collection:collection', false);
         print_r(collection::get_content($url, $data));
     } else {
         showmessage(L('notfound'));
     }
 }
Exemplo n.º 2
0
 public function col_content()
 {
     $nodeid = isset($_GET['nodeid']) ? intval($_GET['nodeid']) : showmessage(L('illegal_parameters'), HTTP_REFERER);
     if ($data = $this->db->get_one(array('nodeid' => $nodeid))) {
         $content_db = pc_base::load_model('collection_content_model');
         //更新附件状态
         $attach_status = false;
         if (pc_base::load_config('system', 'attachment_stat')) {
             $this->attachment_db = pc_base::load_model('attachment_model');
             $attach_status = true;
         }
         pc_base::load_app_class('collection', '', 0);
         $page = isset($_GET['page']) ? intval($_GET['page']) : 1;
         $total = isset($_GET['total']) ? intval($_GET['total']) : 0;
         if (empty($total)) {
             $total = $content_db->count(array('nodeid' => $nodeid, 'siteid' => $this->get_siteid(), 'status' => 0));
         }
         $total_page = ceil($total / 2);
         $list = $content_db->select(array('nodeid' => $nodeid, 'siteid' => $this->get_siteid(), 'status' => 0), 'id,url', '2', 'id desc');
         $i = 0;
         if (!empty($list) && is_array($list)) {
             foreach ($list as $v) {
                 $GLOBALS['downloadfiles'] = array();
                 $html = collection::get_content($v['url'], $data);
                 //更新附件状态
                 if ($attach_status) {
                     $this->attachment_db->api_update($GLOBALS['downloadfiles'], 'cj-' . $v['id'], 1);
                 }
                 $content_db->update(array('status' => 1, 'data' => array2string($html)), array('id' => $v['id']));
                 $i++;
             }
         } else {
             showmessage(L('url_collect_msg'), '?m=collection&c=node&a=manage');
         }
         if ($total_page > $page) {
             showmessage(L('collectioning') . ($i + ($page - 1) * 2) . '/' . $total . '<script type="text/javascript">location.href="?m=collection&c=node&a=col_content&page=' . ($page + 1) . '&nodeid=' . $nodeid . '&total=' . $total . '&pc_hash=' . $_SESSION['pc_hash'] . '"</script>', '?m=collection&c=node&a=col_content&page=' . ($page + 1) . '&nodeid=' . $nodeid . '&total=' . $total);
         } else {
             $this->db->update(array('lastdate' => SYS_TIME), array('nodeid' => $nodeid));
             showmessage(L('collection_success'), '?m=collection&c=node&a=manage');
         }
     }
 }