Exemple #1
0
 function douniontitle()
 {
     @header('Content-type: application/json; charset=' . WIKI_CHARSET);
     $len = strlen('plugin-hdapi-hdapi-uniontitle-');
     $did = substr($_SERVER['QUERY_STRING'], $len);
     $doc = $_ENV["hdapi"]->get_doc_title_by_id($did, 'title');
     if (!isset($doc['title'])) {
         exit;
     }
     $is_private_title = $_ENV['hdapi']->is_private_title($doc['title']);
     if (!empty($is_private_title)) {
         exit;
     }
     $uniontitle = $_ENV["hdapi"]->get_uniontitle_by_did($did);
     if (empty($uniontitle)) {
         $uniontitle = $_ENV["hdapi"]->get_tit_url($doc['title']);
         if (isset($uniontitle['docdeclaration']) && strtolower(WIKI_CHARSET) == 'gbk') {
             $uniontitle['docdeclaration'] = string::hiconv($uniontitle['docdeclaration'], 'gbk', 'utf-8');
         }
         if (!empty($uniontitle['docdeclaration'])) {
             $_ENV["hdapi"]->save_uniontitle_by_did($did, $uniontitle['docdeclaration']);
         }
     }
     if (is_array($uniontitle) && isset($uniontitle['docdeclaration'])) {
         $uniontitle = $uniontitle['docdeclaration'];
     } else {
         $uniontitle = '';
     }
     echo $uniontitle;
 }
Exemple #2
0
 /**
 添加、编辑参考资料
 编辑操作被整合到了add当中,由$_ENV['reference']->add()实现,
 如果 $data 当中包含 id 信息则执行edit操作,否则执行add操作。
 */
 function doadd()
 {
     if ($this->get[2] == 'checkable') {
         if ($this->checkable('reference-add')) {
             if ($this->setting['doc_verification_reference_code']) {
                 exit('CODE');
             } else {
                 exit('OK');
             }
         } else {
             exit('0');
         }
     }
     $data = $this->post['data'];
     //检查验证码
     if ($this->setting['checkcode'] != 3 && $this->setting['doc_verification_reference_code'] && strtolower($data['code']) != $_ENV['user']->get_code()) {
         exit('code.error');
     }
     if (WIKI_CHARSET == 'GBK') {
         $data['name'] = string::hiconv($data['name']);
     }
     if (empty($data['name'])) {
         exit('0');
     }
     $insert_id = $_ENV['reference']->add($data);
     if (is_int($insert_id)) {
         echo $insert_id;
     } else {
         echo $insert_id ? '1' : '0';
     }
 }
Exemple #3
0
 function dolist()
 {
     $page = !empty($this->get[2]) && is_numeric($this->get[2]) ? $this->get[2] : 1;
     $num = !empty($this->get[3]) && is_numeric($this->get[3]) ? $this->get[3] : 50;
     if ($page < 1) {
         $page = 1;
     }
     $doclist = array();
     $count = $_ENV['archiver']->get_total_num();
     if (0 < $count) {
         // 获得词条最大ID
         $maxdid = $_ENV['archiver']->get_max_did();
         $doclist = $_ENV['archiver']->get_doc_list(array('page' => $page, 'num' => $num));
         // 分页数据
         $totalpage = ceil($count / $num);
         $outhtml = $_ENV['archiver']->get_html_list($doclist, $totalpage, $num, $count, $maxdid);
     } else {
         $outhtml = $_ENV['archiver']->get_html_header() . 'No Body! No Body!' . $_ENV['archiver']->get_html_footer();
     }
     if ('gbk' == strtolower(WIKI_CHARSET)) {
         $outhtml = string::hiconv($outhtml, 'utf-8', 'gbk');
     }
     $_ENV['archiver']->close_mysql();
     echo $outhtml;
 }
Exemple #4
0
 function doedit()
 {
     if (!isset($this->post['editsubmit'])) {
         $did = isset($this->get[2]) ? $this->get[2] : '';
         if (!is_numeric($did)) {
             $this->message($this->view->lang['docIdMustNum'], 'BACK');
         }
         $focus = $this->db->fetch_by_field('focus', 'did', $did);
         $focus['time'] = $this->date($focus['time']);
         $this->view->assign("focus", $focus);
         $this->view->display("admin_focus_content");
     } else {
         $did = isset($this->post['did']) ? $this->post['did'] : '';
         if (!is_numeric($did)) {
             $this->message($this->view->lang['docIdMustNum'], 'BACK');
         }
         $summary = string::hiconv($this->post['summary']);
         $image = string::hiconv($this->post['image']);
         $order = $this->post['displayorder'];
         $type = $this->post['doctype'];
         if (is_numeric($order) && $_ENV['doc']->save_focus_content($did, $summary, $image, $order, $type)) {
             $this->cache->removecache('data_' . $GLOBALS['theme'] . '_index');
             $this->message($this->view->lang['docEditSuccess'], "index.php?admin_focus-edit-{$did}");
         } else {
             $this->message($this->view->lang['docEditFail'], 'BACK');
         }
     }
 }
Exemple #5
0
 function edit_marker($did, $marker)
 {
     if ('gbk' == strtolower(WIKI_CHARSET)) {
         $marker['title'] = string::hiconv($marker['title'], 'gbk', 'utf-8');
         $marker['description'] = string::hiconv($marker['description'], 'gbk', 'utf-8');
     }
     $this->db->query("REPLACE INTO " . DB_TABLEPRE . "googlemap (`did`,`title`,`description`,`lat`,`lng`,`zoom`,`created`) values \n    \t\t({$did}, '{$marker['title']}', '{$marker['description']}', '{$marker['lat']}', '{$marker['lng']}', '{$marker['zoom']}', {$this->base->time});");
 }
