Overview

Namespaces

  • MatthiasMullie
    • Minify
      • Exceptions
    • PathConverter
  • None
  • ReCaptcha
    • RequestMethod
  • TOTP

Classes

  • apc_cache
  • apcu_cache
  • ApprovePost_Notify_Background
  • ApproveReply_Notify_Background
  • Attachments
  • Birthday_Notify_Background
  • browser_detector
  • Buddy_Notify_Background
  • cache_api
  • CreateAttachment_Notify_Background
  • CreatePost_Notify_Background
  • curl_fetch_web_data
  • custom_search
  • EventNew_Notify_Background
  • ftp_connection
  • fulltext_search
  • gif_color_table
  • gif_file
  • gif_file_header
  • gif_image
  • gif_image_header
  • gif_lzw_compression
  • GroupAct_Notify_Background
  • GroupReq_Notify_Background
  • Likes
  • Likes_Notify_Background
  • MatthiasMullie\Minify\CSS
  • MatthiasMullie\Minify\JS
  • MatthiasMullie\Minify\Minify
  • MatthiasMullie\PathConverter\Converter
  • MemberReport_Notify_Background
  • MemberReportReply_Notify_Background
  • memcache_cache
  • memcached_cache
  • Mentions
  • MsgReport_Notify_Background
  • MsgReportReply_Notify_Background
  • paypal_display
  • paypal_payment
  • postgres_cache
  • ProxyServer
  • Punycode
  • ReCaptcha\ReCaptcha
  • ReCaptcha\RequestMethod\Curl
  • ReCaptcha\RequestMethod\CurlPost
  • ReCaptcha\RequestMethod\Post
  • ReCaptcha\RequestMethod\Socket
  • ReCaptcha\RequestMethod\SocketPost
  • ReCaptcha\RequestParameters
  • ReCaptcha\Response
  • Register_Notify_Background
  • search_api
  • SMF_BackgroundTask
  • smf_cache
  • sqlite_cache
  • standard_search
  • TOTP\Auth
  • TypeError
  • Update_TLD_Regex
  • xcache_cache
  • xmlArray
  • zend_cache

Interfaces

  • cache_api_interface
  • ReCaptcha\RequestMethod
  • search_api_interface

Exceptions

  • Error
  • MatthiasMullie\Minify\Exception
  • MatthiasMullie\Minify\Exceptions\BasicException
  • MatthiasMullie\Minify\Exceptions\FileImportException
  • MatthiasMullie\Minify\Exceptions\IOException

