From dfec9156dd830ec30a13f89e511fec8ad8b6088f Mon Sep 17 00:00:00 2001 From: Darko Date: Thu, 26 Feb 2015 10:16:53 +0100 Subject: [PATCH] Add DB based collection regexes and import count for nzbs. --- lib/DB/patches/0114~collection_regexes.sql | 64 ++++ lib/DB/patches/0115~tmux.sql | 2 + lib/copy_this/www/admin/ajax_regex.php | 26 ++ .../www/admin/collection_regexes-edit.php | 61 ++++ .../www/admin/collection_regexes-list.php | 29 ++ .../www/admin/collection_regexes-test.php | 30 ++ lib/copy_this/www/lib/CollectionsCleaning.php | 280 +++++++++++++++++- lib/copy_this/www/lib/Tmux.php | 1 + lib/copy_this/www/lib/TmuxOutput.php | 2 +- lib/copy_this/www/lib/TmuxRun.php | 2 +- lib/copy_this/www/lib/binaries.php | 2 +- .../templates/nntmux/scripts/utils-admin.js | 26 +- .../nntmux/views/admin/adminmenu.tpl | 7 + .../views/admin/collection_regexes-edit.tpl | 74 +++++ .../views/admin/collection_regexes-list.tpl | 43 +++ .../views/admin/collection_regexes-test.tpl | 44 +++ .../nntmux/views/admin/tmux-edit.tpl | 10 +- 17 files changed, 696 insertions(+), 7 deletions(-) create mode 100644 lib/DB/patches/0114~collection_regexes.sql create mode 100644 lib/DB/patches/0115~tmux.sql create mode 100644 lib/copy_this/www/admin/ajax_regex.php create mode 100644 lib/copy_this/www/admin/collection_regexes-edit.php create mode 100644 lib/copy_this/www/admin/collection_regexes-list.php create mode 100644 lib/copy_this/www/admin/collection_regexes-test.php create mode 100644 lib/copy_this/www/templates/nntmux/views/admin/collection_regexes-edit.tpl create mode 100644 lib/copy_this/www/templates/nntmux/views/admin/collection_regexes-list.tpl create mode 100644 lib/copy_this/www/templates/nntmux/views/admin/collection_regexes-test.tpl diff --git a/lib/DB/patches/0114~collection_regexes.sql b/lib/DB/patches/0114~collection_regexes.sql new file mode 100644 index 000000000..5a5417568 --- /dev/null +++ b/lib/DB/patches/0114~collection_regexes.sql @@ -0,0 +1,64 @@ +DROP TABLE IF EXISTS collection_regexes; +CREATE TABLE collection_regexes ( + id INT UNSIGNED NOT NULL AUTO_INCREMENT, + group_regex VARCHAR(255) NULL COMMENT 'This is a regex to match against usenet groups', + regex VARCHAR(5000) NOT NULL COMMENT 'Regex used for collection grouping', + status TINYINT(1) UNSIGNED NOT NULL DEFAULT '1' COMMENT '1=ON 0=OFF', + description VARCHAR(1000) NOT NULL COMMENT 'Optional extra details on this regex', + ordinal INT SIGNED NOT NULL DEFAULT '0' COMMENT 'Order to run the regex in', + PRIMARY KEY (id), + INDEX ix_collection_regexes_group_regex (group_regex), + INDEX ix_collection_regexes_status (status), + INDEX ix_collection_regexes_ordinal (ordinal) +) + ENGINE = MYISAM + DEFAULT CHARSET = utf8 + COLLATE = utf8_unicode_ci + AUTO_INCREMENT = 100000; + +INSERT INTO collection_regexes (id, group_regex, regex, status, description, ordinal) + VALUES ( + 1, + 'alt\\.binaries\\.teevee', + '/(?P\\[[\\d#]+\\]-\\[.+?\\]-\\[.+?\\])-\\[ (?P.+?) \\][- ]\\[\\d+\\/\\d+\\] - ".+?" yEnc$/i', + 1, + '[278997]-[FULL]-[#a.b.erotica]-[ chi-the.walking.dead.xxx ]-[06/51] - "chi-the.walking.dead.xxx-s.mp4" yEnc ::: [######]-[FULL]-[#a.b.teevee@EFNet]-[ Misfits.S01.SUBPACK.DVDRip.XviD-P0W4DVD ] [1/5] - "Misfits.S01.SUBPACK.DVDRip.XviD-P0W4DVD.nfo" yEnc ::: Re: [147053]-[FULL]-[#a.b.teevee]-[ Top_Gear.20x04.HDTV_x264-FoV ]-[11/59] - "top_gear.20x04.hdtv_x264-fov.r00" yEnc', + 0 +), ( + 2, + 'alt\\.binaries\\.teevee', + '/(?P\\[[\\d#]+\\]-\\[.+?\\]-\\[.+?\\])-\\[ (?P.+?) \\][ -]{0,3}".+?" yEnc$/i', + 1, + '[185409]-[FULL]-[a.b.teeveeEFNet]-[ Dragon.Ball.Z.S03E24.1080p.WS.BluRay.x264-CCAT ]-"dragon.ball.z.s03e24.1080p.ws.bluray.x264-ccat.nfo" yEnc', + 1 +), ( + 3, + 'alt\\.binaries\\.teevee', + '/^(?P\\[#a\\.b\\.teevee\\] .+? - \\[)\\d+\\/\\d+\\] - ".+?" yEnc$/', + 1, + '[#a.b.teevee] Parks.and.Recreation.S01E01.720p.WEB-DL.DD5.1.H.264-CtrlHD - [01/24] - "Parks.and.Recreation.S01E01.720p.WEB-DL.DD5.1.H.264-CtrlHD.nfo"', + 2 +), ( + 4, + 'alt\\.binaries\\.teevee', + '/^(?P[a-z0-9]+ - )\\[\\d+\\/\\d+\\] - "[a-z0-9]+\\..+?" yEnc$/', + 1, + 'ah63jka93jf0jh26ahjas558 - [01/22] - "ah63jka93jf0jh26ahjas558.par2" yEnc', + 3 +), ( + 5, + 'alt\\.binaries\\.teevee', + '/^(?P[a-z0-9]+ \\()\\d+\\/\\d+\\) ".+?" - \\d+[,.]\\d+ [mMkKgG][bB] - yEnc$/', + 1, + 'fhdbg34rgjdsfd008c (42/43) "fhdbg34rgjdsfd008c.vol062+64.par2" - 3,68 GB - yEnc', + 4 +), ( + 6, + 'alt\\.binaries\\.teevee', + '/^(?P[a-zA-Z0-9]+)\\[\\d+\\/\\d+\\] - ".+?" yEnc$/', + 1, + 't2EI3CdWdF0hi5b8L9tkx[08/52] - "t2EI3CdWdF0hi5b8L9tkx.part07.rar" yEnc', + 5 +); + +UPDATE `tmux` SET `value` = '114' WHERE `setting` = 'sqlpatch'; \ No newline at end of file diff --git a/lib/DB/patches/0115~tmux.sql b/lib/DB/patches/0115~tmux.sql new file mode 100644 index 000000000..c5d09ffbb --- /dev/null +++ b/lib/DB/patches/0115~tmux.sql @@ -0,0 +1,2 @@ +INSERT IGNORE INTO `tmux` (`setting`, `value`) VALUES ('import_count','50000'); +UPDATE `tmux` SET `value` = '115' WHERE `setting` = 'sqlpatch'; \ No newline at end of file diff --git a/lib/copy_this/www/admin/ajax_regex.php b/lib/copy_this/www/admin/ajax_regex.php new file mode 100644 index 000000000..dcae8a6e6 --- /dev/null +++ b/lib/copy_this/www/admin/ajax_regex.php @@ -0,0 +1,26 @@ + $admin->settings]))->deleteRegex($id); + print "Regex $id deleted."; + break; + + case 2: + $id = (int) $_GET['bin_id']; + (new Binaries(['Settings' => $admin->settings]))->deleteBlacklist($id); + print "Blacklist $id deleted."; + break; +} \ No newline at end of file diff --git a/lib/copy_this/www/admin/collection_regexes-edit.php b/lib/copy_this/www/admin/collection_regexes-edit.php new file mode 100644 index 000000000..56e067b8d --- /dev/null +++ b/lib/copy_this/www/admin/collection_regexes-edit.php @@ -0,0 +1,61 @@ + $page->settings]); + +// Set the current action. +$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'view'; + +switch($action) { + case 'submit': + if ($_POST["group_regex"] == "") { + $page->smarty->assign('error', "Group regex must not be empty!"); + break; + } + + if ($_POST["regex"] == "") { + $page->smarty->assign('error', "Regex cannot be empty"); + break; + } + + if ($_POST['description'] == '') { + $_POST['description'] = ''; + } + + if (!is_numeric($_POST['ordinal']) || $_POST['ordinal'] < 0) { + $page->smarty->assign('error', "Ordinal must be a number, 0 or higher."); + break; + } + + if ($_POST["id"] == "") { + $cc->addRegex($_POST); + } else { + $cc->updateRegex($_POST); + } + + header("Location:".WWW_TOP."/collection_regexes-list.php"); + break; + + case 'view': + default: + if (isset($_GET["id"])) { + $page->title = "Collections Regex Edit"; + $id = $_GET["id"]; + $r = $cc->getRegexByID($id); + } else { + $page->title = "Collections Regex Add"; + $r = ['status' => 1]; + } + $page->smarty->assign('regex', $r); + break; +} + +$page->smarty->assign('status_ids', array(Category::STATUS_ACTIVE,Category::STATUS_INACTIVE)); +$page->smarty->assign('status_names', array( 'Yes', 'No')); + +$page->content = $page->smarty->fetch('collection_regexes-edit.tpl'); +$page->render(); \ No newline at end of file diff --git a/lib/copy_this/www/admin/collection_regexes-list.php b/lib/copy_this/www/admin/collection_regexes-list.php new file mode 100644 index 000000000..97a51cac7 --- /dev/null +++ b/lib/copy_this/www/admin/collection_regexes-list.php @@ -0,0 +1,29 @@ + $page->settings]); + +$page->title = "Collections Regex List"; + +$group = ''; +if (isset($_REQUEST['group']) && !empty($_REQUEST['group'])) { + $group = $_REQUEST['group']; +} + +$offset = isset($_REQUEST["offset"]) ? $_REQUEST["offset"] : 0; +$regex = $cc->getRegex($group, ITEMS_PER_PAGE, $offset); +$page->smarty->assign('regex', $regex); + +$count = $cc->getCount($group); +$page->smarty->assign('pagertotalitems', $count); +$page->smarty->assign('pageroffset', $offset); +$page->smarty->assign('pageritemsperpage', ITEMS_PER_PAGE); + +$page->smarty->assign('pagerquerybase', WWW_TOP . "/collection_regexes-list.php?" . $group . "offset="); +$page->smarty->assign('pager', $page->smarty->fetch("pager.tpl")); + +$page->content = $page->smarty->fetch('collection_regexes-list.tpl'); +$page->render(); \ No newline at end of file diff --git a/lib/copy_this/www/admin/collection_regexes-test.php b/lib/copy_this/www/admin/collection_regexes-test.php new file mode 100644 index 000000000..febb2c587 --- /dev/null +++ b/lib/copy_this/www/admin/collection_regexes-test.php @@ -0,0 +1,30 @@ +get(); + +$page->title = "Collections Regex Test"; + +$tpg = $page->site->tablepergroup; +$page->smarty->assign('tpg', $tpg); + +if ($tpg) { + + $group = trim(isset($_POST['group']) && !empty($_POST['group']) ? $_POST['group'] : ''); + $regex = trim(isset($_POST['regex']) && !empty($_POST['regex']) ? $_POST['regex'] : ''); + $limit = (isset($_POST['limit']) && is_numeric($_POST['limit']) ? $_POST['limit'] : 50); + $page->smarty->assign(['group' => $group, 'regex' => $regex, 'limit' => $limit]); + + if ($group && $regex) { + $page->smarty->assign('data', (new CollectionsCleaning(['Settings' => $page->settings]))->testRegex($group, $regex, $limit)); + } + +} + +$page->content = $page->smarty->fetch('collection_regexes-test.tpl'); +$page->render(); \ No newline at end of file diff --git a/lib/copy_this/www/lib/CollectionsCleaning.php b/lib/copy_this/www/lib/CollectionsCleaning.php index 5c5c22379..642e0290d 100644 --- a/lib/copy_this/www/lib/CollectionsCleaning.php +++ b/lib/copy_this/www/lib/CollectionsCleaning.php @@ -55,14 +55,208 @@ class CollectionsCleaning public $subject = ''; /** - * + * @var \DB */ - public function __construct() + public $pdo; + + /** + * @var array Cache of regex and their TTL. + */ + protected $_regexCache; + + /** + * @param array $options Class instances. + */ + public function __construct(array $options = array()) { // Extensions. $this->e0 = self::REGEX_FILE_EXTENSIONS; $this->e1 = self::REGEX_FILE_EXTENSIONS . self::REGEX_END; $this->e2 = self::REGEX_FILE_EXTENSIONS . self::REGEX_SUBJECT_SIZE . self::REGEX_END; + + $defaults = [ + 'Settings' => null, + ]; + $options += $defaults; + + $this->pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB()); + } + + /** + * Add a new regex. + * + * @param array $data + * + * @return bool + */ + public function addRegex(array $data) + { + return (bool)$this->pdo->queryInsert( + sprintf( + 'INSERT INTO collection_regexes (group_regex, regex, status, description, ordinal) VALUES (%s, %s, %d, %s, %d)', + trim($this->pdo->escapeString($data['group_regex'])), + trim($this->pdo->escapeString($data['regex'])), + $data['status'], + trim($this->pdo->escapeString($data['description'])), + $data['ordinal'] + ) + ); + } + + /** + * Update a regex with new info. + * + * @param array $data + * + * @return bool + */ + public function updateRegex(array $data) + { + return (bool)$this->pdo->queryExec( + sprintf( + 'UPDATE collection_regexes + SET group_regex = %s, regex = %s, status = %d, description = %s, ordinal = %d + WHERE id = %d', + trim($this->pdo->escapeString($data['group_regex'])), + trim($this->pdo->escapeString($data['regex'])), + $data['status'], + trim($this->pdo->escapeString($data['description'])), + $data['ordinal'], + $data['id'] + ) + ); + } + + /** + * Get a single regex using its id. + * + * @param int $id + * + * @return array + */ + public function getRegexByID($id) + { + return $this->pdo->queryOneRow(sprintf('SELECT * FROM collection_regexes WHERE id = %d', $id)); + } + + /** + * Get all regex. + * + * @param string $group_regex Optional, a keyword to find a group. + * @param int $limit Optional, amount of results to limit. + * @param int $offset Optional, the offset to use when limiting the result set. + * + * @return array + */ + public function getRegex($group_regex = '', $limit = 0, $offset = 0) + { + return $this->pdo->query( + sprintf( + 'SELECT * FROM collection_regexes %s %s', + ($group_regex ? ('WHERE group_regex ' . $this->pdo->likeString($group_regex)) : ''), + ($limit ? ('LIMIT ' . $limit . ' OFFSET ' . $offset) : '') + ) + ); + } + + /** + * Get the count of regex in the DB. + * + * @param string $group_regex Optional, keyword to find a group. + * + * @return int + */ + public function getCount($group_regex = '') + { + $query = $this->pdo->queryOneRow( + sprintf( + 'SELECT COUNT(id) AS count FROM collection_regexes %s', + ($group_regex ? ('WHERE group_regex ' . $this->pdo->likeString($group_regex)) : '') + ) + ); + return (int)$query['count']; + } + + /** + * Delete a regex using its id. + * + * @param int $id + */ + public function deleteRegex($id) + { + $this->pdo->queryExec('DELETE FROM collection_regexes WHERE id = ' . $id); + } + + /** + * Test a regex for a group name. + * + * Requires table per group to be on. + * + * @param string $groupName + * @param string $regex + * @param int $limit + * + * @return array + */ + public function testRegex($groupName, $regex, $limit) + { + $groups = new Groups(['Settings' => $this->pdo]); + $groupID = $groups->getIDByName($groupName); + + if (!$groupID) { + return []; + } + + $tableNames = $groups->getCBPTableNames(true, $groupID); + + $rows = $this->pdo->query( + sprintf( + 'SELECT + b.name, b.totalparts, b.currentparts, b.binaryhash, + c.fromname, c.collectionhash + FROM %s b + INNER JOIN %s c ON c.id = b.collection_id', + $tableNames['bname'], $tableNames['cname'] + ) + ); + + $data = []; + if ($rows) { + $limit--; + $hashes = []; + foreach ($rows as $row) { + if (preg_match($regex, $row['name'], $matches)) { + ksort($matches); + $string = $string2 = ''; + foreach ($matches as $key => $match) { + if (!is_int($key)) { + $string .= $match; + $string2 .= '
' . $key . ': ' . $match; + } + } + $files = 0; + if (preg_match('/[[(\s](\d{1,5})(\/|[\s_]of[\s_]|-)(\d{1,5})[])\s$:]/i', $row['name'], $fileCount)) { + $files = $fileCount[3]; + } + $newCollectionHash = sha1($string . $row['fromname'] . $groupID . $files); + $data['New hash: ' . $newCollectionHash . $string2][$row['binaryhash']] = [ + 'file_name' => $row['name'], + 'file_total_parts' => $row['totalparts'], + 'file_current_parts' => $row['currentparts'], + 'collection_poster' => $row['fromname'], + 'old_collection_hash' => $row['collectionhash'], + ]; + + if ($limit > 0) { + if (count($hashes) > $limit) { + break; + } + $hashes[$newCollectionHash] = ''; + } + } + } + } + return $data; } /** @@ -77,6 +271,13 @@ class CollectionsCleaning { $this->subject = $subject; $this->groupName = $groupName; + + // Try DB regex first. + $potentialString = $this->_processDBRegex(); + if ($potentialString) { + return $potentialString; + } + switch ($groupName) { case 'alt.binaries.0day.stuffz': return $this->_0daystuffz(); @@ -271,6 +472,81 @@ class CollectionsCleaning } } + /** + * Get the regex from the DB, cache them locally for 15 mins. + * Cache them also in the cache server, as this script might be terminated. + */ + protected function _fetchRegex() + { + // Check if we need to do an initial cache or refresh our cache. + if (isset($this->_regexCache[$this->groupName]['ttl']) && (time() - $this->_regexCache[$this->groupName]['ttl']) < 900) { + return; + } + + // Get all regex from DB which match the current group name. Cache them for 15 minutes. #CACHEDQUERY# + $this->_regexCache[$this->groupName]['regex'] = $this->pdo->query( + sprintf( + 'SELECT c.regex FROM collection_regexes c WHERE %s REGEXP c.group_regex AND c.status = 1 ORDER BY c.ordinal ASC, c.group_regex ASC', + $this->pdo->escapeString($this->groupName) + ), true, 900 + ); + // Set the TTL. + $this->_regexCache[$this->groupName]['ttl'] = time(); + } + + /** + * This will process the regex stored in the DB before trying hardcoded regex below. + * + * @return string + */ + protected function _processDBRegex() + { + $this->_fetchRegex(); + + $returnString = ''; + // If there are no regex, return and try regex in this file. + if ($this->_regexCache[$this->groupName]['regex']) { + foreach ($this->_regexCache[$this->groupName]['regex'] as $regex) { + + $returnString = $this->_matchDBRegex($regex['regex']); + // If this regex found something, break and return, or else continue trying other regex. + if ($returnString) { + break; + } + } + } + return $returnString; + } + + /** + * Find matches on a regex taken from the database. + * + * Requires at least 1 named captured group. + * + * @param string $regex + * + * @return string + */ + protected function _matchDBRegex($regex) + { + $returnString = ''; + if (preg_match($regex, $this->subject, $matches)) { + if (count($matches) > 0) { + // Sort the keys, the named key matches will be concatenated in this order. + ksort($matches); + foreach ($matches as $key => $value) { + // Ignore non-named capture groups. Only named capture groups are important. + if (is_int($key)) { + continue; + } + // Concatenate the string to return. + $returnString .= $value; + } + } + } + return $returnString; + } + // a.b.0daystuffz protected function _0daystuffz() { diff --git a/lib/copy_this/www/lib/Tmux.php b/lib/copy_this/www/lib/Tmux.php index 4a6756536..ce48c4570 100644 --- a/lib/copy_this/www/lib/Tmux.php +++ b/lib/copy_this/www/lib/Tmux.php @@ -212,6 +212,7 @@ class Tmux (%1\$s 'seq_timer') AS seq_timer, (%1\$s 'bins_timer') AS bins_timer, (%1\$s 'back_timer') AS back_timer, + (%1\$s 'import_count') AS import_count, (%1\$s 'import_timer') AS import_timer, (%1\$s 'rel_timer') AS rel_timer, (%1\$s 'fix_timer') AS fix_timer, diff --git a/lib/copy_this/www/lib/TmuxOutput.php b/lib/copy_this/www/lib/TmuxOutput.php index 24766e5ef..cb714b55e 100644 --- a/lib/copy_this/www/lib/TmuxOutput.php +++ b/lib/copy_this/www/lib/TmuxOutput.php @@ -117,7 +117,7 @@ class TmuxOutput extends Tmux $buffer = ''; $state = ($this->runVar['settings']['is_running'] == 1) ? 'Running' : 'Disabled'; //$version = $this->_tvers . 'r' . $this->_vers; - $tversion = '0.6r0046'; + $tversion = '0.6r0052'; $buffer .= sprintf($this->tmpMasks[2], "Monitor $state v$tversion @ $this->_tvers [" . $this->_vers ."]: ", diff --git a/lib/copy_this/www/lib/TmuxRun.php b/lib/copy_this/www/lib/TmuxRun.php index dfe3b3797..3c5501ba7 100644 --- a/lib/copy_this/www/lib/TmuxRun.php +++ b/lib/copy_this/www/lib/TmuxRun.php @@ -357,7 +357,7 @@ class TmuxRun extends Tmux if (($runVar['settings']['import'] != 0) && ($runVar['killswitch']['pp'] == false)) { $log = $this->writelog($runVar['panes']['zero'][1]); shell_exec("tmux respawnp -t{$runVar['constants']['tmux_session']}:0.1 ' \ - {$runVar['commands']['_phpn']} {$runVar['paths']['misc']}update_scripts/nix_scripts/multiprocessing/import.php {$runVar['settings']['nzbs']} {$runVar['settings']['nzbthreads']} true {$useFilenames} false $log; \ + {$runVar['commands']['_phpn']} {$runVar['paths']['misc']}update/nix/multiprocessing/import.php {$runVar['settings']['nzbs']} {$runVar['settings']['nzbthreads']} true true {$useFilenames} {$runVar['settings']['import_count']} $log; \ date +\"{$this->_dateFormat}\"; {$runVar['commands']['_sleep']} {$runVar['settings']['import_timer']}' 2>&1 1> /dev/null" ); diff --git a/lib/copy_this/www/lib/binaries.php b/lib/copy_this/www/lib/binaries.php index f5fbc35f0..dd7aeb5aa 100644 --- a/lib/copy_this/www/lib/binaries.php +++ b/lib/copy_this/www/lib/binaries.php @@ -181,7 +181,7 @@ class Binaries $this->_groups = ($options['Groups'] instanceof \Groups ? $options['Groups'] : new \Groups(['Settings' => $this->_pdo])); $this->_colorCLI = ($options['ColorCLI'] instanceof \ColorCLI ? $options['ColorCLI'] : new \ColorCLI()); $this->_nntp = ($options['NNTP'] instanceof \NNTP ? $options['NNTP'] : new \NNTP(['Echo' => $this->_colorCLI, 'Settings' => $this->_pdo, 'ColorCLI' => $this->_colorCLI])); - $this->_collectionsCleaning = ($options['CollectionsCleaning'] instanceof \CollectionsCleaning ? $options['CollectionsCleaning'] : new \CollectionsCleaning()); + $this->_collectionsCleaning = ($options['CollectionsCleaning'] instanceof \CollectionsCleaning ? $options['CollectionsCleaning'] : new \CollectionsCleaning(['Settings' => $this->_pdo])); $this->_debug = (NN_DEBUG || NN_LOGGING); diff --git a/lib/copy_this/www/templates/nntmux/scripts/utils-admin.js b/lib/copy_this/www/templates/nntmux/scripts/utils-admin.js index 4e6a37024..ab860f630 100644 --- a/lib/copy_this/www/templates/nntmux/scripts/utils-admin.js +++ b/lib/copy_this/www/templates/nntmux/scripts/utils-admin.js @@ -389,7 +389,7 @@ function ajax_sharing_toggle_all(status) $.ajax({ url : WWW_TOP + '/admin/ajax_sharing_settings.php?rand=' + rand_no, data : { toggle_all: status }, - dataType : "html", + dataType : "html" }); } else @@ -631,6 +631,30 @@ function ajax_welcome_msg(bln) }); } +/** + * ajax_collection_regex_delete() + * + * @param id binary id + */ +function ajax_collection_regex_delete(id) +{ + // no caching of results + var rand_no = Math.random(); + $.ajax({ + url : WWW_TOP + '/admin/ajax_regex.php?action=1&rand=' + rand_no, + data : { col_id: id}, + dataType : "html", + success : function(data) + { + $('div#message').html(data); + $('div#message').show('fast', function() {}); + $('#row-'+id).fadeOut(2000); + $('#message').fadeOut(5000); + }, + error: function(xhr,err,e) { alert( "Error in ajax_collection_regex_delete: " + err ); } + }); +} + jQuery(function($){ $('#regexGroupSelect').change(function() { diff --git a/lib/copy_this/www/templates/nntmux/views/admin/adminmenu.tpl b/lib/copy_this/www/templates/nntmux/views/admin/adminmenu.tpl index a9bbd9c4b..7e14f8b6a 100644 --- a/lib/copy_this/www/templates/nntmux/views/admin/adminmenu.tpl +++ b/lib/copy_this/www/templates/nntmux/views/admin/adminmenu.tpl @@ -8,6 +8,13 @@
  • Edit Categories
  • View Add BulkAdd Groups
  • View Add Test Send Regex
  • +
  • Collections + +
  • View Add Blacklist
  • View Releases
  • View Previews
  • diff --git a/lib/copy_this/www/templates/nntmux/views/admin/collection_regexes-edit.tpl b/lib/copy_this/www/templates/nntmux/views/admin/collection_regexes-edit.tpl new file mode 100644 index 000000000..5fc72212c --- /dev/null +++ b/lib/copy_this/www/templates/nntmux/views/admin/collection_regexes-edit.tpl @@ -0,0 +1,74 @@ +

    {$page->title}

    +{if $error != ''} +
    {$error}
    +{/if} +
    + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + +
    + Regex to match against a group or multiple groups.
    + Delimiters are already added, and PCRE_CASELESS is added after for case insensitivity. + An example of matching a single group: alt\.binaries\.example
    + An example of matching multiple groups: alt\.binaries.* +
    +
    + +
    + The regex to use when matching (grouping) collections.
    + The regex delimiters are not added, you MUST add them. See this page.
    + To make the regex case insensitive, add i after the last delimiter.
    + You MUST include at least one regex capture group.
    + You MUST name your regex capture groups.
    + A string will be created from your matched capture groups.
    + The string will form part of a "collection hash".
    + The collection hash is used to group many parts together, to form the finalized release.
    + The usenet group and name of the poster are added automatically when hashing.
    + Capture groups are sorted alphabetically (by capture group name) when concatenating the string.
    + The regex search will be done case insensitive. +
    +
    + +
    + Description for this regex.
    + You can include an example usenet subject this regex would match on. +
    +
    + +
    + The order to run this regex in.
    + Must be a number, 0 or higher.
    + If multiple regex have the same ordinal, MySQL will randomly sort them. +
    +
    + {html_radios id="status" name='status' values=$status_ids output=$status_names selected=$regex.status separator='
    '} +
    Only active regex are used during the collection matching process.
    +
    + +
    +
    \ No newline at end of file diff --git a/lib/copy_this/www/templates/nntmux/views/admin/collection_regexes-list.tpl b/lib/copy_this/www/templates/nntmux/views/admin/collection_regexes-list.tpl new file mode 100644 index 000000000..1d4c56f9a --- /dev/null +++ b/lib/copy_this/www/templates/nntmux/views/admin/collection_regexes-list.tpl @@ -0,0 +1,43 @@ +

    {$page->title}

    +

    This page lists regex used for grouping usenet collections.

    +
    + +
    + + +    + +
    +{if $regex} + +
    {$pager}
    + + + + + + + + + + + + {foreach from=$regex item=row} + + + + + + + + {if $row.status==1} + + {else} + + {/if} + + + {/foreach} +
    idgroupeditdescriptiondeleteordinalstatusregex
    {$row.id}{$row.group_regex}Edit{$row.description|truncate:50:"...":true}Delete{$row.ordinal}ActiveDisabled{$row.regex|escape:html|truncate:50:"...":true}
    +
    {$pager}
    +{/if} \ No newline at end of file diff --git a/lib/copy_this/www/templates/nntmux/views/admin/collection_regexes-test.tpl b/lib/copy_this/www/templates/nntmux/views/admin/collection_regexes-test.tpl new file mode 100644 index 000000000..0c5738543 --- /dev/null +++ b/lib/copy_this/www/templates/nntmux/views/admin/collection_regexes-test.tpl @@ -0,0 +1,44 @@ +

    {$page->title}

    +

    This page is used for testing regex for grouping usenet collections.
    Enter the group name to test and a regex. Limit is how many collections to show max on the page, 0 for no limit(slow).

    + +{if $tpg} +
    + +
    + +
    + +
    + +
    + {if $data} + + {foreach from=$data key=hash item=collection} + + + + +
    {$hash}
    Current Files: {count($collection)}
    + + + + + + + + + {foreach from=$collection item=row} + + + + + + + + {/foreach} +
    namecurrent partstotal partsposterold hash
    {$row.file_name}{$row.file_current_parts}{$row.file_total_parts}{$row.collection_poster}{$row.old_collection_hash}
    + {/foreach} + {/if} +{else} +

    The Table Per Group setting is required to be on to use this page, for performance reasons.

    +{/if} \ No newline at end of file diff --git a/lib/copy_this/www/templates/nntmux/views/admin/tmux-edit.tpl b/lib/copy_this/www/templates/nntmux/views/admin/tmux-edit.tpl index c5ca1a010..210f750c4 100644 --- a/lib/copy_this/www/templates/nntmux/views/admin/tmux-edit.tpl +++ b/lib/copy_this/www/templates/nntmux/views/admin/tmux-edit.tpl @@ -293,7 +293,7 @@ - + @@ -304,6 +304,14 @@ + + + + +
    How many NZB files to import per process.
    + + +