Exemple #6
0
 function doedit()
 {
     $regularname = string::hiconv(trim($this->post['regularname']));
     $regularexpr = trim($this->post['regularexpr']);
     $regulargroupid = $this->post['regulargroupid'];
     $regulargroupid = is_numeric($regulargroupid) ? intval($regulargroupid) : 0;
     $regularname = string::hiconv($regularname);
     $_ENV['regular']->edit_regular($regularname, $regularexpr, $regulargroupid, $this->post['id']);
     $this->message($this->view->lang['regularEditSuccess'], 'index.php?admin_regular');
 }
Exemple #7
0
 function image($srcfile, $targetfile, $settingnew = '')
 {
     $watermarks = is_array($settingnew) ? $settingnew : unserialize($this->base->setting['watermark']);
     foreach ($watermarks as $key => $value) {
         $this->{$key} = $value;
     }
     if ($this->watermarktype == 2 && WIKI_CHARSET == 'GBK') {
         $this->watermarktext['text'] = string::hiconv($this->watermarktext['text'], 'utf-8', 'gbk');
     }
     if ($this->watermarkstatus == '0') {
         return false;
     }
     $this->imageimpath = $this->formaturl(urldecode($this->imageimpath));
     $this->watermarktext['fontpath'] = './style/default/' . $this->watermarktext['fontpath'];
     $this->srcfile = strpos($srcfile, HDWIKI_ROOT) !== false ? realpath(HDWIKI_ROOT . $srcfile) : $srcfile;
     $this->targetfile = strpos($targetfile, HDWIKI_ROOT) !== false ? realpath(HDWIKI_ROOT . $targetfile) : $targetfile;
     $this->attachinfo = @getimagesize($this->srcfile);
     $this->attach['size'] = @filesize($this->srcfile);
     if (!$this->imagelib || !$this->imageimpath) {
         //gd库
         switch ($this->attachinfo['mime']) {
             case 'image/jpeg':
                 $this->imagecreatefromfunc = function_exists('imagecreatefromjpeg') ? 'imagecreatefromjpeg' : '';
                 $this->imagefunc = function_exists('imagejpeg') ? 'imagejpeg' : '';
                 break;
             case 'image/gif':
                 $this->imagecreatefromfunc = function_exists('imagecreatefromgif') ? 'imagecreatefromgif' : '';
                 $this->imagefunc = function_exists('imagegif') ? 'imagegif' : '';
                 break;
             case 'image/png':
                 $this->imagecreatefromfunc = function_exists('imagecreatefrompng') ? 'imagecreatefrompng' : '';
                 $this->imagefunc = function_exists('imagepng') ? 'imagepng' : '';
                 break;
         }
     } else {
         //imagemagick
         $this->imagecreatefromfunc = $this->imagefunc = TRUE;
     }
     if ($this->attachinfo['mime'] == 'image/gif') {
         if ($this->imagecreatefromfunc && !@imagecreatefromgif($srcfile)) {
             //imagemagick并且返回gif图片失败
             return FALSE;
         }
         $fp = fopen($srcfile, 'rb');
         $targetfilecontent = fread($fp, $this->attach['size']);
         fclose($fp);
         $this->animatedgif = strpos($targetfilecontent, 'NETSCAPE2.0') === FALSE ? 0 : 1;
         //判断是静态还是动态
     }
     if ($this->watermarkminwidth && $this->attachinfo[0] <= $this->watermarkminwidth && $this->watermarkminheight && $this->attachinfo[1] <= $this->watermarkminheight || $this->watermarktype == 2 && (!file_exists($this->watermarktext['fontpath']) || !is_file($this->watermarktext['fontpath']))) {
         return false;
     }
     return $this->imagelib && $this->imageimpath ? $this->Watermark_IM() : $this->Watermark_GD();
 }
Exemple #8
0
 function dodefault()
 {
     $len = strlen('plugin-momo-momo-default-');
     $title = substr($_SERVER['QUERY_STRING'], $len);
     $title = urldecode($title);
     $title = trim($title);
     $title2 = $title;
     $title = urldecode($title);
     if (string::hstrtoupper(WIKI_CHARSET) == 'GBK') {
         $title = string::hiconv($title, $to = 'gbk', $from = 'utf-8');
     }
     $doc = $_ENV['momo']->get_doc_by_title($title);
     if ($doc) {
         $doc['image'] = util::getfirstimg($doc['content']);
         $momourl = trim($this->plugin[momo][vars][momourl]);
         if ($momourl) {
             $doc['url'] = $momourl . "index.php?doc-view-" . $doc['did'] . $this->setting['seo_suffix'];
         } else {
             $doc['url'] = $this->setting['site_url'] . "/" . $this->setting['seo_prefix'] . "doc-view-" . $doc['did'] . $this->setting['seo_suffix'];
         }
         $doc_exists = 1;
     } else {
         $url = 'http://www.hudong.com/validateDocSummary.do?doc_title=' . $title2;
         $data = util::hfopen($url);
         $doc_exists = 1;
         if ($data && stripos($data, '<flag>true</flag>') && preg_match_all("/<\\!\\[CDATA\\[(.*)\\]\\]>/", $data, $matches)) {
             $summary = $matches[1][1];
             $image = $matches[1][2];
             if ($summary == 'null') {
                 $summary = '';
             }
             if ($image == 'null') {
                 $image = '';
             }
             if (string::hstrtoupper(WIKI_CHARSET) == 'GBK') {
                 $summary = string::hiconv($summary, $to = 'gbk', $from = 'utf-8');
             }
             $doc = array('image' => $image, 'url' => 'http://www.hudong.com/wiki/' . $title, 'summary' => $summary);
         } else {
             $doc_exists = 0;
         }
     }
     $this->view->assign("doc_exists", $doc_exists);
     $this->view->assign("doc", $doc);
     $this->view->assign("encode", WIKI_CHARSET);
     $this->view->assign("title", $title);
     $this->view->display('file://plugins/momo/view/momo');
 }
