$page->smarty->assign('del', isset($_GET['del']) && $_GET['del'] == 1 ? '1' : '0'); // Output is either json or xml. $outputXML = isset($_GET['o']) && $_GET['o'] == 'json' ? false : true; switch ($function) { // Search releases. case 's': verifyEmptyParameter('q'); $maxAge = maxAge(); $page->users->addApiRequest($uid, $_SERVER['REQUEST_URI'], $hosthash); $categoryID = categoryid(); $limit = limit(); $offset = offset(); if (isset($_GET['q'])) { $relData = $releases->search($_GET['q'], -1, -1, -1, -1, -1, 0, 0, -1, -1, $offset, $limit, '', $maxAge, $catExclusions, "basic", $categoryID); } else { $totalRows = $releases->getBrowseCount($categoryID, $maxAge, $catExclusions); $relData = $releases->getBrowseRange($categoryID, $offset, $limit, '', $maxAge, $catExclusions); if ($totalRows > 0 && count($relData) > 0) { $relData[0]['_totalrows'] = $totalRows; } } printOutput($relData, $outputXML, $page, $offset); break; // Search tv releases. // Search tv releases. case 'tv': verifyEmptyParameter('q'); verifyEmptyParameter('rid'); verifyEmptyParameter('season'); verifyEmptyParameter('ep'); $maxAge = maxAge();
} $limit = 100; if (isset($_GET["limit"]) && is_numeric($_GET["limit"]) && $_GET["limit"] < 100) { $limit = $_GET["limit"]; } $offset = 0; if (isset($_GET["offset"]) && is_numeric($_GET["offset"])) { $offset = $_GET["offset"]; } if (isset($_GET["q"])) { $reldata = $releases->search($_GET["q"], $categoryId, $offset, $limit, $sort, $maxage, $catexclusions, $groupName, $minsize, $maxsize); } else { $orderby = array(); $orderby[0] = "post\tdate"; $orderby[1] = "asc"; $totrows = $releases->getBrowseCount($categoryId, $maxage, $catexclusions, $groupName); $reldata = $releases->getBrowseRange($categoryId, $offset, $limit, "", $maxage, $catexclusions, $groupName); if ($totrows > 0 && count($reldata)) { $reldata[0]["_totalrows"] = $totrows; } } $page->smarty->assign('offset', $offset); $page->smarty->assign('releases', $reldata); $page->smarty->assign('rsshead', $page->smarty->fetch('rssheader.tpl')); $output = trim($page->smarty->fetch('apiresult.tpl')); if ($outputtype == "xml") { header("Content-type: text/xml"); echo $output; } else { header('Content-type: application/json'); echo json_encode(responseXmlToObject($output));
$releases = new Releases(); if (!$users->isLoggedIn()) { $page->show403(); } $category = -1; if (isset($_REQUEST["t"]) && ctype_digit($_REQUEST["t"])) { $category = $_REQUEST["t"]; } $grp = array(); if (isset($_REQUEST["g"])) { $grp = explode(",", $_REQUEST["g"]); } $catarray = array(); $catarray[] = $category; $page->smarty->assign('category', $category); $browsecount = $releases->getBrowseCount($catarray, -1, $page->userdata["categoryexclusions"], $grp); $offset = isset($_REQUEST["offset"]) && ctype_digit($_REQUEST['offset']) ? $_REQUEST["offset"] : 0; $ordering = $releases->getBrowseOrdering(); $orderby = isset($_REQUEST["ob"]) && in_array($_REQUEST['ob'], $ordering) ? $_REQUEST["ob"] : ''; $results = array(); $results = $releases->getBrowseRange($catarray, $offset, ITEMS_PER_PAGE, $orderby, -1, $page->userdata["categoryexclusions"], $grp); $page->smarty->assign('pagertotalitems', $browsecount); $page->smarty->assign('pageroffset', $offset); $page->smarty->assign('pageritemsperpage', ITEMS_PER_PAGE); $page->smarty->assign('pagerquerybase', WWW_TOP . "/browse?t=" . $category . (count($grp) > 0 ? "&g=" . $grp[0] : "") . "&ob=" . $orderby . "&offset="); $page->smarty->assign('pagerquerysuffix', "#results"); $pager = $page->smarty->fetch("pager.tpl"); $page->smarty->assign('pager', $pager); $section = ''; if ($category == -1 && count($grp) == 0) { $page->smarty->assign("catname", "All");