mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-20 21:33:54 -07:00
Replace Sphinx API to the composer version
This commit is contained in:
parent
2e092c7bd4
commit
fcc05aa677
4 changed files with 9 additions and 1711 deletions
|
@ -42,6 +42,7 @@
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^5.3 || ^7.0",
|
"php": "^5.3 || ^7.0",
|
||||||
|
"gigablah/sphinxphp": "^2.0",
|
||||||
"google/recaptcha": "^1.0"
|
"google/recaptcha": "^1.0"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -2239,13 +2239,14 @@ function init_sphinx()
|
||||||
global $sphinx;
|
global $sphinx;
|
||||||
|
|
||||||
if (!isset($sphinx)) {
|
if (!isset($sphinx)) {
|
||||||
require(INC_DIR . 'api/sphinx.php');
|
$sphinx = \Sphinx\SphinxClient::create();
|
||||||
$sphinx = new SphinxClient();
|
|
||||||
|
|
||||||
$sphinx->SetConnectTimeout(5);
|
$sphinx->SetConnectTimeout(5);
|
||||||
$sphinx->SetRankingMode(SPH_RANK_NONE);
|
$sphinx->SetRankingMode($sphinx::SPH_RANK_NONE);
|
||||||
$sphinx->SetMatchMode(SPH_MATCH_BOOLEAN);
|
$sphinx->SetMatchMode($sphinx::SPH_MATCH_BOOLEAN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $sphinx;
|
||||||
}
|
}
|
||||||
|
|
||||||
function log_sphinx_error($err_type, $err_msg, $query = '')
|
function log_sphinx_error($err_type, $err_msg, $query = '')
|
||||||
|
@ -2271,7 +2272,7 @@ function get_title_match_topics($title_match_sql, $forum_ids = array())
|
||||||
$title_match_sql = encode_text_match($title_match_sql);
|
$title_match_sql = encode_text_match($title_match_sql);
|
||||||
|
|
||||||
if ($bb_cfg['search_engine_type'] == 'sphinx') {
|
if ($bb_cfg['search_engine_type'] == 'sphinx') {
|
||||||
init_sphinx();
|
$sphinx = init_sphinx();
|
||||||
|
|
||||||
$where = ($title_match) ? 'topics' : 'posts';
|
$where = ($title_match) ? 'topics' : 'posts';
|
||||||
|
|
||||||
|
@ -2280,7 +2281,7 @@ function get_title_match_topics($title_match_sql, $forum_ids = array())
|
||||||
$sphinx->SetFilter('forum_id', $forum_ids, false);
|
$sphinx->SetFilter('forum_id', $forum_ids, false);
|
||||||
}
|
}
|
||||||
if (preg_match('#^"[^"]+"$#u', $title_match_sql)) {
|
if (preg_match('#^"[^"]+"$#u', $title_match_sql)) {
|
||||||
$sphinx->SetMatchMode(SPH_MATCH_PHRASE);
|
$sphinx->SetMatchMode($sphinx::SPH_MATCH_PHRASE);
|
||||||
}
|
}
|
||||||
if ($result = $sphinx->Query($title_match_sql, $where, $userdata['username'] . ' (' . CLIENT_IP . ')')) {
|
if ($result = $sphinx->Query($title_match_sql, $where, $userdata['username'] . ' (' . CLIENT_IP . ')')) {
|
||||||
if (!empty($result['matches'])) {
|
if (!empty($result['matches'])) {
|
||||||
|
|
|
@ -29,7 +29,7 @@ if (!defined('BB_ROOT')) {
|
||||||
|
|
||||||
function get_sql_log()
|
function get_sql_log()
|
||||||
{
|
{
|
||||||
global $DBS, $CACHES, $sphinx, $datastore;
|
global $DBS, $CACHES, $datastore;
|
||||||
|
|
||||||
$log = '';
|
$log = '';
|
||||||
|
|
||||||
|
@ -45,8 +45,6 @@ function get_sql_log()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$log .= !empty($sphinx) ? get_sql_log_html($sphinx, '$sphinx') : '';
|
|
||||||
|
|
||||||
if (!empty($datastore->db->dbg)) {
|
if (!empty($datastore->db->dbg)) {
|
||||||
$log .= get_sql_log_html($datastore->db, 'cache: datastore [' . $datastore->engine . ']');
|
$log .= get_sql_log_html($datastore->db, 'cache: datastore [' . $datastore->engine . ']');
|
||||||
} elseif (!empty($datastore->dbg)) {
|
} elseif (!empty($datastore->dbg)) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue