Ejemplo n.º 1
0
function categorizeRelease($update = true, $where, $echooutput = false)
{
    $pdo = new Settings();
    $cat = new Categorize();
    $consoletools = new consoleTools();
    $relcount = $chgcount = 0;
    $c = new ColorCLI();
    echo $c->primary("SELECT id, searchname, groupid, categoryid FROM releases " . $where);
    $resrel = $pdo->queryDirect("SELECT id, searchname, groupid, categoryid FROM releases " . $where);
    $total = $resrel->rowCount();
    if ($total > 0) {
        foreach ($resrel as $rowrel) {
            $catId = $cat->determineCategory($rowrel['groupid'], $rowrel['searchname']);
            if ($rowrel['categoryid'] != $catId) {
                if ($update === true) {
                    $pdo->queryExec(sprintf("\n\t\t\t\t\t\t\tUPDATE releases\n\t\t\t\t\t\t\tSET iscategorized = 1,\n\t\t\t\t\t\t\t\trageid = -1,\n\t\t\t\t\t\t\t\tseriesfull = NULL,\n\t\t\t\t\t\t\t\tseason = NULL,\n\t\t\t\t\t\t\t\tepisode = NULL,\n\t\t\t\t\t\t\t\ttvtitle = NULL,\n\t\t\t\t\t\t\t\ttvairdate = NULL,\n\t\t\t\t\t\t\t\timdbid = NULL,\n\t\t\t\t\t\t\t\tmusicinfoid = NULL,\n\t\t\t\t\t\t\t\tconsoleinfoid = NULL,\n\t\t\t\t\t\t\t\tgamesinfo_id = 0,\n\t\t\t\t\t\t\t\txxxinfo_id = 0,\n\t\t\t\t\t\t\t\tbookinfoid = NULL,\n\t\t\t\t\t\t\t\tanidbid = NULL,\n\t\t\t\t\t\t\t\tcategoryid = %d\n\t\t\t\t\t\t\tWHERE id = %d", $catId, $rowrel['id']));
                }
                $chgcount++;
            }
            $relcount++;
            if ($echooutput) {
                $consoletools->overWritePrimary("Re-Categorized: [" . number_format($chgcount) . "] " . $consoletools->percentString($relcount, $total));
            }
        }
    }
    if ($echooutput !== false && $relcount > 0) {
        echo "\n";
    }
    return $chgcount;
}
Ejemplo n.º 2
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.º 3
0
function print_str($type, $str, $argv)
{
    if ($argv[1] != 'file') {
        $cli = new ColorCLI();
        if ($type == "primary") {
            echo $cli->primary($str);
        } else {
            if ($type == "alternate") {
                echo $cli->alternate($str);
            } else {
                echo $cli->header($str);
            }
        }
    } else {
        echo $str . "\n";
    }
}
Ejemplo n.º 4
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.º 5
0
function BackupDatabase()
{
    $db = new DB();
    $c = new ColorCLI();
    $DIR = dirname(__FILE__);
    if (Utility::hasCommand("php5")) {
        $PHP = "php5";
    } else {
        $PHP = "php";
    }
    //Backup based on database system
    if ($db->dbSystem() == "mysql") {
        system("{$PHP} {$DIR}mysqldump_tables.php db dump ../../");
    } else {
        if ($db->dbSystem() == "pgsql") {
            exit($c->error("Currently not supported on this platform."));
        }
    }
}
Ejemplo n.º 6
0
function printMsec($time, $warn = 5, $error = 10)
{
    $str = formatMsec($time);
    if (!class_exists('ColorCLI')) {
        return $str;
    }
    $msec = msec($time);
    if ($msec < $warn) {
        return ColorCLI::lightGreen($str);
    } elseif ($msec < $error) {
        return ColorCLI::yellow($str);
    }
    return ColorCLI::red($str);
}
Ejemplo n.º 7
0
function printMessage($violation)
{
    $str = $violation['message'];
    if (!class_exists('ColorCLI')) {
        return $str;
    }
    $severity = $violation['severity'];
    if ($severity == 'error') {
        return ColorCLI::red($str);
    } elseif ($severity == 'warning') {
        return ColorCLI::yellow($str);
    }
    return ColorCLI::cyan($str);
}
Ejemplo n.º 8
0
function printMessage($violation)
{
    $str = formatMessage($violation);
    if (!class_exists('ColorCLI')) {
        return $str;
    }
    $priority = $violation['priority'];
    if (isHighPriority($priority)) {
        return ColorCLI::red($str);
    } elseif (isNormatPriority($priority)) {
        return ColorCLI::yellow($str);
    }
    return ColorCLI::cyan($str);
}
Ejemplo n.º 9
0
<?php

