$Queries = array(); $OrderWays = array('year', 'votes', 'bounty', 'created', 'lastvote', 'filled'); list($Page,$Limit) = page_limit(REQUESTS_PER_PAGE); $Submitted = !empty($_GET['submit']); //Paranoia $UserInfo = user_info((int)$_GET['userid']); $Perms = get_permissions($UserInfo['PermissionID']); $UserClass = $Perms['Class']; $BookmarkView = false; if(empty($_GET['type'])) { $Title = 'Requests'; if(!check_perms('site_see_old_requests') || empty($_GET['showall'])) { $SS->set_filter('visible', array(1)); } } else { switch($_GET['type']) { case 'created': $Title = 'My requests'; $SS->set_filter('userid', array($LoggedUser['ID'])); break; case 'voted': if(!empty($_GET['userid'])) { if(is_number($_GET['userid'])) { if (!check_paranoia('requestsvoted_list', $UserInfo['Paranoia'], $Perms['Class'], $_GET['userid'])) { error(403); } $Title = "Requests voted for by ".$UserInfo['Username']; $SS->set_filter('voter', array($_GET['userid'])); } else { error(404); } } else { $Title = "Requests I've voted on"; $SS->set_filter('voter', array($LoggedUser['ID'])); } break; case 'filled': if(empty($_GET['userid']) || !is_number($_GET['userid'])) { error(404); } else { if (!check_paranoia('requestsfilled_list', $UserInfo['Paranoia'], $Perms['Class'], $_GET['userid'])) { error(403); } $Title = "Requests filled by ".$UserInfo['Username']; $SS->set_filter('fillerid', array($_GET['userid'])); } break; case 'bookmarks': $Title = 'Your bookmarked requests'; $BookmarkView = true; $SS->set_filter('bookmarker', array($LoggedUser['ID'])); break; default: error(404); } } if($Submitted && empty($_GET['show_filled'])) { $SS->set_filter('torrentid', array(0)); } if(!empty($_GET['search'])) { $Words = explode(' ', $_GET['search']); foreach($Words as $Key => &$Word) { if($Word[0] == '!' && strlen($Word) > 2) { if(strpos($Word,'!',1) === false) { $Word = '!'.$SS->EscapeString(substr($Word,1)); } else { $Word = $SS->EscapeString($Word); } } elseif(strlen($Word) >= 2) { $Word = $SS->EscapeString($Word); } else { unset($Words[$Key]); } } if(!empty($Words)) { $Queries[] = "@* ".implode(' ', $Words); } } if(!empty($_GET['tags'])){ $Tags = explode(',', $_GET['tags']); $TagNames = array(); foreach ($Tags as $Tag) { $Tag = sanitize_tag($Tag); if(!empty($Tag)) { $TagNames[] = $Tag; } } $Tags = get_tags($TagNames); } if(empty($_GET['tags_type']) && !empty($Tags)) { $_GET['tags_type'] = '0'; $SS->set_filter('tagid', array_keys($Tags)); } elseif(!empty($Tags)) { foreach(array_keys($Tags) as $Tag) { $SS->set_filter('tagid', array($Tag)); } } else { $_GET['tags_type'] = '1'; } if(!empty($_GET['filter_cat'])) { $Keys = array_keys($_GET['filter_cat']); $SS->set_filter('categoryid', $Keys); } if(!empty($_GET['releases'])) { $ReleaseArray = $_GET['releases']; if(count($ReleaseArray) != count($ReleaseTypes)) { foreach($ReleaseArray as $Index => $Value) { if(!is_number($Value)) { error(0); } } $SS->set_filter('releasetype', $ReleaseArray); } } 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); } } $Queries[]='@formatlist '.implode(' | ', $FormatNameArray); } } 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); } } $Queries[]='@medialist '.implode(' | ', $MediaNameArray); } } 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] = $SS->EscapeString($Bitrates[$MasterIndex]); } else { //Hax error(0); } } $Queries[]='@bitratelist '.implode(' | ', $BitrateNameArray); } } if(!empty($_GET['requestor']) && check_perms('site_see_old_requests')) { if(is_number($_GET['requestor'])) { $SS->set_filter('userid', array($_GET['requestor'])); } else { error(404); } } if(isset($_GET['year'])) { if(is_number($_GET['year']) || $_GET['year'] == 0) { $SS->set_filter('year', array($_GET['year'])); } else { error(404); } } if(!empty($_GET['page']) && is_number($_GET['page'])) { $Page = min($_GET['page'], 50000/REQUESTS_PER_PAGE); $SS->limit(($Page - 1) * REQUESTS_PER_PAGE, REQUESTS_PER_PAGE, 50000); } else { $Page = 1; $SS->limit(0, REQUESTS_PER_PAGE, 50000); } if(empty($_GET['order'])) { $CurrentOrder = 'created'; $CurrentSort = 'desc'; $Way = SPH_SORT_ATTR_DESC; $NewSort = 'asc'; } else { if(in_array($_GET['order'], $OrderWays)) { $CurrentOrder = $_GET['order']; if($_GET['sort'] == 'asc' || $_GET['sort'] == 'desc') { $CurrentSort = $_GET['sort']; $Way = ($CurrentSort == 'asc' ? SPH_SORT_ATTR_ASC : SPH_SORT_ATTR_DESC); $NewSort = ($_GET['sort'] == 'asc' ? 'desc' : 'asc'); } else { error(404); } } else { error(404); } } switch($CurrentOrder) { case 'votes' : $OrderBy = "Votes"; break; case 'bounty' : $OrderBy = "Bounty"; break; case 'created' : $OrderBy = "TimeAdded"; break; case 'lastvote' : $OrderBy = "LastVote"; break; case 'filled' : $OrderBy = "TimeFilled"; break; case 'year' : $OrderBy = "Year"; break; default : $OrderBy = "TimeAdded"; break; } //print($Way); print($OrderBy); die(); $SS->SetSortMode($Way, $OrderBy); if(count($Queries) > 0) { $Query = implode(' ',$Queries); } else { $Query=''; } $SS->set_index('requests requests_delta'); $SphinxResults = $SS->search($Query, '', 0, array(), '', ''); $NumResults = $SS->TotalResults; //We don't use sphinxapi's default cache searcher, we use our own functions if(!empty($SphinxResults['notfound'])) { $SQLResults = get_requests($SphinxResults['notfound']); if(is_array($SQLResults['notfound'])) { //Something wasn't found in the db, remove it from results reset($SQLResults['notfound']); foreach($SQLResults['notfound'] as $ID) { unset($SQLResults['matches'][$ID]); unset($SphinxResults['matches'][$ID]); } } // Merge SQL results with memcached results foreach($SQLResults['matches'] as $ID => $SQLResult) { $SphinxResults['matches'][$ID] = $SQLResult; //$Requests['matches'][$ID] = array_merge($Requests['matches'][$ID], $SQLResult); //We ksort because depending on the filter modes, we're given our data in an unpredictable order //ksort($Requests['matches'][$ID]); } } $PageLinks = get_pages($Page, $NumResults, REQUESTS_PER_PAGE); $Requests = $SphinxResults['matches']; $CurrentURL = get_url(array('order', 'sort')); show_header($Title, 'requests'); ?>
Request Name / Year | Votes | Bounty | Filled | Filled by | Requested by | Created | Last Vote |
Nothing found! | |||||||
=$FullName?> | } ?> | =get_size($RequestVotes['TotalBounty'])?> | if($IsFilled){ ?> =time_diff($TimeFilled)?> } else { ?> No } ?> | if($IsFilled){ ?> =$FillerName?> } else { ?> -- } ?> | =$RequestorName?> | =time_diff($TimeAdded)?> | =time_diff($LastVote)?> |