mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-09-02 19:28:55 +00:00
Expand support: Add failed download tracking for X-DNZB-Failure headers.
This commit is contained in:
@@ -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);
|
||||
@@ -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 ."]: ",
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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 . '');
|
||||
|
||||
Reference in New Issue
Block a user