mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-09-02 19:28:55 +00:00
Move files around.
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
Update Scripts
|
||||
==============
|
||||
|
||||
This directory (``misc/update_scripts``) contains a collection of
|
||||
command-line utilities for updating Newznab. Whilst you can run them stand-alone
|
||||
for testing things out, it is intended that you should run the calling script
|
||||
win_scripts\runme.bat or nix_scripts\newznab_screen.sh which runs each of these
|
||||
scripts in the right order.
|
||||
|
||||
|
||||
Updating
|
||||
--------
|
||||
|
||||
These scripts should be run on a frequent basis in order to stay
|
||||
current with the newest posts to usenet.
|
||||
|
||||
``update_binaries.php``
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
This script downloads new headers from the news server and puts them
|
||||
in the database (binaries and parts tables).
|
||||
|
||||
``update_binaries_threaded.php``
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
This script runs on linux only and calls the update_binaries script in 10
|
||||
separate threads.
|
||||
|
||||
``update_releases.php``
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
This script creates releases from downloaded headers. It includes all the
|
||||
additional post processing which is performed as a release is formed.
|
||||
|
||||
``update_theaters.php``
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
This script updates the 'whats on in theaters' data from rotten tomatoes if
|
||||
a rotten tomatoes api key is present.
|
||||
|
||||
``update_tvschedule.php``
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
This script updates the tv schedule data from thetvdb.
|
||||
|
||||
``import.php``
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
This script is used for importing .nzb files from a path into newznab.
|
||||
|
||||
Maintenance
|
||||
-----------
|
||||
|
||||
These scripts should be run occasionally.
|
||||
|
||||
``optimise_db.php``
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Optimises and repairs mysql tables if necessary. Pass in the true argument to
|
||||
force an optimise and repair regardless of whether its necessary.
|
||||
|
||||
Backfilling
|
||||
-----------
|
||||
|
||||
``backfill.php``
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
The equivalent of ``update_binaries.php`` but for going forwards from the group.backfilldays to
|
||||
the latest post. Downloads headers from usenet and puts them in the database (binaries and parts tables).
|
||||
|
||||
``backfill_date.php``
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The same as ``backfill.php`` but goes back to a specific date passed as an argument.
|
||||
|
||||
``backfill_threaded.php``
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Calls ``backfill.php`` with a thread for each group requiring backfilling.
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
require_once("config.php");
|
||||
|
||||
use newznab\db\DB;
|
||||
|
||||
$pdo = new DB();
|
||||
|
||||
// Create the connection here and pass
|
||||
$nntp = new \NNTP(['Settings' => $pdo]);
|
||||
if ($nntp->doConnect() !== true) {
|
||||
exit($pdo->log->error("Unable to connect to usenet."));
|
||||
}
|
||||
|
||||
if (isset($argv[1]) && $argv[1] == 'all' && $argv[1] !== 'safe' && $argv[1] !== 'alph' && $argv[1] !== 'date' && !is_numeric($argv[1]) && !isset($argv[2])) {
|
||||
$backfill = new \Backfill(['NNTP' => $nntp, 'Settings' => $pdo]);
|
||||
$backfill->backfillAllGroups();
|
||||
} else if (isset($argv[1]) && $argv[1] !== 'all' && $argv[1] !== 'safe' && $argv[1] !== 'alph' && $argv[1] !== 'date' && !is_numeric($argv[1]) && !isset($argv[2])) {
|
||||
$backfill = new \Backfill(['NNTP' => $nntp, 'Settings' => $pdo]);
|
||||
$backfill->backfillAllGroups($argv[1]);
|
||||
} else if (isset($argv[1]) && $argv[1] !== 'all' && $argv[1] !== 'safe' && $argv[1] !== 'alph' && $argv[1] !== 'date' && !is_numeric($argv[1]) && isset($argv[2]) && is_numeric($argv[2])) {
|
||||
$backfill = new \Backfill(['NNTP' => $nntp, 'Settings' => $pdo]);
|
||||
$backfill->backfillAllGroups($argv[1], $argv[2]);
|
||||
} else if (isset($argv[1]) && $argv[1] !== 'all' && $argv[1] !== 'safe' && $argv[1] == 'alph' && $argv[1] !== 'date' && !is_numeric($argv[1]) && isset($argv[2]) && is_numeric($argv[2])) {
|
||||
$backfill = new \Backfill(['NNTP' => $nntp, 'Settings' => $pdo]);
|
||||
$backfill->backfillAllGroups('', $argv[2], 'normal');
|
||||
} else if (isset($argv[1]) && $argv[1] !== 'all' && $argv[1] !== 'safe' && $argv[1] !== 'alph' && $argv[1] == 'date' && !is_numeric($argv[1]) && isset($argv[2]) && is_numeric($argv[2])) {
|
||||
$backfill = new \Backfill(['NNTP' => $nntp, 'Settings' => $pdo]);
|
||||
$backfill->backfillAllGroups('', $argv[2], 'date');
|
||||
} else if (isset($argv[1]) && $argv[1] !== 'all' && $argv[1] == 'safe' && $argv[1] !== 'alph' && $argv[1] !== 'date' && !is_numeric($argv[1]) && isset($argv[2]) && is_numeric($argv[2])) {
|
||||
$backfill = new \Backfill(['NNTP' => $nntp, 'Settings' => $pdo]);
|
||||
$backfill->safeBackfill($argv[2]);
|
||||
} else {
|
||||
exit($pdo->log->error("\nWrong set of arguments.\n"
|
||||
. 'php backfill.php safe 200000 ...: Backfill an active group alphabetically, x articles, the script stops,' . "\n"
|
||||
. ' ...: if the group has reached reached 2012-06-24, the next group will backfill.' . "\n"
|
||||
. 'php backfill.php alph 200000 ...: Backfills all groups (sorted alphabetically) by number of articles' . "\n"
|
||||
. 'php backfill.php date 200000 ...: Backfills all groups (sorted by least backfilled in time) by number of articles' . "\n"
|
||||
. 'php backfill.php alt.binaries.ath 200000 ...: Backfills a group by name by number of articles' . "\n"
|
||||
. 'php backfill.php all ...: Backfills all groups 1 at a time, by date (set in admin-view groups)' . "\n"
|
||||
. 'php backfill.php alt.binaries.ath ...: Backfills a group by name, by date (set in admin-view groups)' . "\n"));
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/*
|
||||
DESCRIPTION:
|
||||
This script is an alternative to backfill.php.
|
||||
It allows you to backfill based on a specific date, bypassing
|
||||
the "backfill target" setting for each group, used by backfill.php
|
||||
|
||||
PURPOSE:
|
||||
If you are backfilling many groups over a long span of time, the # of days
|
||||
set as your backfill target can become quickly outdated, resulting in
|
||||
potential gaps in your database. In this case, it may be more practical
|
||||
to specify a date explicity and just let the backfill work from there.
|
||||
|
||||
USAGE:
|
||||
$ php backfill_date.php 2011-05-15
|
||||
=> Script will backfill ALL active groups from May 15, 2011
|
||||
|
||||
$ php backfill_date.php 2011-05-15 alt.binaries.games.xbox
|
||||
=> Script will backfill ONLY a.b.games.xbox from May 15, 2011
|
||||
*/
|
||||
|
||||
require_once("config.php");
|
||||
|
||||
$time = 0;
|
||||
|
||||
if (isset($argv[1]))
|
||||
$time = strtotime($argv[1]);
|
||||
|
||||
if (($time > 1) && ($time < time())) {
|
||||
$groupName = (isset($argv[2]) ? $argv[2] : '');
|
||||
|
||||
if (isset($argv[3]) && $argv[3] == true)
|
||||
$regexOnly = true;
|
||||
else
|
||||
$regexOnly = false;
|
||||
|
||||
$backfill = new Backfill();
|
||||
$backfill->backfillAllGroups($groupName, strtotime($argv[1]), $regexOnly);
|
||||
} else {
|
||||
echo "You must provide a backfill date in the format YYYY-MM-DD to use backfill_date.php\n";
|
||||
echo "example: backfill_date.php 2002-04-27 alt.binaries.games.xbox true\n";
|
||||
echo "This will backfill your index with everything posted to a.b.g.x since April 27, 2002 that matches system regex\n";
|
||||
echo "If you choose not to provide a groupname, all active groups will be backfilled.\n";
|
||||
echo "\nIf you do not want to use a date, use the backfill.php script instead.\n";
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
require_once("config.php");
|
||||
|
||||
$groups = new \Groups;
|
||||
$groupList = $groups->getActive();
|
||||
unset($groups);
|
||||
|
||||
$ps = new \PowerProcess;
|
||||
$ps->RegisterCallback('psUpdateComplete');
|
||||
$ps->maxThreads = 10;
|
||||
$ps->tickCount = 10000; // value in usecs. change this to 1000000 (one second) to reduce cpu use
|
||||
$ps->threadTimeLimit = 0; // Disable child timeout
|
||||
|
||||
echo "Starting threaded backfill process\n";
|
||||
|
||||
while ($ps->RunControlCode())
|
||||
{
|
||||
// Start the parent loop
|
||||
if (count($groupList))
|
||||
{
|
||||
// We still have groups to process
|
||||
if ($ps->SpawnReady())
|
||||
{
|
||||
// Spawn another thread
|
||||
$ps->threadData = array_pop($groupList);
|
||||
echo "[Thread-MASTER] Spawning new thread. Still have " . count($groupList) ." group(s) to update after this\n";
|
||||
$ps->spawnThread();
|
||||
}
|
||||
else
|
||||
{
|
||||
// There are no more slots available to run
|
||||
//$ps->tick();
|
||||
//echo ".\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// No more groups to process
|
||||
echo "No more groups to process - Initiating shutdown\n";
|
||||
$ps->Shutdown();
|
||||
echo "Shutdown complete\n";
|
||||
}
|
||||
}
|
||||
|
||||
unset($groupList);
|
||||
|
||||
if ($ps->RunThreadCode())
|
||||
{
|
||||
$group = $ps->threadData;
|
||||
|
||||
$thread = sprintf("%05d",$ps->GetPID());
|
||||
|
||||
echo "[Thread-{$thread}] Begining backfill processing for group {$group['name']}\n";
|
||||
|
||||
$param = $group['name'];
|
||||
|
||||
$dir = dirname(__FILE__);
|
||||
$file = 'backfill.php';
|
||||
|
||||
$output = shell_exec("php {$dir}/{$file} {$param}");
|
||||
//$output = shell_exec("/usr/bin/php -c /etc/php5/cli/php.ini {$dir}/{$file} {$param}");
|
||||
|
||||
echo "[Thread-{$thread}] Completed update for group {$group['name']}\n";
|
||||
}
|
||||
|
||||
// Exit to call back to parent - Let know that child has completed
|
||||
exit(0);
|
||||
|
||||
// Create callback function
|
||||
function psUpdateComplete()
|
||||
{
|
||||
echo "[Thread-MASTER] Threaded backfill process complete\n";
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
|
||||
require_once(dirname(__FILE__) . "/../../www/config.php");
|
||||
@@ -0,0 +1,192 @@
|
||||
<?php
|
||||
|
||||
require_once dirname(__FILE__) . '/../../www/config.php';
|
||||
|
||||
use newznab\db\DB;
|
||||
use newznab\utility\Utility;
|
||||
|
||||
$releases = new Releases();
|
||||
$db = new DB();
|
||||
$cat = new Categorize();
|
||||
$releaseRegex = new ReleaseRegex();
|
||||
$nzb = new NZB();
|
||||
$page = new Page();
|
||||
$num = 0;
|
||||
$usefilename = true;
|
||||
$dupecheck = true;
|
||||
$movefiles = true;
|
||||
$categoryoverride = -1;
|
||||
|
||||
if (empty($argc) || $argc <= 1) {
|
||||
$path = "./";
|
||||
} else {
|
||||
$util = new Utility();
|
||||
$path = (!$util->endsWith($argv[1], "/") ? $argv[1] . "/" : $argv[1]);
|
||||
if (isset($argv[2]))
|
||||
$usefilename = strtolower($argv[2]) == 'true';
|
||||
if (isset($argv[3]))
|
||||
$dupecheck = strtolower($argv[3]) == 'true';
|
||||
if (isset($argv[4]))
|
||||
$movefiles = strtolower($argv[4]) == 'true';
|
||||
if (isset($argv[5]) && is_numeric($argv[5]))
|
||||
$categoryoverride = $argv[5];
|
||||
}
|
||||
|
||||
$groups = $db->query("SELECT id, name FROM groups");
|
||||
foreach ($groups as $group)
|
||||
$siteGroups[$group["name"]] = $group["id"];
|
||||
|
||||
echo "\nUsage: php import.php [path(string)] [usefilename(true/false)] [dupecheck(true/false)] [movefiles(true/false)] [overridecategory(number)]\n";
|
||||
|
||||
$filestoprocess = glob($path . "*.{nzb,nzb.gz}", GLOB_BRACE);
|
||||
$items = count($filestoprocess);
|
||||
$matches = [];
|
||||
$digits = preg_match_all("/[0-9]/", count($filestoprocess), $matches);
|
||||
$dupepath = $path . "dupe/";
|
||||
$nogrouppath = $path . "nogroup/";
|
||||
$importedpath = $path . "imported/";
|
||||
$noregexpath = $path . "noregex/";
|
||||
$errorpath = $path . "error/";
|
||||
$missinggroups = [];
|
||||
echo "[Importing " . $items . " *.nzb file" . ($items != 1 ? "s" : "") . " from " . $path . ($usefilename ? " U" : " Not u") . "sing filename, " . ($dupecheck ? "C" : "Not c") . "hecking for duplicates" . ($categoryoverride != -1 ? ", Forcing category to " . $categoryoverride : "") . "]\n\n";
|
||||
|
||||
foreach ($filestoprocess as $nzbFile) {
|
||||
$groupID = -1;
|
||||
$groupName = "";
|
||||
$num++;
|
||||
$nzbInfo = new nzbInfo;
|
||||
|
||||
if (!$nzbInfo->loadFromFile($nzbFile, true)) {
|
||||
echo "Failed to load nzb from disk " . $nzbFile . "\n";
|
||||
if ($movefiles) {
|
||||
if (!file_exists($errorpath)) mkdir($errorpath);
|
||||
if (!file_exists($errorpath . basename($nzbFile))) rename($nzbFile, $errorpath . basename($nzbFile));
|
||||
}
|
||||
} else {
|
||||
if ($dupecheck) {
|
||||
$dupes = $db->queryOneRow(sprintf("SELECT EXISTS(SELECT 1 FROM releases WHERE gid = %s) as total", $db->escapeString($nzbInfo->gid)));
|
||||
if ($dupes['total'] > 0) {
|
||||
echo sprintf("%0" . $digits . "d %.2f%% Error : Dupe %s - GID(%s)\n", $items - $num, $num / $items * 100, $nzbFile, $nzbInfo->gid);
|
||||
if ($movefiles) {
|
||||
if (!file_exists($dupepath)) mkdir($dupepath);
|
||||
if (!file_exists($dupepath . basename($nzbFile))) rename($nzbFile, $dupepath . basename($nzbFile));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($nzbInfo->groups as $group) {
|
||||
$group = (string)$group;
|
||||
if (array_key_exists($group, $siteGroups)) {
|
||||
$groupID = $siteGroups[$group];
|
||||
$groupName = $group;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($groupID == -1) {
|
||||
echo sprintf("%0" . $digits . "d %.2f%% Error : Missing group %s - Group(%s)\n", $items - $num, $num / $items * 100, $nzbFile, str_replace("alt.binaries.", "a.b.", implode(",", $nzbInfo->groups)));
|
||||
if ($movefiles) {
|
||||
if (!file_exists($nogrouppath)) mkdir($nogrouppath);
|
||||
if (!file_exists($nogrouppath . basename($nzbFile))) rename($nzbFile, $nogrouppath . basename($nzbFile));
|
||||
$missinggroups = array_merge($missinggroups, $nzbInfo->groups);
|
||||
}
|
||||
continue;
|
||||
} else {
|
||||
if ($usefilename) {
|
||||
$relguid = md5(uniqid());
|
||||
$name = $releases->cleanReleaseName(str_replace(".nzb", "", basename($nzbFile)));
|
||||
$catId = $cat->determineCategory($groupName, $name);
|
||||
$relid = $releases->insertRelease($name, $nzbInfo->filecount, $groupID, $relguid, $catId, "", date("Y-m-d H:i:s", $nzbInfo->postedlast), $nzbInfo->poster, "", $page->site);
|
||||
$db->queryExec(sprintf("update releases set totalpart = %d, size = %s, completion = %d, GID=%s where id = %d", $nzbInfo->filecount, $nzbInfo->filesize, $nzbInfo->completion, $db->escapeString($nzbInfo->gid), $relid));
|
||||
|
||||
$nzbfilename = $nzb->getNZBPath($relguid, $page->site->nzbpath, true);
|
||||
$fp = gzopen($nzbfilename, "w");
|
||||
if ($fp) {
|
||||
gzwrite($fp, $nzbInfo->toNzb());
|
||||
gzclose($fp);
|
||||
echo sprintf("%0" . $digits . "d %.2f%% Imported %s\n", $items - $num, $num / $items * 100, $name);
|
||||
if ($movefiles) {
|
||||
if (!file_exists($importedpath)) mkdir($importedpath);
|
||||
if (!file_exists($importedpath . basename($nzbFile))) rename($nzbFile, $importedpath . basename($nzbFile));
|
||||
}
|
||||
} else {
|
||||
echo sprintf("%0" . $digits . "d %.2f%% Error : Failed to write file to disk %s\n", $items - $num, $num / $items * 100, $nzbfilename);
|
||||
if ($movefiles) {
|
||||
if (!file_exists($errorpath)) mkdir($errorpath);
|
||||
if (!file_exists($errorpath . basename($nzbFile))) rename($nzbFile, $errorpath . basename($nzbFile));
|
||||
}
|
||||
$releases->delete($relid);
|
||||
}
|
||||
} else {
|
||||
$numbins = 0;
|
||||
$numparts = 0;
|
||||
$binaryId = 0;
|
||||
$groupRegexes = $releaseRegex->getForGroup($groupName);
|
||||
foreach ($nzbInfo->nzb as $postFile) {
|
||||
$regexMatches = [];
|
||||
|
||||
foreach ($groupRegexes as $groupRegex) {
|
||||
$regexCheck = $releaseRegex->performMatch($groupRegex, $postFile["subject"]);
|
||||
if ($regexCheck !== false) {
|
||||
$regexMatches = $regexCheck;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($regexMatches)) {
|
||||
$relparts = explode("/", $regexMatches['parts']);
|
||||
$regexMatches['regcatid'] = ($categoryoverride != -1 ? $categoryoverride : $regexMatches['regcatid']);
|
||||
|
||||
$sql = sprintf("INSERT INTO binaries (name, fromname, date, xref, totalParts, groupid, binaryhash, dateadded,
|
||||
categoryid, regexid, reqid, procstat, relpart, reltotalpart, relname)
|
||||
values (%s, %s, %s, %s, %d, %d, %s, NOW(), %s, %d, %s, %d, %d, %d, %s )",
|
||||
$db->escapeString($postFile["subject"]), $db->escapeString($postFile["poster"]),
|
||||
$db->escapeString(date("Y-m-d H:i:s", $postFile["posted"])),
|
||||
$db->escapeString(implode(': ', $nzbInfo->groups) . ':'),
|
||||
$postFile["segmenttotal"], $groupID,
|
||||
$db->escapeString(md5($postFile["subject"] . $postFile["poster"] . $groupID)),
|
||||
$regexMatches['regcatid'],
|
||||
$regexMatches['regexid'], $db->escapeString($regexMatches['reqid']),
|
||||
\Releases::PROCSTAT_TITLEMATCHED, $relparts[0], $relparts[1], $db->escapeString(str_replace('_', ' ', $regexMatches['name']))
|
||||
);
|
||||
$binaryId = $db->queryInsert($sql);
|
||||
$numbins++;
|
||||
|
||||
if (count($postFile['segments']) > 0) {
|
||||
$sql = "INSERT INTO parts (binaryID, messageID, number, partnumber, size) values ";
|
||||
foreach ($postFile['segments'] as $fileSegmentNum => $fileSegment) {
|
||||
$sql .= sprintf("(%d, %s, 0, %d, %d),", $binaryId, $db->escapeString($fileSegment), $fileSegmentNum, $postFile['segmentbytes'][$fileSegmentNum]);
|
||||
$numparts++;
|
||||
}
|
||||
$db->queryInsert(substr($sql, 0, -1));
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($binaryId != 0) {
|
||||
echo sprintf("%0" . $digits . "d %.2f%% Imported %s (%d:%s-%d/%d)\n", $items - $num, $num / $items * 100, basename($nzbFile), $regexMatches['regcatid'], $regexMatches['regexid'], $numbins, $numparts);
|
||||
if ($movefiles) {
|
||||
if (!file_exists($importedpath)) mkdir($importedpath);
|
||||
if (!file_exists($importedpath . basename($nzbFile))) rename($nzbFile, $importedpath . basename($nzbFile));
|
||||
}
|
||||
} else {
|
||||
echo sprintf("%0" . $digits . "d %.2f%% Error : No Regex Match %s\n", $items - $num, $num / $items * 100, basename($nzbFile));
|
||||
if ($movefiles) {
|
||||
if (!file_exists($noregexpath)) mkdir($noregexpath);
|
||||
if (!file_exists($noregexpath . basename($nzbFile))) rename($nzbFile, $noregexpath . basename($nzbFile));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count($missinggroups) > 0) {
|
||||
$missinggroups = array_unique($missinggroups);
|
||||
$grpsql = "INSERT INTO groups (name, backfill_target, first_record, first_record_postdate, last_record, last_record_postdate, last_updated, minfilestoformrelease, minsizetoformrelease, active, regexmatchonly, description) VALUES ('%s', 0, 0, null, 0, null, null, null, null, 0, 1, 'Added by import');\n";
|
||||
$grpout = "";
|
||||
foreach ($missinggroups as $mg)
|
||||
$grpout .= sprintf($grpsql, $mg);
|
||||
|
||||
@file_put_contents(sprintf("missing_groups_%s.sql", uniqid()), $grpout);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
Inlcuded in this folder are init.d scripts for unix users. These are NOT to be cronned.
|
||||
They must be ran by init.d or in a screen.
|
||||
|
||||
You MUST set the paths to where you have installed newznab.
|
||||
|
||||
The recommended way to run script is via screen. You should copy newznab_screen.sh
|
||||
to newznab_local.sh so that when you svn update (or export), your changes are not lost.
|
||||
|
||||
Detailed instructions...
|
||||
|
||||
cp newznab_screen.sh newznab_local.sh
|
||||
edit newznab_local.sh to specify paths to your installation
|
||||
chmod +x newznab_local.sh
|
||||
screen bash
|
||||
./newznab_local.sh
|
||||
ctrl-ad to detach screen
|
||||
|
||||
|
||||
|
||||
This will update binaries and releases in a continuous cycle.
|
||||
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
require_once dirname(dirname(dirname(dirname(dirname(__DIR__))))) . DIRECTORY_SEPARATOR . 'www' . DIRECTORY_SEPARATOR . 'config.php';
|
||||
|
||||
if (is_file(dirname(__DIR__) . DIRECTORY_SEPARATOR . 'settings.php')) {
|
||||
require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . 'settings.php';
|
||||
}
|
||||
@@ -0,0 +1,338 @@
|
||||
<?php
|
||||
|
||||
if (!isset($argv[1])) {
|
||||
exit("This script is not intended to be run manually." . PHP_EOL);
|
||||
}
|
||||
|
||||
require_once dirname(__FILE__) . '/../../../../../www/config.php';
|
||||
|
||||
use newznab\db\DB;
|
||||
use newznab\processing\PProcess;
|
||||
use newznab\processing\post\ProcessAdditional;
|
||||
|
||||
|
||||
// Are we coming from python or php ? $options[0] => (string): python|php
|
||||
// The type of process we want to do: $options[1] => (string): releases
|
||||
$options = explode(' ', $argv[1]);
|
||||
|
||||
switch ($options[1]) {
|
||||
|
||||
// Runs backFill interval or all.
|
||||
// $options[2] => (string)group name, Name of group to work on.
|
||||
// $options[3] => (int) backfill type from tmux settings. 1 = Backfill interval , 2 = Bakfill all
|
||||
case 'backfill':
|
||||
if (in_array((int)$options[3], [1, 2])) {
|
||||
$pdo = new DB();
|
||||
$value = $pdo->queryOneRow("SELECT value FROM tmux WHERE setting = 'backfill_qty'");
|
||||
if ($value !== false) {
|
||||
$nntp = nntp($pdo);
|
||||
(new \Backfill())->backfillAllGroups($options[2], ($options[3] == 1 ? '' : $value['value']));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
/* BackFill up to x number of articles for all groups.
|
||||
*
|
||||
* $options[2] => (string) Group name.
|
||||
* $options[3] => (int) Quantity of articles to download.
|
||||
*/
|
||||
case 'backfill_all_quantity':
|
||||
$pdo = new DB();
|
||||
$nntp = nntp($pdo);
|
||||
(new \Backfill())->backfillAllGroups($options[2], $options[3]);
|
||||
break;
|
||||
|
||||
// BackFill a single group, 10000 parts.
|
||||
// $options[2] => (string)group name, Name of group to work on.
|
||||
case 'backfill_all_quick':
|
||||
$pdo = new DB();
|
||||
$nntp = nntp($pdo);
|
||||
(new \Backfill())->backfillAllGroups($options[2], 10000, 'normal');
|
||||
break;
|
||||
|
||||
/* Get a range of article headers for a group.
|
||||
*
|
||||
* $options[2] => (string) backfill/binaries
|
||||
* $options[3] => (string) Group name.
|
||||
* $options[4] => (int) First article number in range.
|
||||
* $options[5] => (int) Last article number in range.
|
||||
* $options[6] => (int) Number of threads.
|
||||
*/
|
||||
case 'get_range':
|
||||
$pdo = new DB();
|
||||
$nntp = nntp($pdo);
|
||||
$groups = new \Groups();
|
||||
$s = new Sites();
|
||||
$site = $s->get();
|
||||
$groupMySQL = $groups->getByName($options[3]);
|
||||
if ($nntp->isError($nntp->selectGroup($groupMySQL['name']))) {
|
||||
if ($nntp->isError($nntp->dataError($nntp, $groupMySQL['name']))) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
$binaries = new \Binaries(['NNTP' => $nntp, 'Settings' => $pdo, 'Groups' => $groups]);
|
||||
$return = $binaries->scan($groupMySQL, $options[4], $options[5], ($site->safepartrepair == 1 ? 'update' : 'backfill'));
|
||||
if (empty($return)) {
|
||||
exit();
|
||||
}
|
||||
$columns = [];
|
||||
switch ($options[2]) {
|
||||
case 'binaries':
|
||||
if ($return['lastArticleNumber'] <= $groupMySQL['last_record']){
|
||||
exit();
|
||||
}
|
||||
$columns[1] = sprintf(
|
||||
'last_record_postdate = %s',
|
||||
$pdo->from_unixtime(
|
||||
(is_numeric($return['lastArticleDate']) ? $return['lastArticleDate'] : strtotime($return['lastArticleDate']))
|
||||
)
|
||||
);
|
||||
$columns[2] = sprintf('last_record = %s', $return['lastArticleNumber']);
|
||||
$query = sprintf(
|
||||
'UPDATE groups SET %s, %s, last_updated = NOW() WHERE id = %d AND last_record < %s',
|
||||
$columns[1],
|
||||
$columns[2],
|
||||
$groupMySQL['id'],
|
||||
$return['lastArticleNumber']
|
||||
);
|
||||
break;
|
||||
case 'backfill':
|
||||
if ($return['firstArticleNumber'] >= $groupMySQL['first_record']){
|
||||
exit();
|
||||
}
|
||||
$columns[1] = sprintf(
|
||||
'first_record_postdate = %s',
|
||||
$pdo->from_unixtime(
|
||||
(is_numeric($return['firstArticleDate']) ? $return['firstArticleDate'] : strtotime($return['firstArticleDate']))
|
||||
)
|
||||
);
|
||||
$columns[2] = sprintf('first_record = %s', $return['firstArticleNumber']);
|
||||
$query = sprintf(
|
||||
'UPDATE groups SET %s, %s, last_updated = NOW() WHERE id = %d AND first_record > %s',
|
||||
$columns[1],
|
||||
$columns[2],
|
||||
$groupMySQL['id'],
|
||||
$return['firstArticleNumber']
|
||||
);
|
||||
break;
|
||||
default:
|
||||
exit();
|
||||
}
|
||||
$pdo->queryExec($query);
|
||||
break;
|
||||
|
||||
/* Do part repair for a group.
|
||||
*
|
||||
* $options[2] => (string) Group name.
|
||||
*/
|
||||
case 'part_repair':
|
||||
$pdo = new DB();
|
||||
$groups = new \Groups(['Settings' => $pdo]);
|
||||
$groupMySQL = $groups->getByName($options[2]);
|
||||
$nntp = nntp($pdo);
|
||||
// Select group, here, only once
|
||||
$data = $nntp->selectGroup($groupMySQL['name']);
|
||||
if ($nntp->isError($data)) {
|
||||
if ($nntp->dataError($nntp, $groupMySQL['name']) === false) {
|
||||
exit();
|
||||
}
|
||||
}
|
||||
(new \Binaries())->partRepair($groupMySQL);
|
||||
break;
|
||||
|
||||
// Process releases.
|
||||
// $options[2] => (string)groupCount, number of groups terminated by _ | (int)groupid, group to work on
|
||||
case 'releases':
|
||||
$pdo = new DB();
|
||||
$s = new Sites();
|
||||
$site = $s->get();
|
||||
$releases = new \Releases(['Settings' => $pdo]);
|
||||
|
||||
//Runs function that are per group
|
||||
if (is_numeric($options[2])) {
|
||||
processReleases($site, $releases, $options[2]);
|
||||
|
||||
} else {
|
||||
|
||||
// Run functions that run on releases table after all others completed.
|
||||
$groupCount = rtrim($options[2], '_');
|
||||
if (!is_numeric($groupCount)) {
|
||||
$groupCount = 1;
|
||||
}
|
||||
$releases->deletedReleasesByGroup();
|
||||
$releases->deleteReleases();
|
||||
$releases->processRequestIDs('', (5000 * $groupCount), true);
|
||||
$releases->processRequestIDs('', (1000 * $groupCount), false);
|
||||
$releases->categorizeReleases(2);
|
||||
}
|
||||
break;
|
||||
|
||||
// Process all local requestid for a single group.
|
||||
// $options[2] => (int)groupid, group to work on
|
||||
case 'requestid':
|
||||
if (is_numeric($options[2])) {
|
||||
(new \RequestIDLocal(['Echo' => true]))->lookupRequestIDs(['GroupID' => $options[2], 'limit' => 5000]);
|
||||
}
|
||||
break;
|
||||
|
||||
/* Update a single group's article headers.
|
||||
*
|
||||
* $options[2] => (string) Group name.
|
||||
*/
|
||||
case 'update_group_headers':
|
||||
$pdo = new DB();
|
||||
$nntp = nntp($pdo);
|
||||
$groups = new \Groups();
|
||||
$groupMySQL = $groups->getByName($options[2]);
|
||||
(new \Binaries(['NNTP' => $nntp, 'Groups' => $groups, 'Settings' => $pdo]))->updateGroup($groupMySQL);
|
||||
break;
|
||||
|
||||
|
||||
// Do a single group (update_binaries/backFill/update_releases/postprocess).
|
||||
// $options[2] => (int)groupid, group to work on
|
||||
case 'update_per_group':
|
||||
if (is_numeric($options[2])) {
|
||||
|
||||
$pdo = new DB();
|
||||
|
||||
// Get the group info from MySQL.
|
||||
$groupMySQL = $pdo->queryOneRow(sprintf('SELECT * FROM groups WHERE id = %d', $options[2]));
|
||||
|
||||
if ($groupMySQL === false) {
|
||||
exit('ERROR: Group not found with id ' . $options[2] . PHP_EOL);
|
||||
}
|
||||
|
||||
// Connect to NNTP.
|
||||
$nntp = nntp($pdo);
|
||||
$backFill = new \Backfill();
|
||||
|
||||
// Update the group for new binaries.
|
||||
(new \Binaries())->updateGroup($groupMySQL);
|
||||
|
||||
// BackFill the group with 20k articles.
|
||||
$backFill->backfillAllGroups($groupMySQL['name'], 20000, 'normal');
|
||||
|
||||
// Create releases.
|
||||
processReleases(new \Releases(['Settings' => $pdo]), $options[2]);
|
||||
|
||||
// Post process the releases.
|
||||
(new ProcessAdditional(['Echo' => true, 'NNTP' => $nntp, 'Settings' => $pdo]))->start($options[2]);
|
||||
(new \Info(['Echo' => true, 'Settings' => $pdo]))->processNfoFiles($nntp, $options[2]);
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
// Post process additional and NFO.
|
||||
// $options[2] => (char)Letter or number a-f 0-9, first character of release guid.
|
||||
case 'pp_additional':
|
||||
case 'pp_nfo':
|
||||
if (charCheck($options[2])) {
|
||||
$pdo = new DB();
|
||||
|
||||
// Create the connection here and pass, this is for post processing, so check for alternate.
|
||||
$nntp = nntp($pdo, true);
|
||||
|
||||
if ($options[1] === 'pp_nfo') {
|
||||
(new \Info(['Echo' => true, 'Settings' => $pdo]))->processNfoFiles($nntp, '', $options[2]);
|
||||
} else {
|
||||
(new ProcessAdditional(['Echo' => true, 'NNTP' => $nntp, 'Settings' => $pdo]))->start('', $options[2]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
/* Post process movies.
|
||||
*
|
||||
* $options[2] (char) Single character, first letter of release guid.
|
||||
* $options[3] (int) Process all releases or renamed releases only.
|
||||
*/
|
||||
case 'pp_movie':
|
||||
if (charCheck($options[2])) {
|
||||
$pdo = new DB();
|
||||
(new PProcess(['Settings' => $pdo]))->processMovies('', $options[2], (isset($options[3]) ? $options[3] : ''));
|
||||
}
|
||||
break;
|
||||
|
||||
/* Post process TV.
|
||||
*
|
||||
* $options[2] (char) Single character, first letter of release guid.
|
||||
* $options[3] (int) Process all releases or renamed releases only.
|
||||
*/
|
||||
case 'pp_tv':
|
||||
if (charCheck($options[2])) {
|
||||
$pdo = new DB();
|
||||
(new PProcess(['Settings' => $pdo]))->processTv('', $options[2], (isset($options[3]) ? $options[3] : ''));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create / process releases for a groupid.
|
||||
*
|
||||
* @param \Releases $releases
|
||||
* @param int $groupID
|
||||
*/
|
||||
function processReleases($site, $releases, $groupID)
|
||||
{
|
||||
$s = new Sites();
|
||||
$site = $s->get();
|
||||
$releaseCreationLimit = ($site->maxnzbsprocessed != '' ? (int)$site->maxnzbsprocessed : 1000);
|
||||
$releases->applyRegex($groupID);
|
||||
$releases->processIncompleteBinaries($groupID);
|
||||
$releases->createReleases($groupID);
|
||||
|
||||
|
||||
do {
|
||||
$releasesCount = $releases->createReleases($groupID);
|
||||
|
||||
// This loops as long as the number of releases or nzbs added was >= the limit (meaning there are more waiting to be created)
|
||||
} while (($releasesCount['added'] + $releasesCount['dupes']) >= $releaseCreationLimit);
|
||||
$releases->deleteBinaries($groupID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the character contains a-f or 0-9.
|
||||
*
|
||||
* @param string $char
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function charCheck($char)
|
||||
{
|
||||
if (in_array($char, ['a','b','c','d','e','f','0','1','2','3','4','5','6','7','8','9'])) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the group should be processed.
|
||||
*
|
||||
* @param \newznab\db\DB $pdo
|
||||
* @param int $groupID
|
||||
*/
|
||||
function collectionCheck(&$pdo, $groupID)
|
||||
{
|
||||
if ($pdo->queryOneRow(sprintf('SELECT id FROM collections_%d LIMIT 1', $groupID)) === false) {
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Connect to usenet, return NNTP object.
|
||||
*
|
||||
* @param \DB $pdo
|
||||
* @param bool $alternate Use alternate NNTP provider.
|
||||
*
|
||||
* @return NNTP
|
||||
*/
|
||||
function &nntp(&$pdo, $alternate = false)
|
||||
{
|
||||
$nntp = new \NNTP(['Settings' => $pdo]);
|
||||
$s = new Sites();
|
||||
$site = $s->get();
|
||||
if (($alternate && $site->alternate_nntp == 1 ? $nntp->doConnect(true, true) : $nntp->doConnect()) !== true) {
|
||||
exit("ERROR: Unable to connect to usenet." . PHP_EOL);
|
||||
}
|
||||
|
||||
return $nntp;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
/settings.php
|
||||
@@ -0,0 +1,19 @@
|
||||
####These multi-processing scripts require a POSIX compliant operating system and the PHP pcntl extension.
|
||||
|
||||
|
||||
####binaries.php
|
||||
This will download new headers for all active groups using your binaries threads site setting.
|
||||
You can pass a argument, a number to limit the max amount of new headers to download.
|
||||
|
||||
|
||||
####releases.php
|
||||
This is identical to the python releases_threaded.py
|
||||
This will create new releases/delete unwanted releases, process requestid's, categorize releases by group
|
||||
using your release threads site setting.
|
||||
|
||||
|
||||
####update_per_group.php:
|
||||
This is identical to the python update_threaded.py
|
||||
This will download new headers for all active groups, backfill 20k headers from all backfill enabled groups,
|
||||
create new releases/delete unwanted releases, process requestid's, categorize releases, process additional and NFO
|
||||
by group using your release threads site setting.
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
declare(ticks=1);
|
||||
require('.do_not_run/require.php');
|
||||
use newznab\libraries\Forking;
|
||||
// Check if argument 1 is numeric, which is to limit article count.
|
||||
(new Forking())->processWorkType(
|
||||
'backfill', (isset($argv[1]) && is_numeric($argv[1]) && $argv[1] > 0 ? array(0 => $argv[1]) : array(0 => false))
|
||||
);
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
if (!isset($argv[1]) || !is_numeric($argv[1])) {
|
||||
exit(
|
||||
'Argument 1 => (Number) Set to 0 to ignore, else fetches up to x new headers for every active group.' . PHP_EOL
|
||||
);
|
||||
}
|
||||
declare(ticks=1);
|
||||
require('.do_not_run/require.php');
|
||||
use newznab\libraries\Forking;
|
||||
(new Forking())->processWorkType('binaries', array(0 => $argv[1]));
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
if (!isset($argv[1]) || !in_array($argv[1], ['nfo', 'filename', 'md5', 'par2', 'miscsorter', 'predbft'])) {
|
||||
exit(
|
||||
'First argument (mandatory):' . PHP_EOL .
|
||||
'nfo => Attempt to fix release name using the nfo.' . PHP_EOL .
|
||||
'filename => Attempt to fix release name using the filenames.' . PHP_EOL .
|
||||
'md5 => Attempt to fix release name using the MD5.' . PHP_EOL .
|
||||
'par2 => Attempt to fix release name using the par2.' . PHP_EOL .
|
||||
'miscsorter => Attempt to fix release name using magic.' . PHP_EOL .
|
||||
'predbft => Attempt to fix release name using Predb full text matching.' . PHP_EOL . PHP_EOL
|
||||
);
|
||||
}
|
||||
|
||||
declare(ticks=1);
|
||||
require('.do_not_run/require.php');
|
||||
|
||||
use newznab\libraries\Forking;
|
||||
|
||||
|
||||
(new Forking())->processWorkType('fixRelNames_' . $argv[1], [0 => $argv[1]]);
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
declare(ticks=1);
|
||||
require('.do_not_run/require.php');
|
||||
|
||||
use newznab\libraries\ForkingImportNZB;
|
||||
|
||||
if (!isset($argv[1]) || !is_dir($argv[1])) {
|
||||
exit(
|
||||
'First argument (mandatory):' . PHP_EOL .
|
||||
'Path to a folder, containing folders with .nzb or .nzb.gz files inside them.' . PHP_EOL .
|
||||
'If you supply a path containing only files, the files will be ignored.' . PHP_EOL .
|
||||
'The sub-folders will be searched recursively for NZB files.' . PHP_EOL . PHP_EOL .
|
||||
'Second argument (optional):' . PHP_EOL .
|
||||
'Number of processes, how many processes to run max at a time. (default is 1)' . PHP_EOL . PHP_EOL .
|
||||
'Third argument (optional):' . PHP_EOL .
|
||||
'true|false => Delete the NZB files after they are imported (recommended), if you stop and restart you will have to go over the imported files again.' . PHP_EOL . PHP_EOL .
|
||||
'Fourth argument (optional)' . PHP_EOL .
|
||||
'true|false => Delete the NZB if importing it fails (not recommended).' . PHP_EOL .
|
||||
'Fifth argument (optional):' . PHP_EOL .
|
||||
'true|false => Use the NZB file name as the release name (not recommended), the names in the NZB are better.' . PHP_EOL . PHP_EOL .
|
||||
'Sixth argument (optional):' . PHP_EOL .
|
||||
'How many NZB files to import per process, if this is not set, it will do 50,000 per process.' . PHP_EOL . PHP_EOL .
|
||||
'Note that successfully imported NZB files WILL be deleted.' . PHP_EOL
|
||||
|
||||
);
|
||||
}
|
||||
(new ForkingImportNZB())->start(
|
||||
$argv[1],
|
||||
(isset($argv[2]) && is_numeric($argv[2]) && $argv[2] > 0 ? $argv[2] : 1),
|
||||
(isset($argv[3]) && $argv[3] === 'true' ? 'true' : 'false'),
|
||||
(isset($argv[4]) && $argv[4] === 'true' ? 'true' : 'false'),
|
||||
(isset($argv[5]) && $argv[5] === 'true' ? 'true' : 'false'),
|
||||
(isset($argv[6]) && is_numeric($argv[6]) && $argv[6] > 0 ? $argv[6] : 50000)
|
||||
);
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
if (!isset($argv[1]) || !in_array($argv[1], ['ama', 'add', 'mov', 'nfo', 'sha', 'tv'])) {
|
||||
exit(
|
||||
'First argument (mandatory):' . PHP_EOL .
|
||||
'ama => Do amazon processing, this does not use multi-processing, because of amazon API restrictions.' . PHP_EOL .
|
||||
'add => Do additional (rar|zip) processing.' . PHP_EOL .
|
||||
'mov => Do movie processing.' . PHP_EOL .
|
||||
'nfo => Do NFO processing.' . PHP_EOL .
|
||||
'sha => Do sharing processing, this does not use multi-processing.' . PHP_EOL .
|
||||
'tv => Do TV processing.' . PHP_EOL . PHP_EOL .
|
||||
'Second argument (optional):' . PHP_EOL .
|
||||
'true|false => Only post-process renamed releases. This is for the mov|tv options.' . PHP_EOL
|
||||
);
|
||||
}
|
||||
|
||||
declare(ticks=1);
|
||||
require('.do_not_run/require.php');
|
||||
|
||||
use newznab\libraries\Forking;
|
||||
|
||||
(new Forking())->processWorkType('postProcess_' . $argv[1], (isset($argv[2]) && $argv[2] === 'true' ? [0 => true] : []));
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
declare(ticks=1);
|
||||
require('.do_not_run/require.php');
|
||||
|
||||
use newznab\libraries\Forking;
|
||||
|
||||
(new Forking())->processWorkType('releases');
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
declare(ticks=1);
|
||||
require('.do_not_run/require.php');
|
||||
|
||||
use \newznab\libraries\Forking;
|
||||
|
||||
(new Forking())->processWorkType('request_id');
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
if (!isset($argv[1]) || !in_array($argv[1], ['backfill', 'binaries'])) {
|
||||
exit(
|
||||
'First argument (mandatory):' . PHP_EOL .
|
||||
'binaries => Do Safe Binaries update.' . PHP_EOL .
|
||||
'backfill => Do Safe Backfill update.' . PHP_EOL
|
||||
);
|
||||
}
|
||||
|
||||
declare(ticks=1);
|
||||
require('.do_not_run/require.php');
|
||||
|
||||
use \newznab\libraries\Forking;
|
||||
|
||||
(new Forking())->processWorkType('safe_' . $argv[1]);
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Maximum time in seconds a child can stay alive.
|
||||
* Keeps long processes, like groups with millions of parts from preventing other groups to update.
|
||||
*
|
||||
* @default 1800
|
||||
*/
|
||||
define('NN_MULTIPROCESSING_MAX_CHILD_TIME', 1800);
|
||||
|
||||
/**
|
||||
* How much work can 1 child do.
|
||||
* Increasing this currently reduces performance with no benefits, here for testing or future use.
|
||||
*
|
||||
* @default 1
|
||||
*/
|
||||
define('NN_MULTIPROCESSING_MAX_CHILD_WORK', 1);
|
||||
|
||||
/**
|
||||
* This setting can be used to override your site settings, to cap the maximum amount of child processes.
|
||||
* Set to 0 to ignore.
|
||||
*
|
||||
* @default 0
|
||||
*/
|
||||
define('NN_MULTIPROCESSING_MAX_CHILDREN_OVERRIDE', 0);
|
||||
|
||||
/**
|
||||
* Which type of messages to display on the screen.
|
||||
*
|
||||
* -1 All messages.
|
||||
* 2 Critical messages.
|
||||
* 4 Warnings.
|
||||
* 6 Info messages.
|
||||
* 7 Debug messages.
|
||||
*
|
||||
* @default 6
|
||||
*/
|
||||
define('NN_MULTIPROCESSING_LOG_TYPE', 6);
|
||||
|
||||
/**
|
||||
* How to display the text output (echo's) from the child processes.
|
||||
*
|
||||
* 0 - Do not display any anything.
|
||||
* 1 - Display the text as the child outputs it in real time. (This will mix all the child process text output.)
|
||||
* 2 - Display the text when the child is done. (This will display the text serially.)
|
||||
*
|
||||
* @default 1
|
||||
*/
|
||||
define('NN_MULTIPROCESSING_CHILD_OUTPUT_TYPE', 1);
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
declare(ticks=1);
|
||||
require('.do_not_run/require.php');
|
||||
|
||||
use \newznab\libraries\Forking;
|
||||
|
||||
// This is the same as the python update_threaded.php
|
||||
(new Forking())->processWorkType('update_per_group');
|
||||
@@ -0,0 +1,88 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# /etc/init.d/newznab: start and stop the newznab update script
|
||||
#
|
||||
# run update-rc.d newznab_ubuntu.sh defaults
|
||||
|
||||
|
||||
### BEGIN INIT INFO
|
||||
# Provides: Newznab
|
||||
# Required-Start: $remote_fs $syslog
|
||||
# Required-Stop: $remote_fs $syslog
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: Start newznab at boot time
|
||||
# Description: Enable newznab service provided by daemon.
|
||||
### END INIT INFO
|
||||
|
||||
RED=$(tput setaf 1)
|
||||
GREEN=$(tput setaf 2)
|
||||
NORMAL=$(tput sgr0)
|
||||
|
||||
col=40
|
||||
|
||||
# Newznab variables
|
||||
|
||||
NN_PATH="/var/www/newznab/htdocs/misc/update_scripts"
|
||||
NN_BINUP="update_binaries.php"
|
||||
NN_RELUP="update_releases.php"
|
||||
NN_PREDB="update_predb.php true"
|
||||
NN_OPT="optimise_db.php"
|
||||
NN_TV="update_tvschedule.php"
|
||||
NN_THEATERS="update_theaters.php"
|
||||
NN_SLEEP_TIME="10" # in seconds . 10sec is good for 100s of groups. 600sec might be a good start for fewer.
|
||||
NN_PID_PATH="/var/run/"
|
||||
PIDFILE="newznab_sh.pid"
|
||||
LASTOPTIMIZE=`date +%s`
|
||||
|
||||
test -f /lib/lsb/init-functions || exit 1
|
||||
. /lib/lsb/init-functions
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
if [ -f ${NN_PID_PATH}${PIDFILE} ]
|
||||
then
|
||||
echo "$0 is already running."
|
||||
else
|
||||
echo -n "Starting Newznab binaries update..."
|
||||
cd ${NN_PATH}
|
||||
while :
|
||||
do
|
||||
CURRTIME=`date +%s`
|
||||
php ${NN_BINUP} 2>&1 > /dev/null && php ${NN_RELUP} 2>&1 > /dev/null && php ${NN_PREDB} 2>&1 > /dev/null
|
||||
DIFF=$(($CURRTIME-$LASTOPTIMIZE))
|
||||
if [ "$DIFF" -gt 43200 ] || [ "$DIFF" -lt 1 ]
|
||||
then
|
||||
LASTOPTIMIZE=`date +%s`
|
||||
php ${NN_OPT} 2>&1 > /dev/null && php ${NN_TV} 2>&1 > /dev/null && php ${NN_THEATERS} 2>&1 > /dev/null
|
||||
fi
|
||||
sleep ${NN_SLEEP_TIME}
|
||||
done &
|
||||
PID=$!
|
||||
echo $PID > ${NN_PID_PATH}${PIDFILE}
|
||||
sleep 2
|
||||
if [ -f ${NN_PID_PATH}${PIDFILE} ]
|
||||
then
|
||||
printf '%s%*s%s\n' "$GREEN" $col '[OK]' "$NORMAL"
|
||||
else
|
||||
printf '%s%*s%s\n' "$RED" $col '[FAIL]' "$NORMAL"
|
||||
fi
|
||||
fi &
|
||||
;;
|
||||
stop)
|
||||
echo -n "Stopping Newznab binaries update..."
|
||||
kill -9 `cat ${NN_PID_PATH}${PIDFILE}` && kill -9 `cat ${NN_PID_PATH}${PIDFILE}` && rm ${NN_PID_PATH}${PIDFILE}
|
||||
sleep 2
|
||||
if [ -f ${NN_PID_PATH}${PIDFILE} ]
|
||||
then
|
||||
printf '%s%*s%s\n' "$RED" $col '[FAIL]' "$NORMAL"
|
||||
else
|
||||
printf '%s%*s%s\n' "$GREEN" $col '[OK]' "$NORMAL"
|
||||
fi
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Usage: $0 [start|stop]"
|
||||
exit 1
|
||||
esac
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
#!/bin/sh
|
||||
# call this script from within screen to get binaries, processes releases and
|
||||
# every half day get tv/theatre info and optimise the database
|
||||
|
||||
set -e
|
||||
|
||||
export NEWZNAB_PATH="/usr/local/www/newznab/misc/update_scripts"
|
||||
export NEWZNAB_SLEEP_TIME="600" # in seconds
|
||||
LASTOPTIMIZE=`date +%s`
|
||||
|
||||
while :
|
||||
|
||||
do
|
||||
CURRTIME=`date +%s`
|
||||
cd ${NEWZNAB_PATH}
|
||||
/usr/bin/php5 ${NEWZNAB_PATH}/update_binaries.php
|
||||
/usr/bin/php5 ${NEWZNAB_PATH}/update_releases.php
|
||||
|
||||
DIFF=$(($CURRTIME-$LASTOPTIMIZE))
|
||||
if [ "$DIFF" -gt 43200 ] || [ "$DIFF" -lt 1 ]
|
||||
then
|
||||
LASTOPTIMIZE=`date +%s`
|
||||
/usr/bin/php5 ${NEWZNAB_PATH}/optimise_db.php
|
||||
/usr/bin/php5 ${NEWZNAB_PATH}/update_tvschedule.php
|
||||
/usr/bin/php5 ${NEWZNAB_PATH}/update_theaters.php
|
||||
fi
|
||||
|
||||
echo "waiting ${NEWZNAB_SLEEP_TIME} seconds..."
|
||||
sleep ${NEWZNAB_SLEEP_TIME}
|
||||
|
||||
done
|
||||
@@ -0,0 +1,51 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Ian - 16/11/2011
|
||||
# /etc/init.d/newznab: start and stop the newznab update script
|
||||
#
|
||||
# run update-rc.d newznab_ubuntu.sh defaults
|
||||
|
||||
|
||||
### BEGIN INIT INFO
|
||||
# Provides: Newznab
|
||||
# Required-Start: $remote_fs $syslog
|
||||
# Required-Stop: $remote_fs $syslog
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: Start newznab at boot time
|
||||
# Description: Enable newznab service provided by daemon.
|
||||
### END INIT INFO
|
||||
|
||||
|
||||
# Newznab variables
|
||||
NN_PATH="/var/www/newznab/misc/update_scripts"
|
||||
NN_BINUP="update_binaries.php"
|
||||
NN_RELUP="update_releases.php"
|
||||
NN_SLEEP_TIME="600" # in seconds . 10sec is good for 100s of groups. 600sec might be a good start for fewer.
|
||||
NN_PID_PATH="/var/run/"
|
||||
PIDFILE="newznab_binup.pid"
|
||||
|
||||
test -f /lib/lsb/init-functions || exit 1
|
||||
. /lib/lsb/init-functions
|
||||
|
||||
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
[ -f ${NN_PID_PATH}${PIDFILE} ] && { echo "$0 is already ruNNing."; false; }
|
||||
echo -n "Starting Newznab binaries update"
|
||||
cd ${NN_PATH}
|
||||
(while (true);do cd ${NN_PATH} && php ${NN_BINUP} 2>&1 > /dev/null && php ${NN_RELUP} 2>&1 > /dev/null ; sleep ${NN_SLEEP_TIME} ;done) &
|
||||
PID=`echo $!`
|
||||
echo $PID > ${NN_PID_PATH}${PIDFILE}
|
||||
;;
|
||||
stop)
|
||||
echo -n "Stopping Newznab binaries update"
|
||||
kill -9 `cat ${NN_PID_PATH}${PIDFILE}`
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Usage: $0 [start|stop]"
|
||||
exit 1
|
||||
esac
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
processAlternate*
|
||||
processAdditional*
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
|
||||
require_once(dirname(__FILE__) . "/../../../../../www/config.php");
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
require_once(dirname(__FILE__) . "/config.php");
|
||||
|
||||
use newznab\db\DB;
|
||||
use newznab\processing\PProcess;
|
||||
|
||||
$c = new ColorCLI();
|
||||
if (!isset($argv[1])) {
|
||||
exit($c->error("This script is not intended to be run manually, it is called from fixreleasenames_threaded.py."));
|
||||
} else if (isset($argv[1])) {
|
||||
$db = new DB();
|
||||
$namefixer = new \NameFixer(['Settings' => $pdo]);
|
||||
$pieces = explode(' ', $argv[1]);
|
||||
if (isset($pieces[1]) && $pieces[0] == 'nfo') {
|
||||
$release = $pieces[1];
|
||||
if ($res = $db->queryOneRow(sprintf('SELECT rel.guid AS guid, nfo.releaseid AS nfoid, rel.groupid, rel.categoryid, rel.name, rel.searchname, uncompress(nfo) AS textstring, rel.id AS releaseid FROM releases rel INNER JOIN releasenfo nfo ON (nfo.releaseid = rel.id) WHERE rel.id = %d', $release))) {
|
||||
//ignore encrypted nfos
|
||||
if (preg_match('/^=newz\[NZB\]=\w+/', $res['textstring'])) {
|
||||
$namefixer->done = $namefixer->matched = false;
|
||||
$db->queryDirect(sprintf('UPDATE releases SET proc_nfo = 1 WHERE id = %d', $res['releaseid']));
|
||||
$namefixer->checked++;
|
||||
echo '.';
|
||||
} else {
|
||||
//echo $res['textstring']."\n";
|
||||
$namefixer->done = $namefixer->matched = false;
|
||||
if ($namefixer->checkName($res, true, 'NFO, ', 1, 1) !== true) {
|
||||
echo '.';
|
||||
}
|
||||
$namefixer->checked++;
|
||||
}
|
||||
}
|
||||
} else if (isset($pieces[1]) && $pieces[0] == 'filename') {
|
||||
$release = $pieces[1];
|
||||
if ($res = $db->queryOneRow(sprintf('SELECT relfiles.name AS textstring, rel.categoryid, rel.searchname, '
|
||||
. 'rel.groupid, relfiles.releaseid AS fileid, rel.id AS releaseid, rel.name FROM releases rel '
|
||||
. 'INNER JOIN releasefiles relfiles ON (relfiles.releaseid = rel.id) WHERE rel.id = %d', $release))) {
|
||||
$namefixer->done = $namefixer->matched = false;
|
||||
if ($namefixer->checkName($res, true, 'Filenames, ', 1, 1) !== true) {
|
||||
echo '.';
|
||||
}
|
||||
$namefixer->checked++;
|
||||
}
|
||||
} else if (isset($pieces[1]) && $pieces[0] == 'md5') {
|
||||
$release = $pieces[1];
|
||||
if ($res = $db->queryOneRow(sprintf('SELECT r.id AS releaseid, r.name, r.searchname, r.categoryid, r.groupid, dehashstatus, rf.name AS filename FROM releases r LEFT JOIN releasefiles rf ON r.id = rf.releaseid WHERE r.id = %d', $release))) {
|
||||
if (preg_match('/[a-fA-F0-9]{32,40}/i', $res['name'], $matches)) {
|
||||
$namefixer->matchPredbHash($matches[0], $res, 1, 1, true, 1);
|
||||
} else if (preg_match('/[a-fA-F0-9]{32,40}/i', $res['filename'], $matches)) {
|
||||
$namefixer->matchPredbHash($matches[0], $res, 1, 1, true, 1);
|
||||
} else {
|
||||
$db->queryExec(sprintf("UPDATE releases SET dehashstatus = %d - 1 WHERE id = %d", $res['dehashstatus'], $res['releaseid']));
|
||||
echo '.';
|
||||
}
|
||||
}
|
||||
} else if (isset($pieces[1]) && $pieces[0] == 'par2') {
|
||||
$nntp = new NNTP();
|
||||
if ($nntp->doConnect() === false) {
|
||||
exit($c->error("Unable to connect to usenet."));
|
||||
}
|
||||
|
||||
$relID = $pieces[1];
|
||||
$guid = $pieces[2];
|
||||
$groupID = $pieces[3];
|
||||
$nzbcontents = new NZBContents(array('echo' => true, 'nntp' => $nntp, 'nfo' => new Info(), 'db' => $db, 'pp' => new PProcess(['Settings' => $pdo, 'Nfo' => $Nfo, 'NameFixer' => $namefixer])));
|
||||
$res = $nzbcontents->checkPAR2($guid, $relID, $groupID, 1, 1);
|
||||
if ($res === false) {
|
||||
echo '.';
|
||||
}
|
||||
|
||||
$nntp->doQuit();
|
||||
|
||||
} else if (isset($pieces[1]) && $pieces[0] == 'predbft') {
|
||||
$pre = $pieces[1];
|
||||
if ($res = $db->queryOneRow(sprintf('SELECT id AS preid, title, source, searched FROM prehash '
|
||||
. 'WHERE id = %d', $pre
|
||||
)
|
||||
)
|
||||
) {
|
||||
$namefixer->done = $namefixer->matched = false;
|
||||
$ftmatched = $searched = 0;
|
||||
$ftmatched = $namefixer->matchPredbFT($res, 1, 1, true, 1);
|
||||
if ($ftmatched > 0) {
|
||||
$searched = 1;
|
||||
} elseif ($ftmatched < 0) {
|
||||
$searched = -6;
|
||||
echo "*";
|
||||
} else {
|
||||
$searched = $res['searched'] - 1;
|
||||
echo ".";
|
||||
}
|
||||
$db->queryExec(sprintf("UPDATE prehash SET searched = %d WHERE id = %d", $searched, $res['preid']));
|
||||
$namefixer->checked++;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,210 @@
|
||||
<?php
|
||||
require_once(dirname(__FILE__) . "/config.php");
|
||||
|
||||
use newznab\db\DB;
|
||||
use newznab\processing\PProcess;
|
||||
|
||||
$pdo = new DB();
|
||||
$s = new Sites();
|
||||
$site = $s->get();
|
||||
|
||||
if (!isset($argv[1])) {
|
||||
exit($pdo->log->error("This script is not intended to be run manually, it is called from groupfixrelnames_threaded.py."));
|
||||
} else if (isset($argv[1])) {
|
||||
$namefixer = new \NameFixer(['Settings' => $pdo]);
|
||||
$pieces = explode(' ', $argv[1]);
|
||||
$guidChar = $pieces[1];
|
||||
$maxperrun = $pieces[2];
|
||||
$thread = $pieces[3];
|
||||
|
||||
switch (true) {
|
||||
case $pieces[0] === 'nfo' && isset($guidChar) && isset($maxperrun) && is_numeric($maxperrun):
|
||||
$releases = $pdo->queryDirect(
|
||||
sprintf('
|
||||
SELECT r.id AS releaseid, r.guid, r.groupid, r.categoryid, r.name, r.searchname,
|
||||
uncompress(nfo) AS textstring
|
||||
FROM releases r
|
||||
INNER JOIN releasenfo rn ON r.id = rn.releaseid
|
||||
WHERE r.guid %s
|
||||
AND r.nzbstatus = 1
|
||||
AND r.proc_nfo = 0
|
||||
AND r.nfostatus = 1
|
||||
AND r.prehashid = 0
|
||||
ORDER BY r.postdate DESC
|
||||
LIMIT %s',
|
||||
$pdo->likeString($guidChar, false, true),
|
||||
$maxperrun
|
||||
)
|
||||
);
|
||||
|
||||
if ($releases instanceof Traversable) {
|
||||
foreach ($releases as $release) {
|
||||
if (preg_match('/^=newz\[NZB\]=\w+/', $release['textstring'])) {
|
||||
$namefixer->done = $namefixer->matched = false;
|
||||
$pdo->queryDirect(sprintf('UPDATE releases SET proc_nfo = 1 WHERE id = %d', $release['releaseid']));
|
||||
$namefixer->checked++;
|
||||
echo '.';
|
||||
} else {
|
||||
$namefixer->done = $namefixer->matched = false;
|
||||
if ($namefixer->checkName($release, true, 'NFO, ', 1, 1) !== true) {
|
||||
echo '.';
|
||||
}
|
||||
$namefixer->checked++;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case $pieces[0] === 'filename' && isset($guidChar) && isset($maxperrun) && is_numeric($maxperrun):
|
||||
$releases = $pdo->queryDirect(
|
||||
sprintf('
|
||||
SELECT rf.name AS textstring, rf.releaseid AS fileid,
|
||||
r.id AS releaseid, r.name, r.searchname, r.categoryid, r.groupid
|
||||
FROM releases r
|
||||
INNER JOIN releasefiles rf ON r.id = rf.releaseid
|
||||
WHERE r.guid %s
|
||||
AND r.nzbstatus = 1 AND r.proc_files = 0
|
||||
AND r.prehashid = 0
|
||||
ORDER BY r.postdate ASC
|
||||
LIMIT %s',
|
||||
$pdo->likeString($guidChar, false, true),
|
||||
$maxperrun
|
||||
)
|
||||
);
|
||||
|
||||
if ($releases instanceof Traversable) {
|
||||
foreach ($releases as $release) {
|
||||
$namefixer->done = $namefixer->matched = false;
|
||||
if ($namefixer->checkName($release, true, 'Filenames, ', 1, 1) !== true) {
|
||||
echo '.';
|
||||
}
|
||||
$namefixer->checked++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case $pieces[0] === 'md5' && isset($guidChar) && isset($maxperrun) && is_numeric($maxperrun):
|
||||
$releases = $pdo->queryDirect(
|
||||
sprintf('
|
||||
SELECT DISTINCT r.id AS releaseid, r.name, r.searchname, r.categoryid, r.groupid, r.dehashstatus,
|
||||
rf.name AS filename
|
||||
FROM releases r
|
||||
LEFT OUTER JOIN releasefiles rf ON r.id = rf.releaseid AND rf.ishashed = 1
|
||||
WHERE r.guid %s
|
||||
AND nzbstatus = 1 AND r.ishashed = 1
|
||||
AND r.dehashstatus BETWEEN -6 AND 0
|
||||
AND r.prehashid = 0
|
||||
ORDER BY r.dehashstatus DESC, r.postdate ASC
|
||||
LIMIT %s',
|
||||
$pdo->likeString($guidChar, false, true),
|
||||
$maxperrun
|
||||
)
|
||||
);
|
||||
|
||||
if ($releases instanceof Traversable) {
|
||||
foreach ($releases as $release) {
|
||||
if (preg_match('/[a-fA-F0-9]{32,40}/i', $release['name'], $matches)) {
|
||||
$namefixer->matchPredbHash($matches[0], $release, 1, 1, true, 1);
|
||||
} else if (preg_match('/[a-fA-F0-9]{32,40}/i', $release['filename'], $matches)) {
|
||||
$namefixer->matchPredbHash($matches[0], $release, 1, 1, true, 1);
|
||||
} else {
|
||||
$pdo->queryExec(sprintf("UPDATE releases SET dehashstatus = %d - 1 WHERE id = %d", $release['dehashstatus'], $release['releaseid']));
|
||||
echo '.';
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case $pieces[0] === 'par2' && isset($guidChar) && isset($maxperrun) && is_numeric($maxperrun):
|
||||
$releases = $pdo->queryDirect(
|
||||
sprintf('
|
||||
SELECT r.id AS releaseid, r.guid, r.groupid
|
||||
FROM releases r
|
||||
WHERE r.guid %s
|
||||
AND r.nzbstatus = 1
|
||||
AND r.proc_par2 = 0
|
||||
AND r.prehashid = 0
|
||||
ORDER BY r.postdate ASC
|
||||
LIMIT %s',
|
||||
$pdo->likeString($guidChar, false, true),
|
||||
$maxperrun
|
||||
)
|
||||
);
|
||||
|
||||
if ($releases instanceof Traversable) {
|
||||
$nntp = new NNTP(['Settings' => $pdo]);
|
||||
if (($site->alternate_nntp == '1' ? $nntp->doConnect(true, true) : $nntp->doConnect()) !== true) {
|
||||
exit($pdo->log->error("Unable to connect to usenet."));
|
||||
}
|
||||
|
||||
$Nfo = new Info(['Settings' => $pdo, 'Echo' => true]);
|
||||
$nzbcontents = new NZBContents(
|
||||
array(
|
||||
'Echo' => true, 'NNTP' => $nntp, 'Nfo' => $Nfo, 'Settings' => $pdo,
|
||||
'PostProcess' => new PProcess(['Settings' => $pdo, 'Nfo' => $Nfo, 'NameFixer' => $namefixer])
|
||||
)
|
||||
);
|
||||
foreach ($releases as $release) {
|
||||
$res = $nzbcontents->checkPAR2($release['guid'], $release['releaseid'], $release['groupid'], 1, 1);
|
||||
if ($res === false) {
|
||||
echo '.';
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case $pieces[0] === 'miscsorter' && isset($guidChar) && isset($maxperrun) && is_numeric($maxperrun):
|
||||
$releases = $pdo->queryDirect(
|
||||
sprintf('
|
||||
SELECT r.id AS releaseid
|
||||
FROM releases r
|
||||
WHERE r.guid %s
|
||||
AND r.nzbstatus = 1 AND r.nfostatus = 1
|
||||
AND r.proc_sorter = 0 AND r.isrenamed = 0
|
||||
AND r.prehashid = 0
|
||||
ORDER BY r.postdate DESC
|
||||
LIMIT %s',
|
||||
$pdo->likeString($guidChar, false, true),
|
||||
$maxperrun
|
||||
)
|
||||
);
|
||||
|
||||
if ($releases instanceof Traversable) {
|
||||
$sorter = new MiscSorter(true, $pdo);
|
||||
foreach ($releases as $release) {
|
||||
$res = $sorter->nfosorter(null, $release['releaseid']);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case $pieces[0] === 'predbft' && isset($maxperrun) && is_numeric($maxperrun) && isset($thread) && is_numeric($thread):
|
||||
$pres = $pdo->queryDirect(
|
||||
sprintf('
|
||||
SELECT p.id AS prehashid, p.title, p.source, p.searched
|
||||
FROM prehash p
|
||||
WHERE LENGTH(title) >= 15 AND title NOT REGEXP "[\"\<\> ]"
|
||||
AND searched = 0
|
||||
AND DATEDIFF(NOW(), predate) > 1
|
||||
ORDER BY predate ASC
|
||||
LIMIT %s
|
||||
OFFSET %s',
|
||||
$maxperrun,
|
||||
$thread * $maxperrun - $maxperrun
|
||||
)
|
||||
);
|
||||
|
||||
if ($pres instanceof Traversable) {
|
||||
foreach ($pres as $pre) {
|
||||
$namefixer->done = $namefixer->matched = false;
|
||||
$ftmatched = $searched = 0;
|
||||
$ftmatched = $namefixer->matchPredbFT($pre, 1, 1, true, 1);
|
||||
if ($ftmatched > 0) {
|
||||
$searched = 1;
|
||||
} elseif ($ftmatched < 0) {
|
||||
$searched = -6;
|
||||
echo "*";
|
||||
} else {
|
||||
$searched = $pre['searched'] - 1;
|
||||
echo ".";
|
||||
}
|
||||
$pdo->queryExec(sprintf("UPDATE prehash SET searched = %d WHERE id = %d", $searched, $pre['prehashid']));
|
||||
$namefixer->checked++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
<?php
|
||||
|
||||
require_once(dirname(__FILE__) . '/config.php');
|
||||
|
||||
use newznab\db\DB;
|
||||
use newznab\processing\PProcess;
|
||||
|
||||
$pdo = new DB();
|
||||
$s = new Sites();
|
||||
$site = $s->get();
|
||||
/**
|
||||
Array with possible arguments for run and
|
||||
whether or not those methods of operation require NNTP
|
||||
**/
|
||||
|
||||
$args = array(
|
||||
'additional' => true,
|
||||
'all' => true,
|
||||
'allinf' => true,
|
||||
'amazon' => false,
|
||||
'anime' => false,
|
||||
'book' => false,
|
||||
'console' => false,
|
||||
'games' => false,
|
||||
'movies' => false,
|
||||
'music' => false,
|
||||
'nfo' => true,
|
||||
'pre' => true,
|
||||
'sharing' => true,
|
||||
'spotnab' => true,
|
||||
'tv' => false,
|
||||
'tvdb' => false,
|
||||
'xxx' => false,
|
||||
);
|
||||
|
||||
$bool = array(
|
||||
'true',
|
||||
'false'
|
||||
);
|
||||
|
||||
if (!isset($argv[1]) || !in_array($argv[1], $args) || !isset($argv[2]) || !in_array($argv[2], $bool)) {
|
||||
exit(
|
||||
$pdo->log->error(
|
||||
"\nIncorrect arguments.\n"
|
||||
. "The second argument (true/false) determines wether to echo or not.\n\n"
|
||||
. "php postprocess.php all true ...: Does all the types of post processing.\n"
|
||||
. "php postprocess.php pre true ...: Processes all Predb sites.\n"
|
||||
. "php postprocess.php nfo true ...: Processes NFO files.\n"
|
||||
. "php postprocess.php movies true ...: Processes movies.\n"
|
||||
. "php postprocess.php music true ...: Processes music.\n"
|
||||
. "php postprocess.php console true ...: Processes console games.\n"
|
||||
. "php postprocess.php games true ...: Processes games.\n"
|
||||
. "php postprocess.php book true ...: Processes books.\n"
|
||||
. "php postprocess.php anime true ...: Processes anime.\n"
|
||||
. "php postprocess.php tv true ...: Processes tv.\n"
|
||||
. "php postprocess.php tvdb true ...: Processes tvdb.\n"
|
||||
. "php postprocess.php xxx true ...: Processes xxx.\n"
|
||||
. "php postprocess.php additional true ...: Processes previews/mediainfo/etc...\n"
|
||||
. "php postprocess.php sharing true ...: Processes uploading/downloading comments.\n"
|
||||
. "php postprocess.php spotnab true ...: Processes uploading/downloading comments from spotnab.\n"
|
||||
. "php postprocess.php allinf true ...: Does all the types of post processing on a loop, sleeping 15 seconds between.\n"
|
||||
. "php postprocess.php amazon true ...: Does all the amazon (books/console/games/music/xxx).\n"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$nntp = null;
|
||||
if ($args[$argv[1]] === true) {
|
||||
$nntp = new NNTP(['Settings' => $pdo]);
|
||||
if (($site->alternate_nntp == 1 ? $nntp->doConnect(true, true) : $nntp->doConnect()) !== true) {
|
||||
exit($pdo->log->error("Unable to connect to usenet." . PHP_EOL));
|
||||
}
|
||||
}
|
||||
|
||||
$postProcess = new PProcess(['Settings' => $pdo, 'Echo' => ($argv[2] === 'true' ? true : false)]);
|
||||
|
||||
$charArray = ['a','b','c','d','e','f','0','1','2','3','4','5','6','7','8','9'];
|
||||
|
||||
switch ($argv[1]) {
|
||||
|
||||
case 'all':
|
||||
$postProcess->processAll($nntp);
|
||||
break;
|
||||
case 'allinf':
|
||||
$i = 1;
|
||||
while ($i = 1) {
|
||||
$postProcess->processAll($nntp);
|
||||
sleep(15);
|
||||
}
|
||||
break;
|
||||
case 'additional':
|
||||
$postProcess->processAdditional($nntp, '', (isset($argv[3]) && in_array($argv[3], $charArray) ? $argv[3] : ''));
|
||||
break;
|
||||
case 'amazon':
|
||||
$postProcess->processBooks();
|
||||
$postProcess->processConsoles();
|
||||
$postProcess->processGames();
|
||||
$postProcess->processMusic();
|
||||
$postProcess->processXXX();
|
||||
break;
|
||||
case 'anime':
|
||||
$postProcess->processAnime();
|
||||
break;
|
||||
case 'book':
|
||||
$postProcess->processBooks();
|
||||
break;
|
||||
case 'console':
|
||||
$postProcess->processConsoles();
|
||||
break;
|
||||
case 'games':
|
||||
$postProcess->processGames();
|
||||
break;
|
||||
case 'nfo':
|
||||
$postProcess->processNfos($nntp, '', (isset($argv[3]) && in_array($argv[3], $charArray) ? $argv[3] : ''));
|
||||
break;
|
||||
case 'movies':
|
||||
$postProcess->processMovies('', (isset($argv[3]) && in_array($argv[3], $charArray) ? $argv[3] : ''));
|
||||
break;
|
||||
case 'music':
|
||||
$postProcess->processMusic();
|
||||
break;
|
||||
case 'pre':
|
||||
break;
|
||||
case 'sharing':
|
||||
$postProcess->processSharing($nntp);
|
||||
break;
|
||||
case 'spotnab':
|
||||
$postProcess->processSpotnab();
|
||||
break;
|
||||
case 'tv':
|
||||
$postProcess->processTV('', (isset($argv[3]) && in_array($argv[3], $charArray) ? $argv[3] : ''));
|
||||
break;
|
||||
case 'tvdb':
|
||||
$postProcess->processTvDB();
|
||||
break;
|
||||
case 'xxx':
|
||||
$postProcess->processXXX();
|
||||
break;
|
||||
default:
|
||||
exit;
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
require_once(dirname(__FILE__) . '/config.php');
|
||||
|
||||
use newznab\processing\PProcess;
|
||||
|
||||
|
||||
$c = new ColorCLI();
|
||||
if (!isset($argv[1])) {
|
||||
exit($c->error("This script is not intended to be run manually, it is called from postprocess_threaded.py."));
|
||||
}
|
||||
|
||||
|
||||
$tmux = new Tmux;
|
||||
$torun = $tmux->get()->post;
|
||||
|
||||
$pieces = explode(' =+= ', $argv[1]);
|
||||
|
||||
$postprocess = new PProcess(['Echo' => true]);
|
||||
if (isset($pieces[6])) {
|
||||
// Create the connection here and pass
|
||||
$nntp = new NNTP();
|
||||
if ($nntp->doConnect() === false) {
|
||||
exit($c->error("Unable to connect to usenet."));
|
||||
}
|
||||
|
||||
$postprocess->processAdditional($nntp, $argv[1]);
|
||||
$nntp->doQuit();
|
||||
} else if (isset($pieces[3])) {
|
||||
// Create the connection here and pass
|
||||
$nntp = new NNTP();
|
||||
if ($nntp->doConnect() === false) {
|
||||
exit($c->error("Unable to connect to usenet."));
|
||||
}
|
||||
|
||||
$postprocess->processNfos($argv[1], $nntp);
|
||||
$nntp->doQuit();
|
||||
|
||||
} else if (isset($pieces[2])) {
|
||||
$postprocess->processMovies($argv[1]);
|
||||
echo '.';
|
||||
} else if (isset($pieces[1])) {
|
||||
$postprocess->processTv($argv[1]);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?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]);
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
require_once(dirname(__FILE__) . "/config.php");
|
||||
|
||||
|
||||
$time = TIME();
|
||||
$c = new ColorCLI();
|
||||
|
||||
if (isset($argv[1])) {
|
||||
$group = $argv[1];
|
||||
echo $c->header("Updating group {$group}");
|
||||
|
||||
$g = new Groups;
|
||||
$group = $g->getByName($group);
|
||||
|
||||
$bin = new Binaries;
|
||||
$bin->updateGroup($group);
|
||||
} else {
|
||||
$binaries = new Binaries;
|
||||
$binaries->updateAllGroups();
|
||||
}
|
||||
|
||||
function relativeTime($_time)
|
||||
{
|
||||
$d = array();
|
||||
$d[0] = array(1, "sec");
|
||||
$d[1] = array(60, "min");
|
||||
$d[2] = array(3600, "hr");
|
||||
$d[3] = array(86400, "day");
|
||||
$d[4] = array(31104000, "yr");
|
||||
|
||||
$w = array();
|
||||
|
||||
$return = "";
|
||||
$now = TIME();
|
||||
$diff = ($now - $_time);
|
||||
$secondsLeft = $diff;
|
||||
|
||||
for ($i = 4; $i > -1; $i--) {
|
||||
$w[$i] = intval($secondsLeft / $d[$i][0]);
|
||||
$secondsLeft -= ($w[$i] * $d[$i][0]);
|
||||
if ($w[$i] != 0) {
|
||||
//$return.= abs($w[$i]). " " . $d[$i][1] . (($w[$i]>1)?'s':'') ." ";
|
||||
$return .= $w[$i] . " " . $d[$i][1] . (($w[$i] > 1) ? 's' : '') . " ";
|
||||
}
|
||||
}
|
||||
|
||||
//$return .= ($diff>0)?"ago":"left";
|
||||
return $return;
|
||||
}
|
||||
|
||||
echo $c->header("Group update process completed in: " . relativeTime($time) . "\n");
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
require_once(dirname(__FILE__) . '/config.php');
|
||||
|
||||
use newznab\db\DB;
|
||||
|
||||
|
||||
$start = TIME();
|
||||
$pdo = new DB();
|
||||
$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
|
||||
foreach ($array as $val) {
|
||||
//if $val is an array cal myInArray again with $val as array input
|
||||
if (is_array($val)) {
|
||||
if (myInArray($val, $value, $key)) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
//else check if the given key has $value as value
|
||||
if ($array[$key] == $value) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
require_once("config.php");
|
||||
|
||||
use newznab\db\DB;
|
||||
|
||||
|
||||
|
||||
$s = new \Sites();
|
||||
$site = $s->get();
|
||||
$pdo = new DB();
|
||||
|
||||
if (isset($argv[2]) && $argv[2] === 'true') {
|
||||
// Create the connection here and pass
|
||||
$nntp = new \NNTP(['Settings' => $pdo]);
|
||||
if ($nntp->doConnect() !== true) {
|
||||
exit($pdo->log->error("Unable to connect to usenet."));
|
||||
}
|
||||
}
|
||||
if ($site->tablepergroup === 1) {
|
||||
exit($pdo->log->error("You are using 'tablepergroup', you must use .../misc/update_scripts/nix_scripts/multiprocessing/releases.php"));
|
||||
}
|
||||
|
||||
$groupName = isset($argv[3]) ? $argv[3] : '';
|
||||
if (isset($argv[1]) && isset($argv[2])) {
|
||||
$consoletools = new \ConsoleTools(['ColorCLI' => $pdo->log]);
|
||||
$releases = new Releases(['Settings' => $pdo, 'ConsoleTools' => $consoletools]);
|
||||
if ($argv[1] == 1 && $argv[2] == 'true') {
|
||||
$releases->processReleases(1, 1, $groupName, $nntp, true);
|
||||
} else if ($argv[1] == 1 && $argv[2] == 'false') {
|
||||
$releases->processReleases(1, 2, $groupName, $nntp, true);
|
||||
} else if ($argv[1] == 2 && $argv[2] == 'true') {
|
||||
$releases->processReleases(2, 1, $groupName, $nntp, true);
|
||||
} else if ($argv[1] == 2 && $argv[2] == 'false') {
|
||||
$releases->processReleases(2, 2, $groupName, $nntp, true);
|
||||
} else if ($argv[1] == 4 && ($argv[2] == 'true' || $argv[2] == 'false')) {
|
||||
echo $pdo->log->header("Moving all releases to other -> misc, this can take a while, be patient.");
|
||||
$releases->resetCategorize();
|
||||
} else if ($argv[1] == 5 && ($argv[2] == 'true' || $argv[2] == 'false')) {
|
||||
echo $pdo->log->header("Categorizing all non-categorized releases in other->misc using usenet subject. This can take a while, be patient.");
|
||||
$timestart = TIME();
|
||||
$relcount = $releases->categorizeRelease('name', 'WHERE iscategorized = 0 AND categoryid = 8010');
|
||||
$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 ...: Creates releases and attempts to categorize new releases\n"
|
||||
. "php update_releases.php 2 true ...: 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 ...: Puts all releases in other-> misc (also resets to look like they have never been categorized)\n"
|
||||
. "php update_releases.php 5 true ...: Categorizes all releases in other-> misc (which have not been categorized already)\n"
|
||||
. "php update_releases.php 6 false ...: Categorizes releases in misc sections using the search name\n"
|
||||
. "php update_releases.php 6 true ...: Categorizes releases in all sections using the search name\n"));
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
tmux_user.conf
|
||||
my.cnf
|
||||
@@ -0,0 +1,58 @@
|
||||
##
|
||||
# You should look at the following URL's in order to grasp a solid understanding
|
||||
# of Nginx configuration files in order to fully unleash the power of Nginx.
|
||||
# http://wiki.nginx.org/Pitfalls
|
||||
# http://wiki.nginx.org/QuickStart
|
||||
# http://wiki.nginx.org/Configuration
|
||||
# http://interfacelab.com/nginx-php-fpm-apc-awesome/
|
||||
#
|
||||
# Generally, you will want to move this file somewhere, and start with a clean
|
||||
# file but keep this around for reference. Or just disable in sites-enabled.
|
||||
#
|
||||
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
|
||||
##
|
||||
|
||||
server {
|
||||
# Change these settings to match your machine
|
||||
listen 80; ## listen for ipv4; this line is default and implied
|
||||
listen [::]:80 default_server ipv6only=on; ## listen for ipv6
|
||||
server_name localhost; #this must be change to an ip or fqdn or else redirects will not work
|
||||
|
||||
# Everything below here doesn't need to be changed
|
||||
access_log /var/log/nginx/access.log;
|
||||
error_log /var/log/nginx/error.log;
|
||||
|
||||
root /var/www/newznab/www/;
|
||||
index index.html index.htm index.php;
|
||||
|
||||
location ~* \.(?:ico|css|js|gif|inc|txt|gz|xml|png|jpe?g) {
|
||||
expires max;
|
||||
add_header Pragma public;
|
||||
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
|
||||
}
|
||||
|
||||
location / { try_files $uri $uri/ @rewrites; }
|
||||
|
||||
location @rewrites {
|
||||
rewrite ^/([^/\.]+)/([^/]+)/([^/]+)/? /index.php?page=$1&id=$2&subpage=$3 last;
|
||||
rewrite ^/([^/\.]+)/([^/]+)/?$ /index.php?page=$1&id=$2 last;
|
||||
rewrite ^/([^/\.]+)/?$ /index.php?page=$1 last;
|
||||
}
|
||||
|
||||
location /admin { }
|
||||
location /install { }
|
||||
|
||||
location ~ \.php$ {
|
||||
try_files $uri =404;
|
||||
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
||||
# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
|
||||
|
||||
# With php5-cgi alone:
|
||||
#fastcgi_pass 127.0.0.1:9000;
|
||||
# With php5-fpm:
|
||||
fastcgi_pass unix:/var/run/php5-fpm.sock;
|
||||
#fastcgi_index index.php;
|
||||
include fastcgi_params;
|
||||
#include /etc/nginx/fastcgi_params;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
# C-b is not acceptable -- Vim uses it
|
||||
set-option -g prefix C-a
|
||||
bind-key C-a last-window
|
||||
|
||||
# use UTF8
|
||||
set -g utf8
|
||||
set-window-option -g utf8 on
|
||||
|
||||
# Start numbering at 1
|
||||
#set -g base-index 1
|
||||
|
||||
# Start panes at 1 instead of 0. tmux 1.6 only
|
||||
#setw -g pane-base-index 1
|
||||
|
||||
# Allows for faster key repetition
|
||||
set -s escape-time 0
|
||||
|
||||
#set 256 color display
|
||||
set -g default-terminal "screen-256color"
|
||||
|
||||
# Set status bar
|
||||
set -g status-bg black
|
||||
set -g status-fg white
|
||||
set -g status-left ""
|
||||
set -g status-right "#[fg=green]#H"
|
||||
|
||||
# Rather than constraining window size to the maximum size of any client
|
||||
# connected to the *session*, constrain window size to the maximum size of any
|
||||
# client connected to *that window*. Much more reasonable.
|
||||
setw -g aggressive-resize on
|
||||
|
||||
# Allows us to use C-a a <command> to send commands to a TMUX session inside
|
||||
# another TMUX session
|
||||
bind-key a send-prefix
|
||||
|
||||
# Activity monitoring
|
||||
setw -g monitor-activity on
|
||||
#set -g visual-activity on
|
||||
|
||||
# # Refresh the status bar every 30 seconds. Try to keep the nzb folder to a reasonable number
|
||||
set-option -g status-interval 1
|
||||
|
||||
# Example of using a shell command in the status line
|
||||
#set -g status-right "#[fg=yellow]#(uptime | cut -d ',' -f 2-)"
|
||||
#set -g status-right "#[fg=red]#(ls -1 changeme | wc -l) NZB's left to process #[fg=yellow]#(uptime | cut -d ',' -f 2-)"
|
||||
#set -g status-right "#[fg=yellow]#(free -m | grep 'Mem' | awk '{ print \"Ram Used: \"$3\" MB\";}') #[fg=yellow]#(free -m | grep 'Mem' | awk '{ print \"Ram Free: \"$4\" MB\";}') \
|
||||
#[fg=yellow]#(free -m | grep 'Swap' | awk '{ print \"Swap Used: \"$3\" MB\";}') #[fg=yellow]#(uptime | cut -d ',' -f 2-)"
|
||||
|
||||
set -g status-right "#[fg=yellow]#(free -m | grep '+' | awk '{ print \"Ram Used: \"$3\" MB, Ram Free: \"$4\" MB\";}')#(free -m | grep 'Swap' | awk '{ print \",Swap Used: \"$3\" MB\";}') #[fg=cyan,bold]%m-%d-%Y #(uptime)"
|
||||
|
||||
set-option -g status-right-length 200
|
||||
#set -g status-right '#[fg=green][#[fg=blue]%Y-%m-%d #[fg=white]%H:%M#[default] #($HOME/bin/battery)#[fg=green]]'
|
||||
|
||||
# Highlight active window
|
||||
set-window-option -g window-status-current-bg red
|
||||
|
||||
#reduce memory and scrollback buffer
|
||||
set -g history-limit 1000
|
||||
|
||||
#mouse - allows selct pane and resize with mouse
|
||||
set -g mode-mouse on
|
||||
set -g mouse-resize-pane on
|
||||
set -g mouse-select-pane on
|
||||
set -g mouse-select-window on
|
||||
|
||||
set -g set-remain-on-exit on
|
||||
|
||||
bind m \
|
||||
set -g mode-mouse on \;\
|
||||
set -g mouse-resize-pane on \;\
|
||||
set -g mouse-select-pane on \;\
|
||||
set -g mouse-select-window on \;\
|
||||
display 'Mouse: ON'
|
||||
|
||||
bind M \
|
||||
set -g mode-mouse off \;\
|
||||
set -g mouse-resize-pane off \;\
|
||||
set -g mouse-select-pane off \;\
|
||||
set -g mouse-select-window off \;\
|
||||
display 'Mouse: OFF'
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,181 @@
|
||||
<?php
|
||||
require_once(dirname(__FILE__) . "/../../bin/config.php");
|
||||
|
||||
use newznab\db\DB;
|
||||
|
||||
|
||||
// This script can dump all tables or just binaries/parts/partrepair/groups.
|
||||
|
||||
$pdo = new DB();
|
||||
|
||||
$exportopts = "";
|
||||
|
||||
//determine mysql platform Percona or Other
|
||||
$mysqlplatform = exec('mysqladmin version | grep "Percona"');
|
||||
if (strlen($mysqlplatform) > 0) {
|
||||
//Percona only has --innodb-optimize-keys
|
||||
$exportopts = "--opt --innodb-optimize-keys --complete-insert --skip-quick";
|
||||
} else {
|
||||
//generic (or unknown) instance of MySQL
|
||||
$exportopts = "--opt --complete-insert --skip-quick";
|
||||
}
|
||||
|
||||
|
||||
function newname($filename)
|
||||
{
|
||||
rename($filename, dirname($filename)."/".basename($filename,".gz")."_".date("Y_m_d_His", filemtime($filename)).".gz");
|
||||
}
|
||||
|
||||
function builddefaultsfile()
|
||||
{
|
||||
//generate file contents
|
||||
$filetext = "[mysqldump]"
|
||||
."\n"
|
||||
."user = " . DB_USER
|
||||
."\n"
|
||||
."password = " . DB_PASSWORD
|
||||
."\n[mysql]"
|
||||
."\n"
|
||||
."user = " . DB_USER
|
||||
."\n"
|
||||
."password = " . DB_PASSWORD;
|
||||
|
||||
$filehandle = fopen("mysql-defaults.txt", "w+");
|
||||
if(!$filehandle) {
|
||||
exit("Unable to write mysql defaults file! Exiting");
|
||||
} else {
|
||||
fwrite($filehandle, $filetext);
|
||||
fclose($filehandle);
|
||||
chmod("mysql-defaults.txt", 0600);
|
||||
}
|
||||
}
|
||||
|
||||
$dbhost = DB_HOST;
|
||||
$dbport = DB_PORT;
|
||||
$dbsocket = DB_SOCKET;
|
||||
$dbuser = DB_USER;
|
||||
$dbpass = DB_PASSWORD;
|
||||
$dbname = DB_NAME;
|
||||
|
||||
if (DB_SOCKET != '') {
|
||||
$use = "-S $dbsocket";
|
||||
} else {
|
||||
$use = "-P$dbport";
|
||||
}
|
||||
|
||||
//generate defaults file used to store database login information so it is not in cleartext in ps command for mysqldump
|
||||
builddefaultsfile();
|
||||
|
||||
if((isset($argv[1]) && $argv[1] == "db") && (isset($argv[2]) && $argv[2] == "dump") && (isset($argv[3]) && file_exists($argv[3]))) {
|
||||
$filename = $argv[3]."/".$dbname.".gz";
|
||||
echo $pdo->log->header("Dumping $dbname.");
|
||||
if (file_exists($filename)) {
|
||||
newname($filename);
|
||||
}
|
||||
$command = "mysqldump --defaults-file=mysql-defaults.txt $exportopts -h$dbhost $use "."$dbname | gzip -9 > $filename";
|
||||
system($command);
|
||||
} else if((isset($argv[1]) && $argv[1] == "db") && (isset($argv[2]) && $argv[2] == "restore") && (isset($argv[3]) && file_exists($argv[3]))) {
|
||||
$filename = $argv[3]."/".$dbname.".gz";
|
||||
if (file_exists($filename)) {
|
||||
echo $pdo->log->header("Restoring $dbname.");
|
||||
$command = "zcat < $filename | mysql --defaults-file=mysql-defaults.txt -h$dbhost $use $dbname";
|
||||
$pdo->queryExec("SET FOREIGN_KEY_CHECKS=0");
|
||||
system($command);
|
||||
$pdo->queryExec("SET FOREIGN_KEY_CHECKS=1");
|
||||
}
|
||||
} else if((isset($argv[1]) && $argv[1] == "all") && (isset($argv[2]) && $argv[2] == "dump") && (isset($argv[3]) && file_exists($argv[3]))) {
|
||||
$sql = "SHOW tables";
|
||||
$tables = $pdo->query($sql);
|
||||
foreach($tables as $row) {
|
||||
$tbl = $row['tables_in_'.DB_NAME];
|
||||
$filename = $argv[3]."/".$tbl.".gz";
|
||||
echo $pdo->log->header("Dumping $tbl.");
|
||||
if (file_exists($filename)) {
|
||||
newname($filename);
|
||||
}
|
||||
$command = "mysqldump --defaults-file=mysql-defaults.txt $exportopts -h$dbhost $use "."$dbname $tbl | gzip -9 > $filename";
|
||||
system($command);
|
||||
}
|
||||
} else if((isset($argv[1]) && $argv[1] == "all") && (isset($argv[2]) && $argv[2] == "restore") && (isset($argv[3]) && file_exists($argv[3]))) {
|
||||
$sql = "SHOW tables";
|
||||
$tables = $pdo->query($sql);
|
||||
$pdo->queryExec("SET FOREIGN_KEY_CHECKS=0");
|
||||
foreach($tables as $row) {
|
||||
$tbl = $row['tables_in_'.DB_NAME];
|
||||
$filename = $argv[3]."/".$tbl.".gz";
|
||||
if (file_exists($filename)) {
|
||||
echo $pdo->log->header("Restoring $tbl.");
|
||||
$command = "zcat < $filename | mysql --defaults-file=mysql-defaults.txt -h$dbhost $use $dbname";
|
||||
system($command);
|
||||
}
|
||||
}
|
||||
$pdo->queryExec("SET FOREIGN_KEY_CHECKS=1");
|
||||
} else if((isset($argv[1]) && $argv[1] == "test") && (isset($argv[2]) && $argv[2] == "dump") && (isset($argv[3]) && file_exists($argv[3]))) {
|
||||
$arr = array("parts", "binaries", "partrepair", "groups");
|
||||
foreach ($arr as &$tbl) {
|
||||
$filename = $argv[3]."/".$tbl.".gz";
|
||||
echo $pdo->log->header("Dumping $tbl..");
|
||||
if (file_exists($filename)) {
|
||||
newname($filename);
|
||||
}
|
||||
$command = "mysqldump --defaults-file=mysql-defaults.txt $exportopts -h$dbhost $use "."$dbname $tbl | gzip -9 > $filename";
|
||||
system($command);
|
||||
}
|
||||
} else if((isset($argv[1]) && $argv[1] == "test") && (isset($argv[2]) && $argv[2] == "restore") && (isset($argv[3]) && file_exists($argv[3]))) {
|
||||
$arr = array("parts", "binaries", "partrepair", "groups");
|
||||
$pdo->queryExec("SET FOREIGN_KEY_CHECKS=0");
|
||||
foreach ($arr as &$tbl) {
|
||||
$filename = $argv[3]."/".$tbl.".gz";
|
||||
if (file_exists($filename)) {
|
||||
echo $pdo->log->header("Restoring $tbl.");
|
||||
$command = "zcat < $filename | mysql --defaults-file=mysql-defaults.txt -h$dbhost $use $dbname";
|
||||
system($command);
|
||||
}
|
||||
}
|
||||
$pdo->queryExec("SET FOREIGN_KEY_CHECKS=1");
|
||||
} else if((isset($argv[1]) && $argv[1] == "all") && (isset($argv[2]) && $argv[2] == "outfile") && (isset($argv[3]) && file_exists($argv[3]))) {
|
||||
$sql = "SHOW tables";
|
||||
$tables = $pdo->query($sql);
|
||||
foreach($tables as $row) {
|
||||
$tbl = $row['tables_in_'.DB_NAME];
|
||||
$filename = $argv[3].$tbl.".csv";
|
||||
echo $pdo->log->header("Dumping $tbl.");
|
||||
if (file_exists($filename)) {
|
||||
newname($filename);
|
||||
}
|
||||
$pdo->queryDirect(sprintf("SELECT * INTO OUTFILE %s FROM %s", $pdo->escapeString($filename), $tbl));
|
||||
}
|
||||
} else if((isset($argv[1]) && $argv[1] == "all") && (isset($argv[2]) && $argv[2] == "infile") && (isset($argv[3]) && is_dir($argv[3]))) {
|
||||
$sql = "SHOW tables";
|
||||
$tables = $pdo->query($sql);
|
||||
$pdo->queryExec("SET FOREIGN_KEY_CHECKS=0");
|
||||
foreach($tables as $row) {
|
||||
$tbl = $row['tables_in_'.DB_NAME];
|
||||
$filename = $argv[3].$tbl.".csv";
|
||||
if (file_exists($filename)) {
|
||||
echo $pdo->log->header("Restoring $tbl.");
|
||||
$pdo->queryExec(sprintf("LOAD DATA INFILE %s INTO TABLE %s", $pdo->escapeString($filename), $tbl));
|
||||
}
|
||||
}
|
||||
$pdo->queryExec("SET FOREIGN_KEY_CHECKS=1");
|
||||
} else {
|
||||
passthru("clear");
|
||||
echo $pdo->log->error("\nThis script can dump/restore all tables, compressed or OUTFILE/INFILE, or just collections/binaries/parts.\n\n"
|
||||
. "**Single File\n"
|
||||
. "php $argv[0] db dump /path/to/save/to ...: To dump the database.\n"
|
||||
. "php $argv[0] db restore /path/to/restore/from ...: To restore the database.\n\n"
|
||||
. "**Individual Table Files\n"
|
||||
. "php $argv[0] all dump /path/to/save/to ...: To dump all tables.\n"
|
||||
. "php $argv[0] all restore /path/to/restore/from ...: To restore all tables.\n\n"
|
||||
. "**Two Tables (binaries, parts)\n"
|
||||
. "php $argv[0] test dump /path/to/save/to ...: To dump binaries, parts tables.\n"
|
||||
. "php $argv[0] test restore /path/to/restore/from ...: To restore binaries, parts tables.\n\n"
|
||||
. "**Individal Files - OUTFILE/INFILE - No schema\n"
|
||||
. "**MySQL MUST have write permissions to this path\n"
|
||||
. "php $argv[0] all outfile /path/to/save/to ...: To dump all tables, using OUTFILE.\n"
|
||||
. "php $argv[0] all infile /path/to/restore/from ...: To restore all tables, using INFILE.\n\n");
|
||||
}
|
||||
|
||||
if(file_exists("mysql-defaults.txt")) {
|
||||
@unlink("mysql-defaults.txt");
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
<?php
|
||||
require_once(dirname(__FILE__) . "/../../bin/config.php");
|
||||
|
||||
use newznab\db\DB;
|
||||
use newznab\utility\Utility;
|
||||
|
||||
// Function inspired by : http://stackoverflow.com/questions/1883079/best-practice-import-mysql-file-in-php-split-queries/2011454#2011454
|
||||
function SplitSQL($file, $delimiter = ';')
|
||||
{
|
||||
set_time_limit(0);
|
||||
|
||||
if (is_file($file) === true) {
|
||||
$file = fopen($file, 'r');
|
||||
|
||||
if (is_resource($file) === true) {
|
||||
$query = array();
|
||||
$db = new DB();
|
||||
$dbsys = DB_TYPE;
|
||||
$c = new ColorCLI();
|
||||
|
||||
while (feof($file) === false) {
|
||||
$query[] = fgets($file);
|
||||
if (preg_match('~' . preg_quote($delimiter, '~') . '\s*$~iS', end($query)) === 1) {
|
||||
$query = trim(implode('', $query));
|
||||
|
||||
if ($dbsys == "pgsql") {
|
||||
$query = str_replace(array("`", chr(96)), '', $query);
|
||||
}
|
||||
try {
|
||||
$qry = $db->prepare($query);
|
||||
$qry->execute();
|
||||
echo $c->alternateOver('SUCCESS: ') . $c->primary($query);
|
||||
} catch (PDOException $e) {
|
||||
if ($e->errorInfo[1] == 1091 || $e->errorInfo[1] == 1060 || $e->errorInfo[1] == 1054 || $e->errorInfo[1] == 1061 || $e->errorInfo[1] == 1062 || $e->errorInfo[1] == 1071 || $e->errorInfo[1] == 1072 || $e->errorInfo[1] == 1146 || $e->errorInfo[0] == 23505 || $e->errorInfo[0] == 42701 || $e->errorInfo[0] == 42703 || $e->errorInfo[0] == '42P07' || $e->errorInfo[0] == '42P16') {
|
||||
if ($e->errorInfo[1] == 1060) {
|
||||
echo $c->error($query . " The column already exists - Not Fatal {" . $e->errorInfo[1] . "}.\n");
|
||||
} else {
|
||||
echo $c->error($query . " Skipped - Not Fatal {" . $e->errorInfo[1] . "}.\n");
|
||||
}
|
||||
} else {
|
||||
if (preg_match('/ALTER IGNORE/i', $query)) {
|
||||
$db->queryExec("SET SESSION old_alter_table = 1");
|
||||
try {
|
||||
$qry = $db->prepare($query);
|
||||
$qry->execute();
|
||||
echo $c->alternateOver('SUCCESS: ') . $c->primary($query);
|
||||
} catch (PDOException $e) {
|
||||
exit($c->error($query . " Failed {" . $e->errorInfo[1] . "}\n\t" . $e->errorInfo[2]));
|
||||
}
|
||||
} else {
|
||||
exit($c->error($query . " Failed {" . $e->errorInfo[1] . "}\n\t" . $e->errorInfo[2]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while (ob_get_level() > 0) {
|
||||
ob_end_flush();
|
||||
}
|
||||
flush();
|
||||
}
|
||||
|
||||
if (is_string($query) === true) {
|
||||
$query = array();
|
||||
}
|
||||
}
|
||||
return fclose($file);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function BackupDatabase()
|
||||
{
|
||||
$db = new DB();
|
||||
$c = new ColorCLI();
|
||||
$DIR = dirname (__FILE__);
|
||||
|
||||
if (Utility::hasCommand("php5")) {
|
||||
$PHP = "php5";
|
||||
} else {
|
||||
$PHP = "php";
|
||||
}
|
||||
|
||||
//Backup based on database system
|
||||
if ($db->dbSystem() == "mysql") {
|
||||
system("$PHP ${DIR}mysqldump_tables.php db dump ../../");
|
||||
} else if ($db->dbSystem() == "pgsql") {
|
||||
exit($c->error("Currently not supported on this platform."));
|
||||
}
|
||||
}
|
||||
|
||||
$os = (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') ? "windows" : "unix";
|
||||
|
||||
if (isset($argv[1]) && $argv[1] == "safe") {
|
||||
$safeupgrade = true;
|
||||
} else {
|
||||
$safeupgrade = false;
|
||||
}
|
||||
|
||||
if (isset($os) && $os == "unix") {
|
||||
$t = new Tmux();
|
||||
$tmux = $t->get();
|
||||
$currentversion = $tmux->sqlpatch;
|
||||
$patched = 0;
|
||||
$patches = array();
|
||||
$db = new DB();
|
||||
$backedup = false;
|
||||
$c = new ColorCLI();
|
||||
$DIR = dirname (__FILE__);
|
||||
$path = $DIR.'/patches/';
|
||||
|
||||
|
||||
// Open the patch folder.
|
||||
if ($handle = @opendir($path)) {
|
||||
while (false !== ($patch = readdir($handle))) {
|
||||
$patches[] = $patch;
|
||||
}
|
||||
closedir($handle);
|
||||
} else {
|
||||
exit($c->error("\nHave you changed the path to the patches folder, or do you have the right permissions?\n"));
|
||||
}
|
||||
|
||||
/* if ($db->dbSystem() == "mysql")
|
||||
$patchpath = preg_replace('/\/misc\/testing\/DB/i', '/db/patches/mysql/',
|
||||
NN_ROOT);
|
||||
else if ($db->dbSystem() == "pgsql")
|
||||
$patchpath = preg_replace('/\/misc\/testing\/DB/i', '/db/patches/pgsql/', nZEDb_ROOT);
|
||||
*/ sort($patches);
|
||||
|
||||
foreach ($patches as $patch) {
|
||||
if (preg_match('/\.sql$/i', $patch)) {
|
||||
$filepath = $path . $patch;
|
||||
$file = fopen($filepath, "r");
|
||||
$patch = fread($file, filesize($filepath));
|
||||
if (preg_match('/UPDATE `?tmux`? SET `?value`? = \'?(\d{1,})\'? WHERE `?setting`? = \'sqlpatch\'/i', $patch, $patchnumber)) {
|
||||
if ($patchnumber['1'] > $currentversion) {
|
||||
if ($safeupgrade == true && $backedup == false) {
|
||||
BackupDatabase();
|
||||
$backedup = true;
|
||||
}
|
||||
SplitSQL($filepath);
|
||||
$patched++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (isset($os) && $os == "windows") {
|
||||
$t = new Tmux();
|
||||
$tmux = $t->get();
|
||||
$currentversion = $tmux->sqlpatch;
|
||||
$patched = 0;
|
||||
$patches = array();
|
||||
|
||||
// Open the patch folder.
|
||||
if (!isset($argv[1])) {
|
||||
exit($c->error("\nYou must supply the directory to the patches.\n"));
|
||||
}
|
||||
if ($handle = @opendir($argv[1])) {
|
||||
while (false !== ($patch = readdir($handle))) {
|
||||
$patches[] = $patch;
|
||||
}
|
||||
closedir($handle);
|
||||
} else {
|
||||
exit($c->error("\nHave you changed the path to the patches folder, or do you have the right permissions?\n"));
|
||||
}
|
||||
|
||||
sort($patches);
|
||||
foreach ($patches as $patch) {
|
||||
if (preg_match('/\.sql$/i', $patch)) {
|
||||
$filepath = $argv[1] . $patch;
|
||||
$file = fopen($filepath, "r");
|
||||
$patch = fread($file, filesize($filepath));
|
||||
if (preg_match('/UPDATE `?tmux`? SET `?value`? = \'?(\d{1,})\'? WHERE `?setting`? = \'sqlpatch\'/i', $patch, $patchnumber)) {
|
||||
if ($patchnumber['1'] > $currentversion) {
|
||||
if ($safeupgrade == true && $backedup == false) {
|
||||
BackupDatabase();
|
||||
$backedup = true;
|
||||
}
|
||||
SplitSQL($filepath);
|
||||
$patched++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
exit($c->error("\nUnable to determine OS.\n"));
|
||||
}
|
||||
|
||||
if ($patched == 0) {
|
||||
exit($c->info("Nothing to patch, you are already on patch version " . $currentversion));
|
||||
}
|
||||
if ($patched > 0) {
|
||||
echo $c->header($patched . " patch(es) applied.");
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
DELETE FROM `tmux` WHERE `setting` = 'releases_threaded';
|
||||
|
||||
UPDATE `tmux` set `value` = '1' where `setting` = 'sqlpatch';
|
||||
@@ -0,0 +1,11 @@
|
||||
DELETE FROM `tmux` WHERE `setting` = 'collections_kill';
|
||||
DELETE FROM `tmux` WHERE `setting` = 'sorter';
|
||||
DELETE FROM `tmux` WHERE `setting` = 'sorter_timer';
|
||||
DELETE FROM `tmux` WHERE `setting` = 'optimize';
|
||||
DELETE FROM `tmux` WHERE `setting` = 'optimize_timer';
|
||||
INSERT IGNORE INTO `tmux` (`setting`, `value`) VALUES ('sphinx', '0'),
|
||||
('sphinx_timer', '600'),
|
||||
('delete_parts', '0'),
|
||||
('delete_timer', '43200');
|
||||
|
||||
UPDATE `tmux` set `value` = '2' where `setting` = 'sqlpatch';
|
||||
@@ -0,0 +1,3 @@
|
||||
INSERT IGNORE INTO `tmux` (`setting`, `value`) VALUES ('partrepair', 1);
|
||||
|
||||
UPDATE `tmux` set `value` = '4' where `setting` = 'sqlpatch';
|
||||
@@ -0,0 +1,3 @@
|
||||
ALTER TABLE `releases` DROP COLUMN `nzbstatus`;
|
||||
|
||||
UPDATE `tmux` set `value` = '5' where `setting` = 'sqlpatch';
|
||||
@@ -0,0 +1,3 @@
|
||||
INSERT IGNORE INTO `tmux` (`setting`, `value`) VALUES ('zippath', '');
|
||||
|
||||
UPDATE `tmux` set `value` = '6' where `setting` = 'sqlpatch';
|
||||
@@ -0,0 +1,4 @@
|
||||
ALTER TABLE `releases` ADD `jpgstatus` TINYINT(1) NOT NULL DEFAULT 0;
|
||||
INSERT IGNORE INTO `tmux` (`setting`, `value`) VALUES ('processjpg', 0);
|
||||
|
||||
UPDATE `tmux` set `value` = '7' where `setting` = 'sqlpatch';
|
||||
@@ -0,0 +1,3 @@
|
||||
ALTER TABLE `releases` ADD `prehashid` INT(12) NULL DEFAULT NULL;
|
||||
|
||||
UPDATE `tmux` set `value` = '8' where `setting` = 'sqlpatch';
|
||||
@@ -0,0 +1,2 @@
|
||||
ALTER TABLE `releases` CHANGE COLUMN `prehashid` `prehashid` INT UNSIGNED NOT NULL DEFAULT '0';
|
||||
UPDATE `tmux` set `value` = '9' where `setting` = 'sqlpatch';
|
||||
@@ -0,0 +1,2 @@
|
||||
ALTER TABLE `releases` ADD INDEX `ix_releases_prehashid_searchname` (`prehashid`, `searchname`);
|
||||
UPDATE `tmux` set `value` = '10' where `setting` = 'sqlpatch';
|
||||
@@ -0,0 +1,3 @@
|
||||
ALTER TABLE `prehash` ADD INDEX `ix_prehash_size` (`size`);
|
||||
ALTER TABLE `prehash` ADD INDEX `ix_prehash_category` (`category`);
|
||||
UPDATE `tmux` set `value` = '11' where `setting` = 'sqlpatch';
|
||||
@@ -0,0 +1,10 @@
|
||||
/* Is this pre nuked? 0 no 1 yes 2 un nuked 3 mod nuked */
|
||||
ALTER TABLE prehash ADD COLUMN nuked TINYINT(1) NOT NULL DEFAULT '0';
|
||||
|
||||
/* If this pre is nuked, what is the reason? */
|
||||
ALTER TABLE prehash ADD COLUMN nukereason VARCHAR(255) NULL;
|
||||
|
||||
/* How many files does this pre have ? */
|
||||
ALTER TABLE prehash ADD COLUMN files VARCHAR(50) NULL;
|
||||
|
||||
UPDATE tmux SET value = '12' WHERE setting = 'sqlpatch';
|
||||
@@ -0,0 +1,4 @@
|
||||
INSERT IGNORE INTO tmux (setting, value) VALUE ('scrape_cz', 0);
|
||||
INSERT IGNORE INTO tmux (setting, value) VALUE ('scrape_efnet', 0);
|
||||
|
||||
UPDATE tmux SET value = '13' WHERE setting = 'sqlpatch';
|
||||
@@ -0,0 +1,10 @@
|
||||
/* Drop the adddate index */
|
||||
ALTER TABLE prehash DROP INDEX ix_prehash_adddate;
|
||||
|
||||
/* Drop the adddate column */
|
||||
ALTER TABLE prehash DROP COLUMN adddate;
|
||||
|
||||
/* Use tmux table to keep the last pre time (unixtime) */
|
||||
INSERT INTO tmux (setting, value) VALUES ('lastpretime', '0');
|
||||
|
||||
UPDATE tmux SET value = '14' WHERE setting = 'sqlpatch';
|
||||
@@ -0,0 +1,34 @@
|
||||
DROP TABLE IF EXISTS sharing_sites;
|
||||
CREATE TABLE sharing_sites (
|
||||
id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
site_name VARCHAR(255) NOT NULL DEFAULT '',
|
||||
site_guid VARCHAR(40) NOT NULL DEFAULT '',
|
||||
last_time DATETIME DEFAULT NULL,
|
||||
first_time DATETIME DEFAULT NULL,
|
||||
enabled TINYINT(1) NOT NULL DEFAULT '0',
|
||||
comments MEDIUMINT UNSIGNED NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (id)
|
||||
) ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci AUTO_INCREMENT=1 ;
|
||||
|
||||
DROP TABLE IF EXISTS sharing;
|
||||
CREATE TABLE sharing (
|
||||
site_guid VARCHAR(40) NOT NULL DEFAULT '',
|
||||
site_name VARCHAR(255) NOT NULL DEFAULT '',
|
||||
enabled TINYINT(1) NOT NULL DEFAULT '0',
|
||||
posting TINYINT(1) NOT NULL DEFAULT '0',
|
||||
start_position TINYINT(1) NOT NULL DEFAULT '0',
|
||||
fetching TINYINT(1) NOT NULL DEFAULT '1',
|
||||
auto_enable TINYINT(1) NOT NULL DEFAULT '1',
|
||||
hide_users TINYINT(1) NOT NULL DEFAULT '1',
|
||||
last_article BIGINT UNSIGNED NOT NULL DEFAULT '0',
|
||||
max_push MEDIUMINT UNSIGNED NOT NULL DEFAULT '40',
|
||||
max_pull INT UNSIGNED NOT NULL DEFAULT '200',
|
||||
PRIMARY KEY (site_guid)
|
||||
) ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
|
||||
|
||||
ALTER TABLE releasecomment ADD COLUMN shared TINYINT(1) NOT NULL DEFAULT '1';
|
||||
ALTER TABLE releasecomment ADD COLUMN shareid VARCHAR(40) NOT NULL DEFAULT '';
|
||||
ALTER TABLE releasecomment ADD COLUMN siteid VARCHAR(40) NOT NULL DEFAULT '';
|
||||
ALTER TABLE releasecomment ADD COLUMN nzb_guid VARCHAR(32) NOT NULL DEFAULT '';
|
||||
|
||||
UPDATE tmux SET value = '15' WHERE setting = 'sqlpatch';
|
||||
@@ -0,0 +1,4 @@
|
||||
INSERT IGNORE INTO tmux (setting, value) VALUE ('nntpretries', '10');
|
||||
INSERT IGNORE INTO tmux (setting, value) VALUE ('alternate_nntp', '0');
|
||||
|
||||
UPDATE tmux SET value = '16' WHERE setting = 'sqlpatch';
|
||||
@@ -0,0 +1,3 @@
|
||||
INSERT IGNORE INTO tmux (setting, value) VALUE ('sharing_timer', '60');
|
||||
|
||||
UPDATE tmux SET value = '17' WHERE setting = 'sqlpatch';
|
||||
@@ -0,0 +1,5 @@
|
||||
ALTER TABLE sharing ADD COLUMN max_download MEDIUMINT UNSIGNED NOT NULL DEFAULT '150';
|
||||
|
||||
UPDATE sharing SET max_pull = 20000;
|
||||
|
||||
UPDATE tmux SET value = '18' WHERE setting = 'sqlpatch';
|
||||
@@ -0,0 +1,5 @@
|
||||
UPDATE releasecomment SET username = (SELECT username FROM users WHERE users.id = releasecomment.userid);
|
||||
|
||||
DELETE FROM users WHERE email = 'sharing@nZEDb.com' AND role = 0;
|
||||
|
||||
UPDATE tmux SET value = '19' WHERE setting = 'sqlpatch';
|
||||
@@ -0,0 +1,6 @@
|
||||
DELETE FROM `tmux` WHERE `setting` = 'delete_parts';
|
||||
DELETE FROM `tmux` WHERE `setting` = 'delete_timer';
|
||||
|
||||
|
||||
|
||||
UPDATE `tmux` set `value` = '20' where `setting` = 'sqlpatch';
|
||||
@@ -0,0 +1,5 @@
|
||||
DELETE FROM `tmux` WHERE `setting` = 'alternate_nntp';
|
||||
|
||||
|
||||
|
||||
UPDATE `tmux` set `value` = '21' where `setting` = 'sqlpatch';
|
||||
@@ -0,0 +1,3 @@
|
||||
ALTER TABLE `releases` ADD INDEX `ix_releases_releasenfoID` (`releasenfoid`);
|
||||
|
||||
UPDATE `tmux` set `value` = '22' where `setting` = 'sqlpatch';
|
||||
@@ -0,0 +1,3 @@
|
||||
INSERT IGNORE INTO tmux (setting, value) VALUE ('fanarttvkey', '');
|
||||
|
||||
UPDATE tmux SET value = '23' WHERE setting = 'sqlpatch';
|
||||
@@ -0,0 +1,3 @@
|
||||
INSERT IGNORE INTO tmux (setting, value) VALUE ('imdburl', '0');
|
||||
|
||||
UPDATE tmux SET value = '24' WHERE setting = 'sqlpatch';
|
||||
@@ -0,0 +1,3 @@
|
||||
INSERT IGNORE INTO tmux (setting, value) VALUE ('yydecoderpath', '');
|
||||
|
||||
UPDATE tmux SET value = '25' WHERE setting = 'sqlpatch';
|
||||
@@ -0,0 +1,9 @@
|
||||
INSERT IGNORE INTO tmux (setting, value) VALUE ('ffmpeg_duration', '5');
|
||||
INSERT IGNORE INTO tmux (setting, VALUE) VALUE ('ffmpeg_image_time', '5');
|
||||
INSERT IGNORE INTO tmux (setting, value) VALUE ('processvideos', '0');
|
||||
|
||||
ALTER TABLE `releases` ADD `proc_pp` TINYINT(1) NOT NULL DEFAULT 0;
|
||||
ALTER TABLE `releases` ADD `videostatus` TINYINT(1) NOT NULL DEFAULT 0;
|
||||
ALTER TABLE `releases` ADD `audiostatus` TINYINT(1) NOT NULL DEFAULT 0;
|
||||
|
||||
UPDATE tmux SET value = '26' WHERE setting = 'sqlpatch';
|
||||
@@ -0,0 +1,9 @@
|
||||
DELETE FROM prehash
|
||||
WHERE MD5(title) != MD5;
|
||||
ALTER TABLE prehash ADD COLUMN sha1 VARCHAR(40) NOT NULL DEFAULT '';
|
||||
ALTER TABLE prehash MODIFY COLUMN md5 VARCHAR(32) NOT NULL DEFAULT '';
|
||||
|
||||
UPDATE prehash SET sha1 = sha1(title);
|
||||
CREATE UNIQUE INDEX ix_prehash_sha1 ON prehash(sha1);
|
||||
|
||||
UPDATE tmux SET value = '27' WHERE setting = 'sqlpatch';
|
||||
@@ -0,0 +1,3 @@
|
||||
INSERT IGNORE INTO tmux (setting, value) VALUE ('bins_kill_timer', '0');
|
||||
|
||||
UPDATE tmux SET value = '28' WHERE setting = 'sqlpatch';
|
||||
@@ -0,0 +1,11 @@
|
||||
ALTER TABLE `releases` ADD COLUMN `nzbstatus` TINYINT(1) NOT NULL DEFAULT 1;
|
||||
ALTER TABLE `releases` ADD COLUMN `nzb_guid` VARCHAR(50) NULL;
|
||||
ALTER TABLE `releases` DROP INDEX `ix_releases_status`;
|
||||
ALTER TABLE `releases` ADD INDEX `ix_releases_status` (`nzbstatus`, `iscategorized`, `isrenamed`, `nfostatus`, `ishashed`, `passwordstatus`, `dehashstatus`, `releasenfoid`, `musicinfoid`, `consoleinfoid`, `bookinfoid`, `haspreview`, `categoryid`, `imdbid`, `rageid`);
|
||||
CREATE INDEX `ix_releases_nzb_guid` ON `releases` (`nzb_guid`);
|
||||
|
||||
UPDATE `releases` SET nzbstatus = 1 WHERE nzbstatus = 0;
|
||||
|
||||
|
||||
|
||||
UPDATE `tmux` set `value` = '29' where `setting` = 'sqlpatch';
|
||||
@@ -0,0 +1,3 @@
|
||||
UPDATE `tmux` SET VALUE = 'http://reqid.nzedb.com/index.php?reqid=[REQUEST_ID]&group=[GROUP_NM]' WHERE `setting` = 'request_url';
|
||||
|
||||
UPDATE `tmux` set `value` = '30' where `setting` = 'sqlpatch';
|
||||
@@ -0,0 +1,4 @@
|
||||
ALTER TABLE `releases` DROP COLUMN `nzb_guid`;
|
||||
ALTER TABLE `releases` DROP INDEX `ix_releases_nzb_guid`;
|
||||
|
||||
UPDATE `tmux` set `value` = '31' where `setting` = 'sqlpatch';
|
||||
@@ -0,0 +1,9 @@
|
||||
DROP TRIGGER IF EXISTS check_insert;
|
||||
DROP TRIGGER IF EXISTS check_update;
|
||||
|
||||
|
||||
CREATE TRIGGER check_insert BEFORE INSERT ON releases FOR EACH ROW BEGIN IF NEW.searchname REGEXP '[a-fA-F0-9]{32}' OR NEW.name REGEXP '[a-fA-F0-9]{32}' THEN SET NEW.ishashed = 1;ELSEIF NEW.name REGEXP '^\[ ?([[:digit:]]{4,6}) ?\]|^REQ\s*([[:digit:]]{4,6})|^([[:digit:]]{4,6})-[[:digit:]]{1}\\[' THEN SET NEW.isrequestid = 1;ELSEIF NEW.releasenfoid = 0 THEN SET NEW.nfostatus = -1; END IF; END;
|
||||
CREATE TRIGGER check_update BEFORE UPDATE ON releases FOR EACH ROW BEGIN IF NEW.searchname REGEXP '[a-fA-F0-9]{32}' OR NEW.name REGEXP '[a-fA-F0-9]{32}' THEN SET NEW.ishashed = 1;ELSEIF NEW.name REGEXP '^\[ ?([[:digit:]]{4,6}) ?\]|^REQ\s*([[:digit:]]{4,6})|^([[:digit:]]{4,6})-[[:digit:]]{1}\\[' THEN SET NEW.isrequestid = 1;ELSEIF NEW.releasenfoid = 0 THEN SET NEW.nfostatus = -1; END IF; END;
|
||||
|
||||
|
||||
UPDATE `tmux` set `value` = '32' where `setting` = 'sqlpatch';
|
||||
@@ -0,0 +1,11 @@
|
||||
DROP TRIGGER IF EXISTS check_insert;
|
||||
DROP TRIGGER IF EXISTS check_update;
|
||||
|
||||
CREATE TRIGGER check_insert BEFORE INSERT ON releases FOR EACH ROW BEGIN IF NEW.searchname REGEXP '[a-fA-F0-9]{32}' OR NEW.name REGEXP '[a-fA-F0-9]{32}' THEN SET NEW.ishashed = 1;ELSEIF NEW.name REGEXP '^\\[ ?([[:digit:]]{4,6}) ?\\]|^REQ\s*([[:digit:]]{4,6})|^([[:digit:]]{4,6})-[[:digit:]]{1}\\[' THEN SET NEW.isrequestid = 1;ELSEIF NEW.releasenfoid = 0 THEN SET NEW.nfostatus = -1; END IF; END;
|
||||
CREATE TRIGGER check_update BEFORE UPDATE ON releases FOR EACH ROW BEGIN IF NEW.searchname REGEXP '[a-fA-F0-9]{32}' OR NEW.name REGEXP '[a-fA-F0-9]{32}' THEN SET NEW.ishashed = 1;ELSEIF NEW.name REGEXP '^\\[ ?([[:digit:]]{4,6}) ?\\]|^REQ\s*([[:digit:]]{4,6})|^([[:digit:]]{4,6})-[[:digit:]]{1}\\[' THEN SET NEW.isrequestid = 1;ELSEIF NEW.releasenfoid = 0 THEN SET NEW.nfostatus = -1; END IF; END;
|
||||
|
||||
UPDATE releases set isrequestid = 1
|
||||
WHERE name REGEXP '^\\[ ?([[:digit:]]{4,6}) ?\\]|^REQ\s*([[:digit:]]{4,6})|^([[:digit:]]{4,6})-[[:digit:]]{1}\\['
|
||||
AND isrequestid = 0;
|
||||
|
||||
UPDATE `tmux` set `value` = '33' where `setting` = 'sqlpatch';
|
||||
@@ -0,0 +1,5 @@
|
||||
DELETE FROM `tmux` WHERE `setting` = 'scrape_cz';
|
||||
DELETE FROM `tmux` WHERE `setting` = 'scrape_efnet';
|
||||
INSERT IGNORE INTO `tmux` (setting, value) VALUE ('scrape', '0');
|
||||
|
||||
UPDATE `tmux` SET value = '34' WHERE `setting` = 'sqlpatch';
|
||||
@@ -0,0 +1,16 @@
|
||||
ALTER TABLE `prehash` ADD COLUMN `filename` varchar(255) NOT NULL DEFAULT '';
|
||||
ALTER TABLE `prehash` ADD INDEX `ix_prehash_filename` (`filename`);
|
||||
ALTER TABLE `releasefiles` ADD COLUMN `ishashed` tinyint(1) NOT NULL DEFAULT '0' AFTER `size`;
|
||||
ALTER TABLE `releasefiles` ADD INDEX `ix_releasefiles_ishashed` (`ishashed`);
|
||||
|
||||
DROP TRIGGER IF EXISTS check_rfinsert;
|
||||
DROP TRIGGER IF EXISTS check_rfupdate;
|
||||
|
||||
|
||||
CREATE TRIGGER check_rfinsert BEFORE INSERT ON releasefiles FOR EACH ROW BEGIN IF NEW.name REGEXP '[a-fA-F0-9]{32}' THEN SET NEW.ishashed = 1; END IF; END;
|
||||
CREATE TRIGGER check_rfupdate BEFORE UPDATE ON releasefiles FOR EACH ROW BEGIN IF NEW.name REGEXP '[a-fA-F0-9]{32}' THEN SET NEW.ishashed = 1; END IF; END;
|
||||
|
||||
|
||||
UPDATE `releasefiles` SET ishashed = 1 WHERE name REGEXP '[a-fA-F0-9]{32}';
|
||||
|
||||
UPDATE `tmux` SET value = '35' WHERE `setting` = 'sqlpatch';
|
||||
@@ -0,0 +1,3 @@
|
||||
DELETE FROM `tmux` WHERE `setting` = 'colors';
|
||||
|
||||
UPDATE `tmux` SET value = '36' WHERE `setting` = 'sqlpatch';
|
||||
@@ -0,0 +1,3 @@
|
||||
INSERT IGNORE INTO tmux (setting, value) VALUE ('run_sharing', '0');
|
||||
|
||||
UPDATE `tmux` SET value = '37' WHERE `setting` = 'sqlpatch';
|
||||
@@ -0,0 +1,25 @@
|
||||
DROP TABLE IF EXISTS releasesearch;
|
||||
CREATE TABLE releasesearch (
|
||||
id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
releaseid INT(11) UNSIGNED NOT NULL,
|
||||
guid VARCHAR(50) NOT NULL,
|
||||
name VARCHAR(255) NOT NULL DEFAULT '',
|
||||
searchname VARCHAR(255) NOT NULL DEFAULT '',
|
||||
PRIMARY KEY (id)
|
||||
) ENGINE =MyISAM DEFAULT CHARSET =utf8 COLLATE =utf8_unicode_ci AUTO_INCREMENT =1;
|
||||
|
||||
CREATE FULLTEXT INDEX ix_releasesearch_name_searchname_ft ON releasesearch (name, searchname);
|
||||
CREATE INDEX ix_releasesearch_releaseid ON releasesearch (releaseid);
|
||||
CREATE INDEX ix_releasesearch_guid ON releasesearch (guid);
|
||||
|
||||
ALTER TABLE `releases`
|
||||
ADD `proc_filenames` BIT NOT NULL DEFAULT 0;
|
||||
|
||||
|
||||
CREATE TRIGGER insert_search AFTER INSERT ON releases FOR EACH ROW BEGIN INSERT INTO releasesearch (releaseid, guid, name, searchname) VALUES (NEW.id, NEW.guid, NEW.name, NEW.searchname);END;
|
||||
CREATE TRIGGER update_search AFTER UPDATE ON releases FOR EACH ROW BEGIN IF NEW.guid != OLD.guid THEN UPDATE releasesearch SET guid = NEW.guid WHERE releaseid = OLD.id; END IF; IF NEW.name != OLD.name THEN UPDATE releasesearch SET name = NEW.name WHERE releaseid = OLD.id; END IF; IF NEW.searchname != OLD.searchname THEN UPDATE releasesearch SET searchname = NEW.searchname WHERE releaseid = OLD.id; END IF;END;
|
||||
CREATE TRIGGER delete_search AFTER DELETE ON releases FOR EACH ROW BEGIN DELETE FROM releasesearch WHERE releaseid = OLD.id;END;
|
||||
|
||||
|
||||
UPDATE `tmux` SET value = '38' WHERE `setting` = 'sqlpatch';
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
ALTER TABLE prehash ADD COLUMN searched tinyint(1) NOT NULL DEFAULT 0;
|
||||
ALTER TABLE prehash ADD INDEX ix_prehash_searched (searched);
|
||||
ALTER TABLE releases DROP COLUMN proc_filenames;
|
||||
|
||||
UPDATE `tmux` SET value = '39' WHERE `setting` = 'sqlpatch';
|
||||
@@ -0,0 +1,3 @@
|
||||
INSERT IGNORE INTO tmux (setting, value) VALUE ('lastpretime', '0');
|
||||
|
||||
UPDATE `tmux` SET value = '40' WHERE `setting` = 'sqlpatch';
|
||||
@@ -0,0 +1,45 @@
|
||||
DROP TABLE IF EXISTS predbhash;
|
||||
CREATE TABLE predbhash (
|
||||
pre_id INT(11) UNSIGNED NOT NULL DEFAULT 0,
|
||||
hashes VARCHAR(512) NOT NULL DEFAULT '',
|
||||
PRIMARY KEY (pre_id)
|
||||
)
|
||||
ENGINE =MYISAM
|
||||
ROW_FORMAT = DYNAMIC
|
||||
DEFAULT CHARSET =utf8mb4
|
||||
COLLATE =utf8mb4_unicode_ci;
|
||||
|
||||
INSERT INTO predbhash (pre_id, hashes) (SELECT
|
||||
id,
|
||||
CONCAT_WS(',', MD5(title), MD5(MD5(title)), SHA1(title))
|
||||
FROM prehash);
|
||||
|
||||
CREATE FULLTEXT INDEX ix_predbhash_hashes_ft ON predbhash (hashes);
|
||||
ALTER IGNORE TABLE predbhash ADD UNIQUE INDEX ix_predbhash_hashes (hashes(32));
|
||||
|
||||
DROP TRIGGER IF EXISTS insert_hashes;
|
||||
|
||||
|
||||
CREATE TRIGGER insert_hashes AFTER INSERT ON prehash FOR EACH ROW BEGIN INSERT INTO predbhash (pre_id, hashes)
|
||||
VALUES (NEW.id, CONCAT_WS(',', MD5(NEW.title), MD5(MD5(NEW.title)), SHA1(NEW.title)));
|
||||
END;
|
||||
|
||||
|
||||
|
||||
DROP TRIGGER IF EXISTS update_hashes;
|
||||
|
||||
|
||||
CREATE TRIGGER update_hashes AFTER UPDATE ON prehash FOR EACH ROW BEGIN IF NEW.title != OLD.title
|
||||
THEN UPDATE predbhash
|
||||
SET hashes = CONCAT_WS(',', MD5(NEW.title), MD5(MD5(NEW.title)), SHA1(NEW.title)); END IF;
|
||||
END;
|
||||
|
||||
DROP TRIGGER IF EXISTS delete_hashes;
|
||||
|
||||
|
||||
CREATE TRIGGER delete_hashes AFTER DELETE ON prehash FOR EACH ROW BEGIN DELETE FROM predbhash
|
||||
WHERE pre_id = OLD.id;
|
||||
END;
|
||||
|
||||
|
||||
UPDATE `tmux` SET value = '41' WHERE `setting` = 'sqlpatch';
|
||||
@@ -0,0 +1,4 @@
|
||||
DROP TRIGGER IF EXISTS update_hashes;
|
||||
|
||||
CREATE TRIGGER update_hashes AFTER UPDATE ON prehash FOR EACH ROW BEGIN IF NEW.title != OLD.title THEN UPDATE predbhash SET hashes = CONCAT_WS(',', MD5(NEW.title), MD5(MD5(NEW.title)), SHA1(NEW.title)) WHERE pre_id = OLD.id;END IF;END;
|
||||
UPDATE `tmux` SET value = '42' WHERE `setting` = 'sqlpatch';
|
||||
@@ -0,0 +1,3 @@
|
||||
ALTER TABLE prehash DROP md5;
|
||||
ALTER TABLE prehash DROP sha1;
|
||||
UPDATE `tmux` SET value = '43' WHERE `setting` = 'sqlpatch';
|
||||
@@ -0,0 +1,5 @@
|
||||
ALTER TABLE releasecomment MODIFY text varchar(255);
|
||||
DROP INDEX ix_releasecomment_text_releaseID ON releasecomment;
|
||||
CREATE UNIQUE INDEX ix_releasecomment_text_releaseID ON releasecomment (text, releaseid);
|
||||
UPDATE `tmux` SET value = '44' WHERE `setting` = 'sqlpatch';
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
ALTER TABLE prehash DROP INDEX ix_prehash_title;
|
||||
ALTER IGNORE TABLE prehash ADD UNIQUE INDEX ix_prehash_title (title);
|
||||
UPDATE `tmux` SET value = '45' WHERE `setting` = 'sqlpatch';
|
||||
@@ -0,0 +1,7 @@
|
||||
ALTER TABLE releasecomment ADD COLUMN text_hash VARCHAR(32) NOT NULL DEFAULT '';
|
||||
DROP TRIGGER IF EXISTS insert_MD5;
|
||||
CREATE TRIGGER insert_MD5 BEFORE INSERT ON releasecomment FOR EACH ROW SET NEW.text_hash = MD5(NEW.text);
|
||||
UPDATE releasecomment
|
||||
SET text_hash = MD5(text);
|
||||
ALTER IGNORE TABLE releasecomment ADD UNIQUE INDEX ix_releasecomment_hash_releaseID (text_hash, releaseid);
|
||||
UPDATE `tmux` SET `value` = '46' WHERE `setting` = 'sqlpatch';
|
||||
@@ -0,0 +1,5 @@
|
||||
ALTER TABLE users ADD COLUMN queuetype TINYINT(1) NOT NULL DEFAULT 1;
|
||||
/* Add a column to pick between Sab and NZBGet. */
|
||||
|
||||
|
||||
UPDATE `tmux` SET `value` = '47' WHERE `setting` = 'sqlpatch';
|
||||
@@ -0,0 +1,3 @@
|
||||
INSERT INTO `site` (`setting`, `value`) VALUES ('categorizeforeign', '1');
|
||||
INSERT INTO `site` (`setting`, `value`) VALUES ('catwebdl', '0');
|
||||
UPDATE `tmux` SET `value` = '49' WHERE `setting` = 'sqlpatch';
|
||||
@@ -0,0 +1,93 @@
|
||||
DROP TABLE IF EXISTS `category`;
|
||||
CREATE TABLE category
|
||||
(
|
||||
`id` INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
|
||||
`title` VARCHAR(255) NOT NULL,
|
||||
`parentid` INT NULL,
|
||||
`status` INT NOT NULL DEFAULT '1',
|
||||
`minsizetoformrelease` BIGINT UNSIGNED NOT NULL DEFAULT '0',
|
||||
`maxsizetoformrelease` BIGINT UNSIGNED NOT NULL DEFAULT '0',
|
||||
`description` VARCHAR(255) NULL,
|
||||
`disablepreview` TINYINT(1) NOT NULL DEFAULT '0'
|
||||
)
|
||||
ENGINE =INNODB
|
||||
DEFAULT CHARACTER SET utf8
|
||||
COLLATE utf8_unicode_ci
|
||||
AUTO_INCREMENT =100000;
|
||||
|
||||
INSERT INTO category (id, title) VALUES (1000, 'Console');
|
||||
INSERT INTO category (id, title) VALUES (2000, 'Movies');
|
||||
INSERT INTO category (id, title) VALUES (3000, 'Audio');
|
||||
INSERT INTO category (id, title) VALUES (4000, 'PC');
|
||||
INSERT INTO category (id, title) VALUES (5000, 'TV');
|
||||
INSERT INTO category (id, title) VALUES (6000, 'XXX');
|
||||
INSERT INTO category (id, title) VALUES (7000, 'Books');
|
||||
INSERT INTO category (id, title) VALUES (8000, 'Other');
|
||||
|
||||
INSERT INTO category (id, title, parentid) VALUES (1010, 'NDS', 1000);
|
||||
INSERT INTO category (id, title, parentid) VALUES (1020, 'PSP', 1000);
|
||||
INSERT INTO category (id, title, parentid) VALUES (1030, 'Wii', 1000);
|
||||
INSERT INTO category (id, title, parentid) VALUES (1040, 'Xbox', 1000);
|
||||
INSERT INTO category (id, title, parentid) VALUES (1050, 'Xbox 360', 1000);
|
||||
INSERT INTO category (id, title, parentid) VALUES (1060, 'WiiWare/VC', 1000);
|
||||
INSERT INTO category (id, title, parentid) VALUES (1070, 'XBOX 360 DLC', 1000);
|
||||
INSERT INTO category (id, title, parentid) VALUES (1080, 'PS3', 1000);
|
||||
INSERT INTO category (id, title, parentid) VALUES (1090, 'Other', 1000);
|
||||
INSERT INTO category (id, title, parentid) VALUES (1110, '3DS', 1000);
|
||||
INSERT INTO category (id, title, parentid) VALUES (1120, 'PS Vita', 1000);
|
||||
INSERT INTO category (id, title, parentid) VALUES (1130, 'WiiU', 1000);
|
||||
INSERT INTO category (id, title, parentid) VALUES (1140, 'Xbox One', 1000);
|
||||
INSERT INTO category (id, title, parentid) VALUES (1180, 'PS4', 1000);
|
||||
|
||||
INSERT INTO category (id, title, parentid) VALUES (2010, 'Foreign', 2000);
|
||||
INSERT INTO category (id, title, parentid) VALUES (2020, 'Other', 2000);
|
||||
INSERT INTO category (id, title, parentid) VALUES (2030, 'SD', 2000);
|
||||
INSERT INTO category (id, title, parentid) VALUES (2040, 'HD', 2000);
|
||||
INSERT INTO category (id, title, parentid) VALUES (2050, '3D', 2000);
|
||||
INSERT INTO category (id, title, parentid) VALUES (2060, 'BluRay', 2000);
|
||||
INSERT INTO category (id, title, parentid) VALUES (2070, 'DVD', 2000);
|
||||
INSERT INTO category (id, title, parentid) VALUES (2080, 'WEB-DL', 2000);
|
||||
|
||||
INSERT INTO category (id, title, parentid) VALUES (3010, 'MP3', 3000);
|
||||
INSERT INTO category (id, title, parentid) VALUES (3020, 'Video', 3000);
|
||||
INSERT INTO category (id, title, parentid) VALUES (3030, 'Audiobook', 3000);
|
||||
INSERT INTO category (id, title, parentid) VALUES (3040, 'Lossless', 3000);
|
||||
INSERT INTO category (id, title, parentid) VALUES (3050, 'Other', 3000);
|
||||
INSERT INTO category (id, title, parentid) VALUES (3060, 'Foreign', 3000);
|
||||
|
||||
INSERT INTO category (id, title, parentid) VALUES (4010, '0day', 4000);
|
||||
INSERT INTO category (id, title, parentid) VALUES (4020, 'ISO', 4000);
|
||||
INSERT INTO category (id, title, parentid) VALUES (4030, 'Mac', 4000);
|
||||
INSERT INTO category (id, title, parentid) VALUES (4040, 'Mobile-Other', 4000);
|
||||
INSERT INTO category (id, title, parentid) VALUES (4050, 'Games', 4000);
|
||||
INSERT INTO category (id, title, parentid) VALUES (4060, 'Mobile-iOS', 4000);
|
||||
INSERT INTO category (id, title, parentid) VALUES (4070, 'Mobile-Android', 4000);
|
||||
|
||||
INSERT INTO category (id, title, parentid) VALUES (5010, 'WEB-DL', 5000);
|
||||
INSERT INTO category (id, title, parentid) VALUES (5020, 'Foreign', 5000);
|
||||
INSERT INTO category (id, title, parentid) VALUES (5030, 'SD', 5000);
|
||||
INSERT INTO category (id, title, parentid) VALUES (5040, 'HD', 5000);
|
||||
INSERT INTO category (id, title, parentid) VALUES (5050, 'Other', 5000);
|
||||
INSERT INTO category (id, title, parentid) VALUES (5060, 'Sport', 5000);
|
||||
INSERT INTO category (id, title, parentid) VALUES (5070, 'Anime', 5000);
|
||||
INSERT INTO category (id, title, parentid) VALUES (5080, 'Documentary', 5000);
|
||||
|
||||
INSERT INTO category (id, title, parentid) VALUES (6010, 'DVD', 6000);
|
||||
INSERT INTO category (id, title, parentid) VALUES (6020, 'WMV', 6000);
|
||||
INSERT INTO category (id, title, parentid) VALUES (6030, 'XviD', 6000);
|
||||
INSERT INTO category (id, title, parentid) VALUES (6040, 'x264', 6000);
|
||||
INSERT INTO category (id, title, parentid) VALUES (6050, 'Pack', 6000);
|
||||
INSERT INTO category (id, title, parentid) VALUES (6060, 'ImgSet', 6000);
|
||||
INSERT INTO category (id, title, parentid) VALUES (6070, 'Other', 6000);
|
||||
|
||||
INSERT INTO category (id, title, parentid) VALUES (7010, 'Mags', 7000);
|
||||
INSERT INTO category (id, title, parentid) VALUES (7020, 'Ebook', 7000);
|
||||
INSERT INTO category (id, title, parentid) VALUES (7030, 'Comics', 7000);
|
||||
INSERT INTO category (id, title, parentid) VALUES (7040, 'Technical', 7000);
|
||||
INSERT INTO category (id, title, parentid) VALUES (7050, 'Other', 7000);
|
||||
INSERT INTO category (id, title, parentid) VALUES (7060, 'Foreign', 7000);
|
||||
|
||||
INSERT INTO category (id, title, parentid) VALUES (8010, 'Misc', 8000);
|
||||
INSERT INTO category (id, title, parentid) VALUES (8020, 'Hashed', 8000);
|
||||
|
||||
UPDATE `tmux` SET `value` = '50' WHERE `setting` = 'sqlpatch';
|
||||
@@ -0,0 +1,2 @@
|
||||
INSERT IGNORE INTO tmux (setting, value) VALUE ('minsizetopostprocess', '1');
|
||||
UPDATE `tmux` SET `value` = '51' WHERE `setting` = 'sqlpatch';
|
||||
@@ -0,0 +1,24 @@
|
||||
DROP TABLE IF EXISTS gamesinfo;
|
||||
CREATE TABLE gamesinfo (
|
||||
id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
title VARCHAR(255) NOT NULL,
|
||||
asin VARCHAR(128) DEFAULT NULL,
|
||||
url VARCHAR(1000) DEFAULT NULL,
|
||||
platform VARCHAR(255) DEFAULT NULL,
|
||||
publisher VARCHAR(255) DEFAULT NULL,
|
||||
genre_id INT(10) NULL DEFAULT NULL,
|
||||
esrb VARCHAR(255) NULL DEFAULT NULL,
|
||||
releasedate DATETIME DEFAULT NULL,
|
||||
review VARCHAR(3000) DEFAULT NULL,
|
||||
cover TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',
|
||||
createddate DATETIME NOT NULL,
|
||||
updateddate DATETIME NOT NULL,
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE INDEX ix_gamesinfo_asin (asin)
|
||||
)
|
||||
ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8
|
||||
COLLATE = utf8_unicode_ci
|
||||
AUTO_INCREMENT = 1;
|
||||
|
||||
UPDATE `tmux` SET `value` = '52' WHERE `setting` = 'sqlpatch';
|
||||
@@ -0,0 +1,2 @@
|
||||
INSERT INTO `site` (`setting`, `value`) VALUES ('giantbombkey', '');
|
||||
UPDATE `tmux` SET `value` = '53' WHERE `setting` = 'sqlpatch';
|
||||
@@ -0,0 +1,3 @@
|
||||
ALTER TABLE releases ADD COLUMN gamesinfo_id INT AFTER consoleinfoid;
|
||||
CREATE INDEX ix_releases_gamesinfo_id ON releases (gamesinfo_id);
|
||||
UPDATE `tmux` SET `value` = '54' WHERE `setting` = 'sqlpatch';
|
||||
@@ -0,0 +1,2 @@
|
||||
ALTER TABLE users ADD COLUMN gameview INT AFTER consoleview;
|
||||
UPDATE `tmux` SET `value` = '55' WHERE `setting` = 'sqlpatch';
|
||||
@@ -0,0 +1,2 @@
|
||||
INSERT INTO menu (href, title, tooltip, role, ordinal ) VALUES ('newposterwall', 'New Releases', "Newest Releases Poster Wall", 1, 11);
|
||||
UPDATE `tmux` SET `value` = '56' WHERE `setting` = 'sqlpatch';
|
||||
@@ -0,0 +1,2 @@
|
||||
ALTER TABLE releases ADD COLUMN proc_sorter TINYINT(1) NOT NULL DEFAULT '0';
|
||||
UPDATE `tmux` SET `value` = '57' WHERE `setting` = 'sqlpatch';
|
||||
@@ -0,0 +1,6 @@
|
||||
DELETE FROM `tmux` WHERE `setting` = 'dehash';
|
||||
DELETE FROM `tmux` WHERE `setting` = 'dehash_timer';
|
||||
DELETE FROM `tmux` WHERE `setting` = 'lookup_reqids';
|
||||
DELETE FROM `tmux` WHERE `setting` = 'lookup_reqids_timer';
|
||||
DELETE FROM `tmux` WHERE `setting` = 'request_url';
|
||||
UPDATE `tmux` set `value` = '58' where `setting` = 'sqlpatch';
|
||||
@@ -0,0 +1,2 @@
|
||||
ALTER TABLE users ADD COLUMN xxxview INT AFTER gameview;
|
||||
UPDATE `tmux` set `value` = '59' where `setting` = 'sqlpatch';
|
||||
@@ -0,0 +1,27 @@
|
||||
DROP TABLE IF EXISTS xxxinfo;
|
||||
CREATE TABLE xxxinfo (
|
||||
id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
title VARCHAR(255) NOT NULL,
|
||||
tagline VARCHAR(1024) NOT NULL,
|
||||
plot BLOB NULL DEFAULT NULL,
|
||||
genre VARCHAR(64) NOT NULL,
|
||||
director VARCHAR(64) DEFAULT NULL,
|
||||
actors VARCHAR(2000) NOT NULL,
|
||||
extras TEXT DEFAULT NULL,
|
||||
productinfo TEXT DEFAULT NULL,
|
||||
trailers TEXT DEFAULT NULL,
|
||||
directurl VARCHAR(2000) NOT NULL,
|
||||
classused VARCHAR(3) NOT NULL,
|
||||
cover TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',
|
||||
backdrop TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',
|
||||
createddate DATETIME NOT NULL,
|
||||
updateddate DATETIME NOT NULL,
|
||||
PRIMARY KEY (id),
|
||||
INDEX ix_xxxinfo_title (title)
|
||||
)
|
||||
ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8
|
||||
COLLATE = utf8_unicode_ci
|
||||
AUTO_INCREMENT = 1;
|
||||
|
||||
UPDATE `tmux` SET `value` = '60' WHERE `setting` = 'sqlpatch';
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user