Functions

  • _safe_serialize
  • _safe_unserialize
  • account
  • Activate
  • activateAccount
  • add_integration_function
  • addData
  • addInlineCss
  • addInlineJavaScript
  • addJavaScriptVar
  • AddLanguage
  • AddMailQueue
  • AddMembergroup
  • addMembersToGroup
  • addSeparator
  • AddSmiley
  • addSubscription
  • addTriggers
  • AdminAccount
  • AdminApprove
  • AdminBoardRecount
  • AdminEndSession
  • AdminHome
  • adminLogin
  • adminLogin_outputPostVars
  • AdminLogs
  • AdminMain
  • adminNotify
  • AdminRegister
  • AdminSearch
  • AdminSearchInternal
  • AdminSearchMember
  • AdminSearchOM
  • alert_configuration
  • alert_count
  • alert_delete
  • alert_mark
  • alert_markread
  • alert_notifications_boards
  • alert_notifications_topics
  • alert_purge
  • alerts_popup
  • AlignURLsWithSSLSetting
  • allowedTo
  • AnnouncementSelectMembergroup
  • AnnouncementSend
  • AnnounceTopic
  • ApplyRules
  • approveAllData
  • ApproveAttach
  • ApproveAttachments
  • ApproveMessage
  • approveMessages
  • approvePosts
  • approveTopics
  • array_column
  • array_length
  • assignAttachments
  • attachDirStatus
  • attachmentChecks
  • attachments_init_dir
  • automanage_attachments_by_space
  • automanage_attachments_check_directory
  • automanage_attachments_create_directory
  • AutoSuggest_Search_Member
  • AutoSuggest_Search_MemberGroups
  • AutoSuggest_Search_SMFVersions
  • AutoSuggestHandler
  • AutoTask
  • BackupDatabase
  • backupTable
  • Ban
  • BanBrowseTriggers
  • BanEdit
  • banEdit2
  • BanEditTrigger
  • BanList
  • banLoadAdditionalIPs
  • banLoadAdditionalIPsError
  • banLoadAdditionalIPsMember
  • BanLog
  • banPermissions
  • bbc_to_html
  • BoardIndex
  • BoardNotify
  • BoardPermissionsReport
  • BoardReport
  • boardsAllowedTo
  • BoardurlMatch
  • BookOfUnknown
  • BrowseFiles
  • BrowseMailQueue
  • BuddyListToggle
  • build_query_board
  • build_regex
  • buildEventDatetimes
  • cache_get_data
  • cache_getLastPosts
  • cache_getMembergroupList
  • cache_getOffsetIndependentEvents
  • cache_getRecentEvents
  • cache_put_data
  • cache_quick_get
  • CalculateNextTrigger
  • CalendarMain
  • CalendarPost
  • call_helper
  • call_integration_hook
  • canLinkEvent
  • canPickTheme
  • cdata_parse
  • censorText
  • check_cron
  • checkActivation
  • checkChange
  • checkConfirm
  • checkExistingTriggerIP
  • CheckFilesWritable
  • checkGD
  • checkImageContents
  • checkImagick
  • checkLogin
  • checkMagickWand
  • checkSession
  • checkSubmitOnce
  • clean_cache
  • cleanLangString
  • cleanRequest
  • cleanRequest_cron
  • cleanTokens
  • cleanXml
  • ClearMailQueue
  • cli_scheduled_fetchSMfiles
  • clock
  • cmdStep0
  • comma_format
  • compareVersions
  • ComposeMailing
  • consolidateSpiderStats
  • construct_query_string
  • constructPageIndex
  • ConvertEntities
  • ConvertMsgBody
  • convertSettingstoOptions
  • convertSettingsToTheme
  • ConvertUtf8
  • CoppaForm
  • CopyTemplate
  • copytree
  • countReports
  • create_button
  • create_chmod_control
  • create_control_richedit
  • create_control_verification
  • createAttachment
  • createBoard
  • createCategory
  • createList
  • createMenu
  • CreateMessageIndex
  • createPost
  • createSalvageArea
  • createThumbnail
  • createToken
  • createWaveFile
  • Credits
  • custFieldsMaxOrder
  • custMinify
  • DatabaseChanges
  • DatabasePopulation
  • DatabaseSettings
  • db_extend
  • db_extra_init
  • db_fix_prefix
  • db_packages_init
  • db_search_init
  • db_version_check
  • debugPrint
  • deleteAccount
  • deleteAccount2
  • deleteAllMinified
  • deleteBoards
  • deleteCategories
  • DeleteDraft
  • deleteErrors
  • DeleteInstall
  • DeleteMembergroup
  • deleteMembergroups
  • deleteMembers
  • DeleteMessage
  • deleteMessages
  • deleteModComment
  • deleteNotifyPrefs
  • DeleteUpgrade
  • deltree
  • Destroy
  • destroyMenu
  • detectBrowser
  • detectFulltextIndex
  • determineActions
  • Display
  • display_db_error
  • display_loadavg_error
  • display_maintenance_message
  • DisplayAdminFile
  • displayDebug
  • DisplayStats
  • DoLogin
  • Download
  • downloadAvatar
  • DownloadLanguage
  • dumpTags
  • EditAgreement
  • EditBoard
  • EditBoard2
  • EditBoardSettings
  • editBuddies
  • editBuddyIgnoreLists
  • EditCategory
  • EditCategory2
  • EditComment
  • EditCustomProfiles
  • EditHoliday
  • editIgnoreList
  • EditMembergroup
  • EditMessageIcons
  • editModComment
  • EditNews
  • EditPermissionProfiles
  • EditPoll
  • EditPoll2
  • EditSearchMethod
  • EditSearchSettings
  • EditSmileyOrder
  • EditSmileys
  • EditSmileySets
  • EditSmileySettings
  • EditSpider
  • EditTask
  • EditTheme
  • EditWeights
  • emailAdmins
  • EnableTheme
  • entity_fix__callback
  • escapestring__recursive
  • ExamineFile
  • expandIPv6
  • fatal_error
  • fatal_lang_error
  • fetch_alerts
  • fetch_task
  • fetch_web_data
  • fetchPerms__recursive
  • fetchTagAttributes
  • find_gpg
  • find_signed_off
  • find_signed_off_parents
  • findForumErrors
  • findMembers
  • findSearchAPI
  • finishTables
  • fix_possible_url
  • fix_serialized_data
  • fixchar__callback
  • fixchardb__callback
  • fixChildren
  • fixModSecurity
  • fixRelativePath
  • fixTag
  • fixTags
  • forum_time
  • forumProfile
  • ForumSettings
  • frameOptionsHeader
  • GeneralPermissionSettings
  • generateSubscriptionError
  • generateValidationCode
  • get_all_themes
  • get_current_settings
  • get_date_or_time_format
  • get_directory_tree_elements
  • get_file_listing
  • get_files_recursive
  • get_gravatar_url
  • get_hook_info_from_raw
  • get_installed_themes
  • get_integration_hooks
  • get_integration_hooks_count
  • get_integration_hooks_data
  • get_proxied_url
  • get_single_theme
  • get_theme_info
  • getAttachmentFilename
  • getAttachMsgInfo
  • getAvatars
  • getBirthdayRange
  • getBoardIndex
  • getBoardList
  • getBoardModeratorGroups
  • getBoardModerators
  • getBoardParents
  • getBoardTree
  • getCalendarGrid
  • getCalendarList
  • getCalendarWeek
  • getCommentModDetails
  • getCustFieldsMList
  • getDailyStats
  • getEventPoster
  • getEventProperties
  • getEventRange
  • getFileVersions
  • getHolidayRange
  • GetJumpTo
  • getLanguages
  • getLastPost
  • getLastPosts
  • GetMemberActivationCounts
  • getMemberData
  • getMemberGroups
  • getMembersOnlineStats
  • getMessageIcons
  • getMsgMemberID
  • getNewEventDatetimes
  • getNotifyPrefs
  • getPackageInfo
  • getRawAttachInfo
  • getReportComments
  • getReportDetails
  • getReports
  • getServerVersions
  • getTodayInfo
  • getTopic
  • getTreeOrder
  • getUserTimezone
  • getXmlMembers
  • getXmlNews
  • getXmlProfile
  • getXmlRecent
  • gif_outputAsPng
  • GroupList
  • groupMembership
  • groupMembership2
  • GroupPermissionsReport
  • GroupRequests
  • Groups
  • groupsAllowedTo
  • HandleComment
  • HandleReport
  • hash_benchmark
  • hash_length
  • hash_password
  • hash_salt
  • hash_verify_password
  • HelpIndex
  • HelpRules
  • highlight
  • highlight_php_code
  • host_from_ip
  • html_to_bbc
  • htmlspecialchars__recursive
  • htmltrim__recursive
  • https_redirect_active
  • httpsOn
  • iCalDownload
  • ignoreboards
  • imagecopyresamplebicubic
  • imagecreatefrombmp
  • imageMemoryCheck
  • ImportSmileys
  • inet_dtop
  • inet_ptod
  • initialize_inputs
  • InMaintenance
  • insertBanGroup
  • insertEvent
  • InstallCopy
  • InstallDir
  • installer_updateSettingsFile
  • installExit
  • InstallFile
  • InstallSmileySet
  • ip2range
  • iri_to_url
  • is_not_banned
  • is_not_guest
  • isAccessiblePM
  • isAllowedTo
  • isBannedEmail
  • isBrowser
  • isChildOf
  • isReservedName
  • issueWarning
  • isValidIP
  • isValidIPv6
  • JavaScriptEscape
  • JavaScriptModify
  • jeffsdatediff
  • JSMembers
  • KickGuest
  • legalise_bbc
  • list_getAttachDirs
  • list_getAttachments
  • list_getBanItems
  • list_getBanLogEntries
  • list_getBans
  • list_getBanTriggers
  • list_getBaseDirs
  • list_getBoardNotifications
  • list_getFiles
  • list_getGroupRequestCount
  • list_getGroupRequests
  • list_getGroupRequestsCount
  • list_getHolidays
  • list_getIPMessageCount
  • list_getIPMessages
  • list_getLanguages
  • list_getLanguagesList
  • list_getLoginCount
  • list_getLogins
  • list_getMailQueue
  • list_getMailQueueSize
  • list_getMembergroups
  • list_getMembers
  • list_getMessageIcons
  • list_getModLogEntries
  • list_getModLogEntryCount
  • list_getNews
  • list_getNumAttachments
  • list_getNumBanItems
  • list_getNumBanLogEntries
  • list_getNumBans
  • list_getNumBanTriggers
  • list_getNumFiles
  • list_getNumHolidays
  • list_getNumLanguages
  • list_getNumMembers
  • list_getNumSmileys
  • list_getNumSmileySets
  • list_getNumSpiderLogs
  • list_getNumSpiders
  • list_getNumSpiderStats
  • list_getNumTaskLogEntries
  • list_getNumUnapprovedAttachments
  • list_getNumUnwatched
  • list_getPackages
  • list_getProfileEditCount
  • list_getProfileEdits
  • list_getProfileFields
  • list_getProfileFieldSize
  • list_getScheduledTasks
  • list_getSmileys
  • list_getSmileySets
  • list_getSpiderLogs
  • list_getSpiders
  • list_getSpiderStats
  • list_getSubscribedUserCount
  • list_getSubscribedUsers
  • list_getTaskLogEntries
  • list_getTopicNotificationCount
  • list_getTopicNotifications
  • list_getUnapprovedAttachments
  • list_getUnwatched
  • list_getUserErrorCount
  • list_getUserErrors
  • list_getUserWarningCount
  • list_getUserWarnings
  • list_getWarningCount
  • list_getWarnings
  • list_getWarningTemplateCount
  • list_getWarningTemplates
  • list_getWatchedUserCount
  • list_getWatchedUserPosts
  • list_getWatchedUserPostsCount
  • list_getWatchedUsers
  • list_integration_hooks
  • listMembergroupMembers_Href
  • ListMessageIcons
  • listtree
  • load_database
  • load_file
  • load_lang_file
  • loadAttachmentContext
  • loadBoard
  • loadCacheAccelerator
  • loadCacheAPIs
  • loadCSSFile
  • loadCustomFields
  • loadDatabase
  • loadDatePair
  • loadDatePicker
  • loadEmailTemplate
  • loadEssentialData
  • loadEssentialThemeData
  • loadForumTests
  • loadGeneralSettingParameters
  • loadIllegalBBCHtmlGroups
  • loadIllegalGuestPermissions
  • loadIllegalPermissions
  • loadInstalledPackages
  • loadJavaScriptFile
  • loadLanguage
  • loadLocale
  • loadMemberContext
  • loadMemberCustomFields
  • loadMemberData
  • loadPaymentGateways
  • loadPermissionProfiles
  • loadPermissions
  • loadProfileFields
  • LoadRules
  • loadSearchAPIs
  • loadSession
  • loadSubscriptions
  • loadSubTemplate
  • loadTemplate
  • loadTheme
  • loadThemeOptions
  • loadTimePicker
  • loadUserSettings
  • LockTopic
  • LockVoting
  • log_ban
  • log_error
  • log_error_online
  • logAction
  • logActions
  • Login
  • Login2
  • LoginTFA
  • logLastDatabaseError
  • Logout
  • logSpider
  • logTriggersUpdates
  • MaintainCleanCache
  • MaintainDatabase
  • MaintainEmptyUnimportantLogs
  • MaintainFiles
  • MaintainFindFixErrors
  • MaintainMassMoveTopics
  • MaintainMembers
  • MaintainPurgeInactiveMembers
  • MaintainReattributePosts
  • MaintainRecountPosts
  • MaintainRemoveOldDrafts
  • MaintainRemoveOldPosts
  • MaintainRoutine
  • MaintainTopics
  • makeCustomFieldChanges
  • makeFilesWritable
  • makeNotificationChanges
  • makeThemeChanges
  • ManageAttachmentPaths
  • ManageAttachments
  • ManageAttachmentSettings
  • ManageAvatarSettings
  • ManageBoards
  • ManageBoardsMain
  • ManageCalendar
  • ManageLabels
  • ManageLanguages
  • ManageMail
  • ManageMaintenance
  • ManageNews
  • ManagePaidSubscriptions
  • ManagePostSettings
  • ManageRules
  • ManageScheduledTasks
  • ManageSearch
  • ManageSearchEngineSettings
  • ManageSmileys
  • markBoardsRead
  • markMessages
  • MarkRead
  • matchHighestPackageVersion
  • matchIPtoCIDR
  • matchPackageVersion
  • md5_hmac
  • MembergroupIndex
  • MembergroupMembers
  • MemberGroupsReport
  • Memberlist
  • membersAllowedTo
  • MembersAwaitingActivation
  • memoryReturnBytes
  • MergeDone
  • MergeExecute
  • MergeIndex
  • mergePosts
  • MergeTopics
  • MessageActionsApply
  • MessageDrafts
  • MessageFolder
  • MessageIndex
  • messageIndexBar
  • MessageKillAll
  • MessageMain
  • MessagePopup
  • MessagePost
  • MessagePost2
  • messagePostError
  • MessagePrune
  • MessageSearch
  • MessageSearch2
  • MessageSettings
  • mimespecialchars
  • mktree
  • MLAll
  • MLSearch
  • ModBlockGroupRequests
  • ModBlockNotes
  • ModBlockReportedMembers
  • ModBlockReportedPosts
  • ModBlockWatchedUsers
  • ModEndSession
  • ModerateGroups
  • ModerationHome
  • ModerationMain
  • ModerationSettings
  • ModifyAlertsSettings
  • ModifyAntispamSettings
  • ModifyBasicSettings
  • ModifyBBCSettings
  • modifyBoard
  • ModifyCacheSettings
  • ModifyCalendarSettings
  • ModifyCat
  • modifyCategory
  • ModifyCookieSettings
  • ModifyDatabaseSettings
  • ModifyDraftSettings
  • modifyEvent
  • ModifyFeatureSettings
  • ModifyGeneralModSettings
  • ModifyGeneralSecuritySettings
  • ModifyGeneralSettings
  • ModifyHolidays
  • ModifyLanguage
  • ModifyLanguages
  • ModifyLanguageSettings
  • ModifyLayoutSettings
  • ModifyLikesSettings
  • ModifyLoadBalancingSettings
  • ModifyLogSettings
  • ModifyMailSettings
  • ModifyMembergroup
  • ModifyMembergroup2
  • ModifyMembergroups
  • ModifyMembergroupsettings
  • ModifyMentionsSettings
  • ModifyModSettings
  • ModifyNewsSettings
  • ModifyPermissions
  • modifyPost
  • ModifyPostModeration
  • ModifyPostSettings
  • ModifyProfile
  • ModifyRegistrationSettings
  • ModifySettings
  • ModifySignatureSettings
  • ModifySubscription
  • ModifySubscriptionSettings
  • ModifyTopicSettings
  • ModifyUserSubscription
  • ModifyWarningSettings
  • ModifyWarningTemplate
  • MoveTopic
  • MoveTopic2
  • moveTopicConcurrence
  • moveTopics
  • MySQLConvertOldIp
  • newsletterpreview
  • newspreview
  • newTable
  • next_time
  • nextSubstep
  • notification
  • ob_sessrewrite
  • obExit
  • obExit_cron
  • OptimizeTables
  • package_chmod
  • package_create_backup
  • package_crypt
  • package_flush_cache
  • package_get_contents
  • package_put_contents
  • PackageBrowse
  • PackageDownload
  • PackageFTPTest
  • PackageGBrowse
  • PackageGet
  • PackageInstall
  • PackageInstallTest
  • PackageList
  • PackageOptions
  • PackagePermissions
  • PackagePermissionsAction
  • PackageRemove
  • packageRequireFTP
  • Packages
  • PackageServerAdd
  • PackageServerRemove
  • PackageServers
  • PackageUpload
  • parse_bbc
  • parse_path
  • parse_sql
  • parseAttachBBC
  • parseBoardMod
  • parseModification
  • parsePackageInfo
  • parsesmileys
  • password_get_info
  • password_hash
  • password_needs_rehash
  • password_verify
  • pauseAttachmentMaintenance
  • pauseMailQueueClear
  • pauseRepairProcess
  • pauseSignatureApplySettings
  • perform_task
  • PermissionByBoard
  • PermissionIndex
  • permute
  • php_version_check
  • phpBB3_password_check
  • PickTheme
  • PlushSearch1
  • PlushSearch2
  • populateDuplicateMembers
  • Post
  • Post2
  • PostModerationMain
  • prepareAttachsByMsg
  • prepareCLIhandler
  • prepareDBSettingContext
  • prepareDisplayContext
  • prepareLikesContext
  • prepareMailingForPreview
  • prepareMessageContext
  • prepareSearchContext
  • prepareServerSettingsContext
  • preparsecode
  • print_error
  • printMemberListRows
  • PrintTopic
  • processAttachments
  • profile_popup
  • profileLoadAvatarData
  • profileLoadGroups
  • profileLoadLanguages
  • profileLoadSignatureData
  • profileReloadUser
  • profileSaveAvatarData
  • profileSaveGroups
  • profileSendActivation
  • profileValidateEmail
  • profileValidateSignature
  • protected_alter
  • quickFileWritable
  • QuickInTopicModeration
  • QuickModeration
  • QuoteFast
  • random_bytes
  • random_int
  • RandomCompat_intval
  • RandomCompat_strlen
  • RandomCompat_substr
  • range2ip
  • read_tgz_data
  • read_tgz_file
  • read_zip_data
  • read_zip_file
  • ReadDraft
  • reapplySubscriptions
  • reattributePosts
  • rebuildModCache
  • recacheSpiderNames
  • RecentPosts
  • recountOpenReports
  • recursiveBoards
  • redirectexit
  • redirectLocation
  • ReduceMailQueue
  • reencodeImage
  • RegCenter
  • Register
  • Register2
  • RegisterCheckUsername
  • registerMember
  • registerSMStats
  • reloadSettings
  • RemindMe
  • RemindPick
  • remove_dir
  • remove_integration_function
  • remove_theme
  • RemoveAllAttachments
  • RemoveAttachment
  • RemoveAttachmentByAge
  • RemoveAttachmentBySize
  • removeBanGroups
  • removeBanLogs
  • removeBanTriggers
  • removeDeleteConcurrence
  • removeEvent
  • removeHolidays
  • removeIllegalBBCHtmlPermission
  • removeMembersFromGroups
  • removeMessage
  • removeMessages
  • RemoveOldTopics2
  • RemovePoll
  • removeSubscription
  • RemoveTheme
  • RemoveTopic2
  • removeTopics
  • reorderBoards
  • RepairAttachments
  • RepairBoards
  • replaceEntities__callback
  • ReportDetails
  • ReportedContent
  • ReportedMembers
  • ReportMessage
  • reportPost
  • ReportsMain
  • ReportToModerator
  • ReportToModerator2
  • reportUser
  • RequestMembers
  • resetPassword
  • resizeImage
  • resizeImageFile
  • RestoreTopic
  • RetrievePreview
  • safe_file_write
  • safe_serialize
  • safe_unserialize
  • sanitize_iri
  • sanitizeMSCutPaste
  • saveDBSettings
  • SaveDraft
  • saveModComment
  • SavePMDraft
  • saveProfileChanges
  • saveProfileFields
  • saveSettings
  • saveTriggers
  • scheduled_birthdayemails
  • scheduled_daily_digest
  • scheduled_daily_maintenance
  • scheduled_fetchSMfiles
  • scheduled_paid_subscriptions
  • scheduled_remove_old_drafts
  • scheduled_remove_temp_attachments
  • scheduled_remove_topic_redirect
  • scheduled_weekly_digest
  • scheduled_weekly_maintenance
  • ScheduledTasks
  • SearchEngines
  • SearchMembers
  • searchSort
  • SecretAnswer2
  • SecretAnswerInput
  • secureDirectory
  • SelectMailingMembers
  • send_http_status
  • SendActivation
  • sendmail
  • SendMailing
  • sendNotifications
  • sendpm
  • sentence_list
  • serialize_to_json
  • sessionClose
  • sessionDestroy
  • sessionGC
  • sessionOpen
  • sessionRead
  • sessionWrite
  • set_alert_icon
  • set_avatar_data
  • set_fatal_error_headers
  • set_tld_regex
  • SetCensor
  • setEventStartEnd
  • SetJavaScript
  • setKeys
  • setLoginCookie
  • setMemoryLimit
  • setNotifyPrefs
  • setPassword
  • setPassword2
  • SetQuickGroups
  • SetReserved
  • setSqlMode
  • setTFACookie
  • SetThemeOptions
  • SetThemeSettings
  • setup_fatal_error_context
  • setupMenuContext
  • setupProfileContext
  • setupThemeContext
  • sha1_core
  • sha1_ft
  • sha1_kt
  • sha1_raw
  • sha1_rol
  • sha1_smf
  • shorten_subject
  • ShowAdminHelp
  • showAlerts
  • showAttachment
  • showAttachments
  • ShowClosedReports
  • showCodeImage
  • ShowCustomProfiles
  • ShowDrafts
  • ShowHelp
  • showLetterImage
  • ShowNotice
  • showPermissions
  • ShowPHPinfoSettings
  • showPMDrafts
  • showPosts
  • showProfileDrafts
  • ShowReports
  • showUnwatched
  • ShowXmlFeed
  • sig_preview
  • smf_chmod
  • smf_crc32
  • smf_db_add_column
  • smf_db_add_index
  • smf_db_affected_rows
  • smf_db_allow_persistent
  • smf_db_backup_table
  • smf_db_calculate_type
  • smf_db_change_column
  • smf_db_create_query_column
  • smf_db_create_table
  • smf_db_create_word_search
  • smf_db_cte_support
  • smf_db_custom_order
  • smf_db_drop_table
  • smf_db_error
  • smf_db_error_backtrace
  • smf_db_error_insert
  • smf_db_escape_string
  • smf_db_escape_wildcard_string
  • smf_db_fetch_all
  • smf_db_get_server_info
  • smf_db_get_vendor
  • smf_db_get_version
  • smf_db_initiate
  • smf_db_insert
  • smf_db_insert_id
  • smf_db_list_columns
  • smf_db_list_indexes
  • smf_db_list_tables
  • smf_db_native_replace
  • smf_db_optimize_table
  • smf_db_query
  • smf_db_quote
  • smf_db_remove_column
  • smf_db_remove_index
  • smf_db_replacement__callback
  • smf_db_search_language
  • smf_db_search_query
  • smf_db_search_support
  • smf_db_select
  • smf_db_select_db
  • smf_db_table_sql
  • smf_db_table_structure
  • smf_db_transaction
  • smf_db_version
  • smf_error_handler
  • smf_error_handler_cron
  • smf_is_resource
  • smf_json_decode
  • smf_list_timezones
  • smf_main
  • smf_mysql_fetch_assoc
  • smf_mysql_fetch_row
  • smf_mysql_free_result
  • smf_mysql_insert_id
  • smf_mysql_num_rows
  • smf_mysql_real_escape_string
  • smf_seed_generator
  • smf_serverResponse
  • smf_setcookie
  • smf_strtolower
  • smf_var_export
  • SMStats
  • sortBoards
  • sortCategories
  • spamProtection
  • spell_check
  • spell_init
  • spell_suggest
  • SpellCheck
  • SpiderCheck
  • SpiderLogs
  • SpiderStats
  • SplitExecute
  • SplitIndex
  • SplitSelectionExecute
  • SplitSelectTopics
  • splitTopic
  • SplitTopics
  • ssi_boardNews
  • ssi_boardStats
  • ssi_checkPassword
  • ssi_copyright
  • ssi_fetchGroupMembers
  • ssi_fetchMember
  • ssi_fetchPosts
  • ssi_full_version
  • ssi_latestMember
  • ssi_login
  • ssi_logOnline
  • ssi_logout
  • ssi_menubar
  • ssi_news
  • ssi_pollVote
  • ssi_queryMembers
  • ssi_queryPosts
  • ssi_quickSearch
  • ssi_randomMember
  • ssi_recentAttachments
  • ssi_recentEvents
  • ssi_recentPoll
  • ssi_recentPosts
  • ssi_recentTopics
  • ssi_showPoll
  • ssi_shutdown
  • ssi_software_year
  • ssi_todaysBirthdays
  • ssi_todaysCalendar
  • ssi_todaysEvents
  • ssi_todaysHolidays
  • ssi_topBoards
  • ssi_topPoll
  • ssi_topPoster
  • ssi_topTopics
  • ssi_topTopicsReplies
  • ssi_topTopicsViews
  • ssi_version
  • ssi_welcome
  • ssi_whosOnline
  • ssl_cert_found
  • StaffReport
  • statPanel
  • Sticky
  • strip_php_comments
  • stripslashes__recursive
  • subscriptions
  • summary
  • TaskLog
  • TaskSettings
  • template_action_permissions
  • template_add_edit_group_boards_list
  • template_add_language
  • template_add_rule
  • template_additional_rows
  • template_addsmiley
  • template_admin
  • template_admin_account
  • template_admin_browse
  • template_admin_login
  • template_admin_quick_search
  • template_admin_register
  • template_admin_search_results
  • template_after
  • template_alert_configuration
  • template_alert_notifications_boards
  • template_alert_notifications_topics
  • template_alerts_all_read
  • template_alerts_popup
  • template_announce
  • template_announcement_send
  • template_ask
  • template_ask_delete
  • template_attachment_errors
  • template_attachment_paths
  • template_attachment_repair
  • template_avatar_settings_above
  • template_avatar_settings_below
  • template_backup_database
  • template_backup_xml
  • template_ban_edit
  • template_ban_edit_trigger
  • template_bcd
  • template_bi_board_children
  • template_bi_board_icon
  • template_bi_board_info
  • template_bi_board_lastpost
  • template_bi_board_stats
  • template_bi_redirect_icon
  • template_bi_redirect_stats
  • template_boardindex_outer_above
  • template_boardindex_outer_below
  • template_body_above
  • template_body_below
  • template_browse
  • template_button_strip
  • template_by_board
  • template_calendar_top
  • template_callback_question_answer_list
  • template_check_username
  • template_chmod
  • template_chmod_files
  • template_choose_payment
  • template_clean_cache_button_above
  • template_clean_cache_button_below
  • template_confirm_board_delete
  • template_confirm_category_delete
  • template_control_chmod
  • template_control_richedit
  • template_control_richedit_buttons
  • template_control_verification
  • template_convert_entities
  • template_convert_msgbody
  • template_convert_utf8
  • template_convert_xml
  • template_coppa
  • template_coppa_form
  • template_copy_template
  • template_create_index
  • template_create_index_done
  • template_create_index_progress
  • template_create_list_menu
  • template_credits
  • template_css
  • template_database_changes
  • template_database_settings
  • template_database_xml
  • template_delete_install
  • template_delete_subscription
  • template_deleteAccount
  • template_download_language
  • template_downloaded
  • template_edit_agreement
  • template_edit_browse
  • template_edit_censored
  • template_edit_comment
  • template_edit_file
  • template_edit_group
  • template_edit_holiday
  • template_edit_list
  • template_edit_options
  • template_edit_profile_field
  • template_edit_profiles
  • template_edit_reserved_words
  • template_edit_scheduled_tasks
  • template_edit_style
  • template_edit_template
  • template_editBuddies
  • template_editicon
  • template_editicons
  • template_editIgnoreList
  • template_editsets
  • template_email_members
  • template_email_members_compose
  • template_email_members_send
  • template_error_log
  • template_error_message
  • template_event_post
  • template_examine
  • template_extract_package
  • template_fatal_error
  • template_file_permissions
  • template_find_members
  • template_folder
  • template_footer
  • template_forum_settings
  • template_ftp_required
  • template_generic
  • template_generic_menu
  • template_generic_menu_dropdown_above
  • template_generic_menu_dropdown_below
  • template_generic_menu_tabs
  • template_generic_xml
  • template_generic_xml_recursive
  • template_group_members
  • template_group_request_reason
  • template_group_requests_block
  • template_groupMembership
  • template_header
  • template_hms
  • template_homepage_sample1
  • template_homepage_sample1_html
  • template_homepage_sample1_php
  • template_html_above
  • template_html_below
  • template_ic_block_calendar
  • template_ic_block_online
  • template_ic_block_recent
  • template_ic_block_stats
  • template_ignoreboards
  • template_include
  • template_info_center
  • template_init
  • template_inline_permissions
  • template_install_above
  • template_install_below
  • template_install_options
  • template_installed
  • template_issueWarning
  • template_javascript
  • template_jump_to
  • template_kick_guest
  • template_labels
  • template_like
  • template_list
  • template_list_themes
  • template_load_warning_variables
  • template_login
  • template_login_tfa
  • template_mailtest
  • template_main
  • template_maint_warning_above
  • template_maint_warning_below
  • template_maintain_database
  • template_maintain_members
  • template_maintain_routine
  • template_maintain_topics
  • template_maintenance
  • template_manual
  • template_max_size
  • template_menu
  • template_merge
  • template_merge_done
  • template_merge_extra_options
  • template_message_icons
  • template_moderation_center
  • template_moderation_settings
  • template_modify_board
  • template_modify_category
  • template_modify_group
  • template_modify_group_display
  • template_modify_language_entries
  • template_modify_subscription
  • template_modify_user_subscription
  • template_modify_weights
  • template_modifydone
  • template_modifyfast
  • template_modifyset
  • template_modifysmiley
  • template_modifytopicdone
  • template_move
  • template_new_group
  • template_news_lists
  • template_newsfader
  • template_not_done
  • template_notes
  • template_notify_board
  • template_omfg
  • template_optimize
  • template_options
  • template_package_confirm
  • template_package_list
  • template_paid_done
  • template_permission_index
  • template_permission_show_contents
  • template_php_info
  • template_pick
  • template_pm
  • template_pm_above
  • template_pm_below
  • template_pm_popup
  • template_populate_database
  • template_popup
  • template_post
  • template_post_header
  • template_postmod_permissions
  • template_print
  • template_print_above
  • template_print_below
  • template_print_options
  • template_profile_above
  • template_profile_avatar_select
  • template_profile_below
  • template_profile_birthdate
  • template_profile_group_manage
  • template_profile_pm_settings
  • template_profile_popup
  • template_profile_save
  • template_profile_signature_modify
  • template_profile_smiley_pick
  • template_profile_tfa
  • template_profile_theme_pick
  • template_profile_theme_settings
  • template_profile_timeformat_modify
  • template_prune
  • template_quickbuttons
  • template_quickreply
  • template_quotefast
  • template_recent
  • template_redirect_options
  • template_registration_agreement
  • template_registration_form
  • template_reminder_pick
  • template_repair_boards
  • template_replies
  • template_report_message
  • template_report_message_complete
  • template_report_type
  • template_reported_members
  • template_reported_members_block
  • template_reported_posts
  • template_reported_posts_block
  • template_reported_users_block
  • template_resend
  • template_reset_list
  • template_results
  • template_retry_activate
  • template_rules
  • template_search
  • template_search_members
  • template_search_results
  • template_select
  • template_select_search_method
  • template_send
  • template_sendbody
  • template_sent
  • template_serialize_json
  • template_serialize_json_xml
  • template_servers
  • template_set_options
  • template_set_password
  • template_set_settings
  • template_setorder
  • template_settings
  • template_show_backtrace
  • template_show_custom_profile
  • template_show_file
  • template_show_list
  • template_show_month_grid
  • template_show_notice
  • template_show_settings
  • template_show_spider_logs
  • template_show_spider_stats
  • template_show_upcoming_list
  • template_show_week_grid
  • template_showAlerts
  • template_showDrafts
  • template_showPermissions
  • template_showPMDrafts
  • template_showPosts
  • template_single_pm
  • template_single_post
  • template_spellcheck
  • template_spider_edit
  • template_split
  • template_ssi_above
  • template_ssi_below
  • template_statPanel
  • template_stats
  • template_subject_list
  • template_summary
  • template_terms
  • template_tfadisable
  • template_tfasetup
  • template_tfasetup_backup
  • template_thetime
  • template_topic_legend
  • template_trackActivity
  • template_trackIP
  • template_unapproved_posts
  • template_unread
  • template_upgrade_above
  • template_upgrade_below
  • template_upgrade_complete
  • template_upgrade_options
  • template_user_subscription
  • template_user_watch_post_callback
  • template_verification_sound
  • template_view_operations
  • template_view_package
  • template_view_scheduled_tasks
  • template_view_versions
  • template_viewmemberreport
  • template_viewmodreport
  • template_viewWarning
  • template_warn_template
  • template_warning
  • template_warning_divs
  • template_watched_users
  • template_welcome_message
  • template_xml_above
  • template_xml_below
  • TestMailSend
  • text2words
  • textfield_alter
  • tfadisable
  • tfasetup
  • theme
  • theme_copyright
  • theme_inline_permissions
  • theme_install
  • theme_linktree
  • ThemeAdmin
  • ThemeInstall
  • ThemeList
  • ThemesMain
  • throw_error
  • time_since
  • timeformat
  • TopicNotify
  • trackActivity
  • trackEdits
  • trackGroupReq
  • tracking
  • TrackIP
  • TrackLogins
  • trackStats
  • trackStatsUsersOnline
  • TransferAttachments
  • truncate_array
  • un_htmlspecialchars
  • un_preparsecode
  • UnapprovedAttachments
  • UnapprovedPosts
  • unescapestring__recursive
  • UnreadTopics
  • updateAdminPreferences
  • updateBanGroup
  • updateBanMembers
  • updateBoardManagers
  • updateChildPermissions
  • updateDbLastError
  • updateLastMessages
  • updateMemberData
  • updateReport
  • updateSettings
  • updateSettingsFile
  • updateStats
  • updateTriggers
  • upgrade_clean_cache
  • upgrade_query
  • upgradeExit
  • upgradeGetColumnInfo
  • UpgradeOptions
  • url_exists
  • url_image_size
  • url_parts
  • url_to_iri
  • urldecode__recursive
  • user_info_callback
  • utf8_strtolower
  • utf8_strtoupper
  • validate_iri
  • validateEventPost
  • validatePassword
  • validatePasswordFlood
  • validateSession
  • validateToken
  • validateTriggers
  • validateUsername
  • VerificationCode
  • VersionDetail
  • ViewBacktrace
  • ViewErrorLog
  • ViewFile
  • ViewMemberlist
  • ViewMembers
  • ViewModlog
  • ViewOperations
  • ViewQuery
  • ViewSpiders
  • ViewSubscribedUsers
  • ViewSubscriptions
  • viewWarning
  • ViewWarningLog
  • ViewWarnings
  • ViewWarningTemplates
  • ViewWatchedUsers
  • Vote
  • warning_preview
  • Welcome
  • WelcomeLogin
  • Who
  • WrapAction
  • writeLog
  • XmlDraft
  • XMLhttpMain
  • Overview
  • Namespace
  • Class
   1:    2:    3:    4:    5:    6:    7:    8:    9:   10:   11:   12:   13:   14:   15:   16:   17:   18:   19:   20:   21:   22:   23:   24:   25:   26:   27:   28:   29:   30:   31:   32:   33:   34:   35:   36:   37:   38:   39:   40:   41:   42:   43:   44:   45:   46:   47:   48:   49:   50:   51:   52:   53:   54:   55:   56:   57:   58:   59:   60:   61:   62:   63:   64:   65:   66:   67:   68:   69:   70:   71:   72:   73:   74:   75:   76:   77:   78:   79:   80:   81:   82:   83:   84:   85:   86:   87:   88:   89:   90:   91:   92:   93:   94:   95:   96:   97:   98:   99:  100:  101:  102:  103:  104:  105:  106:  107:  108:  109:  110:  111:  112:  113:  114:  115:  116:  117:  118:  119:  120:  121:  122:  123:  124:  125:  126:  127:  128:  129:  130:  131:  132:  133:  134:  135:  136:  137:  138:  139:  140:  141:  142:  143:  144:  145:  146:  147:  148:  149:  150:  151:  152:  153:  154:  155:  156:  157:  158:  159:  160:  161:  162:  163:  164:  165:  166:  167:  168:  169:  170:  171:  172:  173:  174:  175:  176:  177:  178:  179:  180:  181:  182:  183:  184:  185:  186:  187:  188:  189:  190:  191:  192:  193:  194:  195:  196:  197:  198:  199:  200:  201:  202:  203:  204:  205:  206:  207:  208:  209:  210:  211:  212:  213:  214:  215:  216:  217:  218:  219:  220:  221:  222:  223:  224:  225:  226:  227:  228:  229:  230:  231:  232:  233:  234:  235:  236:  237:  238:  239:  240:  241:  242:  243:  244:  245:  246:  247:  248:  249:  250:  251:  252:  253:  254:  255:  256:  257:  258:  259:  260:  261:  262:  263:  264:  265:  266:  267:  268:  269:  270:  271:  272:  273:  274:  275:  276:  277:  278:  279:  280:  281:  282:  283:  284:  285:  286:  287:  288:  289:  290:  291:  292:  293:  294:  295:  296:  297:  298:  299:  300:  301:  302:  303:  304:  305:  306:  307:  308:  309:  310:  311:  312:  313:  314:  315:  316:  317:  318:  319:  320:  321:  322:  323:  324:  325:  326:  327:  328:  329:  330:  331:  332:  333:  334:  335:  336:  337:  338:  339:  340:  341:  342:  343:  344:  345:  346:  347:  348:  349:  350:  351:  352:  353:  354:  355:  356:  357:  358:  359:  360:  361:  362:  363:  364:  365:  366:  367:  368:  369:  370:  371:  372:  373:  374:  375:  376:  377:  378:  379:  380:  381:  382:  383:  384:  385:  386:  387:  388:  389:  390:  391:  392:  393:  394:  395:  396:  397:  398:  399:  400:  401:  402:  403:  404:  405:  406:  407:  408:  409:  410:  411:  412:  413:  414:  415:  416:  417:  418:  419:  420:  421:  422:  423:  424:  425:  426:  427:  428:  429:  430:  431:  432:  433:  434:  435:  436:  437:  438:  439:  440:  441:  442:  443:  444:  445:  446:  447:  448:  449:  450:  451:  452:  453:  454:  455:  456:  457:  458:  459:  460:  461:  462:  463:  464:  465:  466:  467:  468:  469:  470:  471:  472:  473:  474:  475:  476:  477:  478:  479:  480:  481:  482:  483:  484:  485:  486:  487:  488:  489:  490:  491:  492:  493:  494:  495:  496:  497:  498:  499:  500:  501:  502:  503:  504:  505:  506:  507:  508:  509:  510:  511:  512:  513:  514:  515:  516:  517:  518:  519:  520:  521:  522:  523:  524:  525:  526:  527:  528:  529:  530:  531:  532:  533:  534:  535:  536:  537:  538:  539:  540:  541:  542:  543:  544:  545:  546:  547:  548:  549:  550:  551:  552:  553:  554:  555:  556:  557:  558:  559:  560:  561:  562:  563:  564:  565:  566:  567:  568:  569:  570:  571:  572:  573:  574:  575:  576:  577:  578:  579:  580:  581:  582:  583:  584:  585:  586:  587:  588:  589:  590:  591:  592:  593:  594:  595:  596:  597:  598:  599:  600:  601:  602:  603:  604:  605:  606:  607:  608:  609:  610:  611:  612:  613:  614:  615:  616:  617:  618:  619:  620:  621:  622:  623:  624:  625:  626:  627:  628:  629:  630:  631:  632:  633:  634:  635:  636:  637:  638:  639:  640:  641:  642:  643:  644:  645:  646:  647:  648:  649:  650:  651:  652:  653:  654:  655:  656:  657:  658:  659:  660:  661:  662:  663:  664:  665:  666:  667:  668:  669:  670:  671:  672:  673:  674:  675:  676:  677:  678:  679:  680:  681:  682:  683:  684:  685:  686:  687:  688:  689:  690:  691:  692:  693:  694:  695:  696:  697:  698:  699:  700:  701:  702:  703:  704:  705:  706:  707:  708:  709:  710:  711:  712:  713:  714:  715:  716:  717:  718:  719:  720:  721:  722:  723:  724:  725:  726:  727:  728:  729:  730:  731:  732:  733:  734:  735:  736:  737:  738:  739:  740:  741:  742:  743:  744:  745:  746:  747:  748:  749:  750:  751:  752:  753:  754:  755:  756:  757:  758:  759:  760:  761:  762:  763:  764:  765:  766:  767:  768:  769:  770:  771:  772:  773:  774:  775:  776:  777:  778:  779:  780:  781:  782:  783:  784:  785:  786:  787:  788:  789:  790:  791:  792:  793:  794:  795:  796:  797:  798:  799:  800:  801:  802:  803:  804:  805:  806:  807:  808:  809:  810:  811:  812:  813:  814:  815:  816:  817:  818:  819:  820:  821:  822:  823:  824:  825:  826:  827:  828:  829:  830:  831:  832:  833:  834:  835:  836:  837:  838:  839:  840:  841:  842:  843:  844:  845:  846:  847:  848:  849:  850:  851:  852:  853:  854:  855:  856:  857:  858:  859:  860:  861:  862:  863:  864:  865:  866:  867:  868:  869:  870:  871:  872:  873:  874:  875:  876:  877:  878:  879:  880:  881:  882:  883:  884:  885:  886:  887:  888:  889:  890:  891:  892:  893:  894:  895:  896:  897:  898:  899:  900:  901:  902:  903:  904:  905:  906:  907:  908:  909:  910:  911:  912:  913:  914:  915:  916:  917:  918:  919:  920:  921:  922:  923:  924:  925:  926:  927:  928:  929:  930:  931:  932:  933:  934:  935:  936:  937:  938:  939:  940:  941:  942:  943:  944:  945:  946:  947:  948:  949:  950:  951:  952:  953:  954:  955:  956:  957:  958:  959:  960:  961:  962:  963:  964:  965:  966:  967:  968:  969:  970:  971:  972:  973:  974:  975:  976:  977:  978:  979:  980:  981:  982:  983:  984:  985:  986:  987:  988:  989:  990:  991:  992:  993:  994:  995:  996:  997:  998:  999: 1000: 1001: 1002: 1003: 1004: 1005: 1006: 1007: 1008: 1009: 1010: 1011: 1012: 1013: 1014: 1015: 1016: 1017: 1018: 1019: 1020: 1021: 1022: 1023: 1024: 1025: 1026: 1027: 1028: 1029: 1030: 1031: 1032: 1033: 1034: 1035: 1036: 1037: 1038: 1039: 1040: 1041: 1042: 1043: 1044: 1045: 1046: 1047: 1048: 1049: 1050: 1051: 1052: 1053: 1054: 1055: 1056: 1057: 1058: 1059: 1060: 1061: 1062: 1063: 1064: 1065: 1066: 1067: 1068: 1069: 1070: 1071: 1072: 1073: 1074: 1075: 1076: 1077: 1078: 1079: 1080: 1081: 1082: 1083: 1084: 1085: 1086: 1087: 1088: 1089: 1090: 1091: 1092: 1093: 1094: 1095: 1096: 1097: 1098: 1099: 1100: 1101: 1102: 1103: 1104: 1105: 1106: 1107: 1108: 1109: 1110: 1111: 1112: 1113: 1114: 1115: 1116: 1117: 1118: 1119: 1120: 1121: 1122: 1123: 1124: 1125: 1126: 1127: 1128: 1129: 1130: 1131: 1132: 1133: 1134: 1135: 1136: 1137: 1138: 1139: 1140: 1141: 1142: 1143: 1144: 1145: 1146: 1147: 1148: 1149: 1150: 1151: 1152: 1153: 1154: 1155: 1156: 1157: 1158: 1159: 1160: 1161: 1162: 1163: 1164: 1165: 1166: 1167: 1168: 1169: 1170: 1171: 1172: 1173: 1174: 1175: 1176: 1177: 1178: 1179: 1180: 1181: 1182: 1183: 1184: 1185: 1186: 1187: 1188: 1189: 1190: 1191: 1192: 1193: 1194: 1195: 1196: 1197: 1198: 1199: 1200: 1201: 1202: 1203: 1204: 1205: 1206: 1207: 1208: 1209: 1210: 1211: 1212: 1213: 1214: 1215: 1216: 1217: 1218: 1219: 1220: 1221: 1222: 1223: 1224: 1225: 1226: 1227: 1228: 1229: 1230: 1231: 1232: 1233: 1234: 1235: 1236: 1237: 1238: 1239: 1240: 1241: 1242: 1243: 1244: 1245: 1246: 1247: 1248: 1249: 1250: 1251: 1252: 1253: 1254: 1255: 1256: 1257: 1258: 1259: 1260: 1261: 1262: 1263: 1264: 1265: 1266: 1267: 1268: 1269: 1270: 1271: 1272: 1273: 1274: 1275: 1276: 1277: 1278: 1279: 1280: 1281: 1282: 1283: 1284: 1285: 1286: 1287: 1288: 1289: 1290: 1291: 1292: 1293: 1294: 1295: 1296: 1297: 1298: 1299: 1300: 1301: 1302: 1303: 1304: 1305: 1306: 1307: 1308: 1309: 1310: 1311: 1312: 1313: 1314: 1315: 1316: 1317: 1318: 1319: 1320: 1321: 1322: 1323: 1324: 1325: 1326: 1327: 1328: 1329: 1330: 1331: 1332: 1333: 1334: 1335: 1336: 1337: 1338: 1339: 1340: 1341: 1342: 1343: 1344: 1345: 1346: 1347: 1348: 1349: 1350: 1351: 1352: 1353: 1354: 1355: 1356: 1357: 1358: 1359: 1360: 1361: 1362: 1363: 1364: 1365: 1366: 1367: 1368: 1369: 1370: 1371: 1372: 1373: 1374: 1375: 1376: 1377: 1378: 1379: 1380: 1381: 1382: 1383: 1384: 1385: 1386: 1387: 1388: 1389: 1390: 1391: 1392: 1393: 1394: 1395: 1396: 1397: 1398: 1399: 1400: 1401: 1402: 1403: 1404: 1405: 1406: 1407: 1408: 1409: 1410: 1411: 1412: 1413: 1414: 1415: 1416: 1417: 1418: 1419: 1420: 1421: 1422: 1423: 1424: 1425: 1426: 1427: 1428: 1429: 1430: 1431: 1432: 1433: 1434: 1435: 1436: 1437: 1438: 1439: 1440: 1441: 1442: 1443: 1444: 1445: 1446: 1447: 1448: 1449: 1450: 1451: 1452: 1453: 1454: 1455: 1456: 1457: 1458: 1459: 1460: 1461: 1462: 1463: 1464: 1465: 1466: 1467: 1468: 1469: 1470: 1471: 1472: 1473: 1474: 1475: 1476: 1477: 1478: 1479: 1480: 1481: 1482: 1483: 1484: 1485: 1486: 1487: 1488: 1489: 1490: 1491: 1492: 1493: 1494: 1495: 1496: 1497: 1498: 1499: 1500: 1501: 1502: 1503: 1504: 1505: 1506: 1507: 1508: 1509: 1510: 1511: 1512: 1513: 1514: 1515: 1516: 1517: 1518: 1519: 1520: 1521: 1522: 1523: 1524: 1525: 1526: 1527: 1528: 1529: 1530: 1531: 1532: 1533: 1534: 1535: 1536: 1537: 1538: 1539: 1540: 1541: 1542: 1543: 1544: 1545: 1546: 1547: 1548: 1549: 1550: 1551: 1552: 1553: 1554: 1555: 1556: 1557: 1558: 1559: 1560: 1561: 1562: 1563: 1564: 1565: 1566: 1567: 1568: 1569: 1570: 1571: 1572: 1573: 1574: 1575: 1576: 1577: 1578: 1579: 1580: 1581: 1582: 1583: 1584: 1585: 1586: 1587: 1588: 1589: 1590: 1591: 1592: 1593: 1594: 1595: 1596: 1597: 1598: 1599: 1600: 1601: 1602: 1603: 1604: 1605: 1606: 1607: 1608: 1609: 1610: 1611: 1612: 1613: 1614: 1615: 1616: 1617: 1618: 1619: 1620: 1621: 1622: 1623: 1624: 1625: 1626: 1627: 1628: 1629: 1630: 1631: 1632: 1633: 1634: 1635: 1636: 1637: 1638: 1639: 1640: 1641: 1642: 1643: 1644: 1645: 1646: 1647: 1648: 1649: 1650: 1651: 1652: 1653: 1654: 1655: 1656: 1657: 1658: 1659: 1660: 1661: 1662: 1663: 1664: 1665: 1666: 1667: 1668: 1669: 1670: 1671: 1672: 1673: 1674: 1675: 1676: 1677: 1678: 1679: 1680: 1681: 1682: 1683: 1684: 1685: 1686: 1687: 1688: 1689: 1690: 1691: 1692: 1693: 1694: 1695: 1696: 1697: 1698: 1699: 1700: 1701: 1702: 1703: 1704: 1705: 1706: 1707: 1708: 1709: 1710: 1711: 1712: 1713: 1714: 1715: 1716: 1717: 1718: 1719: 1720: 1721: 1722: 1723: 1724: 1725: 1726: 1727: 1728: 1729: 1730: 1731: 1732: 1733: 1734: 1735: 1736: 1737: 1738: 1739: 1740: 1741: 1742: 1743: 1744: 1745: 1746: 1747: 1748: 1749: 1750: 1751: 1752: 1753: 1754: 1755: 1756: 1757: 1758: 1759: 1760: 1761: 1762: 1763: 1764: 1765: 1766: 1767: 1768: 1769: 1770: 1771: 1772: 1773: 1774: 1775: 1776: 1777: 1778: 1779: 1780: 1781: 1782: 1783: 1784: 1785: 1786: 1787: 1788: 1789: 1790: 1791: 1792: 1793: 1794: 1795: 1796: 1797: 1798: 1799: 1800: 1801: 1802: 1803: 1804: 1805: 1806: 1807: 1808: 1809: 1810: 1811: 1812: 1813: 1814: 1815: 1816: 1817: 1818: 1819: 1820: 1821: 1822: 1823: 1824: 1825: 1826: 1827: 1828: 1829: 1830: 1831: 1832: 1833: 1834: 1835: 1836: 1837: 1838: 1839: 1840: 1841: 1842: 1843: 1844: 1845: 1846: 1847: 1848: 1849: 1850: 1851: 1852: 1853: 1854: 1855: 1856: 1857: 1858: 1859: 1860: 1861: 1862: 1863: 1864: 1865: 1866: 1867: 1868: 1869: 1870: 1871: 1872: 1873: 1874: 1875: 1876: 1877: 1878: 1879: 1880: 1881: 1882: 1883: 1884: 1885: 1886: 1887: 1888: 1889: 1890: 1891: 1892: 1893: 1894: 1895: 1896: 1897: 1898: 1899: 1900: 1901: 1902: 1903: 1904: 1905: 1906: 1907: 1908: 1909: 1910: 1911: 1912: 1913: 1914: 1915: 1916: 1917: 1918: 1919: 1920: 1921: 1922: 1923: 1924: 1925: 1926: 1927: 1928: 1929: 1930: 1931: 1932: 1933: 1934: 1935: 1936: 1937: 1938: 1939: 1940: 1941: 1942: 1943: 1944: 1945: 1946: 1947: 1948: 1949: 1950: 1951: 1952: 1953: 1954: 1955: 1956: 1957: 1958: 1959: 1960: 1961: 1962: 1963: 1964: 1965: 1966: 1967: 1968: 1969: 1970: 1971: 1972: 1973: 1974: 1975: 1976: 1977: 1978: 1979: 1980: 1981: 1982: 1983: 1984: 1985: 1986: 1987: 1988: 1989: 1990: 1991: 1992: 1993: 1994: 1995: 1996: 1997: 1998: 1999: 2000: 2001: 2002: 2003: 2004: 2005: 2006: 2007: 2008: 2009: 2010: 2011: 2012: 2013: 2014: 2015: 2016: 2017: 2018: 2019: 2020: 2021: 2022: 2023: 2024: 2025: 2026: 2027: 2028: 2029: 2030: 2031: 2032: 2033: 2034: 2035: 2036: 2037: 2038: 2039: 2040: 2041: 2042: 2043: 2044: 2045: 2046: 2047: 2048: 2049: 2050: 2051: 2052: 2053: 2054: 2055: 2056: 2057: 2058: 2059: 2060: 2061: 2062: 2063: 2064: 2065: 2066: 2067: 2068: 2069: 2070: 2071: 2072: 2073: 2074: 2075: 2076: 2077: 2078: 2079: 2080: 2081: 2082: 2083: 2084: 2085: 2086: 2087: 2088: 2089: 2090: 2091: 2092: 2093: 2094: 2095: 2096: 2097: 2098: 2099: 2100: 2101: 2102: 2103: 2104: 2105: 2106: 2107: 2108: 2109: 2110: 2111: 2112: 2113: 2114: 2115: 2116: 2117: 2118: 2119: 2120: 2121: 2122: 2123: 2124: 2125: 2126: 2127: 2128: 2129: 2130: 2131: 2132: 2133: 2134: 2135: 2136: 2137: 2138: 2139: 2140: 2141: 2142: 2143: 2144: 2145: 2146: 2147: 2148: 2149: 2150: 2151: 2152: 2153: 2154: 2155: 2156: 2157: 2158: 2159: 2160: 2161: 2162: 2163: 2164: 2165: 2166: 2167: 2168: 2169: 2170: 2171: 2172: 2173: 2174: 2175: 2176: 2177: 2178: 2179: 2180: 2181: 2182: 2183: 2184: 2185: 2186: 2187: 2188: 2189: 2190: 2191: 2192: 2193: 2194: 2195: 2196: 2197: 2198: 2199: 2200: 2201: 2202: 2203: 2204: 2205: 2206: 2207: 2208: 2209: 2210: 2211: 2212: 2213: 2214: 2215: 2216: 2217: 2218: 2219: 2220: 2221: 2222: 2223: 2224: 2225: 2226: 2227: 2228: 2229: 2230: 2231: 2232: 2233: 2234: 2235: 2236: 2237: 2238: 2239: 2240: 2241: 2242: 2243: 2244: 2245: 