Exemple #9
0
 /**
  * 创建分页的词条 sitemap. 有剩余返回当前offset,无剩余返回false
  *
  * @return mixed
  */
 function create_doc_page()
 {
     //获取上次创建分页;
     $current_page = $this->_lastpage_get();
     //如果实际总分页小于当前分页(生成sitemap后又删除一些词条的情况下),则当前页=总分页。
     $rs = $this->db->fetch_first("SELECT count(did) as count_id from " . DB_TABLEPRE . "doc where visible = 1");
     $total_page = empty($rs['count_id']) ? 0 : floor($rs['count_id'] / 1000);
     if ($total_page < $current_page) {
         $current_page = $total_page;
     }
     $current_offset = $current_page * 1000;
     $query = $this->db->query("SELECT did, title, lastedit FROM " . DB_TABLEPRE . "doc where visible = 1 order by did asc limit {$current_offset}, 1000");
     $this->_sitemap_start_new();
     $doc = array();
     $page_last_did = 0;
     while ($row = $this->db->fetch_array($query)) {
         $doc_id = '1' == $this->base->setting['seo_type'] && '1' == $this->base->setting['seo_type_doc'] ? rawurlencode(string::hiconv($row['title'])) : $row['did'];
         $doc['loc'] = WIKI_URL . '/' . $this->base->view->url("doc-view-{$doc_id}");
         $doc['lastmod'] = gmdate('Y-m-d\\TH:i:s+00:00', $row['lastedit']);
         $doc['changefreq'] = $this->setting['doc_changefreq'];
         //////////////////
         $doc['priority'] = "0.8";
         ////////////////
         $this->_sitemap_add_item($doc);
         $page_last_did = $row['did'];
     }
     $this->_sitemap_end_save('sitemap_doc_' . $current_page);
     if ($this->db->affected_rows() < 1000) {
         //如果当前不足一页(每页1000条),则记录最后页为当前页,下次更新继续以当前页更新。
         $this->_lastpage_log($current_page);
     } else {
         //否则记录下次更新以下页开始更新。
         $this->_lastpage_log($current_page + 1);
     }
     $rs = $this->db->fetch_first("SELECT max(did) as max_id from " . DB_TABLEPRE . "doc where visible = 1");
     if (!empty($rs['max_id']) && $page_last_did < $rs['max_id']) {
         //如果当前页最后一条的did小于数据库中的最大did,则表示尚未完毕
         return $current_offset;
     } else {
         //如果是最后,创建索引页
         $this->_create_index();
         return false;
     }
 }
Exemple #10
0
 function dosavesynonym()
 {
     $destdid = $this->post['destdid'];
     if (!is_numeric($destdid)) {
         exit;
     }
     $synonyms = array();
     foreach ($this->post['srctitles'] as $srctitle) {
         $srctitle = htmlspecialchars(string::haddslashes(string::hiconv(trim($srctitle))));
         if ('' != $srctitle) {
             $synonyms[] = $srctitle;
         }
     }
     $desttitle = trim($this->post['desttitle']);
     if (WIKI_CHARSET == 'GBK') {
         $desttitle = string::hiconv($desttitle);
     }
     if (empty($synonyms)) {
         $_ENV['synonym']->removesynonym($destdid);
         exit("empty");
     }
     $srctitles = $synonyms;
     $filter = $_ENV["synonym"]->is_filter($srctitles, $desttitle);
     if ($filter[0] < 0) {
         echo $filter[0];
         exit;
     }
     if (is_array($srctitles) && !empty($desttitle)) {
         $num = $_ENV['synonym']->savesynonym($destdid, $desttitle, $srctitles);
         if ($num > 0) {
             $synonyms_list = $_ENV['synonym']->get_synonym_by_dest($destdid, '');
             $str = '';
             for ($i = 0; $i < count($synonyms_list); $i++) {
                 $str .= "<a href='index.php?doc-innerlink-" . urlencode($synonyms_list[$i]['srctitle']) . "' name='synonym'> " . $synonyms_list[$i]['srctitle'] . "</a>";
             }
             exit($str);
         } else {
             exit('0');
         }
     } else {
         echo $filter[0];
         exit;
     }
 }
Exemple #11
0
 function doadd()
 {
     if (!isset($this->post['submit'])) {
         $this->view->display('admin_addgift');
     } else {
         $title = htmlspecialchars(string::haddslashes(string::hiconv(trim($this->post['title']))));
         $credit = trim($this->post['credit']);
         $description = htmlspecialchars(string::haddslashes(string::hiconv(trim($this->post['description']))));
         $imgname = $_FILES['giftfile']['name'];
         $extname = file::extname($imgname);
         $destfile = 'uploads/gift/' . util::random(8) . '.' . $extname;
         $uploadreturn = file::uploadfile($_FILES['giftfile'], $destfile);
         util::image_compress($destfile, '', 500, 500, '');
         $iamge = util::image_compress($destfile, '', 106, 106, '_s');
         $destfile = $iamge['tempurl'];
         if ($uploadreturn['result'] === false) {
             $this->message($uploadreturn['msg'], 'index.php?admin_gift-search');
         }
         $_ENV['gift']->add($title, $destfile, $credit, $description);
         $this->message($this->view->lang['usermanageOptSuccess'], 'index.php?admin_gift-search');
     }
 }
