コード例 #1
0
function getPreName($argv)
{
    global $pdo;
    $timestart = time();
    $consoletools = new ConsoleTools(['ColorCLI' => $pdo->log]);
    $namefixer = new NameFixer(['Settings' => $pdo, 'ConsoleTools' => $consoletools]);
    $res = false;
    if (isset($argv[1]) && $argv[1] === "all") {
        $res = $pdo->queryDirect('SELECT id AS releaseid, name, searchname, groupid, categoryid, dehashstatus FROM releases WHERE prehashid = 0 AND ishashed = 1');
    } else {
        if (isset($argv[1]) && $argv[1] === "full") {
            $res = $pdo->queryDirect('SELECT id AS releaseid, name, searchname, groupid, categoryid, dehashstatus FROM releases WHERE categoryid = 8020 AND ishashed = 1 AND dehashstatus BETWEEN -6 AND 0');
        } else {
            if (isset($argv[1]) && is_numeric($argv[1])) {
                $res = $pdo->queryDirect('SELECT id AS releaseid, name, searchname, groupid, categoryid, dehashstatus FROM releases WHERE categoryid = 8020 AND ishashed = 1 AND dehashstatus BETWEEN -6 AND 0 ORDER BY postdate DESC LIMIT ' . $argv[1]);
            }
        }
    }
    $counter = $counted = $total = 0;
    if ($res !== false) {
        $total = $res->rowCount();
    }
    $show = !isset($argv[2]) || $argv[2] !== 'show' ? 0 : 1;
    if ($total > 0) {
        echo $pdo->log->header("\n" . number_format($total) . ' releases to process.');
        sleep(2);
        foreach ($res as $row) {
            $success = 0;
            if (preg_match('/[a-fA-F0-9]{32,40}/i', $row['name'], $matches)) {
                $success = $namefixer->matchPredbHash($matches[0], $row, 1, 1, true, $show);
            } else {
                if (preg_match('/[a-fA-F0-9]{32,40}/i', $row['searchname'], $matches)) {
                    $success = $namefixer->matchPredbHash($matches[0], $row, 1, 1, true, $show);
                }
            }
            if ($success === 0) {
                $pdo->queryDirect(sprintf('UPDATE releases SET dehashstatus = dehashstatus - 1 WHERE id = %d', $row['releaseid']));
            } else {
                $counted++;
            }
            if ($show === 0) {
                $consoletools->overWritePrimary("Renamed Releases: [" . number_format($counted) . "] " . $consoletools->percentString(++$counter, $total));
            }
        }
    }
    if ($total > 0) {
        echo $pdo->log->header("\nRenamed " . $counted . " releases in " . $consoletools->convertTime(TIME() - $timestart) . ".");
    } else {
        echo $pdo->log->info("\nNothing to do.");
    }
}
コード例 #2
0
function reCategorize($argv)
{
    $c = new ColorCLI();
    $where = '';
    $update = true;
    if (isset($argv[1]) && is_numeric($argv[1])) {
        $where = ' AND groupid = ' . $argv[1];
    } else {
        if (isset($argv[1]) && preg_match('/\\([\\d, ]+\\)/', $argv[1])) {
            $where = ' AND groupid IN ' . $argv[1];
        } else {
            if (isset($argv[1]) && $argv[1] === 'misc') {
                $where = ' AND categoryid IN (1090, 2020, 3050, 4040, 5050, 6050, 7050, 8010)';
            }
        }
    }
    if (isset($argv[2]) && $argv[2] === 'test') {
        $update = false;
    }
    if (isset($argv[1]) && (is_numeric($argv[1]) || preg_match('/\\([\\d, ]+\\)/', $argv[1]))) {
        echo $c->header("Categorizing all releases in {$argv[1]} using searchname. This can take a while, be patient.");
    } else {
        if (isset($argv[1]) && $argv[1] == "misc") {
            echo $c->header("Categorizing all releases in misc categories using searchname. This can take a while, be patient.");
        } else {
            echo $c->header("Categorizing all releases using searchname. This can take a while, be patient.");
        }
    }
    $timestart = TIME();
    if (isset($argv[1]) && (is_numeric($argv[1]) || preg_match('/\\([\\d, ]+\\)/', $argv[1])) || $argv[1] === 'misc') {
        $chgcount = categorizeRelease($update, str_replace(" AND", "WHERE", $where), true);
    } else {
        $chgcount = categorizeRelease($update, "", true);
    }
    $consoletools = new ConsoleTools();
    $time = $consoletools->convertTime(TIME() - $timestart);
    if ($update === true) {
        echo $c->header("Finished re-categorizing " . number_format($chgcount) . " releases in " . $time . " , \tusing the searchname.\n");
    } else {
        echo $c->header("Finished re-categorizing in " . $time . " , using the searchname.\n" . "This would have changed " . number_format($chgcount) . " releases but no updates were done.\n");
    }
}
コード例 #3
0
ファイル: update_groups.php プロジェクト: Jay204/nZEDb
<?php