<?php

/**
 * Handle all of the searching from here.
 *
 * Simple Machines Forum (SMF)
 *
 * @package SMF
 * @author Simple Machines https://www.simplemachines.org
 * @copyright 2020 Simple Machines and individual contributors
 * @license https://www.simplemachines.org/about/smf/license.php BSD
 *
 * @version 2.1 RC2
 */

if (!defined('SMF'))
    die('No direct access...');

/**
 * Ask the user what they want to search for.
 * What it does:
 * - shows the screen to search forum posts (action=search)
 * - uses the main sub template of the Search template.
 * - uses the Search language file.
 * - requires the search_posts permission.
 * - decodes and loads search parameters given in the URL (if any).
 * - the form redirects to index.php?action=search2.
 */
function PlushSearch1()
{
    global $txt, $scripturl, $modSettings, $user_info, $context, $smcFunc, $sourcedir;

    // Is the load average too high to allow searching just now?
    if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search'])
        fatal_lang_error('loadavg_search_disabled', false);

    loadLanguage('Search');
    // Don't load this in XML mode.
    if (!isset($_REQUEST['xml']))
    {
        loadTemplate('Search');
        loadJavaScriptFile('suggest.js', array('defer' => false, 'minimize' => true), 'smf_suggest');
    }

    // Check the user's permissions.
    isAllowedTo('search_posts');

    // Link tree....
    $context['linktree'][] = array(
        'url' => $scripturl . '?action=search',
        'name' => $txt['search']
    );

    // This is hard coded maximum string length.
    $context['search_string_limit'] = 100;

    $context['require_verification'] = $user_info['is_guest'] && !empty($modSettings['search_enable_captcha']) && empty($_SESSION['ss_vv_passed']);
    if ($context['require_verification'])
    {
        require_once($sourcedir . '/Subs-Editor.php');
        $verificationOptions = array(
            'id' => 'search',
        );
        $context['require_verification'] = create_control_verification($verificationOptions);
        $context['visual_verification_id'] = $verificationOptions['id'];
    }

    // If you got back from search2 by using the linktree, you get your original search parameters back.
    if (isset($_REQUEST['params']))
    {
        // Due to IE's 2083 character limit, we have to compress long search strings
        $temp_params = base64_decode(str_replace(array('-', '_', '.'), array('+', '/', '='), $_REQUEST['params']));
        // Test for gzuncompress failing
        $temp_params2 = @gzuncompress($temp_params);
        $temp_params = explode('|"|', !empty($temp_params2) ? $temp_params2 : $temp_params);

        $context['search_params'] = array();
        foreach ($temp_params as $i => $data)
        {
            @list ($k, $v) = explode('|\'|', $data);
            $context['search_params'][$k] = $v;
        }
        if (isset($context['search_params']['brd']))
            $context['search_params']['brd'] = $context['search_params']['brd'] == '' ? array() : explode(',', $context['search_params']['brd']);
    }

    if (isset($_REQUEST['search']))
        $context['search_params']['search'] = un_htmlspecialchars($_REQUEST['search']);

    if (isset($context['search_params']['search']))
        $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']);
    if (isset($context['search_params']['userspec']))
        $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']);
    if (!empty($context['search_params']['searchtype']))
        $context['search_params']['searchtype'] = 2;
    if (!empty($context['search_params']['minage']))
        $context['search_params']['minage'] = (int) $context['search_params']['minage'];
    if (!empty($context['search_params']['maxage']))
        $context['search_params']['maxage'] = (int) $context['search_params']['maxage'];

    $context['search_params']['show_complete'] = !empty($context['search_params']['show_complete']);
    $context['search_params']['subject_only'] = !empty($context['search_params']['subject_only']);

    // Load the error text strings if there were errors in the search.
    if (!empty($context['search_errors']))
    {
        loadLanguage('Errors');
        $context['search_errors']['messages'] = array();
        foreach ($context['search_errors'] as $search_error => $dummy)
        {
            if ($search_error === 'messages')
                continue;

            if ($search_error == 'string_too_long')
                $txt['error_string_too_long'] = sprintf($txt['error_string_too_long'], $context['search_string_limit']);

            $context['search_errors']['messages'][] = $txt['error_' . $search_error];
        }
    }

    // Find all the boards this user is allowed to see.
    $request = $smcFunc['db_query']('order_by_board_order', '
        SELECT b.id_cat, c.name AS cat_name, b.id_board, b.name, b.child_level
        FROM {db_prefix}boards AS b
            LEFT JOIN {db_prefix}categories AS c ON (c.id_cat = b.id_cat)
        WHERE {query_see_board}
            AND redirect = {string:empty_string}',
        array(
            'empty_string' => '',
        )
    );
    $context['num_boards'] = $smcFunc['db_num_rows']($request);
    $context['boards_check_all'] = true;
    $context['categories'] = array();
    while ($row = $smcFunc['db_fetch_assoc']($request))
    {
        // This category hasn't been set up yet..
        if (!isset($context['categories'][$row['id_cat']]))
            $context['categories'][$row['id_cat']] = array(
                'id' => $row['id_cat'],
                'name' => $row['cat_name'],
                'boards' => array()
            );

        // Set this board up, and let the template know when it's a child.  (indent them..)
        $context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array(
            'id' => $row['id_board'],
            'name' => $row['name'],
            'child_level' => $row['child_level'],
            'selected' => (empty($context['search_params']['brd']) && (empty($modSettings['recycle_enable']) || $row['id_board'] != $modSettings['recycle_board']) && !in_array($row['id_board'], $user_info['ignoreboards'])) || (!empty($context['search_params']['brd']) && in_array($row['id_board'], $context['search_params']['brd']))
        );

        // If a board wasn't checked that probably should have been ensure the board selection is selected, yo!
        if (!$context['categories'][$row['id_cat']]['boards'][$row['id_board']]['selected'] && (empty($modSettings['recycle_enable']) || $row['id_board'] != $modSettings['recycle_board']))
            $context['boards_check_all'] = false;
    }
    $smcFunc['db_free_result']($request);

    require_once($sourcedir . '/Subs-Boards.php');
    sortCategories($context['categories']);

    // Now, let's sort the list of categories into the boards for templates that like that.
    $temp_boards = array();
    foreach ($context['categories'] as $category)
    {
        $temp_boards[] = array(
            'name' => $category['name'],
            'child_ids' => array_keys($category['boards'])
        );
        $temp_boards = array_merge($temp_boards, array_values($category['boards']));

        // Include a list of boards per category for easy toggling.
        $context['categories'][$category['id']]['child_ids'] = array_keys($category['boards']);
    }

    $max_boards = ceil(count($temp_boards) / 2);
    if ($max_boards == 1)
        $max_boards = 2;

    // Now, alternate them so they can be shown left and right ;).
    $context['board_columns'] = array();
    for ($i = 0; $i < $max_boards; $i++)
    {
        $context['board_columns'][] = $temp_boards[$i];
        if (isset($temp_boards[$i + $max_boards]))
            $context['board_columns'][] = $temp_boards[$i + $max_boards];
        else
            $context['board_columns'][] = array();
    }

    if (!empty($_REQUEST['topic']))
    {
        $context['search_params']['topic'] = (int) $_REQUEST['topic'];
        $context['search_params']['show_complete'] = true;
    }
    if (!empty($context['search_params']['topic']))
    {
        $context['search_params']['topic'] = (int) $context['search_params']['topic'];

        $context['search_topic'] = array(
            'id' => $context['search_params']['topic'],
            'href' => $scripturl . '?topic=' . $context['search_params']['topic'] . '.0',
        );

        $request = $smcFunc['db_query']('', '
            SELECT subject
            FROM {db_prefix}topics AS t
                INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_first_msg)
            WHERE t.id_topic = {int:search_topic_id}
                AND {query_see_message_board} ' . ($modSettings['postmod_active'] ? '
                AND t.approved = {int:is_approved_true}' : '') . '
            LIMIT 1',
            array(
                'is_approved_true' => 1,
                'search_topic_id' => $context['search_params']['topic'],
            )
        );

        if ($smcFunc['db_num_rows']($request) == 0)
            fatal_lang_error('topic_gone', false);

        list ($context['search_topic']['subject']) = $smcFunc['db_fetch_row']($request);
        $smcFunc['db_free_result']($request);

        $context['search_topic']['link'] = '<a href="' . $context['search_topic']['href'] . '">' . $context['search_topic']['subject'] . '</a>';
    }

    $context['page_title'] = $txt['set_parameters'];

    call_integration_hook('integrate_search');
}

