<?php require_once './config.php'; $page = new AdminPage(); $tvrage = new TvRage(['Settings' => $page->settings]); $page->title = "TV Rage List"; $tname = ""; if (isset($_REQUEST['ragename']) && !empty($_REQUEST['ragename'])) { $tname = $_REQUEST['ragename']; } $ragecount = $tvrage->getCount($tname); $offset = isset($_REQUEST["offset"]) ? $_REQUEST["offset"] : 0; $tsearch = $tname != "" ? 'ragename=' . $tname . '&' : ''; $page->smarty->assign('pagertotalitems', $ragecount); $page->smarty->assign('pageroffset', $offset); $page->smarty->assign('pageritemsperpage', ITEMS_PER_PAGE); $page->smarty->assign('pagerquerybase', WWW_TOP . "/rage-list.php?" . $tsearch . "&offset="); $pager = $page->smarty->fetch("pager.tpl"); $page->smarty->assign('pager', $pager); $page->smarty->assign('ragename', $tname); $tvragelist = $tvrage->getRange($offset, ITEMS_PER_PAGE, $tname); $page->smarty->assign('tvragelist', $tvragelist); $page->content = $page->smarty->fetch('rage-list.tpl'); $page->render();
<?php require_once './config.php'; $page = new AdminPage(); $tvRage = new TvRage(['Settings' => $page->settings]); $rage = ['id' => '', 'description' => '', 'releasetitle' => '', 'genre' => '', 'rageid' => '', 'country' => '', 'imgdata' => '']; switch (isset($_REQUEST['action']) ? $_REQUEST['action'] : 'view') { case 'submit': if ($_POST["id"] == '') { $tvRage->add($_POST["rageid"], $_POST["releasetitle"], $_POST["description"], $_POST["genre"], $_POST['country'], getImage()); } else { $tvRage->update($_POST["id"], $_POST["rageid"], $_POST["releasetitle"], $_POST["description"], $_POST["genre"], $_POST['country'], getImage()); } if (isset($_POST['from']) && !empty($_POST['from'])) { header("Location:" . $_POST['from']); exit; } header("Location:" . WWW_TOP . "/rage-list.php"); break; case 'view': default: if (isset($_GET["id"])) { $page->title = "Tv Rage Edit"; $rage = $tvRage->getByID($_GET["id"]); } break; } $page->smarty->assign('rage', $rage); $page->title = "Add/Edit TV Rage Show Data"; $page->content = $page->smarty->fetch('rage-edit.tpl'); $page->render();
<?php // // page is accessible only to logged in users. // if (!$page->users->isLoggedIn()) { $page->show403(); } if (!isset($_GET["type"]) || !isset($_GET["id"]) || !ctype_digit($_GET["id"])) { $page->show404(); } // // user requested a tvrage image. // if ($_GET["type"] == "tvrage") { $rage = new TvRage(); $r = $rage->getByID($_GET["id"]); if (!$r) { $page->show404(); } header("Content-type: image/jpeg"); print $r["imgdata"]; die; } else { $page->show404(); }
<?php if (!$page->users->isLoggedIn()) { $page->show403(); } if (!isset($_REQUEST["id"])) { $page->show404(); } $r = new Releases(['Settings' => $page->settings]); $rel = $r->getByGuid($_REQUEST["id"]); if (!$rel) { print "No tv info"; } else { //print "<h3 class=\"tooltiphead\">episode info...</h3>\n"; print "<ul>\n"; if (isset($rel['tvtitle'])) { print "<li>" . htmlentities($rel["tvtitle"], ENT_QUOTES) . "</li>\n"; } print "<li>Aired on " . date("F j, Y", strtotime($rel["tvairdate"])) . "</li>\n"; print "</ul>"; if ($rel["rageid"] > 0) { $t = new TvRage(['Settings' => $page->settings]); $rage = $t->getByRageID($rel["rageid"]); if (count($rage) > 0) { if ($rage[0]["imgdata"] != "") { print "<img class=\"shadow\" src=\"" . WWW_TOP . "/getimage?type=tvrage&id=" . $rage[0]["id"] . "\" width=\"180\"/>"; } } } }
<?php require_once './config.php'; $page = new AdminPage(); $tvrage = new TvRage(['Settings' => $page->settings]); $id = 0; // Set the current action. $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'view'; switch ($action) { case 'submit': if ($_POST["id"] == "") { $imgbytes = ""; if ($_FILES['imagedata']['size'] > 0) { $fileName = $_FILES['imagedata']['name']; $tmpName = $_FILES['imagedata']['tmp_name']; $fileSize = $_FILES['imagedata']['size']; $fileType = $_FILES['imagedata']['type']; // Check the uploaded file is actually an image. $file_info = getimagesize($tmpName); if (!empty($file_info)) { $fp = fopen($tmpName, 'r'); $imgbytes = fread($fp, filesize($tmpName)); fclose($fp); } } $tvrage->add($_POST["rageid"], $_POST["releasetitle"], $_POST["description"], $_POST["genre"], $_POST['country'], $imgbytes); } else { $imgbytes = ""; if ($_FILES['imagedata']['size'] > 0) { $fileName = $_FILES['imagedata']['name']; $tmpName = $_FILES['imagedata']['tmp_name'];
/** * Attempt to find NFO files inside the NZB's of releases. * * @param object $nntp Instance of class NNTP. * @param string $groupID (optional) Group id. * @param string $guidChar (optional) First character of the release GUID (used for multi-processing). * @param int $processImdb (optional) Attempt to find IMDB id's in the NZB? * @param int $processTvrage (optional) Attempt to find TvRage id's in the NZB? * * @return int How many NFO's were processed? * * @access public */ public function processNfoFiles($nntp, $groupID = '', $guidChar = '', $processImdb = 1, $processTvrage = 1) { $ret = 0; $guidCharQuery = $guidChar === '' ? '' : 'AND r.guid ' . $this->pdo->likeString($guidChar, false, true); $groupIDQuery = $groupID === '' ? '' : 'AND r.groupid = ' . $groupID; $optionsQuery = self::NfoQueryString($this->pdo); $res = $this->pdo->query(sprintf(' SELECT r.id, r.guid, r.groupid, r.name FROM releases r WHERE 1=1 %s %s %s ORDER BY r.nfostatus ASC, r.postdate DESC LIMIT %d', $optionsQuery, $guidCharQuery, $groupIDQuery, $this->nzbs)); $nfoCount = count($res); if ($nfoCount > 0) { $this->pdo->log->doEcho($this->pdo->log->primary(PHP_EOL . ($guidChar === '' ? '' : '[' . $guidChar . '] ') . ($groupID === '' ? '' : '[' . $groupID . '] ') . 'Processing ' . $nfoCount . ' NFO(s), starting at ' . $this->nzbs . ' * = hidden NFO, + = NFO, - = no NFO, f = download failed.')); if ($this->echo) { // Get count of releases per nfo status $nfoStats = $this->pdo->queryDirect(sprintf(' SELECT r.nfostatus AS status, COUNT(*) AS count FROM releases r WHERE 1=1 %s %s %s GROUP BY r.nfostatus ORDER BY r.nfostatus ASC', $optionsQuery, $guidCharQuery, $groupIDQuery)); if ($nfoStats instanceof Traversable) { $outString = PHP_EOL . 'Available to process'; foreach ($nfoStats as $row) { $outString .= ', ' . $row['status'] . ' = ' . number_format($row['count']); } $this->pdo->log->doEcho($this->pdo->log->header($outString . '.')); } } $groups = new Groups(['Settings' => $this->pdo]); $nzbContents = new NZBContents(['Echo' => $this->echo, 'NNTP' => $nntp, 'Nfo' => $this, 'Settings' => $this->pdo, 'PostProcess' => new PostProcess(['Echo' => $this->echo, 'Nfo' => $this, 'Settings' => $this->pdo])]); $movie = new Movie(['Echo' => $this->echo, 'Settings' => $this->pdo]); $tvRage = new TvRage(['Echo' => $this->echo, 'Settings' => $this->pdo]); foreach ($res as $arr) { $fetchedBinary = $nzbContents->getNFOfromNZB($arr['guid'], $arr['id'], $arr['groupid'], $groups->getByNameByID($arr['groupid'])); if ($fetchedBinary !== false) { // Insert nfo into database. $cp = 'COMPRESS(%s)'; $nc = $this->pdo->escapeString($fetchedBinary); $ckreleaseid = $this->pdo->queryOneRow(sprintf('SELECT id FROM releasenfo WHERE releaseid = %d', $arr['id'])); if (!isset($ckreleaseid['id'])) { $this->pdo->queryInsert(sprintf('INSERT INTO releasenfo (nfo, releaseid) VALUES (' . $cp . ', %d)', $nc, $arr['id'])); } $this->pdo->queryExec(sprintf('UPDATE releases SET nfostatus = %d WHERE id = %d', self::NFO_FOUND, $arr['id'])); $ret++; $movie->doMovieUpdate($fetchedBinary, 'nfo', $arr['id'], $processImdb); // If set scan for tvrage info. if ($processTvrage == 1) { $rageId = $this->parseRageId($fetchedBinary); if ($rageId !== false) { $show = $tvRage->parseNameEpSeason($arr['name']); if (is_array($show) && $show['name'] != '') { // Update release with season, ep, and air date info (if available) from release title. $tvRage->updateEpInfo($show, $arr['id']); $rid = $tvRage->getByRageID($rageId); if (!$rid) { $tvrShow = $tvRage->getRageInfoFromService($rageId); $tvRage->updateRageInfo($rageId, $show, $tvrShow, $arr['id']); } } } } } } } // Remove nfo that we cant fetch after 5 attempts. $releases = $this->pdo->queryDirect(sprintf('SELECT r.id FROM releases r WHERE r.nzbstatus = %d AND r.nfostatus < %d %s %s', NZB::NZB_ADDED, $this->maxRetries, $groupIDQuery, $guidCharQuery)); if ($releases instanceof Traversable) { foreach ($releases as $release) { $this->pdo->queryExec(sprintf('DELETE FROM releasenfo WHERE nfo IS NULL AND releaseid = %d', $release['id'])); } } // Set releases with no NFO. $this->pdo->queryExec(sprintf(' UPDATE releases r SET r.nfostatus = %d WHERE r.nzbstatus = %d AND r.nfostatus < %d %s %s', self::NFO_FAILED, NZB::NZB_ADDED, $this->maxRetries, $groupIDQuery, $guidCharQuery)); if ($this->echo) { if ($nfoCount > 0) { echo PHP_EOL; } if ($ret > 0) { $this->pdo->log->doEcho($ret . ' NFO file(s) found/processed.', true); } } return $ret; }
$page->show404(); } $rc = new ReleaseComments($page->settings); if ($page->isPostBack()) { $rc->addComment($data['id'], $_POST['txtAddComment'], $page->users->currentUserId(), $_SERVER['REMOTE_ADDR']); } $nfo = $releases->getReleaseNfo($data['id'], false); $re = new ReleaseExtra($page->settings); $reVideo = $re->getVideo($data['id']); $reAudio = $re->getAudio($data['id']); $reSubs = $re->getSubs($data['id']); $comments = $rc->getComments($data['id']); $similars = $releases->searchSimilar($data['id'], $data['searchname'], 6, $page->userdata['categoryexclusions']); $rage = $ani = $mov = $mus = $con = $game = $xxx = $boo = ''; if ($data['rageid'] != '') { $tvrage = new TvRage(['Settings' => $page->settings]); $rageinfo = $tvrage->getByRageID($data['rageid']); if (count($rageinfo) > 0) { $seriesnames = $seriesdescription = $seriescountry = $seriesgenre = $seriesimg = $seriesid = array(); foreach ($rageinfo as $r) { $seriesnames[] = $r['releasetitle']; if (!empty($r['description'])) { $seriesdescription[] = $r['description']; } if (!empty($r['country'])) { $seriescountry[] = $r['country']; } if (!empty($r['genre'])) { $seriesgenre[] = $r['genre']; } if (!empty($r['imgdata'])) {
$data = $releases->getByGuid($_GET["id"]); if (!$data) { $page->show404(); } if ($page->isPostBack()) { $rc->addComment($data["id"], $data["gid"], $_POST["txtAddComment"], $page->users->currentUserId(), $_SERVER['REMOTE_ADDR']); } $nfo = $releases->getReleaseNfo($data["id"], false); $reVideo = $re->getVideo($data["id"]); $reAudio = $re->getAudio($data["id"]); $reSubs = $re->getSubs($data["id"]); $comments = $rc->getCommentsByGid($data["gid"]); $similars = $releases->searchSimilar($data['id'], $data['searchname'], 6, $page->userdata['categoryexclusions']); $rage = ''; if ($data["rageid"] != '') { $tvrage = new TvRage(); $rageinfo = $tvrage->getByRageID($data["rageid"]); if (count($rageinfo) > 0) { $seriesnames = $seriesdescription = $seriescountry = $seriesgenre = $seriesimg = $seriesid = []; foreach ($rageinfo as $r) { $seriesnames[] = $r['releasetitle']; if (!empty($r['description'])) { $seriesdescription[] = $r['description']; } if (!empty($r['country'])) { $seriescountry[] = $r['country']; } if (!empty($r['genre'])) { $seriesgenre[] = $r['genre']; } if (!empty($r['imgdata'])) {
<?php require_once dirname(__FILE__) . '/../../www/config.php'; use newznab\db\Settings; $db = new Settings(); $t = new TvRage(); // // all rage entries with a blank description $rows = $db->query("select ID, releasetitle from tvrage\n where description is null\n and rageID in (select distinct rageID from releases)\n order by ID desc"); echo "Updating " . count($rows) . " entries \n"; foreach ($rows as $row) { $t->refreshRageInfo($row["id"]); echo "Refreshing " . $row["releasetitle"] . "\n"; }
<?php //This script downloads covert art for Tv Shows -- it is intended to be run at interval, generally after the TvRage database is populated require_once dirname(__FILE__) . '/../../../www/config.php'; use nzedb\db\Settings; use nzedb\utility; $pdo = new Settings(); $tvrage = new TvRage(['Settings' => $pdo, 'Echo' => true]); $shows = $pdo->queryDirect("SELECT rageid FROM tvrage WHERE imgdata IS NULL ORDER BY rageid DESC LIMIT 2000"); if ($shows->rowCount() > 0) { echo "\n"; echo $pdo->log->header("Updating " . number_format($shows->rowCount()) . " tv shows.\n"); } else { echo "\n"; echo $pdo->log->info("All shows in TvRage database have been updated.\n"); usleep(5000000); } $loop = 0; if ($shows instanceof Traversable) { foreach ($shows as $show) { $starttime = microtime(true); $rageid = $show['rageid']; $tvrShow = $tvrage->getRageInfoFromService($rageid); $genre = ''; if (isset($tvrShow['genres']) && is_array($tvrShow['genres']) && !empty($tvrShow['genres'])) { if (is_array($tvrShow['genres']['genre'])) { $genre = @implode('|', $tvrShow['genres']['genre']); } else { $genre = $tvrShow['genres']['genre']; } }
<?php require_once "config.php"; $page = new AdminPage(); if (isset($_GET['id'])) { $tvrage = new TvRage(); $tvrage->delete($_GET['id']); } if (isset($_GET['from']) && !empty($_GET['from'])) { header("Location:" . $_GET['from']); die; } $referrer = $_SERVER['HTTP_REFERER']; header("Location: " . $referrer); die;
<?php if (!$page->users->isLoggedIn()) { $page->show403(); } $releases = new Releases(); $tvrage = new TvRage(); $cat = new Category(); $us = new UserSeries(); if (isset($_GET["id"]) && ctype_digit($_GET['id'])) { $category = -1; if (isset($_REQUEST["t"]) && ctype_digit($_REQUEST["t"])) { $category = $_REQUEST["t"]; } $catarray = []; $catarray[] = $category; $rel = $releases->searchbyRageId($_GET["id"], '', '', 0, 1000, "", $catarray, -1); $rage = $tvrage->getByRageID($_GET['id']); if (!$rage) { $page->smarty->assign('nodata', 'No tvrage information for this series.'); } elseif (!$rel) { $page->smarty->assign('nodata', 'No releases for this series.'); } else { $myshows = $us->getShow($page->users->currentUserId(), $rage[0]['rageid']); // Sort releases by season, episode, date posted. $season = $episode = $posted = []; foreach ($rel as $rlk => $rlv) { $season[$rlk] = $rlv['season']; $episode[$rlk] = $rlv['episode']; $posted[$rlk] = $rlv['postdate']; }
<?php require_once WWW_DIR . "/lib/tvrage.php"; if (!$users->isLoggedIn()) { $page->show403(); } $tvrage = new TvRage(); $date = date("Y-m-d"); if (isset($_GET["date"])) { $date = $_GET["date"]; } $timestamp = mktime(0, 0, 0, substr($date, 6, 2), substr($date, 8, 2), substr($date, 0, 4)); // make it 7 days before, 7 days after $start = $timestamp - 86400 * 7; for ($i = 0; $i <= 13; $i++) { $start = $start + 86400; $cal[] = date("Y-m-d", $start); } $prettydate = date("l, jS F Y", $timestamp); $prepretty = date("l, jS F Y", $timestamp - 86400); $nxtpretty = date("l, jS F Y", $timestamp + 86400); $predaydata = $tvrage->getCalendar(date("Y-m-d", $timestamp - 86400)); $nxtdaydata = $tvrage->getCalendar(date("Y-m-d", $timestamp + 86400)); $daydata = $tvrage->getCalendar($date); $page->title = 'Calendar'; $page->meta_title = "View Calendar"; $page->meta_keywords = "view,calendar,tv,"; $page->meta_description = "View Calendar"; $page->smarty->assign('date', $prettydate); $page->smarty->assign('predate', $prepretty); $page->smarty->assign('nxtdate', $nxtpretty);
<?php require_once WWW_DIR . "/lib/releases.php"; require_once WWW_DIR . "/lib/tvrage.php"; require_once WWW_DIR . "/lib/category.php"; $releases = new Releases(); $tvrage = new TvRage(); $cat = new Category(); if (!$users->isLoggedIn()) { $page->show403(); } if (isset($_GET["id"]) && ctype_digit($_GET['id'])) { $category = -1; if (isset($_REQUEST["t"]) && ctype_digit($_REQUEST["t"])) { $category = $_REQUEST["t"]; } $catarray = array(); $catarray[] = $category; $rel = $releases->searchbyRageId($_GET["id"], '', '', 0, 1000, "", $catarray, -1); $rage = $tvrage->getByRageID($_GET['id']); if (!$rel || !$rage) { $page->show404(); } //sort releases by season, episode, date posted $season = $episode = $posted = array(); foreach ($rel as $rlk => $rlv) { $season[$rlk] = $rlv['season']; $episode[$rlk] = $rlv['episode']; $posted[$rlk] = $rlv['postdate']; } array_multisort($season, SORT_DESC, $episode, SORT_DESC, $posted, SORT_DESC, $rel);
<?php require_once dirname(__FILE__) . '/../../www/config.php'; use newznab\db\Settings; $t = new TvRage(); $db = new Settings(); $shows = $db->query("select name from releases where categoryID IN (select ID from category where parentID = 5000) limit 0, 50"); foreach ($shows as $show) { $res = $t->parseNameEpSeason($show['name']); $res['release'] = $show['name']; echo "<pre>"; print_r($res); echo "</pre>"; }