Updated handling of X-DNZB-Failure headers, removed double checks, it is sabnzbd problem not mine. Removed status column and renamed failed_downloads table to dnzb_failures.

This commit is contained in:
Darko
2015-03-31 14:52:10 +02:00
parent 970f2873a6
commit 6c0a3441d5
7 changed files with 38 additions and 38 deletions
+4 -7
View File
@@ -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';
+7
View File
@@ -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';
+1 -1
View File
@@ -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 ."]: ",
+10 -11
View File
@@ -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;
}
+14 -14
View File
@@ -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=<usernumber>&r=APIKEY
$url = $page->serverurl . 'getnzb/' . $alt['guid'] . '.nzb' . '&i=' . $userid . '&r=' . $rsstoken;
header('Location: ' . $url . '');
}
$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 . '');
}
+1 -4
View File
@@ -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) {
+1 -1
View File
@@ -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"));
}