Ejemplo n.º 1
0
 /**
  * @param string $message
  * @param bool   $reset
  */
 public function overWritePrimary($message, $reset = False)
 {
     if ($reset) {
         $this->lastMessageLength = 0;
     }
     echo str_repeat(chr(8), $this->lastMessageLength);
     echo str_repeat(" ", $this->lastMessageLength);
     echo str_repeat(chr(8), $this->lastMessageLength);
     $this->lastMessageLength = strlen($message);
     echo $this->cli->primaryOver($message);
 }
Ejemplo n.º 2
0
 /**
  * Log / Echo message.
  *
  * @param string $message Message to log.
  * @param string $method  Method that called this.
  * @param int    $level   Logger severity level constant.
  * @param string $color   ColorCLI method name.
  */
 private function log($message, $method, $level, $color)
 {
     if ($this->_echoCLI) {
         $this->_colorCLI->doEcho($this->_colorCLI->{$color}($message . ' [' . get_class() . "::{$method}]"), true);
     }
     if ($this->_debug) {
         $this->_debugging->log(get_class(), $method, $message, $level);
     }
 }
Ejemplo n.º 3
0
 /**
  * Log / Echo message.
  *
  * @param string $message Message to log.
  * @param string $method  Method that called this.
  * @param int    $level   Logger severity level constant.
  * @param string $color   ColorCLI method name.
  */
 private function log($message, $method, $level, $color)
 {
     if ($this->_echoCLI) {
         $this->_colorCLI->doEcho($this->_colorCLI->{$color}($message), true);
     }
     if ($this->_debug) {
         $this->_debugging->log('Binaries', $method, $message, $level);
     }
 }
Ejemplo n.º 4
0
<?php

// To troubleshoot what's actually on usenet.
require_once realpath(dirname(dirname(dirname(__DIR__))) . DIRECTORY_SEPARATOR . 'indexer.php');
use nzedb\Binaries;
use nzedb\ColorCLI;
use nzedb\NNTP;
$cli = new ColorCLI();
if (!isset($argv[2]) || !is_numeric($argv[2])) {
    exit($cli->error("\nTest your nntp connection, get group information and postdate for specific article.\n\n" . "php {$argv['0']} alt.binaries.teevee 595751142    ...: To test nntp on alt.binaries.teevee with artivle 595751142.\n"));
}
$nntp = new NNTP();
if ($nntp->doConnect() !== true) {
    exit;
}
$first = $argv[2];
$group = $argv[1];
// Select a group.
$groupArr = $nntp->selectGroup($group);
print_r($groupArr);
// Insert actual local part numbers here.
$msg = $nntp->getXOVER($first . '-' . $first);
// Print out the array of headers.
print_r($msg);
// get postdate for an article
$binaries = new Binaries(['NNTP' => $nntp]);
$newdate = $binaries->postdate($first, $groupArr);
echo $cli->primary("The posted date for " . $group . ", article " . $first . " is " . date('Y-m-d H:i:s', $newdate));
Ejemplo n.º 5
0
<?php