Exemple #12
0
 function get_html_view($doc)
 {
     if (!empty($doc)) {
         $outxml = '';
         if ('gbk' == strtolower(WIKI_CHARSET)) {
             $transition = 1;
         } else {
             $transition = 0;
         }
         foreach ($doc as $k => $v) {
             if ($transition) {
                 $v = string::hiconv($v, 'utf-8', 'gbk', 1);
             }
             $outxml .= "<{$k}><![CDATA[" . $v . "]]></{$k}>\n";
         }
     } else {
         $outxml = 'No Body! No Body!';
     }
     return $this->get_xml_header() . $outxml . $this->get_xml_footer();
 }
Exemple #13
0
 function doreport()
 {
     $usernames = array();
     $id = $this->post['id'];
     $report = trim(htmlspecialchars(WIKI_CHARSET == GBK ? string::hiconv($this->post['report']) : $this->post['report']));
     if (empty($id) || empty($report)) {
         $this->message(-1, '', 2);
     }
     $users = $_ENV["user"]->get_users('groupid', 4);
     if (!(bool) $users) {
         $this->message(-2, '', 2);
     } else {
         foreach ($users as $user) {
             $usernames[] = $user['username'];
         }
     }
     $sendto = join(',', $usernames);
     $subject = $this->view->lang['commentReportObj'];
     if ($this->user['uid'] == '0') {
         $from = $this->ip;
     } else {
         $from = $this->user['username'];
     }
     $comment = $this->db->fetch_by_field('comment', 'id', $id);
     if (!(bool) $comment) {
         $this->message(-1, '', 2);
     }
     $doc = $this->db->fetch_by_field('doc', 'did', $comment['did']);
     $report = $this->view->lang['commentCom'] . $this->view->lang['commentUser'] . $comment['author'] . '<br/>' . $this->view->lang['commentCom'] . $this->view->lang['commentTime'] . $this->date($comment['time']) . "<br/>" . $this->view->lang['commentId'] . $comment['id'] . '<br/>' . $this->view->lang['commentsDocTitle'] . $doc['title'] . "<br/>" . $this->view->lang['commentContent'] . $comment['comment'] . '<br/>' . $this->view->lang['commentReportReason'] . $report;
     $sendarray = array('sendto' => $sendto, 'subject' => $subject, 'content' => $report, 'isdraft' => 1, 'user' => $this->user);
     $_ENV['pms']->send_ownmessage($sendarray);
     $this->message(1, '', 2);
 }
Exemple #14
0
 function save($did, &$titlelist)
 {
     if (empty($titlelist)) {
         return;
     }
     //词条列表和同义词列表
     $doclist = $this->_getdoc($titlelist);
     $synonymlist = $this->_getsynonym($titlelist);
     $sql = "insert INTO " . DB_TABLEPRE . "innerlinkcache (`did`,`title`,`titleid`)VALUES";
     $data = array();
     foreach ($titlelist as $key => $title) {
         $title2 = urlencode($title);
         $titleid = isset($doclist[$title2]) ? $doclist[$title2] : 0;
         if (!$titleid) {
             $titleid = isset($synonymlist[$title2]) ? -1 : 0;
         }
         $data[] = "('{$did}','{$title}','{$titleid}')";
         $title2 = 'gbk' == strtolower(WIKI_CHARSET) ? string::hiconv($title, 'utf-8', 'gbk') : $title;
         $title2 = urlencode($title2);
         $this->titles[$title2][0] = $titleid;
     }
     $sql .= implode(',', $data);
     $this->db->query($sql);
 }
Exemple #15
0
 function dosave()
 {
     $synonym = str_replace(array("\n", "\r"), ' ', string::hiconv(trim($this->post['synonym']), '', '', true));
     if (empty($synonym)) {
         $this->message($_ENV["synonym"]->encode_data(array(-1, '')), '', 2);
     }
     if (count(explode(',', $synonym)) > 10) {
         $this->message($_ENV["synonym"]->encode_data(array(-8, '')), '', 2);
     }
     $srctitles = array_unique(explode(',', $synonym));
     $returnsyn = stripslashes(implode(',', $srctitles));
     $i = false;
     if (isset($this->post['destdid'])) {
         $destdid = $this->post['destdid'];
         if (!is_numeric($destdid)) {
             $this->message($_ENV["synonym"]->encode_data(array(-1, '')), '', 2);
         }
         $doc = $this->db->fetch_by_field('doc', 'did', $destdid);
         $desttitle = addslashes($doc['title']);
         $i = true;
     } elseif (isset($this->post['desttitle'])) {
         $desttitle = string::hiconv(trim($this->post['desttitle']), '', '', true);
         if ($doc = $this->db->fetch_by_field('doc', 'title', $desttitle)) {
             $destdid = $doc['did'];
         } else {
             $this->message($_ENV["synonym"]->encode_data(array(-7, $desttitle)), '', 2);
         }
     } else {
         $this->message($_ENV["synonym"]->encode_data(array(-1, '')), '', 2);
     }
     $filter = $_ENV["synonym"]->is_filter($srctitles, $desttitle, !$i);
     if ($filter[0] < 0) {
         $this->message($_ENV["synonym"]->encode_data($filter), '', 2);
     }
     if ($_ENV["synonym"]->savesynonym($destdid, $desttitle, $srctitles)) {
         if ($i) {
             $this->message($_ENV["synonym"]->encode_data(array(1, $returnsyn)), '', 2);
         }
         $this->message($_ENV["synonym"]->encode_data(array(1, $desttitle, $doc['author'], $this->date($doc['time']), $destdid, $returnsyn)), '', 2);
     } else {
         $this->message($_ENV["synonym"]->encode_data(array(-1, '')), '', 2);
     }
 }
