redirect_header('search.php', 2, sprintf(_SR_KEYTOOSHORT, $xoopsConfigSearch['keyword_min'])); exit(); } $queries = array($myts->addSlashes($query)); } // entries must be lowercase $allowed = array('p.post_time desc', 't.topic_title', 't.topic_views', 't.topic_replies', 'f.forum_name', 'u.uname'); $sortby = isset($_POST['sortby']) ? $_POST['sortby'] : (isset($_GET['sortby']) ? $_GET['sortby'] : null); $next_search['sortby'] = $sortby; $sortby = (in_array(strtolower($sortby), $allowed)) ? $sortby : 'p.post_time DESC'; $searchin = isset($_POST['searchin']) ? $_POST['searchin'] : (isset($_GET['searchin']) ? $_GET['searchin'] : 'both'); $next_search['searchin'] = $searchin; if (!empty($since)) { $subquery = ' AND p.post_time >= ' . (time() - forum_getSinceTime($since)); } if($uname_required&&(!$uid||count($uid)<1)) $result = false; else $results =& forum_search($queries, $andor, $limit, $start, $uid, $xforum, $sortby, $searchin, $subquery); if ( count($results) < 1 ) { $xoopsTpl->assign("lang_nomatch", _SR_NOMATCH); } else { foreach ($results as $row) { $xoopsTpl->append('results', array('forum_name' => $myts->htmlSpecialChars($row['forum_name']), 'forum_link' => $row['forum_link'], 'link' => $row['link'], 'title' => $row['title'], 'poster' => $row['poster'], 'post_time' => formatTimestamp($row['time'], "m"))); } unset($results); if(count($next_search)>0){
$xoopsTpl->assign_by_ref('forum_selection_order', $forum_selection_order); $since = isset($_GET['since']) ? intval($_GET['since']) : $xoopsModuleConfig["since_default"]; $forum_selection_since = forum_sinceSelectBox($since); $xoopsTpl->assign_by_ref('forum_selection_since', $forum_selection_since); $xoopsTpl->assign('h_topic_link', "viewforum.php?forum=$forum_id&sortname=t.topic_title&since=$since&sortorder=". (($sortname == "t.topic_title" && $sortorder == "DESC") ? "ASC" : "DESC"))."&type=$type"; $xoopsTpl->assign('h_reply_link', "viewforum.php?forum=$forum_id&sortname=t.topic_replies&since=$since&sortorder=". (($sortname == "t.topic_replies" && $sortorder == "DESC") ? "ASC" : "DESC"))."&type=$type"; $xoopsTpl->assign('h_poster_link', "viewforum.php?forum=$forum_id&sortname=u.uname&since=$since&sortorder=". (($sortname == "u.uname" && $sortorder == "DESC") ? "ASC" : "DESC"))."&type=$type"; $xoopsTpl->assign('h_views_link', "viewforum.php?forum=$forum_id&sortname=t.topic_views&since=$since&sortorder=". (($sortname == "t.topic_views" && $sortorder == "DESC") ? "ASC" : "DESC"))."&type=$type"; $xoopsTpl->assign('h_rating_link', "viewforum.php?forum=$forum_id&sortname=t.topic_ratings&since=$since&sortorder=". (($sortname == "t.topic_ratings" && $sortorder == "DESC") ? "ASC" : "DESC"))."&type=$type"; $xoopsTpl->assign('h_date_link', "viewforum.php?forum=$forum_id&sortname=p.post_time&since=$since&sortorder=". (($sortname == "p.post_time" && $sortorder == "DESC") ? "ASC" : "DESC"))."&type=$type"; $xoopsTpl->assign('h_publish_link', "viewforum.php?forum=$forum_id&sortname=t.topic_time&since=$since&sortorder=". (($sortname == "t.topic_time" && $sortorder == "DESC") ? "ASC" : "DESC"))."&type=$type"; $xoopsTpl->assign('forum_since', $since); // For $since in search.php $startdate = empty($since)?0:(time() - forum_getSinceTime($since)); $start = !empty($_GET['start']) ? intval($_GET['start']) : 0; list($allTopics, $sticky) = $forum_handler->getAllTopics($forum_obj,$startdate,$start,$sortname,$sortorder,$type,$xoopsModuleConfig['post_excerpt']); $xoopsTpl->assign_by_ref('topics', $allTopics); //unset($allTopics); $xoopsTpl->assign('sticky', $sticky); $xoopsTpl->assign('rating_enable', $xoopsModuleConfig['rating_enabled']); $xoopsTpl->assign('img_newposts', forum_displayImage($xforumImage['newposts_topic'])); $xoopsTpl->assign('img_hotnewposts', forum_displayImage($xforumImage['hot_newposts_topic'])); $xoopsTpl->assign('img_folder', forum_displayImage($xforumImage['folder_topic'])); $xoopsTpl->assign('img_hotfolder', forum_displayImage($xforumImage['hot_folder_topic'])); $xoopsTpl->assign('img_locked', forum_displayImage($xforumImage['locked_topic'])); $xoopsTpl->assign('img_sticky', forum_displayImage($xforumImage['folder_sticky'],_MD_TOPICSTICKY)); $xoopsTpl->assign('img_digest', forum_displayImage($xforumImage['folder_digest'],_MD_TOPICDIGEST));
function b_forum_author_show($options) { global $xoopsConfig; global $access_forums; $db = &Database::getInstance(); $myts = &MyTextSanitizer::getInstance(); $block = array(); $i = 0; $type = "topic"; $order = "count"; $extra_criteria = ""; $time_criteria = null; if(!empty($options[2])) { $time_criteria = time() - forum_getSinceTime($options[2]); $extra_criteria = " AND topic_time>".$time_criteria; } switch ($options[0]) { case 'topic': break; case 'digest': $extra_criteria = " AND topic_digest=1"; if($time_criteria) $extra_criteria .= " AND digest_time>".$time_criteria; break; case 'sticky': $extra_criteria .= " AND topic_sticky=1"; break; case 'post': default: $type = "post"; if($time_criteria) $extra_criteria = " AND post_time>".$time_criteria; break; } $xforumConfig = getConfigForBlock(); if(!isset($access_forums)){ $forum_handler = &xoops_getmodulehandler('forum', 'xforum'); if(!$access_obj =& $forum_handler->getForums(0, 'access', array('forum_id', 'cat_id', 'forum_type')) ){ return null; } $access_forums = array_keys( $access_obj ); // get all accessible forums unset($access_obj ); } if (!empty($options[5])) { $allowedforums = array_filter(array_slice($options, 5), "b_forum_array_filter"); // get allowed forums $allowed_forums = array_intersect($allowedforums, $access_forums); }else{ $allowed_forums = $access_forums; } if($type=="topic"){ $forum_criteria = ' AND forum_id IN (' . implode(',', $allowed_forums) . ')'; $approve_criteria = ' AND approved = 1'; $query = 'SELECT DISTINCT topic_poster AS author, COUNT(*) AS count FROM ' . $db->prefix('xf_topics') . ' WHERE topic_poster>0 ' . $forum_criteria . $approve_criteria . $extra_criteria . ' GROUP BY topic_poster ORDER BY ' . $order . ' DESC'; }else{ $forum_criteria = ' AND forum_id IN (' . implode(',', $allowed_forums) . ')'; $approve_criteria = ' AND approved = 1'; $query = 'SELECT DISTINCT uid AS author, COUNT(*) AS count FROM ' . $db->prefix('xf_posts') . ' WHERE uid>0 ' . $forum_criteria . $approve_criteria . $extra_criteria . ' GROUP BY uid ORDER BY ' . $order . ' DESC'; } $result = $db->query($query, $options[1], 0); if (!$result) { forum_message("xforum block query error: ".$query); return false; } $author = array(); while ($row = $db->fetchArray($result)) { $author[$row["author"]]["count"] = $row["count"]; } if (count($author) < 1) return false; $author_name = forum_getUnameFromIds(array_keys($author), $xforumConfig['show_realname']); foreach(array_keys($author) as $uid){ $author[$uid]["name"] = $myts->htmlSpecialChars($author_name[$uid]); } $block['authors'] =& $author; $block['disp_mode'] = $options[3]; // 0 - full view; 1 - lite view; $block['indexNav'] = intval($options[4]); return $block; }