require_once realpath(dirname(dirname(dirname(__DIR__))) . DIRECTORY_SEPARATOR . 'indexer.php');
use nzedb\ColorCLI;
use nzedb\db\Settings;
$cli = new ColorCLI();
$pdo = new Settings(['checkVersion' => true]);
$ftinnodb = $pdo->isDbVersionAtLeast('5.6');
if (isset($argv[1]) && isset($argv[2]) && $argv[2] == "fmyisam") {
    $tbl = $argv[1];
    printf($cli->header("Converting {$tbl}"));
    $pdo->queryExec("ALTER TABLE {$tbl} ENGINE=MYISAM ROW_FORMAT=FIXED");
} else {
    if (isset($argv[1]) && isset($argv[2]) && $argv[2] == "dmyisam") {
        $tbl = $argv[1];
        printf($cli->header("Converting {$tbl}"));
        $pdo->queryExec("ALTER TABLE {$tbl} ENGINE=MYISAM ROW_FORMAT=DYNAMIC");
    } else {
        if (isset($argv[1]) && isset($argv[2]) && $argv[2] == "cinnodb") {
            $tbl = $argv[1];
            if ($ftinnodb || !$ftinnodb && $tbl !== 'release_search_data' && $tbl !== 'predb_hashes' && $tbl !== 'bookinfo' && $tbl !== 'consoleinfo' && $tbl !== 'musicinfo') {
                printf($cli->header("Converting {$tbl}"));
                $pdo->queryExec("ALTER TABLE {$tbl} ENGINE=INNODB ROW_FORMAT=COMPRESSED");
            } else {
                printf($cli->header("Not converting bookinfo / consoleinfo / musicinfo / release_search_data / predb_hashes as your INNODB version does not support fulltext indexes"));
            }
        } else {
            if (isset($argv[1]) && isset($argv[2]) && $argv[2] == "dinnodb") {
                $tbl = $argv[1];
                if ($ftinnodb || !$ftinnodb && $tbl !== 'release_search_data' && $tbl !== 'predb_hashes' && $tbl !== 'bookinfo' && $tbl !== 'consoleinfo' && $tbl !== 'musicinfo') {
                    printf($cli->header("Converting {$tbl}"));
Ejemplo n.º 6
0
<?php

require_once realpath(dirname(dirname(dirname(__DIR__))) . DIRECTORY_SEPARATOR . 'indexer.php');
require_once realpath(dirname(dirname(dirname(__DIR__))) . DS . 'libs' . DS . 'smarty' . DS . 'Autoloader.php');
Smarty_Autoloader::register();
use nzedb\ColorCLI;
use nzedb\Tmux;
use nzedb\db\Settings;
use nzedb\utility\Misc;
$pdo = new Settings();
$DIR = nZEDb_MISC;
$smarty = new Smarty();
$dbname = DB_NAME;
$cli = new ColorCLI();
if (isset($argv[1]) && ($argv[1] == "true" || $argv[1] == "safe")) {
    $restart = (new Tmux())->stopIfRunning();
    system("cd {$DIR} && git pull");
    if (Misc::hasCommand("php5")) {
        $PHP = "php5";
    } else {
        $PHP = "php";
    }
    echo $cli->header("Patching database - {$dbname}.");
    $safe = $argv[1] === "safe" ? true : false;
    system("{$PHP} " . nZEDb_ROOT . 'cli' . DS . "update_db.php true {$safe}");
    // Remove folders from smarty.
    $cleared = $smarty->clearCompiledTemplate();
    if ($cleared) {
        echo $cli->header("The smarty template cache has been cleaned for you");
    } else {
        echo $cli->header("You should clear your smarty template cache at: " . SMARTY_DIR . "templates_c");
Ejemplo n.º 7
0
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
require_once realpath(dirname(dirname(dirname(__DIR__))) . DIRECTORY_SEPARATOR . 'indexer.php');
use nzedb\ColorCLI;
use nzedb\Users;
use nzedb\db\Settings;
$colorCLI = new ColorCLI();
$warning = <<<WARNING
This script will (re)set the password hashes for older hashes (pre Db patch
158, others are ignored), with the user's email as the new password.
  It is intended for use ONLY if you have a *lot* of users, as this is not
secure (a user's email addresses may be known to other users). If you only have
a few users then run setUsersPasswordHash.php for each of them instead.
WARNING;
$usage = "\nUsage: php {$argv[0]} <IUnderStandTheRisks>";
echo $colorCLI->warning($warning);
if ($argc != 2) {
    exit($colorCLI->error("\nWrong number of parameters{$usage}"));
} else {
    if ($argv[1] !== 1 && $argv[1] != '<IUnderStandTheRisks>' && $argv[1] != 'IUnderStandTheRisks' && $argv[1] != 'true') {
        exit($colorCLI->error("\nInvalid parameter(s){$usage}"));
    }
Ejemplo n.º 8
0
if ($argc > 1 && $argv[1]) {
    define('VERBOSE', true);
} else {
    define('VERBOSE', false);
}
$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]);
        }
Ejemplo n.º 9
0
<?php

require_once realpath(dirname(dirname(dirname(__DIR__))) . DIRECTORY_SEPARATOR . 'indexer.php');
use nzedb\ColorCLI;
use nzedb\RottenTomato;
use nzedb\db\Settings;
$cli = new ColorCLI();
$rtkey = (new Settings())->getSetting('rottentomatokey');
if (isset($rtkey)) {
    $rt = new RottenTomato($rtkey);
    print_r(json_decode($rt->searchMovie("inception")));
    $url = RottenTomato::API_URL . "movies.json?apikey=" . $rt->getApiKey() . "&q=inception&page_limit=50";
    exit($cli->header("\nIf nothing was displayed above then there might be an error. If so, go to the following url: {$url}\n"));
} else {
    exit($cli->error("\nNo rotten tomato key.\n"));
}
Ejemplo n.º 10
0
<?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!");
Ejemplo n.º 11
0
<?php

/* This script deletes releases that match certain criteria, type php removeCrapReleases.php false for details. */
require_once realpath(dirname(dirname(dirname(__DIR__))) . DIRECTORY_SEPARATOR . 'indexer.php');
use nzedb\ColorCLI;
use nzedb\ReleaseRemover;
$cli = new ColorCLI();
$n = PHP_EOL;
$argCnt = count($argv);
if ($argCnt === 1) {
    exit($cli->error($n . 'Run fixReleaseNames.php first to attempt to fix release names.' . $n . 'This will miss some releases if you have not set fixReleaseNames to set the release as checked.' . $n . $n . "php {$argv['0']} false Display full usage of this script." . $n . "php {$argv['0']} true full Run this script with all options."));
}
if ($argCnt === 2) {
    if ($argv[1] === 'false') {
        exit("php {$argv['0']} arg1 arg2 arg3 arg4" . $n . $n . 'arg1 (Required) = true/false' . $n . '                  true   = Run this script and delete releases.' . $n . '                  false  = Run this script and show what could be deleted.' . $n . $n . 'arg2 (Required) = full/number' . $n . '                  full   = Run without a time limit.' . $n . '                  number = Run on releases up to this old.' . $n . $n . 'arg3 (Optional) = blacklist | blfiles | codec | executable | gibberish | hashed | huge | installbin | passworded | passwordurl | sample | scr | short | size | wmv_all' . $n . '                  blfiles     = Remove releases using the enabled blacklists in admin section of site against filenames.' . $n . '                  codec       = Remove releases where the release contains AVI or WMV file and is in x264 category (the spammer).' . $n . '                  executable  = Remove releases containing an exe file.' . $n . '                  gibberish   = Remove releases where the name is letters/numbers only and 15 characters or longer.' . $n . '                  hashed      = Remove releases where the name is letters/numbers only and 25 characters or longer.' . $n . '                  installbin  = Remove releases which contain an install.bin file.' . $n . '                  passworded  = Remove releases which contain the word password in the title.' . $n . '                  passwordurl = Remove releases which contain a password.url file.' . $n . '                  sample      = Remove releases that are smaller than 40MB more than 1 file and have sample in the title' . $n . '                  scr         = Remove releases where .scr extension is found in the files or subject.' . $n . '                  short       = Remove releases where the name is only numbers or letters and is 5 characters or less.' . $n . '                  wmv_all     = Remove releases where the release contains WMV file in any group!!.' . $n . '                  size        = Remove releases smaller than 1MB and have only 1 file and not in books or mp3 section.' . $n . $n . 'examples:' . $n . "php {$argv['0']} true 12 blacklist     = Remove releases up to 12 hours old using site blacklists." . $n . "php {$argv['0']} false full            = Show what releases could have been removed." . $n . "php {$argv['0']} true full installbin  = Remove releases which containing an install.bin file." . $n . "php {$argv['0']} true full blacklist 1 = Remove releases matching blacklist id 1." . $n);
    } else {
        exit($cli->error("Wrong usage! Type php {$argv['0']} false"));
    }
}
if ($argCnt < 3) {
    exit($cli->error("Wrong usage! Type php {$argv['0']} false"));
}
if (isset($argv[3]) && $argv[3] === 'blacklist' && isset($argv[4])) {
    $blacklistID = $argv[4];
}
$RR = new ReleaseRemover();
$RR->removeCrap($argv[1] === 'true' ? true : false, $argv[2], isset($argv[3]) ? $argv[3] : '', isset($blacklistID) ? $argv[4] : '');
Ejemplo n.º 12
0
 /**
  * @param string $message
  *
  * @return void
  */
 public function info($message)
 {
     if (PEAR_LOG_DEBUG) {
         echo $this->color->info($message);
     }
 }
Ejemplo n.º 13
0
<?php

require_once dirname(__FILE__) . '/config.php';
use nzedb\ColorCLI;
use nzedb\RequestIDLocal;
use nzedb\RequestIDWeb;
$cli = new ColorCLI();
if (!isset($argv[1]) || $argv[1] != "all" && $argv[1] != "full" && $argv[1] != "web" && !is_numeric($argv[1]) || !isset($argv[2]) || !in_array($argv[2], ['true', 'false'])) {
    exit($cli->error(PHP_EOL . "This script tries to match a release request ID by group to a PreDB request ID by group doing local lookup only." . PHP_EOL . "In addition an optional final argument is time, in minutes, to check releases that have previously been checked." . PHP_EOL . PHP_EOL . "Argument 1: full|all|number|web => (mandatory)" . PHP_EOL . "all does only requestid releases, full does full database, number limits to x amount of releases, web does web requestID's" . PHP_EOL . "Argument 2: true|false          => (mandatory) Display full info on how the release was renamed or not." . PHP_EOL . "Argument 3: number             => (optional)  This is to limit how old the releases to work on (in hours)." . PHP_EOL . "php requestid.php 1000 true    => to limit to 1000 sorted by newest postdate and show renaming." . PHP_EOL . PHP_EOL . "php requestid.php full true    => to run on full database and show renaming." . PHP_EOL . "php requestid.php all true     => to run on all requestid releases (including previously renamed) and show renaming." . PHP_EOL));
}
if ($argv[1] === 'web') {
    (new RequestIDWeb())->lookupRequestIDs(['limit' => 1000, 'show' => $argv[2], 'time' => isset($argv[3]) && is_numeric($argv[3]) && $argv[3] > 0 ? $argv[3] : 0]);
} else {
    (new RequestIDLocal())->lookupRequestIDs(['limit' => $argv[1], 'show' => $argv[2], 'time' => isset($argv[3]) && is_numeric($argv[3]) && $argv[3] > 0 ? $argv[3] : 0]);
}
Ejemplo n.º 14
0
<?php

require_once realpath(dirname(dirname(dirname(__DIR__))) . DIRECTORY_SEPARATOR . 'indexer.php');
use nzedb\ColorCLI;
use nzedb\db\Settings;
$pdo = new Settings();
$count = $groups = 0;
$cli = new ColorCLI();
echo $cli->header("This script will show all Backfill Groups.\n" . "An optional first argument of ASC/DESC is used to sort the display by first_record_postdate in ascending/descending order.\n" . "An optional second argument will limit the return to that number of groups.\n\n" . "php {$argv['0']} true 20    ...: To sort the backfill groups by first_record_postdate and display only 20 groups.\n");
$limit = "";
if (isset($argv[2]) && is_numeric($argv[2])) {
    $limit = "limit " . $argv[2];
} else {
    if (isset($argv[1]) && is_numeric($argv[1])) {
        $limit = "limit " . $argv[1];
    }
}
$mask = $cli->primary("%-50.50s %22.22s %22.22s %22.22s %22.22s");
$mask1 = $cli->header("%-50.50s %22.22s %22.22s %22.22s %22.22s");
$groups = $pdo->queryOneRow("SELECT COUNT(*) AS count FROM groups WHERE backfill = 1 AND first_record IS NOT NULL");
if ($rels = $pdo->query("SELECT last_updated, last_updated, CAST(last_record AS SIGNED)-CAST(first_record AS SIGNED) AS headers_downloaded FROM groups")) {
    foreach ($rels as $rel) {
        $count += $rel['headers_downloaded'];
    }
}
printf($mask1, "Group Name => " . $groups['count'] . "(" . number_format($count) . " downloaded)", "Backfilled Days", "Oldest Post", "Last Updated", "Headers Downloaded");
printf($mask1, "==================================================", "======================", "======================", "======================", "======================");
if (isset($argv[1]) && ($argv[1] === "desc" || $argv[1] === "DESC")) {
    if ($rels = $pdo->query(sprintf("SELECT name, backfill_target, first_record_postdate, last_updated, last_updated, " . "CAST(last_record AS SIGNED)-CAST(first_record AS SIGNED) AS headers_downloaded, " . "TIMESTAMPDIFF(DAY,first_record_postdate,NOW()) AS days FROM groups " . "WHERE backfill = 1 AND first_record_postdate IS NOT NULL AND last_updated IS NOT NULL " . "AND last_updated IS NOT NULL ORDER BY first_record_postdate DESC %s", $limit))) {
        foreach ($rels as $rel) {
            $headers = number_format($rel['headers_downloaded']);
Ejemplo n.º 15
0
<?php

require_once realpath(dirname(dirname(dirname(__DIR__))) . DIRECTORY_SEPARATOR . 'indexer.php');
require_once nZEDb_LIBS . 'GiantBombAPI.php';
// Test if your giantbomb key is working.
use nzedb\ColorCLI;
use nzedb\db\Settings;
$giantbombkey = (new Settings())->getSetting('giantbombkey');
$cli = new ColorCLI();
$obj = new GiantBomb($giantbombkey, $resp = "json");
$searchgame = "South Park The Stick of Truth";
$resultsfound = 0;
$e = null;
try {
    $fields = array("deck", "description", "original_game_rating", "api_detail_url", "image", "genres", "name", "platforms", "publishers", "original_release_date", "reviews", "site_detail_url");
    $result = $obj->search($searchgame, $fields, 1);
    $result = json_decode(json_encode($result), true);
    if ($result['number_of_total_results'] != 0) {
        $resultsfound = count($result['results']);
        for ($i = 0; $i <= $resultsfound; $i++) {
            similar_text($result['results'][$i]['name'], $searchgame, $p);
            if ($p > 90) {
                $result = $result['results'][$i];
                break;
            }
        }
    }
} catch (\Exception $e) {
    $result = false;
}
if ($result !== false && !empty($result)) {
Ejemplo n.º 16
0
 /**
  * @note Disable group that does not exist on USP server
  * @param $id
  *
  */
 public function disableIfNotExist($id)
 {
     $this->pdo->queryExec(sprintf("UPDATE groups SET active = 0 WHERE id = %d", $id));
     $this->colorCLI->doEcho($this->colorCLI->error('Group does not exist on server, disabling'));
 }
Ejemplo n.º 17
0
 /**
  * Echo a updated release name to CLI.
  *
  * @param array $data
  *        array(
  *              'new_name'     => (string) The new release search name.
  *              'old_name'     => (string) The old release search name.
  *              'new_category' => (string) The new category name or ID for the release.
  *              'old_category' => (string) The old category name or ID for the release.
  *              'group'        => (string) The group name or ID of the release.
  *              'release_id'   => (int)    The ID of the release.
  *              'method'       => (string) The method used to rename the release.
  *        )
  *
  * @access public
  * @static
  * @void
  */
 public static function echoChangedReleaseName(array $data = ['new_name' => '', 'old_name' => '', 'new_category' => '', 'old_category' => '', 'group' => '', 'release_id' => 0, 'method' => ''])
 {
     echo PHP_EOL . ColorCLI::headerOver('New name:     ') . ColorCLI::primaryOver($data['new_name']) . PHP_EOL . ColorCLI::headerOver('Old name:     ') . ColorCLI::primaryOver($data['old_name']) . PHP_EOL . ColorCLI::headerOver('New category: ') . ColorCLI::primaryOver($data['new_category']) . PHP_EOL . ColorCLI::headerOver('Old category: ') . ColorCLI::primaryOver($data['old_category']) . PHP_EOL . ColorCLI::headerOver('Group:        ') . ColorCLI::primaryOver($data['group']) . PHP_EOL . ColorCLI::headerOver('Release ID:   ') . ColorCLI::primaryOver($data['release_id']) . PHP_EOL . ColorCLI::headerOver('Method:       ') . ColorCLI::primaryOver($data['method']) . PHP_EOL;
 }
Ejemplo n.º 18
0
<?php

// This script updates all releases with the guid from the nzb file.
require_once dirname(__FILE__) . '/../../../www/config.php';
use nzedb\ColorCLI;
use nzedb\ConsoleTools;
use nzedb\NZB;
use nzedb\ReleaseImage;
use nzedb\Releases;
use nzedb\db\Settings;
use nzedb\utility\Utility;
$cli = new ColorCLI();
if (isset($argv[1])) {
    $del = false;
    if (isset($argv[2])) {
        $del = $argv[2];
    }
    create_guids($argv[1], $del);
} else {
    exit($cli->error("\nThis script updates all releases with the guid (md5 hash of the first message-id) from the nzb file.\n\n" . "php {$argv['0']} true         ...: To create missing nzb_guids.\n" . "php {$argv['0']} true delete  ...: To create missing nzb_guids and delete invalid nzbs and releases.\n"));
}
function create_guids($live, $delete = false)
{
    $pdo = new Settings();
    $consoletools = new ConsoleTools(['ColorCLI' => $pdo->log]);
    $timestart = TIME();
    $relcount = $deleted = $total = 0;
    $relrecs = false;
    if ($live == "true") {
        $relrecs = $pdo->queryDirect(sprintf("SELECT id, guid FROM releases WHERE nzbstatus = 1 AND nzb_guid IS NULL ORDER BY id DESC"));
    } else {
Ejemplo n.º 19
0
<?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));
Ejemplo n.º 20
0
<?php

require_once realpath(dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'indexer.php');
use nzedb\ColorCLI;
use nzedb\NameFixer;
$cli = new ColorCLI();
if (!isset($argv[1]) && ($argv[1] !== 'full' || !is_numeric($argv[1]))) {
    exit($cli->error(PHP_EOL . "This script tries to match release filenames to PreDB filenames." . PHP_EOL . "To display the changes, use 'show' as the second argument. The optional third argument will limit the amount of filenames to attempt to match." . PHP_EOL . PHP_EOL . "php match_prefiles.php full show\t...: to run on full database and show renames." . PHP_EOL . "php match_prefiles.php 2000 show\t...: to run against 2000 distinct releases and show renames." . PHP_EOL));
}
$nameFixer = new NameFixer();
$nameFixer->getPreFileNames($argv);