Exemple #16
0
 function hdautosns()
 {
     $content = array('ding' => '分享词条', 'edit' => '编辑词条', 'create' => '创建词条', 'comment' => '评论词条');
     $action = trim($this->get[2]);
     if (!$this->setting['hdapi_autoshare_' . $action] || !$this->setting['hdapi_sharetosns']) {
         exit('exit');
     }
     $did = trim($this->get[3]);
     $content = $content[$action];
     if (empty($content)) {
         $content = '分享词条';
     }
     if ('comment' == $action) {
         $content = $this->post['comment'];
         if (strtolower(WIKI_CHARSET) == 'gbk') {
             $content = string::hiconv($content, 'gbk', 'utf-8', true);
         }
     }
     $op = 'true';
     $obj = $_ENV['hdapi']->sharetosns($did, $content, $op);
     if (!$obj) {
         exit('err');
     }
     if ($obj->return && $obj->return == 'true') {
         echo 'OK';
     } else {
         echo $obj->errormessage;
     }
 }
Exemple #17
0
 function doprivatedoc()
 {
     $titles = $this->post['titles'];
     if (WIKI_CHARSET == 'GBK') {
         $titles = string::hiconv($titles);
     }
     $titles = explode("\n", $titles);
     $_ENV['hdapi']->update_private_titles($titles);
 }
Exemple #18
0
 function roll_docs($page, $limit = 30)
 {
     $title = NULL;
     $start = ($page - 1) * $limit;
     $sql = "SELECT `did`,`title` FROM `" . DB_TABLEPRE . "doc` WHERE 1 LIMIT {$start},{$limit}";
     $query = $this->db->query($sql);
     while ($tmp = $this->db->fetch_array($query)) {
         if ('gbk' == strtolower(WIKI_CHARSET)) {
             $title[] = string::hiconv($tmp['title'], 'utf-8', 'gbk');
         } else {
             $title[] = $tmp['title'];
         }
     }
     if (!$title) {
         return false;
     } else {
         include HDWIKI_ROOT . '/lib/json.class.php';
         $json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
         $l = NEW_WIKI_POST_URL;
         $sitenick = $this->base->plugin['hdapi']['vars']['sitenick'];
         if ('gbk' == strtolower(WIKI_CHARSET)) {
             $sitenick = string::hiconv($sitenick, 'utf-8', 'gbk');
         }
         $postdata = array('type' => 'batch', 'site_nick' => urlencode($sitenick), 'key' => $this->base->plugin['hdapi']['vars']['sitekey'], 'docList' => $title);
         if ($postdata['site_nick'] && $postdata['key']) {
             $jsondata = 'json=' . $json->encode($postdata);
             $xmldata = $this->hfopen($l, 0, $jsondata);
             return true;
         } else {
             return false;
         }
     }
 }
Exemple #19
0
 function doaddrelatedoc()
 {
     $did = trim($this->post['did']);
     if (is_numeric($did)) {
         $relate = trim($this->post['relatename']);
         $title = htmlspecialchars(trim($this->post['title']));
         if (string::hstrtoupper(WIKI_CHARSET) == 'GBK') {
             $relate = string::hiconv($relate, 'gbk', 'utf-8');
             $title = string::hiconv($title, 'gbk', 'utf-8');
         }
         $list = array();
         if ($relate) {
             $list = array_unique(explode(';', $relate));
             foreach ($list as $key => $relatename) {
                 $relatename = htmlspecialchars($relatename);
                 if ($_ENV['doc']->have_danger_word($relatename)) {
                     unset($list[$key]);
                     $this->message("2", "", 2);
                 }
             }
         }
         $_ENV['doc']->add_relate_title($did, $title, $list);
         $this->message("1", "", 2);
     }
 }
Exemple #20
0
 function dosavetemp()
 {
     //将参数写入临时文件,等待模板“保存修改”时调用参数,存入到数据库。
     $iseidt = isset($this->post['bid']);
     //编辑时
     $bid = $iseidt ? $this->post['bid'] : uniqid('hd');
     file_exists($this->tempfile) && (include $this->tempfile);
     if (strtoupper(WIKI_CHARSET) == 'GBK' && isset($this->post['params'])) {
         //ajax在gbk下传过来的值是utf8的,所以gbk下需要转码。
         //array_walk($this->post['params'],string::hiconv());
         foreach ($this->post['params'] as $key => $val) {
             $this->post['params'][$key] = string::hiconv($val);
         }
     }
     $this->post = string::hstripslashes($this->post);
     if ($this->post['tplcontent']) {
         $tplc = $this->post['tplcontent'];
         unset($this->post['tplcontent']);
     }
     if ($iseidt) {
         if (is_numeric($bid)) {
             //如果是数字,则有可能是第一次编辑,临时表中,并没有他的数据。那么交给get_setting去处理。
             $data = $_ENV['theme']->get_setting($bid);
             $temp[$bid]['block'] = $data['block'];
             $temp[$bid]['fun'] = $data['fun'];
         }
         $temp[$bid]['params'] = $this->post['params'];
         $cls = $temp[$bid]['block'];
         $fun = $temp[$bid]['fun'];
     } else {
         $cls = $this->post['block'];
         $fun = $this->post['fun'];
         $temp[$bid] = $this->post;
     }
     $contents = '<?php $temp=';
     $contents .= var_export($temp, true) . ' ?>';
     file::writetofile($this->tempfile, $contents);
     $this->view->setlang($this->setting['lang_name'], 'front');
     //得到数据
     $blockfile = $_ENV['global']->block_file($GLOBALS['theme'], "/{$cls}/{$cls}.php");
     if (is_file($blockfile)) {
         include_once $blockfile;
         $obj = new $cls($this);
         if (method_exists($obj, $fun)) {
             $blockdata = $obj->{$fun}($this->post['params']);
         } else {
             $blockdata = array();
         }
     }
     //将数据赋值给模板。显示替换上数据的html代码。
     $this->view->assign('bid', $bid);
     $this->view->assign('data', $blockdata);
     //2010-11-8模板代码编辑将文件内容写入临时文件,目的是给下面的预览时模板调用使用。
     $tplfile = HDWIKI_ROOT . "/data/tmp/" . $GLOBALS['theme'] . ".{$cls}.{$fun}.htm";
     isset($tplc) && file::writetofile($tplfile, $tplc);
     if (file_exists($tplfile)) {
         $tplfile = "file://data/tmp/" . $GLOBALS['theme'] . ".{$cls}.{$fun}";
     } else {
         if (!file_exists(HDWIKI_ROOT . '/block/' . $GLOBALS['theme'] . "/{$cls}/{$fun}.htm")) {
             $tplfile = "file://block/default/{$cls}/{$fun}";
         } else {
             $tplfile = 'file://block/' . $GLOBALS['theme'] . "/{$cls}/{$fun}";
         }
     }
     $this->view->display($tplfile);
 }
