diff --git a/lib/DB/patches/0125~faileddownloads.sql b/lib/DB/patches/0125~faileddownloads.sql index 67189fb1a..c4cb54623 100644 --- a/lib/DB/patches/0125~faileddownloads.sql +++ b/lib/DB/patches/0125~faileddownloads.sql @@ -1,16 +1,13 @@ -DROP TABLE IF EXISTS failed_downloads; -CREATE TABLE failed_downloads ( +DROP TABLE IF EXISTS dnzb_failures; +CREATE TABLE dnzb_failures ( 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, + guid VARCHAR(50) NOT NULL, 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); + CREATE UNIQUE INDEX ux_dnzb_failures ON dnzb_failures (userid, guid); UPDATE `tmux` set `value` = '125' where `setting` = 'sqlpatch'; \ No newline at end of file diff --git a/lib/DB/patches/0126~dnzb_failures.sql b/lib/DB/patches/0126~dnzb_failures.sql new file mode 100644 index 000000000..f544cbd94 --- /dev/null +++ b/lib/DB/patches/0126~dnzb_failures.sql @@ -0,0 +1,7 @@ +RENAME TABLE failed_downloads TO dnzb_failures; +ALTER TABLE dnzb_failures DROP COLUMN status; +DROP INDEX ux_index_failed ON dnzb_failures; +DROP INDEX ix_failed_downloads_guid ON dnzb_failures; +DROP INDEX ix_failed_downloads_userid ON dnzb_failures; +CREATE UNIQUE INDEX ux_dnzb_failures ON dnzb_failures (userid, guid); + UPDATE `tmux` set `value` = '126' where `setting` = 'sqlpatch'; \ 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 911e687c9..486526ad7 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.6r0154'; + $tversion = '0.6r0160'; $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 6ea38819f..c819b403a 100644 --- a/lib/copy_this/www/lib/releases.php +++ b/lib/copy_this/www/lib/releases.php @@ -1657,27 +1657,26 @@ class Releases * @param string $guid * @param string $searchname * @param string $userid - * @param bool $failed * @return string - * */ - - public function getAlternate($guid, $searchname, $userid, $failed = true) + public function getAlternate($guid, $searchname, $userid) { //status values // 0/false = successfully downloaded // 1/true = failed download - - - $this->pdo->queryInsert(sprintf("INSERT INTO failed_downloads (guid, userid, status) VALUES (%s, %d, %d) ON DUPLICATE KEY UPDATE status = %d", - $this->pdo->escapeString($guid), + $this->pdo->queryInsert(sprintf("INSERT IGNORE INTO dnzb_failures (userid, guid) VALUES (%d, %s)", $userid, - ($failed === true ? true : false), - ($failed === true ? true : false) + $this->pdo->escapeString($guid) ) ); - $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 = %d)', $this->pdo->likeString($searchname), $userid)); + $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 = %d)', + $this->pdo->likeString($searchname), + $userid + ) + ); return $alternate; } diff --git a/lib/copy_this/www/pages/failed.php b/lib/copy_this/www/pages/failed.php index ad0c492fd..44e47c059 100644 --- a/lib/copy_this/www/pages/failed.php +++ b/lib/copy_this/www/pages/failed.php @@ -7,19 +7,19 @@ $releases = new Releases(['Settings' => $page->settings]); $users = new Users(); $page = new Page(); - if (isset($_GET['userid']) && is_numeric($_GET['userid']) && isset($_GET['rsstoken']) && isset($_GET['guid'])) { - $rel = $releases->getByGuid($_GET["guid"]); - $userid = $_GET['userid']; - $rsstoken = $_GET['rsstoken']; +if (isset($_GET['userid']) && is_numeric($_GET['userid']) && isset($_GET['rsstoken']) && isset($_GET['guid'])) { + $rel = $releases->getByGuid($_GET["guid"]); + $userid = $_GET['userid']; + $rsstoken = $_GET['rsstoken']; - if (!$rel) - $page->show404(); + if (!$rel) { + $page->show404(); + } - $alt = $releases->getAlternate($rel['guid'], $rel['searchname'], $userid, true); - if (!$alt) { - $page->show404(); - } - //http://blah.net/getnzb/GUID.nzb&i=&r=APIKEY - $url = $page->serverurl . 'getnzb/' . $alt['guid'] . '.nzb' . '&i=' . $userid . '&r=' . $rsstoken; - header('Location: ' . $url . ''); - } \ No newline at end of file + $alt = $releases->getAlternate($rel['guid'], $rel['searchname'], $userid); + if (!$alt) { + $page->show404(); + } + $url = $page->serverurl . 'getnzb/' . $alt['guid'] . '.nzb' . '&i=' . $userid . '&r=' . $rsstoken; + header('Location: ' . $url . ''); +} \ No newline at end of file diff --git a/lib/copy_this/www/pages/getnzb.php b/lib/copy_this/www/pages/getnzb.php index 35e4653da..96e896328 100644 --- a/lib/copy_this/www/pages/getnzb.php +++ b/lib/copy_this/www/pages/getnzb.php @@ -105,7 +105,6 @@ if (isset($_GET["id"])) { header("X-DNZB-RText: Release not found!"); $page->show404(); } - $altdata = $rel->getAlternate($_GET['id'], $reldata['searchname'], $uid, false); // Start reading output buffer. ob_start(); @@ -119,9 +118,7 @@ if (isset($_GET["id"])) { header("Content-Type: application/x-nzb"); header("Expires: " . date('r', time() + 31536000)); // Set X-DNZB header data. - if (!empty($altdata['guid']) && $altdata['guid'] != NULL) { - header("X-DNZB-Failure: " . $page->serverurl . 'failed/' . '?guid=' . $_GET['id'] . '&userid=' . $uid . '&rsstoken=' . $rsstoken); - } + header("X-DNZB-Failure: " . $page->serverurl . 'failed/' . '?guid=' . $_GET['id'] . '&userid=' . $uid . '&rsstoken=' . $rsstoken); header("X-DNZB-Category: " . $reldata["category_name"]); header("X-DNZB-Details: " . $page->serverurl . 'details/' . $_GET["id"]); if (!empty($reldata['imdbid']) && $reldata['imdbid'] > 0) { diff --git a/run.php b/run.php index 2caff8fc0..dfbd06253 100644 --- a/run.php +++ b/run.php @@ -40,7 +40,7 @@ if (count($nntpkill) !== 0) { } // Check database patch version -if ($patch < 125) { +if ($patch < 126) { 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")); }