require_once dirname(__FILE__) . '/../../../../www/config.php';
use newznab\db\Settings;
use newznab\utility\Utility;
$pdo = new Settings();
$DIR = NN_TMUX;
$c = new ColorCLI();
$t = new Tmux();
$tmux = $t->get();
$import = isset($tmux->import) ? $tmux->import : 0;
$tmux_session = isset($tmux->tmux_session) ? $tmux->tmux_session : 0;
$seq = isset($tmux->sequential) ? $tmux->sequential : 0;
$powerline = isset($tmux->powerline) ? $tmux->powerline : 0;
$colors = isset($tmux->colors) ? $tmux->colors : 0;
$nntpproxy = $pdo->getSetting('nntpproxy');
$tablepergroup = $pdo->getSetting('tablepergroup');
$tablepergroup = $tablepergroup != '' ? $tablepergroup : 0;
// Check that Db patch level is current. Also checks nZEDb.xml is valid.
Utility::isPatched();
Utility::clearScreen();
echo "Starting Tmux...\n";
// Create a placeholder session so tmux commands do not throw server not found errors.
exec('tmux new-session -ds placeholder 2>/dev/null');
// Search for NNTPProxy session that might be running from a user threaded.php run. Setup a clean environment to run in.
exec("tmux list-session | grep NNTPProxy", $nntpkill);
if (count($nntpkill) !== 0) {
    exec("tmux kill-session -t NNTPProxy");
    echo $pdo->log->notice("Found NNTPProxy tmux session and killing it.");
} else {
    exec("tmux list-session", $session);
Ejemplo n.º 10
0
<?php

require_once dirname(__FILE__) . "/config.php";
use newznab\db\Settings;
use newznab\processing\PProcess;
$c = new ColorCLI();
if (!isset($argv[1])) {
    exit($c->error("This script is not intended to be run manually, it is called from fixreleasenames_threaded.py."));
} else {
    if (isset($argv[1])) {
        $db = new Settings();
        $namefixer = new \NameFixer(['Settings' => $pdo]);
        $pieces = explode(' ', $argv[1]);
        if (isset($pieces[1]) && $pieces[0] == 'nfo') {
            $release = $pieces[1];
            if ($res = $db->queryOneRow(sprintf('SELECT rel.guid AS guid, nfo.releaseid AS nfoid, rel.groupid, rel.categoryid, rel.name, rel.searchname, uncompress(nfo) AS textstring, rel.id AS releaseid FROM releases rel INNER JOIN releasenfo nfo ON (nfo.releaseid = rel.id) WHERE rel.id = %d', $release))) {
                //ignore encrypted nfos
                if (preg_match('/^=newz\\[NZB\\]=\\w+/', $res['textstring'])) {
                    $namefixer->done = $namefixer->matched = false;
                    $db->queryDirect(sprintf('UPDATE releases SET proc_nfo = 1 WHERE id = %d', $res['releaseid']));
                    $namefixer->checked++;
                    echo '.';
                } else {
                    //echo $res['textstring']."\n";
                    $namefixer->done = $namefixer->matched = false;
                    if ($namefixer->checkName($res, true, 'NFO, ', 1, 1) !== true) {
                        echo '.';
                    }
                    $namefixer->checked++;
                }
            }
Ejemplo n.º 11
0
            preg_match_all('/<epno>(.+)<\\/epno>/i', $episodes[0], $epnos);
            $AniDBAPIArray['epnos'] = isset($epnos[1]) ? implode($epnos[1], '|') : '';
            preg_match_all('/<airdate>(.+)<\\/airdate>/i', $episodes[0], $airdates);
            $AniDBAPIArray['airdates'] = isset($airdates[1]) ? implode($airdates[1], '|') : '';
            preg_match_all('/<title xml:lang="en">(.+)<\\/title>/i', $episodes[0], $episodetitles);
            $AniDBAPIArray['episodetitles'] = isset($episodetitles[1]) ? implode($episodetitles[1], '|') : '';
            $sleeptime = 10 + rand(2, 10);
            if ($this->echooutput) {
                $this->c->doEcho($this->c->primary("[" . date('d-m-Y G:i') . "] Start waitloop for " . $sleeptime . " seconds to comply with flooding rule."));
            }
            sleep($sleeptime);
            return $AniDBAPIArray;
        }
    }
}
// end class AniDBstandAlone
$c = new ColorCLI();
if (isset($argv[1]) && is_numeric($argv[1])) {
    // create a new AniDB object
    $anidb = new AniDBstandAlone(true);
    // next get the title list and populate the DB, update animetitles once a week
    $anidb->animetitlesUpdate();
    // sleep between 1 and 3 minutes before it starts, this way if from a cron process the start times are random
    if (isset($argv[2]) && $argv[2] == 'cron') {
        sleep(rand(60, 180));
    }
    // then get the titles, this is where we will make the real changes
    $anidb->getAniDBInfo((int) $argv[1] + rand(1, 12));
} else {
    echo $c->error("This script is designed to gather all show data from anidb and add it to the anidb table for nZEDb, as part of this process we need the number of API queries that can be executed max.\nTo execute this script run:\nphp populate_anidb.php 30\n");
}
Ejemplo n.º 12
0
<?php

require_once dirname(__FILE__) . "/../../../bin/config.php";
use newznab\db\Settings;
$pdo = new Settings();
$covers = $updated = $deleted = 0;
$c = new ColorCLI();
if ($argc == 1 || $argv[1] != 'true') {
    exit($c->error("\nThis script will check all images in covers/games and compare to db->gamesinfo.\nTo run:\nphp {$argv['0']} true\n"));
}
$path2covers = NN_COVERS . 'games' . DS;
$dirItr = new RecursiveDirectoryIterator($path2covers);
$itr = new RecursiveIteratorIterator($dirItr, RecursiveIteratorIterator::LEAVES_ONLY);
foreach ($itr as $filePath) {
    if (is_file($filePath) && preg_match('/\\d+\\.jpg/', $filePath)) {
        preg_match('/(\\d+)\\.jpg/', basename($filePath), $match);
        if (isset($match[1])) {
            $run = $pdo->queryDirect("UPDATE gamesinfo SET cover = 1 WHERE cover = 0 AND id = " . $match[1]);
            if ($run !== false) {
                if ($run->rowCount() >= 1) {
                    $covers++;
                } else {
                    $run = $pdo->queryDirect("SELECT id FROM gamesinfo WHERE id = " . $match[1]);
                    if ($run !== false && $run->rowCount() == 0) {
                        echo $c->info($filePath . " not found in db.");
                    }
                }
            }
        }
    }
}
Ejemplo n.º 13
0
 /**
  * @param string $message
  *
  * @return void
  */
 public function info($message)
 {
     if (PEAR_LOG_DEBUG) {
         echo $this->color->info($message);
     }
 }
Ejemplo n.º 14
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 = array('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.º 15
0
<?php

// This script updates all releases with the guid from the nzb file.
require_once dirname(__FILE__) . '/../../../www/config.php';
use nzedb\db\Settings;
$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 {
        if ($live == "limited") {
            $relrecs = $pdo->queryDirect(sprintf("SELECT id, guid FROM releases WHERE nzbstatus = 1 AND nzb_guid IS NULL ORDER BY id DESC LIMIT 10000"));
        }
    }
    if ($relrecs) {
        $total = $relrecs->rowCount();
Ejemplo n.º 16
0
<?php

require_once dirname(__FILE__) . '/../../../www/config.php';
use nzedb\db\Settings;
exit('Needs to be rewritten');
$cli = new ColorCLI();
if (!isset($argv[1])) {
    exit($cli->error("\nThis script will set bitwise = 0 or all rename bits to unchecked or just specific bits.\n\n" . "php {$argv['0']} true           ...: To reset bitwise on all releases to 0.\n" . "php {$argv['0']} rename         ...: To reset bitwise on all releases for just rename bits (4, 8, 16, 32, 64, 128).\n" . "php {$argv['0']} 512            ...: To reset a specific bit.\n"));
}
$pdo = new Settings();
$res = false;
if ($argv[1] === 'true') {
    $res = $pdo->queryExec('UPDATE releases SET bitwise = 0, iscategorized = 0, isrenamed = 0, nzbstatus = 0, ishashed = 0, isrequestid = 0');
} else {
    if ($argv[1] === 'rename') {
        $res = $pdo->queryExec('UPDATE releases SET isrenamed = 0, bitwise = ((bitwise & ~248)|0)');
    } else {
        if (is_numeric($argv[1])) {
            $res = $pdo->queryExec('UPDATE releases SET bitwise = ((bitwise & ~' . $argv[1] . ')|0)');
        }
    }
}
if ($res !== false && is_numeric($argv[1])) {
    echo $cli->header('Succesfully reset the bitwise of ' . number_format($res->rowCount()) . ' releases to 0 for bit(s) ' . $argv[1] . '.');
} else {
    if ($res !== false) {
        echo $cli->header('Succesfully reset the bitwise of ' . number_format($res->rowCount()) . ' releases to un-renamed.');
    } else {
        echo $cli->header('No releases to be reset.');
    }
}
Ejemplo n.º 17
0
<?php

// To troubleshoot what's actually on usenet.
require_once dirname(__FILE__) . '/../../../www/config.php';
$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.º 18
0
<?php

require_once dirname(__FILE__) . '/config.php';
$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' => $argv[1], '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.º 19
0
<?php

require_once dirname(__FILE__) . '/../../../www/config.php';
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 !== 'releasesearch' && $tbl !== 'predbhash') {
                printf($cli->header("Converting {$tbl}"));
                $pdo->queryExec("ALTER TABLE {$tbl} ENGINE=INNODB ROW_FORMAT=COMPRESSED");
            } else {
                printf($cli->header("Not converting releasesearch / predbhash 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 !== 'releasesearch' && $tbl !== 'predbhash') {
                    printf($cli->header("Converting {$tbl}"));
                    $pdo->queryExec("ALTER TABLE {$tbl} ENGINE=INNODB ROW_FORMAT=DYNAMIC");
Ejemplo n.º 20
0
<?php

require_once dirname(__FILE__) . '/config.php';
use newznab\processing\PProcess;
$c = new ColorCLI();
if (!isset($argv[1])) {
    exit($c->error("This script is not intended to be run manually, it is called from postprocess_threaded.py."));
}
$tmux = new Tmux();
$torun = $tmux->get()->post;
$pieces = explode('           =+=            ', $argv[1]);
$postprocess = new PProcess(['Echo' => true]);
if (isset($pieces[6])) {
    // Create the connection here and pass
    $nntp = new NNTP();
    if ($nntp->doConnect() === false) {
        exit($c->error("Unable to connect to usenet."));
    }
    $postprocess->processAdditional($nntp, $argv[1]);
    $nntp->doQuit();
} else {
    if (isset($pieces[3])) {
        // Create the connection here and pass
        $nntp = new NNTP();
        if ($nntp->doConnect() === false) {
            exit($c->error("Unable to connect to usenet."));
        }
        $postprocess->processNfos($argv[1], $nntp);
        $nntp->doQuit();
    } else {
        if (isset($pieces[2])) {
Ejemplo n.º 21
0
<?php

require_once dirname(__FILE__) . '/../../../www/config.php';
if (!isset($argv[1])) {
    exit;
}
$group = $argv[1];
//$cleaner = new CollectionsCleaning();
$nntp = new NNTP();
$cli = new ColorCLI();
if ($nntp->doConnect() !== true) {
    exit($cli->error("Unable to connect to usenet."));
}
$number = 1000000;
//exec("tmux kill-session -t NNTPProxy");
$groupArr = $nntp->selectGroup($group);
if ($nntp->isError($groupArr) || !isset($groupArr['first']) || !isset($groupArr['last'])) {
    exit;
}
print_r($groupArr);
if (isset($argv[2]) && is_numeric($argv[2])) {
    $first = $argv[2];
} else {
    if ($groupArr['last'] - $number > $groupArr['first']) {
        $first = $groupArr['last'] - $number;
    } else {
        $first = $groupArr['first'];
    }
}
$last = $groupArr['last'];
@unlink(nZEDb_RES . 'logs' . DS . 'not_yenc' . DS . $group . '.txt');
Ejemplo n.º 22
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 = NN_HOOKS . DS . PRE_COMMIT_HOOK;
if (!file_exists(NN_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 \newznab\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('/^#newznab hook\\s*-\\s*(.+)$/', $file[$index], $match)) {
        if (VERBOSE) {
            echo $out->primary("Matched: " . $file[$index]);
        }
Ejemplo n.º 23
0
 /**
  * Work out the category based on the name, resets to null if no category matched.
  */
 private function determineCategory($rel, &$foundName, &$methodused)
 {
     $categoryID = null;
     $category = new Categorize();
     $categoryID = $category->determineCategory($rel['groupname'], $foundName);
     if ($methodused == 'a.b.hdtv.x264' && $rel['groupname'] == 'alt.binaries.hdtv.x264') {
         $categoryID = Category::CAT_MOVIE_HD;
     }
     if ($categoryID == $rel['categoryid'] || $categoryID == '7900' || ($foundName == $rel['name'] || $foundName == $rel['searchname'])) {
         $foundName = null;
         $methodused = null;
     } else {
         $foundName = str_replace('&#x27;', '', trim(html_entity_decode($foundName)));
         $name = str_replace(' ', '_', $foundName);
         $searchname = str_replace('_', ' ', $foundName);
         echo PHP_EOL . ColorCLI::headerOver('ReleaseID: 		') . ColorCLI::primaryOver($rel['rid']) . PHP_EOL . ColorCLI::headerOver(' Group: 		') . ColorCLI::primaryOver($rel['groupname']) . PHP_EOL . ColorCLI::headerOver(' Old Name: 		') . ColorCLI::primaryOver($rel['name']) . PHP_EOL . ColorCLI::headerOver(' Old SearchName: 	') . ColorCLI::primaryOver($rel['searchname']) . PHP_EOL . ColorCLI::headerOver(' New Name: 		') . ColorCLI::primaryOver($name) . PHP_EOL . ColorCLI::headerOver(' New SearchName: 	') . ColorCLI::primaryOver($searchname) . PHP_EOL . ColorCLI::headerOver(' Old Cat: 		') . ColorCLI::primaryOver($rel['categoryid']) . PHP_EOL . ColorCLI::headerOver(' New Cat: 		') . ColorCLI::primaryOver($categoryID) . PHP_EOL . ColorCLI::headerOver(' Method: 		') . ColorCLI::primaryOver($methodused) . PHP_EOL;
         if (!$this->echoonly) {
             $this->pdo->queryExec(sprintf("update releases SET name = %s, searchname = %s, categoryid = %d, imdbid = NULL, rageid = -1, bookinfoid = NULL, musicinfoid = NULL, consoleinfoid = NULL WHERE releases.id = %d", $this->pdo->escapeString($name), $this->pdo->escapeString($searchname), $categoryID, $rel['rid']));
         }
         $this->numupdated++;
     }
 }
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * 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 dirname(__FILE__) . '/../../../www/config.php';
use newznab\db\Settings;
$colorCLI = new ColorCLI();
$warning = <<<WARNING
This script will (re)set the password hashes for older hashes,
before the change of hashing mchanism, 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.º 25
0
<?php

// New line for CLI.
$n = PHP_EOL;
// Include config.php
require_once dirname(__FILE__) . '/../../../www/config.php';
// 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 . $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'));
}
$RR = new ReleaseRemover();
// Remove argv[0] and send the array.
$RR->removeByCriteria(array_slice($argv, 1, $totalArgs - 1));
Ejemplo n.º 26
0
<?php

require_once dirname(__FILE__) . '/../www/config.php';
$output = new \ColorCLI();
echo $output->primary("Checking for files in the renamed directories.");
$status = 0;
$dirs = array(['old' => 'misc/testing/DB_scripts', 'newpath' => 'misc/testing/DB'], ['old' => 'misc/testing/Dev_testing/Subject_testing', 'newpath' => 'misc/testing/Dev/Subject'], ['old' => 'misc/testing/Dev_testing', 'newpath' => 'misc/testing/Dev'], ['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.º 27
0
<?php

require_once dirname(__FILE__) . '/../../../www/config.php';
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.º 28
0
<?php

require_once dirname(__FILE__) . "/config.php";
$time = TIME();
$c = new ColorCLI();
if (isset($argv[1])) {
    $group = $argv[1];
    echo $c->header("Updating group {$group}");
    $g = new Groups();
    $group = $g->getByName($group);
    $bin = new Binaries();
    $bin->updateGroup($group);
} else {
    $binaries = new Binaries();
    $binaries->updateAllGroups();
}
function relativeTime($_time)
{
    $d = array();
    $d[0] = array(1, "sec");
    $d[1] = array(60, "min");
    $d[2] = array(3600, "hr");
    $d[3] = array(86400, "day");
    $d[4] = array(31104000, "yr");
    $w = array();
    $return = "";
    $now = TIME();
    $diff = $now - $_time;
    $secondsLeft = $diff;
    for ($i = 4; $i > -1; $i--) {
        $w[$i] = intval($secondsLeft / $d[$i][0]);
Ejemplo n.º 29
0
<?php

/* This script deletes releases that match certain criteria, type php removeCrapReleases.php false for details. */
require_once dirname(__FILE__) . '/../../../www/config.php';
$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 | executable | gibberish | hashed | installbin | passworded | passwordurl | sample | scr | short | size | wmv' . $n . '                  blacklist   = Remove releases using the enabled blacklists in admin section of site.' . $n . '                  blfiles     = Remove releases using the enabled blacklists in admin section of site against filenames.' . $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 . '                  codec       = Remove releases where the release contains WMV file, x264 name, and Codec\\Setup.exe file (Spammer).' . $n . '                  size        = Remove releases smaller than 2MB and have only 1 file and not in books or mp3 section.' . $n . '                  huge        = Remove releases bigger than 200MB with just a single file.' . $n . $n . 'arg4 (Optional) = blacklist regular expression id number.  Only works when blacklist is selected as third argument.' . $n . '                  100001      = Remove releases where the Binary Blacklist ID is 100001.' . $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.º 30
0
<?php

//This script will update all records in the xxxinfo table where there is no cover
require_once dirname(__FILE__) . '/../../../www/config.php';
use newznab\db\Settings;
$pdo = new Settings();
$movie = new XXX();
$c = new ColorCLI();
$movies = $pdo->queryDirect("SELECT title FROM xxxinfo WHERE cover = 0");
if ($movies instanceof Traversable) {
    echo $c->primary("Updating " . number_format($movies->rowCount()) . " XXX movie covers.");
    foreach ($movies as $mov) {
        $starttime = microtime(true);
        $mov = $movie->updateXXXInfo($mov['title']);
        // sleep so that it's not ddos' the site
        $diff = floor((microtime(true) - $starttime) * 1000000);
        if (333333 - $diff > 0) {
            echo "\nsleeping\n";
            usleep(333333 - $diff);
        }
    }
    echo "\n";
}