Exemple #21
0
 function doshortcut()
 {
     $shortcut = trim($this->post['link']);
     if (string::hstrtoupper(WIKI_CHARSET) == 'GBK') {
         $shortcut = string::hiconv($shortcut, 'gbk', 'utf-8');
     }
     $setting['shortcut'] = $shortcut;
     $setting['shortcutstate'] = $this->post['shortcutstate'];
     $_ENV['setting']->update_setting($setting);
     $this->cache->removecache('setting');
     $this->message("1", "", 2);
 }
Exemple #22
0
 function dorename()
 {
     $title = string::hiconv(trim($this->post['newname']));
     $title = string::substring(string::stripspecialcharacter($title), 0, 80);
     if ($title == '') {
         echo "-1";
     } else {
         if ($this->db->fetch_by_field('doc', 'title', $title)) {
             echo "-2";
         } elseif ($_ENV['doc']->change_name($this->post['did'], $title)) {
             if (1 == $this->setting['cloud_search']) {
                 // 编辑标题 通知云搜索
                 $_ENV['search']->cloud_change(array('dids' => $this->post['did'], 'mode' => '2'));
             }
             echo "1";
         } else {
             echo "0";
         }
     }
     $this->cache->removecache('data_' . $GLOBALS['theme'] . '_index');
 }
Exemple #23
0
 function doaddcoins()
 {
     $this->load('pms');
     $uid = $this->post['uid'];
     $names = $this->post['names'];
     $coin = $this->post['coin'];
     $ispms = $this->post['ispms'];
     $content = $this->post['content'];
     $_ENV['user']->add_coin($uid, $coin);
     if (WIKI_CHARSET == 'GBK') {
         $names = string::hiconv($names);
         $content = string::hiconv($content);
     }
     $return = 1;
     if ($ispms) {
         $subject = $this->view->lang['coinManage'];
         $sendarray = array('sendto' => $names, 'subject' => $subject, 'content' => $content, 'isdraft' => 0, 'user' => $this->user);
         if ($names) {
             $return = $_ENV['pms']->send_ownmessage($sendarray);
         }
     }
     echo $return ? 'OK' : '0';
 }
Exemple #24
0
 function filewords($alluploadwords, $attachment_size)
 {
     $filetype = strtolower(substr($_FILES['file_path']['name'], strrpos($_FILES['file_path']['name'], ".") + 1));
     $destfile = 'data/tmp/' . time() . '.' . $filetype;
     $result = file::uploadfile($_FILES['file_path']['tmp_name'], $destfile, $attachment_size, 0);
     if ($result) {
         if (file_exists($destfile)) {
             if (WIKI_CHARSET == 'UTF-8') {
                 $data = string::hiconv(file::readfromfile($destfile), 'utf-8');
             } else {
                 $data = string::hiconv(file::readfromfile($destfile), 'gbk');
             }
         }
         $filewords = array_filter(explode(',', str_replace(',', ',', addslashes($data))), array($this, "trimwords"));
         $alluploadwords = array_merge($alluploadwords, $filewords);
         @unlink($destfile);
     }
     return $alluploadwords;
 }
