/** * Cleans a usenet subject returning a string that can be used to "merge" files together, a pretty subject, a categoryID and the name status. * * @param string $subject Subject to parse. * @param string $groupName Group to work in. * * @return string */ public function collectionsCleaner($subject, $groupName) { $this->subject = $subject; $this->groupName = $groupName; // Try DB regex first. $potentialString = $this->_regexes->tryRegex($subject, $groupName); if ($potentialString) { return $potentialString; } switch ($groupName) { /* case 'alt.binaries.this.is.an.example': return $this->_example_method_name(); */ case null: default: return $this->generic(); } }
<?php require_once './config.php'; use nzedb\Category; use nzedb\Regexes; $page = new AdminPage(); $regexes = new Regexes(['Settings' => $page->settings, 'Table_Name' => 'collection_regexes']); // 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"] == "") { $regexes->addRegex($_POST); } else { $regexes->updateRegex($_POST); }
<?php require_once './config.php'; use nzedb\Regexes; $page = new AdminPage(); $regexes = new Regexes(['Settings' => $page->settings, 'Table_Name' => 'category_regexes']); $page->title = "Category Regex List"; $group = isset($_REQUEST['group']) && !empty($_REQUEST['group']) ? $_REQUEST['group'] : ''; $offset = isset($_REQUEST["offset"]) ? $_REQUEST["offset"] : 0; $regex = $regexes->getRegex($group, ITEMS_PER_PAGE, $offset); $count = $regexes->getCount($group); $page->smarty->assign(['pagertotalitems' => $count, 'pageroffset' => $offset, 'pageritemsperpage' => ITEMS_PER_PAGE, 'regex' => $regex, 'pagerquerybase' => WWW_TOP . "/category_regexes-list.php?" . $group . "offset=", 'pager' => $page->smarty->fetch("pager.tpl")]); $page->content = $page->smarty->fetch('category_regexes-list.tpl'); $page->render();
<?php require_once './config.php'; use nzedb\Category; use nzedb\Regexes; $page = new AdminPage(); $regexes = new Regexes(['Settings' => $page->settings, 'Table_Name' => 'release_naming_regexes']); $error = ''; $regex = ['id' => '', 'group_regex' => '', 'regex' => '', 'description' => '', 'ordinal' => '']; switch (isset($_REQUEST['action']) ? $_REQUEST['action'] : 'view') { case 'submit': if ($_POST["group_regex"] == '') { $error = "Group regex must not be empty!"; break; } if ($_POST["regex"] == '') { $error = "Regex cannot be empty"; break; } if ($_POST['description'] == '') { $_POST['description'] = ''; } if (!is_numeric($_POST['ordinal']) || $_POST['ordinal'] < 0) { $error = "Ordinal must be a number, 0 or higher."; break; } if ($_POST["id"] == '') { $regexes->addRegex($_POST); } else { $regexes->updateRegex($_POST); }
public function releaseCleaner($subject, $fromName, $size, $groupName, $usepre = false) { $match = $matches = []; $this->groupName = $groupName; $this->subject = $subject; $this->fromName = $fromName; $this->size = $size; // Get pre style name from releases.name if (preg_match_all('/([\\w\\(\\)]+[\\s\\._-]([\\w\\(\\)]+[\\s\\._-])+[\\w\\(\\)]+-\\w+)/', $this->subject, $matches)) { foreach ($matches as $match) { foreach ($match as $val) { $title = $this->pdo->queryOneRow("SELECT title, id from predb WHERE title = " . $this->pdo->escapeString(trim($val))); // don't match against ab.teevee if title is for just the season if ($this->groupName == 'alt.binaries.teevee' and preg_match('/\\.S\\d\\d\\./', $title['title'], $match)) { $title = false; } if ($title !== false) { return ["cleansubject" => $title['title'], "properlynamed" => true, "increment" => false, "predb" => $title['id'], "requestid" => false]; } } } } // Get pre style name from requestid if (preg_match('/^\\[ ?(\\d{4,6}) ?\\]/', $this->subject, $match) || preg_match('/^REQ\\s*(\\d{4,6})/i', $this->subject, $match) || preg_match('/^(\\d{4,6})-\\d{1}\\[/', $this->subject, $match) || preg_match('/(\\d{4,6}) -/', $this->subject, $match)) { $title = $this->pdo->queryOneRow(sprintf('SELECT p.title , p.id from predb p INNER JOIN groups g on g.id = p.group_id WHERE p.requestid = %d and g.name = %s', $match[1], $this->pdo->escapeString($this->groupName))); //check for predb title matches against other groups where it matches relative size / fromname //known crossposted requests only atm $reqGname = ''; switch ($this->groupName) { case 'alt.binaries.etc': if ($this->fromName === 'kingofpr0n (brian@iamking.ws)') { $reqGname = 'alt.binaries.teevee'; } break; case 'alt.binaries.mom': if ($this->fromName === 'Yenc@power-post.org (Yenc-PP-A&A)' || $this->fromName === 'yEncBin@Poster.com (yEncBin)') { $reqGname = 'alt.binaries.moovee'; } break; case 'alt.binaries.hdtv.x264': if ($this->fromName === 'moovee@4u.tv (moovee)') { $reqGname = 'alt.binaries.moovee'; } break; } if ($title === false && !empty($reqGname)) { $title = $this->pdo->queryOneRow(sprintf("SELECT p.title as title, p.id as id from predb p INNER JOIN groups g on g.id = p.group_id\n\t\t\t\t\t\t\t\tWHERE p.requestid = %d and g.name = %s", $match[1], $this->pdo->escapeString($reqGname))); } // don't match against ab.teevee if title is for just the season if ($this->groupName == 'alt.binaries.teevee' and preg_match('/\\.S\\d\\d\\./', $title['title'], $match)) { $title = false; } if ($title !== false) { return ["cleansubject" => $title['title'], "properlynamed" => true, "increment" => false, "predb" => $title['id'], "requestid" => true]; } } if ($usepre === true) { return false; } // Try DB regex. $potentialName = $this->_regexes->tryRegex($subject, $groupName); if ($potentialName) { return $potentialName; } //if www.town.ag releases check against generic_town regexes if (preg_match('/www\\.town\\.ag/i', $this->subject)) { return $this->generic_town(); } switch ($groupName) { case 'alt.binaries.teevee': return $this->teevee(); default: return $this->generic(); } }
<?php require_once './config.php'; use nzedb\Regexes; $page = new AdminPage(); $regexes = new Regexes(['Settings' => $page->settings, 'Table_Name' => 'release_naming_regexes']); $page->title = "Release Naming Regex List"; $group = isset($_REQUEST['group']) && !empty($_REQUEST['group']) ? $_REQUEST['group'] : ''; $offset = isset($_REQUEST["offset"]) ? $_REQUEST["offset"] : 0; $regex = $regexes->getRegex($group, ITEMS_PER_PAGE, $offset); $page->smarty->assign(['group' => $group, 'regex' => $regex, 'pagertotalitems' => $regexes->getCount($group), 'pageroffset' => $offset, 'pageritemsperpage' => ITEMS_PER_PAGE, 'pagerquerysuffix' => '', 'pagerquerybase' => WWW_TOP . "/release_naming_regexes-list.php?" . $group . "offset="]); $page->smarty->assign('pager', $page->smarty->fetch("pager.tpl")); $page->content = $page->smarty->fetch('release_naming_regexes-list.tpl'); $page->render();