require_once dirname(__FILE__) . '/../../../config.php';
use nzedb\db\Settings;
$start = TIME();
$pdo = new Settings();
$consoleTools = new ConsoleTools(['ColorCLI' => $pdo->log]);
// Create the connection here and pass
$nntp = new NNTP(['Settings' => $pdo]);
if ($nntp->doConnect() !== true) {
    exit($pdo->log->error("Unable to connect to usenet."));
}
echo $pdo->log->header("Getting first/last for all your active groups.");
$data = $nntp->getGroups();
if ($nntp->isError($data)) {
    exit($pdo->log->error("Failed to getGroups() from nntp server."));
}
echo $pdo->log->header("Inserting new values into shortgroups table.");
$pdo->queryExec('TRUNCATE TABLE shortgroups');
// Put into an array all active groups
$res = $pdo->query('SELECT name FROM groups WHERE active = 1 OR backfill = 1');
foreach ($data as $newgroup) {
    if (myInArray($res, $newgroup['group'], 'name')) {
        $pdo->queryInsert(sprintf('INSERT INTO shortgroups (name, first_record, last_record, updated) VALUES (%s, %s, %s, NOW())', $pdo->escapeString($newgroup['group']), $pdo->escapeString($newgroup['first']), $pdo->escapeString($newgroup['last'])));
        echo $pdo->log->primary('Updated ' . $newgroup['group']);
    }
}
echo $pdo->log->header('Running time: ' . $consoleTools->convertTimer(TIME() - $start));
function myInArray($array, $value, $key)
{
    //loop through the array
コード例 #4
0
ファイル: renametopre.php プロジェクト: RickDB/newznab-tmux
function catRelease($type, $where, $echooutput = false)
{
    global $pdo;
    $cat = new \Categorize(['Settings' => $pdo]);
    $consoletools = new \ConsoleTools(['ColorCLI' => $pdo->log]);
    $relcount = 0;
    echo $pdo->log->primary("SELECT id, " . $type . ", groupid FROM releases " . $where);
    $resrel = $pdo->queryDirect("SELECT id, " . $type . ", groupid FROM releases " . $where);
    $total = $resrel->rowCount();
    if ($total > 0) {
        foreach ($resrel as $rowrel) {
            $catId = $cat->determineCategory($rowrel['groupid'], $rowrel[$type]);
            $pdo->queryExec(sprintf("UPDATE releases SET iscategorized = 1, categoryid = %d WHERE id = %d", $catId, $rowrel['id']));
            $relcount++;
            if ($echooutput) {
                $consoletools->overWritePrimary("Categorizing: " . $consoletools->percentString($relcount, $total));
            }
        }
    }
    if ($echooutput !== false && $relcount > 0) {
        echo "\n";
    }
    return $relcount;
}
コード例 #5
0
ファイル: resetSearchname.php プロジェクト: Jay204/nZEDb
         $namefixer->fixNamesWithNfo(2, 1, 1, 1, $show);
         $namefixer->fixNamesWithFiles(2, 1, 1, 1, $show);
         $timetotal = $consoletools->convertTime(time() - $timestart);
         echo $pdo->log->header("Finished recreating search names / recategorizing / refixing names in " . $timetotal);
     } else {
         exit($pdo->log->info("You have no releases in the DB."));
     }
 } else {
     if (isset($argv[1]) && $argv[1] == "reset") {
         $pdo = new Settings();
         $res = $pdo->query("SELECT releases.id, releases.name, releases.fromname, releases.size, groups.name AS gname FROM releases INNER JOIN groups ON releases.group_id = groups.id");
         if (count($res) > 0) {
             echo $pdo->log->header("Going to reset search names, this can take a while.");
             $done = 0;
             $timestart = time();
             $consoletools = new ConsoleTools(['ColorCLI' => $pdo->log]);
             foreach ($res as $row) {
                 $rc = new ReleaseCleaning($pdo);
                 $newname = $rc->releaseCleaner($row['name'], $row['fromname'], $row['size'], $row['gname']);
                 if (is_array($newname)) {
                     $newname = $newname['cleansubject'];
                 }
                 $newname = $pdo->escapeString($newname);
                 $pdo->queryExec(sprintf("UPDATE releases SET searchname = %s where id = %d", $newname, $row['id']));
                 $sphinx->updateReleaseSearchName($newname, $row['id']);
                 $done++;
                 $consoletools->overWritePrimary("Renaming:" . $consoletools->percentString($done, count($res)));
             }
             $timenc = $consoletools->convertTime(TIME() - $timestart);
             echo $pdo->log->header($done . " releases renamed in " . $timenc);
         }
コード例 #6
0
ファイル: convert_to_tpg_alt.php プロジェクト: Jay204/nZEDb
<?php

require_once dirname(__FILE__) . '/../../../www/config.php';
use nzedb\db\Settings;
$pdo = new Settings();
if (!isset($argv[1]) || $argv[1] != 'true') {
    exit($pdo->log->error("\nThis script will move all collections, binaries, parts into tables per group.\n\n" . "php {$argv['0']} true                ...: To process all parts and leave the parts/binaries/collections tables intact.\n" . "php {$argv['0']} true truncate       ...: To process all parts and truncate parts/binaries/collections tables after completed.\n"));
}
$start = time();
$consoleTools = new ConsoleTools(['ColorCLI' => $pdo->log]);
$groups = new Groups(['Settings' => $pdo]);
$actgroups = $pdo->query("SELECT DISTINCT group_id from collections");
echo $pdo->log->info("Creating new collections, binaries, and parts tables for each group that has collections.");
foreach ($actgroups as $group) {
    $pdo->queryExec("DROP TABLE IF EXISTS collections_" . $group['group_id']);
    $pdo->queryExec("DROP TABLE IF EXISTS binaries_" . $group['group_id']);
    $pdo->queryExec("DROP TABLE IF EXISTS parts_" . $group['group_id']);
    if ($groups->createNewTPGTables($group['group_id']) === false) {
        exit($pdo->log->error("\nThere is a problem creating new parts/files tables for group {$group['name']}.\n"));
    }
}
$collections_rows = $pdo->queryDirect("SELECT group_id FROM collections GROUP BY group_id");
echo $pdo->log->info("Counting parts, this could table a few minutes.");
$parts_count = $pdo->queryOneRow("SELECT COUNT(*) AS cnt FROM parts");
$i = 0;
if ($collections_rows instanceof Traversable) {
    foreach ($collections_rows as $row) {
        $groupName = $groups->getByNameByID($row['group_id']);
        echo $pdo->log->header("Processing {$groupName}");
        //collection
        $pdo->queryExec("INSERT IGNORE INTO collections_" . $row['group_id'] . " (subject, fromname, date, xref, totalfiles, group_id, collectionhash, dateadded, filecheck, filesize, releaseid) " . "SELECT subject, fromname, date, xref, totalfiles, group_id, collectionhash, dateadded, filecheck, filesize, releaseid FROM collections WHERE group_id = {$row['group_id']}");
コード例 #7
0
 /**
  * Delete crap releases.
  *
  * @param bool       $delete                 Delete the release or just show the result?
  * @param int|string $time                   Time in hours (to select old releases) or 'full' for no time limit.
  * @param string     $type                   Type of query to run [blacklist, executable, gibberish, hashed, installbin, passworded,
  *                                           passwordurl, sample, scr, short, size, ''] ('' runs against all types)
  * @param string     $blacklistID
  *
  * @return string|bool
  */
 public function removeCrap($delete, $time, $type = '', $blacklistID = '')
 {
     $this->timeStart = time();
     $this->delete = $delete;
     $this->blacklistID = '';
     if (isset($blacklistID) && is_numeric($blacklistID)) {
         $this->blacklistID = sprintf("AND id = %d", $blacklistID);
     }
     $time = trim($time);
     $this->crapTime = '';
     $type = strtolower(trim($type));
     switch ($time) {
         case 'full':
             if ($this->echoCLI) {
                 echo $this->pdo->log->header("Removing " . ($type == '' ? "All crap releases " : $type . " crap releases") . " - no time limit.\n");
             }
             break;
         default:
             if (!is_numeric($time)) {
                 $this->error = 'Error, time must be a number or full.';
                 return $this->returnError();
             }
             if ($this->echoCLI) {
                 echo $this->pdo->log->header("Removing " . ($type == '' ? "All crap releases " : $type . " crap releases") . " from the past " . $time . " hour(s).\n");
             }
             $this->crapTime = ' AND r.adddate > (NOW() - INTERVAL ' . $time . ' HOUR)';
             break;
     }
     $this->deletedCount = 0;
     $type = strtolower(trim($type));
     switch ($type) {
         case 'blacklist':
             $this->removeBlacklist();
             break;
         case 'blfiles':
             $this->removeBlacklistFiles();
             break;
         case 'executable':
             $this->removeExecutable();
             break;
         case 'gibberish':
             $this->removeGibberish();
             break;
         case 'hashed':
             $this->removeHashed();
             break;
         case 'installbin':
             $this->removeInstallBin();
             break;
         case 'passworded':
             $this->removePassworded();
             break;
         case 'passwordurl':
             $this->removePasswordURL();
             break;
         case 'sample':
             $this->removeSample();
             break;
         case 'scr':
             $this->removeSCR();
             break;
         case 'short':
             $this->removeShort();
             break;
         case 'size':
             $this->removeSize();
             break;
         case 'huge':
             $this->removeHuge();
             break;
         case 'codec':
             $this->removeCodecPoster();
             break;
         case '':
             $this->removeBlacklist();
             $this->removeBlacklistFiles();
             $this->removeExecutable();
             $this->removeGibberish();
             $this->removeHashed();
             $this->removeInstallBin();
             $this->removePassworded();
             $this->removeSample();
             $this->removeSCR();
             $this->removeShort();
             $this->removeSize();
             $this->removeHuge();
             $this->removeCodecPoster();
             break;
         default:
             $this->error = 'Wrong type: ' . $type;
             return $this->returnError();
     }
     if ($this->echoCLI) {
         echo $this->pdo->log->headerOver(($this->delete ? "Deleted " : "Would have deleted ") . $this->deletedCount . " release(s). This script ran for ");
         echo $this->pdo->log->header($this->consoleTools->convertTime(TIME() - $this->timeStart));
     }
     return $this->browser ? 'Success! ' . ($this->delete ? "Deleted " : "Would have deleted ") . $this->deletedCount . ' release(s) in ' . $this->consoleTools->convertTime(TIME() - $this->timeStart) : true;
 }
コード例 #8
0
ファイル: showsleep.php プロジェクト: RickDB/newznab-tmux
<?php

//This script is ported from nZEDb and adapted for newznab
require_once 'config.php';
// This script is simply so I can show sleep progress in bash script
$consoletools = new ConsoleTools();
if (isset($argv[1]) && is_numeric($argv[1])) {
    $consoletools->showsleep($argv[1]);
}
コード例 #9
0
ファイル: renametopre.php プロジェクト: Jay204/nZEDb
function preName($argv, $argc)
{
    global $pdo;
    $groups = new Groups(['Settings' => $pdo]);
    $category = new Categorize(['Settings' => $pdo]);
    $internal = $external = $pre = 0;
    $show = 2;
    if ($argv[$argc - 1] === 'show') {
        $show = 1;
    } else {
        if ($argv[$argc - 1] === 'bad') {
            $show = 3;
        }
    }
    $counter = 0;
    $pdo->log = new ColorCLI();
    $full = $all = $usepre = false;
    $what = $where = '';
    if ($argv[1] === 'full') {
        $full = true;
    } else {
        if ($argv[1] === 'all') {
            $all = true;
        } else {
            if ($argv[1] === 'preid') {
                $usepre = true;
            } else {
                if (is_numeric($argv[1])) {
                    $what = ' AND adddate > NOW() - INTERVAL ' . $argv[1] . ' HOUR';
                }
            }
        }
    }
    if ($usepre === true) {
        $where = '';
        $why = ' WHERE preid = 0 AND nzbstatus = 1';
    } else {
        if (isset($argv[1]) && is_numeric($argv[1])) {
            $where = '';
            $why = ' WHERE nzbstatus = 1 AND isrenamed = 0';
        } else {
            if (isset($argv[2]) && is_numeric($argv[2]) && $full === true) {
                $where = ' AND group_id = ' . $argv[2];
                $why = ' WHERE nzbstatus = 1 AND isrenamed = 0';
            } else {
                if (isset($argv[2]) && preg_match('/\\([\\d, ]+\\)/', $argv[2]) && $full === true) {
                    $where = ' AND group_id IN ' . $argv[2];
                    $why = ' WHERE nzbstatus = 1 AND isrenamed = 0';
                } else {
                    if (isset($argv[2]) && preg_match('/\\([\\d, ]+\\)/', $argv[2]) && $all === true) {
                        $where = ' AND group_id IN ' . $argv[2];
                        $why = ' WHERE nzbstatus = 1';
                    } else {
                        if (isset($argv[2]) && is_numeric($argv[2]) && $all === true) {
                            $where = ' AND group_id = ' . $argv[2];
                            $why = ' WHERE nzbstatus = 1 and preid = 0';
                        } else {
                            if (isset($argv[2]) && is_numeric($argv[2])) {
                                $where = ' AND group_id = ' . $argv[2];
                                $why = ' WHERE nzbstatus = 1 AND isrenamed = 0';
                            } else {
                                if ($full === true) {
                                    $why = ' WHERE nzbstatus = 1 AND (isrenamed = 0 OR categoryid between 7000 AND 7999)';
                                } else {
                                    if ($all === true) {
                                        $why = ' WHERE nzbstatus = 1';
                                    } else {
                                        $why = ' WHERE 1=1';
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    resetSearchnames();
    echo $pdo->log->header("SELECT id, name, searchname, fromname, size, group_id, categoryid FROM releases" . $why . $what . $where . ";\n");
    $res = $pdo->queryDirect("SELECT id, name, searchname, fromname, size, group_id, categoryid FROM releases" . $why . $what . $where);
    $total = $res->rowCount();
    if ($total > 0) {
        $consoletools = new ConsoleTools(['ColorCLI' => $pdo->log]);
        foreach ($res as $row) {
            $groupname = $groups->getByNameByID($row['group_id']);
            $cleanerName = releaseCleaner($row['name'], $row['fromname'], $row['size'], $groupname, $usepre);
            $preid = 0;
            $predb = $predbfile = $increment = false;
            if (!is_array($cleanerName)) {
                $cleanName = trim((string) $cleanerName);
                $propername = $increment = true;
                if ($cleanName != '' && $cleanerName != false) {
                    $run = $pdo->queryOneRow("SELECT id FROM predb WHERE title = " . $pdo->escapeString($cleanName));
                    if (isset($run['id'])) {
                        $preid = $run['id'];
                        $predb = true;
                    }
                }
            } else {
                $cleanName = trim($cleanerName["cleansubject"]);
                $propername = $cleanerName["properlynamed"];
                if (isset($cleanerName["increment"])) {
                    $increment = $cleanerName["increment"];
                }
                if (isset($cleanerName["predb"])) {
                    $preid = $cleanerName["predb"];
                    $predb = true;
                }
            }
            if ($cleanName != '') {
                if (preg_match('/alt\\.binaries\\.e\\-?book(\\.[a-z]+)?/', $groupname)) {
                    if (preg_match('/^[0-9]{1,6}-[0-9]{1,6}-[0-9]{1,6}$/', $cleanName, $match)) {
                        $rf = new ReleaseFiles($pdo);
                        $files = $rf->get($row['id']);
                        foreach ($files as $f) {
                            if (preg_match('/^(?P<title>.+?)(\\[\\w\\[\\]\\(\\). -]+)?\\.(pdf|htm(l)?|epub|mobi|azw|tif|doc(x)?|lit|txt|rtf|opf|fb2|prc|djvu|cb[rz])/', $f["name"], $match)) {
                                $cleanName = $match['title'];
                                break;
                            }
                        }
                    }
                }
                //try to match clean name against predb filename
                $prefile = $pdo->queryOneRow("SELECT id, title FROM predb WHERE filename = " . $pdo->escapeString($cleanName));
                if (isset($prefile['id'])) {
                    $preid = $prefile['id'];
                    $cleanName = $prefile['title'];
                    $predbfile = true;
                    $propername = true;
                }
                if ($cleanName != $row['name'] && $cleanName != $row['searchname']) {
                    if (strlen(utf8_decode($cleanName)) <= 3) {
                    } else {
                        $determinedcat = $category->determineCategory($cleanName, $row["group_id"]);
                        if ($propername == true) {
                            $pdo->queryExec(sprintf("UPDATE releases SET rageid = -1, seriesfull = NULL, season = NULL, episode = NULL, tvtitle = NULL, tvairdate = NULL, imdbid = NULL, musicinfoid = NULL, consoleinfoid = NULL, bookinfoid = NULL, anidbid = NULL, " . "iscategorized = 1, isrenamed = 1, searchname = %s, categoryid = %d, preid = " . $preid . " WHERE id = %d", $pdo->escapeString($cleanName), $determinedcat, $row['id']));
                        } else {
                            $pdo->queryExec(sprintf("UPDATE releases SET rageid = -1, seriesfull = NULL, season = NULL, episode = NULL, tvtitle = NULL, tvairdate = NULL, imdbid = NULL, musicinfoid = NULL, consoleinfoid = NULL, bookinfoid = NULL, anidbid = NULL,  " . "iscategorized = 1, searchname = %s, categoryid = %d, preid = " . $preid . " WHERE id = %d", $pdo->escapeString($cleanName), $determinedcat, $row['id']));
                        }
                        if ($increment === true) {
                            $internal++;
                        } else {
                            if ($predb === true) {
                                $pre++;
                            } else {
                                if ($predbfile === true) {
                                    $pre++;
                                } else {
                                    if ($propername === true) {
                                        $external++;
                                    }
                                }
                            }
                        }
                        if ($show === 1) {
                            $oldcatname = $category->getNameByID($row["categoryid"]);
                            $newcatname = $category->getNameByID($determinedcat);
                            NameFixer::echoChangedReleaseName(array('new_name' => $cleanName, 'old_name' => $row["searchname"], 'new_category' => $newcatname, 'old_category' => $oldcatname, 'group' => $groupname, 'release_id' => $row["id"], 'method' => 'misc/testing/Dev/renametopre.php'));
                        }
                    }
                } else {
                    if ($show === 3 && preg_match('/^\\[?\\d*\\].+?yEnc/i', $row['name'])) {
                        echo $pdo->log->primary($row['name']);
                    }
                }
            }
            if ($cleanName == $row['name']) {
                $pdo->queryExec(sprintf("UPDATE releases SET isrenamed = 1, iscategorized = 1 WHERE id = %d", $row['id']));
            }
            if ($show === 2 && $usepre === false) {
                $consoletools->overWritePrimary("Renamed Releases:  [Internal=" . number_format($internal) . "][External=" . number_format($external) . "][Predb=" . number_format($pre) . "] " . $consoletools->percentString(++$counter, $total));
            } else {
                if ($show === 2 && $usepre === true) {
                    $consoletools->overWritePrimary("Renamed Releases:  [" . number_format($pre) . "] " . $consoletools->percentString(++$counter, $total));
                }
            }
        }
    }
    echo $pdo->log->header("\n" . number_format($pre) . " renamed using preDB Match\n" . number_format($external) . " renamed using ReleaseCleaning.php\n" . number_format($internal) . " using renametopre.php\nout of " . number_format($total) . " releases.\n");
    if (isset($argv[1]) && is_numeric($argv[1]) && !isset($argv[2])) {
        echo $pdo->log->header("Categorizing all releases using searchname from the last {$argv[1]} hours. This can take a while, be patient.");
    } else {
        if (isset($argv[1]) && $argv[1] !== "all" && isset($argv[2]) && !is_numeric($argv[2]) && !preg_match('/\\([\\d, ]+\\)/', $argv[2])) {
            echo $pdo->log->header("Categorizing all non-categorized releases in other->misc using searchname. This can take a while, be patient.");
        } else {
            if (isset($argv[1]) && isset($argv[2]) && (is_numeric($argv[2]) || preg_match('/\\([\\d, ]+\\)/', $argv[2]))) {
                echo $pdo->log->header("Categorizing all non-categorized releases in {$argv[2]} using searchname. This can take a while, be patient.");
            } else {
                echo $pdo->log->header("Categorizing all releases using searchname. This can take a while, be patient.");
            }
        }
    }
    $timestart = TIME();
    if (isset($argv[1]) && is_numeric($argv[1])) {
        $relcount = catRelease("searchname", "WHERE (iscategorized = 0 OR categoryID = 7010) AND adddate > NOW() - INTERVAL " . $argv[1] . " HOUR", true);
    } else {
        if (isset($argv[2]) && preg_match('/\\([\\d, ]+\\)/', $argv[2]) && $full === true) {
            $relcount = catRelease("searchname", str_replace(" AND", "WHERE", $where) . " AND iscategorized = 0 ", true);
        } else {
            if (isset($argv[2]) && preg_match('/\\([\\d, ]+\\)/', $argv[2]) && $all === true) {
                $relcount = catRelease("searchname", str_replace(" AND", "WHERE", $where), true);
            } else {
                if (isset($argv[2]) && is_numeric($argv[2]) && $argv[1] == "full") {
                    $relcount = catRelease("searchname", str_replace(" AND", "WHERE", $where) . " AND iscategorized = 0 ", true);
                } else {
                    if (isset($argv[2]) && is_numeric($argv[2]) && $argv[1] == "all") {
                        $relcount = catRelease("searchname", str_replace(" AND", "WHERE", $where), true);
                    } else {
                        if (isset($argv[1]) && $argv[1] == "full") {
                            $relcount = catRelease("searchname", "WHERE categoryID = 7010 OR iscategorized = 0", true);
                        } else {
                            if (isset($argv[1]) && $argv[1] == "all") {
                                $relcount = catRelease("searchname", "", true);
                            } else {
                                if (isset($argv[1]) && $argv[1] == "preid") {
                                    $relcount = catRelease("searchname", "WHERE preid = 0 AND nzbstatus = 1", true);
                                } else {
                                    $relcount = catRelease("searchname", "WHERE (iscategorized = 0 OR categoryID = 7010) AND adddate > NOW() - INTERVAL " . $argv[1] . " HOUR", true);
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    $consoletools = new ConsoleTools(['ColorCLI' => $pdo->log]);
    $time = $consoletools->convertTime(TIME() - $timestart);
    echo $pdo->log->header("Finished categorizing " . number_format($relcount) . " releases in " . $time . " seconds, using the usenet subject.\n");
    resetSearchnames();
}
コード例 #10
0
ファイル: nzb-reorg.php プロジェクト: Jay204/nZEDb
<?php

require_once dirname(__FILE__) . '/../../../www/config.php';
use nzedb\db\Settings;
if (!isset($argv[1]) || !isset($argv[2])) {
    exit("ERROR: You must supply the level you want to reorganize it to, and the source directory  (You would use: 3 .../nZEDb/resources/nzb/ to move it to 3 levels deep)\n");
}
$pdo = new Settings();
$nzb = new NZB($pdo);
$consoleTools = new ConsoleTools();
$newLevel = $argv[1];
$sourcePath = $argv[2];
$objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($sourcePath));
$filestoprocess = array();
$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}");
    }
コード例 #11
0
ファイル: nzb-import.php プロジェクト: Jay204/nZEDb
<?php

require_once dirname(__FILE__) . '/../../../../www/config.php';
use nzedb\db\Settings;
$pdo = new Settings();
if (!isset($argv[1])) {
    exit($pdo->log->error("\nYou must supply a path as the first argument. Two additional, optional arguments can also be used.\n\n" . "php {$argv['0']} /path/to/import true 1000            ...: To import using the filename as release searchname, limited to 1000\n" . "php {$argv['0']} /path/to/import false                ...: To import using the subject as release searchname\n"));
}
$consoleTools = new ConsoleTools(['ColorCLI' => $pdo->log]);
$binaries = new Binaries(['Settings' => $pdo]);
$crosspostt = $pdo->getSetting('crossposttime');
$crosspostt = !empty($crosspostt) ? $crosspostt : 2;
$releasecleaning = new ReleaseCleaning($pdo);
$categorize = new Categorize(['Settings' => $pdo]);
$nzb = new NZB($pdo);
$releases = new Releases(['Settings' => $pdo]);
$nzbsperhour = $nzbSkipped = $maxtoprocess = 0;
if (isset($argv[2]) && is_numeric($argv[2])) {
    exit($pdo->log->error("\nTo use a max number to process, it must be the third argument. \nTo run:\nphp nzb-import.php /path [true, false] 1000\n"));
}
if (!isset($argv[2])) {
    $pieces = explode("   ", $argv[1]);
    $usenzbname = isset($pieces[1]) && $pieces[1] == 'true' ? true : false;
    $path = $pieces[0];
} else {
    $path = $argv[1];
    $usenzbname = isset($argv[2]) && $argv[2] == 'true' ? true : false;
}
if (isset($argv[3]) && is_numeric($argv[3])) {
    $maxtoprocess = $argv[3];
}
コード例 #12
0
<?php

require_once dirname(__FILE__) . '/../../../www/config.php';
use newznab\db\Settings;
/* This script will allow you to move from single binaries/parts tables to TPG without having to run reset_truncate.
  Please STOP all update scripts before running this script.

  Use the following options to run:
  php convert_to_tpg.php true               Convert c/b/p to tpg leaving current binaries/parts tables in-tact.
  php convert_to_tgp.php true delete        Convert c/b/p to tpg and TRUNCATE current binaries/parts tables.
 */
$debug = false;
$pdo = new Settings();
$groups = new \Groups(['Settings' => $pdo]);
$consoletools = new \ConsoleTools(['ColorCLI' => $pdo->log]);
$DoPartRepair = $pdo->getSetting('partrepair') == '0' ? false : true;
if (!isset($argv[1]) || $argv[1] != 'true') {
    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']}."));
コード例 #13
0
ファイル: ProcessReleases.php プロジェクト: Jay204/nZEDb
    /**
     * Delete releases using admin settings.
     * This deletes releases, regardless of group.
     *
     * @void
     * @access public
     */
    public function deleteReleases()
    {
        $startTime = time();
        $category = new \Category(['Settings' => $this->pdo]);
        $genres = new \Genres(['Settings' => $this->pdo]);
        $passwordDeleted = $duplicateDeleted = $retentionDeleted = $completionDeleted = $disabledCategoryDeleted = 0;
        $disabledGenreDeleted = $miscRetentionDeleted = $miscHashedDeleted = $categoryMinSizeDeleted = 0;
        // Delete old releases and finished collections.
        if ($this->echoCLI) {
            $this->pdo->log->doEcho($this->pdo->log->header("Process Releases -> Delete old releases and passworded releases."));
        }
        // Releases past retention.
        if ($this->pdo->getSetting('releaseretentiondays') != 0) {
            $releases = $this->pdo->queryDirect(sprintf('SELECT id, guid FROM releases WHERE postdate < (NOW() - INTERVAL %d DAY)', $this->pdo->getSetting('releaseretentiondays')));
            if ($releases instanceof \Traversable) {
                foreach ($releases as $release) {
                    $this->releases->deleteSingle(['g' => $release['guid'], 'i' => $release['id']], $this->nzb, $this->releaseImage);
                    $retentionDeleted++;
                }
            }
        }
        // Passworded releases.
        if ($this->pdo->getSetting('deletepasswordedrelease') == 1) {
            $releases = $this->pdo->queryDirect(sprintf('SELECT id, guid FROM releases WHERE passwordstatus = %d', \Releases::PASSWD_RAR));
            if ($releases instanceof \Traversable) {
                foreach ($releases as $release) {
                    $this->releases->deleteSingle(['g' => $release['guid'], 'i' => $release['id']], $this->nzb, $this->releaseImage);
                    $passwordDeleted++;
                }
            }
        }
        // Possibly passworded releases.
        if ($this->pdo->getSetting('deletepossiblerelease') == 1) {
            $releases = $this->pdo->queryDirect(sprintf('SELECT id, guid FROM releases WHERE passwordstatus = %d', \Releases::PASSWD_POTENTIAL));
            if ($releases instanceof \Traversable) {
                foreach ($releases as $release) {
                    $this->releases->deleteSingle(['g' => $release['guid'], 'i' => $release['id']], $this->nzb, $this->releaseImage);
                    $passwordDeleted++;
                }
            }
        }
        if ($this->crossPostTime != 0) {
            // Crossposted releases.
            do {
                $releases = $this->pdo->queryDirect(sprintf('SELECT id, guid FROM releases WHERE adddate > (NOW() - INTERVAL %d HOUR) GROUP BY name HAVING COUNT(name) > 1', $this->crossPostTime));
                $total = 0;
                if ($releases && $releases->rowCount()) {
                    $total = $releases->rowCount();
                    foreach ($releases as $release) {
                        $this->releases->deleteSingle(['g' => $release['guid'], 'i' => $release['id']], $this->nzb, $this->releaseImage);
                        $duplicateDeleted++;
                    }
                }
            } while ($total > 0);
        }
        if ($this->completion > 0) {
            $releases = $this->pdo->queryDirect(sprintf('SELECT id, guid FROM releases WHERE completion < %d AND completion > 0', $this->completion));
            if ($releases instanceof \Traversable) {
                foreach ($releases as $release) {
                    $this->releases->deleteSingle(['g' => $release['guid'], 'i' => $release['id']], $this->nzb, $this->releaseImage);
                    $completionDeleted++;
                }
            }
        }
        // Disabled categories.
        $disabledCategories = $category->getDisabledIDs();
        if (count($disabledCategories) > 0) {
            foreach ($disabledCategories as $disabledCategory) {
                $releases = $this->pdo->queryDirect(sprintf('SELECT id, guid FROM releases WHERE categoryid = %d', $disabledCategory['id']));
                if ($releases instanceof \Traversable) {
                    foreach ($releases as $release) {
                        $disabledCategoryDeleted++;
                        $this->releases->deleteSingle(['g' => $release['guid'], 'i' => $release['id']], $this->nzb, $this->releaseImage);
                    }
                }
            }
        }
        // Delete smaller than category minimum sizes.
        $categories = $this->pdo->queryDirect('
			SELECT c.id AS id,
			CASE WHEN c.minsize = 0 THEN cp.minsize ELSE c.minsize END AS minsize
			FROM category c
			INNER JOIN category cp ON cp.id = c.parentid
			WHERE c.parentid IS NOT NULL');
        if ($categories instanceof \Traversable) {
            foreach ($categories as $category) {
                if ($category['minsize'] > 0) {
                    $releases = $this->pdo->queryDirect(sprintf('
							SELECT r.id, r.guid
							FROM releases r
							WHERE r.categoryid = %d
							AND r.size < %d', $category['id'], $category['minsize']));
                    if ($releases instanceof \Traversable) {
                        foreach ($releases as $release) {
                            $this->releases->deleteSingle(['g' => $release['guid'], 'i' => $release['id']], $this->nzb, $this->releaseImage);
                            $categoryMinSizeDeleted++;
                        }
                    }
                }
            }
        }
        // Disabled music genres.
        $genrelist = $genres->getDisabledIDs();
        if (count($genrelist) > 0) {
            foreach ($genrelist as $genre) {
                $releases = $this->pdo->queryDirect(sprintf('
						SELECT id, guid
						FROM releases
						INNER JOIN (SELECT id AS mid FROM musicinfo WHERE musicinfo.genre_id = %d) mi
						ON musicinfoid = mid', $genre['id']));
                if ($releases instanceof \Traversable) {
                    foreach ($releases as $release) {
                        $disabledGenreDeleted++;
                        $this->releases->deleteSingle(['g' => $release['guid'], 'i' => $release['id']], $this->nzb, $this->releaseImage);
                    }
                }
            }
        }
        // Misc other.
        if ($this->pdo->getSetting('miscotherretentionhours') > 0) {
            $releases = $this->pdo->queryDirect(sprintf('
					SELECT id, guid
					FROM releases
					WHERE categoryid = %d
					AND adddate <= NOW() - INTERVAL %d HOUR', \Category::CAT_MISC, $this->pdo->getSetting('miscotherretentionhours')));
            if ($releases instanceof \Traversable) {
                foreach ($releases as $release) {
                    $this->releases->deleteSingle(['g' => $release['guid'], 'i' => $release['id']], $this->nzb, $this->releaseImage);
                    $miscRetentionDeleted++;
                }
            }
        }
        // Misc hashed.
        if ($this->pdo->getSetting('mischashedretentionhours') > 0) {
            $releases = $this->pdo->queryDirect(sprintf('
					SELECT id, guid
					FROM releases
					WHERE categoryid = %d
					AND adddate <= NOW() - INTERVAL %d HOUR', \Category::CAT_OTHER_HASHED, $this->pdo->getSetting('mischashedretentionhours')));
            if ($releases instanceof \Traversable) {
                foreach ($releases as $release) {
                    $this->releases->deleteSingle(['g' => $release['guid'], 'i' => $release['id']], $this->nzb, $this->releaseImage);
                    $miscHashedDeleted++;
                }
            }
        }
        if ($this->echoCLI) {
            $this->pdo->log->doEcho($this->pdo->log->primary('Removed releases: ' . number_format($retentionDeleted) . ' past retention, ' . number_format($passwordDeleted) . ' passworded, ' . number_format($duplicateDeleted) . ' crossposted, ' . number_format($disabledCategoryDeleted) . ' from disabled categories, ' . number_format($categoryMinSizeDeleted) . ' smaller than category settings, ' . number_format($disabledGenreDeleted) . ' from disabled music genres, ' . number_format($miscRetentionDeleted) . ' from misc->other' . number_format($miscHashedDeleted) . ' from misc->hashed' . ($this->completion > 0 ? ', ' . number_format($completionDeleted) . ' under ' . $this->completion . '% completion.' : '.')));
            $totalDeleted = $retentionDeleted + $passwordDeleted + $duplicateDeleted + $disabledCategoryDeleted + $disabledGenreDeleted + $miscRetentionDeleted + $miscHashedDeleted + $completionDeleted + $categoryMinSizeDeleted;
            if ($totalDeleted > 0) {
                $this->pdo->log->doEcho($this->pdo->log->primary("Removed " . number_format($totalDeleted) . ' releases in ' . $this->consoleTools->convertTime(time() - $startTime)));
            }
        }
    }
コード例 #14
0
ファイル: Releases.php プロジェクト: engine9-/newznab-tmux
 /**
  * Categorize releases.
  *
  * @param int        $categorize
  * @param int|string $groupID (optional)
  *
  * @void
  * @access public
  */
 public function categorizeReleases($categorize, $groupID = '')
 {
     $startTime = time();
     if ($this->echoCLI) {
         echo $this->pdo->log->header("Process Releases -> Categorize releases.");
     }
     switch ((int) $categorize) {
         case 2:
             $type = 'searchname';
             break;
         case 1:
         default:
             $type = 'name';
             break;
     }
     $this->categorizeRelease($type, !empty($groupID) ? 'WHERE iscategorized = 0 AND groupid = ' . $groupID : 'WHERE iscategorized = 0');
     if ($this->echoCLI) {
         $this->pdo->log->doEcho($this->pdo->log->primary($this->consoleTools->convertTime(time() - $startTime)), true);
     }
 }
コード例 #15
0
<?php

require_once dirname(__FILE__) . '/../../../www/config.php';
use newznab\db\Settings;
$pdo = new Settings();
$consoletools = new \ConsoleTools(['ColorCLI' => $pdo->log]);
$ran = false;
if (isset($argv[1]) && $argv[1] === "all") {
    if (isset($argv[2]) && $argv[2] === "true") {
        $ran = true;
        $where = '';
        if (isset($argv[3]) && $argv[3] === "truncate") {
            echo "Truncating tables\n";
            $pdo->queryExec("TRUNCATE TABLE consoleinfo");
            $pdo->queryExec("TRUNCATE TABLE gamesinfo");
            $pdo->queryExec("TRUNCATE TABLE movieinfo");
            $pdo->queryExec("TRUNCATE TABLE releasevideo");
            $pdo->queryExec("TRUNCATE TABLE musicinfo");
            $pdo->queryExec("TRUNCATE TABLE bookinfo");
            $pdo->queryExec("TRUNCATE TABLE releasenfo");
            $pdo->queryExec("TRUNCATE TABLE releaseextrafull");
            $pdo->queryExec("TRUNCATE TABLE xxxinfo");
        }
        echo $pdo->log->header("Resetting all postprocessing");
        $qry = $pdo->queryDirect("SELECT id FROM releases");
        $affected = 0;
        if ($qry instanceof Traversable) {
            $total = $qry->rowCount();
            foreach ($qry as $releases) {
                $pdo->queryExec(sprintf("\n\t\t\t\t\t\tUPDATE releases\n\t\t\t\t\t\tSET consoleinfoid = NULL, gamesinfo_id = 0, imdbid = NULL, musicinfoid = NULL,\n\t\t\t\t\t\t\tbookinfoid = NULL, rageid = -1, xxxinfo_id = 0, passwordstatus = -1, haspreview = -1,\n\t\t\t\t\t\t\tjpgstatus = 0, videostatus = 0, audiostatus = 0, nfostatus = -1\n\t\t\t\t\t\tWHERE id = %d", $releases['id']));
                $consoletools->overWritePrimary("Resetting Releases:  " . $consoletools->percentString(++$affected, $total));
コード例 #16
0
ファイル: remove_exact_dupes.php プロジェクト: Jay204/nZEDb
<?php

require_once dirname(__FILE__) . '/../../../www/config.php';
use nzedb\db\Settings;
$pdo = new Settings();
if ($argc < 3 || !isset($argv[1]) || isset($argv[1]) && !is_numeric($argv[1])) {
    exit($pdo->log->error("\nIncorrect argument suppplied. This script will delete all duplicate releases matching on name, fromname, group_id and size.\n" . "Unfortunately, I can not guarantee which copy will be deleted.\n\n" . "php remove_exact_dupes.php 10 exact             ...: To delete all duplicates added within the last 10 hours.\n" . "php remove_exact_dupes.php 10 near              ...: To delete all duplicates with size variation of 1% and added within the last 10 hours.\n" . "php remove_exact_dupes.php 0 exact              ...: To delete all duplicates.\n" . "php remove_exact_dupes.php 0 near               ...: To delete all duplicates with size variation of 1%.\n" . "php remove_exact_dupes.php 10 exact dupes/      ...: To delete all duplicates added within the last 10 hours and save a copy of the nzb to dupes folder.\n"));
}
$crosspostt = $argv[1];
$releases = new Releases(['Settings' => $pdo]);
$count = $total = $all = 0;
$nzb = new NZB($pdo);
$ri = new ReleaseImage($pdo);
$consoleTools = new ConsoleTools(['ColorCLI' => $pdo->log]);
$size = ' size ';
if ($argv[2] === 'near') {
    $size = ' size between (size *.99) AND (size * 1.01) ';
}
if ($crosspostt != 0) {
    $query = sprintf('SELECT max(id) AS id, id AS idx, guid FROM releases WHERE adddate > (NOW() - INTERVAL %d HOUR) GROUP BY name, fromname, group_id,' . $size . 'HAVING COUNT(*) > 1', $crosspostt);
} else {
    $query = sprintf('SELECT max(id) AS id, id AS idx, guid FROM releases GROUP BY name, fromname, group_id,' . $size . 'HAVING COUNT(*) > 1');
}
do {
    $resrel = $pdo->queryDirect($query);
    if ($resrel instanceof Traversable) {
        $total = $resrel->rowCount();
        echo $pdo->log->header(number_format($total) . " Releases have Duplicates");
        foreach ($resrel as $rowrel) {
            $nzbpath = $nzb->getNZBPath($rowrel['guid']);
            if (isset($argv[3]) && is_dir($argv[3])) {
コード例 #17
0
                            $time = $consoletools->convertTime(TIME() - $timestart);
                            echo $pdo->log->primary("\n" . 'Finished categorizing ' . $relcount . ' releases in ' . $time . " seconds, using the usenet subject.");
                        } else {
                            if ($argv[1] == 6 && $argv[2] == 'true') {
                                echo $pdo->log->header("Categorizing releases in all sections using the searchname. This can take a while, be patient.");
                                $timestart = TIME();
                                $relcount = $releases->categorizeRelease('searchname', '');
                                $consoletools = new \ConsoleTools(['ColorCLI' => $pdo->log]);
                                $time = $consoletools->convertTime(TIME() - $timestart);
                                echo $pdo->log->primary("\n" . 'Finished categorizing ' . $relcount . ' releases in ' . $time . " seconds, using the search name.");
                            } else {
                                if ($argv[1] == 6 && $argv[2] == 'false') {
                                    echo $pdo->log->header("Categorizing releases in misc sections using the searchname. This can take a while, be patient.");
                                    $timestart = TIME();
                                    $relcount = $releases->categorizeRelease('searchname', 'WHERE categoryid IN (1090, 2020, 3050, 5050, 6050, 8010)');
                                    $consoletools = new \ConsoleTools(['ColorCLI' => $pdo->log]);
                                    $time = $consoletools->convertTime(TIME() - $timestart);
                                    echo $pdo->log->primary("\n" . 'Finished categorizing ' . $relcount . ' releases in ' . $time . " seconds, using the search name.");
                                } else {
                                    exit($pdo->log->error("Wrong argument, type php update_releases.php to see a list of valid arguments."));
                                }
                            }
                        }
                    }
                }
            }
        }
    }
} else {
    exit($pdo->log->error("\nWrong set of arguments.\n" . "php update_releases.php 1 true\t\t\t...: Creates releases and attempts to categorize new releases\n" . "php update_releases.php 2 true\t\t\t...: Creates releases and leaves new releases in other -> misc\n" . "\nYou must pass a second argument whether to post process or not, true or false\n" . "You can pass a third optional argument, a group name (ex.: alt.binaries.multimedia).\n" . "\nExtra commands::\n" . "php update_releases.php 4 true\t\t\t...: Puts all releases in other-> misc (also resets to look like they have never been categorized)\n" . "php update_releases.php 5 true\t\t\t...: Categorizes all releases in other-> misc (which have not been categorized already)\n" . "php update_releases.php 6 false\t\t\t...: Categorizes releases in misc sections using the search name\n" . "php update_releases.php 6 true\t\t\t...: Categorizes releases in all sections using the search name\n"));
}
コード例 #18
0
ファイル: PreDb.php プロジェクト: Jay204/nZEDb
 /**
  * Matches the hashes within the predb table to release files and subjects (names) which are hashed.
  *
  * @param $time
  * @param $echo
  * @param $cats
  * @param $namestatus
  * @param $show
  *
  * @return int
  */
 public function parseTitles($time, $echo, $cats, $namestatus, $show)
 {
     $namefixer = new NameFixer(['Echo' => $this->echooutput, 'ConsoleTools' => $this->pdo->log, 'Settings' => $this->pdo]);
     $consoletools = new ConsoleTools(['ColorCLI' => $this->pdo->log]);
     $updated = $checked = 0;
     $tq = '';
     if ($time == 1) {
         $tq = 'AND r.adddate > (NOW() - INTERVAL 3 HOUR) ORDER BY rf.releaseid, rf.size DESC';
     }
     $ct = '';
     if ($cats == 1) {
         $ct = 'AND r.categoryid IN (1090, 2020, 3050, 6050, 5050, 7010, 8050)';
     }
     if ($this->echooutput) {
         $te = '';
         if ($time == 1) {
             $te = ' in the past 3 hours';
         }
         echo $this->pdo->log->header('Fixing search names' . $te . " using the predb hash.");
     }
     $regex = "AND (r.ishashed = 1 OR rf.ishashed = 1)";
     if ($cats === 3) {
         $query = sprintf('SELECT r.id AS releaseid, r.name, r.searchname, r.categoryid, r.group_id, ' . 'dehashstatus, rf.name AS filename FROM releases r ' . 'LEFT OUTER JOIN releasefiles rf ON r.id = rf.releaseid ' . 'WHERE nzbstatus = 1 AND dehashstatus BETWEEN -6 AND 0 AND preid = 0 %s', $regex);
     } else {
         $query = sprintf('SELECT r.id AS releaseid, r.name, r.searchname, r.categoryid, r.group_id, ' . 'dehashstatus, rf.name AS filename FROM releases r ' . 'LEFT OUTER JOIN releasefiles rf ON r.id = rf.releaseid ' . 'WHERE nzbstatus = 1 AND isrenamed = 0 AND dehashstatus BETWEEN -6 AND 0 %s %s %s', $regex, $ct, $tq);
     }
     $res = $this->pdo->queryDirect($query);
     $total = $res->rowCount();
     echo $this->pdo->log->primary(number_format($total) . " releases to process.");
     if ($res instanceof Traversable) {
         foreach ($res as $row) {
             if (preg_match('/[a-fA-F0-9]{32,40}/i', $row['name'], $matches)) {
                 $updated = $updated + $namefixer->matchPredbHash($matches[0], $row, $echo, $namestatus, $this->echooutput, $show);
             } else {
                 if (preg_match('/[a-fA-F0-9]{32,40}/i', $row['filename'], $matches)) {
                     $updated = $updated + $namefixer->matchPredbHash($matches[0], $row, $echo, $namestatus, $this->echooutput, $show);
                 }
             }
             if ($show === 2) {
                 $consoletools->overWritePrimary("Renamed Releases: [" . number_format($updated) . "] " . $consoletools->percentString(++$checked, $total));
             }
         }
     }
     if ($echo == 1) {
         echo $this->pdo->log->header("\n" . $updated . " releases have had their names changed out of: " . number_format($checked) . " files.");
     } else {
         echo $this->pdo->log->header("\n" . $updated . " releases could have their names changed. " . number_format($checked) . " files were checked.");
     }
     return $updated;
 }
コード例 #19
0
ファイル: clean_nzbs.php プロジェクト: Jay204/nZEDb
<?php

require_once dirname(__FILE__) . '/../../../www/config.php';
use nzedb\db\Settings;
$pdo = new Settings();
if (isset($argv[1]) && ($argv[1] === "true" || $argv[1] === "delete")) {
    $releases = new Releases(['Settings' => $pdo]);
    $nzb = new NZB($pdo);
    $releaseImage = new ReleaseImage($pdo);
    $consoletools = new ConsoleTools(['ColorCLI' => $pdo->log]);
    $timestart = time();
    $checked = $deleted = 0;
    $couldbe = $argv[1] === "true" ? $couldbe = "could be " : "were ";
    echo $pdo->log->header('Getting List of nzbs to check against db.');
    $dirItr = new RecursiveDirectoryIterator($pdo->getSetting('nzbpath'));
    $itr = new RecursiveIteratorIterator($dirItr, RecursiveIteratorIterator::LEAVES_ONLY);
    foreach ($itr as $filePath) {
        if (is_file($filePath) && preg_match('/([a-f-0-9]+)\\.nzb\\.gz/', $filePath, $guid)) {
            $nzbfile = nzedb\utility\Utility::unzipGzipFile($filePath);
            if ($nzbfile) {
                $nzbfile = @simplexml_load_string($nzbfile);
            }
            if ($nzbfile) {
                $res = $pdo->queryOneRow(sprintf("SELECT id, guid FROM releases WHERE guid = %s", $pdo->escapeString(stristr($filePath->getFilename(), '.nzb.gz', true))));
                if ($res === false) {
                    if ($argv[1] === "delete") {
                        @copy($filePath, nZEDb_ROOT . "pooped/" . $guid[1] . ".nzb.gz");
                        $releases->deleteSingle(['g' => $guid[1], 'i' => false], $nzb, $releaseImage);
                        $deleted++;
                    }
                } else {
コード例 #20
0
ファイル: populate_nzb_guid.php プロジェクト: Jay204/nZEDb
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();
    }
    if ($total > 0) {
        echo $pdo->log->header("Creating nzb_guids for " . number_format($total) . " releases.");
        $releases = new Releases(['Settings' => $pdo]);
        $nzb = new NZB($pdo);
        $releaseImage = new ReleaseImage($pdo);
        $reccnt = 0;
        if ($relrecs instanceof Traversable) {
            foreach ($relrecs as $relrec) {
                $reccnt++;
                $nzbpath = $nzb->NZBPath($relrec['guid']);
                if ($nzbpath !== false) {
                    $nzbfile = nzedb\utility\Utility::unzipGzipFile($nzbpath);
                    if ($nzbfile) {
                        $nzbfile = @simplexml_load_string($nzbfile);
                    }
                    if (!$nzbfile) {
                        if (isset($delete) && $delete == 'delete') {
                            //echo "\n".$nzb->NZBPath($relrec['guid'])." is not a valid xml, deleting release.\n";
                            $releases->deleteSingle(['g' => $relrec['guid'], 'i' => $relrec['id']], $nzb, $releaseImage);
                            $deleted++;
                        }
                        continue;
                    }
                    $binary_names = array();
                    foreach ($nzbfile->file as $file) {
                        $binary_names[] = $file["subject"];
                    }
                    if (count($binary_names) == 0) {
                        if (isset($delete) && $delete == 'delete') {
                            //echo "\n".$nzb->NZBPath($relrec['guid'])." has no binaries, deleting release.\n";
                            $releases->deleteSingle(['g' => $relrec['guid'], 'i' => $relrec['id']], $nzb, $releaseImage);
                            $deleted++;
                        }
                        continue;
                    }
                    asort($binary_names);
                    foreach ($nzbfile->file as $file) {
                        if ($file["subject"] == $binary_names[0]) {
                            $segment = $file->segments->segment;
                            $nzb_guid = md5($segment);
                            $pdo->queryExec("UPDATE releases set nzb_guid = " . $pdo->escapestring($nzb_guid) . " WHERE id = " . $relrec["id"]);
                            $relcount++;
                            $consoletools->overWritePrimary("Created: [" . $deleted . "] " . $consoletools->percentString($reccnt, $total) . " Time:" . $consoletools->convertTimer(TIME() - $timestart));
                            break;
                        }
                    }
                } else {
                    if (isset($delete) && $delete == 'delete') {
                        //echo $pdo->log->primary($nzb->NZBPath($relrec['guid']) . " does not have an nzb, deleting.");
                        $releases->deleteSingle(['g' => $relrec['guid'], 'i' => $relrec['id']], $nzb, $releaseImage);
                    }
                }
            }
        }
        if ($relcount > 0) {
            echo "\n";
        }
        echo $pdo->log->header("Updated " . $relcount . " release(s). This script ran for " . $consoletools->convertTime(TIME() - $timestart));
    } else {
        echo $pdo->log->info('Query time: ' . $consoletools->convertTime(TIME() - $timestart));
        exit($pdo->log->info("No releases are missing the guid."));
    }
}
コード例 #21
0
ファイル: resetdb.php プロジェクト: engine9-/newznab-tmux
    exit($pdo->log->error("\nThis script removes all releases and release related files. To run:\nphp resetdb.php true\n"));
}
echo $pdo->log->warning("This script removes all releases, nzb files, samples, previews , nfos, truncates all article tables and resets all groups.");
echo $pdo->log->header("Are you sure you want reset the DB?  Type 'DESTROY' to continue:  \n");
echo $pdo->log->warningOver("\n");
$line = fgets(STDIN);
if (trim($line) != 'DESTROY') {
    exit($pdo->log->error("This script is dangerous you must type DESTROY for it function."));
}
echo "\n";
echo $pdo->log->header("Thank you, continuing...\n\n");
$timestart = time();
$relcount = 0;
$ri = new \ReleaseImage($pdo);
$nzb = new \NZB($pdo);
$consoletools = new \ConsoleTools(['ColorCLI' => $pdo->log]);
$pdo->queryExec("UPDATE groups SET first_record = 0, first_record_postdate = NULL, last_record = 0, last_record_postdate = NULL, last_updated = NULL");
echo $pdo->log->primary("Reseting all groups completed.");
$arr = ["tvrage", "releasenfo", "releasecomment", 'sharing', 'sharing_sites', "usercart", "usermovies", "userseries", "movieinfo", "musicinfo", "releasefiles", "releaseaudio", "releasesubs", "releasevideo", "releaseextrafull", "parts", "partrepair", "binaries", "collections", "releases", "spotnabsources"];
foreach ($arr as &$value) {
    $rel = $pdo->queryExec("TRUNCATE TABLE {$value}");
    if ($rel !== false) {
        echo $pdo->log->primary("Truncating {$value} completed.");
    }
}
unset($value);
$sql = "SHOW table status";
$tables = $pdo->query($sql);
foreach ($tables as $row) {
    $tbl = $row['name'];
    if (preg_match('/binaries_\\d+/', $tbl) || preg_match('/parts_\\d+/', $tbl) || preg_match('/collections_\\d+/', $tbl) || preg_match('/partrepair_\\d+/', $tbl) || preg_match('/\\d+_binaries/', $tbl) || preg_match('/\\d+_collections/', $tbl) || preg_match('/\\d+_parts/', $tbl) || preg_match('/\\d+_partrepair_\\d+/', $tbl)) {