Exemple #1
0
 function input_db_docs($str, $cid)
 {
     $docs = explode($this->exploder, $str);
     $num = array('all' => 0, 'in' => 0);
     $num['all'] = count($docs) - 1;
     $time = time();
     if (is_array($docs)) {
         foreach ($docs as $doc) {
             if ($doc) {
                 $sql = "SELECT * FROM `" . DB_TABLEPRE . "doc` WHERE title='{$doc}'";
                 if (!is_array($this->db->fetch_first($sql))) {
                     $letter = string::getfirstletter($doc);
                     $author = $this->base->user['username'];
                     $authorid = $this->base->user['uid'];
                     $sql = "INSERT INTO `" . DB_TABLEPRE . "doc` (`cid`,`letter`,`title`,`author`,`authorid`,`time`,`lastedit`,`lasteditor`) VALUES ('{$cid}','{$letter}','{$doc}','{$author}','{$authorid}','{$time}','{$time}','{$author}')";
                     $this->db->query($sql);
                     $num['in']++;
                 }
             }
         }
     }
     return $num;
 }
Exemple #2
0
 function doimport()
 {
     $title = string::hiconv($this->post['title']);
     $data = $_ENV['doc']->get_doc_by_title($title);
     $page = $this->cache->getcache('systemdata');
     if (empty($page)) {
         $page = 1;
     }
     $_ENV['hdapi']->roll_docs($page, 10);
     $this->cache->writecache('systemdata', ++$page);
     if ($data) {
         $this->message(0, '', 2);
     }
     $doc['content'] = $_ENV['hdapi']->get_content_import($title, 2, true);
     $doc['tags'] = array($title);
     $doc['search_tags'] = $title;
     if ($doc['content'] && is_string($doc['content'])) {
         $doc['category'] = $this->post['cid'];
         $doc['title'] = $title;
         $doc['letter'] = string::getfirstletter($title);
         $doc['content'] = mysql_real_escape_string($doc['content']);
         $doc['content'] = str_replace('\\r\\n', "\r\n", $doc['content']);
         $doc['tags'] = $_ENV['doc']->jointags($doc['tags']);
         $doc['summary'] = trim(string::convercharacter(strip_tags($doc['content'])));
         $doc['images'] = util::getimagesnum($doc['content']);
         $doc['time'] = $this->time;
         $doc['words'] = string::hstrlen($doc['content']);
         $doc['visible'] = '1';
         //$this->setting['verify_doc']?'0':'1';
         $did = $_ENV['doc']->add_doc($doc);
         $_ENV['doc']->add_searchindex($did, $doc['title'], $doc['search_tags'], $doc['content']);
         $_ENV['user']->add_credit($this->user['uid'], 'doc-create', $this->setting['credit_create']);
         $_ENV['user']->update_field('creates', $this->user['creates'] + 1, $this->user['uid']);
         $_ENV['category']->update_category_docs($this->post['category']);
         //$data = array('did'=>$did, 'name'=>'互动百科 '.$title, 'url'=>'http://www.hudong.com/wiki/'.urlencode($this->post['title']));
         //$_ENV['reference']->add($data);
         $this->message(1, '', 2);
     } else {
         if ($doc['content'] && is_array($doc['content'])) {
             $this->message($doc['content']['return_type'] . '_' . $doc['content']['return_info'], '', 2);
         } else {
             $this->message(2, '', 2);
         }
     }
 }
Exemple #3
0
 function change_name($did, $title)
 {
     $letter = string::getfirstletter($title);
     if ($this->db->query("UPDATE " . DB_TABLEPRE . "doc SET title='{$title}',letter='{$letter}' WHERE did={$did}")) {
         $this->db->query("UPDATE " . DB_TABLEPRE . "edition SET title='{$title}' WHERE did={$did}");
         return true;
     } else {
         return false;
     }
 }
