示例#1
0
    exit($pdo->log->error("\nMandatory argument missing\n\n" . "This script will allow you to move from single collections/binaries/parts tables to TPG without having to run reset_truncate.\n" . "Please STOP all update scripts before running this script.\n\n" . "Use the following options to run:\n" . "php {$argv['0']} true             ...: Convert c/b/p to tpg leaving current collections/binaries/parts tables in-tact.\n" . "php {$argv['0']} true delete      ...: Convert c/b/p to tpg and TRUNCATE current collections/binaries/parts tables.\n"));
}
$clen = $pdo->queryOneRow('SELECT COUNT(*) AS total FROM collections;');
$cdone = 0;
$ccount = 1;
$gdone = 1;
$actgroups = $groups->getActive();
$glen = count($actgroups);
$newtables = $glen * 3;
$begintime = time();
echo "Creating new collections, binaries, and parts tables for each active group...\n";
foreach ($actgroups as $group) {
    if ($groups->createNewTPGTables($group['id']) === false) {
        exit($pdo->log->error("There is a problem creating new parts/files tables for group {$group['name']}."));
    }
    $consoletools->overWrite("Tables Created: " . $consoletools->percentString($gdone * 3, $newtables));
    $gdone++;
}
$endtime = time();
echo "\nTable creation took " . $consoletools->convertTime($endtime - $begintime) . ".\n";
$starttime = time();
echo "\nNew tables created, moving data from old tables to new tables.\nThis will take awhile....\n\n";
while ($cdone < $clen['total']) {
    // Only load 1000 collections per loop to not overload memory.
    $collections = $pdo->queryAssoc('select * from collections limit ' . $cdone . ',1000;');
    if ($collections instanceof \Traversable) {
        foreach ($collections as $collection) {
            $collection['subject'] = $pdo->escapeString($collection['subject']);
            $collection['fromname'] = $pdo->escapeString($collection['fromname']);
            $collection['date'] = $pdo->escapeString($collection['date']);
            $collection['collectionhash'] = $pdo->escapeString($collection['collectionhash']);
示例#2
0
$iFilesProcessed = $iFilesCounted = 0;
$time = TIME();
echo "\nReorganizing files to Level {$newLevel} from: {$sourcePath} This could take a while...\n";
//$consoleTools = new \ConsoleTools();
foreach ($objects as $filestoprocess => $nzbFile) {
    if ($nzbFile->getExtension() != "gz") {
        continue;
    }
    $newFileName = $nzb->getNZBPath(str_replace(".nzb.gz", "", $nzbFile->getBasename()), $newLevel, true);
    if ($newFileName != $nzbFile) {
        rename($nzbFile, $newFileName);
        chmod($newFileName, 0777);
    }
    $iFilesProcessed++;
    if ($iFilesProcessed % 100 == 0) {
        $consoleTools->overWrite("Reorganized {$iFilesProcessed}");
    }
}
$pdo->ping(true);
$pdo->queryExec(sprintf("UPDATE settings SET value = %s WHERE setting = 'nzbsplitlevel'", $argv[1]));
$consoleTools->overWrite("Processed {$iFilesProcessed} nzbs in " . relativeTime($time) . "\n");
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 = "";