($hook = vBulletinHook::fetch_hook('search_start')) ? eval($hook) : false; // ############################################################################# if ($_REQUEST['do'] == 'intro') { do_intro($current_user, $globals, $navbits, $search_type); exit; } // ############################################################################# if ($_REQUEST['do'] == 'showresults') { $results = vB_Search_Results::create_from_searchid($current_user, $vbulletin->GPC['searchid']); $base = 'search.php?' . $vbulletin->session->vars['sessionurl'] . 'searchid=' . $vbulletin->GPC['searchid'] . '&pp=' . $perpage; //note that show page will handle blank results just fine if ($results AND ($criteria = $results->get_criteria()) AND $criteria->get_searchtype() == vB_Search_Core::SEARCH_NEW) { $navbits = array( 'search.php' . $vbulletin->session->vars['sessionurl_q'] => $vbphrase['search'], '' => $vbphrase['new_posts_nav'] ); } else { $navbits = array(
function do_showresults($searchid, $pagenumber = 1, $perpage = 25) { global $vbulletin, $db, $show, $vbphrase, $current_user, $show; $vbulletin->options['threadpreview'] = FR_PREVIEW_LEN; $vbulletin->input->clean_array_gpc('r', array('previewtype' => TYPE_INT)); $previewtype = $vbulletin->GPC['previewtype']; if (!$previewtype) { $previewtype = 1; } $bbcode_parser = new vB_BbCodeParser($vbulletin, fetch_tag_list()); // Get exclude IDs $exclude_ids = @explode(',', $vbulletin->options['forumrunner_exclude']); if (in_array('-1', $exclude_ids)) { $exclude_ids = array(); } if ($results = vB_Search_Results::create_from_searchid($current_user, $searchid)) { $pages = $results->get_page($pagenumber, $perpage, 10000); } else { $pages = array(); } if (count($pages) == 0) { $threads[]['error'] = strip_tags(fetch_error('searchnoresults', '')); return array('threads' => $threads, 'total_threads' => count($threads)); } $thread_data = array(); $skipped = 0; foreach ($pages as $item) { switch (get_class($item)) { case 'vBForum_Search_Result_Thread': $thread = $item->get_thread(); $foruminfo = fetch_foruminfo($thread->get_field('forumid')); $parentlist = explode(',', substr($foruminfo['parentlist'], 0, -3)); $skip = false; foreach ($parentlist as $parent_id) { if (in_array($parent_id, $exclude_ids)) { $skip = true; } } if ($thread->get_field('visible') == 2) { $skip = true; } if ($skip) { $skipped++; continue; } $lastread = $thread->get_forum()->get_last_read_by_current_user($current_user); $legacy_thread = process_thread_array($thread->get_record(), $lastread); $date = vbdate($vbulletin->options['dateformat'], $thread->get_field('lastpost')); $time = vbdate($vbulletin->options['timeformat'], $thread->get_field('lastpost')); $previewinfo = $db->query_first_slave("\n\t\tSELECT *\n\t\tFROM " . TABLE_PREFIX . "post\n\t\tWHERE postid = " . $thread->get_field($previewtype == 1 ? 'firstpostid' : 'lastpostid') . "\n\t "); $preview = ''; if (method_exists($bbcode_parser, 'get_preview')) { $preview = $bbcode_parser->get_preview(fetch_censored_text($previewinfo['pagetext']), 200); } else { // vB4 prior to vB4.0.4 did not have get_preview() list($text, $nuked_quotes, $images) = parse_post($previewinfo['pagetext'], true, array()); $preview = preview_chop(fetch_censored_text($nuked_quotes), 200); } $avatarurl = ''; if ($previewinfo['userid'] > 0) { $userinfoavatar = fetch_userinfo($previewinfo['userid'], FETCH_USERINFO_AVATAR); fetch_avatar_from_userinfo($userinfoavatar, true, false); if ($userinfoavatar['avatarurl'] != '') { $avatarurl = process_avatarurl($userinfoavatar['avatarurl']); } unset($userinfoavatar); } $tmp = array('thread_id' => $thread->get_field('threadid'), 'new_posts' => $show['gotonewpost'], 'forum_id' => $thread->get_field('forumid'), 'total_posts' => $thread->get_field('replycount'), 'forum_title' => prepare_utf8_string(strip_tags($foruminfo['title'])), 'thread_title' => prepare_utf8_string(strip_tags($thread->get_field('title'))), 'thread_preview' => prepare_utf8_string(preview_chop(strip_tags(strip_bbcode(html_entity_decode($preview))), FR_PREVIEW_LEN)), 'post_userid' => $previewinfo['userid'], 'post_lastposttime' => prepare_utf8_string(date_trunc($date) . ' ' . $time), 'post_username' => prepare_utf8_string(strip_tags($previewinfo['username']))); if ($avatarurl != '') { $tmp['avatarurl'] = $avatarurl; } if ($thread->get_field('prefixid')) { $prefixid = $thread->get_field('prefixid'); $tmp['prefix'] = prepare_utf8_string(strip_tags($vbphrase["prefix_{$prefixid}_title_plain"])); } if ($thread->get_field('attach')) { $tmp['attach'] = true; } if ($thread->get_field('pollid')) { $tmp['poll'] = true; } $thread_data[] = $tmp; break; case 'vBForum_Search_Result_Post': $post = $item->get_post(); $thread = $post->get_thread(); $foruminfo = fetch_foruminfo($thread->get_field('forumid')); $parentlist = explode(',', substr($foruminfo['parentlist'], 0, -3)); $skip = false; foreach ($parentlist as $parent_id) { if (in_array($parent_id, $exclude_ids)) { $skip = true; } } if ($post->get_field('visible') == 2) { $skip = true; } if ($skip) { $skipped++; continue; } $date = vbdate($vbulletin->options['dateformat'], $post->get_field('dateline')); $time = vbdate($vbulletin->options['timeformat'], $post->get_field('dateline')); $avatarurl = ''; if ($post->get_field('userid') > 0) { $userinfoavatar = fetch_userinfo($post->get_field('userid'), FETCH_USERINFO_AVATAR); fetch_avatar_from_userinfo($userinfoavatar, true, false); if ($userinfoavatar['avatarurl'] != '') { $avatarurl = process_avatarurl($userinfoavatar['avatarurl']); } unset($userinfoavatar); } $tmp = array('thread_id' => $post->get_field('threadid'), 'post_id' => $post->get_field('postid'), 'jump_to_post' => 1, 'forum_id' => $thread->get_field('forumid'), 'forum_title' => prepare_utf8_string(strip_tags($foruminfo['title'])), 'thread_title' => prepare_utf8_string(strip_tags($thread->get_field('title'))), 'thread_preview' => prepare_utf8_string(preview_chop(htmlspecialchars_uni(fetch_censored_text(strip_bbcode(strip_quotes(html_entity_decode($post->get_field('pagetext'))), false, true))), FR_PREVIEW_LEN)), 'post_userid' => $post->get_field('userid'), 'post_lastposttime' => prepare_utf8_string(date_trunc($date) . ' ' . $time), 'post_username' => prepare_utf8_string(strip_tags($post->get_field('username')))); if ($avatarurl != '') { $tmp['avatarurl'] = $avatarurl; } if ($thread->get_field('prefixid')) { $prefixid = $thread->get_field('prefixid'); $tmp['prefix'] = prepare_utf8_string(strip_tags($vbphrase["prefix_{$prefixid}_title_plain"])); } if ($post->get_field('attach')) { $tmp['attach'] = true; } $thread_data[] = $tmp; break; } } $out = array(); if (is_array($thread_data) && count($thread_data) > 0) { $out['threads'] = $thread_data; $out['total_threads'] = max($results->get_confirmed_count() - $skipped, 0); } else { $out['threads'] = array(); $out['total_threads'] = 0; } $out['searchid'] = $searchid; return $out; }