$count = DB::result(DB::query("SELECT COUNT(*) FROM " . DB::table('forum_thread') . " t {$apply_sql} WHERE {$wheresql}"), 0); if ($count) { $query = DB::query("SELECT t.* FROM " . DB::table('forum_thread') . " t {$apply_sql}\r\n\t\t\tWHERE {$wheresql}\r\n\t\t\tORDER BY {$ordersql} LIMIT {$start},{$perpage}"); } } if ($count) { loadcache('forums'); $tids = array(); require_once libfile('function/misc'); while ($value = DB::fetch($query)) { if (empty($value['author']) && $value['authorid'] != $_G['uid']) { $hiddennum++; continue; } $tids[$value['tid']] = $value['tid']; $list[$value['tid']] = procthread($value); } if ($tids) { $query = DB::query("SELECT * FROM " . DB::table('forum_poll') . " WHERE tid IN(" . dimplode($tids) . ")"); while ($value = DB::fetch($query)) { $value['pollpreview'] = explode("\t", trim($value['pollpreview'])); $list[$value['tid']]['poll'] = $value; } } $multi = multi($count, $perpage, $page, $theurl); } if ($_G['uid']) { $_G['gp_view'] = !$_G['gp_view'] ? 'we' : $_G['gp_view']; $navtitle = lang('core', 'title_' . $_G['gp_view'] . '_poll'); } else { $_G['gp_order'] = !$_G['gp_order'] ? 'dateline' : $_G['gp_order'];
function getthreadsbytids($tidarray) { global $_G; $threadlist = array(); if (!empty($tidarray)) { loadcache('forums'); include_once libfile('function_misc', 'function'); $fids = array(); foreach (C::t('forum_thread')->fetch_all_by_tid($tidarray) as $result) { if (!isset($_G['cache']['forums'][$result['fid']]['name'])) { $fids[$result['fid']] = $result['tid']; } else { $result['name'] = $_G['cache']['forums'][$result['fid']]['name']; } $threadlist[$result['tid']] = procthread($result); } if (!empty($fids)) { foreach (C::t('forum_forum')->fetch_all_by_fid(array_keys($fids)) as $fid => $forum) { $_G['cache']['forums'][$fid]['forumname'] = $forum['name']; $threadlist[$fids[$fid]]['forumname'] = $forum['name']; } } } return $threadlist; }
require_once DISCUZ_ROOT . './include/misc.func.php'; require_once DISCUZ_ROOT . './forumdata/cache/cache_forums.php'; require_once DISCUZ_ROOT . './forumdata/cache/cache_icons.php'; $tpp = $inajax ? 5 : $tpp; $page = max(1, intval($page)); $start_limit = ($page - 1) * $tpp; $tag = $db->fetch_first("SELECT * FROM {$tablepre}tags WHERE tagname='{$name}'"); if ($tag['closed']) { showmessage('tag_closed'); } $count = $db->result_first("SELECT count(*) FROM {$tablepre}threadtags WHERE tagname='{$name}'"); $query = $db->query("SELECT t.*,tt.tid as tagtid FROM {$tablepre}threadtags tt LEFT JOIN {$tablepre}threads t ON t.tid=tt.tid AND t.displayorder>='0' WHERE tt.tagname='{$name}' ORDER BY lastpost DESC LIMIT {$start_limit}, {$tpp}"); $cleantid = $threadlist = array(); while ($tagthread = $db->fetch_array($query)) { if ($tagthread['tid']) { $threadlist[] = procthread($tagthread); } else { $cleantid[] = $tagthread['tagtid']; } } if ($cleantid) { $db->query("DELETE FROM {$tablepre}threadtags WHERE tagname='{$name}' AND tid IN (" . implodeids($cleantid) . ")", 'UNBUFFERED'); $cleancount = count($cleantid); if ($count > $cleancount) { $db->query("UPDATE {$tablepre}tags SET total=total-'{$cleancount}' WHERE tagname='{$name}'", 'UNBUFFERED'); } else { $db->query("DELETE FROM {$tablepre}tags WHERE tagname='{$name}'", 'UNBUFFERED'); } } $tagnameenc = rawurlencode($name); $navtitle = $name . ' - ';
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 && !DB::result_first("SELECT uid FROM " . DB::table('forum_moderator') . " WHERE uid='{$_G['uid']}' AND fid='{$modfid}'")) { $modfid = 0; } } } $threadlist = $posttables = array(); $query = DB::query("SELECT * FROM " . DB::table('forum_thread') . " WHERE tid IN ({$index['ids']}) AND displayorder>='0' ORDER BY {$orderby} {$ascdesc} LIMIT {$start_limit}, {$_G['tpp']}"); while ($thread = DB::fetch($query)) { $thread['subject'] = bat_highlight($thread['subject'], $keyword); $thread['realtid'] = $thread['isgroup'] == 1 ? $thread['closed'] : $thread['tid']; $threadlist[$thread['tid']] = procthread($thread, 'dt'); $posttables[$thread['posttableid']][] = $thread['tid']; } 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 ($result['fid'] == $_G['fid']) { $total = $result['count']; $tpage = ceil($total / $_G['tpp']); $page = min($tpage, $page); $multipage = multi($total, $_G['tpp'], $page, "{$cpscript}?mod=modcp&action={$_G['gp_action']}&op={$op}&fid={$_G['fid']}&do={$do}"); if ($total) { $start = ($page - 1) * $_G['tpp']; $query = DB::query("SELECT * FROM " . DB::table('forum_thread') . " WHERE tid in({$result['tids']}) ORDER BY lastpost DESC LIMIT {$start}, {$_G['tpp']}"); } } } $postlist = array(); if ($query) { require_once libfile('function/misc'); while ($thread = DB::fetch($query)) { $postlist[] = procthread($thread); } } } return; } if ($op == 'post') { $error = 0; $result = array(); $_G['gp_starttime'] = !preg_match("/^(0|\\d{4}\\-\\d{1,2}\\-\\d{1,2})\$/", getgpc('starttime')) ? dgmdate(TIMESTAMP - 86400 * ($_G['adminid'] == 2 ? 13 : ($_G['adminid'] == 3 ? 6 : 60)), 'Y-m-d') : getgpc('starttime'); $_G['gp_endtime'] = $_G['adminid'] == 3 || !preg_match("/^(0|\\d{4}\\-\\d{1,2}\\-\\d{1,2})\$/", getgpc('endtime')) ? dgmdate(TIMESTAMP, 'Y-m-d') : getgpc('endtime'); foreach (array('threadoption', 'starttime', 'endtime', 'keywords', 'users', 'useip') as $key) { ${$key} = isset($_G['gp_' . $key]) ? trim($_G['gp_' . $key]) : ''; $result[$key] = dhtmlspecialchars(${$key}); } $threadoptionselect = range(1, 3);
showmessage('search_id_invalid'); } $keyword = htmlspecialchars($index['keywords']); $keyword = $keyword != '' ? str_replace('+', ' ', $keyword) : ''; $index['keywords'] = rawurlencode($index['keywords']); $index['ids'] = unserialize($index['ids']); $searchstring = explode('|', $index['searchstring']); $srchfid = $searchstring[2]; $threadlist = $grouplist = $posttables = array(); if ($index['ids']['thread'] && ($searchstring[2] || empty($viewgroup))) { require_once libfile('function/misc'); $query = DB::query("SELECT t.*, f.name AS forumname FROM " . DB::table('forum_thread') . " t LEFT JOIN " . DB::table('forum_forum') . " f ON t.fid=f.fid WHERE t.tid IN ({$index[ids][thread]}) AND t.displayorder>='0' ORDER BY {$orderby} {$ascdesc} LIMIT {$start_limit}, {$_G['tpp']}"); while ($thread = DB::fetch($query)) { $thread['subject'] = bat_highlight($thread['subject'], $keyword); $thread['realtid'] = $thread['tid']; $threadlist[$thread['tid']] = procthread($thread); $posttables[$thread['posttableid']][] = $thread['tid']; } 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); } } } } $groupnum = !empty($index['ids']['group']) ? count(explode(',', $index['ids']['group'])) - 1 : 0; if ($index['ids']['group'] && ($viewgroup || empty($searchstring[2]))) { if (empty($viewgroup)) { $index['ids']['group'] = implode(',', array_slice(explode(',', $index['ids']['group']), 0, 9));
} $contents[$key] = $row['content']; } //排序 ksort($titles); ksort($postlist); ksort($contents); $sp_titles = $cl->BuildExcerpts($titles, $sp_hightlight_index, $sp_keyword, $sp_build_opts); $sp_contents = $cl->BuildExcerpts($contents, $sp_hightlight_index, $sp_keyword, $sp_build_opts); for ($i = 0, $l = count($contents); $i < $l; $i++) { $postlist[$i]['content'] = $sp_contents[$i]; $postlist[$i]['title'] = $sp_titles[$i]; } include template('search_sphinx'); } else { $threadlist = $titles = array(); $query = $db->query("SELECT * FROM {$tablepre}threads WHERE tid IN ({$sp_find_ids})"); // AND displayorder>='0' while ($thread = $db->fetch_array($query)) { $threadlist[$sp_res_order[$thread['tid']]] = procthread($thread); $titles[$sp_res_order[$thread['tid']]] = $thread['subject']; } $sp_titles = $cl->BuildExcerpts($titles, $sp_hightlight_index, $sp_keyword, $sp_build_opts); //排序 ksort($titles); ksort($threadlist); for ($i = 0, $l = count($titles); $i < $l; $i++) { $threadlist[$i]['subject'] = $sp_titles[$i]; } include template('search_threads'); }
} $threadoptionselect[$result['threadoption']] = 'selected'; $total = $result['count']; $tpage = ceil($total / $_G['tpp']); $page = min($tpage, $page); $multipage = multi($total, $_G['tpp'], $page, "{$cpscript}?mod=modcp&action={$action}&op={$op}&fid={$_G['fid']}&do={$do}"); if ($total) { $start = ($page - 1) * $_G['tpp']; $query = DB::query("SELECT * FROM " . DB::table('forum_thread') . " WHERE tid in({$result['tids']}) AND fid='{$_G['fid']}' AND displayorder='-1' ORDER BY lastpost DESC LIMIT {$start}, {$_G['tpp']}"); } } } $postlist = array(); if ($query) { require_once libfile('function/misc'); while ($thread = DB::fetch($query)) { $post = procthread($thread); $post['modthreadkey'] = modauthkey($post['tid']); $postlist[$post['tid']] = $post; } if ($postlist) { $tids = array_keys($postlist); $query = DB::query("SELECT * FROM " . DB::table('forum_threadmod') . " WHERE tid IN(" . dimplode($tids) . ") ORDER BY dateline DESC"); while ($row = DB::fetch($query)) { if (empty($postlist[$row['tid']]['reason'])) { $postlist[$row['tid']]['reason'] = $row['reason']; } } } } }
$list = $cachearr['data']; $hiddennum = $cachearr['hiddennum']; $havecache = true; } } } if (!$havecache) { $count = DB::result(DB::query("SELECT COUNT(*) FROM " . DB::table('forum_thread') . " t WHERE {$wheresql}"), 0); if ($count) { $query = DB::query("SELECT t.* FROM " . DB::table('forum_thread') . " t\r\n\t\t\t\tWHERE {$wheresql}\r\n\t\t\t\tORDER BY {$ordersql} LIMIT {$start},{$perpage}"); while ($value = DB::fetch($query)) { if (empty($value['author']) && $value['authorid'] != $_G['uid']) { $hiddennum++; continue; } $list[] = procthread($value); } if ($_G['gp_view'] == 'all') { $_G['cache']['space_reward'][$alltype] = array('dateline' => $_G['timestamp'], 'hiddennum' => $hiddennum, 'data' => $list); save_syscache('space_reward', $_G['cache']['space_reward']); } if ($_G['gp_view'] != 'all') { $multi = multi($count, $perpage, $page, $theurl); } } } else { $count = count($list); } } $creditid = 0; if ($_G['setting']['creditstransextra'][2]) {
} } $todaytime = strtotime(dgmdate(TIMESTAMP, 'Ymd')); $threadlist = array(); $tids = explode(',', $index['ids']); $threads = C::t('forum_thread')->fetch_all_by_tid($tids, $start_limit, $_G['tpp']); //tids是有序的,但是查出来的threads是无序的。 foreach ($tids as $tid) { foreach ($threads as $thread) { if ($thread['tid'] != $tid) { continue; } $thread['subject'] = bat_highlight($thread['subject'], $keyword); $thread['realtid'] = $thread['isgroup'] == 1 ? $thread['closed'] : $thread['tid']; $thread['allreplies'] = $thread['replies'] + $thread['comments']; $threadlist[] = procthread($thread, 'dt'); break; } } $multipage = multi($index['num'], $_G['tpp'], $page, "source/plugin/ngpt/search.php?" . "mod=seed&" . "searchid={$searchid}&" . "orderby={$orderby}&" . "ascdesc={$ascdesc}&" . "searchsubmit=yes&" . "kw=" . urlencode($keyword) . "&author={$author}&" . "oblue={$onlyblue}&" . "nodead={$nodead}"); $url_forward = 'search.php?mod=forum&' . $_SERVER['QUERY_STRING']; $fulltextchecked = $searchstring[1] == 'fulltext' ? 'checked="checked"' : ''; $_G['forum_threadlist'] = $threadlist; $_G['forum_threadcount'] = count($threadlist); include template('search/seed-main'); } else { $orderby = in_array($_GET['orderby'], array('dateline', 'replies', 'views')) ? $_GET['orderby'] : 'lastpost'; $ascdesc = isset($_GET['ascdesc']) && $_GET['ascdesc'] == 'asc' ? 'asc' : 'desc'; $srchtype = 'title'; $specials = ''; $srchfilter = in_array($_GET['srchfilter'], array('all', 'digest', 'top')) ? $_GET['srchfilter'] : 'all';
} elseif($type == 'reply') { require_once DISCUZ_ROOT.'./include/post.func.php'; $num = $db->result_first("SELECT COUNT(*) FROM {$tablepre}posts p, {$tablepre}threads t WHERE p.authorid='$discuz_uid' AND p.tid=t.tid AND t.special='5' $threadadd"); $multipage = multi($num, $tpp, $page, "my.php?item=debate&type=reply$extrafid"); require_once DISCUZ_ROOT.'./include/misc.func.php'; $query = $db->query("SELECT p.pid, p.message, t.dateline, t.* FROM {$tablepre}posts p, {$tablepre}threads t WHERE p.authorid='$discuz_uid' AND p.first='0' AND p.tid=t.tid AND t.special='5' $threadadd ORDER BY p.dateline DESC LIMIT $start_limit, $tpp"); while($debate = $db->fetch_array($query)) { $debate['message'] = messagecutstr($debate['message'], 100); $debate['forumname'] = $_DCACHE['forums'][$debate['fid']]['name']; $debatelist[] = procthread($debate); } } } elseif($item == 'buddylist') { include_once DISCUZ_ROOT.'./uc_client/client.php'; $buddynum = 999; $extratype = empty($type) ? '' : '&type=fans'; if(!submitcheck('buddysubmit', 1)) { $buddylist = array(); $friendtype = empty($type) ? 3 : 1;
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 getthreadsbytids($tidarray) { global $_G; $threadlist = array(); if (!empty($tidarray)) { loadcache('forums'); include_once libfile('function_misc', 'function'); $query = DB::query("SELECT t.*,f.name FROM " . DB::table('forum_thread') . " t LEFT JOIN " . DB::table('forum_forum') . " f ON f.fid=t.fid WHERE t.tid IN (" . dimplode($tidarray) . ") ORDER BY t.lastpost DESC"); while ($result = DB::fetch($query)) { if (!isset($_G['cache']['forums'][$result['fid']]['name'])) { $_G['cache']['forums'][$result['fid']]['name'] = $result['name']; } $threadlist[] = procthread($result); } } return $threadlist; }
function getthreadlist($tids, $type, $fids, $sid, $havecover, $withpost, $start = 0, $num = 30) { require_once libfile('function/forum'); require_once libfile('function/discuzcode'); global $_G, $block_reply_num, $block_special_data_on, $block_attach_on, $masonry_preread; $query = C::t('#singcere_waterfall#dx')->fetch_all_threads($tids, $type, $fids, $sid, $havecover, $withpost, $start, $num); $threadlist = $tids = array(); foreach ($query as $thread) { $tids[] = $thread['tid']; if ($block_special_data_on && $thread['special']) { $thread['sdata'] = getspecialdata($thread['tid'], $thread['special']); } $thread['coverpath'] = getthreadcover($thread['tid'], $thread['cover']); if ($masonry_preread) { list($thread['w'], $thread['h']) = getimagesize(($thread['cover'] < 0 ? $thread['coverpath'] : DISCUZ_ROOT . $_G['setting']['attachurl']) . 'forum/' . getthreadcover($thread['tid'], $thread['cover'], 1)); } $thread['collections'] = count(explode("\t", $thread['collection'], -1)); $thread['forumname'] = $_G['cache']['forums'][$thread['fid']]['name']; $thread = procthread($thread); $threadlist[$thread[tid]] = $thread; } if ($block_reply_num > 0) { $replies = C::t('#singcere_waterfall#dx')->fetch_all_replies_by_tids($tids, $block_reply_num); foreach ($replies as $reply) { if (count($threadlist[$reply['tid']]['replylist']) <= $block_reply_num) { if ($block_attach_on) { preg_match_all("/\\[attach\\](\\d+)\\[\\/attach\\]/i", $reply['message'], $matchaids); $attachs = parseattach($reply['tid'], $reply['pid'], $matchaids, $reply['message'], $skipaids); $k = $reply['message'] = preg_replace("/\\[attach\\](\\d+)\\[\\/attach\\]/ ", "\$attachs[\\1]", $reply['message']); eval("\$k=\"{$k}\";"); $k = discuzcode($k, FALSE, FALSE); $reply['message'] = $k; $reply['message'] = html2txt($reply['message']); $threadlist[$reply['tid']]['replylist'][] = $reply; } else { $reply['message'] = discuzcode($reply['message'], false, false); $threadlist[$reply['tid']]['replylist'][] = $reply; } } } } return $threadlist; }