|
|
@ -33,6 +33,9 @@ try { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Connect memcached |
|
|
|
// Connect memcached |
|
|
|
|
|
|
|
// @TODO |
|
|
|
|
|
|
|
// legacy, upgrade to yggverse/cache instead |
|
|
|
|
|
|
|
// https://github.com/YGGverse/cache-php |
|
|
|
try { |
|
|
|
try { |
|
|
|
|
|
|
|
|
|
|
|
$memcached = new Memcached(); |
|
|
|
$memcached = new Memcached(); |
|
|
@ -45,6 +48,18 @@ try { |
|
|
|
exit; |
|
|
|
exit; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Connect Yggverse\Cache\Memory |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$memory = new Yggverse\Cache\Memory(MEMCACHED_HOST, MEMCACHED_PORT, MEMCACHED_NAMESPACE, MEMCACHED_TIMEOUT + time()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch(Exception $e) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var_dump($e); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exit; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Filter request data |
|
|
|
// Filter request data |
|
|
|
$t = !empty($_GET['t']) ? Filter::url($_GET['t']) : 'text'; |
|
|
|
$t = !empty($_GET['t']) ? Filter::url($_GET['t']) : 'text'; |
|
|
|
$m = !empty($_GET['m']) ? Filter::url($_GET['m']) : 'default'; |
|
|
|
$m = !empty($_GET['m']) ? Filter::url($_GET['m']) : 'default'; |
|
|
@ -52,16 +67,19 @@ $q = !empty($_GET['q']) ? Filter::url($_GET['q']) : ''; |
|
|
|
$p = !empty($_GET['p']) ? (int) $_GET['p'] : 1; |
|
|
|
$p = !empty($_GET['p']) ? (int) $_GET['p'] : 1; |
|
|
|
|
|
|
|
|
|
|
|
// Search request |
|
|
|
// Search request |
|
|
|
|
|
|
|
if (empty($q)) { |
|
|
|
|
|
|
|
$resultsTotal = 0; |
|
|
|
|
|
|
|
$results = []; |
|
|
|
|
|
|
|
$hostPagesMime = []; |
|
|
|
|
|
|
|
} else { |
|
|
|
$resultsTotal = $sphinx->searchHostPagesTotal(Filter::searchQuery($q, $m), $t); |
|
|
|
$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); |
|
|
|
$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)); |
|
|
|
$hostPagesMime = $sphinx->searchHostPagesMime(Filter::searchQuery($q, $m)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Define page basics |
|
|
|
// Define page basics |
|
|
|
$totalPages = $sphinx->getHostPagesTotal(); |
|
|
|
$totalPages = $sphinx->getHostPagesTotal(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$placeholder = Filter::plural($totalPages, [sprintf(_('Over %s page or enter the new one...'), $totalPages), |
|
|
|
$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), |
|
|
|
sprintf(_('Over %s pages or enter the new one...'), $totalPages), |
|
|
|
sprintf(_('Over %s pages or enter the new one...'), $totalPages), |
|
|
@ -107,7 +125,11 @@ if (Yggverse\Parser\Url::is($q)) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Count pages in the crawl queue |
|
|
|
// Count pages in the crawl queue |
|
|
|
if ($queueTotal = $db->getHostPageCrawlQueueTotal(time() - CRAWL_HOST_PAGE_QUEUE_SECONDS_OFFSET)) { |
|
|
|
$timeThisHour = strtotime(sprintf('%s-%s-%s %s:00', date('Y'), date('n'), date('d'), date('H'))); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($queueTotal = $memory->getByMethodCallback( |
|
|
|
|
|
|
|
$db, 'getHostPageCrawlQueueTotal', [$timeThisHour - CRAWL_HOST_PAGE_QUEUE_SECONDS_OFFSET], $timeThisHour + 3600 |
|
|
|
|
|
|
|
)) { |
|
|
|
|
|
|
|
|
|
|
|
$alertMessages[] = sprintf(_('* Please wait for all pages crawl to complete (%s in queue).'), $queueTotal); |
|
|
|
$alertMessages[] = sprintf(_('* Please wait for all pages crawl to complete (%s in queue).'), $queueTotal); |
|
|
|
} |
|
|
|
} |
|
|
@ -340,9 +362,17 @@ if ($queueTotal = $db->getHostPageCrawlQueueTotal(time() - CRAWL_HOST_PAGE_QUEUE |
|
|
|
<?php } else { ?> |
|
|
|
<?php } else { ?> |
|
|
|
<div style="text-align:center"> |
|
|
|
<div style="text-align:center"> |
|
|
|
<span><?php echo sprintf(_('Total found: %s'), $resultsTotal) ?></span> |
|
|
|
<span><?php echo sprintf(_('Total found: %s'), $resultsTotal) ?></span> |
|
|
|
<?php if ($q && $queueTotal = $db->getHostPageCrawlQueueTotal(time() - CRAWL_HOST_PAGE_QUEUE_SECONDS_OFFSET)) { ?> |
|
|
|
<span> |
|
|
|
<span><?php echo sprintf(_('* Please wait for all pages crawl to complete (%s in queue).'), $queueTotal) ?></span> |
|
|
|
<?php |
|
|
|
<?php } ?> |
|
|
|
// Count pages in the crawl queue |
|
|
|
|
|
|
|
if ($q && $queueTotal = $memory->getByMethodCallback( |
|
|
|
|
|
|
|
$db, 'getHostPageCrawlQueueTotal', [$timeThisHour - CRAWL_HOST_PAGE_QUEUE_SECONDS_OFFSET], $timeThisHour + 3600 |
|
|
|
|
|
|
|
)) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
echo sprintf(_('* Please wait for all pages crawl to complete (%s in queue).'), $queueTotal); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
?> |
|
|
|
|
|
|
|
</span> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<?php } ?> |
|
|
|
<?php } ?> |
|
|
|
</main> |
|
|
|
</main> |
|
|
|