Gazelle/sections/requests/requests.php

654 lines
21 KiB
PHP
Raw Normal View History

2013-05-28 08:01:02 +00:00
<?php
2013-09-13 08:00:53 +00:00
$SphQL = new SphinxqlQuery();
$SphQL->select('id, votes, bounty')->from('requests, requests_delta');
$SortOrders = array(
'votes' => 'votes',
'bounty' => 'bounty',
'lastvote' => 'lastvote',
'filled' => 'timefilled',
'year' => 'year',
'created' => 'timeadded',
'random' => false);
if (empty($_GET['order']) || !isset($SortOrders[$_GET['order']])) {
$_GET['order'] = 'created';
}
$OrderBy = $_GET['order'];
2014-03-16 08:00:50 +00:00
if (!empty($_GET['sort']) && $_GET['sort'] === 'asc') {
2013-09-13 08:00:53 +00:00
$OrderWay = 'asc';
} else {
$_GET['sort'] = 'desc';
$OrderWay = 'desc';
}
$NewSort = $_GET['sort'] === 'asc' ? 'desc' : 'asc';
2011-03-28 14:21:28 +00:00
2013-09-13 08:00:53 +00:00
if ($OrderBy === 'random') {
$SphQL->order_by('RAND()', '');
unset($_GET['page']);
} else {
$SphQL->order_by($SortOrders[$OrderBy], $OrderWay);
}
2011-03-28 14:21:28 +00:00
$Submitted = !empty($_GET['submit']);
2013-02-10 08:00:29 +00:00
//Paranoia
2013-09-13 08:00:53 +00:00
if (!empty($_GET['userid'])) {
if (!is_number($_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;
2013-04-15 08:00:54 +00:00
if (empty($_GET['type'])) {
2011-03-28 14:21:28 +00:00
$Title = 'Requests';
2014-03-16 08:00:50 +00:00
if (empty($_GET['showall'])) {
2013-09-13 08:00:53 +00:00
$SphQL->where('visible', 1);
2011-03-28 14:21:28 +00:00
}
} else {
2013-04-20 08:01:01 +00:00
switch ($_GET['type']) {
2011-03-28 14:21:28 +00:00
case 'created':
2013-09-13 08:00:53 +00:00
if (!empty($UserInfo)) {
if (!check_paranoia('requestsvoted_list', $UserInfo['Paranoia'], $Perms['Class'], $UserInfo['ID'])) {
error(403);
2013-04-22 08:00:58 +00:00
}
2013-09-13 08:00:53 +00:00
$Title = "Requests created by $UserInfo[Username]";
$SphQL->where('userid', $UserInfo['ID']);
2013-04-22 08:00:58 +00:00
} else {
$Title = 'My requests';
2013-09-13 08:00:53 +00:00
$SphQL->where('userid', $LoggedUser['ID']);
2013-04-22 08:00:58 +00:00
}
2011-03-28 14:21:28 +00:00
break;
case 'voted':
2013-09-13 08:00:53 +00:00
if (!empty($UserInfo)) {
if (!check_paranoia('requestsvoted_list', $UserInfo['Paranoia'], $Perms['Class'], $UserInfo['ID'])) {
error(403);
2011-03-28 14:21:28 +00:00
}
2013-09-13 08:00:53 +00:00
$Title = "Requests voted for by $UserInfo[Username]";
$SphQL->where('voter', $UserInfo['ID']);
2011-03-28 14:21:28 +00:00
} else {
2013-09-13 08:00:53 +00:00
$Title = 'Requests I have voted on';
$SphQL->where('voter', $LoggedUser['ID']);
2011-03-28 14:21:28 +00:00
}
break;
case 'filled':
2013-09-13 08:00:53 +00:00
if (!empty($UserInfo)) {
if (!check_paranoia('requestsfilled_list', $UserInfo['Paranoia'], $Perms['Class'], $UserInfo['ID'])) {
2013-04-20 08:01:01 +00:00
error(403);
}
2013-09-13 08:00:53 +00:00
$Title = "Requests filled by $UserInfo[Username]";
$SphQL->where('fillerid', $UserInfo['ID']);
} else {
$Title = 'Requests I have filled';
$SphQL->where('fillerid', $LoggedUser['ID']);
2011-03-28 14:21:28 +00:00
}
break;
case 'bookmarks':
$Title = 'Your bookmarked requests';
$BookmarkView = true;
2013-09-13 08:00:53 +00:00
$SphQL->where('bookmarker', $LoggedUser['ID']);
break;
2011-03-28 14:21:28 +00:00
default:
error(404);
}
}
2013-04-15 08:00:54 +00:00
if ($Submitted && empty($_GET['show_filled'])) {
2013-09-13 08:00:53 +00:00
$SphQL->where('torrentid', 0);
2011-03-28 14:21:28 +00:00
}
2012-09-02 08:00:26 +00:00
$EnableNegation = false; // Sphinx needs at least one positive search condition to support the NOT operator
2013-04-15 08:00:54 +00:00
if (!empty($_GET['formats'])) {
2012-09-02 08:00:26 +00:00
$FormatArray = $_GET['formats'];
2013-07-11 08:00:55 +00:00
if (count($FormatArray) !== count($Formats)) {
2012-09-02 08:00:26 +00:00
$FormatNameArray = array();
2013-04-15 08:00:54 +00:00
foreach ($FormatArray as $Index => $MasterIndex) {
if (isset($Formats[$MasterIndex])) {
2013-09-13 08:00:53 +00:00
$FormatNameArray[$Index] = '"' . strtr(Sphinxql::sph_escape_string($Formats[$MasterIndex]), '-.', ' ') . '"';
2012-09-02 08:00:26 +00:00
}
}
2013-04-15 08:00:54 +00:00
if (count($FormatNameArray) >= 1) {
2012-09-02 08:00:26 +00:00
$EnableNegation = true;
2013-04-15 08:00:54 +00:00
if (!empty($_GET['formats_strict'])) {
2013-09-13 08:00:53 +00:00
$SearchString = '(' . implode(' | ', $FormatNameArray) . ')';
2011-03-28 14:21:28 +00:00
} else {
2013-09-13 08:00:53 +00:00
$SearchString = '(any | ' . implode(' | ', $FormatNameArray) . ')';
2012-09-02 08:00:26 +00:00
}
2013-09-13 08:00:53 +00:00
$SphQL->where_match($SearchString, 'formatlist', false);
2012-09-02 08:00:26 +00:00
}
}
}
2013-04-15 08:00:54 +00:00
if (!empty($_GET['media'])) {
2012-09-02 08:00:26 +00:00
$MediaArray = $_GET['media'];
2013-07-11 08:00:55 +00:00
if (count($MediaArray) !== count($Media)) {
2012-09-02 08:00:26 +00:00
$MediaNameArray = array();
2013-04-15 08:00:54 +00:00
foreach ($MediaArray as $Index => $MasterIndex) {
if (isset($Media[$MasterIndex])) {
2013-09-13 08:00:53 +00:00
$MediaNameArray[$Index] = '"' . strtr(Sphinxql::sph_escape_string($Media[$MasterIndex]), '-.', ' ') . '"';
2012-09-02 08:00:26 +00:00
}
}
2013-04-15 08:00:54 +00:00
if (count($MediaNameArray) >= 1) {
2012-09-02 08:00:26 +00:00
$EnableNegation = true;
2013-04-15 08:00:54 +00:00
if (!empty($_GET['media_strict'])) {
2013-09-13 08:00:53 +00:00
$SearchString = '(' . implode(' | ', $MediaNameArray) . ')';
2012-09-02 08:00:26 +00:00
} else {
2013-09-13 08:00:53 +00:00
$SearchString = '(any | ' . implode(' | ', $MediaNameArray) . ')';
2011-03-28 14:21:28 +00:00
}
2013-09-13 08:00:53 +00:00
$SphQL->where_match($SearchString, 'medialist', false);
2011-03-28 14:21:28 +00:00
}
}
2012-09-02 08:00:26 +00:00
}
2013-04-15 08:00:54 +00:00
if (!empty($_GET['bitrates'])) {
2012-09-02 08:00:26 +00:00
$BitrateArray = $_GET['bitrates'];
2013-07-11 08:00:55 +00:00
if (count($BitrateArray) !== count($Bitrates)) {
2012-09-02 08:00:26 +00:00
$BitrateNameArray = array();
2013-04-15 08:00:54 +00:00
foreach ($BitrateArray as $Index => $MasterIndex) {
if (isset($Bitrates[$MasterIndex])) {
2013-09-13 08:00:53 +00:00
$BitrateNameArray[$Index] = '"' . strtr(Sphinxql::sph_escape_string($Bitrates[$MasterIndex]), '-.', ' ') . '"';
2012-09-02 08:00:26 +00:00
}
}
2013-04-15 08:00:54 +00:00
if (count($BitrateNameArray) >= 1) {
2012-09-02 08:00:26 +00:00
$EnableNegation = true;
2013-04-15 08:00:54 +00:00
if (!empty($_GET['bitrate_strict'])) {
2013-09-13 08:00:53 +00:00
$SearchString = '(' . implode(' | ', $BitrateNameArray) . ')';
2012-09-02 08:00:26 +00:00
} else {
2013-09-13 08:00:53 +00:00
$SearchString = '(any | ' . implode(' | ', $BitrateNameArray) . ')';
2012-09-02 08:00:26 +00:00
}
2013-09-13 08:00:53 +00:00
$SphQL->where_match($SearchString, 'bitratelist', false);
2012-09-02 08:00:26 +00:00
}
}
}
2013-04-15 08:00:54 +00:00
if (!empty($_GET['search'])) {
2012-09-02 08:00:26 +00:00
$SearchString = trim($_GET['search']);
2013-12-13 08:00:46 +00:00
2013-07-11 08:00:55 +00:00
if ($SearchString !== '') {
2012-09-02 08:00:26 +00:00
$SearchWords = array('include' => array(), 'exclude' => array());
$Words = explode(' ', $SearchString);
2013-04-15 08:00:54 +00:00
foreach ($Words as $Word) {
2012-09-02 08:00:26 +00:00
$Word = trim($Word);
2013-03-08 08:00:45 +00:00
// Skip isolated hyphens to enable "Artist - Title" searches
2013-07-11 08:00:55 +00:00
if ($Word === '-') {
2013-03-08 08:00:45 +00:00
continue;
}
2013-07-11 08:00:55 +00:00
if ($Word[0] === '!' && strlen($Word) >= 2) {
if (strpos($Word, '!', 1) === false) {
2012-09-02 08:00:26 +00:00
$SearchWords['exclude'][] = $Word;
} else {
$SearchWords['include'][] = $Word;
$EnableNegation = true;
}
2013-07-11 08:00:55 +00:00
} elseif ($Word !== '') {
2012-09-02 08:00:26 +00:00
$SearchWords['include'][] = $Word;
$EnableNegation = true;
}
}
2011-03-28 14:21:28 +00:00
}
}
2013-09-13 08:00:53 +00:00
if (!isset($_GET['tags_type']) || $_GET['tags_type'] === '1') {
$TagType = 1;
$_GET['tags_type'] = '1';
} else {
$TagType = 0;
$_GET['tags_type'] = '0';
}
2013-04-20 08:01:01 +00:00
if (!empty($_GET['tags'])) {
2014-04-06 08:00:49 +00:00
$SearchTags = array('include' => array(), 'exclude' => array());
$Tags = explode(',', str_replace('.', '_', $_GET['tags']));
2013-04-15 08:00:54 +00:00
foreach ($Tags as $Tag) {
2014-04-06 08:00:49 +00:00
$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;
2011-03-28 14:21:28 +00:00
}
}
2012-06-02 08:00:16 +00:00
2014-04-06 08:00:49 +00:00
$TagFilter = Tags::tag_filter_sph($SearchTags, $EnableNegation, $TagType);
$TagNames = $TagFilter['input'];
if (!empty($TagFilter['predicate'])) {
$SphQL->where_match($TagFilter['predicate'], 'taglist', false);
2012-06-02 08:00:16 +00:00
}
2014-04-06 08:00:49 +00:00
2013-07-11 08:00:55 +00:00
} elseif (!isset($_GET['tags_type']) || $_GET['tags_type'] !== '0') {
2012-09-02 08:00:26 +00:00
$_GET['tags_type'] = 1;
} else {
$_GET['tags_type'] = 0;
}
2014-04-06 08:00:49 +00:00
if (isset($SearchWords)) {
$QueryParts = array();
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);
2011-03-28 14:21:28 +00:00
}
}
2013-04-15 08:00:54 +00:00
if (!empty($_GET['filter_cat'])) {
2012-08-09 08:00:19 +00:00
$CategoryArray = array_keys($_GET['filter_cat']);
2013-07-11 08:00:55 +00:00
if (count($CategoryArray) !== count($Categories)) {
2013-04-15 08:00:54 +00:00
foreach ($CategoryArray as $Key => $Index) {
2013-07-11 08:00:55 +00:00
if (!isset($Categories[$Index - 1])) {
2012-08-09 08:00:19 +00:00
unset($CategoryArray[$Key]);
}
}
2013-04-15 08:00:54 +00:00
if (count($CategoryArray) >= 1) {
2013-09-13 08:00:53 +00:00
$SphQL->where('categoryid', $CategoryArray);
2012-08-09 08:00:19 +00:00
}
}
2011-03-28 14:21:28 +00:00
}
2013-04-15 08:00:54 +00:00
if (!empty($_GET['releases'])) {
2011-03-28 14:21:28 +00:00
$ReleaseArray = $_GET['releases'];
2013-07-11 08:00:55 +00:00
if (count($ReleaseArray) !== count($ReleaseTypes)) {
2013-04-15 08:00:54 +00:00
foreach ($ReleaseArray as $Index => $Value) {
if (!isset($ReleaseTypes[$Value])) {
2012-08-09 08:00:19 +00:00
unset($ReleaseArray[$Index]);
2011-03-28 14:21:28 +00:00
}
}
2013-04-15 08:00:54 +00:00
if (count($ReleaseArray) >= 1) {
2013-09-13 08:00:53 +00:00
$SphQL->where('releasetype', $ReleaseArray);
2012-08-09 08:00:19 +00:00
}
2011-03-28 14:21:28 +00:00
}
}
2014-03-16 08:00:50 +00:00
if (!empty($_GET['requestor'])) {
2013-04-15 08:00:54 +00:00
if (is_number($_GET['requestor'])) {
2013-09-13 08:00:53 +00:00
$SphQL->where('userid', $_GET['requestor']);
2011-03-28 14:21:28 +00:00
} else {
error(404);
}
}
2013-04-15 08:00:54 +00:00
if (isset($_GET['year'])) {
2013-07-11 08:00:55 +00:00
if (is_number($_GET['year']) || $_GET['year'] === '0') {
2013-09-13 08:00:53 +00:00
$SphQL->where('year', $_GET['year']);
2011-03-28 14:21:28 +00:00
} else {
error(404);
}
}
2013-04-15 08:00:54 +00:00
if (!empty($_GET['page']) && is_number($_GET['page']) && $_GET['page'] > 0) {
2012-08-08 08:00:12 +00:00
$Page = $_GET['page'];
2013-09-13 08:00:53 +00:00
$Offset = ($Page - 1) * REQUESTS_PER_PAGE;
$SphQL->limit($Offset, REQUESTS_PER_PAGE, $Offset + REQUESTS_PER_PAGE);
2011-03-28 14:21:28 +00:00
} else {
$Page = 1;
2013-09-13 08:00:53 +00:00
$SphQL->limit(0, REQUESTS_PER_PAGE, REQUESTS_PER_PAGE);
2011-03-28 14:21:28 +00:00
}
2013-09-13 08:00:53 +00:00
$SphQLResult = $SphQL->query();
2013-10-24 08:01:05 +00:00
$NumResults = (int)$SphQLResult->get_meta('total_found');
2013-09-13 08:00:53 +00:00
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;
2011-03-28 14:21:28 +00:00
}
2013-09-13 08:00:53 +00:00
$PageLinks = Format::get_pages($Page, $NumResults, REQUESTS_PER_PAGE);
2011-03-28 14:21:28 +00:00
}
}
2013-09-13 08:00:53 +00:00
$CurrentURL = Format::get_url(array('order', 'sort', 'page'));
2012-10-11 08:00:15 +00:00
View::show_header($Title, 'requests');
2011-03-28 14:21:28 +00:00
?>
<div class="thin">
2012-08-19 08:00:19 +00:00
<div class="header">
<h2><?=$Title?></h2>
2011-03-28 14:21:28 +00:00
</div>
2013-02-15 08:00:35 +00:00
<div class="linkbox">
<? if (!$BookmarkView) {
if (check_perms('site_submit_requests')) { ?>
<a href="requests.php?action=new" class="brackets">New request</a>
<a href="requests.php?type=created" class="brackets">My requests</a>
<? }
if (check_perms('site_vote')) { ?>
<a href="requests.php?type=voted" class="brackets">Requests I've voted on</a>
<? } ?>
<a href="bookmarks.php?type=requests" class="brackets">Bookmarked requests</a>
<? } else { ?>
<a href="bookmarks.php?type=torrents" class="brackets">Torrents</a>
<a href="bookmarks.php?type=artists" class="brackets">Artists</a>
<a href="bookmarks.php?type=collages" class="brackets">Collages</a>
<a href="bookmarks.php?type=requests" class="brackets">Requests</a>
<? } ?>
</div>
2013-10-24 08:01:05 +00:00
<? if ($BookmarkView && $NumResults === 0) { ?>
<div class="box pad" align="center">
<h2>You have not bookmarked any requests.</h2>
</div>
<? } else { ?>
2012-09-15 08:00:25 +00:00
<form class="search_form" name="requests" action="" method="get">
2013-10-24 08:01:05 +00:00
<? if ($BookmarkView) { ?>
2012-09-15 08:00:25 +00:00
<input type="hidden" name="action" value="view" />
<input type="hidden" name="type" value="requests" />
2013-10-24 08:01:05 +00:00
<? } elseif (isset($_GET['type'])) { ?>
2012-09-15 08:00:25 +00:00
<input type="hidden" name="type" value="<?=$_GET['type']?>" />
2013-10-24 08:01:05 +00:00
<? } ?>
2012-09-15 08:00:25 +00:00
<input type="hidden" name="submit" value="true" />
2013-10-24 08:01:05 +00:00
<? if (!empty($_GET['userid']) && is_number($_GET['userid'])) { ?>
2012-09-15 08:00:25 +00:00
<input type="hidden" name="userid" value="<?=$_GET['userid']?>" />
2013-10-24 08:01:05 +00:00
<? } ?>
2012-09-15 08:00:25 +00:00
<table cellpadding="6" cellspacing="1" border="0" class="layout border" width="100%">
2012-11-06 08:00:20 +00:00
<tr id="search_terms">
2012-09-15 08:00:25 +00:00
<td class="label">Search terms:</td>
<td>
2014-03-23 08:00:50 +00:00
<input type="search" name="search" size="75" value="<? if (isset($_GET['search'])) { echo display_str($_GET['search']); } ?>" />
2012-09-15 08:00:25 +00:00
</td>
</tr>
2012-11-06 08:00:20 +00:00
<tr id="tagfilter">
2012-09-15 08:00:25 +00:00
<td class="label">Tags (comma-separated):</td>
<td>
2014-04-06 08:00:49 +00:00
<input type="search" name="tags" id="tags" size="60" value="<?=!empty($TagNames) ? display_str($TagNames) : ''?>"<? Users::has_autocomplete_enabled('other'); ?> />&nbsp;
2013-07-04 08:00:56 +00:00
<input type="radio" name="tags_type" id="tags_type0" value="0"<? Format::selected('tags_type', 0, 'checked')?> /><label for="tags_type0"> Any</label>&nbsp;&nbsp;
<input type="radio" name="tags_type" id="tags_type1" value="1"<? Format::selected('tags_type', 1, 'checked')?> /><label for="tags_type1"> All</label>
2012-09-15 08:00:25 +00:00
</td>
</tr>
2012-11-06 08:00:20 +00:00
<tr id="include_filled">
2014-03-16 08:00:50 +00:00
<td class="label"><label for="include_filled_box">Include filled:</label></td>
2012-09-15 08:00:25 +00:00
<td>
2014-03-16 08:00:50 +00:00
<input type="checkbox" id="include_filled_box" name="show_filled"<? if (!$Submitted || !empty($_GET['show_filled']) || (!$Submitted && !empty($_GET['type']) && $_GET['type'] === 'filled')) { ?> checked="checked"<? } ?> />
2012-09-15 08:00:25 +00:00
</td>
</tr>
2012-11-06 08:00:20 +00:00
<tr id="include_old">
2014-03-16 08:00:50 +00:00
<td class="label"><label for="include_old_box">Include old:</label></td>
2012-09-15 08:00:25 +00:00
<td>
2014-03-16 08:00:50 +00:00
<input type="checkbox" id="include_old_box" name="showall"<? if (!empty($_GET['showall'])) { ?> checked="checked"<? } ?> />
2012-09-15 08:00:25 +00:00
</td>
</tr>
2014-03-16 08:00:50 +00:00
<? /* ?>
2012-09-15 08:00:25 +00:00
<tr>
<td class="label">Requested by:</td>
<td>
2014-03-23 08:00:50 +00:00
<input type="search" name="requester" size="75" value="<?=display_str($_GET['requester'])?>" />
2012-09-15 08:00:25 +00:00
</td>
</tr>
2014-03-16 08:00:50 +00:00
<? */ ?>
2012-09-15 08:00:25 +00:00
</table>
<table class="layout cat_list">
2011-03-28 14:21:28 +00:00
<?
2013-10-24 08:01:05 +00:00
$x = 1;
reset($Categories);
foreach ($Categories as $CatKey => $CatName) {
if ($x % 8 === 0 || $x === 1) {
2011-03-28 14:21:28 +00:00
?>
2013-09-04 08:00:43 +00:00
<tr>
2013-10-24 08:01:05 +00:00
<? } ?>
2012-09-15 08:00:25 +00:00
<td>
2013-04-15 08:00:54 +00:00
<input type="checkbox" name="filter_cat[<?=($CatKey + 1) ?>]" id="cat_<?=($CatKey + 1) ?>" value="1"<? if (isset($_GET['filter_cat'][$CatKey + 1])) { ?> checked="checked"<? } ?> />
<label for="cat_<?=($CatKey + 1) ?>"><?=$CatName?></label>
2012-09-15 08:00:25 +00:00
</td>
2013-10-24 08:01:05 +00:00
<? if ($x % 7 === 0) { ?>
2012-09-15 08:00:25 +00:00
</tr>
2011-03-28 14:21:28 +00:00
<?
2013-10-24 08:01:05 +00:00
}
$x++;
}
2011-03-28 14:21:28 +00:00
?>
2012-09-15 08:00:25 +00:00
</table>
<table class="layout">
<tr id="release_list">
2013-02-10 08:00:29 +00:00
<td class="label">Release types</td>
2012-09-15 08:00:25 +00:00
<td>
2013-07-11 08:00:55 +00:00
<input type="checkbox" id="toggle_releases" onchange="Toggle('releases', 0);"<?=(!$Submitted || !empty($ReleaseArray) && count($ReleaseArray) === count($ReleaseTypes) ? ' checked="checked"' : '') ?> /> <label for="toggle_releases">All</label>
2013-09-13 08:00:53 +00:00
<?
2013-10-24 08:01:05 +00:00
$i = 0;
foreach ($ReleaseTypes as $Key => $Val) {
if ($i % 8 === 0) {
echo '<br />';
}
2013-09-13 08:00:53 +00:00
?>
2012-09-15 08:00:25 +00:00
<input type="checkbox" name="releases[]" value="<?=$Key?>" id="release_<?=$Key?>"
2013-09-13 08:00:53 +00:00
<?=(!$Submitted || (!empty($ReleaseArray) && in_array($Key, $ReleaseArray)) ? ' checked="checked" ' : '')?>
2012-09-15 08:00:25 +00:00
/> <label for="release_<?=$Key?>"><?=$Val?></label>
2013-09-13 08:00:53 +00:00
<?
2013-10-24 08:01:05 +00:00
$i++;
}
2013-09-13 08:00:53 +00:00
?>
2012-09-15 08:00:25 +00:00
</td>
</tr>
<tr id="format_list">
<td class="label">Formats</td>
<td>
2013-07-11 08:00:55 +00:00
<input type="checkbox" id="toggle_formats" onchange="Toggle('formats', 0);"<?=(!$Submitted || !empty($FormatArray) && count($FormatArray) === count($Formats) ? ' checked="checked"' : '') ?> />
2012-09-15 08:00:25 +00:00
<label for="toggle_formats">All</label>
<input type="checkbox" id="formats_strict" name="formats_strict"<?=(!empty($_GET['formats_strict']) ? ' checked="checked"' : '')?> />
<label for="formats_strict">Only specified</label>
2013-09-13 08:00:53 +00:00
<?
2013-10-24 08:01:05 +00:00
foreach ($Formats as $Key => $Val) {
if ($Key % 8 === 0) {
echo '<br />';
}
2013-09-13 08:00:53 +00:00
?>
2012-09-15 08:00:25 +00:00
<input type="checkbox" name="formats[]" value="<?=$Key?>" id="format_<?=$Key?>"
2013-09-13 08:00:53 +00:00
<?=(!$Submitted || (!empty($FormatArray) && in_array($Key, $FormatArray)) ? ' checked="checked" ' : '')?>
2012-09-15 08:00:25 +00:00
/> <label for="format_<?=$Key?>"><?=$Val?></label>
2013-10-24 08:01:05 +00:00
<? } ?>
2012-09-15 08:00:25 +00:00
</td>
2013-02-10 08:00:29 +00:00
</tr>
2012-09-15 08:00:25 +00:00
<tr id="bitrate_list">
<td class="label">Bitrates</td>
<td>
2013-07-11 08:00:55 +00:00
<input type="checkbox" id="toggle_bitrates" onchange="Toggle('bitrates', 0);"<?=(!$Submitted || !empty($BitrateArray) && count($BitrateArray) === count($Bitrates) ? ' checked="checked"' : '')?> />
2012-09-15 08:00:25 +00:00
<label for="toggle_bitrates">All</label>
2013-04-15 08:00:54 +00:00
<input type="checkbox" id="bitrate_strict" name="bitrate_strict"<?=(!empty($_GET['bitrate_strict']) ? ' checked="checked"' : '') ?> />
2012-09-15 08:00:25 +00:00
<label for="bitrate_strict">Only specified</label>
2013-09-13 08:00:53 +00:00
<?
2013-10-24 08:01:05 +00:00
foreach ($Bitrates as $Key => $Val) {
if ($Key % 8 === 0) {
echo '<br />';
}
2013-09-13 08:00:53 +00:00
?>
2012-09-15 08:00:25 +00:00
<input type="checkbox" name="bitrates[]" value="<?=$Key?>" id="bitrate_<?=$Key?>"
2013-09-13 08:00:53 +00:00
<?=(!$Submitted || (!empty($BitrateArray) && in_array($Key, $BitrateArray)) ? ' checked="checked" ' : '')?>
2012-09-15 08:00:25 +00:00
/> <label for="bitrate_<?=$Key?>"><?=$Val?></label>
2013-09-13 08:00:53 +00:00
<?
2013-10-24 08:01:05 +00:00
}
2013-09-13 08:00:53 +00:00
?>
2012-09-15 08:00:25 +00:00
</td>
</tr>
<tr id="media_list">
<td class="label">Media</td>
<td>
2013-07-11 08:00:55 +00:00
<input type="checkbox" id="toggle_media" onchange="Toggle('media', 0);"<?=(!$Submitted || !empty($MediaArray) && count($MediaArray) === count($Media) ? ' checked="checked"' : '')?> />
2012-09-15 08:00:25 +00:00
<label for="toggle_media">All</label>
<input type="checkbox" id="media_strict" name="media_strict"<?=(!empty($_GET['media_strict']) ? ' checked="checked"' : '')?> />
<label for="media_strict">Only specified</label>
2013-09-13 08:00:53 +00:00
<?
2013-10-24 08:01:05 +00:00
foreach ($Media as $Key => $Val) {
if ($Key % 8 === 0) {
echo '<br />';
}
2013-09-13 08:00:53 +00:00
?>
2012-09-15 08:00:25 +00:00
<input type="checkbox" name="media[]" value="<?=$Key?>" id="media_<?=$Key?>"
2013-09-13 08:00:53 +00:00
<?=(!$Submitted || (!empty($MediaArray) && in_array($Key, $MediaArray)) ? ' checked="checked" ' : '')?>
2012-09-15 08:00:25 +00:00
/> <label for="media_<?=$Key?>"><?=$Val?></label>
2013-10-24 08:01:05 +00:00
<? } ?>
2012-09-15 08:00:25 +00:00
</td>
</tr>
<tr>
<td colspan="2" class="center">
<input type="submit" value="Search requests" />
</td>
</tr>
2013-02-10 08:00:29 +00:00
</table>
2012-09-15 08:00:25 +00:00
</form>
2013-10-24 08:01:05 +00:00
<? if (isset($PageLinks)) { ?>
2011-03-28 14:21:28 +00:00
<div class="linkbox">
2013-10-24 08:01:05 +00:00
<?= $PageLinks?>
2011-03-28 14:21:28 +00:00
</div>
2013-10-24 08:01:05 +00:00
<? } ?>
2012-09-15 08:00:25 +00:00
<table id="request_table" class="request_table border" cellpadding="6" cellspacing="1" border="0" width="100%">
2011-03-28 14:21:28 +00:00
<tr class="colhead_dark">
2011-11-13 08:00:16 +00:00
<td style="width: 38%;" class="nobr">
2013-09-13 08:00:53 +00:00
<strong>Request Name</strong> / <a href="?order=year&amp;sort=<?=($OrderBy === 'year' ? $NewSort : 'desc')?>&amp;<?=$CurrentURL?>"><strong>Year</strong></a>
2011-03-28 14:21:28 +00:00
</td>
2011-11-13 08:00:16 +00:00
<td class="nobr">
2013-09-13 08:00:53 +00:00
<a href="?order=votes&amp;sort=<?=($OrderBy === 'votes' ? $NewSort : 'desc')?>&amp;<?=$CurrentURL?>"><strong>Votes</strong></a>
2011-03-28 14:21:28 +00:00
</td>
2011-11-13 08:00:16 +00:00
<td class="nobr">
2013-09-13 08:00:53 +00:00
<a href="?order=bounty&amp;sort=<?=($OrderBy === 'bounty' ? $NewSort : 'desc')?>&amp;<?=$CurrentURL?>"><strong>Bounty</strong></a>
2011-03-28 14:21:28 +00:00
</td>
2011-11-13 08:00:16 +00:00
<td class="nobr">
2013-09-13 08:00:53 +00:00
<a href="?order=filled&amp;sort=<?=($OrderBy === 'filled' ? $NewSort : 'desc')?>&amp;<?=$CurrentURL?>"><strong>Filled</strong></a>
2011-03-28 14:21:28 +00:00
</td>
2011-11-13 08:00:16 +00:00
<td class="nobr">
2011-03-28 14:21:28 +00:00
<strong>Filled by</strong>
</td>
2011-11-13 08:00:16 +00:00
<td class="nobr">
2011-03-28 14:21:28 +00:00
<strong>Requested by</strong>
</td>
2011-11-13 08:00:16 +00:00
<td class="nobr">
2013-09-13 08:00:53 +00:00
<a href="?order=created&amp;sort=<?=($OrderBy === 'created' ? $NewSort : 'desc')?>&amp;<?=$CurrentURL?>"><strong>Created</strong></a>
2011-03-28 14:21:28 +00:00
</td>
2011-11-13 08:00:16 +00:00
<td class="nobr">
2013-09-13 08:00:53 +00:00
<a href="?order=lastvote&amp;sort=<?=($OrderBy === 'lastvote' ? $NewSort : 'desc')?>&amp;<?=$CurrentURL?>"><strong>Last vote</strong></a>
2011-03-28 14:21:28 +00:00
</td>
</tr>
2013-10-24 08:01:05 +00:00
<?
if ($NumResults === 0) {
// not viewing bookmarks but no requests found
?>
2011-03-28 14:21:28 +00:00
<tr class="rowb">
<td colspan="8">
Nothing found!
</td>
</tr>
2013-10-24 08:01:05 +00:00
<? } elseif ($Page === 0) { ?>
2012-08-08 08:00:12 +00:00
<tr class="rowb">
<td colspan="8">
The requested page contains no matches!
</td>
</tr>
2013-10-24 08:01:05 +00:00
<?
} else {
2013-09-13 08:00:53 +00:00
$TimeCompare = 1267643718; // Requests v2 was implemented 2010-03-03 20:15:18
$Requests = Requests::get_requests(array_keys($SphRequests));
2014-02-19 08:00:32 +00:00
foreach ($Requests as $RequestID => $Request) {
$SphRequest = $SphRequests[$RequestID];
2013-09-13 08:00:53 +00:00
$Bounty = $SphRequest['bounty'] * 1024; // Sphinx stores bounty in kB
$VoteCount = $SphRequest['votes'];
if ($Request['CategoryID'] == 0) {
$CategoryName = 'Unknown';
} else {
$CategoryName = $Categories[$Request['CategoryID'] - 1];
2012-08-08 08:00:12 +00:00
}
2013-09-13 08:00:53 +00:00
if ($Request['TorrentID'] != 0) {
$IsFilled = true;
$FillerInfo = Users::user_info($Request['FillerID']);
} else {
$IsFilled = false;
2012-08-08 08:00:12 +00:00
}
2013-02-10 08:00:29 +00:00
2013-09-13 08:00:53 +00:00
if ($CategoryName === 'Music') {
$ArtistForm = Requests::get_artists($RequestID);
$ArtistLink = Artists::display_artists($ArtistForm, true, true);
2014-04-22 08:00:44 +00:00
$FullName = "$ArtistLink<a href=\"requests.php?action=view&amp;id=$RequestID\"><span dir=\"ltr\">$Request[Title]</span> [$Request[Year]]</a>";
2013-09-13 08:00:53 +00:00
} elseif ($CategoryName === 'Audiobooks' || $CategoryName === 'Comedy') {
2014-04-22 08:00:44 +00:00
$FullName = "<a href=\"requests.php?action=view&amp;id=$RequestID\"><span dir=\"ltr\">$Request[Title]</span> [$Request[Year]]</a>";
2013-09-13 08:00:53 +00:00
} else {
2014-04-22 08:00:44 +00:00
$FullName = "<a href=\"requests.php?action=view&amp;id=$RequestID\" dir=\"ltr\">$Request[Title]</a>";
2013-09-13 08:00:53 +00:00
}
$Tags = $Request['Tags'];
2011-03-28 14:21:28 +00:00
?>
2013-09-13 08:00:53 +00:00
<tr class="row<?=($i % 2 ? 'b' : 'a')?>">
2011-03-28 14:21:28 +00:00
<td>
<?=$FullName?>
<div class="tags">
2013-02-10 08:00:29 +00:00
<?
2013-09-13 08:00:53 +00:00
$TagList = array();
foreach ($Request['Tags'] as $TagID => $TagName) {
2013-09-20 08:00:56 +00:00
$TagList[] = '<a href="?tags='.$TagName.($BookmarkView ? '&amp;type=requests' : '').'">'.display_str($TagName).'</a>';
2013-09-13 08:00:53 +00:00
}
$TagList = implode(', ', $TagList);
2011-03-28 14:21:28 +00:00
?>
<?=$TagList?>
</div>
</td>
2011-11-13 08:00:16 +00:00
<td class="nobr">
2013-02-15 08:00:35 +00:00
<span id="vote_count_<?=$RequestID?>"><?=number_format($VoteCount)?></span>
2013-09-13 08:00:53 +00:00
<? if (!$IsFilled && check_perms('site_vote')) { ?>
2013-02-20 08:00:33 +00:00
&nbsp;&nbsp; <a href="javascript:Vote(0, <?=$RequestID?>)" class="brackets"><strong>+</strong></a>
2013-09-13 08:00:53 +00:00
<? } ?>
2011-03-28 14:21:28 +00:00
</td>
2013-08-28 23:08:41 +00:00
<td class="number_column nobr">
2013-09-13 08:00:53 +00:00
<?=Format::get_size($Bounty)?>
2011-03-28 14:21:28 +00:00
</td>
2013-10-24 08:01:05 +00:00
<td class="nobr">
2013-09-13 08:00:53 +00:00
<? if ($IsFilled) { ?>
2013-10-24 08:01:05 +00:00
<a href="torrents.php?<?=(strtotime($Request['TimeFilled']) < $TimeCompare ? 'id=' : 'torrentid=') . $Request['TorrentID']?>"><strong><?=time_diff($Request['TimeFilled'], 1)?></strong></a>
2013-09-13 08:00:53 +00:00
<? } else { ?>
2011-03-28 14:21:28 +00:00
<strong>No</strong>
2013-09-13 08:00:53 +00:00
<? } ?>
2011-03-28 14:21:28 +00:00
</td>
<td>
2013-09-13 08:00:53 +00:00
<? if ($IsFilled) { ?>
<a href="user.php?id=<?=$FillerInfo['ID']?>"><?=$FillerInfo['Username']?></a>
<? } else { ?>
2013-06-15 08:00:45 +00:00
&mdash;
2013-09-13 08:00:53 +00:00
<? } ?>
2011-03-28 14:21:28 +00:00
</td>
<td>
2013-09-13 08:00:53 +00:00
<a href="user.php?id=<?=$Request['UserID']?>"><?=Users::format_username($Request['UserID'], false, false, false)?></a>
2011-03-28 14:21:28 +00:00
</td>
2013-10-24 08:01:05 +00:00
<td class="nobr">
<?=time_diff($Request['TimeAdded'], 1)?>
2011-03-28 14:21:28 +00:00
</td>
2013-10-24 08:01:05 +00:00
<td class="nobr">
<?=time_diff($Request['LastVote'], 1)?>
2011-03-28 14:21:28 +00:00
</td>
</tr>
<?
2013-09-13 08:00:53 +00:00
} // foreach
2013-10-24 08:01:05 +00:00
} // else
} // if ($BookmarkView && $NumResults < 1)
2011-03-28 14:21:28 +00:00
?>
</table>
2013-09-13 08:00:53 +00:00
<? if (isset($PageLinks)) { ?>
2011-03-28 14:21:28 +00:00
<div class="linkbox">
<?=$PageLinks?>
</div>
2013-09-13 08:00:53 +00:00
<? } ?>
2011-03-28 14:21:28 +00:00
</div>
2013-05-21 08:01:09 +00:00
<? View::show_footer(); ?>