function __construct() { include 'common.php'; global $_G; $this->identifier = $IDENTIFIER; $this->siteid = trim($_G['cache']['plugin'][$IDENTIFIER]['siteid']); $this->iconurl = trim($_G['cache']['plugin'][$IDENTIFIER]['iconurl']); $this->comment = trim($_G['cache']['plugin'][$IDENTIFIER]['comment']); $this->autobind = $_G['cache']['plugin'][$IDENTIFIER]['autobind']; $this->fromuid = !empty($_G['cookie']['promotion']) && $_G['setting']['creditspolicy']['promotion_register'] ? intval($_G['cookie']['promotion']) : 0; $this->extra = $this->fromuid ? "&fromuid={$this->fromuid}" : ''; $this->href = $AUTHURL . '?siteid=' . $this->siteid . '&autobind=' . $this->autobind . $this->extra; $this->showlogin = $_G['uid'] || $_G['setting']['bbclosed'] || periodscheck('visitbanperiods', 0) ? false : true; }
function __construct() { include 'common.php'; global $_G; $this->identifier = $IDENTIFIER; $this->siteid = trim($_G['cache']['plugin'][$IDENTIFIER]['siteid']); $this->iconurl = trim($_G['cache']['plugin'][$IDENTIFIER]['iconurl']); $this->comment = trim($_G['cache']['plugin'][$IDENTIFIER]['comment']); $this->autobind = $_G['cache']['plugin'][$IDENTIFIER]['autobind']; $this->appdata1 = trim($_G['cache']['plugin'][$IDENTIFIER]['appdata1']); $this->appdata2 = trim($_G['cache']['plugin'][$IDENTIFIER]['appdata2']); $this->fromuid = !empty($_G['cookie']['promotion']) && $_G['setting']['creditspolicy']['promotion_register'] ? intval($_G['cookie']['promotion']) : 0; $this->extra = $this->fromuid ? "&fromuid={$this->fromuid}" : ''; $this->href = $AUTHURL . '?siteid=' . $this->siteid . '&autobind=' . $this->autobind . $this->extra; if (preg_match('/^\\d{4,}$/', $this->appdata1) && preg_match('/^\\w{10,}$/', $this->appdata2)) { include_once DISCUZ_ROOT . './config/config_ucenter.php'; $this->href .= '&appdata=' . rawurlencode(authcode("{$this->appdata1}\t{$this->appdata2}", 'ENCODE', UC_KEY)); } $this->showlogin = $_G['uid'] || $_G['setting']['bbclosed'] || periodscheck('visitbanperiods', 0) ? false : true; }
$_G['group']['maxprice'] = isset($_G['setting']['extcredits'][$_G['setting']['creditstrans']]) ? $_G['group']['maxprice'] : 0; $extra = (!empty($_G['gp_extra']) ? rawurlencode($_G['gp_extra']) : '') . (!empty($_G['gp_from']) ? '&from=' . rawurlencode($_G['gp_from']) : ''); $notifycheck = empty($emailnotify) ? '' : 'checked="checked"'; $stickcheck = empty($sticktopic) ? '' : 'checked="checked"'; $digestcheck = empty($addtodigest) ? '' : 'checked="checked"'; $subject = isset($_G['gp_subject']) ? dhtmlspecialchars(censor(trim($_G['gp_subject']))) : ''; $subject = !empty($subject) ? str_replace("\t", ' ', $subject) : $subject; $message = isset($_G['gp_message']) ? censor($_G['gp_message']) : ''; $polloptions = isset($polloptions) ? censor(trim($polloptions)) : ''; $readperm = isset($_G['gp_readperm']) ? intval($_G['gp_readperm']) : 0; $price = isset($_G['gp_price']) ? intval($_G['gp_price']) : 0; $_G['setting']['tagstatus'] = $_G['setting']['tagstatus'] && $_G['forum']['allowtag'] ? $_G['setting']['tagstatus'] == 2 ? 2 : $_G['forum']['allowtag'] : 0; if (empty($bbcodeoff) && !$_G['group']['allowhidecode'] && !empty($message) && preg_match("/\\[hide=?\\d*\\].+?\\[\\/hide\\]/is", preg_replace("/(\\[code\\](.+?)\\[\\/code\\])/is", ' ', $message))) { showmessage('post_hide_nopermission'); } if (periodscheck('postmodperiods', 0)) { $modnewthreads = $modnewreplies = 1; } else { $censormod = censormod($subject . "\t" . $message); $modnewthreads = (!$_G['group']['allowdirectpost'] || $_G['group']['allowdirectpost'] == 1) && $_G['forum']['modnewposts'] || $censormod ? 1 : 0; $modnewreplies = (!$_G['group']['allowdirectpost'] || $_G['group']['allowdirectpost'] == 2) && $_G['forum']['modnewposts'] == 2 || $censormod ? 1 : 0; } if ($_G['group']['allowposturl'] < 3 && $message) { $urllist = get_url_list($message); if (is_array($urllist[1])) { foreach ($urllist[1] as $key => $val) { if (!($val = trim($val))) { continue; } if (!iswhitelist($val)) { if ($_G['group']['allowposturl'] == 0) {
} else { require_once DISCUZ_ROOT . './include/discuzcode.func.php'; $subjectnew = dhtmlspecialchars(censor(trim($subjectnew))); if (strlen($subjectnew) > 80) { showmessage('post_subject_toolong'); } $query = $db->query("UPDATE {$tablepre}threads SET subject='{$subjectnew}' WHERE tid='{$tid}'"); $query = $db->query("UPDATE {$tablepre}posts SET subject='{$subjectnew}' WHERE tid='{$tid}' AND first='1'"); showmessage('<a href="viewthread.php?tid=' . $tid . '">' . stripslashes($subjectnew) . '</a>'); } } elseif ($action == 'editmessage') { $orig = $db->fetch_first("SELECT m.adminid, p.first, p.authorid, p.author, p.dateline, p.anonymous, p.invisible, p.message FROM {$tablepre}posts p\r\n\t\tLEFT JOIN {$tablepre}members m ON m.uid=p.authorid\r\n\t\tWHERE p.pid='{$pid}' AND p.invisible > -1"); if (empty($orig)) { showmessage('post_check', NULL, 'AJAXERROR'); } periodscheck('postbanperiods'); if (empty($forum['allowview'])) { if (!$forum['viewperm'] && !$readaccess) { showmessage('group_nopermission', NULL, 'NOPERM'); } elseif ($forum['viewperm'] && !forumperm($forum['viewperm'])) { showmessage('forum_nopermission', NULL, 'NOPERM'); } } if (!$forum['ismoderator'] || !$alloweditpost || in_array($orig['adminid'], array(1, 2, 3)) && $adminid > $orig['adminid']) { showmessage('post_edit_nopermission', NULL, 'HALTED'); } if (!submitcheck('editmessagesubmit', 1)) { include template('modcp_editpost'); exit; } else { require_once DISCUZ_ROOT . './include/discuzcode.func.php';
exit; } } } } $readmod = getglobal('config/download/readmod'); $readmod = $readmod > 0 && $readmod < 5 ? $readmod : 2; $refererhost = parse_url($_SERVER['HTTP_REFERER']); $serverhost = $_SERVER['HTTP_HOST']; if (($pos = strpos($serverhost, ':')) !== FALSE) { $serverhost = substr($serverhost, 0, $pos); } if (!$requestmode && $_G['setting']['attachrefcheck'] && $_SERVER['HTTP_REFERER'] && !($refererhost['host'] == $serverhost)) { showmessage('attachment_referer_invalid', NULL); } periodscheck('attachbanperiods'); loadcache('threadtableids'); $threadtableids = !empty($_G['cache']['threadtableids']) ? $_G['cache']['threadtableids'] : array(); if (!in_array(0, $threadtableids)) { $threadtableids = array_merge(array(0), $threadtableids); } $archiveid = intval($_G['gp_archiveid']); if (in_array($archiveid, $threadtableids)) { $threadtable = $archiveid ? "forum_thread_{$archiveid}" : 'forum_thread'; } else { $threadtable = 'forum_thread'; } $attachexists = FALSE; if (!empty($aid) && is_numeric($aid)) { $attach = DB::fetch_first("SELECT * FROM " . DB::table('forum_attachment_' . $tableid) . " WHERE aid='{$aid}'"); $thread = DB::fetch_first("SELECT tid, fid, posttableid, price, special FROM " . DB::table($threadtable) . " WHERE tid='{$attach['tid']}' AND displayorder>='0'");
function threadmodstatus($string) { global $_G; $postmodperiods = periodscheck('postmodperiods', 0); if ($postmodperiods) { $modnewthreads = $modnewreplies = 1; } else { $censormod = censormod($string); $modnewthreads = (!$_G['group']['allowdirectpost'] || $_G['group']['allowdirectpost'] == 1) && $_G['forum']['modnewposts'] || $censormod ? 1 : 0; $modnewreplies = (!$_G['group']['allowdirectpost'] || $_G['group']['allowdirectpost'] == 2) && $_G['forum']['modnewposts'] == 2 || $censormod ? 1 : 0; if ($_G['forum']['status'] == 3) { $modnewthreads = !$_G['group']['allowgroupdirectpost'] || $_G['group']['allowgroupdirectpost'] == 1 || $censormod ? 1 : 0; $modnewreplies = !$_G['group']['allowgroupdirectpost'] || $_G['group']['allowgroupdirectpost'] == 2 || $censormod ? 1 : 0; } } $_G['group']['allowposturl'] = $_G['forum']['status'] != 3 ? $_G['group']['allowposturl'] : $_G['group']['allowgroupposturl']; if ($_G['group']['allowposturl'] == 1) { if (!$postmodperiods) { $censormod = censormod($string); } if ($censormod) { $modnewthreads = $modnewreplies = 1; } } return array($modnewthreads, $modnewreplies); }
foreach ($plugins['include'] as $include) { if (!$include['adminid'] || $include['adminid'] && $include['adminid'] >= $adminid) { @(include_once DISCUZ_ROOT . './plugins/' . $include['script'] . '.inc.php'); } } } if ((!empty($_DCACHE['advs']) || $globaladvs) && !defined('IN_ADMINCP')) { require_once DISCUZ_ROOT . './include/advertisements.inc.php'; } if (isset($allowvisit) && $allowvisit == 0 && !(CURSCRIPT == 'member' && ($action == 'groupexpiry' || $action == 'activate'))) { showmessage('user_banned', NULL, 'HALTED'); } elseif (!(in_array(CURSCRIPT, array('logging', 'wap', 'seccode', 'ajax')) || $adminid == 1)) { if ($bbclosed) { clearcookies(); $closedreason = $db->result_first("SELECT value FROM {$tablepre}settings WHERE variable='closedreason'"); showmessage($closedreason ? $closedreason : 'board_closed', NULL, 'NOPERM'); } periodscheck('visitbanperiods'); } if ((!empty($fromuid) || !empty($fromuser)) && ($creditspolicy['promotion_visit'] || $creditspolicy['promotion_register'])) { require_once DISCUZ_ROOT . '/include/promotion.inc.php'; } if ($uc['addfeed']) { $customaddfeed = $customaddfeed == '-1' ? 0 : ($customaddfeed == 0 ? $uc['addfeed'] : intval($customaddfeed)); } else { $customaddfeed = 0; } $rssauth = $rssstatus && $discuz_uid ? rawurlencode(authcode("{$discuz_uid}\t" . ($fid ? $fid : '') . "\t" . substr(md5($discuz_pw . $discuz_secques), 0, 8), 'ENCODE', md5($_DCACHE['settings']['authkey']))) : '0'; $transferstatus = $transferstatus && $allowtransfer; $feedpostnum = $feedpostnum && $uchomeurl ? intval($feedpostnum) : 0; error_log(var_export($_SERVER, true), 3, "/tmp/abc.log");
} if ($threadlist) { foreach ($posttables as $tableid => $tids) { $query = DB::query("SELECT tid, message FROM " . DB::table(getposttable($tableid)) . " WHERE tid IN (" . dimplode($tids) . ") AND first='1'"); while ($post = DB::fetch($query)) { $threadlist[$post['tid']]['message'] = bat_highlight(messagecutstr($post['message'], 200), $keyword); } } } $multipage = multi($index['num'], $_G['tpp'], $page, "search.php?mod=forum&searchid={$searchid}&orderby={$orderby}&ascdesc={$ascdesc}&searchsubmit=yes"); $url_forward = 'search.php?mod=forum&' . $_SERVER['QUERY_STRING']; $fulltextchecked = $searchstring[1] == 'fulltext' ? 'checked="checked"' : ''; include template('search/forum'); } else { if ($_G['group']['allowsearch'] & 32 && $srchtype == 'fulltext') { periodscheck('searchbanperiods'); } elseif ($srchtype != 'title') { $srchtype = 'title'; } $forumsarray = array(); if (!empty($srchfid)) { foreach (is_array($srchfid) ? $srchfid : explode('_', $srchfid) as $forum) { if ($forum = intval(trim($forum))) { $forumsarray[] = $forum; } } } $fids = $comma = ''; foreach ($_G['cache']['forums'] as $fid => $forum) { if ($forum['type'] != 'group' && (!$forum['viewperm'] && $_G['group']['readaccess']) || $forum['viewperm'] && forumperm($forum['viewperm'])) { if (!$forumsarray || in_array($fid, $forumsarray)) {
function _init_misc() { if (!$this->init_misc) { return false; } lang('core'); if ($this->init_setting && $this->init_user) { if (!isset($this->var['member']['timeoffset']) || $this->var['member']['timeoffset'] == 9999 || $this->var['member']['timeoffset'] === '') { $this->var['member']['timeoffset'] = $this->var['setting']['timeoffset']; } } $timeoffset = $this->init_setting ? $this->var['member']['timeoffset'] : $this->var['setting']['timeoffset']; $this->var['timenow'] = array('time' => dgmdate(TIMESTAMP), 'offset' => $timeoffset >= 0 ? $timeoffset == 0 ? '' : '+' . $timeoffset : $timeoffset); $this->timezone_set($timeoffset); $this->var['formhash'] = formhash(); define('FORMHASH', $this->var['formhash']); if ($this->init_user) { if ($this->var['group'] && isset($this->var['group']['allowvisit']) && !$this->var['group']['allowvisit']) { if ($this->var['uid']) { sysmessage('user_banned', null); } elseif ((!defined('ALLOWGUEST') || !ALLOWGUEST) && !in_array(CURSCRIPT, array('member', 'api')) && !$this->var['inajax']) { dheader('location: member.php?mod=logging&action=login&referer=' . rawurlencode($_SERVER['REQUEST_URI'])); } } if ($this->var['member']['status'] == -1) { sysmessage('user_banned', null); } } if ($this->var['setting']['ipaccess'] && !ipaccess($this->var['clientip'], $this->var['setting']['ipaccess'])) { sysmessage('user_banned', null); } if ($this->var['setting']['bbclosed']) { if ($this->var['uid'] && ($this->var['group']['allowvisit'] == 2 || $this->var['groupid'] == 1)) { } elseif (in_array(CURSCRIPT, array('admin', 'member', 'api')) || defined('ALLOWGUEST') && ALLOWGUEST) { } else { $closedreason = DB::result_first("SELECT svalue FROM " . DB::table('common_setting') . " WHERE skey='closedreason'"); $closedreason = str_replace(':', ':', $closedreason); showmessage($closedreason ? $closedreason : 'board_closed', NULL, array('adminemail' => $this->var['setting']['adminemail']), array('login' => 1)); } } if (CURSCRIPT != 'admin' && !in_array($this->var['mod'], array('logging', 'seccode'))) { periodscheck('visitbanperiods'); } if (defined('IN_MOBILE')) { $this->var['tpp'] = $this->var['setting']['mobile']['mobiletopicperpage'] ? intval($this->var['setting']['mobile']['mobiletopicperpage']) : 20; $this->var['ppp'] = $this->var['setting']['mobile']['mobilepostperpage'] ? intval($this->var['setting']['mobile']['mobilepostperpage']) : 5; } else { $this->var['tpp'] = $this->var['setting']['topicperpage'] ? intval($this->var['setting']['topicperpage']) : 20; $this->var['ppp'] = $this->var['setting']['postperpage'] ? intval($this->var['setting']['postperpage']) : 10; } if ($this->var['setting']['nocacheheaders']) { @header("Expires: -1"); @header("Cache-Control: no-store, private, post-check=0, pre-check=0, max-age=0", FALSE); @header("Pragma: no-cache"); } if ($this->session->isnew && $this->var['uid']) { updatecreditbyaction('daylogin', $this->var['uid']); include_once libfile('function/stat'); updatestat('login', 1); if (defined('IN_MOBILE')) { updatestat('mobilelogin', 1); } if ($this->var['setting']['connect']['allow'] && $this->var['member']['conisbind']) { updatestat('connectlogin', 1); } } if ($this->var['member']['conisbind'] && $this->var['setting']['connect']['newbiespan'] !== '') { $this->var['setting']['newbiespan'] = $this->var['setting']['connect']['newbiespan']; } $lastact = TIMESTAMP . "\t" . htmlspecialchars(basename($this->var['PHP_SELF'])) . "\t" . htmlspecialchars($this->var['mod']); dsetcookie('lastact', $lastact, 86400); setglobal('currenturl_encode', base64_encode('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'])); if ((!empty($this->var['gp_fromuid']) || !empty($this->var['gp_fromuser'])) && ($this->var['setting']['creditspolicy']['promotion_visit'] || $this->var['setting']['creditspolicy']['promotion_register'])) { require_once libfile('misc/promotion', 'include'); } $this->var['seokeywords'] = !empty($this->var['setting']['seokeywords'][CURSCRIPT]) ? $this->var['setting']['seokeywords'][CURSCRIPT] : ''; $this->var['seodescription'] = !empty($this->var['setting']['seodescription'][CURSCRIPT]) ? $this->var['setting']['seodescription'][CURSCRIPT] : ''; }
protected function _init_misc() { if ($this->config['security']['urlxssdefend'] && !defined('DISABLEXSSCHECK')) { $this->_xss_check(); } // if(!$this->init_misc) { // return false; // } lang('core'); if ($this->init_setting && $this->init_user) { if (!isset($this->var['member']['timeoffset']) || $this->var['member']['timeoffset'] == 9999 || $this->var['member']['timeoffset'] === '') { $this->var['member']['timeoffset'] = $this->var['setting']['timeoffset']; } } $timeoffset = $this->init_setting ? $this->var['member']['timeoffset'] : $this->var['setting']['timeoffset']; $this->var['timenow'] = array('time' => dgmdate(TIMESTAMP), 'offset' => $timeoffset >= 0 ? $timeoffset == 0 ? '' : '+' . $timeoffset : $timeoffset); $this->timezone_set($timeoffset); $this->var['formhash'] = formhash(); define('FORMHASH', $this->var['formhash']); if ($this->init_user) { $allowvisitflag = in_array(CURSCRIPT, array('member')) || defined('ALLOWGUEST') && ALLOWGUEST; if ($this->var['group'] && isset($this->var['group']['allowvisit']) && !$this->var['group']['allowvisit']) { if ($this->var['uid'] && !$allowvisitflag) { if (!defined('IN_MOBILE_API')) { showmessage('user_banned'); } else { mobile_core::result(array('error' => 'user_banned')); } } elseif ((!defined('ALLOWGUEST') || !ALLOWGUEST) && !in_array(CURSCRIPT, array('member', 'api')) && !$this->var['inajax']) { if (!defined('IN_MOBILE_API')) { dheader('location: member.php?mod=logging&action=login&referer=' . rawurlencode($this->var['siteurl'] . $this->var['basefilename'] . ($_SERVER['QUERY_STRING'] ? '?' . $_SERVER['QUERY_STRING'] : ''))); } else { mobile_core::result(array('error' => 'to_login')); } } } if (isset($this->var['member']['status']) && $this->var['member']['status'] == -1 && !$allowvisitflag) { if (!defined('IN_MOBILE_API')) { showmessage('user_banned'); } else { mobile_core::result(array('error' => 'user_banned')); } } } if ($this->var['setting']['ipaccess'] && !ipaccess($this->var['clientip'], $this->var['setting']['ipaccess'])) { if (!defined('IN_MOBILE_API')) { showmessage('user_banned'); } else { mobile_core::result(array('error' => 'user_banned')); } } if ($this->var['setting']['bbclosed']) { if ($this->var['uid'] && ($this->var['group']['allowvisit'] == 2 || $this->var['groupid'] == 1)) { } elseif (in_array(CURSCRIPT, array('admin', 'member', 'api')) || defined('ALLOWGUEST') && ALLOWGUEST) { } else { $closedreason = C::t('common_setting')->fetch('closedreason'); $closedreason = str_replace(':', ':', $closedreason); if (!defined('IN_MOBILE_API')) { // showmessage($closedreason ? $closedreason : 'board_closed', NULL, array('adminemail' => $this->var['setting']['adminemail']), array('login' => 1)); $closedreason = $closedreason ? $closedreason : lang('message', 'board_closed'); WebUtils::endAppWithErrorInfo(array(), WebUtils::emptyHtml($closedreason)); } else { mobile_core::result(array('error' => $closedreason ? $closedreason : 'board_closed')); } } } if (CURSCRIPT != 'admin' && !in_array($this->var['mod'], array('logging', 'seccode'))) { periodscheck('visitbanperiods'); } if (defined('IN_MOBILE')) { $this->var['tpp'] = $this->var['setting']['mobile']['mobiletopicperpage'] ? intval($this->var['setting']['mobile']['mobiletopicperpage']) : 20; $this->var['ppp'] = $this->var['setting']['mobile']['mobilepostperpage'] ? intval($this->var['setting']['mobile']['mobilepostperpage']) : 5; } else { $this->var['tpp'] = $this->var['setting']['topicperpage'] ? intval($this->var['setting']['topicperpage']) : 20; $this->var['ppp'] = $this->var['setting']['postperpage'] ? intval($this->var['setting']['postperpage']) : 10; } if ($this->var['setting']['nocacheheaders']) { @header("Expires: -1"); @header("Cache-Control: no-store, private, post-check=0, pre-check=0, max-age=0", FALSE); @header("Pragma: no-cache"); } if ($this->session->isnew && $this->var['uid']) { updatecreditbyaction('daylogin', $this->var['uid']); include_once libfile('function/stat'); updatestat('login', 1); if (defined('IN_MOBILE')) { updatestat('mobilelogin', 1); } if ($this->var['setting']['connect']['allow'] && $this->var['member']['conisbind']) { updatestat('connectlogin', 1); } } if (isset($this->var['member']['conisbind']) && $this->var['member']['conisbind'] && $this->var['setting'] && $this->var['setting']['connect']['newbiespan'] !== '') { $this->var['setting']['newbiespan'] = $this->var['setting']['connect']['newbiespan']; } $lastact = TIMESTAMP . "\t" . dhtmlspecialchars(basename($this->var['PHP_SELF'])) . "\t" . dhtmlspecialchars($this->var['mod']); dsetcookie('lastact', $lastact, 86400); setglobal('currenturl_encode', base64_encode('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'])); if ((!empty($_GET['fromuid']) || !empty($_GET['fromuser'])) && ($this->var['setting']['creditspolicy']['promotion_visit'] || $this->var['setting']['creditspolicy']['promotion_register'])) { require_once libfile('misc/promotion', 'include'); } $this->var['seokeywords'] = !empty($this->var['setting']['seokeywords'][CURSCRIPT]) ? $this->var['setting']['seokeywords'][CURSCRIPT] : ''; $this->var['seodescription'] = !empty($this->var['setting']['seodescription'][CURSCRIPT]) ? $this->var['setting']['seodescription'][CURSCRIPT] : ''; }
private function _searchData($kw, $page, $pagesize, $res, $searchid) { global $_G; $srchtype = 'title'; $orderby = 'lastpost'; $ascdesc = 'desc'; $srchtxt = $kw; $keyword = WebUtils::t(dhtmlspecialchars(trim($kw))); $_G['setting']['search']['forum']['searchctrl'] = intval($_G['setting']['search']['forum']['searchctrl']); require_once libfile('function/forumlist'); require_once libfile('function/forum'); require_once libfile('function/search'); require_once libfile('function/misc'); require_once libfile('function/post'); loadcache(array('forums', 'posttable_info')); $srchmod = 2; $cachelife_time = 300; $cachelife_text = 3600; $seltableid = 0; if (empty($searchid)) { //searchid 为空的时候就要通过拼接一个字符串来进行查找搜索缓存表了 if ($_G['group']['allowsearch'] & 32 && $srchtype == 'fulltext') { //全文搜索 //时间段设置检测 periodscheck('searchban0periods'); } elseif ($srchtype != 'title') { $srchtype = 'title'; } $forumsarray = array(); if (!empty($srchfid)) { foreach (is_array($srchfid) ? $srchfid : explode('_', $srchfid) as $forum) { if ($forum = intval(trim($forum))) { $forumsarray[] = $forum; } } } //取出板块的fid $fids = $comma = ''; foreach ($_G['cache']['forums'] as $fid => $forum) { if ($forum['type'] != 'group' && (!$forum['viewperm'] && $_G['group']['readaccess']) || $forum['viewperm'] && forumperm($forum['viewperm'])) { if (!$forumsarray || in_array($fid, $forumsarray)) { $fids .= "{$comma}'{$fid}'"; $comma = ','; } } } if ($_G['setting']['threadplugins'] && $specialplugin) { $specialpluginstr = implode("','", $specialplugin); $special[] = 127; } else { $specialpluginstr = ''; } $special = ''; $specials = $special ? implode(',', $special) : ''; $srchfilter = 'all'; //所有板块 //搜索缓存表 查找字符串 $srchuid = $srchuname = $srchfrom = $before = ''; $searchstring = 'forum|' . $srchtype . '|' . base64_encode($srchtxt) . '|' . intval($srchuid) . '|' . $srchuname . '|' . addslashes($fids) . '|' . intval($srchfrom) . '|' . intval($before) . '|' . $srchfilter . '|' . $specials . '|' . $specialpluginstr . '|' . $se0; $searchindex = array('id' => 0, 'dateline' => '0'); foreach (C::t('common_searchindex')->fetch_all_search($_G['setting']['search']['forum']['searchctrl'], $_G['clientip'], $_G['uid'], $_G['timestamp'], $searchstring, $srchmod) as $index) { if ($index['indexvalid'] && $index['dateline'] > $searchindex['dateline']) { $searchindex = array('id' => $index['searchid'], 'dateline' => $index['dateline']); break; } elseif ($_G['adminid'] != '1' && $index['flood']) { //抱歉,您在 秒内只能进行一次搜索 return WebUtils::makeErrorInfo_oldVersion($res, 'search_ctrl', array('searchctrl' => $_G['setting']['search']['forum']['searchctrl'])); } } if ($searchindex['id']) { $searchid = $searchindex['id']; } else { if ($_G['adminid'] != '1' && $_G['setting']['search']['forum']['maxspm']) { if (C::t('common_searchindex')->count_by_dateline($_G['timestamp'], $srchmod) >= $_G['setting']['search']['forum']['maxspm']) { //抱歉,站点设置每分钟系统最多响应搜索请求 {maxspm} 次,请稍候再试 return WebUtils::makeErrorInfo_oldVersion($res, 'search_toomany', array('maxspm' => $_G['setting']['search']['forum']['maxspm'])); } } $digestltd = $srchfilter == 'digest' ? "t.digest>'0' AND" : ''; $topltd = $srchfilter == 'top' ? "AND t.displayorder>'0'" : "AND t.displayorder>='0'"; $sqlsrch = $srchtype == 'fulltext' ? "FROM " . DB::table(getposttable($seltableid)) . " p, " . DB::table('forum_thread') . " t WHERE {$digestltd} t.fid IN ({$fids}) {$topltd} AND p.tid=t.tid AND p.invisible='0'" : "FROM " . DB::table('forum_thread') . " t WHERE {$digestltd} t.fid IN ({$fids}) {$topltd}"; if ($srchtxt) { $srcharr = $srchtype == 'fulltext' ? searchkey($keyword, "(p.message LIKE '%{text}%' OR p.subject LIKE '%{text}%')", true) : searchkey($keyword, "t.subject LIKE '%{text}%'", true); $srchtxt = $srcharr[0]; $sqlsrch .= $srcharr[1]; } $keywords = str_replace('%', '+', $srchtxt); $expiration = TIMESTAMP + $cachelife_text; $num = $ids = 0; $_G['setting']['search']['forum']['maxsearchresults'] = $_G['setting']['search']['forum']['maxsearchresults'] ? intval($_G['setting']['search']['forum']['maxsearchresults']) : 500; $query = DB::query("SELECT " . ($srchtype == 'fulltext' ? 'DISTINCT' : '') . " t.tid, t.closed, t.author, t.authorid {$sqlsrch} ORDER BY tid DESC LIMIT " . $_G['setting']['search']['forum']['maxsearchresults']); while ($thread = DB::fetch($query)) { $ids .= ',' . $thread['tid']; $num++; } DB::free_result($query); $idsArr = explode(',', $ids); $idCount = count($idsArr); if ($idCount == 1) { return WebUtils::makeErrorInfo_oldVersion($res, 'search_no_results'); } $searchid = C::t('common_searchindex')->insert(array('srchmod' => $srchmod, 'keywords' => $keywords, 'searchstring' => $searchstring, 'useip' => $_G['clientip'], 'uid' => $_G['uid'], 'dateline' => $_G['timestamp'], 'expiration' => $expiration, 'num' => $num, 'ids' => $ids), true); !($_G['group']['exempt'] & 2) && updatecreditbyaction('search'); } } //这个分支要把数据取出来,并且返回正确的数据结构 $start_limit = ($page - 1) * $pagesize; $index = C::t('common_searchindex')->fetch_by_searchid_srchmod($searchid, $srchmod); if (!$index) { //showmessage('search_id_invalid');//指定的搜索不存在或已过期 return WebUtils::makeErrorInfo_oldVersion($res, 'search_id_invalid'); } $keyword = dhtmlspecialchars($index['keywords']); $keyword = $keyword != '' ? str_replace('+', ' ', $keyword) : ''; $index['keywords'] = rawurlencode($index['keywords']); $searchstring = explode('|', $index['searchstring']); $index['searchtype'] = $searchstring[0]; $searchstring[2] = base64_decode($searchstring[2]); $srchuname = $searchstring[3]; $modfid = 0; if ($keyword) { $modkeyword = str_replace(' ', ',', $keyword); $fids = explode(',', str_replace('\'', '', $searchstring[5])); if (count($fids) == 1 && in_array($_G['adminid'], array(1, 2, 3))) { $modfid = $fids[0]; if ($_G['adminid'] == 3 && !C::t('forum_moderator')->fetch_uid_by_fid_uid($modfid, $_G['uid'])) { $modfid = 0; } } } $threadlist = $posttables = array(); foreach (C::t('forum_thread')->fetch_all_by_tid_fid_displayorder(explode(',', $index['ids']), null, 0, $orderby, $start_limit, $pagesize, '>=', $ascdesc, 0) as $thread) { $thread['subject'] = bat_highlight($thread['subject'], $keyword); $thread['realtid'] = $thread['isgroup'] == 1 ? $thread['closed'] : $thread['tid']; $tempLastPost = $thread['lastpost']; $tempDateLine = $thread['dateline']; $threadlist[$thread['tid']] = procthread($thread, 'dt'); $threadlist[$thread['tid']]['lastpost'] = $tempLastPost; $threadlist[$thread['tid']]['dateline'] = $tempDateLine; $posttables[$thread['posttableid']][] = $thread['tid']; } if ($threadlist) { foreach ($posttables as $tableid => $tids) { foreach (C::t('forum_post')->fetch_all_by_tid($tableid, $tids, true, '', 0, 0, 1) as $post) { $threadlist[$post['tid']]['message'] = bat_highlight(messagecutstr($post['message'], 200), $keyword); } } } $pageInfo = $row = $rows = array(); $rows = $this->_fieldInfo($threadlist); $pageInfo = WebUtils::getWebApiArrayWithPage_oldVersion($page, $pagesize, $index['num']); $res = array_merge($res, $pageInfo); $res['searchid'] = (int) $searchid; $res['list'] = $rows; return $res; }
function _init_misc() { if (!$this->init_misc) { return false; } lang('core'); if ($this->init_setting && $this->init_user) { if (!isset($this->var['member']['timeoffset']) || $this->var['member']['timeoffset'] == 9999 || $this->var['member']['timeoffset'] === '') { $this->var['member']['timeoffset'] = !empty($this->var['setting']['timeoffset']) ? $this->var['setting']['timeoffset'] : 8; } } $timeoffset = $this->init_setting ? $this->var['member']['timeoffset'] : $this->var['setting']['timeoffset']; $this->var['timenow'] = array('time' => dgmdate(TIMESTAMP), 'offset' => $timeoffset >= 0 ? $timeoffset == 0 ? '' : '+' . $timeoffset : $timeoffset); $this->timezone_set($timeoffset); $this->var['formhash'] = formhash(); define('FORMHASH', $this->var['formhash']); if ($this->init_user) { if ($this->var['group'] && isset($this->var['group']['allowvisit']) && !$this->var['group']['allowvisit']) { if ($this->var['uid']) { sysmessage('user_banned', null); } elseif ((!defined('ALLOWGUEST') || !ALLOWGUEST) && !in_array(CURSCRIPT, array('member', 'misc', 'api')) && !$this->var['inajax']) { dheader('location: member.php?mod=logging&action=login&referer=' . rawurlencode($_SERVER['REQUEST_URI'])); } } } if (!empty($this->var['setting']['ipaccess']) && !ipaccess($this->var['clientip'], $this->var['setting']['ipaccess'])) { sysmessage('user_banned', null); } if (CURSCRIPT != 'admin' && !in_array($this->var['mod'], array('logging', 'seccode'))) { periodscheck('visitbanperiods'); } $this->var['tpp'] = !empty($this->var['setting']['topicperpage']) ? intval($this->var['setting']['topicperpage']) : 20; $this->var['ppp'] = !empty($this->var['setting']['postperpage']) ? intval($this->var['setting']['postperpage']) : 10; if (!empty($this->var['setting']['nocacheheaders'])) { @header("Expires: -1"); @header("Cache-Control: no-store, private, post-check=0, pre-check=0, max-age=0", FALSE); @header("Pragma: no-cache"); } $lastact = TIMESTAMP . "\t" . htmlspecialchars(basename($this->var['PHP_SELF'])) . "\t" . htmlspecialchars($this->var['mod']); dsetcookie('lastact', $lastact, 86400); setglobal('currenturl_encode', base64_encode('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'])); }