Exemple #25
0
 function dofulltext()
 {
     if (!$this->get[3] && !$this->get[10]) {
         if (1 == $this->setting['cloud_search']) {
             // 云搜索开启后,关闭本地搜索
             $this->header();
         }
         $all_category = $_ENV['category']->get_category_cache();
         $categorytree = $_ENV['category']->get_categrory_tree($all_category);
         $this->view->assign("categorytree", $categorytree);
         $_ENV['block']->view('search');
     } else {
         $page = isset($this->get[11]) ? $this->get[11] : '';
         if (empty($page) || !is_numeric($page)) {
             $page = 1;
             // 指定时间内只能进行一次搜索
             $search_time = isset($this->setting['search_time']) ? $this->setting['search_time'] : 30;
             if ('' != $this->hgetcookie('searchtime') && $search_time > $this->time - $this->hgetcookie('searchtime')) {
                 $this->message($this->view->lang['search_time_error1'] . $search_time . $this->view->lang['search_time_error2'], "BACK", 0);
             } else {
                 $this->hsetcookie('searchtime', $this->time, 24 * 3600 * 365);
             }
         }
         // 获得搜索类型和搜索关键字
         $element['searchtype'] = $this->get[2];
         // tag or title
         $element['keyword'] = isset($this->get[3]) ? string::haddslashes(str_replace(array('&#45;', '&#46;'), array('-', '.'), rawurldecode($this->get[3]))) : '';
         // 自动转码,将编码变为当前设置编码
         //$element['keyword']= string::hiconv(trim($element['keyword']));
         //$element['keyword']=string::haddslashes($element['keyword'],1);
         $author = isset($this->get[4]) ? string::haddslashes(urldecode($this->get[4])) : '';
         $element['author'] = $author ? str_replace('*', '%', $author) : '';
         $element['categoryid'] = isset($this->get[5]) ? explode(",", $this->get[5]) : 'all';
         $element['timelimited'] = isset($this->get[6]) ? $this->get[6] : 0;
         $element['withinbefore'] = isset($this->get[7]) ? $this->get[7] : 'within';
         $element['ordertype'] = isset($this->get[8]) ? $this->get[8] : 'time';
         $element['ascdesc'] = isset($this->get[9]) ? $this->get[9] : 'desc';
         if (!(bool) $element['keyword']) {
             $this->message($this->view->lang['searchKeywordNull'], "BACK", 0);
         } elseif (strtoupper(substr($element['keyword'], 0, 4)) == 'TAG:' && strlen($element['keyword']) > 4) {
             $element['keyword'] = substr($element['keyword'], 4);
             $element['searchtype'] = 'tag';
         }
         if ($element['searchtype'] != "title" && $element['searchtype'] != "tag" && $element['searchtype'] != "content") {
             $element['searchtype'] = "title";
         }
         if ($element['categoryid'] != "all" && !preg_match("/^\\d[\\d\\,]*?\$/i", implode(",", $element['categoryid']))) {
             $element['categoryid'][0] = "all";
         }
         if (!is_numeric($element['timelimited'])) {
             $element['timelimited'] = 0;
         }
         if ($element['withinbefore'] != "within" && $element['timelimited'] != "before") {
             $element['timelimited'] = "within";
         }
         if ($element['ordertype'] != "time" && $element['ordertype'] != "comments" && $element['ordertype'] != "views") {
             $element['ordertype'] = "time";
         }
         if ($element['ascdesc'] != "asc" && $element['ascdesc'] != "desc") {
             $element['ascdesc'] = "desc";
         }
         // 初始化云搜索
         $cloudsearch = 0;
         if (1 == $this->setting['cloud_search']) {
             //最后一次云搜索异常时间
             $cloud_search_last_time = $this->hgetcookie('lasttime');
             // 异常时,关闭云搜索的时间,默认关闭30秒
             $cloud_search_close_time = isset($this->setting['cloud_search_close_time']) ? $this->setting['cloud_search_close_time'] : 30;
             if (empty($cloud_search_last_time) || $this->time - $cloud_search_last_time > $cloud_search_close_time) {
                 $cloudsearch = 1;
                 // 云搜索
                 $iframesrc = $_ENV['search']->cloud_search($element['keyword']);
                 $this->view->assign('iframesrc', $iframesrc);
                 if (!$iframesrc || 2 > strlen($iframesrc)) {
                     // 显示超时信息
                     // 云搜索超时
                     // 设置暂时关闭云搜索
                     $this->hsetcookie('lasttime', $this->time, $cloud_search_last_time);
                     $cloudsearch = 0;
                 }
             }
         }
         if (0 == $cloudsearch) {
             $result = $_ENV['search']->join_sql($element);
             $count = $_ENV['search']->get_total_num($result['dsql']);
             $count = $count <= 500 ? $count : 500;
             // 最多500条记录
             $num = isset($this->setting['list_prepage']) ? $this->setting['list_prepage'] : 20;
             $start_limit = ($page - 1) * $num;
             $list = $_ENV['search']->fulltext_search($result['sql'], $start_limit, $num);
             $keyword_for_view = str_replace("|", "\\|", $element['keyword']);
             foreach ($list as $key => $value) {
                 $list[$key]['title'] = preg_replace("|({$keyword_for_view})|i", "<span style='color:red'>\$1</span>", $value['title']);
             }
             $url = "search-fulltext-{$element['searchtype']}-" . str_replace(array('-', '.'), array('&#45;', '&#46;'), rawurlencode($element[keyword])) . "-" . urlencode($element[author]) . "-" . implode(',', $element[categoryid]) . "-{$element['timelimited']}-{$element['withinbefore']}-{$element['ordertype']}-{$element['ascdesc']}-1";
             $url = isset($this->setting['seo_prefix']) ? $url : "index.php?" . $url;
             $departstr = $this->multi($count, $num, $page, $url);
             $allcategory = $_ENV['category']->get_category_cache();
             $categorylist = $_ENV['category']->get_site_category(0, $allcategory);
         }
         $searchtext = stripslashes($element['searchtype'] == "tag" ? "TAG:" . stripslashes($element['keyword']) : stripslashes($element['keyword']));
         // 标题搜索,查找同义词,并给出提示
         if ($element['searchtype'] == "title") {
             // 查找同义词
             $synonym = $_ENV['synonym']->get_synonym_by_src($element['keyword']);
             if ($synonym) {
                 //header('Location:index.php?doc-innerlink-'.urlencode($synonym['srctitle']));
                 $synonym['linktitle'] = rawurlencode($synonym['srctitle']);
                 $this->view->assign("synonym", $synonym);
                 //exit;
             } else {
                 //创建词条提示
                 $docexit = $this->db->fetch_by_field('doc', 'title', $element['keyword']);
                 if (!$docexit) {
                     $this->view->assign("docnoexit", 1);
                 }
             }
         }
         $title = htmlspecialchars(stripslashes($element['keyword']));
         $this->view->assign("title", $title);
         $this->view->assign("keyword", rawurlencode($element['keyword']));
         $this->view->assign("searchword", urlencode(string::hiconv($title, 'utf-8')));
         $this->view->assign("search_tip_switch", $this->setting['search_tip_switch']);
         $this->view->assign('cloudsearch', $cloudsearch);
         $this->view->assign('categorylist', $categorylist);
         $this->view->assign("searchtext", $searchtext);
         $this->view->assign("list", $list);
         $this->view->assign("count", $count);
         $this->view->assign('navtitle', $this->view->lang['search'] . '-' . stripslashes(stripslashes($element['keyword'])));
         $this->view->assign("departstr", $departstr);
         //$this->view->display("searchresult");
         $_ENV['block']->view('searchresult');
     }
 }
