list($Page,$Limit) = page_limit(REQUESTS_PER_PAGE); $OrderWays = array('name', 'votes', 'bounty', 'filler', 'requestor', 'created', 'lastvote', 'filled'); $Wheres = array(); $ExtraJoins = array(); $Submitted = !empty($_GET['submit']); if (!empty($_GET['search'])) { $Words = explode(' ', $_GET['search']); $SearchWords = array(); foreach ($Words AS $Word) { $Wheres[] = "LOCATE('".db_string($Word)."', r.Title)"; } } $TagMatcher = (!empty($_GET['tagmatcher']) && $_GET['tagmatcher'] == "any") ? "any" : "all"; if (!empty($_GET['tags'])) { $Tags = explode(',', $_GET['tags']); $TagNames = array(); foreach ($Tags as $Tag) { $Tag = Misc::sanitize_tag($Tag); if (!empty($Tag)) { $TagNames[] = $Tag; } } if ($TagMatcher == "any") { $ExtraJoins[] = "LEFT JOIN requests_tags AS rt ON r.ID=rt.RequestID"; $ExtraJoins[] = "LEFT JOIN tags AS t ON t.ID=rt.TagID"; $Wheres[] = "t.Name IN ('".implode("', '", $TagNames)."')"; } else { } } if (!empty($_GET['requestor']) && check_perms('site_see_old_requests')) { $Wheres[] = "u.Username LIKE ".db_string($_GET['requestor']); } if (!empty($_GET['filter_cat'])) { $Keys = array_keys($_GET['filter_cat']); $Wheres[] = "r.CategoryID IN (".implode(", ", $Keys).")"; } if (!empty($_GET['releases'])) { $ReleaseArray = $_GET['releases']; if (count($ReleaseArray) != count($ReleaseTypes)) { foreach ($ReleaseArray as $Index => $Value) { if (is_number($Value)) { $Wheres[] = "r.ReleaseType = ".$Value; } else { error(0); } } } } if (!empty($_GET['formats'])) { $FormatArray = $_GET['formats']; if (count($FormatArray) != count($Formats)) { $FormatNameArray = array(); foreach ($FormatArray as $Index => $MasterIndex) { if (array_key_exists($Index, $Formats)) { $FormatNameArray[$Index] = $Formats[$MasterIndex]; } else { //Hax error(0); } } foreach ($FormatNameArray as $Index => $Name) { $Wheres[] = "LOCATE('".db_string($Name)."', r.FormatList)"; } } } if (!empty($_GET['media'])) { $MediaArray = $_GET['media']; if (count($MediaArray) != count($Media)) { $MediaNameArray = array(); foreach ($MediaArray as $Index => $MasterIndex) { if (array_key_exists($Index, $Media)) { $MediaNameArray[$Index] = $Media[$MasterIndex]; } else { //Hax error(0); } } foreach ($MediaNameArray as $Index => $Name) { $Wheres[] = "LOCATE('".db_string($Name)."', r.MediaList)"; } } } if (!empty($_GET['bitrates'])) { $BitrateArray = $_GET['bitrates']; if (count($BitrateArray) != count($Bitrates)) { $BitrateNameArray = array(); foreach ($BitrateArray as $Index => $MasterIndex) { if (array_key_exists($Index, $Bitrates)) { $BitrateNameArray[$Index] = $Bitrates[$MasterIndex]; } else { //Hax error(0); } } foreach ($BitrateNameArray as $Index => $Name) { $Wheres[] = "LOCATE('".db_string($Name)."', r.BitrateList)"; } } } if (empty($_GET['type'])) { $Title = 'Requests'; if (!check_perms('site_see_old_requests') || empty($_GET['showall'])) { $Wheres[] = "(TorrentID = 0 OR (TimeFilled > (NOW() - INTERVAL 3 DAY)))"; } } else { switch ($_GET['type']) { case 'created': $Title = 'My requests'; $Wheres[] = "r.UserID = ".$LoggedUser['ID']; break; case 'voted': $Title = "Requests I've voted on"; $Wheres[] = "_rv.UserID = ".$LoggedUser['ID']; $ExtraJoins[] = "LEFT JOIN requests_votes AS _rv ON _rv.RequestID=r.ID"; break; case 'filled': if (empty($_GET['userid']) || !is_number($_GET['userid'])) { error(404); } else { $Title = "Requests filled"; $Wheres = "r.FillerID = ".$_GET['userid']; } default: error(404); } } if (empty($_GET['order'])) { $CurrentOrder = 'created'; $CurrentSort = 'desc'; $NewSort = 'asc'; } else { if (in_array($_GET['order'], $OrderWays)) { $CurrentOrder = $_GET['order']; if ($_GET['sort'] == 'asc' || $_GET['sort'] == 'desc') { $CurrentSort = $_GET['sort']; $NewSort = ($_GET['sort'] == 'asc' ? 'desc' : 'asc'); } else { error(404); } } else { error(404); } } $CurrentURL = get_url(array('order', 'sort')); switch ($CurrentOrder) { case 'name' : $OrderBy = "r.Title"; break; case 'votes' : $OrderBy = "Votes"; break; case 'bounty' : $OrderBy = "Bounty"; break; case 'filler' : $OrderBy = "r.FillerID"; break; case 'requestor' : $OrderBy = "r.UserID"; break; case 'created' : $OrderBy = "r.ID"; break; case 'lastvote' : $OrderBy = "r.LastVote"; break; case 'filled' : $OrderBy = "r.TimeFilled"; break; default : $OrderBy = "r.ID"; break; } $OrderBy = $OrderBy." ".$CurrentSort; $Matcher = 'AND'; if (count($Wheres)) { $Where = 'WHERE ('.implode(") ".$Matcher." (", $Wheres).")"; } else { $Where = ''; } if (count($ExtraJoins)) { $ExtraJoin = implode(' ', $ExtraJoins); } else { $ExtraJoin = ''; } // Build SQL query $DB->query("SELECT SQL_CALC_FOUND_ROWS r.ID, r.CategoryID, r.Title, r.Year, SUM(rv.Bounty) AS Bounty, COUNT(rv.UserID) AS Votes, r.FillerID, filler.Username, r.TorrentID, r.TimeFilled, r.UserID, u.Username, r.TimeAdded, r.LastVote FROM requests AS r LEFT JOIN users_main AS u ON u.ID=r.UserID LEFT JOIN users_main AS filler ON filler.ID = FillerID LEFT JOIN requests_votes AS rv ON rv.RequestID=r.ID " .$ExtraJoin." " .$Where." GROUP BY r.ID ORDER BY ".$OrderBy." LIMIT ".$Limit); $Requests = $DB->to_array(); $DB->query('SELECT FOUND_ROWS()'); list($Results) = $DB->next_record(); $PageLinks = get_pages($Page, $Results, REQUESTS_PER_PAGE, 11); show_header($Title, 'requests'); ?>
Request name | Vote (20MB) | Bounty | Filled | Filled by | Requested by | Created | Last vote |
Nothing found! | |||||||
=$FullName?> | =$Votes?> if (!$IsFilled && check_perms('site_vote')) { ?> + } ?> | =get_size($Bounty)?> | if ($IsFilled) { ?> Yes - =$TimeFilled?> } else { ?> No - Upload } ?> | if ($IsFilled) { ?> =$FillerName?> } else { ?> -- } ?> | =$RequestorName?> | =time_diff($TimeAdded)?> | =time_diff($LastVote)?> |