get(SearchService::class); if (isset($_GET['search']) && !empty($_GET['search'])) { $raw_search = $_GET['search']; $ip = $_SERVER['REMOTE_ADDR']; $fallback_board = (isset($_GET['board']) && !empty($_GET['board'])) ? $_GET['board'] : null; if ($search_service->checkFlood($ip, $raw_search)) { error(_('Wait a while before searching again, please.')); } // Actually do the search. $parse_res = $search_service->parse($raw_search); $filters = $search_service->reduceAndWeight($parse_res); $search_res = $search_service->search($ip, $raw_search, $filters, $fallback_board); // Needed to set a global variable further down the stack, plus the template. $actual_board = $filters->board ?? $fallback_board; $body = Element('search_form.html', [ 'boards' => $search_service->getSearchableBoards(), 'board' => $actual_board, 'search' => \str_replace('"', '"', utf8tohtml($_GET['search'])) ]); if (empty($search_res)) { $body .= '
(' . _('No results.') . ')
'; } else { $body .= '