Exemple #26
0
 function catedoclist($taglist = '')
 {
     $catedoclist = array();
     $tag = preg_split("/\\s+/", trim($taglist));
     foreach ($tag as $t) {
         $t = explode("=", $t);
         $field[$t[0]] = $t[1];
     }
     $limit = $field['rows'] ? $field['rows'] : 10;
     $catename = string::hiconv($field['catename'], WIKI_CHARSET);
     if ($catename) {
         $query = $this->db->query("SELECT * FROM " . DB_TABLEPRE . "category WHERE name='{$catename}' ");
         $cateinfo = $this->db->fetch_array($query);
         $cid = $cateinfo['cid'];
     }
     if (!$cid) {
         $cid = $field['cid'] ? $field['cid'] : 1;
     }
     $this->base->load('doc');
     $catedoclist = $_ENV['doc']->get_docs_by_cid($cid, 0, $limit);
     return $catedoclist;
 }
Exemple #27
0
 function get_jason_data($content)
 {
     include_once HDWIKI_ROOT . '/lib/json.class.php';
     $json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
     // 规范URL
     $siteUrl = strtolower(WIKI_URL);
     $pos = strpos($siteUrl, 'http://');
     if (false === $pos) {
         $pos = strpos($siteUrl, 'https://');
         if (false === $pos) {
             $siteUrl = 'http://' . $siteUrl;
         }
     }
     if ('gbk' == strtolower(WIKI_CHARSET)) {
         $sitename = string::hiconv($this->base->setting['site_name'], 'utf-8', 'gbk');
     } else {
         $sitename = $this->base->setting['site_name'];
     }
     $sitename = urlencode($sitename);
     $jsondata = array_merge(array('siteName' => $sitename, 'siteUrl' => $siteUrl), $content);
     $jsondata = 'json=' . $json->encode($jsondata);
     return $jsondata;
 }
Exemple #28
0
 function docheckrecipient()
 {
     $sendto = $this->post['sendto'];
     if (WIKI_CHARSET == 'GBK') {
         $sendto = string::hiconv($sendto, 'GBK', 'UTF-8', 1);
     }
     $send = explode(',', $sendto);
     if (count($send) > 10) {
         $this->message($this->view->lang['fullsend'], '', 2);
     }
     $checkreturn = $_ENV['pms']->check_recipient($sendto, 0);
     $message = $checkreturn === true ? 'OK' : $checkreturn . ' ' . $this->view->lang['loginTip3'];
     $this->message($message, '', 2);
 }
Exemple #29
0
 function sharetosns($did, $content, $op)
 {
     $doc = $_ENV['hdapi']->get_doc_title_by_id($did, 'title, summary');
     $title = $doc['title'];
     $summary = trim($doc['summary']);
     if (empty($summary)) {
         $doc = $_ENV['hdapi']->get_doc_title_by_id($did, 'content');
         $summary = trim(strip_tags($doc['content']));
         $summary = substr($summary, 0, 250);
     }
     $appkey = $this->base->setting['site_appkey'];
     if ('gbk' == strtolower(WIKI_CHARSET)) {
         $title = string::hiconv($title, 'utf-8', 'gbk');
         $summary = string::hiconv($summary, 'utf-8', 'gbk');
         $content = string::hiconv($content, 'utf-8', 'gbk');
     }
     $summary = string::convercharacter($summary);
     $link = urlencode(WIKI_URL . '/?doc-innerlink-' . urlencode($title));
     $rows = $this->db->fetch_first("SELECT attachment FROM " . DB_TABLEPRE . "attachment WHERE did='{$did}' and isimage=1 order by id desc limit 1");
     if (!empty($rows)) {
         if (strpos($rows['attachment'], '_') === false) {
             $rows['attachment'] = str_replace('.', '_140.', $rows['attachment']);
             if (is_file(HDWIKI_ROOT . '/' . $rows['attachment'])) {
                 $pic = urlencode(WIKI_URL . '/' . $rows['attachment']);
             } else {
                 $pic = '';
             }
         }
     } else {
         $pic = '';
     }
     $post = 'op=' . $op . '&appkey=' . $appkey . '&url=' . $link . '&title=' . urlencode($title) . '&content=' . urlencode($content) . '&pic=' . $pic . '&summary=' . urlencode($summary);
     $data = $this->hfopen(SNS_SHARE_URL, 0, $post);
     $obj = $_ENV['hdapi']->unjson($data);
     return $obj;
 }
Exemple #30
0
 function read_xml($filenames)
 {
     $xmlarray = array();
     $values = array();
     $tags = array();
     $filedir = HDWIKI_ROOT . '/style/' . $filenames . '/';
     if (file_exists($filedir . "desc.xml")) {
         $data = implode("", file($filedir . "desc.xml"));
         $parser = xml_parser_create();
         xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
         xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
         xml_parse_into_struct($parser, $data, $values, $tags);
         xml_parser_free($parser);
         $xmlcounts = count($values);
         $xmlarray['path'] = $filenames;
         for ($x = 0; $x < $xmlcounts; $x++) {
             if ($values[$x]['level'] == 2) {
                 $values[$x]['value'] = string::hiconv($values[$x]['value']);
                 $xmlarray[$values[$x]['tag']] = $values[$x]['value'];
             }
         }
         $filedir = HDWIKI_ROOT . "/style/" . $filenames . '/';
         file::forcemkdir($filedir);
         if (is_file($filedir . "screenshot.jpg")) {
             $xmlarray['img'] = 1;
         }
     }
     return $xmlarray;
 }