Exemple #4
0
 function doimport()
 {
     //global $wmdb;
     if (file_exists($this->configfile) && file_exists($this->sumfile)) {
         include $this->configfile;
         include $this->sumfile;
     } else {
         $this->message('5|0', '', 2);
     }
     $this->wmdb = new hddb(WDB_HOST, WDB_USER, WDB_PW, WDB_NAME, WDB_CHARSET, WDB_CONNECT);
     //$wmdb = $this->wmdb;
     //判断做到哪一步了.
     if (file_exists($this->processfile)) {
         include $this->processfile;
         list($type, $i) = explode('|', $process);
         if ($type >= 5) {
             $this->message('5|0', '', 2);
         }
     } else {
         list($type, $i) = array(1, 0);
     }
     $totalnum = array(1 => $catsum, 2 => $usersum, 3 => $docsum, 4 => $clinksum);
     $totalnum = $totalnum[$type];
     $j = 10;
     for (; $i < $totalnum; $i += $j) {
         $msg = $type . '|' . (($n = $i + $j) >= $totalnum ? $totalnum : $n);
         if ($type == 1 || $type == 2 || $type == 4) {
             //导入分类和用户。
             $hdsql = $_ENV['mwimport']->get_sql($this->wmdb, $type, $i, $j);
             if (!$hdsql || $this->db->query($hdsql)) {
                 $_ENV['mwimport']->writefile($this->processfile, '<?php $process = "' . $msg . '"; ?>');
             } else {
                 $this->message('5|0', '', 2);
             }
         } elseif ($type == 3) {
             include HDWIKI_ROOT . '/plugins/mwimport/text/Mediawiki.php';
             $parser = 'Mediawiki';
             $text_wiki = new Text_Wiki_Mediawiki();
             $sql = "SELECT a.page_id, a.page_title, b.old_text, b.old_flags, b.old_id FROM " . WDB_TABLEPRE . "page a, " . WDB_TABLEPRE . "text b WHERE a.page_namespace = 0 AND a.page_latest = b.old_id limit " . $i . ",{$j}";
             $query = $this->wmdb->query($sql);
             while ($doc = $this->wmdb->fetch_array($query)) {
                 if ($_ENV['doc']->get_doc_by_title($doc['page_title'])) {
                     continue;
                 }
                 $doc['did'] = $doc['page_id'];
                 $doc['title'] = $doc['page_title'];
                 $doc['letter'] = string::getfirstletter($doc['page_title']);
                 $wiki = $text_wiki->singleton($parser);
                 $result = $wiki->transform($source);
                 $doc['old_text'] = $wiki->transform($doc['old_text']);
                 //加入对内容的处理和过滤。
                 $doc['old_text'] = mysql_real_escape_string($doc['old_text']);
                 $doc['tags'] = '';
                 $doc['summary'] = trim(string::convercharacter(string::substring(strip_tags($doc['old_text']), 0, 100)));
                 $doc['images'] = util::getimagesnum($doc['old_text']);
                 $doc['time'] = $this->time;
                 $doc['words'] = string::hstrlen($doc['old_text']);
                 $doc['visible'] = '1';
                 $doc['cid'] = $_ENV['mwimport']->get_cid($this->wmdb, '', $doc['did']);
                 $sql = "SELECT rev_user,rev_user_text FROM " . WDB_TABLEPRE . "revision  WHERE rev_page = " . $doc['page_id'] . " ORDER BY  rev_id ";
                 $user = $this->wmdb->fetch_first($sql);
                 $this->db->query("REPLACE INTO " . DB_TABLEPRE . "doc\r\n\t\t\t    (did,cid,letter,title,tag ,summary ,content,author,authorid,time,lastedit,lasteditor,lasteditorid,visible,editions)\r\n\t\t\t    VALUES (" . $doc['did'] . "," . $doc['cid'] . ",'" . $doc['letter'] . "','" . $doc['title'] . "','" . $doc['tags'] . "','" . $doc['summary'] . "','" . $doc['old_text'] . "',\r\n\t\t\t    '" . $user['rev_user_text'] . "','" . $user['rev_user'] . "',\r\n\t\t\t    " . $doc['time'] . "," . $doc['time'] . ",'" . $user['rev_user_text'] . "','" . $user['rev_user'] . "','" . $doc['visible'] . "',1)");
             }
             $_ENV['mwimport']->writefile($this->processfile, '<?php $process = "' . $msg . '"; ?>');
         }
         $this->message($msg, '', 2);
     }
     $msg = $type + 1 . '|0';
     $_ENV['mwimport']->writefile($this->processfile, '<?php $process = "' . $msg . '"; ?>');
     $this->message($msg, '', 2);
 }
