diff --git a/misc/sphinxsearch/create_se_tables.php b/misc/sphinxsearch/create_se_tables.php index 31d96dbb3..436bdb50a 100644 --- a/misc/sphinxsearch/create_se_tables.php +++ b/misc/sphinxsearch/create_se_tables.php @@ -1,37 +1,41 @@ $query) { $pdo->queryExec(sprintf('DROP TABLE IF EXISTS %s', $table)); diff --git a/misc/sphinxsearch/optimize.php b/misc/sphinxsearch/optimize.php index 5fa12ef10..6f3d66792 100644 --- a/misc/sphinxsearch/optimize.php +++ b/misc/sphinxsearch/optimize.php @@ -1,7 +1,7 @@ optimizeRTIndex($argv[1]); diff --git a/misc/sphinxsearch/populate_rt_indexes.php b/misc/sphinxsearch/populate_rt_indexes.php index bd09982e6..0025574eb 100644 --- a/misc/sphinxsearch/populate_rt_indexes.php +++ b/misc/sphinxsearch/populate_rt_indexes.php @@ -1,48 +1,55 @@ 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 = ''; diff --git a/misc/sphinxsearch/sphinx.conf b/misc/sphinxsearch/sphinx.conf index 0d6e18503..2264120eb 100644 --- a/misc/sphinxsearch/sphinx.conf +++ b/misc/sphinxsearch/sphinx.conf @@ -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-- \ No newline at end of file diff --git a/misc/sphinxsearch/toggle_search_type.php b/misc/sphinxsearch/toggle_search_type.php index 99cf683d3..8ae65064e 100644 --- a/misc/sphinxsearch/toggle_search_type.php +++ b/misc/sphinxsearch/toggle_search_type.php @@ -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); } diff --git a/newznab/controllers/NameFixer.php b/newznab/controllers/NameFixer.php index 6be792be6..5df21192c 100644 --- a/newznab/controllers/NameFixer.php +++ b/newznab/controllers/NameFixer.php @@ -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; diff --git a/newznab/controllers/ReleaseFiles.php b/newznab/controllers/ReleaseFiles.php index 23c46cb56..30efa911e 100644 --- a/newznab/controllers/ReleaseFiles.php +++ b/newznab/controllers/ReleaseFiles.php @@ -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; } } \ No newline at end of file diff --git a/newznab/controllers/ReleaseRemover.php b/newznab/controllers/ReleaseRemover.php index 37bcc66af..2bd24131d 100644 --- a/newznab/controllers/ReleaseRemover.php +++ b/newznab/controllers/ReleaseRemover.php @@ -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)) ); } diff --git a/newznab/controllers/ReleaseSearch.php b/newznab/controllers/ReleaseSearch.php index 1bab6b9a6..e202c9f42 100644 --- a/newznab/controllers/ReleaseSearch.php +++ b/newznab/controllers/ReleaseSearch.php @@ -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; } } \ No newline at end of file diff --git a/newznab/controllers/Releases.php b/newznab/controllers/Releases.php index f65832ab3..3845f3d2a 100644 --- a/newznab/controllers/Releases.php +++ b/newznab/controllers/Releases.php @@ -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; } diff --git a/newznab/controllers/RequestIDLocal.php b/newznab/controllers/RequestIDLocal.php index 6b2e134f5..0105f8c69 100644 --- a/newznab/controllers/RequestIDLocal.php +++ b/newznab/controllers/RequestIDLocal.php @@ -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) { diff --git a/newznab/controllers/RequestIDWeb.php b/newznab/controllers/RequestIDWeb.php index 0574beb20..41572af26 100644 --- a/newznab/controllers/RequestIDWeb.php +++ b/newznab/controllers/RequestIDWeb.php @@ -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( diff --git a/newznab/controllers/SphinxSearch.php b/newznab/controllers/SphinxSearch.php index dca42f2b8..f0cc2bce9 100644 --- a/newznab/controllers/SphinxSearch.php +++ b/newznab/controllers/SphinxSearch.php @@ -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)); } } -} +} \ No newline at end of file diff --git a/newznab/processing/post/ProcessAdditional.php b/newznab/processing/post/ProcessAdditional.php index da28f546f..a86f442ce 100644 --- a/newznab/processing/post/ProcessAdditional.php +++ b/newznab/processing/post/ProcessAdditional.php @@ -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) { diff --git a/www/automated.config.php b/www/automated.config.php index 0dec13506..56cef3fd4 100644 --- a/www/automated.config.php +++ b/www/automated.config.php @@ -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 diff --git a/www/pages/api.php b/www/pages/api.php index ba775a231..a5c88be4f 100644 --- a/www/pages/api.php +++ b/www/pages/api.php @@ -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 { diff --git a/www/pages/search.php b/www/pages/search.php index f99cd9386..e6323ce65 100644 --- a/www/pages/search.php +++ b/www/pages/search.php @@ -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']), diff --git a/www/settings.example.php b/www/settings.example.php index fc6ba1b55..8261c002c 100644 --- a/www/settings.example.php +++ b/www/settings.example.php @@ -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. -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/ \ No newline at end of file +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/ diff --git a/www/templates/charisma/views/frontend/search.tpl b/www/templates/charisma/views/frontend/search.tpl index 3b3502638..5efd05cd2 100644 --- a/www/templates/charisma/views/frontend/search.tpl +++ b/www/templates/charisma/views/frontend/search.tpl @@ -56,6 +56,11 @@