<?php use nzedb\TvRage; // 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(['Settings' => $page->settings]); $r = $rage->getByID($_GET["id"]); if (!$r) { $page->show404(); } $imgdata = $r["imgdata"]; header("Content-type: image/jpeg"); print $imgdata; } else { $page->show404(); }
<?php use nzedb\TvRage; if (!$page->users->isLoggedIn()) { $page->show403(); } $tvrage = new TvRage(['Settings' => $page->settings]); $date = date("Y-m-d"); if (isset($_GET["date"])) { $date = $_GET["date"]; } $timestamp = mktime(0, 0, 0, substr($date, 5, 2), substr($date, 8, 2), substr($date, 0, 4)); // Make it 7 days before, 7 days after. $start = $timestamp - 86400 * 7; $cal = array(); 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);
<?php require_once './config.php'; use nzedb\TvRage; $page = new AdminPage(); $tvRage = new TvRage(['Settings' => $page->settings]); $page->title = "TV Rage List"; $tvRageName = isset($_REQUEST['ragename']) && !empty($_REQUEST['ragename']) ? $_REQUEST['ragename'] : ''; $offset = isset($_REQUEST["offset"]) ? $_REQUEST["offset"] : 0; $page->smarty->assign(['ragename' => $tvRageName, 'tvragelist' => $tvRage->getRange($offset, ITEMS_PER_PAGE, $tvRageName), 'pagertotalitems' => $tvRage->getCount($tvRageName), 'pageroffset' => $offset, 'pageritemsperpage' => ITEMS_PER_PAGE, 'pagerquerysuffix' => '', 'pagerquerybase' => WWW_TOP . "/rage-list.php?" . ($tvRageName != '' ? 'ragename=' . $tvRageName . '&' : '') . "&offset="]); $page->smarty->assign('pager', $page->smarty->fetch("pager.tpl")); $page->content = $page->smarty->fetch('rage-list.tpl'); $page->render();
<?php use nzedb\Category; use nzedb\Releases; use nzedb\TvRage; use nzedb\UserSeries; if (!$page->users->isLoggedIn()) { $page->show403(); } $releases = new Releases(['Settings' => $page->settings]); $tvrage = new TvRage(['Settings' => $page->settings]); $cat = new Category(['Settings' => $page->settings]); $us = new UserSeries(['Settings' => $page->settings]); 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 (!$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 = array(); foreach ($rel as $rlk => $rlv) {
<?php require_once './config.php'; use nzedb\TvRage; $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 //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\TvRage; use nzedb\db\Settings; use nzedb\utility\Utility; $pdo = new Settings(); $tvrage = new TvRage(['Settings' => $pdo, 'Echo' => true]); $shows = $pdo->queryDirect("SELECT rageid FROM tvrage_titles 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']; }
/** * 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.group_id = ' . $groupID; $optionsQuery = self::NfoQueryString($this->pdo); $res = $this->pdo->query(sprintf(' SELECT r.id, r.guid, r.group_id, 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['group_id'], $groups->getByNameByID($arr['group_id'])); if ($fetchedBinary !== false) { // Insert nfo into database. $cp = 'COMPRESS(%s)'; $nc = $this->pdo->escapeString($fetchedBinary); $ckreleaseid = $this->pdo->queryOneRow(sprintf('SELECT id FROM release_nfos WHERE releaseid = %d', $arr['id'])); if (!isset($ckreleaseid['id'])) { $this->pdo->queryInsert(sprintf('INSERT INTO release_nfos (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 release_nfos 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; }
<?php require_once './config.php'; use nzedb\TvRage; $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'];
$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 = []; 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'])) {
use nzedb\Releases; use nzedb\TvRage; 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'; use nzedb\TvRage; $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');