Exemple #5
0
 function docreate()
 {
     if (4 != $this->user['groupid'] && $this->time - $this->user['regtime'] < $this->setting['forbidden_edit_time'] * 60) {
         $this->message($this->view->lang['editTimeLimit1'] . $this->setting['forbidden_edit_time'] . $this->view->lang['editTimeLimit2'], 'BACK', 0);
     }
     if ($this->setting['verify_doc'] == -1) {
         //首次编辑审核
         if ($this->setting['max_newdocs'] != 0 && $this->user['newdocs'] >= $this->setting['max_newdocs']) {
             $this->message('您的首次可创建或编辑词条数的数量已达最大值,请等待管理员审核', 'BACK', 0);
         }
     }
     if (!isset($this->post['create_submit'])) {
         if ('0' === $this->user['checkup']) {
             $this->message($this->view->lang['createDocTip17'], 'BACK', 0);
         }
         if (isset($this->post['title'])) {
             $this->view->assign('title', htmlspecialchars(stripslashes($this->post['title'])));
         }
         if (@is_numeric($this->get[2])) {
             $category = $_ENV['category']->get_category($this->get[2]);
             $this->view->assign("category", $category);
         }
         $this->view->assign('navtitle', $this->view->lang['createDoc'] . "-");
         $this->view->display('createdoc');
     } else {
         if (!isset($this->post['publishsubmit'])) {
             if (trim($this->post['title']) == "") {
                 $this->message($this->view->lang['createDocTip1'], 'BACK', 0);
             }
             if ($synonym = $_ENV['synonym']->get_synonym_by_src($this->post['title'])) {
                 $this->view->assign('synonymdoc', $synonym['srctitle']);
                 $this->get[2] = $synonym['destdid'];
                 $this->doview();
                 exit;
             }
             if ($_ENV['doc']->have_danger_word($this->post['title'])) {
                 $this->message($this->view->lang['docHaveDanerWord'], 'BACK', 0);
             }
             if (!(bool) $_ENV['category']->vilid_category($this->post['category'])) {
                 $this->message($this->view->lang['categoryNotExist'], 'BACK', 0);
             }
             $title = string::substring(string::stripscript($_ENV['doc']->replace_danger_word(trim($this->post['title']))), 0, 80);
             if (!(bool) $title) {
                 $this->message($this->view->lang['createDocTip16'], 'BACK', 0);
             }
             $data = $this->db->fetch_by_field('doc', 'title', $title);
             if ((bool) $data) {
                 $this->header('doc-view-' . $data['did']);
             }
             $doc['title'] = htmlspecialchars($title);
             $doc['cid'] = $this->post['category'];
             $doc['did'] = $_ENV['doc']->add_doc_placeholder($doc);
             $this->view->assign("savetime", 60000);
             $this->view->assign("filter_external", $this->setting['filter_external']);
             //eval($this->plugin['hdapi']['hooks']['readcontent']);
             $this->load("hdapi");
             if ($this->setting['site_nick'] && $this->setting["hdapi_bklm"]) {
                 if ($_ENV["hdapi"]->islock($doc["title"])) {
                     $doc["locked"] = 1;
                     $this->message("该词条正在被百科联盟网站锁定编辑中", "BACK", 0);
                 } else {
                     $_ENV["hdapi"]->lock($doc["title"]);
                     $content = $_ENV["hdapi"]->get_content($doc["title"]);
                     if (is_string($content) && !empty($content)) {
                         $doc["content"] = $content;
                     }
                 }
             }
             $this->view->assign('navtitle', "{$title}-" . $this->view->lang['createDoc'] . "-");
             $this->view->assign("page_action", "create");
             $this->view->assign("attachment_open", $this->setting['attachment_open']);
             //$this->view->assign("attachment_type","['".implode("','",$_ENV['attachment']->get_attachment_type())."']");
             $this->view->assign('attachment_size', $this->setting['attachment_size']);
             $doc['title'] = stripcslashes($doc['title']);
             eval($this->plugin['doctemplate']['hooks']['doctemplate']);
             //载入类别模版。
             $this->view->assign('doc', $doc);
             $this->view->assign("doc_verification_create_code", $this->setting['checkcode'] != 3 && $this->setting['doc_verification_create_code']);
             $this->view->assign('g_img_big', $this->setting['img_width_big']);
             $this->view->assign('g_img_small', $this->setting['img_width_small']);
             //$this->view->display('editor');
             $_ENV['block']->view('editor');
         } else {
             if ($this->setting['checkcode'] != 3 && $this->setting['doc_verification_create_code'] && strtolower($this->post['code']) != $_ENV['user']->get_code()) {
                 $this->message($this->view->lang['codeError'], 'BACK', 0);
             }
             if (@trim($this->post['content']) == '' || @trim($this->post['title']) == '') {
                 $this->message($this->view->lang['contentIsNull'], 'BACK', 0);
             }
             $doc['title'] = string::substring(string::stripscript($_ENV['doc']->replace_danger_word(trim($this->post['title']))), 0, 80);
             $_doc = $this->db->fetch_by_field('doc', 'title', $doc['title']);
             if ((bool) $_doc && !empty($_doc['content'])) {
                 $this->message($this->view->lang['createDocTip5'], 'BACK', 0);
             }
             if (!(bool) $_ENV['category']->vilid_category($this->post['category'])) {
                 $this->message($this->view->lang['categoryNotExist'], 'BACK', 0);
             }
             if (@(!(bool) $this->post['summary'])) {
                 $doc['summary'] = trim(strip_tags($_ENV['doc']->replace_danger_word($this->post['summary'])));
             }
             $doc['did'] = $this->post['did'];
             $doc['letter'] = string::getfirstletter($this->post['title']);
             $doc['category'] = $this->post['category'];
             //$doc['tags']=$_ENV['doc']->jointags($this->post['tags']);
             $doc['tags'] = $this->post['tags'];
             $doc['tags'] = $_ENV['doc']->replace_danger_word($doc['tags']);
             $doc['content'] = string::stripscript($_ENV['doc']->replace_danger_word($this->post['content']));
             $doc['content'] = $this->setting['auto_picture'] ? $_ENV['doc']->auto_picture($doc['content'], $doc['did']) : $doc['content'];
             $doc['summary'] = trim(strip_tags($_ENV['doc']->replace_danger_word($this->post['summary'])));
             $doc['summary'] = (bool) $doc['summary'] ? $doc['summary'] : $doc['content'];
             $doc['summary'] = trim(string::convercharacter(string::substring(strip_tags($doc['summary']), 0, 100)));
             $doc['images'] = util::getimagesnum($doc['content']);
             $doc['time'] = $this->time;
             $doc['words'] = string::hstrlen($doc['content']);
             $doc['visible'] = $this->setting['verify_doc'] != 0 ? '0' : '1';
             if (strpos($this->user['regulars'], 'doc-immunity') === false && 4 != $this->user['groupid']) {
                 if (!$_ENV['doc']->check_submit_interval($this->user['uid'])) {
                     if ($this->setting['save_spam']) {
                         $doc['visible'] = 0;
                     } else {
                         $this->message(sprintf($this->view->lang['submit_interval_msg'], $this->setting['submit_min_interval']), "BACK", 0);
                     }
                 }
                 if (!$_ENV['doc']->check_eng_pcnt($doc['content']) || !$_ENV['doc']->check_extlink_pcnt($doc['content'])) {
                     if ($this->setting['save_spam']) {
                         $doc['visible'] = 0;
                     } else {
                         $this->message($this->view->lang['spam_msg'], "BACK", 0);
                     }
                 }
             }
             if (strpos($this->user['regulars'], 'doc-immunity') !== false || 4 == $this->user['groupid'] || !$this->setting['verify_doc'] || $this->setting['verify_doc'] == -1 && $this->user['newdocs'] == -1) {
                 $doc['visible'] = 1;
             }
             if ($this->setting['verify_doc'] == -1) {
                 //首次编辑审核
                 if ($this->user['newdocs'] != -1) {
                     $_ENV['user']->update_newdocs($this->user['uid'], +1);
                 }
             }
             if ($doc['visible'] == 1) {
                 $_ENV['user']->add_credit($this->user['uid'], 'doc-create', $this->setting['credit_create'], $this->setting['coin_create']);
             }
             /*foreach($this->post['tags'] as $search_tags){
             			$doc['search_tags'] .=string::convert_to_unicode($search_tags).";";
             		}*/
             $did = $_ENV['doc']->add_doc($doc);
             $_ENV['user']->update_field('creates', $this->user['creates'] + 1, $this->user['uid']);
             //$_ENV['category']->update_category_docs($this->post['category']);
             //多个分类下添加词条,更新分类下词条数量调整到doc.class.php->add_doc_placeholder()->add_doc_category()
             //附件已经不再编辑页面上传
             //$message=$_ENV['attachment']->upload_attachment($did);
             $_ENV['innerlink']->update($doc['title'], $did);
             $_ENV['doc']->unset_editlock($doc['did'], $this->user['uid']);
             $this->load('noticemail');
             $_ENV['noticemail']->doc_create($doc);
             //eval($this->plugin["ucenter"]["hooks"]["create_feed"]);
             UC_OPEN && $_ENV['ucenter']->create_feed($doc, $did);
             //eval($this->plugin['hdapi']['hooks']['postcontent']);
             $this->load("hdapi");
             if ($this->setting['site_nick'] && $this->setting["hdapi_bklm"]) {
                 $_ENV["hdapi"]->post_content($doc["title"], $doc["content"]);
             }
             if (1 == $this->setting['cloud_search'] && 1 == $doc['visible']) {
                 // 创建词条 通知云搜索
                 $_ENV['search']->cloud_change(array('dids' => $did, 'mode' => '1'));
             }
             if ((bool) $message) {
                 $this->message($message, $this->setting['seo_prefix'] . "doc-view-" . $did . $this->setting['seo_suffix'], 0);
             } else {
                 $msg = $this->view->lang['docPublishSuccess'];
                 if ($this->setting['hdapi_autoshare_create']) {
                     $msg .= "<script>\$.get('index.php?hdapi-hdautosns-create-'+{$did});</script>";
                 }
                 $this->message($msg, $this->setting['seo_prefix'] . "doc-view-" . $did . $this->setting['seo_suffix'], 0);
             }
         }
     }
 }