function do_process_search(&$searchid, &$reterrors) { global $vbulletin, $db, $vbphrase, $search_core, $search_type, $globals, $current_user; if (!$vbulletin->options['enablesearches']) { $searchid = -1; $reterrors[] = 'searchdisabled'; return; } $errors = array(); ($hook = vBulletinHook::fetch_hook('search_before_process')) ? eval($hook) : false; ($hook = vBulletinHook::fetch_hook('search_process_start')) ? eval($hook) : false; if (!$vbulletin->options['threadtagging']) { // tagging disabled, don't let them search on it $vbulletin->GPC['tag'] = ''; } if ($vbulletin->GPC['userid'] and $userinfo = fetch_userinfo($vbulletin->GPC['userid'])) { $vbulletin->GPC_exists['searchuser'] = true; $vbulletin->GPC['searchuser'] = unhtmlspecialchars($userinfo['username']); } if ($vbulletin->GPC['searchthreadid']) { $vbulletin->GPC['sortby'] = 'dateline'; $vbulletin->GPC['sortorder'] = 'ASC'; $vbulletin->GPC['showposts'] = true; $vbulletin->GPC['starteronly'] = false; $vbulletin->GPC['titleonly'] = false; } // if searching for only a tag, we must show results as threads if ($vbulletin->GPC['tag'] and empty($vbulletin->GPC['query']) and empty($vbulletin->GPC['searchuser'])) { $vbulletin->GPC['showposts'] = false; } //do this even if the hv check fails to make sure that the user sees any errors //nothing worse then typing in a capcha five times only to get a message saying //fix something and type it in again. if ($vbulletin->GPC['contenttypeid'] and !is_array($vbulletin->GPC['contenttypeid'])) { $criteria = $search_core->create_criteria(vB_Search_Core::SEARCH_ADVANCED); $criteria->set_advanced_typeid($vbulletin->GPC['contenttypeid']); } else { $criteria = $search_core->create_criteria(vB_Search_Core::SEARCH_COMMON); } set_criteria_from_vbform($current_user, $criteria); $search_type->add_advanced_search_filters($criteria, $vbulletin); //caputure the search form values for backreferencing $searchterms = array(); foreach ($globals as $varname => $value) { if (!$vbulletin->GPC_exists[$varname] or in_array($value, array(TYPE_ARRAY, TYPE_ARRAY_NOHTML)) and !is_array($vbulletin->GPC[$varname])) { continue; } $searchterms[$varname] = $vbulletin->GPC[$varname]; } $criteria->set_search_terms($searchterms); $errors = array_merge($errors, $criteria->get_errors()); if ($errors) { return; } $results = null; if (!($vbulletin->debug and $vbulletin->GPC_exists['nocache'] and $vbulletin->GPC['nocache'])) { $results = vB_Search_Results::create_from_cache($current_user, $criteria); } if (!$results) { $results = vB_Search_Results::create_from_criteria($current_user, $criteria); } $searchid = $results->get_searchid(); }
if (! $vbulletin->GPC_exists['contenttypeid']) { $vbulletin->GPC['contenttypeid'] = vB_Types::instance()->getContentTypeID('vBForum_Post'); } if ($vbulletin->GPC['contenttypeid'] and !is_array($vbulletin->GPC['contenttypeid'])) { $criteria = $search_core->create_criteria(vB_Search_Core::SEARCH_ADVANCED); $criteria->set_advanced_typeid($vbulletin->GPC['contenttypeid']); } else { $criteria = $search_core->create_criteria(vB_Search_Core::SEARCH_COMMON); } set_criteria_from_vbform($current_user, $criteria); $search_type->add_advanced_search_filters($criteria, $vbulletin); $criteria->set_sort($criteria->switch_field('dateline'), 'desc'); $errors = $criteria->get_errors(); if ($errors) { standard_error(fetch_error($errors[0])); } $results = null; if (!($vbulletin->debug AND $vbulletin->GPC_exists['nocache'] AND $vbulletin->GPC['nocache'])) { $results = vB_Search_Results::create_from_cache($current_user, $criteria); }
function do_search_finduser() { global $vbulletin, $search_core, $search_type, $current_user; $vbulletin->input->clean_array_gpc('r', array('type' => TYPE_ARRAY_NOHTML, 'userid' => TYPE_UINT, 'starteronly' => TYPE_BOOL, 'forumchoice' => TYPE_ARRAY, 'childforums' => TYPE_BOOL, 'postuserid' => TYPE_UINT, 'searchthreadid' => TYPE_UINT, 'pagenumber' => TYPE_INT, 'perpage' => TYPE_INT)); $vbulletin->GPC['prefixchoice'] = array(); $vbulletin->GPC_exists['prefixchoice'] = true; if (!$current_user->hasPermission('forumpermissions', 'cansearch')) { $threads[]['error'] = ERR_NO_PERMISSION; return array('threads' => $threads, 'total_threads' => 1); } if (!$vbulletin->options['enablesearches']) { $threads[]['error'] = strip_tags(fetch_error('searchdisabled')); return array('threads' => $threads, 'total_threads' => 1); } // valid user id? if (!$vbulletin->GPC['userid']) { if (!$vbulletin->userinfo['userid']) { json_error(ERR_INVALID_USER); } $vbulletin->GPC['userid'] = $vbulletin->userinfo['userid']; $vbulletin->GPC_exists['userid'] = true; } // valid user id? if (!$vbulletin->GPC['userid'] and !$vbulletin->GPC['postuserid']) { json_error(ERR_INVALID_USER); } //default to posts if (!$vbulletin->GPC_exists['contenttypeid']) { $vbulletin->GPC['contenttypeid'] = vB_Types::instance()->getContentTypeID('vBForum_Post'); $vbulletin->GPC_exists['contenttypeid'] = true; } if ($vbulletin->GPC['contenttypeid'] and !is_array($vbulletin->GPC['contenttypeid'])) { $criteria = $search_core->create_criteria(vB_Search_Core::SEARCH_ADVANCED); $criteria->set_advanced_typeid($vbulletin->GPC['contenttypeid']); } else { $criteria = $search_core->create_criteria(vB_Search_Core::SEARCH_COMMON); } set_criteria_from_vbform($current_user, $criteria); $search_type->add_advanced_search_filters($criteria, $vbulletin); $criteria->set_sort($criteria->switch_field('dateline'), 'desc'); $errors = $criteria->get_errors(); if ($errors) { json_error($errors[0]); } $results = null; if (!($vbulletin->debug and $vbulletin->GPC_exists['nocache'] and $vbulletin->GPC['nocache'])) { $results = vB_Search_Results::create_from_cache($current_user, $criteria); } if (!$results) { $results = vB_Search_Results::create_from_criteria($current_user, $criteria); } $searchid = $results->get_searchid(); if ($searchid != -1) { return do_showresults($searchid, $vbulletin->GPC['pagenumber'], $vbulletin->GPC['perpage']); } else { return array('threads' => array(), 'total_threads' => 0); } }