addServer(MEMCACHED_HOST, MEMCACHED_PORT); } catch(Exception $e) { var_dump($e); exit; } // Filter request data $t = !empty($_GET['t']) ? Filter::url($_GET['t']) : 'text'; $m = !empty($_GET['m']) ? Filter::url($_GET['m']) : 'default'; $q = !empty($_GET['q']) ? Filter::url($_GET['q']) : ''; $p = !empty($_GET['p']) ? (int) $_GET['p'] : 1; // Search request $resultsTotal = $sphinx->searchHostPagesTotal(Filter::searchQuery($q, $m), $t); $results = $sphinx->searchHostPages(Filter::searchQuery($q, $m), $t, $p * WEBSITE_PAGINATION_SEARCH_PAGE_RESULTS_LIMIT - WEBSITE_PAGINATION_SEARCH_PAGE_RESULTS_LIMIT, WEBSITE_PAGINATION_SEARCH_PAGE_RESULTS_LIMIT, $resultsTotal); // Mime list $hostPagesMime = $sphinx->searchHostPagesMime(Filter::searchQuery($q, $m)); // Define page basics $totalPages = $sphinx->getHostPagesTotal(); $placeholder = Filter::plural($totalPages, [sprintf(_('Over %s page or enter the new one...'), $totalPages), sprintf(_('Over %s pages or enter the new one...'), $totalPages), sprintf(_('Over %s pages or enter the new one...'), $totalPages), ]); // Define alert message $alertMessages = []; // Register new host/page on search request contains the link if (URL::is($q)) { try { $db->beginTransaction(); if ($linkToDBresult = Helper::addLinkToDB($db, $memcached, $q)) { if (count($linkToDBresult->new->hostPageId)) { $alertMessages[] = _('Link successfully registered in the crawl queue!'); } else { if ($resultsTotal == 0) { $alertMessages[] = _('This link already registered in the crawl queue.'); } } } else { $alertMessages[] = _('Link address not supported on this host!'); } $db->commit(); } catch(Exception $e){ var_dump($e); $db->rollBack(); } } // Count pages in the crawl queue if ($queueTotal = $db->getHostPageCrawlQueueTotal(time() - CRAWL_HOST_PAGE_QUEUE_SECONDS_OFFSET)) { $alertMessages[] = sprintf(_('* Please wait for all pages crawl to complete (%s in queue).'), $queueTotal); } ?>