Add sphinx filename search support.

This commit is contained in:
DariusIII
2015-08-27 22:41:33 +02:00
parent b155c62dba
commit 0fc6b3ebc4
21 changed files with 433 additions and 127 deletions
+21 -17
View File
@@ -1,37 +1,41 @@
<?php
require dirname(__FILE__) . '/../../www/config.php';
use newznab\db\Settings;
use newznab\db\DB;
if (NN_RELEASE_SEARCH_TYPE != \ReleaseSearch::SPHINX) {
exit('Error, NN_RELEASE_SEARCH_TYPE in www/settings.php must be set to SPHINX!' . PHP_EOL);
}
if (!isset($argv[1]) || !isset($argv[2]) || !is_numeric($argv[2])) {
exit('Argument 1 must the hostname or IP to the Sphinx searchd server, Argument 2 must be the port to the Sphinx searchd server.' . PHP_EOL);
$sphinxConnection = '';
if ($argc == 3 && is_numeric($argv[2])) {
$sphinxConnection = sprintf('sphinx://%s:%d/', $argv[1], $argv[2]);
} elseif ($argc == 2) {
// Checks that argv[1] exists AND that there are no other arguments, which would be an error.
$socket = preg_replace('#^(?:unix://)?(.*)$#', '$1', $argv[1]);
if (substr($socket, 0, 1) == '/') {
// Make sure the socket path is fully qualified (and using correct separator).
$sphinxConnection = sprintf('unix://%s:', $socket);
}
} else {
exit("Argument 1 must the hostname or IP to the Sphinx searchd server, Argument 2 must be the port to the Sphinx searchd server.\nAlternatively, Argument 1 can be a unix domain socket." . PHP_EOL);
}
$pdo = new Settings();
$pdo = new DB();
$sphinxConnection = sprintf('%s:%d', $argv[1], $argv[2]);
$tables = [];
$tables['releases_se'] =
sprintf(
"CREATE TABLE releases_se
$tableSQL_releases = <<<DDLSQL
CREATE TABLE releases_se
(
id BIGINT UNSIGNED NOT NULL,
weight INTEGER NOT NULL,
query VARCHAR(1024) NOT NULL,
guid VARCHAR(40) NOT NULL,
name VARCHAR(255) NOT NULL DEFAULT '',
searchname VARCHAR(255) NOT NULL DEFAULT '',
fromname VARCHAR(255) NULL,
INDEX(query)
) ENGINE=SPHINX CONNECTION=\"sphinx://%s/releases_rt\"",
$sphinxConnection
);
) ENGINE=SPHINX CONNECTION="%sreleases_rt"
DDLSQL;
$tables = [];
$tables['releases_se'] = sprintf($tableSQL_releases, $sphinxConnection);
foreach ($tables as $table => $query) {
$pdo->queryExec(sprintf('DROP TABLE IF EXISTS %s', $table));
+2 -2
View File
@@ -1,7 +1,7 @@
<?php
require dirname(__FILE__) . '/../../www/config.php';
if (!isset($argv[1]) || !in_array($argv[1], ['releases_rt'])) {
exit('Argument1 is the index name, currently only releases_rt is supported.' . PHP_EOL);
if (!isset($argv[1]) || !in_array($argv[1], ['releases_rt', 'release_files_rt'])) {
exit('Argument1 is the index name, currently only releases_rt/release_files_rt are supported.' . PHP_EOL);
}
(new \SphinxSearch())->optimizeRTIndex($argv[1]);
+37 -30
View File
@@ -1,48 +1,55 @@
<?php
require dirname(__FILE__) . '/../../www/config.php';
use newznab\db\Settings;
use newznab\db\DB;
if (NN_RELEASE_SEARCH_TYPE != \ReleaseSearch::SPHINX) {
if (NN_RELEASE_SEARCH_TYPE != ReleaseSearch::SPHINX) {
exit('Error, NN_RELEASE_SEARCH_TYPE in www/settings.php must be set to SPHINX!' . PHP_EOL);
}
if (!isset($argv[1]) || !in_array($argv[1], ['releases_rt'])) {
exit('Argument1 is the index name, releases_rt is the only supported currently.' . PHP_EOL);
}
switch ($argv[1]) {
case 'releases_rt':
releases_rt();
break;
default:
exit();
} else if (!isset($argv[1]) || !in_array($argv[1], ['releases_rt'])) {
exit('Argument1 is the index name, releases_rt are the only supported ones currently.' . PHP_EOL);
} else {
populate_rt($argv[1]);
}
// Bulk insert releases into sphinx RT index.
function releases_rt()
function populate_rt($table = '')
{
$pdo = new Settings();
$rows = $pdo->queryExec('SELECT id, guid, name, searchname, fromname FROM releases');
$pdo = new DB();
if ($rows !== false && $rows->rowCount()) {
$sphinx = new \SphinxSearch();
$rows = false;
$total = $rows->rowCount();
$string = 'REPLACE INTO releases_rt (id, guid, name, searchname, fromname) VALUES ';
switch ($table) {
case 'releases_rt':
$pdo->queryDirect('SET SESSION group_concat_max_len=8192');
$rows = $pdo->queryExec('SELECT r.id, r.name, r.searchname, r.fromname, IFNULL(GROUP_CONCAT(rf.name SEPARATOR " "),"") filename
FROM releases r LEFT JOIN releasefiles rf ON(r.id=rf.releaseid) GROUP BY r.id'
);
$rtvalues = '(id, name, searchname, fromname, filename)';
break;
}
if ($rows !== false && $total = $rows->rowCount()) {
$sphinx = new SphinxSearch();
$string = sprintf('REPLACE INTO %s %s VALUES ', $table, $rtvalues);
$tempString = '';
$i = 0;
echo '[Starting to populate sphinx RT indexes with ' . $total . ' releases.] ';
echo '[Starting to populate sphinx RT index ' . $table . ' with ' . $total . ' releases.] ';
foreach ($rows as $row) {
$i++;
$tempString .= sprintf(
'(%d, %s, %s, %s, %s),' ,
$row['id'],
$sphinx->sphinxQL->escapeString($row['guid']),
$sphinx->sphinxQL->escapeString($row['name']),
$sphinx->sphinxQL->escapeString($row['searchname']),
$sphinx->sphinxQL->escapeString($row['fromname'])
);
switch ($table) {
case 'releases_rt':
$tempString .= sprintf(
'(%d, %s, %s, %s, %s),',
$row['id'],
$sphinx->sphinxQL->escapeString($row['name']),
$sphinx->sphinxQL->escapeString($row['searchname']),
$sphinx->sphinxQL->escapeString($row['fromname']),
$sphinx->sphinxQL->escapeString($row['filename'])
);
break;
}
if ($i === 1000 || $i >= $total) {
$sphinx->sphinxQL->queryExec($string . rtrim($tempString, ','));
$tempString = '';
+6 -11
View File
@@ -1,4 +1,4 @@
# !*: indicates newznab Notes
# !*: indicates nZEDb Notes
# !*: Do not change the "releases_rt" word.
index releases_rt
@@ -25,7 +25,6 @@ index releases_rt
#
min_prefix_len = 0
min_infix_len = 1
enable_star = 1
# !*: Path to where the index files will be stored.
# !*: http://sphinxsearch.com/docs/current.html#conf-path
@@ -41,16 +40,12 @@ index releases_rt
rt_field = name
rt_field = searchname
rt_field = fromname
rt_field = filename
# String attribute declations.
# !*: Do not change these.
rt_attr_string = name
rt_attr_string = searchname
rt_attr_string = fromname
rt_attr_string = guid
}
indexer
{
# Memory limit, in bytes, kiloytes (16384K) or megabytes (256M)
# Default is 32M, max is 2047M, recommended is 256M to 1024M
@@ -95,7 +90,7 @@ searchd
# listen = 192.168.0.1:9312
# listen = 9312
# listen = /var/run/searchd.sock
# !*: If you change this, you will need to change your newznab settings.php file accordingly.
# !*: If you change this, you will need to change your nZEDb settings.php file accordingly.
# Setting anything else can cause issues, beware.
# The first listen is for the sphinxse plugin in MySQL to communicate with the sphinx server,
# so we can select from the RT index.
@@ -137,7 +132,7 @@ searchd
# !*: http://sphinxsearch.com/docs/current.html#conf-max-children
# max_children = 0
# PID file, searchd process id file name
# PID file, searchd process ID file name
# mandatory
# !*: Sphinx will not start if this folder does not exist.
# !*: http://sphinxsearch.com/docs/current.html#conf-pid-file
@@ -315,4 +310,4 @@ searchd
# rt_merge_maxiosize = 0
}
# --eof--
# --eof--
+1 -1
View File
@@ -7,7 +7,7 @@ use newznab\db\Settings;
if (!isset($argv[1]) || !in_array($argv[1], ['sphinx', 'standard'])) {
exit('Argument1 (required) is the method of search you would like to optimize for. Choices are sphinx or standard.' . PHP_EOL .
'Argument2 (optional) is the storage engine and row_format you would like the releasesearch table to use. If not entered it will be left default.' . PHP_EOL .
'Choices are (c|d)(myisam|innodb) (Compressed|Dynamic)(MyISAM|InnoDB) entered like dinnodb. This argument has no effect if optimizinf for Sphinx.' . PHP_EOL .
'Choices are (c|d)(myisam|innodb) (Compressed|Dynamic)(MyISAM|InnoDB) entered like dinnodb. This argument has no effect if optimizing for Sphinx.' . PHP_EOL .
'Please stop all processing scripts before running this script.' . PHP_EOL);
}
+3 -3
View File
@@ -575,7 +575,7 @@ class NameFixer
$release['releaseid']
)
);
$this->sphinx->updateReleaseSearchName($release['releaseid'], $newTitle);
$this->sphinx->updateRelease($release['releaseid'], $this->pdo);
} else {
$newTitle = $this->pdo->escapeString(substr($newName, 0, 255));
$this->pdo->queryExec(
@@ -592,7 +592,7 @@ class NameFixer
$release['releaseid']
)
);
$this->sphinx->updateReleaseSearchName($release['releaseid'], $newTitle);
$this->sphinx->updateRelease($release['releaseid'], $this->pdo);
}
}
}
@@ -689,7 +689,7 @@ class NameFixer
$titlematch = \SphinxSearch::escapeString($preTitle);
$join = sprintf(
'INNER JOIN releases_se rse ON rse.id = r.id
WHERE rse.query = "@(name,searchname) %s;mode=extended"',
WHERE rse.query = "@(name,searchname,filename) %s;mode=extended"',
$titlematch
);
break;
+45 -7
View File
@@ -12,12 +12,18 @@ class ReleaseFiles
*/
protected $pdo;
/**
* @var SphinxSearch
*/
public $sphinxSearch;
/**
* @param \newznab\db\Settings $settings
*/
public function __construct($settings = null)
{
$this->pdo = ($settings instanceof Settings ? $settings : new Settings());
$this->sphinxSearch = new SphinxSearch();
}
@@ -42,19 +48,51 @@ class ReleaseFiles
*/
public function delete($id)
{
return $this->pdo->queryExec(sprintf("DELETE FROM releasefiles WHERE releaseid = %d", $id));
$res = $this->pdo->queryExec(sprintf("DELETE FROM releasefiles WHERE releaseid = %d", $id));
$this->sphinxSearch->updateRelease($id, $this->pdo);
return $res;
}
/**
* Add a releasefiles row.
* Add new files for a release ID.
*
* @param int $id The ID of the release.
* @param string $name Name of the file.
* @param int $size Size of the file.
* @param int $createdTime Unix time the file was created.
* @param int $hasPassword Does it have a password (see Releases class constants)?
*
* @return mixed
*/
public function add($id, $name, $size, $createddate, $passworded)
public function add($id, $name, $size, $createdTime, $hasPassword)
{
return $this->pdo->queryInsert(sprintf("INSERT INTO releasefiles (releaseid, name, size, createddate, passworded) VALUES
(%d, %s, %s, from_unixtime(%d), %d)",
$id, $this->pdo->escapeString($name), $this->pdo->escapeString($size),
$createddate, $passworded
$insert = 0;
$duplicateCheck = $this->pdo->queryOneRow(
sprintf('
SELECT id
FROM releasefiles
WHERE releaseid = %d AND name = %s',
$id,
$this->pdo->escapeString(utf8_encode($name))
)
);
if ($duplicateCheck === false) {
$insert = $this->pdo->queryInsert(
sprintf("
INSERT INTO releasefiles
(releaseid, name, size, createddate, passworded)
VALUES
(%d, %s, %s, %s, %d)",
$id,
$this->pdo->escapeString(utf8_encode($name)),
$this->pdo->escapeString($size),
$this->pdo->from_unixtime($createdTime),
$hasPassword
)
);
}
return $insert;
}
}
+1 -1
View File
@@ -768,7 +768,7 @@ class ReleaseRemover
}
$ftMatch = (NN_RELEASE_SEARCH_TYPE == ReleaseSearch::SPHINX
? sprintf('rse.query = "@(name,searchname) %s;limit=10000;maxmatches=10000;mode=any" AND', str_replace('|', ' ', str_replace('"', '', $regexMatch)))
? sprintf('rse.query = "@(name,searchname,filename) %s;limit=10000;maxmatches=10000;mode=any" AND', str_replace('|', ' ', str_replace('"', '', $regexMatch)))
: sprintf("(MATCH (rs.name) AGAINST ('%1\$s') OR MATCH (rs.searchname) AGAINST ('%1\$s')) AND", str_replace('|', ' ', $regexMatch))
);
}
+12 -9
View File
@@ -43,6 +43,7 @@ class ReleaseSearch
break;
}
$this->sphinxQueryOpt = ";limit=10000;maxmatches=10000;sort=relevance;mode=extended";
$this->pdo = ($settings instanceof newznab\db\Settings ? $settings : new newznab\db\Settings());
}
@@ -147,6 +148,7 @@ class ReleaseSearch
}
return $return;
}
/**
* Create SQL sub-query using sphinx full text search.
*
@@ -154,29 +156,30 @@ class ReleaseSearch
*/
private function sphinxSQL()
{
$return = '';
$searchQuery = $fullReturn = '';
foreach ($this->searchOptions as $columnName => $searchString) {
$searchWords = '';
$words = explode(' ', $searchString);
foreach ($words as $word) {
$word = str_replace("'", "\\'", trim($word, "\n\t\r\0\x0B "));
if ($word !== '') {
$searchWords .= ($word . ' ');
}
}
$searchWords = rtrim($searchWords, "\n\t\r\0\x0B ");
if ($searchWords !== '') {
$return .= sprintf("@%s %s ", $columnName, $searchWords);
$searchQuery .= sprintf("@%s %s ",
$columnName,
$searchWords
);
}
}
if ($return === '') {
return $this->likeSQL();
if ($searchQuery !== '') {
$fullReturn = sprintf("AND (rse.query = '@@relaxed %s')", trim($searchQuery) . $this->sphinxQueryOpt);
} else {
return sprintf(
" AND rse.query = '%s;limit=10000;maxmatches=10000;sort=relevance;mode=extended'",
trim($return)
);
$fullReturn = $this->likeSQL();
}
return $fullReturn;
}
}
+7 -3
View File
@@ -795,7 +795,7 @@ class Releases
$ID
)
);
$this->sphinxSearch->updateReleaseSearchName($ID, $searchName);
$this->sphinxSearch->updateRelease($ID, $this->pdo);
}
/**
@@ -920,6 +920,7 @@ class Releases
* @param string $usenetName
* @param string $posterName
* @param string $groupName
* @param string $fileName
* @param int $sizeFrom
* @param int $sizeTo
* @param int $hasNfo
@@ -940,6 +941,7 @@ class Releases
$searchName,
$usenetName,
$posterName,
$fileName,
$groupName,
$sizeFrom,
$sizeTo,
@@ -987,6 +989,9 @@ class Releases
if ($posterName != -1) {
$searchOptions['fromname'] = $posterName;
}
if ($fileName != -1) {
$searchOptions['filename'] = $fileName;
}
$whereSql = sprintf(
"%s
@@ -1379,8 +1384,7 @@ class Releases
$parentCat = $catRow['parentid'];
$results = $this->search(
$this->getSimilarName($name), -1, -1, -1, -1, -1, 0, 0, -1, -1, 0, $limit, '', -1, $excludedCats, null, [$parentCat]
);
$this->getSimilarName($name), -1, -1, -1, -1, -1, -1, 0, 0, -1, -1, 0, $limit, '', -1, $excludedCats, null, [$parentCat] );
if (!$results) {
return $results;
}
+2 -2
View File
@@ -266,7 +266,7 @@ class RequestIDLocal extends RequestID
$this->_release['id']
)
);
$this->sphinx->updateReleaseSearchName($this->_release['id'], $newTitle);
$this->sphinx->updateRelease($this->_release['id'], $this->pdo);
} else {
$newTitle = $this->pdo->escapeString($this->_newTitle['title']);
$this->pdo->queryExec(
@@ -284,7 +284,7 @@ class RequestIDLocal extends RequestID
$this->_release['id']
)
);
$this->sphinx->updateReleaseSearchName($this->_release['id'], $newTitle);
$this->sphinx->updateRelease($this->_release['id'], $this->pdo);
}
if ($this->_release['name'] !== $this->_newTitle['title'] && $this->_show == 1) {
+1 -1
View File
@@ -300,7 +300,7 @@ class RequestIDWeb extends RequestID
$this->_release['id']
)
);
$this->sphinx->updateReleaseSearchName($this->_release['id'], $newTitle);
$this->sphinx->updateRelease($this->_release['id'], $this->pdo);
if ($this->echoOutput) {
\NameFixer::echoChangedReleaseName(array(
+37 -27
View File
@@ -45,21 +45,21 @@ class SphinxSearch
if (!is_null($this->sphinxQL) && $parameters['id']) {
$this->sphinxQL->queryExec(
sprintf(
'REPLACE INTO releases_rt (id, guid, name, searchname, fromname) VALUES (%s, %s, %s, %s, %s)',
'REPLACE INTO releases_rt (id, name, searchname, fromname, filename) VALUES (%d, %s, %s, %s, %s)',
$parameters['id'],
$parameters['guid'],
$parameters['name'],
$parameters['searchname'],
$parameters['fromname']
$this->sphinxQL->escapeString($parameters['name']),
$this->sphinxQL->escapeString($parameters['searchname']),
$this->sphinxQL->escapeString($parameters['fromname']),
empty($parameters['filename']) ? "''" : $this->sphinxQL->escapeString($parameters['filename'])
)
);
}
}
/**
* Delete release from Sphinx RT table.
* @param array $identifiers ['g' => Release GUID(mandatory), 'id => ReleaseID(optional, pass false)]
* @param Settings $pdo
* Delete release from Sphinx RT tables.
* @param array $identifiers ['g' => Release GUID(mandatory), 'id' => ReleaseID(optional, pass false)]
* @param \newznab\db\Settings $pdo
*/
public function deleteRelease($identifiers, Settings $pdo)
{
@@ -73,39 +73,48 @@ class SphinxSearch
}
}
if ($identifiers['i'] !== false) {
$this->sphinxQL->queryExec(sprintf('DELETE FROM releases_rt WHERE id = %s', $identifiers['i']));
$this->sphinxQL->queryExec(sprintf('DELETE FROM releases_rt WHERE id = %d', $identifiers['i']));
}
}
}
public static function escapeString($string)
{
$from = array ('\\', '(',')','|','---','--','-','!','@','~','"','&', '/', '^', '$', '=', "'", "\x00", "\n", "\r", "\x1a");
$to = array ('\\\\\\\\','\\\\\\\\(','\\\\\\\\)','\\\\\\\\|','-','-','\\\\\\\\-','\\\\\\\\!','\\\\\\\\@','\\\\\\\\~',
'\\\\\\\\"', '\\\\\\\\&', '\\\\\\\\/', '\\\\\\\\^', '\\\\\\\\$', '\\\\\\\\=', "\\'", "\\x00", "\\n", "\\r", "\\x1a");
$from = [
'\\', '(', ')', '|', '---', '--', '-', '!', '@', '~', '"', '&', '/', '^', '$', '=', "'",
"\x00", "\n", "\r", "\x1a"
];
$to = [
'\\\\\\\\', '\\\\\\\\(', '\\\\\\\\)', '\\\\\\\\|', '-', '-', '\\\\\\\\-', '\\\\\\\\!',
'\\\\\\\\@', '\\\\\\\\~',
'\\\\\\\\"', '\\\\\\\\&', '\\\\\\\\/', '\\\\\\\\^', '\\\\\\\\$', '\\\\\\\\=', "\\'",
"\\x00", "\\n", "\\r", "\\x1a"
];
return str_replace($from, $to, $string);
}
/**
* Update the search name of a release.
* Update Sphinx Relases index for given releaseid.
*
* @param int $releaseID
* @param string $searchName
* @param \newznab\db\Settings $pdo
*/
public function updateReleaseSearchName($releaseID, $searchName)
public function updateRelease($releaseID, Settings $pdo)
{
if (!is_null($this->sphinxQL)) {
$old = $this->sphinxQL->queryOneRow(sprintf('SELECT * FROM releases_rt WHERE id = %s', $releaseID));
if ($old !== false) {
$this->insertRelease(
[
'id' => $releaseID,
'guid' => $this->sphinxQL->escapeString($old['guid']),
'name' => $this->sphinxQL->escapeString($old['name']),
'searchname' => $searchName,
'fromname' => $this->sphinxQL->escapeString($old['fromname'])
]
);
$new = $pdo->queryOneRow(
sprintf('
SELECT r.id, r.name, r.searchname, r.fromname, IFNULL(GROUP_CONCAT(rf.name SEPARATOR " "),"") filename
FROM releases r
LEFT JOIN releasefiles rf ON (r.id=rf.releaseid)
WHERE r.id = %d
GROUP BY r.id LIMIT 1',
$releaseID
)
);
if ($new !== false) {
$this->insertRelease($new);
}
}
}
@@ -128,7 +137,8 @@ class SphinxSearch
public function optimizeRTIndex($indexName)
{
if (!is_null($this->sphinxQL)) {
$this->sphinxQL->queryExec(sprintf('FLUSH RTINDEX %s', $indexName));
$this->sphinxQL->queryExec(sprintf('OPTIMIZE INDEX %s', $indexName));
}
}
}
}
@@ -1079,6 +1079,9 @@ class ProcessAdditional
$this->_addFileInfo($file);
}
if ($this->_addedFileInfo > 0) {
$this->sphinx->updateRelease($this->_release['id'], $this->pdo);
}
return ($this->_totalFileInfo > 0 ? true : false);
}
@@ -1712,7 +1715,7 @@ class ProcessAdditional
$this->_release['id']
)
);
$this->sphinx->updateReleaseSearchName($this->_release['id'], $newTitle);
$this->sphinx->updateRelease($this->_release['id'], $this->pdo);
// Echo the changed name.
if ($this->_echoCLI) {
@@ -2300,7 +2303,7 @@ class ProcessAdditional
$this->_release['id']
)
);
$this->sphinx->updateReleaseSearchName($this->_release['id'], $newTitle);
$this->sphinx->updateRelease($this->_release['id'], $this->pdo);
// Echo the changed name to CLI.
if ($this->_echoCLI) {
+1 -1
View File
@@ -77,7 +77,7 @@ $settings_file = __DIR__ . DS . 'settings.php';
if (is_file($settings_file)) {
require_once($settings_file);
if (php_sapi_name() == 'cli') {
$current_settings_file_version = 3; // Update this when updating settings.php.example
$current_settings_file_version = 4; // Update this when updating settings.php.example
if (!defined('NN_SETTINGS_FILE_VERSION') || NN_SETTINGS_FILE_VERSION != $current_settings_file_version) {
echo ("\033[0;31mNotice: Your $settings_file file is either out of date or you have not updated" .
" NN_SETTINGS_FILE_VERSION to $current_settings_file_version in that file.\033[0m" . PHP_EOL
+1 -1
View File
@@ -133,7 +133,7 @@ switch ($function) {
if (isset($_GET['q'])) {
$relData = $releases->search(
$_GET['q'], -1, -1, -1, -1, -1, 0, 0, -1, -1, $offset, $limit, '', $maxAge, $catExclusions,
$_GET['q'], -1, -1, -1, -1, -1, -1, 0, 0, -1, -1, $offset, $limit, '', $maxAge, $catExclusions,
"basic", $categoryID
);
} else {
+5 -4
View File
@@ -55,7 +55,7 @@ if ((isset($_REQUEST["id"]) || isset($_REQUEST["subject"])) && !isset($_REQUEST[
}
$results = $releases->search(
$searchString, -1, -1, -1, -1, -1, 0, 0, -1, -1, $offset, ITEMS_PER_PAGE,
$searchString, -1, -1, -1, -1, -1, -1, 0, 0, -1, -1, $offset, ITEMS_PER_PAGE,
$orderBy, -1, $page->userdata["categoryexclusions"], "basic", $categoryID
);
@@ -77,9 +77,9 @@ if ((isset($_REQUEST["id"]) || isset($_REQUEST["subject"])) && !isset($_REQUEST[
$searchVars = [
'searchadvr' => '', 'searchadvsubject' => '', 'searchadvposter' => '',
'searchadvdaysnew' => '', 'searchadvdaysold' => '', 'searchadvgroups' => '',
'searchadvcat' => '', 'searchadvsizefrom' => '', 'searchadvsizeto' => '',
'searchadvhasnfo' => '', 'searchadvhascomments' => ''
'searchadvfilename' => '', 'searchadvdaysnew' => '', 'searchadvdaysold' => '',
'searchadvgroups' => '', 'searchadvcat' => '', 'searchadvsizefrom' => '',
'searchadvsizeto' => '', 'searchadvhasnfo' => '', 'searchadvhascomments' => ''
];
foreach($searchVars as $searchVarKey => $searchVar) {
@@ -113,6 +113,7 @@ if (isset($_REQUEST["searchadvr"]) && !isset($_REQUEST["id"]) && !isset($_REQUES
($searchVars['searchadvr'] == '' ? -1 : $searchVars['searchadvr']),
($searchVars['searchadvsubject'] == '' ? -1 : $searchVars['searchadvsubject']),
($searchVars['searchadvposter'] == '' ? -1 : $searchVars['searchadvposter']),
($searchVars['searchadvfilename'] == '' ? -1 : $searchVars['searchadvfilename']),
$searchVars['searchadvgroups'], $searchVars['searchadvsizefrom'], $searchVars['searchadvsizeto'],
$searchVars['searchadvhasnfo'], $searchVars['searchadvhascomments'],
($searchVars['searchadvdaysnew'] == '' ? -1 : $searchVars['searchadvdaysnew']),
+231 -5
View File
@@ -15,9 +15,9 @@
*
* @note Developers: When updating settings.php.example, up this version
* and $current_settings_file_version in automated.config.php
* @version 3
* @version 4
*/
define('NN_SETTINGS_FILE_VERSION', 3);
define('NN_SETTINGS_FILE_VERSION', 4);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////// Web Settings //////////////////////////////////////////////////////////
@@ -539,17 +539,243 @@ define('PHPMAILER_SMTP_USER','');
*/
define('PHPMAILER_SMTP_PASSWORD', '');
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////// PHP CLI Settings ///////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if (stripos(PHP_SAPI, 'cli') !== false) {
/**
* Your server's local timezone.
* @note Uncomment to enable.
* @see https://secure.php.net/manual/en/timezones.php
* @version 4
*/
//ini_set('date.timezone', 'America/New_York');
/**
* Maximum amount of memory a PHP script can consume before being terminated.
* @note Uncomment to enable.
* @default '1024M'
* @version 4
*/
//ini_set('memory_limit', '1024M');
/**
* Show PHP errors on CLI output.
* @note Set to '1' for development.
* @default '0'
* @version 4
*/
ini_set('display_errors', '0');
/**
* Show startup errors on CLI output.
* @note Set to '1' for development/debugging.
* @default '0'
* @version 4
*/
ini_set('display_startup_errors', '0');
/**
* Type of errors to display.
* @note For development/debugging set to E_ALL
* @default E_ALL & ~E_DEPRECATED & ~E_STRICT
* @see https://secure.php.net/manual/en/errorfunc.constants.php
* @version 4
*/
ini_set('error_reporting', E_ALL & ~E_DEPRECATED & ~E_STRICT);
/**
* Turn off HTML tags in error messages.
* @default '1'
* @version 4
*/
ini_set('html_errors', '1');
/**
* Set the location to log PHP errors.
* @default NN_LOGS . 'php_errors.log'
* @note To log to syslog, put in 'syslog'
* @version 4
*/
ini_set('error_log', NN_LOGS . 'php_errors.log');
/**
* Log errors to error_log?
* @default '1'
* @version 4
*/
ini_set('log_errors', '1');
/**
* Max line length for a error.
* @default 1024
* @version 4
*/
ini_set('log_errors_max_len', '1024');
/**
* Store the last PHP error in $php_errormsg
* @default '0'
* @note This is a development/debugging option.
* @version 4
*/
ini_set('track_errors', '0');
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////// PHP Web Settings ///////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
} else {
/**
* Your server's local timezone.
* @note Uncomment to enable.
* @see https://secure.php.net/manual/en/timezones.php
* @version 4
*/
//ini_set('date.timezone', 'America/New_York');
/**
* Maximum amount of seconds a script can run before being terminated.
* @default '120'
* @version 4
*/
ini_set('max_execution_time', '120');
/**
* Maximum amount of memory a PHP script can consume before being terminated.
* @note Uncomment to enable.
* @default '1024M'
* @version 4
*/
//ini_set('memory_limit', '1024M');
/**
* Show PHP errors on web browser.
* @note Set to '1' for development.
* @default '0'
* @version 4
*/
ini_set('display_errors', '0');
/**
* Show startup errors on web browser.
* @note Set to '1' for development/debugging.
* @default '0'
* @version 4
*/
ini_set('display_startup_errors', '0');
/**
* Type of errors to display.
* @note For development/debugging set to E_ALL
* @default E_ALL & ~E_DEPRECATED & ~E_STRICT
* @see https://secure.php.net/manual/en/errorfunc.constants.php
* @version 4
*/
ini_set('error_reporting', E_ALL & ~E_DEPRECATED & ~E_STRICT);
/**
* Turn off HTML tags in error messages.
* @default '1'
* @version 4
*/
ini_set('html_errors', '1');
/**
* Set the location to log PHP errors.
* @default NN_LOGS . 'php_errors.log'
* @note To log to syslog, put in 'syslog'
* @version 4
*/
ini_set('error_log', NN_LOGS . 'php_errors.log');
/**
* Log errors to error_log?
* @default '1'
* @version 4
*/
ini_set('log_errors', '1');
/**
* Max line length for a error.
* @default 1024
* @version 4
*/
ini_set('log_errors_max_len', '1024');
/**
* Store the last PHP error in $php_errormsg
* @default '0'
* @note This is a development/debugging option.
* @version 4
*/
ini_set('track_errors', '0');
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////// PHP Xdebug Settings //////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if (extension_loaded('xdebug')) {
/**
* Display colors on xdebug CLI output?
* 0 - off, 1 - on only if on a TTY with ansi support, 2 - on regardless of TTY or ansi support.
* @default 0
* @version 4
*/
ini_set('xdebug.cli_color', '0');
/**
* Replace PHP's var_dump with xdebug's own?
* @default '1'
* @version 4
*/
ini_set('xdebug.overload_var_dump', '1');
/**
* How many items in a array or object to display on var_dump.
* @note Set to '-1' for no limit.
* @default '128'
* @version 4
*/
ini_set('xdebug.var_display_max_children', '128');
/**
* Maximum string length on var_dump. (anything over is truncated)
* @note Set to '-1' for no limit.
* @default '512'
* @version 4
*/
ini_set('xdebug.var_display_max_data', '512');
/**
* How many nested arrays / objects deep to display on var_dump.
* @note Set to '-1' for no limit.
* @note Maximum value is '1023'
* @default '3'
* @version 4
*/
ini_set('xdebug.var_display_max_depth', '3');
}
/***********************************************************************************************************************
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////// Change log ////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2015-08-26 v4 Add settings for PHP web/CLI SAPI's.
Add settings for Xdebug.
All new settings start from the "PHP CLI Settings" up to the "Change log", lines ~544 to ~768
2015-06-11 v3 Add support for APC or APCu extensions for caching data. Search for @version 3 for the changes.
2015-05-10 v2 Update path to find_password_hash_cost.php in comments. Search for @version 2 for the changes.
2015-05-03 v1 Track settings.php.example changes.
Add support for quick and low_priority on MySQL DELETE queries.
Search for @version 1 in this file to quickly find these additions.
Add support for quick and low_priority on MySQL DELETE queries.
Search for @version 1 in this file to quickly find these additions.
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/
@@ -56,6 +56,11 @@
<td><input class="searchadv" id="searchadvposter" name="searchadvposter"
value="{$searchadvposter|escape:'html'}" type="text"></td>
</tr>
<tr>
<th><label for="searchadvfilename">Filename:</label></th>
<td><input class="searchadv" id="searchadvfilename" name="searchadvfilename" value="{$searchadvfilename|escape:'html'}" type="text"/></td>
</tr>
<tr>
<tr>
<th><label for="searchadvdaysnew">Min age(days):</label></th>
<td>
@@ -42,6 +42,11 @@
<th><label for="searchadvposter">Poster:</label></th>
<td><input class="searchadv" id="searchadvposter" name="searchadvposter" value="{$searchadvposter|escape:'html'}" type="text"></td>
</tr>
<tr>
<tr>
<th><label for="searchadvfilename">Filename:</label></th>
<td><input class="searchadv" id="searchadvfilename" name="searchadvfilename" value="{$searchadvfilename|escape:'html'}" type="text"/></td>
</tr>
<tr>
<th><label for="searchadvdaysnew">Min age(days):</label></th>
<td>
@@ -56,6 +56,11 @@
<td><input class="searchadv" id="searchadvposter" name="searchadvposter"
value="{$searchadvposter|escape:'html'}" type="text"></td>
</tr>
<tr>
<th><label for="searchadvfilename">Filename:</label></th>
<td><input class="searchadv" id="searchadvfilename" name="searchadvfilename" value="{$searchadvfilename|escape:'html'}" type="text"/></td>
</tr>
<tr>
<tr>
<th><label for="searchadvdaysnew">Min age(days):</label></th>
<td>