Exemple #1
0
function categorizeRelease($where, $update = true, $echooutput = false)
{
    global $pdo;
    $cat = new Categorize(['Settings' => $pdo]);
    $pdo->log = new ColorCLI();
    $consoletools = new ConsoleTools(['ColorCLI' => $pdo->log]);
    $relcount = $chgcount = 0;
    echo $pdo->log->primary("SELECT id, searchname, group_id, categoryid FROM releases " . $where);
    $resrel = $pdo->queryDirect("SELECT id, searchname, group_id, categoryid FROM releases " . $where);
    $total = $resrel->rowCount();
    if ($total > 0) {
        foreach ($resrel as $rowrel) {
            $catId = $cat->determineCategory($rowrel['group_id'], $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\tvideos_id = 0,\n\t\t\t\t\t\t\t\ttv_episodes_id = 0,\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\tbookinfoid = NULL,\n\t\t\t\t\t\t\t\tanidbid = NULL,\n\t\t\t\t\t\t\t\txxxinfo_id = 0,\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;
}
Exemple #2
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, group_id, categoryid, dehashstatus FROM releases WHERE preid = 0 AND ishashed = 1');
    } else {
        if (isset($argv[1]) && $argv[1] === "full") {
            $res = $pdo->queryDirect('SELECT id AS releaseid, name, searchname, group_id, categoryid, dehashstatus FROM releases WHERE categoryid = 7020 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, group_id, categoryid, dehashstatus FROM releases WHERE categoryid = 7020 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.");
    }
}
Exemple #3
0
 /**
  * Look up request ID's for releases.
  *
  * @param array $options
  *
  * @return int Quantity of releases matched to a request ID.
  */
 public function lookupRequestIDs(array $options = [])
 {
     $curOptions = ['charGUID' => '', 'GroupID' => '', 'limit' => '', 'show' => 1, 'time' => 0];
     $curOptions = array_replace($curOptions, $options);
     $startTime = time();
     $renamed = 0;
     $this->_charGUID = $curOptions['charGUID'];
     $this->_groupID = $curOptions['GroupID'];
     $this->_show = $curOptions['show'];
     $this->_maxTime = $curOptions['time'];
     $this->_limit = $curOptions['limit'];
     $this->_getReleases();
     if ($this->_releases !== false && $this->_releases->rowCount() > 0) {
         $this->_totalReleases = $this->_releases->rowCount();
         $this->pdo->log->doEcho($this->pdo->log->primary('Processing ' . $this->_totalReleases . " releases for RequestID's."));
         $renamed = $this->_processReleases();
         if ($this->echoOutput) {
             echo $this->pdo->log->header("\nRenamed " . number_format($renamed) . " releases in " . $this->consoleTools->convertTime(time() - $startTime) . ".");
         }
     } elseif ($this->echoOutput) {
         $this->pdo->log->doEcho($this->pdo->log->primary("No RequestID's to process."));
     }
     return $renamed;
 }
Exemple #4
0
    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_titles", "release_nfos", "release_comments", 'sharing', 'sharing_sites', "users_releases", "user_movies", "user_series", "movieinfo", "musicinfo", "release_files", "audio_data", "release_subtitles", "video_data", "releaseextrafull", "parts", "missed_parts", "binaries", "collections", "releases"];
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('/collections_\\d+/', $tbl) || preg_match('/binaries_\\d+/', $tbl) || preg_match('/parts_\\d+/', $tbl) || preg_match('/missed_parts_\\d+/', $tbl) || preg_match('/\\d+_collections/', $tbl) || preg_match('/\\d+_binaries/', $tbl) || preg_match('/\\d+_parts/', $tbl) || preg_match('/\\d+_missed_parts_\\d+/', $tbl)) {
<?php

require_once dirname(__FILE__) . '/../../../www/config.php';
use nzedb\ConsoleTools;
use nzedb\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 video_data");
            $pdo->queryExec("TRUNCATE TABLE musicinfo");
            $pdo->queryExec("TRUNCATE TABLE bookinfo");
            $pdo->queryExec("TRUNCATE TABLE release_nfos");
            $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']));
Exemple #6
0
    public function getPreFileNames($args = [])
    {
        $timestart = time();
        $counter = $counted = 0;
        $limit = $orderby = '';
        $show = isset($args[2]) && $args[2] === 'show' ? 1 : 0;
        if (isset($args[1]) && is_numeric($args[1])) {
            $orderby = "ORDER BY r.id DESC";
            $limit = "LIMIT " . $args[1];
        }
        echo $this->pdo->log->header("\nMatch PreFiles ({$args[1]}) Started at " . date('g:i:s'));
        echo $this->pdo->log->primary("Matching predb filename to cleaned release_files.name.\n");
        $query = $this->pdo->queryDirect(sprintf('
							SELECT r.id AS releaseid, r.name, r.searchname,
								r.group_id, r.categoryid,
								rf.name AS filename
							FROM releases r
							INNER JOIN release_files rf ON r.id = rf.releaseid
							AND rf.name IS NOT NULL
							WHERE r.preid = 0
							GROUP BY r.id
							%s %s', $orderby, $limit));
        if ($query !== false) {
            $total = $query->rowCount();
            if ($total > 0 && $query instanceof \Traversable) {
                echo $this->pdo->log->header("\n" . number_format($total) . ' releases to process.');
                foreach ($query as $row) {
                    $success = $this->matchPredbFiles($row, 1, 1, true, $show);
                    if ($success === 1) {
                        $counted++;
                    }
                    if ($show === 0) {
                        $this->consoletools->overWritePrimary("Renamed Releases: [" . number_format($counted) . "] " . $this->consoletools->percentString(++$counter, $total));
                    }
                }
                echo $this->pdo->log->header("\nRenamed " . number_format($counted) . " releases in " . $this->consoletools->convertTime(TIME() - $timestart) . ".");
            } else {
                echo $this->pdo->log->info("\nNothing to do.");
            }
        }
    }
Exemple #7
0
    /**
     * 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 SQL_NO_CACHE 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 SQL_NO_CACHE 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 SQL_NO_CACHE 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 SQL_NO_CACHE 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 SQL_NO_CACHE 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 SQL_NO_CACHE 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 SQL_NO_CACHE 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 SQL_NO_CACHE r.id, r.guid
							FROM releases r
							WHERE r.categoryid = %d
							AND r.size < %d LIMIT 1000', $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 SQL_NO_CACHE 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 SQL_NO_CACHE id, guid
					FROM releases
					WHERE categoryid = %d
					AND adddate <= NOW() - INTERVAL %d HOUR', Category::CAT_OTHER_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 SQL_NO_CACHE 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)));
            }
        }
    }
Exemple #8
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, 7010)');
                                    $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"));
}
Exemple #9
0
<?php

require_once realpath(dirname(dirname(dirname(dirname(dirname(__DIR__))))) . DIRECTORY_SEPARATOR . 'indexer.php');
use nzedb\ConsoleTools;
// 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]);
}
Exemple #10
0
require_once dirname(__FILE__) . '/../../../www/config.php';
use nzedb\ConsoleTools;
use nzedb\NZB;
use nzedb\ReleaseImage;
use nzedb\Releases;
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) {
Exemple #11
0
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 = 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."));
    }
}
Exemple #12
0
<?php

require_once realpath(dirname(dirname(dirname(__DIR__))) . DIRECTORY_SEPARATOR . 'indexer.php');
use nzedb\ConsoleTools;
use nzedb\NZB;
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 = [];
$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) {
Exemple #13
0
 /**
  * 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]);
     $othercats = Category::getCategoryOthersGroup();
     $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 = sprintf('AND r.categoryid IN (%s)', $othercats);
     }
     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 release_files 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 release_files 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;
 }
Exemple #14
0
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 . ", group_id FROM releases " . $where);
    $resrel = $pdo->queryDirect("SELECT id, " . $type . ", group_id FROM releases " . $where);
    $total = $resrel->rowCount();
    if ($total > 0) {
        foreach ($resrel as $rowrel) {
            $catId = $cat->determineCategory($rowrel['group_id'], $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;
}
Exemple #15
0
<?php

require_once dirname(__FILE__) . '/../../../../www/config.php';
use nzedb\Binaries;
use nzedb\Categorize;
use nzedb\ConsoleTools;
use nzedb\NZB;
use nzedb\ReleaseCleaning;
use nzedb\Releases;
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 {
Exemple #16
0
<?php

require_once dirname(__FILE__) . '/../../../www/config.php';
use nzedb\ConsoleTools;
use nzedb\NZB;
use nzedb\ReleaseImage;
use nzedb\Releases;
use nzedb\db\Settings;
use nzedb\utility\Utility;
$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 = 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") {
Exemple #17
0
<?php

require_once realpath(dirname(dirname(dirname(__DIR__))) . DIRECTORY_SEPARATOR . 'indexer.php');
use nzedb\ConsoleTools;
use nzedb\Groups;
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}");
Exemple #18
0
<?php

require_once realpath(dirname(dirname(dirname(dirname(dirname(__DIR__))))) . DIRECTORY_SEPARATOR . 'indexer.php');
use nzedb\ConsoleTools;
use nzedb\NNTP;
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 short_groups table.");
$pdo->queryExec('TRUNCATE TABLE short_groups');
// 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 short_groups (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)
Exemple #19
0
         $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->updateRelease($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);
         }
Exemple #20
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;
     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 'wmv_all':
             $this->removeWMV();
             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;
 }
Exemple #21
0
        $titles = $pdo->queryDirect("SELECT id AS preid, title, source, searched FROM predb\n\t\t\t\t\tWHERE LENGTH(title) >= 15 AND searched = 0\n\t\t\t\t\tAND title NOT REGEXP '[\"\\<\\> ]' ORDER BY predate ASC");
        //Selects PreDB Titles where predate is greater than the past user selected number of hours
    } else {
        if (isset($argv[1]) && is_numeric($argv[1])) {
            $titles = $pdo->queryDirect(sprintf("SELECT id AS preid, title, source, searched FROM predb\n\t\t\t\t\t\t WHERE LENGTH(title) >= 15 AND searched = 0\n\t\t\t\t\t\t AND title NOT REGEXP '[\"\\<\\> ]' ORDER BY predate ASC LIMIT %d %s", $argv[1], $offset));
        }
    }
}
if (isset($argv[2]) && $argv[2] === "show") {
    $show = 1;
} else {
    $show = 0;
}
$total = $titles === false ? 0 : $titles->rowCount();
if ($total > 1) {
    $consoletools = new ConsoleTools(['ColorCLI' => $pdo->log]);
    echo $pdo->log->header("\nMatching " . number_format($total) . " PreDB titles against release name or searchname.\n" . "'.' = No Match Found, '*' = Bad Match Parameters (Flood)\n\n");
    sleep(2);
    if ($titles instanceof \Traversable) {
        foreach ($titles as $row) {
            $matched = 0;
            $searched = 0;
            $matched = $namefixer->matchPredbFT($row, 1, 1, true, $show);
            //echo "Pre Title " . $row['title'] . " is translated to search string: ";
            //echo $pdo->log->header($matched);
            if ($matched > 0) {
                $searched = 1;
                $counted++;
            } elseif ($matched < 0) {
                $searched = -6;
                echo "*";
Exemple #22
0
require_once dirname(__FILE__) . '/../../../www/config.php';
use nzedb\ConsoleTools;
use nzedb\Groups;
use nzedb\db\Settings;
/* This script will allow you to move from single collections/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 collections/binaries/parts tables in-tact.
  php convert_to_tgp.php true delete        Convert c/b/p to tpg and TRUNCATE current collections/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 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) {