select('id, votes, bounty')->from('requests, requests_delta'); $SortOrderMap = [ 'votes' => ['votes', 'desc'], 'bounty' => ['bounty', 'desc'], 'lastvote' => ['lastvote', 'desc'], 'filled' => ['timefilled', 'desc'], 'year' => ['year', 'desc'], 'created' => ['timeadded', 'desc'], 'random' => ['RAND()', ''], ]; $SortOrder = (!empty($_GET['order']) && isset($SortOrderMap[$_GET['order']])) ? $_GET['order'] : 'created'; $OrderBy = $SortOrderMap[$SortOrder][0]; $OrderWay = ''; if (!empty($SortOrderMap[$SortOrder][1])) { $OrderWay = (empty($_GET['sort']) || $_GET['sort'] == $SortOrderMap[$SortOrder][1]) ? $SortOrderMap[$SortOrder][1] : SortableTableHeader::SORT_DIRS[$SortOrderMap[$SortOrder][1]]; } $SphQL->order_by($OrderBy, $OrderWay); $Submitted = !empty($_GET['submit']); //Paranoia if (!empty($_GET['userid'])) { if (!intval($_GET['userid'])) { error('User ID must be an integer'); } $UserInfo = Users::user_info($_GET['userid']); if (empty($UserInfo)) { error('That user does not exist'); } $Perms = Permissions::get_permissions($UserInfo['PermissionID']); $UserClass = $Perms['Class']; } $BookmarkView = false; if (empty($_GET['type'])) { $Title = 'Requests'; } else { // Show filled defaults to on only for viewing types if (!$Submitted) { $_GET['show_filled'] = "on"; } switch ($_GET['type']) { case 'created': if (!empty($UserInfo)) { if (!check_paranoia('requestsvoted_list', $UserInfo['Paranoia'], $Perms['Class'], $UserInfo['ID'])) { error(403); } $Title = "Requests created by $UserInfo[Username]"; $SphQL->where('userid', $UserInfo['ID']); } else { $Title = 'My requests'; $SphQL->where('userid', $LoggedUser['ID']); } break; case 'voted': if (!empty($UserInfo)) { if (!check_paranoia('requestsvoted_list', $UserInfo['Paranoia'], $Perms['Class'], $UserInfo['ID'])) { error(403); } $Title = "Requests voted for by $UserInfo[Username]"; $SphQL->where('voter', $UserInfo['ID']); } else { $Title = 'Requests I have voted on'; $SphQL->where('voter', $LoggedUser['ID']); } break; case 'filled': if (!empty($UserInfo)) { if (!check_paranoia('requestsfilled_list', $UserInfo['Paranoia'], $Perms['Class'], $UserInfo['ID'])) { error(403); } $Title = "Requests filled by $UserInfo[Username]"; $SphQL->where('fillerid', $UserInfo['ID']); } else { $Title = 'Requests I have filled'; $SphQL->where('fillerid', $LoggedUser['ID']); } break; case 'bookmarks': $Title = 'Your bookmarked requests'; $BookmarkView = true; $SphQL->where('bookmarker', $LoggedUser['ID']); break; default: error(404); } } if ($Submitted && empty($_GET['showall'])) { $SphQL->where('visible', 1); } // We don't want to show filled by default on plain requests.php, // but we do show it by default if viewing a $_GET['type'] page // by default if ((!$Submitted && empty($_GET['type'])) || ($Submitted && empty($_GET['show_filled']))) { $SphQL->where('torrentid', 0); } $EnableNegation = false; // Sphinx needs at least one positive search condition to support the NOT operator if (!empty($_GET['formats'])) { $FormatArray = $_GET['formats']; if (count($FormatArray) !== count($Formats)) { $FormatNameArray = []; foreach ($FormatArray as $Index => $MasterIndex) { if (isset($Formats[$MasterIndex])) { $FormatNameArray[$Index] = '"' . strtr(Sphinxql::sph_escape_string($Formats[$MasterIndex]), '-.', ' ') . '"'; } } if (count($FormatNameArray) >= 1) { $EnableNegation = true; if (!empty($_GET['formats_strict'])) { $SearchString = '(' . implode(' | ', $FormatNameArray) . ')'; } else { $SearchString = '(any | ' . implode(' | ', $FormatNameArray) . ')'; } $SphQL->where_match($SearchString, 'formatlist', false); } } } if (!empty($_GET['media'])) { $MediaArray = $_GET['media']; if (count($MediaArray) !== count($Media)) { $MediaNameArray = []; foreach ($MediaArray as $Index => $MasterIndex) { if (isset($Media[$MasterIndex])) { $MediaNameArray[$Index] = '"' . strtr(Sphinxql::sph_escape_string($Media[$MasterIndex]), '-.', ' ') . '"'; } } if (count($MediaNameArray) >= 1) { $EnableNegation = true; if (!empty($_GET['media_strict'])) { $SearchString = '(' . implode(' | ', $MediaNameArray) . ')'; } else { $SearchString = '(any | ' . implode(' | ', $MediaNameArray) . ')'; } $SphQL->where_match($SearchString, 'medialist', false); } } } if (!empty($_GET['bitrates'])) { $BitrateArray = $_GET['bitrates']; if (count($BitrateArray) !== count($Bitrates)) { $BitrateNameArray = []; foreach ($BitrateArray as $Index => $MasterIndex) { if (isset($Bitrates[$MasterIndex])) { $BitrateNameArray[$Index] = '"' . strtr(Sphinxql::sph_escape_string($Bitrates[$MasterIndex]), '-.', ' ') . '"'; } } if (count($BitrateNameArray) >= 1) { $EnableNegation = true; if (!empty($_GET['bitrate_strict'])) { $SearchString = '(' . implode(' | ', $BitrateNameArray) . ')'; } else { $SearchString = '(any | ' . implode(' | ', $BitrateNameArray) . ')'; } $SphQL->where_match($SearchString, 'bitratelist', false); } } } if (!empty($_GET['search'])) { $SearchString = trim($_GET['search']); if ($SearchString !== '') { $SearchWords = ['include' => [], 'exclude' => []]; $Words = explode(' ', $SearchString); foreach ($Words as $Word) { $Word = trim($Word); // Skip isolated hyphens to enable "Artist - Title" searches if ($Word === '-') { continue; } if ($Word[0] === '!' && strlen($Word) >= 2) { if (strpos($Word, '!', 1) === false) { $SearchWords['exclude'][] = $Word; } else { $SearchWords['include'][] = $Word; $EnableNegation = true; } } elseif ($Word !== '') { $SearchWords['include'][] = $Word; $EnableNegation = true; } } } } if (!isset($_GET['tags_type']) || $_GET['tags_type'] === '1') { $TagType = 1; $_GET['tags_type'] = '1'; } else { $TagType = 0; $_GET['tags_type'] = '0'; } if (!empty($_GET['tags'])) { $SearchTags = ['include' => [], 'exclude' => []]; $Tags = explode(',', str_replace('.', '_', $_GET['tags'])); foreach ($Tags as $Tag) { $Tag = trim($Tag); if ($Tag[0] === '!' && strlen($Tag) >= 2) { if (strpos($Tag, '!', 1) === false) { $SearchTags['exclude'][] = $Tag; } else { $SearchTags['include'][] = $Tag; $EnableNegation = true; } } elseif ($Tag !== '') { $SearchTags['include'][] = $Tag; $EnableNegation = true; } } $TagFilter = Tags::tag_filter_sph($SearchTags, $EnableNegation, $TagType); $TagNames = $TagFilter['input']; if (!empty($TagFilter['predicate'])) { $SphQL->where_match($TagFilter['predicate'], 'taglist', false); } } elseif (!isset($_GET['tags_type']) || $_GET['tags_type'] !== '0') { $_GET['tags_type'] = 1; } else { $_GET['tags_type'] = 0; } if (isset($SearchWords)) { $QueryParts = []; if (!$EnableNegation && !empty($SearchWords['exclude'])) { $SearchWords['include'] = array_merge($SearchWords['include'], $SearchWords['exclude']); unset($SearchWords['exclude']); } foreach ($SearchWords['include'] as $Word) { $QueryParts[] = Sphinxql::sph_escape_string($Word); } if (!empty($SearchWords['exclude'])) { foreach ($SearchWords['exclude'] as $Word) { $QueryParts[] = '!' . Sphinxql::sph_escape_string(substr($Word, 1)); } } if (!empty($QueryParts)) { $SearchString = implode(' ', $QueryParts); $SphQL->where_match($SearchString, '*', false); } } if (!empty($_GET['filter_cat'])) { $CategoryArray = array_keys($_GET['filter_cat']); if (count($CategoryArray) !== count($CategoriesV2)) { foreach ($CategoryArray as $Key => $Index) { if (!isset($CategoriesV2[$Index - 1])) { unset($CategoryArray[$Key]); } } if (count($CategoryArray) >= 1) { $SphQL->where('categoryid', $CategoryArray); } } } if (!empty($_GET['releases'])) { $ReleaseArray = $_GET['releases']; if (count($ReleaseArray) !== count($ReleaseTypes)) { foreach ($ReleaseArray as $Index => $Value) { if (!isset($ReleaseTypes[$Value])) { unset($ReleaseArray[$Index]); } } if (count($ReleaseArray) >= 1) { $SphQL->where('releasetype', $ReleaseArray); } } } if (!empty($_GET['requestor'])) { if (intval($_GET['requestor'])) { $SphQL->where('userid', $_GET['requestor']); } else { error(404); } } if (isset($_GET['year'])) { if (intval($_GET['year']) || $_GET['year'] === '0') { $SphQL->where('year', $_GET['year']); } else { error(404); } } if ($OrderBy !== 'random' && isset($_GET['page']) && intval($_GET['page']) && $_GET['page'] > 0) { $Page = $_GET['page']; $Offset = ($Page - 1) * REQUESTS_PER_PAGE; $SphQL->limit($Offset, REQUESTS_PER_PAGE, $Offset + REQUESTS_PER_PAGE); } else { $Page = 1; $SphQL->limit(0, REQUESTS_PER_PAGE, REQUESTS_PER_PAGE); } $SphQLResult = $SphQL->query(); $NumResults = (int)$SphQLResult->get_meta('total_found'); if ($NumResults > 0) { $SphRequests = $SphQLResult->to_array('id'); if ($OrderBy === 'random') { $NumResults = count($SphRequests); } if ($NumResults > REQUESTS_PER_PAGE) { if (($Page - 1) * REQUESTS_PER_PAGE > $NumResults) { $Page = 0; } $PageLinks = Format::get_pages($Page, $NumResults, REQUESTS_PER_PAGE); } } $CurrentURL = Format::get_url(['order', 'sort', 'page']); View::show_header($Title, 'requests'); ?>
| Request Name / = $header->emit('year', $SortOrderMap['year'][1]) ?> | = $header->emit('votes', $SortOrderMap['votes'][1]) ?> | = $header->emit('bounty', $SortOrderMap['bounty'][1]) ?> | = $header->emit('filled', $SortOrderMap['filled'][1]) ?> | Filled by | Requested by | = $header->emit('created', $SortOrderMap['created'][1]) ?> | = $header->emit('lastvote', $SortOrderMap['lastvote'][1]) ?> |
| Nothing found! | |||||||
| The requested page contains no matches! | |||||||
| =$FullName?> | =number_format($VoteCount)?> + | =Format::get_size($Bounty)?> | =time_diff($Request['TimeFilled'], 1)?> No | =$FillerInfo['Username']?> — | =Users::format_username($Request['UserID'], false, false, false)?> | =time_diff($Request['TimeAdded'], 1)?> | =time_diff($Request['LastVote'], 1)?> |