diff --git a/lib/DB/patches/0125~faileddownloads.sql b/lib/DB/patches/0125~faileddownloads.sql new file mode 100644 index 000000000..7057e69d8 --- /dev/null +++ b/lib/DB/patches/0125~faileddownloads.sql @@ -0,0 +1,15 @@ +DROP TABLE IF EXISTS failed_downloads; +CREATE TABLE failed_downloads ( + id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, + guid VARCHAR(50) NOT NULL, + userid INT(11) UNSIGNED NOT NULL, + status TINYINT NOT NULL DEFAULT 0, + PRIMARY KEY (id) +) + ENGINE =MYISAM + DEFAULT CHARSET =utf8 + COLLATE =utf8_unicode_ci + AUTO_INCREMENT =1; + CREATE INDEX ix_failed_downloads_guid ON failed_downloads (guid); + CREATE INDEX ix_failed_downloads_userid ON failed_downloads (userid); + CREATE UNIQUE INDEX ux_index_failed ON failed_downloads (guid, userid); \ No newline at end of file diff --git a/lib/copy_this/www/lib/TmuxOutput.php b/lib/copy_this/www/lib/TmuxOutput.php index 48ad94656..ee66b14ba 100644 --- a/lib/copy_this/www/lib/TmuxOutput.php +++ b/lib/copy_this/www/lib/TmuxOutput.php @@ -117,7 +117,7 @@ class TmuxOutput extends Tmux $buffer = ''; $state = ($this->runVar['settings']['is_running'] == 1) ? 'Running' : 'Disabled'; //$version = $this->_tvers . 'r' . $this->_vers; - $tversion = '0.6r0138'; + $tversion = '0.6r0144'; $buffer .= sprintf($this->tmpMasks[2], "Monitor $state v$tversion @ $this->_tvers [" . $this->_vers ."]: ", diff --git a/lib/copy_this/www/lib/releases.php b/lib/copy_this/www/lib/releases.php index 4621a135a..d1ce69676 100644 --- a/lib/copy_this/www/lib/releases.php +++ b/lib/copy_this/www/lib/releases.php @@ -1654,14 +1654,26 @@ class Releases /** * Retrieve alternate release with same or similar searchname * - * @param $searchname - * @param $guid + * @param string $guid + * @param string $searchname + * @param string $userid + * * @return string */ - public function getAlternate($guid, $searchname) + public function getAlternate($guid, $searchname, $userid) { - $alternate = $this->pdo->queryOneRow(sprintf('SELECT * FROM releases where guid != %s AND searchname %s', $this->pdo->escapeString($guid), $this->pdo->likeString($searchname))); + //status values + // 0 = default value + // 1 = failed + // 2 = success (not used yet) + + $this->pdo->queryInsert(sprintf("INSERT INTO failed_downloads (guid, userid, status) VALUES (%s, %s, 1) ON DUPLICATE KEY UPDATE guid = %s, userid = %s, status = %d", + $this->pdo->escapeString($guid), $this->pdo->escapeString($userid), + $this->pdo->escapeString($guid), $this->pdo->escapeString($userid), '1' + ) + ); + $alternate = $this->pdo->queryOneRow(sprintf('SELECT * FROM releases r WHERE r.searchname %s AND r.guid NOT IN (SELECT guid FROM failed_downloads WHERE userid = %s)', $this->pdo->likeString($searchname), $this->pdo->escapeString($userid))); return $alternate; } diff --git a/lib/copy_this/www/pages/failed.php b/lib/copy_this/www/pages/failed.php index dd3d31422..9270b0f00 100644 --- a/lib/copy_this/www/pages/failed.php +++ b/lib/copy_this/www/pages/failed.php @@ -7,19 +7,16 @@ $releases = new Releases(['Settings' => $page->settings]); $users = new Users(); $page = new Page(); - if (isset($_GET["userid"])) { + if (isset($_GET["userid"]) && isset($_GET['rsstoken']) && isset($_GET['guid'])) { $rel = $releases->getByGuid($_GET["guid"]); if (!$rel) $page->show404(); - $alt = $releases->getAlternate($rel['guid'], $rel['searchname']); + $alt = $releases->getAlternate($rel['guid'], $rel['searchname'], $_GET['userid']); if (!$alt) { $page->show404(); } - $userid = $users->getById($_GET["userid"]); - $uid = $userid['id']; - $rsstoken = $userid['rsstoken']; //http://blah.net/getnzb/GUID.nzb&i=&r=APIKEY $url = $page->serverurl . 'getnzb/' . $alt['guid'] . '.nzb' . '&i=' . $_GET['userid'] . '&r=' . $_GET['rsstoken']; header('Location: ' . $url . ''); diff --git a/run.php b/run.php index d859e3efd..2caff8fc0 100644 --- a/run.php +++ b/run.php @@ -40,7 +40,7 @@ if (count($nntpkill) !== 0) { } // Check database patch version -if ($patch < 124) { +if ($patch < 125) { exit($c->error("\nYour database is not up to date. Please update.\nphp /var/www/newznab/misc/update_scripts/nix_scripts/tmux/lib/DB/patchDB.php\n")); }