/** * Create the results based on a list of ids return from the search implmentation * * @param vB_Current_User $user * @param vB_Search_Criteria criteria for the search * @return vB_Search_Results */ public static function create_from_criteria($user, $criteria, $searchcontroller = null) { global $vbulletin; $results = new vB_Search_Results(); $results->user = $user; $results->criteria = $criteria; $start = microtime(); if (is_null($searchcontroller)) { $searchcontroller = vB_Search_Core::get_instance()->get_search_controller(); $searchcontroller->clear(); } $results->results = $searchcontroller->get_results($user, $criteria); //move log_search call after get_results to allow for any changes to the $criteria //object that might be made by the searchcontroller $results->searchid = $results->log_search(); $results->dateline = TIMENOW; $results->cache_results(); $searchtime = vb_number_format(fetch_microtime_difference($start), 2); $results->searchtime = $searchtime; $results->complete_search($searchtime); //log tag search $filter = $criteria->get_filters('tag'); if (isset($filter[vB_Search_Core::OP_EQ])) { $dm = datamanager_init('tag', $vbulletin, ERRTYPE_ARRAY); $dm->log_tag_search($filter[vB_Search_Core::OP_EQ]); } return $results; }
case 'TRUNCATE': case 'LOAD': default: if (!$vbulletin->GPC['confirmquery']) { print_form_header('queries', 'doquery'); construct_hidden_code('do', 'doquery'); construct_hidden_code('query', $query); construct_hidden_code('perpage', $vbulletin->GPC['perpage']); construct_hidden_code('confirmquery', 1); print_table_header($vbphrase['confirm_query_execution']); print_description_row($vbphrase['query_may_modify_database']); print_submit_row($vbphrase['continue'], false, 2, $vbphrase['go_back']); } else { $time_before = microtime(); $db->query_write($query); $time_taken = fetch_microtime_difference($time_before); print_form_header('queries', 'doquery'); print_table_header($vbphrase['vbulletin_message']); if ($errornum = $db->errno()) { print_description_row(construct_phrase($vbphrase['an_error_occured_while_attempting_to_run_your_query'], $errornum, nl2br(htmlspecialchars_uni($db->error())))); } else { print_description_row(construct_phrase($vbphrase['affected_rows'], vb_number_format($db->affected_rows()), vb_number_format($time_taken, 4))); } print_table_footer(); } break; } } // ##################### START MODIFY ##################### if ($_REQUEST['do'] == 'modify') { print_form_header('queries', 'doquery');
unset($customfieldsheader); if ($show['customfields'] AND is_array($profileinfo)) { foreach ($profileinfo AS $index => $customfield) { $totalcols++; $customfield = $customfield['title']; $templater = vB_Template::create('memberlist_results_header'); $templater->register('customfield', $customfield); $customfieldsheader .= $templater->render(); } } // build navbar $navbits = array('' => $vbphrase['members_list']); $searchtime = vb_number_format(fetch_microtime_difference($searchstart), 2); $totalcols += !empty($usergroupid) ? 2 : 1; $page_templater = vB_Template::create('memberlist'); $page_templater->register('customfieldsheader', $customfieldsheader); $page_templater->register('first', $first); $page_templater->register('forumjump', $forumjump); $page_templater->register('gobutton', $gobutton); $page_templater->register('last', $last); $page_templater->register('leadergroup', $leadergroup); $page_templater->register('letterbits', $letterbits); $page_templater->register('ltr', $ltr); $page_templater->register('memberlistbits', $memberlistbits); $page_templater->register('pagenav', $pagenav); $page_templater->register('perpage', $perpage); $page_templater->register('searchtime', $searchtime);
exec_queries(); } // ############################################################################# // step 2 if ($vbulletin->GPC['step'] == 2) { require_once DIR . '/includes/functions_misc.php'; // change post title field echo_flush("<p>" . sprintf($upgrade_phrases['upgrade_300b5.php']['alter_post_title'], TABLE_PREFIX) . "</i>"); $t = microtime(); $db->query_write("\n\t\tALTER TABLE " . TABLE_PREFIX . "post\n\t\tCHANGE title title VARCHAR(250) NOT NULL DEFAULT ''\n\t"); echo_flush('<br />' . sprintf($vbphrase['query_took'], number_format(fetch_microtime_difference($t), 2)) . '</p>'); // change thread title field echo_flush("<p>" . sprintf($upgrade_phrases['upgrade_300b5.php']['alter_thread_title'], TABLE_PREFIX) . "</i>"); $t = microtime(); $db->query_write("\n\t\tALTER TABLE " . TABLE_PREFIX . "thread\n\t\tCHANGE title title VARCHAR(250) NOT NULL DEFAULT ''\n\t"); echo_flush('<br />' . sprintf($vbphrase['query_took'], number_format(fetch_microtime_difference($t), 2)) . '</p>'); } // ############################################################################# // ask user if they want to change a setting that is causing some of the CP login issues if ($vbulletin->GPC['step'] == 3) { $vbulletin->input->clean_array_gpc('p', array('settingconfirm' => TYPE_UINT, 'disablesetting' => TYPE_UINT)); if ($vbulletin->GPC['settingconfirm'] == 1) { echo '<p>'; if ($vbulletin->GPC['disablesetting'] == 1) { $db->query_write("UPDATE " . TABLE_PREFIX . "setting SET value=0 WHERE varname='timeoutcontrolpanel'"); echo $upgrade_phrases['upgrade_300b5.php']['disabled_timeout_admin']; } else { echo $upgrade_phrases['upgrade_300b5.php']['timeout_admin_not_changed']; } echo '</p>'; } else {
} } else { $posts = $db->query_read_slave("\n\t\t\tSELECT postid\n\t\t\tFROM " . TABLE_PREFIX . "post AS post\n\t\t\tINNER JOIN " . TABLE_PREFIX . "thread AS thread ON(thread.threadid = post.threadid)\n\t\t\tWHERE post.userid = {$user['userid']}\n\t\t\t\t{$sql}\n\t\t\tORDER BY post.dateline DESC\n\t\t\tLIMIT " . $vbulletin->options['maxresults'] * 2 . "\n\t\t"); while ($post = $db->fetch_array($posts)) { $orderedids[] = $post['postid']; } $db->free_result($posts); } // did we get some results? if (empty($orderedids)) { eval(standard_error(fetch_error('searchnoresults', $displayCommon), '', false)); } // set display terms $display = array('words' => array(), 'highlight' => array(), 'common' => array(), 'users' => array($user['userid'] => $user['username']), 'forums' => iif($showforums, $display['forums'], 0), 'options' => array('starteronly' => $starteronly, 'childforums' => 1, 'action' => 'process')); // end search timer $searchtime = number_format(fetch_microtime_difference($searchtime), 5, '.', ''); $sort_order = $showposts ? 'post.dateline' : 'lastpost'; ($hook = vBulletinHook::fetch_hook('search_finduser_complete')) ? eval($hook) : false; /*insert query*/ $db->query_write("\n\t\tREPLACE INTO " . TABLE_PREFIX . "search\n\t\t\t(userid, ipaddress, personal,\n\t\t\tsearchuser, forumchoice,\n\t\t\tsortby, sortorder, searchtime,\n\t\t\tshowposts, orderedids, dateline,\n\t\t\tdisplayterms, searchhash, completed)\n\t\tVALUES\n\t\t\t(" . $vbulletin->userinfo['userid'] . ", '" . $db->escape_string(IPADDRESS) . "', 1,\n\t\t\t'" . $db->escape_string($user['username']) . "', '" . $db->escape_string($forumchoice) . "',\n\t\t\t'{$sort_order}', 'DESC', {$searchtime},\n\t\t\t{$showposts}, '" . $db->escape_string(implode(',', $orderedids)) . "', " . TIMENOW . ",\n\t\t\t'" . $db->escape_string(serialize($display)) . "', '" . $db->escape_string($searchhash) . "', 1)\n\t"); $searchid = $db->insert_id(); $vbulletin->url = 'search.php?' . $vbulletin->session->vars['sessionurl'] . "searchid={$searchid}"; eval(print_standard_redirect('search')); } // ############################################################################# if ($_POST['do'] == 'doprefs') { $vbulletin->input->clean_array_gpc('p', $globals); if ($vbulletin->userinfo['userid']) { // save preferences if ($vbulletin->GPC['saveprefs']) { $prefs = array('exactname' => $vbulletin->GPC['exactname'], 'starteronly' => $vbulletin->GPC['starteronly'], 'childforums' => $vbulletin->GPC['childforums'], 'showposts' => $vbulletin->GPC['showposts'], 'titleonly' => $vbulletin->GPC['titleonly'], 'searchdate' => $vbulletin->GPC['searchdate'], 'beforeafter' => $vbulletin->GPC['beforeafter'], 'sortby' => $vbulletin->GPC['sortby'], 'sortorder' => $vbulletin->GPC['sortorder'], 'replyless' => $vbulletin->GPC['replyless'], 'replylimit' => $vbulletin->GPC['replylimit'], 'searchtype' => $vbulletin->GPC['searchtype']);
$max_id = $indexer->get_max_id(); $finishat = min($vbulletin->GPC['startat'] + $vbulletin->GPC['perpage'], $max_id); echo '<p>' . $vbphrase['building_search_index'] . ' ' . vB_Search_Core::get_instance()->get_search_type_from_id($vbulletin->GPC['indextypes'])->get_display_name() . ' ' . $vbulletin->GPC['startat'] . ' :: ' . $vbulletin->GPC['perpage'] . '</p>'; vbflush(); // Do the indexing if (!$end) { $indexer->index_id_range($vbulletin->GPC['startat'], $finishat); } $pagetime = vb_number_format(fetch_microtime_difference($starttime), 2); echo '</p><p><b>' . construct_phrase($vbphrase['processing_time_x'], $pagetime) . '<br />' . construct_phrase($vbphrase['total_items_processed_x'], $indexer->range_indexed) . '</b></p>'; vbflush(); // There is more to do of that type if ($finishat < $max_id) { if ($vbulletin->GPC['autoredirect'] == 1) { print_cp_redirect("misc.php?" . $vbulletin->session->vars['sessionurl'] . "do=doindextypes&startat=$finishat&pp=" . $vbulletin->GPC['perpage'] . "&autoredirect=" . $vbulletin->GPC['autoredirect'] . "&doprocess=" . $vbulletin->GPC['doprocess'] . "&totalitems=" . $vbulletin->GPC['totalitems'] . "&indextypes=" . $vbulletin->GPC['indextypes']);
$showposts = 1; $searchdate = 0; $beforeafter = 'after'; $replyless = 0; $replylimit = 0; $searchthreadid = 0; $searchhash = md5(TIMENOW . "||" . $vbulletin->userinfo['userid'] . "||" . strtolower($searchuser) . "||{$exactname}||{$starteronly}||{$forumchoice}||{$childforums}||{$titleonly}||{$showposts}||{$searchdate}||{$beforeafter}||{$replyless}||{$replylimit}||{$searchthreadid}"); $searchtime = microtime(); // ############################################################################# // query post ids in dateline DESC order... $orderedids = array(); $posts = $db->query_read("\n\t\tSELECT award.postid AS postid\n\t\tFROM `" . TABLE_PREFIX . "kbank_donations` AS award\n\t\t" . iif($forumchoice, "INNER JOIN `" . TABLE_PREFIX . "post` AS post ON (post.postid = award.postid)\n\t\t\tINNER JOIN `" . TABLE_PREFIX . "thread` AS thread ON (thread.threadid = post.threadid)") . "WHERE award.postid <> 0\n\t\t\tAND award.from <> 0\n\t\t" . iif($forumchoice, "\tAND thread.forumid IN ({$forumchoice})") . "\n\t\tGROUP BY award.postid\n\t\tORDER BY award.time DESC\n\t\tLIMIT " . $vbulletin->options['maxresults'] * 2 . "\n\t"); while ($post = $db->fetch_array($posts)) { $orderedids[] = $post['postid']; } unset($post); $db->free_result($posts); // did we get some results? if (empty($orderedids)) { eval(standard_error(fetch_error('searchnoresults', $displayCommon), '', false)); } // set display terms $display = array('words' => array(), 'highlight' => array(), 'common' => array(), 'forums' => iif($display['forums'], $display['forums'], 0), 'options' => array('starteronly' => 0, 'childforums' => 1, 'action' => 'process', 'award_search_name' => $_REQUEST['do'])); // end search timer $searchtime = fetch_microtime_difference($searchtime); /*insert query*/ $db->query_write("\n\t\tREPLACE INTO " . TABLE_PREFIX . "search (userid, ipaddress, personal, searchuser, forumchoice, sortby, sortorder, searchtime, showposts, orderedids, dateline, displayterms, searchhash)\n\t\tVALUES (" . $vbulletin->userinfo['userid'] . ", '" . $db->escape_string(IPADDRESS) . "', 1, '" . $db->escape_string($user['username']) . "', '" . $db->escape_string($forumchoice) . "', 'post.dateline', 'DESC', {$searchtime}, 1, '" . $db->escape_string(implode(',', $orderedids)) . "', " . TIMENOW . ", '" . $db->escape_string(serialize($display)) . "', '" . $db->escape_string($searchhash) . "')\n\t"); $searchid = $db->insert_id(); $vbulletin->url = "search.php?" . $vbulletin->session->vars['sessionurl'] . "searchid={$searchid}"; eval(print_standard_redirect('search')); }