/**
 * Gather the results and show them.
 * What it does:
 * - checks user input and searches the messages table for messages matching the query.
 * - requires the search_posts permission.
 * - uses the results sub template of the Search template.
 * - uses the Search language file.
 * - stores the results into the search cache.
 * - show the results of the search query.
 */
function PlushSearch2()
{
    global $scripturl, $modSettings, $sourcedir, $txt;
    global $user_info, $context, $options, $messages_request, $boards_can;
    global $excludedWords, $participants, $smcFunc, $cache_enable;

    // if comming from the quick search box, and we want to search on members, well we need to do that ;)
    if (isset($_REQUEST['search_selection']) && $_REQUEST['search_selection'] === 'members')
        redirectexit($scripturl . '?action=mlist;sa=search;fields=name,email;search=' . urlencode($_REQUEST['search']));

    if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search'])
        fatal_lang_error('loadavg_search_disabled', false);

    // No, no, no... this is a bit hard on the server, so don't you go prefetching it!
    if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch')
    {
        ob_end_clean();
        send_http_status(403);
        die;
    }

    $weight_factors = array(
        'frequency' => array(
            'search' => 'COUNT(*) / (MAX(t.num_replies) + 1)',
            'results' => '(t.num_replies + 1)',
        ),
        'age' => array(
            'search' => 'CASE WHEN MAX(m.id_msg) < {int:min_msg} THEN 0 ELSE (MAX(m.id_msg) - {int:min_msg}) / {int:recent_message} END',
            'results' => 'CASE WHEN t.id_first_msg < {int:min_msg} THEN 0 ELSE (t.id_first_msg - {int:min_msg}) / {int:recent_message} END',
        ),
        'length' => array(
            'search' => 'CASE WHEN MAX(t.num_replies) < {int:huge_topic_posts} THEN MAX(t.num_replies) / {int:huge_topic_posts} ELSE 1 END',
            'results' => 'CASE WHEN t.num_replies < {int:huge_topic_posts} THEN t.num_replies / {int:huge_topic_posts} ELSE 1 END',
        ),
        'subject' => array(
            'search' => 0,
            'results' => 0,
        ),
        'first_message' => array(
            'search' => 'CASE WHEN MIN(m.id_msg) = MAX(t.id_first_msg) THEN 1 ELSE 0 END',
        ),
        'sticky' => array(
            'search' => 'MAX(t.is_sticky)',
            'results' => 't.is_sticky',
        ),
    );

    call_integration_hook('integrate_search_weights', array(&$weight_factors));

    $weight = array();
    $weight_total = 0;
    foreach ($weight_factors as $weight_factor => $value)
    {
        $weight[$weight_factor] = empty($modSettings['search_weight_' . $weight_factor]) ? 0 : (int) $modSettings['search_weight_' . $weight_factor];
        $weight_total += $weight[$weight_factor];
    }

    // Zero weight.  Weightless :P.
    if (empty($weight_total))
        fatal_lang_error('search_invalid_weights');

    // These vars don't require an interface, they're just here for tweaking.
    $recentPercentage = 0.30;
    $humungousTopicPosts = 200;
    $maxMembersToSearch = 500;
    $maxMessageResults = empty($modSettings['search_max_results']) ? 0 : $modSettings['search_max_results'] * 5;

    // Start with no errors.
    $context['search_errors'] = array();

    // Number of pages hard maximum - normally not set at all.
    $modSettings['search_max_results'] = empty($modSettings['search_max_results']) ? 200 * $modSettings['search_results_per_page'] : (int) $modSettings['search_max_results'];

    // Maximum length of the string.
    $context['search_string_limit'] = 100;

    loadLanguage('Search');
    if (!isset($_REQUEST['xml']))
        loadTemplate('Search');
    //If we're doing XML we need to use the results template regardless really.
    else
        $context['sub_template'] = 'results';

    // Are you allowed?
    isAllowedTo('search_posts');

    require_once($sourcedir . '/Display.php');
    require_once($sourcedir . '/Subs-Package.php');

    // Search has a special database set.
    db_extend('search');

    // Load up the search API we are going to use.
    $searchAPI = findSearchAPI();

    // $search_params will carry all settings that differ from the default search parameters.
    // That way, the URLs involved in a search page will be kept as short as possible.
    $search_params = array();

    if (isset($_REQUEST['params']))
    {
        // Due to IE's 2083 character limit, we have to compress long search strings
        $temp_params = base64_decode(str_replace(array('-', '_', '.'), array('+', '/', '='), $_REQUEST['params']));

        // Test for gzuncompress failing
        $temp_params2 = @gzuncompress($temp_params);
        $temp_params = explode('|"|', (!empty($temp_params2) ? $temp_params2 : $temp_params));

        foreach ($temp_params as $i => $data)
        {
            @list($k, $v) = explode('|\'|', $data);
            $search_params[$k] = $v;
        }

        if (isset($search_params['brd']))
            $search_params['brd'] = empty($search_params['brd']) ? array() : explode(',', $search_params['brd']);
    }

    // Store whether simple search was used (needed if the user wants to do another query).
    if (!isset($search_params['advanced']))
        $search_params['advanced'] = empty($_REQUEST['advanced']) ? 0 : 1;

    // 1 => 'allwords' (default, don't set as param) / 2 => 'anywords'.
    if (!empty($search_params['searchtype']) || (!empty($_REQUEST['searchtype']) && $_REQUEST['searchtype'] == 2))
        $search_params['searchtype'] = 2;

    // Minimum age of messages. Default to zero (don't set param in that case).
    if (!empty($search_params['minage']) || (!empty($_REQUEST['minage']) && $_REQUEST['minage'] > 0))
        $search_params['minage'] = !empty($search_params['minage']) ? (int) $search_params['minage'] : (int) $_REQUEST['minage'];

    // Maximum age of messages. Default to infinite (9999 days: param not set).
    if (!empty($search_params['maxage']) || (!empty($_REQUEST['maxage']) && $_REQUEST['maxage'] < 9999))
        $search_params['maxage'] = !empty($search_params['maxage']) ? (int) $search_params['maxage'] : (int) $_REQUEST['maxage'];

    // Searching a specific topic?
    if (!empty($_REQUEST['topic']) || (!empty($_REQUEST['search_selection']) && $_REQUEST['search_selection'] == 'topic'))
    {
        $search_params['topic'] = empty($_REQUEST['search_selection']) ? (int) $_REQUEST['topic'] : (isset($_REQUEST['sd_topic']) ? (int) $_REQUEST['sd_topic'] : '');
        $search_params['show_complete'] = true;
    }
    elseif (!empty($search_params['topic']))
        $search_params['topic'] = (int) $search_params['topic'];

    if (!empty($search_params['minage']) || !empty($search_params['maxage']))
    {
        $request = $smcFunc['db_query']('', '
            SELECT ' . (empty($search_params['maxage']) ? '0, ' : 'COALESCE(MIN(id_msg), -1), ') . (empty($search_params['minage']) ? '0' : 'COALESCE(MAX(id_msg), -1)') . '
            FROM {db_prefix}messages
            WHERE 1=1' . ($modSettings['postmod_active'] ? '
                AND approved = {int:is_approved_true}' : '') . (empty($search_params['minage']) ? '' : '
                AND poster_time <= {int:timestamp_minimum_age}') . (empty($search_params['maxage']) ? '' : '
                AND poster_time >= {int:timestamp_maximum_age}'),
            array(
                'timestamp_minimum_age' => empty($search_params['minage']) ? 0 : time() - 86400 * $search_params['minage'],
                'timestamp_maximum_age' => empty($search_params['maxage']) ? 0 : time() - 86400 * $search_params['maxage'],
                'is_approved_true' => 1,
            )
        );
        list ($minMsgID, $maxMsgID) = $smcFunc['db_fetch_row']($request);
        if ($minMsgID < 0 || $maxMsgID < 0)
            $context['search_errors']['no_messages_in_time_frame'] = true;
        $smcFunc['db_free_result']($request);
    }

    // Default the user name to a wildcard matching every user (*).
    if (!empty($search_params['userspec']) || (!empty($_REQUEST['userspec']) && $_REQUEST['userspec'] != '*'))
        $search_params['userspec'] = isset($search_params['userspec']) ? $search_params['userspec'] : $_REQUEST['userspec'];

    // If there's no specific user, then don't mention it in the main query.
    if (empty($search_params['userspec']))
        $userQuery = '';
    else
    {
        $userString = strtr($smcFunc['htmlspecialchars']($search_params['userspec'], ENT_QUOTES), array('&quot;' => '"'));
        $userString = strtr($userString, array('%' => '\%', '_' => '\_', '*' => '%', '?' => '_'));

        preg_match_all('~"([^"]+)"~', $userString, $matches);
        $possible_users = array_merge($matches[1], explode(',', preg_replace('~"[^"]+"~', '', $userString)));

        for ($k = 0, $n = count($possible_users); $k < $n; $k++)
        {
            $possible_users[$k] = trim($possible_users[$k]);

            if (strlen($possible_users[$k]) == 0)
                unset($possible_users[$k]);
        }

        // Create a list of database-escaped search names.
        $realNameMatches = array();
        foreach ($possible_users as $possible_user)
            $realNameMatches[] = $smcFunc['db_quote'](
                '{string:possible_user}',
                array(
                    'possible_user' => $possible_user
                )
            );

        // Retrieve a list of possible members.
        $request = $smcFunc['db_query']('', '
            SELECT id_member
            FROM {db_prefix}members
            WHERE {raw:match_possible_users}',
            array(
                'match_possible_users' => 'real_name LIKE ' . implode(' OR real_name LIKE ', $realNameMatches),
            )
        );
        // Simply do nothing if there're too many members matching the criteria.
        if ($smcFunc['db_num_rows']($request) > $maxMembersToSearch)
            $userQuery = '';
        elseif ($smcFunc['db_num_rows']($request) == 0)
        {
            $userQuery = $smcFunc['db_quote'](
                'm.id_member = {int:id_member_guest} AND ({raw:match_possible_guest_names})',
                array(
                    'id_member_guest' => 0,
                    'match_possible_guest_names' => 'm.poster_name LIKE ' . implode(' OR m.poster_name LIKE ', $realNameMatches),
                )
            );
        }
        else
        {
            $memberlist = array();
            while ($row = $smcFunc['db_fetch_assoc']($request))
                $memberlist[] = $row['id_member'];
            $userQuery = $smcFunc['db_quote'](
                '(m.id_member IN ({array_int:matched_members}) OR (m.id_member = {int:id_member_guest} AND ({raw:match_possible_guest_names})))',
                array(
                    'matched_members' => $memberlist,
                    'id_member_guest' => 0,
                    'match_possible_guest_names' => 'm.poster_name LIKE ' . implode(' OR m.poster_name LIKE ', $realNameMatches),
                )
            );
        }
        $smcFunc['db_free_result']($request);
    }

    // If the boards were passed by URL (params=), temporarily put them back in $_REQUEST.
    if (!empty($search_params['brd']) && is_array($search_params['brd']))
        $_REQUEST['brd'] = $search_params['brd'];

    // Ensure that brd is an array.
    if ((!empty($_REQUEST['brd']) && !is_array($_REQUEST['brd'])) || (!empty($_REQUEST['search_selection']) && $_REQUEST['search_selection'] == 'board'))
    {
        if (!empty($_REQUEST['brd']))
            $_REQUEST['brd'] = strpos($_REQUEST['brd'], ',') !== false ? explode(',', $_REQUEST['brd']) : array($_REQUEST['brd']);
        else
            $_REQUEST['brd'] = isset($_REQUEST['sd_brd']) ? array($_REQUEST['sd_brd']) : array();
    }

    // Make sure all boards are integers.
    if (!empty($_REQUEST['brd']))
        foreach ($_REQUEST['brd'] as $id => $brd)
            $_REQUEST['brd'][$id] = (int) $brd;

    // Special case for boards: searching just one topic?
    if (!empty($search_params['topic']))
    {
        $request = $smcFunc['db_query']('', '
            SELECT t.id_board
            FROM {db_prefix}topics AS t
            WHERE t.id_topic = {int:search_topic_id}
                AND {query_see_topic_board}' . ($modSettings['postmod_active'] ? '
                AND t.approved = {int:is_approved_true}' : '') . '
            LIMIT 1',
            array(
                'search_topic_id' => $search_params['topic'],
                'is_approved_true' => 1,
            )
        );

        if ($smcFunc['db_num_rows']($request) == 0)
            fatal_lang_error('topic_gone', false);

        $search_params['brd'] = array();
        list ($search_params['brd'][0]) = $smcFunc['db_fetch_row']($request);
        $smcFunc['db_free_result']($request);
    }
    // Select all boards you've selected AND are allowed to see.
    elseif ($user_info['is_admin'] && (!empty($search_params['advanced']) || !empty($_REQUEST['brd'])))
        $search_params['brd'] = empty($_REQUEST['brd']) ? array() : $_REQUEST['brd'];
    else
    {
        $see_board = empty($search_params['advanced']) ? 'query_wanna_see_board' : 'query_see_board';
        $request = $smcFunc['db_query']('', '
            SELECT b.id_board
            FROM {db_prefix}boards AS b
            WHERE {raw:boards_allowed_to_see}
                AND redirect = {string:empty_string}' . (empty($_REQUEST['brd']) ? (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? '
                AND b.id_board != {int:recycle_board_id}' : '') : '
                AND b.id_board IN ({array_int:selected_search_boards})'),
            array(
                'boards_allowed_to_see' => $user_info[$see_board],
                'empty_string' => '',
                'selected_search_boards' => empty($_REQUEST['brd']) ? array() : $_REQUEST['brd'],
                'recycle_board_id' => $modSettings['recycle_board'],
            )
        );
        $search_params['brd'] = array();
        while ($row = $smcFunc['db_fetch_assoc']($request))
            $search_params['brd'][] = $row['id_board'];
        $smcFunc['db_free_result']($request);

        // This error should pro'bly only happen for hackers.
        if (empty($search_params['brd']))
            $context['search_errors']['no_boards_selected'] = true;
    }

    if (count($search_params['brd']) != 0)
    {
        foreach ($search_params['brd'] as $k => $v)
            $search_params['brd'][$k] = (int) $v;

        // If we've selected all boards, this parameter can be left empty.
        $request = $smcFunc['db_query']('', '
            SELECT COUNT(*)
            FROM {db_prefix}boards
            WHERE redirect = {string:empty_string}',
            array(
                'empty_string' => '',
            )
        );
        list ($num_boards) = $smcFunc['db_fetch_row']($request);
        $smcFunc['db_free_result']($request);

        if (count($search_params['brd']) == $num_boards)
            $boardQuery = '';
        elseif (count($search_params['brd']) == $num_boards - 1 && !empty($modSettings['recycle_board']) && !in_array($modSettings['recycle_board'], $search_params['brd']))
            $boardQuery = '!= ' . $modSettings['recycle_board'];
        else
            $boardQuery = 'IN (' . implode(', ', $search_params['brd']) . ')';
    }
    else
        $boardQuery = '';

    $search_params['show_complete'] = !empty($search_params['show_complete']) || !empty($_REQUEST['show_complete']);
    $search_params['subject_only'] = !empty($search_params['subject_only']) || !empty($_REQUEST['subject_only']);

    $context['compact'] = !$search_params['show_complete'];

    // Get the sorting parameters right. Default to sort by relevance descending.
    $sort_columns = array(
        'relevance',
        'num_replies',
        'id_msg',
    );
    call_integration_hook('integrate_search_sort_columns', array(&$sort_columns));
    if (empty($search_params['sort']) && !empty($_REQUEST['sort']))
        list ($search_params['sort'], $search_params['sort_dir']) = array_pad(explode('|', $_REQUEST['sort']), 2, '');
    $search_params['sort'] = !empty($search_params['sort']) && in_array($search_params['sort'], $sort_columns) ? $search_params['sort'] : 'relevance';
    if (!empty($search_params['topic']) && $search_params['sort'] === 'num_replies')
        $search_params['sort'] = 'id_msg';

    // Sorting direction: descending unless stated otherwise.
    $search_params['sort_dir'] = !empty($search_params['sort_dir']) && $search_params['sort_dir'] == 'asc' ? 'asc' : 'desc';

    // Determine some values needed to calculate the relevance.
    $minMsg = (int) ((1 - $recentPercentage) * $modSettings['maxMsgID']);
    $recentMsg = $modSettings['maxMsgID'] - $minMsg;

    // *** Parse the search query
    call_integration_hook('integrate_search_params', array(&$search_params));

    /*
     * Unfortunately, searching for words like this is going to be slow, so we're blacklisting them.
     *
     * @todo Setting to add more here?
     * @todo Maybe only blacklist if they are the only word, or "any" is used?
     */
    $blacklisted_words = array('img', 'url', 'quote', 'www', 'http', 'the', 'is', 'it', 'are', 'if');
    call_integration_hook('integrate_search_blacklisted_words', array(&$blacklisted_words));

    // What are we searching for?
    if (empty($search_params['search']))
    {
        if (isset($_GET['search']))
            $search_params['search'] = un_htmlspecialchars($_GET['search']);
        elseif (isset($_POST['search']))
            $search_params['search'] = $_POST['search'];
        else
            $search_params['search'] = '';
    }

    // Nothing??
    if (!isset($search_params['search']) || $search_params['search'] == '')
        $context['search_errors']['invalid_search_string'] = true;
    // Too long?
    elseif ($smcFunc['strlen']($search_params['search']) > $context['search_string_limit'])
    {
        $context['search_errors']['string_too_long'] = true;
    }

    // Change non-word characters into spaces.
    $stripped_query = preg_replace('~(?:[\x0B\0' . ($context['utf8'] ? '\x{A0}' : '\xA0') . '\t\r\s\n(){}\\[\\]<>!@$%^*.,:+=`\~\?/\\\\]+|&(?:amp|lt|gt|quot);)+~' . ($context['utf8'] ? 'u' : ''), ' ', $search_params['search']);

    // Make the query lower case. It's gonna be case insensitive anyway.
    $stripped_query = un_htmlspecialchars($smcFunc['strtolower']($stripped_query));

    // This (hidden) setting will do fulltext searching in the most basic way.
    if (!empty($modSettings['search_simple_fulltext']))
        $stripped_query = strtr($stripped_query, array('"' => ''));

    $no_regexp = preg_match('~&#(?:\d{1,7}|x[0-9a-fA-F]{1,6});~', $stripped_query) === 1;

    // Extract phrase parts first (e.g. some words "this is a phrase" some more words.)
    preg_match_all('/(?:^|\s)([-]?)"([^"]+)"(?:$|\s)/', $stripped_query, $matches, PREG_PATTERN_ORDER);
    $phraseArray = $matches[2];

    // Remove the phrase parts and extract the words.
    $wordArray = preg_replace('~(?:^|\s)(?:[-]?)"(?:[^"]+)"(?:$|\s)~' . ($context['utf8'] ? 'u' : ''), ' ', $search_params['search']);
    $wordArray = explode(' ', $smcFunc['htmlspecialchars'](un_htmlspecialchars($wordArray), ENT_QUOTES));

    // A minus sign in front of a word excludes the word.... so...
    $excludedWords = array();
    $excludedIndexWords = array();
    $excludedSubjectWords = array();
    $excludedPhrases = array();

    // .. first, we check for things like -"some words", but not "-some words".
    foreach ($matches[1] as $index => $word)
    {
        if ($word === '-')
        {
            if (($word = trim($phraseArray[$index], '-_\' ')) !== '' && !in_array($word, $blacklisted_words))
                $excludedWords[] = $word;
            unset($phraseArray[$index]);
        }
    }

    // Now we look for -test, etc.... normaller.
    foreach ($wordArray as $index => $word)
    {
        if (strpos(trim($word), '-') === 0)
        {
            if (($word = trim($word, '-_\' ')) !== '' && !in_array($word, $blacklisted_words))
                $excludedWords[] = $word;
            unset($wordArray[$index]);
        }
    }

    // The remaining words and phrases are all included.
    $searchArray = array_merge($phraseArray, $wordArray);

    $context['search_ignored'] = array();
    // Trim everything and make sure there are no words that are the same.
    foreach ($searchArray as $index => $value)
    {
        // Skip anything practically empty.
        if (($searchArray[$index] = trim($value, '-_\' ')) === '')
            unset($searchArray[$index]);
        // Skip blacklisted words. Make sure to note we skipped them in case we end up with nothing.
        elseif (in_array($searchArray[$index], $blacklisted_words))
        {
            $foundBlackListedWords = true;
            unset($searchArray[$index]);
        }
        // Don't allow very, very short words.
        elseif ($smcFunc['strlen']($value) < 2)
        {
            $context['search_ignored'][] = $value;
            unset($searchArray[$index]);
        }
    }
    $searchArray = array_slice(array_unique($searchArray), 0, 10);

    // Create an array of replacements for highlighting.
    $context['mark'] = array();
    foreach ($searchArray as $word)
        $context['mark'][$word] = '<strong class="highlight">' . $word . '</strong>';

    // Initialize two arrays storing the words that have to be searched for.
    $orParts = array();
    $searchWords = array();

    // Make sure at least one word is being searched for.
    if (empty($searchArray))
        $context['search_errors']['invalid_search_string' . (!empty($foundBlackListedWords) ? '_blacklist' : '')] = true;
    // All words/sentences must match.
    elseif (empty($search_params['searchtype']))
        $orParts[0] = $searchArray;
    // Any word/sentence must match.
    else
        foreach ($searchArray as $index => $value)
            $orParts[$index] = array($value);

    // Don't allow duplicate error messages if one string is too short.
    if (isset($context['search_errors']['search_string_small_words'], $context['search_errors']['invalid_search_string']))
        unset($context['search_errors']['invalid_search_string']);
    // Make sure the excluded words are in all or-branches.
    foreach ($orParts as $orIndex => $andParts)
        foreach ($excludedWords as $word)
            $orParts[$orIndex][] = $word;

    // Determine the or-branches and the fulltext search words.
    foreach ($orParts as $orIndex => $andParts)
    {
        $searchWords[$orIndex] = array(
            'indexed_words' => array(),
            'words' => array(),
            'subject_words' => array(),
            'all_words' => array(),
            'complex_words' => array(),
        );

        // Sort the indexed words (large words -> small words -> excluded words).
        if ($searchAPI->supportsMethod('searchSort'))
            usort($orParts[$orIndex], 'searchSort');

        foreach ($orParts[$orIndex] as $word)
        {
            $is_excluded = in_array($word, $excludedWords);

            $searchWords[$orIndex]['all_words'][] = $word;

            $subjectWords = text2words($word);
            if (!$is_excluded || count($subjectWords) === 1)
            {
                $searchWords[$orIndex]['subject_words'] = array_merge($searchWords[$orIndex]['subject_words'], $subjectWords);
                if ($is_excluded)
                    $excludedSubjectWords = array_merge($excludedSubjectWords, $subjectWords);
            }
            else
                $excludedPhrases[] = $word;

            // Have we got indexes to prepare?
            if ($searchAPI->supportsMethod('prepareIndexes'))
                $searchAPI->prepareIndexes($word, $searchWords[$orIndex], $excludedIndexWords, $is_excluded);
        }

        // Search_force_index requires all AND parts to have at least one fulltext word.
        if (!empty($modSettings['search_force_index']) && empty($searchWords[$orIndex]['indexed_words']))
        {
            $context['search_errors']['query_not_specific_enough'] = true;
            break;
        }
        elseif ($search_params['subject_only'] && empty($searchWords[$orIndex]['subject_words']) && empty($excludedSubjectWords))
        {
            $context['search_errors']['query_not_specific_enough'] = true;
            break;
        }

        // Make sure we aren't searching for too many indexed words.
        else
        {
            $searchWords[$orIndex]['indexed_words'] = array_slice($searchWords[$orIndex]['indexed_words'], 0, 7);
            $searchWords[$orIndex]['subject_words'] = array_slice($searchWords[$orIndex]['subject_words'], 0, 7);
            $searchWords[$orIndex]['words'] = array_slice($searchWords[$orIndex]['words'], 0, 4);
        }
    }

    // *** Spell checking
    $context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && (function_exists('pspell_new') || (function_exists('enchant_broker_init') && ($txt['lang_character_set'] == 'UTF-8' || function_exists('iconv'))));
    if ($context['show_spellchecking'])
    {
        require_once($sourcedir . '/Subs-Post.php');

        // Don't hardcode spellchecking functions!
        $link = spell_init();

        $did_you_mean = array('search' => array(), 'display' => array());
        $found_misspelling = false;
        foreach ($searchArray as $word)
        {
            if (empty($link))
                continue;

            // Don't check phrases.
            if (preg_match('~^\w+$~', $word) === 0)
            {
                $did_you_mean['search'][] = '"' . $word . '"';
                $did_you_mean['display'][] = '&quot;' . $smcFunc['htmlspecialchars']($word) . '&quot;';
                continue;
            }
            // For some strange reason spell check can crash PHP on decimals.
            elseif (preg_match('~\d~', $word) === 1)
            {
                $did_you_mean['search'][] = $word;
                $did_you_mean['display'][] = $smcFunc['htmlspecialchars']($word);
                continue;
            }
            elseif (spell_check($link, $word))
            {
                $did_you_mean['search'][] = $word;
                $did_you_mean['display'][] = $smcFunc['htmlspecialchars']($word);
                continue;
            }

            $suggestions = spell_suggest($link, $word);
            foreach ($suggestions as $i => $s)
            {
                // Search is case insensitive.
                if ($smcFunc['strtolower']($s) == $smcFunc['strtolower']($word))
                    unset($suggestions[$i]);
                // Plus, don't suggest something the user thinks is rude!
                elseif ($suggestions[$i] != censorText($s))
                    unset($suggestions[$i]);
            }

            // Anything found?  If so, correct it!
            if (!empty($suggestions))
            {
                $suggestions = array_values($suggestions);
                $did_you_mean['search'][] = $suggestions[0];
                $did_you_mean['display'][] = '<em><strong>' . $smcFunc['htmlspecialchars']($suggestions[0]) . '</strong></em>';
                $found_misspelling = true;
            }
            else
            {
                $did_you_mean['search'][] = $word;
                $did_you_mean['display'][] = $smcFunc['htmlspecialchars']($word);
            }
        }

        if ($found_misspelling)
        {
            // Don't spell check excluded words, but add them still...
            $temp_excluded = array('search' => array(), 'display' => array());
            foreach ($excludedWords as $word)
            {
                if (preg_match('~^\w+$~', $word) == 0)
                {
                    $temp_excluded['search'][] = '-"' . $word . '"';
                    $temp_excluded['display'][] = '-&quot;' . $smcFunc['htmlspecialchars']($word) . '&quot;';
                }
                else
                {
                    $temp_excluded['search'][] = '-' . $word;
                    $temp_excluded['display'][] = '-' . $smcFunc['htmlspecialchars']($word);
                }
            }

            $did_you_mean['search'] = array_merge($did_you_mean['search'], $temp_excluded['search']);
            $did_you_mean['display'] = array_merge($did_you_mean['display'], $temp_excluded['display']);

            $temp_params = $search_params;
            $temp_params['search'] = implode(' ', $did_you_mean['search']);
            if (isset($temp_params['brd']))
                $temp_params['brd'] = implode(',', $temp_params['brd']);
            $context['params'] = array();
            foreach ($temp_params as $k => $v)
                $context['did_you_mean_params'][] = $k . '|\'|' . $v;
            $context['did_you_mean_params'] = base64_encode(implode('|"|', $context['did_you_mean_params']));
            $context['did_you_mean'] = implode(' ', $did_you_mean['display']);
        }
    }

    // Let the user adjust the search query, should they wish?
    $context['search_params'] = $search_params;
    if (isset($context['search_params']['search']))
        $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']);
    if (isset($context['search_params']['userspec']))
        $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']);

    // Do we have captcha enabled?
    if ($user_info['is_guest'] && !empty($modSettings['search_enable_captcha']) && empty($_SESSION['ss_vv_passed']) && (empty($_SESSION['last_ss']) || $_SESSION['last_ss'] != $search_params['search']))
    {
        require_once($sourcedir . '/Subs-Editor.php');
        $verificationOptions = array(
            'id' => 'search',
        );
        $context['require_verification'] = create_control_verification($verificationOptions, true);

        if (is_array($context['require_verification']))
        {
            foreach ($context['require_verification'] as $error)
                $context['search_errors'][$error] = true;
        }
        // Don't keep asking for it - they've proven themselves worthy.
        else
            $_SESSION['ss_vv_passed'] = true;
    }

    // *** Encode all search params

    // All search params have been checked, let's compile them to a single string... made less simple by PHP 4.3.9 and below.
    $temp_params = $search_params;
    if (isset($temp_params['brd']))
        $temp_params['brd'] = implode(',', $temp_params['brd']);
    $context['params'] = array();
    foreach ($temp_params as $k => $v)
        $context['params'][] = $k . '|\'|' . $v;

    if (!empty($context['params']))
    {
        // Due to old IE's 2083 character limit, we have to compress long search strings
        $params = @gzcompress(implode('|"|', $context['params']));
        // Gzcompress failed, use try non-gz
        if (empty($params))
            $params = implode('|"|', $context['params']);
        // Base64 encode, then replace +/= with uri safe ones that can be reverted
        $context['params'] = str_replace(array('+', '/', '='), array('-', '_', '.'), base64_encode($params));
    }

    // ... and add the links to the link tree.
    $context['linktree'][] = array(
        'url' => $scripturl . '?action=search;params=' . $context['params'],
        'name' => $txt['search']
    );
    $context['linktree'][] = array(
        'url' => $scripturl . '?action=search2;params=' . $context['params'],
        'name' => $txt['search_results']
    );

    // *** A last error check
    call_integration_hook('integrate_search_errors');

    // One or more search errors? Go back to the first search screen.
    if (!empty($context['search_errors']))
    {
        $_REQUEST['params'] = $context['params'];
        return PlushSearch1();
    }

    // Spam me not, Spam-a-lot?
    if (empty($_SESSION['last_ss']) || $_SESSION['last_ss'] != $search_params['search'])
        spamProtection('search');
    // Store the last search string to allow pages of results to be browsed.
    $_SESSION['last_ss'] = $search_params['search'];

    // *** Reserve an ID for caching the search results.
    $query_params = array_merge($search_params, array(
        'min_msg_id' => isset($minMsgID) ? (int) $minMsgID : 0,
        'max_msg_id' => isset($maxMsgID) ? (int) $maxMsgID : 0,
        'memberlist' => !empty($memberlist) ? $memberlist : array(),
    ));

    // Can this search rely on the API given the parameters?
    if ($searchAPI->supportsMethod('searchQuery', $query_params))
    {
        $participants = array();
        $searchArray = array();

        $searchAPI->searchQuery($query_params, $searchWords, $excludedIndexWords, $participants, $searchArray);
    }

    // Update the cache if the current search term is not yet cached.
    else
    {
        $update_cache = empty($_SESSION['search_cache']) || ($_SESSION['search_cache']['params'] != $context['params']);
        // Are the result fresh?
        if (!$update_cache && !empty($_SESSION['search_cache']['id_search']))
        {
            $request = $smcFunc['db_query']('', '
                SELECT id_search
                FROM {db_prefix}log_search_results
                WHERE id_search = {int:search_id}
                LIMIT 1',
                array(
                    'search_id' => $_SESSION['search_cache']['id_search'],
                )
            );

            if ($smcFunc['db_num_rows']($request) === 0)
                $update_cache = true;
        }

        if ($update_cache)
        {
            // Increase the pointer...
            $modSettings['search_pointer'] = empty($modSettings['search_pointer']) ? 0 : (int) $modSettings['search_pointer'];
            // ...and store it right off.
            updateSettings(array('search_pointer' => $modSettings['search_pointer'] >= 255 ? 0 : $modSettings['search_pointer'] + 1));
            // As long as you don't change the parameters, the cache result is yours.
            $_SESSION['search_cache'] = array(
                'id_search' => $modSettings['search_pointer'],
                'num_results' => -1,
                'params' => $context['params'],
            );

            // Clear the previous cache of the final results cache.
            $smcFunc['db_search_query']('delete_log_search_results', '
                DELETE FROM {db_prefix}log_search_results
                WHERE id_search = {int:search_id}',
                array(
                    'search_id' => $_SESSION['search_cache']['id_search'],
                )
            );

            if ($search_params['subject_only'])
            {
                // We do this to try and avoid duplicate keys on databases not supporting INSERT IGNORE.
                $inserts = array();
                foreach ($searchWords as $orIndex => $words)
                {
                    $subject_query_params = array();
                    $subject_query = array(
                        'from' => '{db_prefix}topics AS t',
                        'inner_join' => array(),
                        'left_join' => array(),
                        'where' => array(),
                    );

                    if ($modSettings['postmod_active'])
                        $subject_query['where'][] = 't.approved = {int:is_approved}';

                    $numTables = 0;
                    $prev_join = 0;
                    $numSubjectResults = 0;
                    foreach ($words['subject_words'] as $subjectWord)
                    {
                        $numTables++;
                        if (in_array($subjectWord, $excludedSubjectWords))
                        {
                            $subject_query['left_join'][] = '{db_prefix}log_search_subjects AS subj' . $numTables . ' ON (subj' . $numTables . '.word ' . (empty($modSettings['search_match_words']) ? 'LIKE {string:subject_words_' . $numTables . '_wild}' : '= {string:subject_words_' . $numTables . '}') . ' AND subj' . $numTables . '.id_topic = t.id_topic)';
                            $subject_query['where'][] = '(subj' . $numTables . '.word IS NULL)';
                        }
                        else
                        {
                            $subject_query['inner_join'][] = '{db_prefix}log_search_subjects AS subj' . $numTables . ' ON (subj' . $numTables . '.id_topic = ' . ($prev_join === 0 ? 't' : 'subj' . $prev_join) . '.id_topic)';
                            $subject_query['where'][] = 'subj' . $numTables . '.word ' . (empty($modSettings['search_match_words']) ? 'LIKE {string:subject_words_' . $numTables . '_wild}' : '= {string:subject_words_' . $numTables . '}');
                            $prev_join = $numTables;
                        }
                        $subject_query_params['subject_words_' . $numTables] = $subjectWord;
                        $subject_query_params['subject_words_' . $numTables . '_wild'] = '%' . $subjectWord . '%';
                    }

                    if (!empty($userQuery))
                    {
                        if ($subject_query['from'] != '{db_prefix}messages AS m')
                        {
                            $subject_query['inner_join'][] = '{db_prefix}messages AS m ON (m.id_topic = t.id_topic)';
                        }
                        $subject_query['where'][] = $userQuery;
                    }
                    if (!empty($search_params['topic']))
                        $subject_query['where'][] = 't.id_topic = ' . $search_params['topic'];
                    if (!empty($minMsgID))
                        $subject_query['where'][] = 't.id_first_msg >= ' . $minMsgID;
                    if (!empty($maxMsgID))
                        $subject_query['where'][] = 't.id_last_msg <= ' . $maxMsgID;
                    if (!empty($boardQuery))
                        $subject_query['where'][] = 't.id_board ' . $boardQuery;
                    if (!empty($excludedPhrases))
                    {
                        if ($subject_query['from'] != '{db_prefix}messages AS m')
                        {
                            $subject_query['inner_join'][] = '{db_prefix}messages AS m ON (m.id_msg = t.id_first_msg)';
                        }
                        $count = 0;
                        foreach ($excludedPhrases as $phrase)
                        {
                            $subject_query['where'][] = 'm.subject NOT ' . (empty($modSettings['search_match_words']) || $no_regexp ? ' LIKE ' : ' RLIKE ') . '{string:excluded_phrases_' . $count . '}';
                            $subject_query_params['excluded_phrases_' . $count++] = empty($modSettings['search_match_words']) || $no_regexp ? '%' . strtr($phrase, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $phrase), '\\\'') . '[[:>:]]';
                        }
                    }
                    call_integration_hook('integrate_subject_only_search_query', array(&$subject_query, &$subject_query_params));

                    $relevance = '1000 * (';
                    foreach ($weight_factors as $type => $value)
                    {
                        $relevance .= $weight[$type];
                        if (!empty($value['results']))
                            $relevance .= ' * ' . $value['results'];
                        $relevance .= ' + ';
                    }
                    $relevance = substr($relevance, 0, -3) . ') / ' . $weight_total . ' AS relevance';

                    $ignoreRequest = $smcFunc['db_search_query']('insert_log_search_results_subject',
                        ($smcFunc['db_support_ignore'] ? '
                        INSERT IGNORE INTO {db_prefix}log_search_results
                            (id_search, id_topic, relevance, id_msg, num_matches)' : '') . '
                        SELECT
                            {int:id_search},
                            t.id_topic,
                            ' . $relevance . ',
                            ' . (empty($userQuery) ? 't.id_first_msg' : 'm.id_msg') . ',
                            1
                        FROM ' . $subject_query['from'] . (empty($subject_query['inner_join']) ? '' : '
                            INNER JOIN ' . implode('
                            INNER JOIN ', $subject_query['inner_join'])) . (empty($subject_query['left_join']) ? '' : '
                            LEFT JOIN ' . implode('
                            LEFT JOIN ', $subject_query['left_join'])) . '
                        WHERE ' . implode('
                            AND ', $subject_query['where']) . (empty($modSettings['search_max_results']) ? '' : '
                        LIMIT ' . ($modSettings['search_max_results'] - $numSubjectResults)),
                        array_merge($subject_query_params, array(
                            'id_search' => $_SESSION['search_cache']['id_search'],
                            'min_msg' => $minMsg,
                            'recent_message' => $recentMsg,
                            'huge_topic_posts' => $humungousTopicPosts,
                            'is_approved' => 1,
                        ))
                    );

                    // If the database doesn't support IGNORE to make this fast we need to do some tracking.
                    if (!$smcFunc['db_support_ignore'])
                    {
                        while ($row = $smcFunc['db_fetch_row']($ignoreRequest))
                        {
                            // No duplicates!
                            if (isset($inserts[$row[1]]))
                                continue;

                            foreach ($row as $key => $value)
                                $inserts[$row[1]][] = (int) $row[$key];
                        }
                        $smcFunc['db_free_result']($ignoreRequest);
                        $numSubjectResults = count($inserts);
                    }
                    else
                        $numSubjectResults += $smcFunc['db_affected_rows']();

                    if (!empty($modSettings['search_max_results']) && $numSubjectResults >= $modSettings['search_max_results'])
                        break;
                }

                // If there's data to be inserted for non-IGNORE databases do it here!
                if (!empty($inserts))
                {
                    $smcFunc['db_insert']('',
                        '{db_prefix}log_search_results',
                        array('id_search' => 'int', 'id_topic' => 'int', 'relevance' => 'int', 'id_msg' => 'int', 'num_matches' => 'int'),
                        $inserts,
                        array('id_search', 'id_topic')
                    );
                }

                $_SESSION['search_cache']['num_results'] = $numSubjectResults;
            }
            else
            {
                $main_query = array(
                    'select' => array(
                        'id_search' => $_SESSION['search_cache']['id_search'],
                        'relevance' => '0',
                    ),
                    'weights' => array(),
                    'from' => '{db_prefix}topics AS t',
                    'inner_join' => array(
                        '{db_prefix}messages AS m ON (m.id_topic = t.id_topic)'
                    ),
                    'left_join' => array(),
                    'where' => array(),
                    'group_by' => array(),
                    'parameters' => array(
                        'min_msg' => $minMsg,
                        'recent_message' => $recentMsg,
                        'huge_topic_posts' => $humungousTopicPosts,
                        'is_approved' => 1,
                    ),
                );

                if (empty($search_params['topic']) && empty($search_params['show_complete']))
                {
                    $main_query['select']['id_topic'] = 't.id_topic';
                    $main_query['select']['id_msg'] = 'MAX(m.id_msg) AS id_msg';
                    $main_query['select']['num_matches'] = 'COUNT(*) AS num_matches';

                    $main_query['weights'] = $weight_factors;

                    $main_query['group_by'][] = 't.id_topic';
                }
                else
                {
                    // This is outrageous!
                    $main_query['select']['id_topic'] = 'm.id_msg AS id_topic';
                    $main_query['select']['id_msg'] = 'm.id_msg';
                    $main_query['select']['num_matches'] = '1 AS num_matches';

                    $main_query['weights'] = array(
                        'age' => array(
                            'search' => '((m.id_msg - t.id_first_msg) / CASE WHEN t.id_last_msg = t.id_first_msg THEN 1 ELSE t.id_last_msg - t.id_first_msg END)',
                        ),
                        'first_message' => array(
                            'search' => 'CASE WHEN m.id_msg = t.id_first_msg THEN 1 ELSE 0 END',
                        ),
                    );

                    if (!empty($search_params['topic']))
                    {
                        $main_query['where'][] = 't.id_topic = {int:topic}';
                        $main_query['parameters']['topic'] = $search_params['topic'];
                    }
                    if (!empty($search_params['show_complete']))
                        $main_query['group_by'][] = 'm.id_msg, t.id_first_msg, t.id_last_msg';
                }

                // *** Get the subject results.
                $numSubjectResults = 0;
                if (empty($search_params['topic']))
                {
                    $inserts = array();
                    // Create a temporary table to store some preliminary results in.
                    $smcFunc['db_search_query']('drop_tmp_log_search_topics', '
                        DROP TABLE IF EXISTS {db_prefix}tmp_log_search_topics',
                        array(
                        )
                    );
                    $createTemporary = $smcFunc['db_search_query']('create_tmp_log_search_topics', '
                        CREATE TEMPORARY TABLE {db_prefix}tmp_log_search_topics (
                            id_topic int NOT NULL default {string:string_zero},
                            PRIMARY KEY (id_topic)
                        ) ENGINE=MEMORY',
                        array(
                            'string_zero' => '0',
                        )
                    ) !== false;

                    // Clean up some previous cache.
                    if (!$createTemporary)
                        $smcFunc['db_search_query']('delete_log_search_topics', '
                            DELETE FROM {db_prefix}log_search_topics
                            WHERE id_search = {int:search_id}',
                            array(
                                'search_id' => $_SESSION['search_cache']['id_search'],
                            )
                        );

                    foreach ($searchWords as $orIndex => $words)
                    {
                        $subject_query = array(
                            'from' => '{db_prefix}topics AS t',
                            'inner_join' => array(),
                            'left_join' => array(),
                            'where' => array(),
                            'params' => array(),
                        );

                        $numTables = 0;
                        $prev_join = 0;
                        $count = 0;
                        $excluded = false;
                        foreach ($words['subject_words'] as $subjectWord)
                        {
                            $numTables++;
                            if (in_array($subjectWord, $excludedSubjectWords))
                            {
                                if (($subject_query['from'] != '{db_prefix}messages AS m') && !$excluded)
                                {
                                    $subject_query['inner_join'][] = '{db_prefix}messages AS m ON (m.id_msg = t.id_first_msg)';
                                    $excluded = true;
                                }
                                $subject_query['left_join'][] = '{db_prefix}log_search_subjects AS subj' . $numTables . ' ON (subj' . $numTables . '.word ' . (empty($modSettings['search_match_words']) ? 'LIKE {string:subject_not_' . $count . '}' : '= {string:subject_not_' . $count . '}') . ' AND subj' . $numTables . '.id_topic = t.id_topic)';
                                $subject_query['params']['subject_not_' . $count] = empty($modSettings['search_match_words']) ? '%' . $subjectWord . '%' : $subjectWord;

                                $subject_query['where'][] = '(subj' . $numTables . '.word IS NULL)';
                                $subject_query['where'][] = 'm.body NOT ' . (empty($modSettings['search_match_words']) || $no_regexp ? ' LIKE ' : ' RLIKE ') . '{string:body_not_' . $count . '}';
                                $subject_query['params']['body_not_' . $count++] = empty($modSettings['search_match_words']) || $no_regexp ? '%' . strtr($subjectWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $subjectWord), '\\\'') . '[[:>:]]';
                            }
                            else
                            {
                                $subject_query['inner_join'][] = '{db_prefix}log_search_subjects AS subj' . $numTables . ' ON (subj' . $numTables . '.id_topic = ' . ($prev_join === 0 ? 't' : 'subj' . $prev_join) . '.id_topic)';
                                $subject_query['where'][] = 'subj' . $numTables . '.word LIKE {string:subject_like_' . $count . '}';
                                $subject_query['params']['subject_like_' . $count++] = empty($modSettings['search_match_words']) ? '%' . $subjectWord . '%' : $subjectWord;
                                $prev_join = $numTables;
                            }
                        }

                        if (!empty($userQuery))
                        {
                            if ($subject_query['from'] != '{db_prefix}messages AS m')
                            {
                                $subject_query['inner_join'][] = '{db_prefix}messages AS m ON (m.id_msg = t.id_first_msg)';
                            }
                            $subject_query['where'][] = '{raw:user_query}';
                            $subject_query['params']['user_query'] = $userQuery;
                        }
                        if (!empty($search_params['topic']))
                        {
                            $subject_query['where'][] = 't.id_topic = {int:topic}';
                            $subject_query['params']['topic'] = $search_params['topic'];
                        }
                        if (!empty($minMsgID))
                        {
                            $subject_query['where'][] = 't.id_first_msg >= {int:min_msg_id}';
                            $subject_query['params']['min_msg_id'] = $minMsgID;
                        }
                        if (!empty($maxMsgID))
                        {
                            $subject_query['where'][] = 't.id_last_msg <= {int:max_msg_id}';
                            $subject_query['params']['max_msg_id'] = $maxMsgID;
                        }
                        if (!empty($boardQuery))
                        {
                            $subject_query['where'][] = 't.id_board {raw:board_query}';
                            $subject_query['params']['board_query'] = $boardQuery;
                        }
                        if (!empty($excludedPhrases))
                        {
                            if ($subject_query['from'] != '{db_prefix}messages AS m')
                            {
                                $subject_query['inner_join'][] = '{db_prefix}messages AS m ON (m.id_msg = t.id_first_msg)';
                            }
                            $count = 0;
                            foreach ($excludedPhrases as $phrase)
                            {
                                $subject_query['where'][] = 'm.subject NOT ' . (empty($modSettings['search_match_words']) || $no_regexp ? ' LIKE ' : ' RLIKE ') . '{string:exclude_phrase_' . $count . '}';
                                $subject_query['where'][] = 'm.body NOT ' . (empty($modSettings['search_match_words']) || $no_regexp ? ' LIKE ' : ' RLIKE ') . '{string:exclude_phrase_' . $count . '}';
                                $subject_query['params']['exclude_phrase_' . $count++] = empty($modSettings['search_match_words']) || $no_regexp ? '%' . strtr($phrase, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $phrase), '\\\'') . '[[:>:]]';
                            }
                        }
                        call_integration_hook('integrate_subject_search_query', array(&$subject_query));

                        // Nothing to search for?
                        if (empty($subject_query['where']))
                            continue;

                        $ignoreRequest = $smcFunc['db_search_query']('insert_log_search_topics', ($smcFunc['db_support_ignore'] ? ('
                            INSERT IGNORE INTO {db_prefix}' . ($createTemporary ? 'tmp_' : '') . 'log_search_topics
                                (' . ($createTemporary ? '' : 'id_search, ') . 'id_topic)') : '') . '
                            SELECT ' . ($createTemporary ? '' : $_SESSION['search_cache']['id_search'] . ', ') . 't.id_topic
                            FROM ' . $subject_query['from'] . (empty($subject_query['inner_join']) ? '' : '
                                INNER JOIN ' . implode('
                                INNER JOIN ', $subject_query['inner_join'])) . (empty($subject_query['left_join']) ? '' : '
                                LEFT JOIN ' . implode('
                                LEFT JOIN ', $subject_query['left_join'])) . '
                            WHERE ' . implode('
                                AND ', $subject_query['where']) . (empty($modSettings['search_max_results']) ? '' : '
                            LIMIT ' . ($modSettings['search_max_results'] - $numSubjectResults)),
                            $subject_query['params']
                        );
                        // Don't do INSERT IGNORE? Manually fix this up!
                        if (!$smcFunc['db_support_ignore'])
                        {
                            while ($row = $smcFunc['db_fetch_row']($ignoreRequest))
                            {
                                $ind = $createTemporary ? 0 : 1;
                                // No duplicates!
                                if (isset($inserts[$row[$ind]]))
                                    continue;

                                $inserts[$row[$ind]] = $row;
                            }
                            $smcFunc['db_free_result']($ignoreRequest);
                            $numSubjectResults = count($inserts);
                        }
                        else
                            $numSubjectResults += $smcFunc['db_affected_rows']();

                        if (!empty($modSettings['search_max_results']) && $numSubjectResults >= $modSettings['search_max_results'])
                            break;
                    }

                    // Got some non-MySQL data to plonk in?
                    if (!empty($inserts))
                    {
                        $smcFunc['db_insert']('',
                            ('{db_prefix}' . ($createTemporary ? 'tmp_' : '') . 'log_search_topics'),
                            $createTemporary ? array('id_topic' => 'int') : array('id_search' => 'int', 'id_topic' => 'int'),
                            $inserts,
                            $createTemporary ? array('id_topic') : array('id_search', 'id_topic')
                        );
                    }

                    if ($numSubjectResults !== 0)
                    {
                        $main_query['weights']['subject']['search'] = 'CASE WHEN MAX(lst.id_topic) IS NULL THEN 0 ELSE 1 END';
                        $main_query['left_join'][] = '{db_prefix}' . ($createTemporary ? 'tmp_' : '') . 'log_search_topics AS lst ON (' . ($createTemporary ? '' : 'lst.id_search = {int:id_search} AND ') . 'lst.id_topic = t.id_topic)';
                        if (!$createTemporary)
                            $main_query['parameters']['id_search'] = $_SESSION['search_cache']['id_search'];
                    }
                }

                $indexedResults = 0;
                // We building an index?
                if ($searchAPI->supportsMethod('indexedWordQuery', $query_params))
                {
                    $inserts = array();
                    $smcFunc['db_search_query']('drop_tmp_log_search_messages', '
                        DROP TABLE IF EXISTS {db_prefix}tmp_log_search_messages',
                        array(
                        )
                    );

                    $createTemporary = $smcFunc['db_search_query']('create_tmp_log_search_messages', '
                        CREATE TEMPORARY TABLE {db_prefix}tmp_log_search_messages (
                            id_msg int NOT NULL default {string:string_zero},
                            PRIMARY KEY (id_msg)
                        ) ENGINE=MEMORY',
                        array(
                            'string_zero' => '0',
                        )
                    ) !== false;

                    // Clear, all clear!
                    if (!$createTemporary)
                        $smcFunc['db_search_query']('delete_log_search_messages', '
                            DELETE FROM {db_prefix}log_search_messages
                            WHERE id_search = {int:id_search}',
                            array(
                                'id_search' => $_SESSION['search_cache']['id_search'],
                            )
                        );

                    foreach ($searchWords as $orIndex => $words)
                    {
                        // Search for this word, assuming we have some words!
                        if (!empty($words['indexed_words']))
                        {
                            // Variables required for the search.
                            $search_data = array(
                                'insert_into' => ($createTemporary ? 'tmp_' : '') . 'log_search_messages',
                                'no_regexp' => $no_regexp,
                                'max_results' => $maxMessageResults,
                                'indexed_results' => $indexedResults,
                                'params' => array(
                                    'id_search' => !$createTemporary ? $_SESSION['search_cache']['id_search'] : 0,
                                    'excluded_words' => $excludedWords,
                                    'user_query' => !empty($userQuery) ? $userQuery : '',
                                    'board_query' => !empty($boardQuery) ? $boardQuery : '',
                                    'topic' => !empty($search_params['topic']) ? $search_params['topic'] : 0,
                                    'min_msg_id' => !empty($minMsgID) ? $minMsgID : 0,
                                    'max_msg_id' => !empty($maxMsgID) ? $maxMsgID : 0,
                                    'excluded_phrases' => !empty($excludedPhrases) ? $excludedPhrases : array(),
                                    'excluded_index_words' => !empty($excludedIndexWords) ? $excludedIndexWords : array(),
                                    'excluded_subject_words' => !empty($excludedSubjectWords) ? $excludedSubjectWords : array(),
                                ),
                            );

                            $ignoreRequest = $searchAPI->indexedWordQuery($words, $search_data);

                            if (!$smcFunc['db_support_ignore'])
                            {
                                while ($row = $smcFunc['db_fetch_row']($ignoreRequest))
                                {
                                    // No duplicates!
                                    if (isset($inserts[$row[0]]))
                                        continue;

                                    $inserts[$row[0]] = $row;
                                }
                                $smcFunc['db_free_result']($ignoreRequest);
                                $indexedResults = count($inserts);
                            }
                            else
                                $indexedResults += $smcFunc['db_affected_rows']();

                            if (!empty($maxMessageResults) && $indexedResults >= $maxMessageResults)
                                break;
                        }
                    }

                    // More non-MySQL stuff needed?
                    if (!empty($inserts))
                    {
                        $smcFunc['db_insert']('',
                            '{db_prefix}' . ($createTemporary ? 'tmp_' : '') . 'log_search_messages',
                            $createTemporary ? array('id_msg' => 'int') : array('id_msg' => 'int', 'id_search' => 'int'),
                            $inserts,
                            $createTemporary ? array('id_msg') : array('id_msg', 'id_search')
                        );
                    }

                    if (empty($indexedResults) && empty($numSubjectResults) && !empty($modSettings['search_force_index']))
                    {
                        $context['search_errors']['query_not_specific_enough'] = true;
                        $_REQUEST['params'] = $context['params'];
                        return PlushSearch1();
                    }
                    elseif (!empty($indexedResults))
                    {
                        $main_query['inner_join'][] = '{db_prefix}' . ($createTemporary ? 'tmp_' : '') . 'log_search_messages AS lsm ON (lsm.id_msg = m.id_msg)';
                        if (!$createTemporary)
                        {
                            $main_query['where'][] = 'lsm.id_search = {int:id_search}';
                            $main_query['parameters']['id_search'] = $_SESSION['search_cache']['id_search'];
                        }
                    }
                }

                // Not using an index? All conditions have to be carried over.
                else
                {
                    $orWhere = array();
                    $count = 0;
                    foreach ($searchWords as $orIndex => $words)
                    {
                        $where = array();
                        foreach ($words['all_words'] as $regularWord)
                        {
                            $where[] = 'm.body' . (in_array($regularWord, $excludedWords) ? ' NOT' : '') . (empty($modSettings['search_match_words']) || $no_regexp ? ' LIKE ' : ' RLIKE ') . '{string:all_word_body_' . $count . '}';
                            if (in_array($regularWord, $excludedWords))
                                $where[] = 'm.subject NOT' . (empty($modSettings['search_match_words']) || $no_regexp ? ' LIKE ' : ' RLIKE ') . '{string:all_word_body_' . $count . '}';
                            $main_query['parameters']['all_word_body_' . $count++] = empty($modSettings['search_match_words']) || $no_regexp ? '%' . strtr($regularWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $regularWord), '\\\'') . '[[:>:]]';
                        }
                        if (!empty($where))
                            $orWhere[] = count($where) > 1 ? '(' . implode(' AND ', $where) . ')' : $where[0];
                    }
                    if (!empty($orWhere))
                        $main_query['where'][] = count($orWhere) > 1 ? '(' . implode(' OR ', $orWhere) . ')' : $orWhere[0];

                    if (!empty($userQuery))
                    {
                        $main_query['where'][] = '{raw:user_query}';
                        $main_query['parameters']['user_query'] = $userQuery;
                    }
                    if (!empty($search_params['topic']))
                    {
                        $main_query['where'][] = 'm.id_topic = {int:topic}';
                        $main_query['parameters']['topic'] = $search_params['topic'];
                    }
                    if (!empty($minMsgID))
                    {
                        $main_query['where'][] = 'm.id_msg >= {int:min_msg_id}';
                        $main_query['parameters']['min_msg_id'] = $minMsgID;
                    }
                    if (!empty($maxMsgID))
                    {
                        $main_query['where'][] = 'm.id_msg <= {int:max_msg_id}';
                        $main_query['parameters']['max_msg_id'] = $maxMsgID;
                    }
                    if (!empty($boardQuery))
                    {
                        $main_query['where'][] = 'm.id_board {raw:board_query}';
                        $main_query['parameters']['board_query'] = $boardQuery;
                    }
                }
                call_integration_hook('integrate_main_search_query', array(&$main_query));

                // Did we either get some indexed results, or otherwise did not do an indexed query?
                if (!empty($indexedResults) || !$searchAPI->supportsMethod('indexedWordQuery', $query_params))
                {
                    $relevance = '1000 * (';
                    $new_weight_total = 0;
                    foreach ($main_query['weights'] as $type => $value)
                    {
                        $relevance .= $weight[$type];
                        if (!empty($value['search']))
                            $relevance .= ' * ' . $value['search'];
                        $relevance .= ' + ';
                        $new_weight_total += $weight[$type];
                    }
                    $main_query['select']['relevance'] = substr($relevance, 0, -3) . ') / ' . $new_weight_total . ' AS relevance';

                    $ignoreRequest = $smcFunc['db_search_query']('insert_log_search_results_no_index', ($smcFunc['db_support_ignore'] ? ('
                        INSERT IGNORE INTO ' . '{db_prefix}log_search_results
                            (' . implode(', ', array_keys($main_query['select'])) . ')') : '') . '
                        SELECT
                            ' . implode(',
                            ', $main_query['select']) . '
                        FROM ' . $main_query['from'] . (empty($main_query['inner_join']) ? '' : '
                            INNER JOIN ' . implode('
                            INNER JOIN ', $main_query['inner_join'])) . (empty($main_query['left_join']) ? '' : '
                            LEFT JOIN ' . implode('
                            LEFT JOIN ', $main_query['left_join'])) . (!empty($main_query['where']) ? '
                        WHERE ' : '') . implode('
                            AND ', $main_query['where']) . (empty($main_query['group_by']) ? '' : '
                        GROUP BY ' . implode(', ', $main_query['group_by'])) . (empty($modSettings['search_max_results']) ? '' : '
                        LIMIT ' . $modSettings['search_max_results']),
                        $main_query['parameters']
                    );

                    // We love to handle non-good databases that don't support our ignore!
                    if (!$smcFunc['db_support_ignore'])
                    {
                        $inserts = array();
                        while ($row = $smcFunc['db_fetch_row']($ignoreRequest))
                        {
                            // No duplicates!
                            if (isset($inserts[$row[2]]))
                                continue;

                            foreach ($row as $key => $value)
                                $inserts[$row[2]][] = (int) $row[$key];
                        }
                        $smcFunc['db_free_result']($ignoreRequest);

                        // Now put them in!
                        if (!empty($inserts))
                        {
                            $query_columns = array();
                            foreach ($main_query['select'] as $k => $v)
                                $query_columns[$k] = 'int';

                            $smcFunc['db_insert']('',
                                '{db_prefix}log_search_results',
                                $query_columns,
                                $inserts,
                                array('id_search', 'id_topic')
                            );
                        }
                        $_SESSION['search_cache']['num_results'] += count($inserts);
                    }
                    else
                        $_SESSION['search_cache']['num_results'] = $smcFunc['db_affected_rows']();
                }

                // Insert subject-only matches.
                if ($_SESSION['search_cache']['num_results'] < $modSettings['search_max_results'] && $numSubjectResults !== 0)
                {
                    $relevance = '1000 * (';
                    foreach ($weight_factors as $type => $value)
                        if (isset($value['results']))
                        {
                            $relevance .= $weight[$type];
                            if (!empty($value['results']))
                                $relevance .= ' * ' . $value['results'];
                            $relevance .= ' + ';
                        }
                    $relevance = substr($relevance, 0, -3) . ') / ' . $weight_total . ' AS relevance';

                    $usedIDs = array_flip(empty($inserts) ? array() : array_keys($inserts));
                    $ignoreRequest = $smcFunc['db_search_query']('insert_log_search_results_sub_only', ($smcFunc['db_support_ignore'] ? ('
                        INSERT IGNORE INTO {db_prefix}log_search_results
                            (id_search, id_topic, relevance, id_msg, num_matches)') : '') . '
                        SELECT
                            {int:id_search},
                            t.id_topic,
                            ' . $relevance . ',
                            t.id_first_msg,
                            1
                        FROM {db_prefix}topics AS t
                            INNER JOIN {db_prefix}' . ($createTemporary ? 'tmp_' : '') . 'log_search_topics AS lst ON (lst.id_topic = t.id_topic)'
                        . ($createTemporary ? '' : ' WHERE lst.id_search = {int:id_search}')
                        . (empty($modSettings['search_max_results']) ? '' : '
                        LIMIT ' . ($modSettings['search_max_results'] - $_SESSION['search_cache']['num_results'])),
                        array(
                            'id_search' => $_SESSION['search_cache']['id_search'],
                            'min_msg' => $minMsg,
                            'recent_message' => $recentMsg,
                            'huge_topic_posts' => $humungousTopicPosts,
                        )
                    );
                    // Once again need to do the inserts if the database don't support ignore!
                    if (!$smcFunc['db_support_ignore'])
                    {
                        $inserts = array();
                        while ($row = $smcFunc['db_fetch_row']($ignoreRequest))
                        {
                            // No duplicates!
                            if (isset($usedIDs[$row[1]]))
                                continue;

                            $usedIDs[$row[1]] = true;
                            $inserts[] = $row;
                        }
                        $smcFunc['db_free_result']($ignoreRequest);

                        // Now put them in!
                        if (!empty($inserts))
                        {
                            $smcFunc['db_insert']('',
                                '{db_prefix}log_search_results',
                                array('id_search' => 'int', 'id_topic' => 'int', 'relevance' => 'float', 'id_msg' => 'int', 'num_matches' => 'int'),
                                $inserts,
                                array('id_search', 'id_topic')
                            );
                        }
                        $_SESSION['search_cache']['num_results'] += count($inserts);
                    }
                    else
                        $_SESSION['search_cache']['num_results'] += $smcFunc['db_affected_rows']();
                }
                elseif ($_SESSION['search_cache']['num_results'] == -1)
                    $_SESSION['search_cache']['num_results'] = 0;
            }
        }

        if (!empty($modSettings['postmod_active']))
        {
            $approve_boards = boardsAllowedTo('approve_posts');

            // Can approve everywhere, so search all topics.
            if ($approve_boards === array(0))
                $approve_query = '';

            // Can't approve anywhere, so search ony their own topics and approved topics.
            elseif (empty($approve_boards))
                $approve_query = '
                AND (t.approved = {int:is_approved} OR t.id_member_started = {int:current_member})';

            // Can approve in some boards, so search own, approved, and approvable topics.
            else
                $approve_query = '
                AND (t.approved = {int:is_approved} OR t.id_member_started = {int:current_member} OR t.id_board IN ({array_int:approve_boards}))';
        }

        // *** Retrieve the results to be shown on the page
        $participants = array();
        $request = $smcFunc['db_search_query']('', '
            SELECT ' . (empty($search_params['topic']) ? 'lsr.id_topic' : $search_params['topic'] . ' AS id_topic') . ', lsr.id_msg, lsr.relevance, lsr.num_matches
            FROM {db_prefix}log_search_results AS lsr' . ($search_params['sort'] == 'num_replies' || !empty($approve_query) ? '
                INNER JOIN {db_prefix}topics AS t ON (t.id_topic = lsr.id_topic)' : '') . '
            WHERE lsr.id_search = {int:id_search}' . $approve_query . '
            ORDER BY {raw:sort} {raw:sort_dir}
            LIMIT {int:start}, {int:max}',
            array(
                'id_search' => $_SESSION['search_cache']['id_search'],
                'sort' => $search_params['sort'],
                'sort_dir' => $search_params['sort_dir'],
                'start' => $_REQUEST['start'],
                'max' => $modSettings['search_results_per_page'],
                'is_approved' => 1,
                'current_member' => $user_info['id'],
                'approve_boards' => !empty($approve_boards) ? $approve_boards : array(0),
            )
        );
        while ($row = $smcFunc['db_fetch_assoc']($request))
        {
            $context['topics'][$row['id_msg']] = array(
                'relevance' => round($row['relevance'] / 10, 1) . '%',
                'num_matches' => $row['num_matches'],
                'matches' => array(),
            );
            // By default they didn't participate in the topic!
            $participants[$row['id_topic']] = false;
        }
        $smcFunc['db_free_result']($request);
    }

    $num_results = 0;
    if (!empty($context['topics']))
    {
        // Create an array for the permissions.
        $perms = array('post_reply_own', 'post_reply_any');

        if (!empty($options['display_quick_mod']))
            $perms = array_merge($perms, array('lock_any', 'lock_own', 'make_sticky', 'move_any', 'move_own', 'remove_any', 'remove_own', 'merge_any'));

        if (!empty($modSettings['postmod_active']) && !isset($approve_boards))
            $perms[] = 'approve_posts';

        $boards_can = boardsAllowedTo($perms, true, false);

        // How's about some quick moderation?
        if (!empty($options['display_quick_mod']))
        {
            $context['can_lock'] = in_array(0, $boards_can['lock_any']);
            $context['can_sticky'] = in_array(0, $boards_can['make_sticky']);
            $context['can_move'] = in_array(0, $boards_can['move_any']);
            $context['can_remove'] = in_array(0, $boards_can['remove_any']);
            $context['can_merge'] = in_array(0, $boards_can['merge_any']);
        }

        if (!empty($modSettings['postmod_active']))
        {
            if (!isset($approve_boards))
                $approve_boards = $boards_can['approve_posts'];

            if ($approve_boards === array(0))
                $approve_query = '';

            elseif (empty($approve_boards))
                $approve_query = '
                AND (m.approved = {int:is_approved} OR m.id_member = {int:current_member})';

            else
                $approve_query = '
                AND (m.approved = {int:is_approved} OR m.id_member = {int:current_member} OR m.id_board IN ({array_int:approve_boards}))';
        }

        // What messages are we using?
        $msg_list = array_keys($context['topics']);

        // Load the posters...
        $request = $smcFunc['db_query']('', '
            SELECT id_member
            FROM {db_prefix}messages
            WHERE id_member != {int:no_member}
                AND id_msg IN ({array_int:message_list})
            LIMIT {int:limit}',
            array(
                'message_list' => $msg_list,
                'no_member' => 0,
                'limit' => count($context['topics']),
            )
        );
        $posters = array();
        while ($row = $smcFunc['db_fetch_assoc']($request))
            $posters[] = $row['id_member'];
        $smcFunc['db_free_result']($request);

        call_integration_hook('integrate_search_message_list', array(&$msg_list, &$posters));

        if (!empty($posters))
            loadMemberData(array_unique($posters));

        // Get the messages out for the callback - select enough that it can be made to look just like Display.
        $messages_request = $smcFunc['db_query']('', '
            SELECT
                m.id_msg, m.subject, m.poster_name, m.poster_email, m.poster_time, m.id_member,
                m.icon, m.poster_ip, m.body, m.smileys_enabled, m.modified_time, m.modified_name,
                first_m.id_msg AS first_msg, first_m.subject AS first_subject, first_m.icon AS first_icon, first_m.poster_time AS first_poster_time,
                first_mem.id_member AS first_member_id, COALESCE(first_mem.real_name, first_m.poster_name) AS first_member_name,
                last_m.id_msg AS last_msg, last_m.poster_time AS last_poster_time, last_mem.id_member AS last_member_id,
                COALESCE(last_mem.real_name, last_m.poster_name) AS last_member_name, last_m.icon AS last_icon, last_m.subject AS last_subject,
                t.id_topic, t.is_sticky, t.locked, t.id_poll, t.num_replies, t.num_views,
                b.id_board, b.name AS board_name, c.id_cat, c.name AS cat_name
            FROM {db_prefix}messages AS m
                INNER JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic)
                INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board)
                INNER JOIN {db_prefix}categories AS c ON (c.id_cat = b.id_cat)
                INNER JOIN {db_prefix}messages AS first_m ON (first_m.id_msg = t.id_first_msg)
                INNER JOIN {db_prefix}messages AS last_m ON (last_m.id_msg = t.id_last_msg)
                LEFT JOIN {db_prefix}members AS first_mem ON (first_mem.id_member = first_m.id_member)
                LEFT JOIN {db_prefix}members AS last_mem ON (last_mem.id_member = first_m.id_member)
            WHERE m.id_msg IN ({array_int:message_list})' . $approve_query . '
            ORDER BY ' . $smcFunc['db_custom_order']('m.id_msg', $msg_list) . '
            LIMIT {int:limit}',
            array(
                'message_list' => $msg_list,
                'is_approved' => 1,
                'current_member' => $user_info['id'],
                'approve_boards' => !empty($approve_boards) ? $approve_boards : array(0),
                'limit' => count($context['topics']),
            )
        );

        // How many results will the user be able to see?
        $num_results = $smcFunc['db_num_rows']($messages_request);

        // If there are no results that means the things in the cache got deleted, so pretend we have no topics anymore.
        if ($num_results == 0)
            $context['topics'] = array();

        // If we want to know who participated in what then load this now.
        if (!empty($modSettings['enableParticipation']) && !$user_info['is_guest'])
        {
            $result = $smcFunc['db_query']('', '
                SELECT id_topic
                FROM {db_prefix}messages
                WHERE id_topic IN ({array_int:topic_list})
                    AND id_member = {int:current_member}
                GROUP BY id_topic
                LIMIT {int:limit}',
                array(
                    'current_member' => $user_info['id'],
                    'topic_list' => array_keys($participants),
                    'limit' => count($participants),
                )
            );
            while ($row = $smcFunc['db_fetch_assoc']($result))
                $participants[$row['id_topic']] = true;

            $smcFunc['db_free_result']($result);
        }
    }

    // Now that we know how many results to expect we can start calculating the page numbers.
    $context['page_index'] = constructPageIndex($scripturl . '?action=search2;params=' . $context['params'], $_REQUEST['start'], $num_results, $modSettings['search_results_per_page'], false);

    // Consider the search complete!
    if (!empty($cache_enable) && $cache_enable >= 2)
        cache_put_data('search_start:' . ($user_info['is_guest'] ? $user_info['ip'] : $user_info['id']), null, 90);

    $context['key_words'] = &$searchArray;

    // Setup the default topic icons... for checking they exist and the like!
    $context['icon_sources'] = array();
    foreach ($context['stable_icons'] as $icon)
        $context['icon_sources'][$icon] = 'images_url';

    $context['sub_template'] = 'results';
    $context['page_title'] = $txt['search_results'];
    $context['get_topics'] = 'prepareSearchContext';
    $context['can_restore_perm'] = allowedTo('move_any') && !empty($modSettings['recycle_enable']);
    $context['can_restore'] = false; // We won't know until we handle the context later whether we can actually restore...

    $context['jump_to'] = array(
        'label' => addslashes(un_htmlspecialchars($txt['jump_to'])),
        'board_name' => addslashes(un_htmlspecialchars($txt['select_destination'])),
    );
}

/**
 * Callback to return messages - saves memory.
 *
 * What it does:
 * - callback function for the results sub template.
 * - loads the necessary contextual data to show a search result.
 *
 * @param bool $reset Whether to reset the counter
 * @return array An array of contextual info related to this search
 */
function prepareSearchContext($reset = false)
{
    global $txt, $modSettings, $scripturl, $user_info;
    global $memberContext, $context, $settings, $options, $messages_request;
    global $boards_can, $participants, $smcFunc;
    static $recycle_board = null;

    if ($recycle_board === null)
        $recycle_board = !empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) ? (int) $modSettings['recycle_board'] : 0;

    // Remember which message this is.  (ie. reply #83)
    static $counter = null;
    if ($counter == null || $reset)
        $counter = $_REQUEST['start'] + 1;

    // If the query returned false, bail.
    if ($messages_request == false)
        return false;

    // Start from the beginning...
    if ($reset)
        return @$smcFunc['db_data_seek']($messages_request, 0);

    // Attempt to get the next message.
    $message = $smcFunc['db_fetch_assoc']($messages_request);
    if (!$message)
        return false;

    // Can't have an empty subject can we?
    $message['subject'] = $message['subject'] != '' ? $message['subject'] : $txt['no_subject'];

    $message['first_subject'] = $message['first_subject'] != '' ? $message['first_subject'] : $txt['no_subject'];
    $message['last_subject'] = $message['last_subject'] != '' ? $message['last_subject'] : $txt['no_subject'];

    // If it couldn't load, or the user was a guest.... someday may be done with a guest table.
    if (!loadMemberContext($message['id_member']))
    {
        // Notice this information isn't used anywhere else.... *cough guest table cough*.
        $memberContext[$message['id_member']]['name'] = $message['poster_name'];
        $memberContext[$message['id_member']]['id'] = 0;
        $memberContext[$message['id_member']]['group'] = $txt['guest_title'];
        $memberContext[$message['id_member']]['link'] = $message['poster_name'];
        $memberContext[$message['id_member']]['email'] = $message['poster_email'];
    }
    $memberContext[$message['id_member']]['ip'] = inet_dtop($message['poster_ip']);

    // Do the censor thang...
    censorText($message['body']);
    censorText($message['subject']);

    censorText($message['first_subject']);
    censorText($message['last_subject']);

    // Shorten this message if necessary.
    if ($context['compact'])
    {
        // Set the number of characters before and after the searched keyword.
        $charLimit = 50;

        $message['body'] = strtr($message['body'], array("\n" => ' ', '<br>' => "\n"));
        $message['body'] = parse_bbc($message['body'], $message['smileys_enabled'], $message['id_msg']);
        $message['body'] = strip_tags(strtr($message['body'], array('</div>' => '<br>', '</li>' => '<br>')), '<br>');

        if ($smcFunc['strlen']($message['body']) > $charLimit)
        {
            if (empty($context['key_words']))
                $message['body'] = $smcFunc['substr']($message['body'], 0, $charLimit) . '<strong>...</strong>';
            else
            {
                $matchString = '';
                $force_partial_word = false;
                foreach ($context['key_words'] as $keyword)
                {
                    $keyword = un_htmlspecialchars($keyword);
                    $keyword = preg_replace_callback('~(&amp;#(\d{1,7}|x[0-9a-fA-F]{1,6});)~', 'entity_fix__callback', strtr($keyword, array('\\\'' => '\'', '&' => '&amp;')));

                    if (preg_match('~[\'\.,/@%&;:(){}\[\]_\-+\\\\]$~', $keyword) != 0 || preg_match('~^[\'\.,/@%&;:(){}\[\]_\-+\\\\]~', $keyword) != 0)
                        $force_partial_word = true;
                    $matchString .= strtr(preg_quote($keyword, '/'), array('\*' => '.+?')) . '|';
                }
                $matchString = un_htmlspecialchars(substr($matchString, 0, -1));

                $message['body'] = un_htmlspecialchars(strtr($message['body'], array('&nbsp;' => ' ', '<br>' => "\n", '&#91;' => '[', '&#93;' => ']', '&#58;' => ':', '&#64;' => '@')));

                if (empty($modSettings['search_method']) || $force_partial_word)
                    preg_match_all('/([^\s\W]{' . $charLimit . '}[\s\W]|[\s\W].{0,' . $charLimit . '}?|^)(' . $matchString . ')(.{0,' . $charLimit . '}[\s\W]|[^\s\W]{0,' . $charLimit . '})/is' . ($context['utf8'] ? 'u' : ''), $message['body'], $matches);
                else
                    preg_match_all('/([^\s\W]{' . $charLimit . '}[\s\W]|[\s\W].{0,' . $charLimit . '}?[\s\W]|^)(' . $matchString . ')([\s\W].{0,' . $charLimit . '}[\s\W]|[\s\W][^\s\W]{0,' . $charLimit . '})/is' . ($context['utf8'] ? 'u' : ''), $message['body'], $matches);

                $message['body'] = '';
                foreach ($matches[0] as $index => $match)
                {
                    $match = strtr($smcFunc['htmlspecialchars']($match, ENT_QUOTES), array("\n" => '&nbsp;'));
                    $message['body'] .= '<strong>......</strong>&nbsp;' . $match . '&nbsp;<strong>......</strong>';
                }
            }

            // Re-fix the international characters.
            $message['body'] = preg_replace_callback('~(&amp;#(\d{1,7}|x[0-9a-fA-F]{1,6});)~', 'entity_fix__callback', $message['body']);
        }
        $message['subject_highlighted'] = highlight($message['subject'], $context['key_words']);
        $message['body_highlighted'] = highlight($message['body'], $context['key_words']);
    }
    else
    {
        $message['subject_highlighted'] = highlight($message['subject'], $context['key_words']);
        $message['body_highlighted'] = highlight($message['body'], $context['key_words']);

        // Run BBC interpreter on the message.
        $message['body'] = parse_bbc($message['body'], $message['smileys_enabled'], $message['id_msg']);
    }

    // Make sure we don't end up with a practically empty message body.
    $message['body'] = preg_replace('~^(?:&nbsp;)+$~', '', $message['body']);

    if (!empty($recycle_board) && $message['id_board'] == $recycle_board)
    {
        $message['first_icon'] = 'recycled';
        $message['last_icon'] = 'recycled';
        $message['icon'] = 'recycled';
    }

    // Sadly, we need to check the icon ain't broke.
    if (!empty($modSettings['messageIconChecks_enable']))
    {
        if (!isset($context['icon_sources'][$message['first_icon']]))
            $context['icon_sources'][$message['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['first_icon'] . '.png') ? 'images_url' : 'default_images_url';
        if (!isset($context['icon_sources'][$message['last_icon']]))
            $context['icon_sources'][$message['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['last_icon'] . '.png') ? 'images_url' : 'default_images_url';
        if (!isset($context['icon_sources'][$message['icon']]))
            $context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url';
    }
    else
    {
        if (!isset($context['icon_sources'][$message['first_icon']]))
            $context['icon_sources'][$message['first_icon']] = 'images_url';
        if (!isset($context['icon_sources'][$message['last_icon']]))
            $context['icon_sources'][$message['last_icon']] = 'images_url';
        if (!isset($context['icon_sources'][$message['icon']]))
            $context['icon_sources'][$message['icon']] = 'images_url';
    }

    // Do we have quote tag enabled?
    $quote_enabled = empty($modSettings['disabledBBC']) || !in_array('quote', explode(',', $modSettings['disabledBBC']));

    // Reference the main color class.
    $colorClass = 'windowbg';

    // Sticky topics should get a different color, too.
    if ($message['is_sticky'])
        $colorClass .= ' sticky';

    // Locked topics get special treatment as well.
    if ($message['locked'])
        $colorClass .= ' locked';

    $output = array_merge($context['topics'][$message['id_msg']], array(
        'id' => $message['id_topic'],
        'is_sticky' => !empty($message['is_sticky']),
        'is_locked' => !empty($message['locked']),
        'css_class' => $colorClass,
        'is_poll' => $modSettings['pollMode'] == '1' && $message['id_poll'] > 0,
        'posted_in' => !empty($participants[$message['id_topic']]),
        'views' => $message['num_views'],
        'replies' => $message['num_replies'],
        'can_reply' => in_array($message['id_board'], $boards_can['post_reply_any']) || in_array(0, $boards_can['post_reply_any']),
        'can_quote' => (in_array($message['id_board'], $boards_can['post_reply_any']) || in_array(0, $boards_can['post_reply_any'])) && $quote_enabled,
        'first_post' => array(
            'id' => $message['first_msg'],
            'time' => timeformat($message['first_poster_time']),
            'timestamp' => forum_time(true, $message['first_poster_time']),
            'subject' => $message['first_subject'],
            'href' => $scripturl . '?topic=' . $message['id_topic'] . '.0',
            'link' => '<a href="' . $scripturl . '?topic=' . $message['id_topic'] . '.0">' . $message['first_subject'] . '</a>',
            'icon' => $message['first_icon'],
            'icon_url' => $settings[$context['icon_sources'][$message['first_icon']]] . '/post/' . $message['first_icon'] . '.png',
            'member' => array(
                'id' => $message['first_member_id'],
                'name' => $message['first_member_name'],
                'href' => !empty($message['first_member_id']) ? $scripturl . '?action=profile;u=' . $message['first_member_id'] : '',
                'link' => !empty($message['first_member_id']) ? '<a href="' . $scripturl . '?action=profile;u=' . $message['first_member_id'] . '" title="' . $txt['profile_of'] . ' ' . $message['first_member_name'] . '">' . $message['first_member_name'] . '</a>' : $message['first_member_name']
            )
        ),
        'last_post' => array(
            'id' => $message['last_msg'],
            'time' => timeformat($message['last_poster_time']),
            'timestamp' => forum_time(true, $message['last_poster_time']),
            'subject' => $message['last_subject'],
            'href' => $scripturl . '?topic=' . $message['id_topic'] . ($message['num_replies'] == 0 ? '.0' : '.msg' . $message['last_msg']) . '#msg' . $message['last_msg'],
            'link' => '<a href="' . $scripturl . '?topic=' . $message['id_topic'] . ($message['num_replies'] == 0 ? '.0' : '.msg' . $message['last_msg']) . '#msg' . $message['last_msg'] . '">' . $message['last_subject'] . '</a>',
            'icon' => $message['last_icon'],
            'icon_url' => $settings[$context['icon_sources'][$message['last_icon']]] . '/post/' . $message['last_icon'] . '.png',
            'member' => array(
                'id' => $message['last_member_id'],
                'name' => $message['last_member_name'],
                'href' => !empty($message['last_member_id']) ? $scripturl . '?action=profile;u=' . $message['last_member_id'] : '',
                'link' => !empty($message['last_member_id']) ? '<a href="' . $scripturl . '?action=profile;u=' . $message['last_member_id'] . '" title="' . $txt['profile_of'] . ' ' . $message['last_member_name'] . '">' . $message['last_member_name'] . '</a>' : $message['last_member_name']
            )
        ),
        'board' => array(
            'id' => $message['id_board'],
            'name' => $message['board_name'],
            'href' => $scripturl . '?board=' . $message['id_board'] . '.0',
            'link' => '<a href="' . $scripturl . '?board=' . $message['id_board'] . '.0">' . $message['board_name'] . '</a>'
        ),
        'category' => array(
            'id' => $message['id_cat'],
            'name' => $message['cat_name'],
            'href' => $scripturl . '#c' . $message['id_cat'],
            'link' => '<a href="' . $scripturl . '#c' . $message['id_cat'] . '">' . $message['cat_name'] . '</a>'
        )
    ));

    if (!empty($options['display_quick_mod']))
    {
        $started = $output['first_post']['member']['id'] == $user_info['id'];

        $output['quick_mod'] = array(
            'lock' => in_array(0, $boards_can['lock_any']) || in_array($output['board']['id'], $boards_can['lock_any']) || ($started && (in_array(0, $boards_can['lock_own']) || in_array($output['board']['id'], $boards_can['lock_own']))),
            'sticky' => (in_array(0, $boards_can['make_sticky']) || in_array($output['board']['id'], $boards_can['make_sticky'])),
            'move' => in_array(0, $boards_can['move_any']) || in_array($output['board']['id'], $boards_can['move_any']) || ($started && (in_array(0, $boards_can['move_own']) || in_array($output['board']['id'], $boards_can['move_own']))),
            'remove' => in_array(0, $boards_can['remove_any']) || in_array($output['board']['id'], $boards_can['remove_any']) || ($started && (in_array(0, $boards_can['remove_own']) || in_array($output['board']['id'], $boards_can['remove_own']))),
            'restore' => $context['can_restore_perm'] && ($modSettings['recycle_board'] == $output['board']['id']),
        );

        $context['can_lock'] |= $output['quick_mod']['lock'];
        $context['can_sticky'] |= $output['quick_mod']['sticky'];
        $context['can_move'] |= $output['quick_mod']['move'];
        $context['can_remove'] |= $output['quick_mod']['remove'];
        $context['can_merge'] |= in_array($output['board']['id'], $boards_can['merge_any']);
        $context['can_restore'] |= $output['quick_mod']['restore'];
        $context['can_markread'] = $context['user']['is_logged'];

        $context['qmod_actions'] = array('remove', 'lock', 'sticky', 'move', 'merge', 'restore', 'markread');
        call_integration_hook('integrate_quick_mod_actions_search');
    }

    $output['matches'][] = array(
        'id' => $message['id_msg'],
        'attachment' => array(),
        'member' => &$memberContext[$message['id_member']],
        'icon' => $message['icon'],
        'icon_url' => $settings[$context['icon_sources'][$message['icon']]] . '/post/' . $message['icon'] . '.png',
        'subject' => $message['subject'],
        'subject_highlighted' => $message['subject_highlighted'],
        'time' => timeformat($message['poster_time']),
        'timestamp' => forum_time(true, $message['poster_time']),
        'counter' => $counter,
        'modified' => array(
            'time' => timeformat($message['modified_time']),
            'timestamp' => forum_time(true, $message['modified_time']),
            'name' => $message['modified_name']
        ),
        'body' => $message['body'],
        'body_highlighted' => $message['body_highlighted'],
        'start' => 'msg' . $message['id_msg']
    );
    $counter++;

    call_integration_hook('integrate_search_message_context', array(&$output, &$message, $counter));

    return $output;
}

/**
 * Creates a search API and returns the object.
 *
 * @return search_api_interface An instance of the search API interface
 */
function findSearchAPI()
{
    global $sourcedir, $modSettings, $searchAPI, $txt;

    require_once($sourcedir . '/Subs-Package.php');
    require_once($sourcedir . '/Class-SearchAPI.php');

    // Search has a special database set.
    db_extend('search');

    // Load up the search API we are going to use.
    $modSettings['search_index'] = empty($modSettings['search_index']) ? 'standard' : $modSettings['search_index'];
    if (!file_exists($sourcedir . '/SearchAPI-' . ucwords($modSettings['search_index']) . '.php'))
        fatal_lang_error('search_api_missing');
    require_once($sourcedir . '/SearchAPI-' . ucwords($modSettings['search_index']) . '.php');

    // Create an instance of the search API and check it is valid for this version of SMF.
    $search_class_name = $modSettings['search_index'] . '_search';
    $searchAPI = new $search_class_name();

    // An invalid Search API.
    if (!$searchAPI || !($searchAPI instanceof search_api_interface) || ($searchAPI->supportsMethod('isValid') && !$searchAPI->isValid()) || !matchPackageVersion(SMF_VERSION, $searchAPI->min_smf_version . '-' . $searchAPI->version_compatible))
    {
        // Log the error.
        loadLanguage('Errors');
        log_error(sprintf($txt['search_api_not_compatible'], 'SearchAPI-' . ucwords($modSettings['search_index']) . '.php'), 'critical');

        require_once($sourcedir . '/SearchAPI-Standard.php');
        $searchAPI = new standard_search();
    }

    return $searchAPI;
}

/**
 * This function compares the length of two strings plus a little.
 * What it does:
 * - callback function for usort used to sort the fulltext results.
 * - passes sorting duty to the current API.
 *
 * @param string $a
 * @param string $b
 * @return int
 */
function searchSort($a, $b)
{
    global $searchAPI;

    return $searchAPI->searchSort($a, $b);
}

/**
 * Highlighting matching string
 *
 * @param string $text Text to search through
 * @param array $words List of keywords to search
 *
 * @return string Text with highlighted keywords
 */
function highlight($text, array $words)
{
    $words = implode('|', array_map('preg_quote', $words));
    $highlighted = preg_filter('/' . $words . '/i', '<span class="highlight">$0</span>', $text);

    if (!empty($highlighted))
        $text = $highlighted;

    return $text;
}

?>
API documentation generated by ApiGen