Gazelle/sections/requests/requests.php

682 lines
22 KiB
PHP
Raw Normal View History

2013-05-28 08:01:02 +00:00
<?php
2011-03-28 14:21:28 +00:00
$Queries = array();
$OrderWays = array('year', 'votes', 'bounty', 'created', 'lastvote', 'filled');
2013-05-28 08:01:02 +00:00
list($Page, $Limit) = Format::page_limit(REQUESTS_PER_PAGE);
2011-03-28 14:21:28 +00:00
$Submitted = !empty($_GET['submit']);
2013-02-10 08:00:29 +00:00
//Paranoia
2012-10-11 08:00:15 +00:00
$UserInfo = Users::user_info((int)$_GET['userid']);
$Perms = Permissions::get_permissions($UserInfo['PermissionID']);
2011-03-28 14:21:28 +00:00
$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';
2013-04-15 08:00:54 +00:00
if (!check_perms('site_see_old_requests') || empty($_GET['showall'])) {
2011-03-28 14:21:28 +00:00
$SS->set_filter('visible', array(1));
}
} else {
2013-04-20 08:01:01 +00:00
switch ($_GET['type']) {
2011-03-28 14:21:28 +00:00
case 'created':
2013-04-22 08:00:58 +00:00
if (!empty($_GET['userid'])) {
if (is_number($_GET['userid'])) {
if (!check_paranoia('requestsvoted_list', $UserInfo['Paranoia'], $Perms['Class'], $_GET['userid'])) {
error(403);
}
$Title = 'Requests created by ' . $UserInfo['Username'];
$SS->set_filter('userid', array($_GET['userid']));
} else {
error(404);
}
} else {
$Title = 'My requests';
$SS->set_filter('userid', array($LoggedUser['ID']));
}
2011-03-28 14:21:28 +00:00
break;
case 'voted':
2013-04-15 08:00:54 +00:00
if (!empty($_GET['userid'])) {
if (is_number($_GET['userid'])) {
2013-04-20 08:01:01 +00:00
if (!check_paranoia('requestsvoted_list', $UserInfo['Paranoia'], $Perms['Class'], $_GET['userid'])) {
error(403);
}
2011-03-28 14:21:28 +00:00
$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':
2013-04-15 08:00:54 +00:00
if (empty($_GET['userid']) || !is_number($_GET['userid'])) {
2011-03-28 14:21:28 +00:00
error(404);
} else {
2013-04-20 08:01:01 +00:00
if (!check_paranoia('requestsfilled_list', $UserInfo['Paranoia'], $Perms['Class'], $_GET['userid'])) {
error(403);
}
2011-03-28 14:21:28 +00:00
$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;
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'])) {
2011-03-28 14:21:28 +00:00
$SS->set_filter('torrentid', array(0));
}
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-04-15 08:00:54 +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])) {
2012-09-02 08:00:26 +00:00
$FormatNameArray[$Index] = '"'.strtr($Formats[$MasterIndex], '-.', ' ').'"';
}
}
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'])) {
2012-09-02 08:00:26 +00:00
$Queries[]='@formatlist ('.implode(' | ', $FormatNameArray).')';
2011-03-28 14:21:28 +00:00
} else {
2012-09-02 08:00:26 +00:00
$Queries[]='@formatlist (any | '.implode(' | ', $FormatNameArray).')';
}
}
}
}
2013-04-15 08:00:54 +00:00
if (!empty($_GET['media'])) {
2012-09-02 08:00:26 +00:00
$MediaArray = $_GET['media'];
2013-04-15 08:00:54 +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])) {
2012-09-02 08:00:26 +00:00
$MediaNameArray[$Index] = '"'.strtr($Media[$MasterIndex], '-.', ' ').'"';
}
}
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'])) {
2012-09-02 08:00:26 +00:00
$Queries[]='@medialist ('.implode(' | ', $MediaNameArray).')';
} else {
$Queries[]='@medialist (any | '.implode(' | ', $MediaNameArray).')';
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-04-15 08:00:54 +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])) {
2012-09-02 08:00:26 +00:00
$BitrateNameArray[$Index] = '"'.strtr($SS->EscapeString($Bitrates[$MasterIndex]), '-.', ' ').'"';
}
}
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'])) {
2012-09-02 08:00:26 +00:00
$Queries[]='@bitratelist ('.implode(' | ', $BitrateNameArray).')';
} else {
$Queries[]='@bitratelist (any | '.implode(' | ', $BitrateNameArray).')';
}
}
}
}
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-04-15 08:00:54 +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
if ($Word == '-') {
continue;
}
2013-04-15 08:00:54 +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-04-15 08:00:54 +00:00
} elseif ($Word != '') {
2012-09-02 08:00:26 +00:00
$SearchWords['include'][] = $Word;
$EnableNegation = true;
}
}
$QueryParts = array();
2013-04-15 08:00:54 +00:00
if (!$EnableNegation && !empty($SearchWords['exclude'])) {
2012-09-02 08:00:26 +00:00
$SearchWords['include'] = array_merge($SearchWords['include'], $SearchWords['exclude']);
unset($SearchWords['exclude']);
}
2013-04-15 08:00:54 +00:00
foreach ($SearchWords['include'] as $Word) {
2012-09-02 08:00:26 +00:00
$QueryParts[] = $SS->EscapeString($Word);
}
2013-04-15 08:00:54 +00:00
if (!empty($SearchWords['exclude'])) {
foreach ($SearchWords['exclude'] as $Word) {
2012-09-02 08:00:26 +00:00
$QueryParts[] = '!'.$SS->EscapeString(substr($Word,1));
}
}
2013-04-15 08:00:54 +00:00
if (!empty($QueryParts)) {
2012-09-02 08:00:26 +00:00
$Queries[] = "@* ".implode(' ', $QueryParts);
}
2011-03-28 14:21:28 +00:00
}
}
2013-04-20 08:01:01 +00:00
if (!empty($_GET['tags'])) {
2011-03-28 14:21:28 +00:00
$Tags = explode(',', $_GET['tags']);
$TagNames = array();
2013-04-15 08:00:54 +00:00
if (!isset($_GET['tags_type']) || $_GET['tags_type'] == 1) {
2012-09-02 08:00:26 +00:00
$TagType = 1;
$_GET['tags_type'] = '1';
} else {
$TagType = 0;
$_GET['tags_type'] = '0';
}
2013-04-15 08:00:54 +00:00
foreach ($Tags as $Tag) {
2012-06-02 08:00:16 +00:00
$Tag = ltrim($Tag);
2012-09-02 08:00:26 +00:00
$Exclude = ($Tag[0] == '!');
2012-10-11 08:00:15 +00:00
$Tag = Misc::sanitize_tag($Tag);
2013-04-15 08:00:54 +00:00
if (!empty($Tag)) {
2011-03-28 14:21:28 +00:00
$TagNames[] = $Tag;
2012-06-02 08:00:16 +00:00
$TagsExclude[$Tag] = $Exclude;
2011-03-28 14:21:28 +00:00
}
}
2012-09-02 08:00:26 +00:00
$AllNegative = !in_array(false, $TagsExclude);
2012-10-11 08:00:15 +00:00
$Tags = Misc::get_tags($TagNames);
2012-06-02 08:00:16 +00:00
// Replace the ! characters that sanitize_tag removed
2013-04-15 08:00:54 +00:00
if ($TagType == 1 || $AllNegative) {
foreach ($TagNames as &$TagName) {
if ($TagsExclude[$TagName]) {
2012-09-02 08:00:26 +00:00
$TagName = '!'.$TagName;
}
2012-06-02 08:00:16 +00:00
}
2012-09-02 08:00:26 +00:00
unset($TagName);
2012-06-02 08:00:16 +00:00
}
2013-04-15 08:00:54 +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;
}
2012-09-02 08:00:26 +00:00
// 'All' tags
2013-04-15 08:00:54 +00:00
if ($TagType == 1 && !empty($Tags)) {
foreach ($Tags as $TagID => $TagName) {
2012-06-02 08:00:16 +00:00
$SS->set_filter('tagid', array($TagID), $TagsExclude[$TagName]);
2011-03-28 14:21:28 +00:00
}
2013-04-15 08:00:54 +00:00
} elseif (!empty($Tags)) {
2012-09-02 08:00:26 +00:00
$SS->set_filter('tagid', array_keys($Tags), $AllNegative);
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']);
$Debug->log_var(array($CategoryArray, $Categories));
2013-04-15 08:00:54 +00:00
if (count($CategoryArray) != count($Categories)) {
foreach ($CategoryArray as $Key => $Index) {
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) {
2012-08-09 08:00:19 +00:00
$SS->set_filter('categoryid', $CategoryArray);
}
}
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-04-15 08:00:54 +00:00
if (count($ReleaseArray) != count($ReleaseTypes)) {
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) {
2012-08-09 08:00:19 +00:00
$SS->set_filter('releasetype', $ReleaseArray);
}
2011-03-28 14:21:28 +00:00
}
}
2013-04-15 08:00:54 +00:00
if (!empty($_GET['requestor']) && check_perms('site_see_old_requests')) {
if (is_number($_GET['requestor'])) {
2011-03-28 14:21:28 +00:00
$SS->set_filter('userid', array($_GET['requestor']));
} else {
error(404);
}
}
2013-04-15 08:00:54 +00:00
if (isset($_GET['year'])) {
if (is_number($_GET['year']) || $_GET['year'] == 0) {
2011-03-28 14:21:28 +00:00
$SS->set_filter('year', array($_GET['year']));
} 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'];
$SS->limit(($Page - 1) * REQUESTS_PER_PAGE, REQUESTS_PER_PAGE);
2011-03-28 14:21:28 +00:00
} else {
$Page = 1;
2012-08-08 08:00:12 +00:00
$SS->limit(0, REQUESTS_PER_PAGE);
2011-03-28 14:21:28 +00:00
}
2013-04-15 08:00:54 +00:00
if (empty($_GET['order'])) {
2011-03-28 14:21:28 +00:00
$CurrentOrder = 'created';
$CurrentSort = 'desc';
$Way = SPH_SORT_ATTR_DESC;
$NewSort = 'asc';
} else {
2013-04-15 08:00:54 +00:00
if (in_array($_GET['order'], $OrderWays)) {
2011-03-28 14:21:28 +00:00
$CurrentOrder = $_GET['order'];
2013-04-15 08:00:54 +00:00
if ($_GET['sort'] == 'asc' || $_GET['sort'] == 'desc') {
2011-03-28 14:21:28 +00:00
$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);
}
}
2013-05-01 08:00:16 +00:00
switch ($CurrentOrder) {
2011-03-28 14:21:28 +00:00
case 'votes' :
2013-05-01 08:00:16 +00:00
$OrderBy = 'Votes';
2011-03-28 14:21:28 +00:00
break;
case 'bounty' :
2013-05-01 08:00:16 +00:00
$OrderBy = 'Bounty';
2011-03-28 14:21:28 +00:00
break;
case 'created' :
2013-05-01 08:00:16 +00:00
$OrderBy = 'TimeAdded';
2011-03-28 14:21:28 +00:00
break;
case 'lastvote' :
2013-05-01 08:00:16 +00:00
$OrderBy = 'LastVote';
2011-03-28 14:21:28 +00:00
break;
case 'filled' :
2013-05-01 08:00:16 +00:00
$OrderBy = 'TimeFilled';
2011-03-28 14:21:28 +00:00
break;
case 'year' :
2013-05-01 08:00:16 +00:00
$OrderBy = 'Year';
2011-03-28 14:21:28 +00:00
break;
default :
2013-05-01 08:00:16 +00:00
$OrderBy = 'TimeAdded';
2011-03-28 14:21:28 +00:00
break;
}
//print($Way); print($OrderBy); die();
$SS->SetSortMode($Way, $OrderBy);
2013-04-15 08:00:54 +00:00
if (count($Queries) > 0) {
2011-03-28 14:21:28 +00:00
$Query = implode(' ',$Queries);
} else {
2013-05-14 08:00:34 +00:00
$Query = '';
2011-03-28 14:21:28 +00:00
}
$SS->set_index('requests requests_delta');
$SphinxResults = $SS->search($Query, '', 0, array(), '', '');
$NumResults = $SS->TotalResults;
2013-04-15 08:00:54 +00:00
if ($NumResults && $NumResults < ($Page - 1) * REQUESTS_PER_PAGE + 1) {
2012-10-11 08:00:15 +00:00
$PageLinks = Format::get_pages(0, $NumResults, REQUESTS_PER_PAGE);
2012-08-08 08:00:12 +00:00
} else {
2012-10-11 08:00:15 +00:00
$PageLinks = Format::get_pages($Page, $NumResults, REQUESTS_PER_PAGE);
2011-03-28 14:21:28 +00:00
}
2012-10-11 08:00:15 +00:00
$CurrentURL = Format::get_url(array('order', 'sort'));
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>
2012-09-15 08:00:25 +00:00
<form class="search_form" name="requests" action="" method="get">
<? if ($BookmarkView) { ?>
2012-09-15 08:00:25 +00:00
<input type="hidden" name="action" value="view" />
<input type="hidden" name="type" value="requests" />
<? } else { ?>
2012-09-15 08:00:25 +00:00
<input type="hidden" name="type" value="<?=$_GET['type']?>" />
<? } ?>
2012-09-15 08:00:25 +00:00
<input type="hidden" name="submit" value="true" />
2013-04-15 08:00:54 +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']?>" />
2011-03-28 14:21:28 +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>
2013-04-15 08:00:54 +00:00
<input type="text" 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>
<input type="text" name="tags" size="60" value="<?= (!empty($TagNames) ? display_str(implode(', ', $TagNames)) : '') ?>" />&nbsp;
2013-05-01 08:00:16 +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">
2012-09-15 08:00:25 +00:00
<td class="label">Include filled:</td>
<td>
2013-04-15 08:00:54 +00:00
<input type="checkbox" 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>
2013-04-20 08:01:01 +00:00
<? if (check_perms('site_see_old_requests')) { ?>
2012-11-06 08:00:20 +00:00
<tr id="include_old">
2012-09-15 08:00:25 +00:00
<td class="label">Include old:</td>
<td>
2013-04-15 08:00:54 +00:00
<input type="checkbox" name="showall"<? if (!empty($_GET['showall'])) { ?> checked="checked"<? } ?> />
2012-09-15 08:00:25 +00:00
</td>
</tr>
2013-02-10 08:00:29 +00:00
<? /* ?>
2012-09-15 08:00:25 +00:00
<tr>
<td class="label">Requested by:</td>
<td>
<input type="text" name="requester" size="75" value="<?=display_str($_GET['requester'])?>" />
</td>
</tr>
2011-03-28 14:21:28 +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-04-15 08:00:54 +00:00
$x = 1;
2011-03-28 14:21:28 +00:00
reset($Categories);
2013-04-15 08:00:54 +00:00
foreach ($Categories as $CatKey => $CatName) {
if ($x % 8 == 0 || $x == 1) {
2011-03-28 14:21:28 +00:00
?>
2012-09-15 08:00:25 +00:00
<tr class="cat_list">
2011-03-28 14:21:28 +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>
2011-03-28 14:21:28 +00:00
<?
2013-04-15 08:00:54 +00:00
if ($x % 7 == 0) {
2011-03-28 14:21:28 +00:00
?>
2012-09-15 08:00:25 +00:00
</tr>
2011-03-28 14:21:28 +00:00
<?
}
$x++;
}
?>
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-04-15 08:00:54 +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>
2011-03-28 14:21:28 +00:00
<? $i = 0;
foreach ($ReleaseTypes as $Key => $Val) {
2013-04-15 08:00:54 +00:00
if ($i % 8 == 0) {
echo '<br />';
} ?>
2012-09-15 08:00:25 +00:00
<input type="checkbox" name="releases[]" value="<?=$Key?>" id="release_<?=$Key?>"
<?=(((!$Submitted) || !empty($ReleaseArray) && in_array($Key, $ReleaseArray)) ? ' checked="checked" ' : '')?>
/> <label for="release_<?=$Key?>"><?=$Val?></label>
2011-03-28 14:21:28 +00:00
<? $i++;
2013-04-15 08:00:54 +00:00
} ?>
2012-09-15 08:00:25 +00:00
</td>
</tr>
<tr id="format_list">
<td class="label">Formats</td>
<td>
2013-04-15 08:00:54 +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>
2011-03-28 14:21:28 +00:00
<? foreach ($Formats as $Key => $Val) {
2013-04-15 08:00:54 +00:00
if ($Key % 8 == 0) {
echo '<br />';
} ?>
2012-09-15 08:00:25 +00:00
<input type="checkbox" name="formats[]" value="<?=$Key?>" id="format_<?=$Key?>"
<?=(((!$Submitted) || !empty($FormatArray) && in_array($Key, $FormatArray)) ? ' checked="checked" ' : '')?>
/> <label for="format_<?=$Key?>"><?=$Val?></label>
2013-04-15 08:00:54 +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>
<input type="checkbox" id="toggle_bitrates" onchange="Toggle('bitrates', 0);"<?=(!$Submitted || !empty($BitrateArray) && count($BitrateArray) == count($Bitrates) ? ' checked="checked"' : '')?> />
<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>
2011-03-28 14:21:28 +00:00
<? foreach ($Bitrates as $Key => $Val) {
2013-04-15 08:00:54 +00:00
if ($Key % 8 == 0) {
echo '<br />';
} ?>
2012-09-15 08:00:25 +00:00
<input type="checkbox" name="bitrates[]" value="<?=$Key?>" id="bitrate_<?=$Key?>"
<?=(((!$Submitted) || !empty($BitrateArray) && in_array($Key, $BitrateArray)) ? ' checked="checked" ' : '')?>
/> <label for="bitrate_<?=$Key?>"><?=$Val?></label>
2013-04-15 08:00:54 +00:00
<? } ?>
2012-09-15 08:00:25 +00:00
</td>
</tr>
<tr id="media_list">
<td class="label">Media</td>
<td>
<input type="checkbox" id="toggle_media" onchange="Toggle('media', 0);"<?=(!$Submitted || !empty($MediaArray) && count($MediaArray) == count($Media) ? ' checked="checked"' : '')?> />
<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>
2011-03-28 14:21:28 +00:00
<? foreach ($Media as $Key => $Val) {
2013-04-15 08:00:54 +00:00
if ($Key % 8 == 0) {
echo '<br />';
} ?>
2012-09-15 08:00:25 +00:00
<input type="checkbox" name="media[]" value="<?=$Key?>" id="media_<?=$Key?>"
<?=(((!$Submitted) || !empty($MediaArray) && in_array($Key, $MediaArray)) ? ' checked="checked" ' : '')?>
/> <label for="media_<?=$Key?>"><?=$Val?></label>
2013-04-15 08:00:54 +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>
2012-08-08 08:00:12 +00:00
2013-04-15 08:00:54 +00:00
<? if ($NumResults) { ?>
2011-03-28 14:21:28 +00:00
<div class="linkbox">
<?=$PageLinks?>
</div>
2012-08-08 08:00:12 +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-02-10 08:00:29 +00:00
<strong>Request name</strong> / <a href="?order=year&amp;sort=<?=(($CurrentOrder == '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">
2011-09-13 08:00:15 +00:00
<a href="?order=votes&amp;sort=<?=(($CurrentOrder == '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">
2011-09-13 08:00:15 +00:00
<a href="?order=bounty&amp;sort=<?=(($CurrentOrder == '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">
2011-09-13 08:00:15 +00:00
<a href="?order=filled&amp;sort=<?=(($CurrentOrder == '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">
2011-09-13 08:00:15 +00:00
<a href="?order=created&amp;sort=<?=(($CurrentOrder == '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-02-10 08:00:29 +00:00
<a href="?order=lastvote&amp;sort=<?=(($CurrentOrder == 'lastvote') ? $NewSort : 'desc')?>&amp;<?=$CurrentURL ?>"><strong>Last vote</strong></a>
2011-03-28 14:21:28 +00:00
</td>
</tr>
2013-04-15 08:00:54 +00:00
<? if ($NumResults == 0) { ?>
2011-03-28 14:21:28 +00:00
<tr class="rowb">
<td colspan="8">
Nothing found!
</td>
</tr>
2013-04-15 08:00:54 +00:00
<? } elseif ($NumResults < ($Page - 1) * REQUESTS_PER_PAGE + 1) { ?>
2012-08-08 08:00:12 +00:00
<tr class="rowb">
<td colspan="8">
The requested page contains no matches!
</td>
</tr>
2011-03-28 14:21:28 +00:00
<? } else {
2012-08-08 08:00:12 +00:00
//We don't use sphinxapi's default cache searcher, we use our own functions
2013-04-15 08:00:54 +00:00
if (!empty($SphinxResults['notfound'])) {
2012-10-11 08:00:15 +00:00
$SQLResults = Requests::get_requests($SphinxResults['notfound']);
2013-04-15 08:00:54 +00:00
if (is_array($SQLResults['notfound'])) {
2012-08-08 08:00:12 +00:00
//Something wasn't found in the db, remove it from results
reset($SQLResults['notfound']);
2013-04-15 08:00:54 +00:00
foreach ($SQLResults['notfound'] as $ID) {
2012-08-08 08:00:12 +00:00
unset($SQLResults['matches'][$ID]);
unset($SphinxResults['matches'][$ID]);
}
}
// Merge SQL results with memcached results
2013-04-15 08:00:54 +00:00
foreach ($SQLResults['matches'] as $ID => $SQLResult) {
2012-08-08 08:00:12 +00:00
$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]);
}
}
$Requests = $SphinxResults['matches'];
2011-03-28 14:21:28 +00:00
$Row = 'a';
$TimeCompare = 1267643718; // Requests v2 was implemented 2010-03-03 20:15:18
foreach ($Requests as $RequestID => $Request) {
2013-02-10 08:00:29 +00:00
//list($BitrateList, $CatalogueNumber, $CategoryID, $Description, $FillerID, $FormatList, $RequestID, $Image, $LogCue, $MediaList, $ReleaseType,
// $Tags, $TimeAdded, $TimeFilled, $Title, $TorrentID, $RequestorID, $RequestorName, $Year, $RequestID, $Categoryid, $FillerID, $LastVote,
2011-03-28 14:21:28 +00:00
// $ReleaseType, $TagIDs, $TimeAdded, $TimeFilled, $TorrentID, $RequestorID, $Voters) = array_values($Request);
2013-02-10 08:00:29 +00:00
2012-02-04 08:00:25 +00:00
list($RequestID, $RequestorID, $RequestorName, $TimeAdded, $LastVote, $CategoryID, $Title, $Year, $Image, $Description, $CatalogueNumber, $RecordLabel,
2011-03-28 14:21:28 +00:00
$ReleaseType, $BitrateList, $FormatList, $MediaList, $LogCue, $FillerID, $FillerName, $TorrentID, $TimeFilled) = $Request;
2013-02-10 08:00:29 +00:00
2013-05-13 08:00:33 +00:00
$RequestVotes = Requests::get_votes_array($RequestID);
2013-02-10 08:00:29 +00:00
2011-03-28 14:21:28 +00:00
$VoteCount = count($RequestVotes['Voters']);
2013-02-10 08:00:29 +00:00
2013-04-15 08:00:54 +00:00
if ($CategoryID == 0) {
$CategoryName = 'Unknown';
2011-03-28 14:21:28 +00:00
} else {
$CategoryName = $Categories[$CategoryID - 1];
}
2013-02-10 08:00:29 +00:00
2011-03-28 14:21:28 +00:00
$IsFilled = ($TorrentID != 0);
2013-02-10 08:00:29 +00:00
2013-04-15 08:00:54 +00:00
if ($CategoryName == 'Music') {
2013-05-13 08:00:33 +00:00
$ArtistForm = Requests::get_artists($RequestID);
2012-10-11 08:00:15 +00:00
$ArtistLink = Artists::display_artists($ArtistForm, true, true);
2013-04-15 08:00:54 +00:00
$FullName = $ArtistLink."<a href=\"requests.php?action=view&amp;id=".$RequestID."\">$Title [$Year]</a>";
} elseif ($CategoryName == 'Audiobooks' || $CategoryName == 'Comedy') {
$FullName = "<a href=\"requests.php?action=view&amp;id=".$RequestID."\">$Title [$Year]</a>";
2011-03-28 14:21:28 +00:00
} else {
2013-04-15 08:00:54 +00:00
$FullName ="<a href=\"requests.php?action=view&amp;id=".$RequestID."\">$Title</a>";
2011-03-28 14:21:28 +00:00
}
2013-02-10 08:00:29 +00:00
2011-03-28 14:21:28 +00:00
$Row = ($Row == 'a') ? 'b' : 'a';
2013-02-10 08:00:29 +00:00
2011-03-28 14:21:28 +00:00
$Tags = $Request['Tags'];
?>
<tr class="row<?=$Row?>">
<td>
<?=$FullName?>
<div class="tags">
2013-02-10 08:00:29 +00:00
<?
2011-03-28 14:21:28 +00:00
$TagList = array();
2013-04-15 08:00:54 +00:00
foreach ($Tags as $TagID => $TagName) {
$TagList[] = '<a href="?tags='.$TagName.($BookmarkView ? '&amp;type=requests' : '').'\">'.display_str($TagName).'</a>';
2011-03-28 14:21:28 +00:00
}
$TagList = implode(', ', $TagList);
?>
<?=$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-05-30 08:00:30 +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>
2012-09-14 08:00:34 +00:00
<? } ?>
2011-03-28 14:21:28 +00:00
</td>
2011-11-13 08:00:16 +00:00
<td class="nobr">
2012-10-11 08:00:15 +00:00
<?=Format::get_size($RequestVotes['TotalBounty'])?>
2011-03-28 14:21:28 +00:00
</td>
<td>
2013-05-14 08:00:34 +00:00
<? if ($IsFilled) { ?>
2013-04-15 08:00:54 +00:00
<a href="torrents.php?<?=(strtotime($TimeFilled) < $TimeCompare ? 'id=' : 'torrentid=').$TorrentID?>"><strong><?=time_diff($TimeFilled)?></strong></a>
2013-05-14 08:00:34 +00:00
<? } else { ?>
2011-03-28 14:21:28 +00:00
<strong>No</strong>
2013-05-14 08:00:34 +00:00
<? } ?>
2011-03-28 14:21:28 +00:00
</td>
<td>
2013-04-15 08:00:54 +00:00
<? if ($IsFilled) { ?>
2013-06-15 08:00:45 +00:00
<a href="user.php?id=<?=$FillerID?>"><?=$FillerName?></a>
2011-03-28 14:21:28 +00:00
<? } else { ?>
2013-06-15 08:00:45 +00:00
&mdash;
2011-03-28 14:21:28 +00:00
<? } ?>
</td>
<td>
<a href="user.php?id=<?=$RequestorID?>"><?=$RequestorName?></a>
</td>
<td>
<?=time_diff($TimeAdded)?>
</td>
<td>
<?=time_diff($LastVote)?>
</td>
</tr>
<?
} // while
} // else
?>
</table>
<div class="linkbox">
<?=$PageLinks?>
</div>
</div>
2013-05-21 08:01:09 +00:00
<? View::show_footer(); ?>