<?php // Include config.php require_once realpath(dirname(dirname(dirname(__DIR__))) . DIRECTORY_SEPARATOR . 'indexer.php'); use nzedb\ReleaseRemover; use nzedb\ColorCLI; // New line for CLI. $n = PHP_EOL; // ColorCLI class. $cli = new ColorCLI(); // Print arguments/usage. $totalArgs = count($argv); if ($totalArgs < 2) { exit($cli->info($n . 'This deletes releases based on a list of criteria you pass.' . $n . 'Usage:' . $n . $n . 'List of supported criteria:' . $n . 'fromname : Look for names of people who posted releases (the poster name). (modifiers: equals, like)' . $n . 'groupname : Look in groups. (modifiers: equals, like)' . $n . 'guid : Look for a specific guid. (modifiers: equals)' . $n . 'name : Look for a name (the usenet name). (modifiers: equals, like)' . $n . 'searchname : Look for a name (the search name). (modifiers: equals, like)' . $n . 'size : Release must be (bigger than |smaller than |exactly) this size.(bytes) (modifiers: equals,bigger,smaller)' . $n . 'adddate : Look for releases added to our DB (older than|newer than) x hours. (modifiers: bigger,smaller)' . $n . 'postdate : Look for posted to usenet (older than|newer than) x hours. (modifiers: bigger,smaller)' . $n . 'completion : Look for completion (less than) (modifiers: smaller)' . $n . 'categoryid : Look for releases within specified category (modifiers: equals)' . $n . 'imdbid : Look for releases with imdbid (modifiers: equals)' . $n . 'rageid : Look for releases with rageid (modifiers: equals)' . $n . 'totalpart : Look for releases with certain number of parts (modifiers: equals,bigger,smaller)' . $n . 'nzbstatus : Look for releases with nzbstatus (modifiers: equals)' . $n . $n . 'List of Modifiers:' . $n . 'equals : Match must be exactly this. (fromname=equals="john" will only look for "john", not "johndoe")' . $n . 'like : Match can be similar to this. Separate words using spaces(ie:"cars hdtv x264").' . $n . ' (fromname=like="john" will look for any posters with john in it (ie:john@smith.com)' . $n . 'bigger : Match must be bigger than this. (postdate=bigger="3" means older than 3 hours ago)' . $n . 'smaller : Match must be smaller than this (postdate=smaller="3" means between now and 3 hours ago.' . $n . $n . 'Extra:' . $n . 'ignore : Ignore the user check. (before running we ask you if you want to run the query to delete)' . $n . $n . 'Examples:' . $n . $_SERVER['_'] . ' ' . $argv[0] . ' groupname=equals="alt.binaries.teevee" searchname=like="olympics 2014" postdate=bigger="5"' . $n . $_SERVER['_'] . ' ' . $argv[0] . ' guid=equals="8fb5956bae3de4fb94edcc69da44d6883d586fd0"' . $n . $_SERVER['_'] . ' ' . $argv[0] . ' size=smaller="104857600" size=bigger="2048" groupname=like="movies"' . $n . $_SERVER['_'] . ' ' . $argv[0] . ' fromname=like="@XviD.net" groupname=equals="alt.binaries.movies.divx" ignore' . $n . $_SERVER['_'] . ' ' . $argv[0] . ' imdbid=equals=NULL categoryid=equals=2020 nzbstatus=equals=1 adddate=bigger=2880 # Remove other movie releases with non-cleaned names added > 120 days ago')); } $RR = new ReleaseRemover(); // Remove argv[0] and send the array. $RR->removeByCriteria(array_slice($argv, 1, $totalArgs - 1));
/** * @param string $message * * @return void */ public function info($message) { if (PEAR_LOG_DEBUG) { echo $this->color->info($message); } }
<?php require_once dirname(dirname(dirname(__DIR__))) . '/www/config.php'; use nzedb\ColorCLI; $output = new ColorCLI(); echo $output->primary("Checking for files in the renamed directories."); $status = 0; $dirs = [['old' => 'misc/testing/DB_scripts', 'newpath' => 'misc/testing/DB'], ['old' => 'misc/testing/Dev_testing/Subject_testing', 'newpath' => 'misc/testing/Developers/Subject'], ['old' => 'misc/testing/Dev_testing', 'newpath' => 'misc/testing/Developers'], ['old' => 'misc/testing/PostProc_testing', 'newpath' => 'misc/testing/PostProc'], ['old' => 'misc/testing/Regex_testing', 'newpath' => 'misc/testing/Regex'], ['old' => 'misc/testing/Release_scripts', 'newpath' => 'misc/testing/Release'], ['old' => 'misc/update_scripts/nix_scripts/tmux/powerline/themes', 'newpath' => 'misc/update/nix/tmux/powerline/themes'], ['old' => 'misc/update_scripts/nix_scripts/tmux/powerline', 'newpath' => 'misc/update/nix/tmux/powerline'], ['old' => 'misc/update_scripts/nix_scripts/screen/sequential', 'newpath' => 'misc/update/nix/screen/sequential'], ['old' => 'misc/update_scripts/nix_scripts/tmux/', 'newpath' => 'misc/update/nix/tmux'], ['old' => 'misc/update_scripts/nix_scripts', 'newpath' => 'misc/update/nix'], ['old' => 'misc/update_scripts/python_scripts/lib', 'newpath' => 'misc/update/python/lib'], ['old' => 'misc/update_scripts/python_scripts', 'newpath' => 'misc/update/python'], ['old' => 'misc/update_scripts/win_scripts', 'newpath' => 'misc/update/win'], ['old' => 'misc/update_scripts', 'newpath' => 'misc/update']]; $tatus = 0; foreach ($dirs as $dir) { if (isset($dir['old'])) { $pathOld = nZEDb_ROOT . $dir['old']; if (file_exists($pathOld)) { $pathNew = nZEDb_ROOT . $dir['newpath']; echo $output->info("Moving contents of '{$pathOld}' to '{$pathNew}'"); $dirIt = new \DirectoryIterator($pathOld); foreach ($dirIt as $item) { if ($item->isDot()) { continue; } echo $output->info(" Moving {$item->getPathname()}"); if (rename($item->getPathname(), $pathNew . DIRECTORY_SEPARATOR . $item->getFilename()) === false) { echo $output->error(" FAILED!"); $status = 1; } } $d = dir($pathOld); if ($d->read() === false) { @unlink($pathOld); } else { echo $output->error("Could not move all files. Check your permissions!");
$changed = false; $source = __DIR__ . DS . 'git-hooks' . DS . PRE_COMMIT_HOOK; $target = nZEDb_HOOKS . DS . PRE_COMMIT_HOOK; if (!file_exists(nZEDb_HOOKS . PRE_COMMIT_HOOK)) { copy($source, $target); } $file = file($target, FILE_IGNORE_NEW_LINES); if (preg_match('/^(?P<key>#version=)(?P<value>.*)$/', $file[1], $match)) { $current = $match['value']; } $out = new ColorCLI(); $versions = new \nzedb\utility\Versions(); $version = $versions->getGitHookPrecommit(); if ($version > $current) { copy($source, $target); echo $out->info("Updated pre-commit hook to version {$version}"); $file = file($target, FILE_IGNORE_NEW_LINES); } chmod($target, 0774); $count = count($file); $index = 0; while ($index < $count) { if (preg_match('/^#nZEDb hook\\s*-\\s*(.+)$/', $file[$index], $match)) { if (VERBOSE) { echo $out->primary("Matched: " . $file[$index]); } $index++; $file[$index] = trim($file[$index]); switch ($match[1]) { case 'update version info': case 'run hooks':