mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 00:01:21 +00:00
Update SphinxSearch class
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
2018-02-06 DariusIII
|
||||
* Chg: Update SphinxSearch class
|
||||
* Fix: Update installation console commands to fix missing type error when using fixtures in production
|
||||
2018-02-04 DariusIII
|
||||
* Fix: Fix error on details page in Gamma theme
|
||||
|
||||
+13
-17
@@ -14,6 +14,8 @@ class SphinxSearch
|
||||
|
||||
/**
|
||||
* Establish connection to SphinxQL.
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
@@ -49,10 +51,10 @@ class SphinxSearch
|
||||
sprintf(
|
||||
'REPLACE INTO releases_rt (id, name, searchname, fromname, filename) VALUES (%d, %s, %s, %s, %s)',
|
||||
$parameters['id'],
|
||||
$this->sphinxQL->escapeString($parameters['name']),
|
||||
$this->sphinxQL->escapeString($parameters['searchname']),
|
||||
$this->sphinxQL->escapeString($parameters['fromname']),
|
||||
empty($parameters['filename']) ? "''" : $this->sphinxQL->escapeString($parameters['filename'])
|
||||
$this->escapeString($parameters['name']),
|
||||
$this->escapeString($parameters['searchname']),
|
||||
$this->escapeString($parameters['fromname']),
|
||||
empty($parameters['filename']) ? "''" : $this->escapeString($parameters['filename'])
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -81,22 +83,16 @@ class SphinxSearch
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $string
|
||||
* Escapes characters that are treated as special operators by the query language parser
|
||||
*
|
||||
* @return mixed
|
||||
* @param string $string unescaped string
|
||||
*
|
||||
* @return string Escaped string.
|
||||
*/
|
||||
public static function escapeString($string)
|
||||
public function escapeString($string): string
|
||||
{
|
||||
$from = [
|
||||
'\\', '(', ')', '|', '---', '--', '-', '!', '@', '~', '"', '&', '/', '^', '$', '=', "'",
|
||||
"\x00", "\n", "\r", "\x1a",
|
||||
];
|
||||
$to = [
|
||||
'\\\\\\\\', '\\\\\\\\(', '\\\\\\\\)', '\\\\\\\\|', '-', '-', '\\\\\\\\-', '\\\\\\\\!',
|
||||
'\\\\\\\\@', '\\\\\\\\~',
|
||||
'\\\\\\\\"', '\\\\\\\\&', '\\\\\\\\/', '\\\\\\\\^', '\\\\\\\\$', '\\\\\\\\=', "\\'",
|
||||
'\\x00', '\\n', '\\r', '\\x1a',
|
||||
];
|
||||
$from = ['\\', '(', ')', '|', '-', '!', '@', '~', '"', '&', '/', '^', '$', '='];
|
||||
$to = ['\\\\', '\(', '\)', '\|', '\-', '\!', '\@', '\~', '\"', '\&', '\/', '\^', '\$', '\='];
|
||||
|
||||
return str_replace($from, $to, $string);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user