Beispiel #1
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 = "";
Beispiel #2
0
    exit($pdo->log->error("\nMandatory argument missing\n\n" . "This script will allow you to move from single 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 b/p to tpg leaving current binaries/parts tables in-tact.\n" . "php {$argv['0']} true delete      ...: Convert b/p to tpg and TRUNCATE current binaries/parts tables.\n"));
}
$blen = $pdo->queryOneRow('SELECT COUNT(*) AS total FROM binaries;');
$bdone = 0;
$bcount = 1;
$gdone = 1;
$actgroups = $groups->getActive();
$glen = count($actgroups);
$newtables = $glen * 3;
$begintime = time();
echo "Creating new 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 ($bdone < $blen['total']) {
    // Only load 1000 binaries per loop to not overload memory.
    $binaries = $pdo->queryAssoc('SELECT * FROM binaries LIMIT ' . $bdone . ',1000;');
    if ($binaries instanceof \Traversable) {
        foreach ($binaries as $binary) {
            $binary['name'] = $pdo->escapeString($binary['name']);
            $binary['fromname'] = $pdo->escapeString($binary['fromname']);
            $binary['date'] = $pdo->escapeString($binary['date']);
            $binary['binaryhash'] = $pdo->escapeString($binary['binarynhash']);