$config->manticore->server->host, 'port' => $config->manticore->server->port, ] ); // Init index $index = $client->index( $config->manticore->index->document->name ); // Get totals $total = $index->search('') ->option('cutoff', 0) ->limit(0) ->get() ->getTotal(); $placeholder = sprintf( _('Search in %s documents %s'), number_format( $total ), $config->webui->search->index->request->url->enabled ? _('or enter new address to crawl...') : false ); $response = false; // Request $q = !empty($_GET['q']) ? trim($_GET['q']) : ''; $p = !empty($_GET['p']) ? (int) $_GET['p'] : 1; // Register new URL by request on enabled if ($config->webui->search->index->request->url->enabled && filter_var($q, FILTER_VALIDATE_URL)) { if (preg_match($config->webui->search->index->request->url->regex, $q)) { // Prepare URL $url = $q; $crc32url = crc32($url); // Check URL for exist $exist = $index->search('') ->filter('id', $crc32url) ->limit(1) ->get() ->getTotal(); if ($exist) { /* disable as regular search request possible $response = sprintf( _('URL "%s" exists in search index'), htmlentities($q) ); */ } // Add URL else { // @TODO check http code $index->addDocument( [ 'url' => $url, 'rank' => (int) mb_strlen( (string) urldecode( (string) parse_url( $url, PHP_URL_PATH ) ) ) ], $crc32url ); $response = sprintf( _('URL "%s" added to the crawl queue!'), htmlentities($q) ); } } else { $response = sprintf( _('URL "%s" does not match node settings!'), htmlentities($q) ); } } // Extended corrections switch (true) { // Empty query case empty($q): $query = $index->search('')->sort('RAND()'); break; // URL request case filter_var($q, FILTER_VALIDATE_URL): $query = $index->search('')->filter('id', crc32($q)); break; default: // Allow raw requests on extended syntax mode requested // http://sphinxsearch.com/docs/current/extended-syntax.html if (isset($_GET['e']) && $config->webui->search->extended->enabled) { $query = $index->search($q); } // Regular request else { $query = $index->search( @\Manticoresearch\Utils::escape( $q ) ); } } // Apply search options (e.g. field_weights) foreach ($config->webui->search->options as $key => $value) { if (is_int($value) || is_string($value)) { $query->option( $key, $value ); } else { $query->option( $key, (array) $value ); } } // Apply highlight options if ($config->webui->search->highlight->fields) { $query->highlight( (array) $config->webui->search->highlight->fields, (array) $config->webui->search->highlight->options ); } // Get found $found = empty($q) ? $total : $query->get()->getTotal(); // Search request begin $results = $query->offset($p * $config->webui->pagination->limit - $config->webui->pagination->limit) ->limit($config->webui->pagination->limit) ->get(); ?> <?php echo sprintf(_('Yo! %s'), htmlentities($q)) ?>

webui->search->extended->enabled) { ?>
webui->search->extended->enabled) { ?>

@title @description @keywords @mime @url

url, PHP_URL_HOST ); $identicon = new \Jdenticon\Identicon(); $identicon->setValue( $hostname ); $identicon->setSize(14); $identicon->setStyle( [ 'backgroundColor' => 'rgba(255, 255, 255, 0)', 'padding' => 0 ] ); $icon = $identicon->getImageDataUri('webp'); ?> identicon getHighlight()['title'])) { ?>

getHighlight()['title'] as $title) { ?>

title)) { ?>

title ?>

getHighlight()['description'])) { ?>
getHighlight()['description'] as $description) { ?>

description)) { ?>
description ?>
getHighlight()['keywords'])) { ?>
getHighlight()['keywords'] as $keywords) { ?>

keywords)) { ?>
keywords ?>
getHighlight()['body'])) { ?>
getHighlight()['body'] as $body) { ?>

getHighlight()['url'])) { ?> getHighlight()['url'] as $url) { ?> title)) { ?> url)) ?> get('code'), [0, 200])) { ?> get('code') ?>
webui->pagination->limit <= $results->getTotal()) { ?>