Expand support: Add failed download tracking for X-DNZB-Failure headers.

This commit is contained in:
Darko
2015-03-27 13:22:28 +01:00
parent 700aaf2768
commit 933754968c
5 changed files with 35 additions and 11 deletions
+15
View File
@@ -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);
+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.6r0138';
$tversion = '0.6r0144';
$buffer .= sprintf($this->tmpMasks[2],
"Monitor $state v$tversion @ $this->_tvers [" . $this->_vers ."]: ",
+16 -4
View File
@@ -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;
}
+2 -5
View File
@@ -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=<usernumber>&r=APIKEY
$url = $page->serverurl . 'getnzb/' . $alt['guid'] . '.nzb' . '&i=' . $_GET['userid'] . '&r=' . $_GET['rsstoken'];
header('Location: ' . $url . '');
+1 -1
View File
@@ -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"));
}