mirror of
https://github.com/WhatCD/Gazelle.git
synced 2025-01-18 04:01:35 +00:00
Empty commit
This commit is contained in:
parent
fcb95ba306
commit
0c935a8600
@ -108,7 +108,7 @@ public function get_value($Key, $NoCache = false) {
|
||||
}
|
||||
|
||||
if (isset($_GET['clearcache']) && $this->CanClear && !Misc::in_array_partial($Key, $this->PersistentKeys)) {
|
||||
if ($_GET['clearcache'] == 1) {
|
||||
if ($_GET['clearcache'] === '1') {
|
||||
// Because check_perms() isn't true until LoggedUser is pulled from the cache, we have to remove the entries loaded before the LoggedUser data
|
||||
// Because of this, not user cache data will require a secondary pageload following the clearcache to update
|
||||
if (count($this->CacheHits) > 0) {
|
||||
@ -131,7 +131,18 @@ public function get_value($Key, $NoCache = false) {
|
||||
$this->ClearedKeys[$Key] = true;
|
||||
$this->Time += (microtime(true) - $StartTime) * 1000;
|
||||
return false;
|
||||
} elseif (!isset($this->ClearedKeys[$_GET['clearcache']]) && in_array($_GET['clearcache'], $this->CacheHits)) {
|
||||
} elseif ($_GET['clearcache'] == $Key) {
|
||||
$this->delete($Key);
|
||||
$this->Time += (microtime(true) - $StartTime) * 1000;
|
||||
return false;
|
||||
} elseif (substr($_GET['clearcache'], -1) === '*') {
|
||||
$Prefix = substr($_GET['clearcache'], 0, -1);
|
||||
if ($Prefix == substr($Key, 0, strlen($Prefix))) {
|
||||
$this->delete($Key);
|
||||
$this->Time += (microtime(true) - $StartTime) * 1000;
|
||||
return false;
|
||||
}
|
||||
} elseif (!isset($this->ClearedKeys[$_GET['clearcache']]) && isset($this->CacheHits[$_GET['clearcache']])) {
|
||||
unset($this->CacheHits[$_GET['clearcache']]);
|
||||
$this->ClearedKeys[$_GET['clearcache']] = true;
|
||||
$this->delete($_GET['clearcache']);
|
||||
|
@ -272,16 +272,6 @@ public function get_cache_keys() {
|
||||
return array_keys(G::$Cache->CacheHits);
|
||||
}
|
||||
|
||||
public function get_sphinx_queries() {
|
||||
global $SS;
|
||||
return $SS->Queries;
|
||||
}
|
||||
|
||||
public function get_sphinx_time() {
|
||||
global $SS;
|
||||
return $SS->Time;
|
||||
}
|
||||
|
||||
public function get_sphinxql_queries() {
|
||||
if (class_exists('Sphinxql')) {
|
||||
return Sphinxql::$Queries;
|
||||
@ -564,11 +554,8 @@ public function query_table($Queries=false) {
|
||||
public function sphinx_table($Queries = false) {
|
||||
$Header = 'Searches';
|
||||
if (!is_array($Queries)) {
|
||||
$Queries = $this->get_sphinx_queries();
|
||||
if ($QueriesQL = $this->get_sphinxql_queries()) {
|
||||
$Queries = array_merge($Queries, $QueriesQL);
|
||||
}
|
||||
$Header .= ' ('.number_format($this->get_sphinx_time() + $this->get_sphinxql_time(), 5).' ms)';
|
||||
$Queries = $this->get_sphinxql_queries();
|
||||
$Header .= ' ('.number_format($this->get_sphinxql_time(), 5).' ms)';
|
||||
}
|
||||
if (empty($Queries)) {
|
||||
return;
|
||||
|
@ -42,8 +42,7 @@ public static function update_sphinx_requests($RequestID) {
|
||||
|
||||
|
||||
/**
|
||||
* Function to get data from an array of $RequestIDs.
|
||||
* In places where the output from this is merged with sphinx filters, it will be in a different order.
|
||||
* Function to get data from an array of $RequestIDs. Order of keys doesn't matter (let's keep it that way).
|
||||
*
|
||||
* @param array $RequestIDs
|
||||
* @param boolean $Return if set to false, data won't be returned (ie. if we just want to prime the cache.)
|
||||
@ -54,11 +53,13 @@ public static function update_sphinx_requests($RequestID) {
|
||||
//
|
||||
//In places where the output from this is merged with sphinx filters, it will be in a different order.
|
||||
public static function get_requests($RequestIDs, $Return = true) {
|
||||
// Make sure there's something in $RequestIDs, otherwise the SQL will break
|
||||
if (count($RequestIDs) === 0) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$Found = $NotFound = array_fill_keys($RequestIDs, false);
|
||||
// Try to fetch the requests from the cache first.
|
||||
$Found = array_flip($RequestIDs);
|
||||
$NotFound = array_flip($RequestIDs);
|
||||
|
||||
foreach ($RequestIDs as $RequestID) {
|
||||
$Data = G::$Cache->get_value("request_$RequestID");
|
||||
if (!empty($Data)) {
|
||||
@ -67,7 +68,7 @@ public static function get_requests($RequestIDs, $Return = true) {
|
||||
}
|
||||
}
|
||||
|
||||
$IDs = implode(',', array_flip($NotFound));
|
||||
$IDs = implode(',', array_keys($NotFound));
|
||||
|
||||
/*
|
||||
Don't change without ensuring you change everything else that uses get_requests()
|
||||
@ -78,51 +79,67 @@ public static function get_requests($RequestIDs, $Return = true) {
|
||||
|
||||
G::$DB->query("
|
||||
SELECT
|
||||
r.ID AS ID,
|
||||
r.UserID,
|
||||
u.Username,
|
||||
r.TimeAdded,
|
||||
r.LastVote,
|
||||
r.CategoryID,
|
||||
r.Title,
|
||||
r.Year,
|
||||
r.Image,
|
||||
r.Description,
|
||||
r.CatalogueNumber,
|
||||
r.RecordLabel,
|
||||
r.ReleaseType,
|
||||
r.BitrateList,
|
||||
r.FormatList,
|
||||
r.MediaList,
|
||||
r.LogCue,
|
||||
r.FillerID,
|
||||
filler.Username,
|
||||
r.TorrentID,
|
||||
r.TimeFilled,
|
||||
r.GroupID,
|
||||
r.OCLC
|
||||
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 AND FillerID != 0
|
||||
WHERE r.ID IN ($IDs)
|
||||
ID,
|
||||
UserID,
|
||||
TimeAdded,
|
||||
LastVote,
|
||||
CategoryID,
|
||||
Title,
|
||||
Year,
|
||||
Image,
|
||||
Description,
|
||||
CatalogueNumber,
|
||||
RecordLabel,
|
||||
ReleaseType,
|
||||
BitrateList,
|
||||
FormatList,
|
||||
MediaList,
|
||||
LogCue,
|
||||
FillerID,
|
||||
TorrentID,
|
||||
TimeFilled,
|
||||
GroupID,
|
||||
OCLC
|
||||
FROM requests
|
||||
WHERE ID IN ($IDs)
|
||||
ORDER BY ID");
|
||||
$Requests = G::$DB->to_array();
|
||||
G::$DB->set_query_id($QueryID);
|
||||
|
||||
$Requests = G::$DB->to_array(false, MYSQLI_ASSOC, true);
|
||||
$Tags = self::get_tags(G::$DB->collect('ID', false));
|
||||
foreach ($Requests as $Request) {
|
||||
unset($NotFound[$Request['ID']]);
|
||||
$Request['Tags'] = self::get_tags($Request['ID']);
|
||||
$Request['Tags'] = isset($Tags[$Request['ID']]) ? $Tags[$Request['ID']] : array();
|
||||
$Found[$Request['ID']] = $Request;
|
||||
G::$Cache->cache_value('request_'.$Request['ID'], $Request, 0);
|
||||
}
|
||||
G::$DB->set_query_id($QueryID);
|
||||
|
||||
// Orphan requests. There shouldn't ever be any
|
||||
if (count($NotFound) > 0) {
|
||||
foreach (array_keys($NotFound) as $GroupID) {
|
||||
unset($Found[$GroupID]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($Return) { // If we're interested in the data, and not just caching it
|
||||
$Matches = array('matches' => $Found, 'notfound' => array_flip($NotFound));
|
||||
return $Matches;
|
||||
return $Found;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a single request. Wrapper for get_requests
|
||||
*
|
||||
* @param int $RequestID
|
||||
* @return request array or false if request doesn't exist. See get_requests for a description of the format
|
||||
*/
|
||||
public static function get_request($RequestID) {
|
||||
$Request = self::get_requests(array($RequestID));
|
||||
if (isset($Request[$RequestID])) {
|
||||
return $Request[$RequestID];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function get_artists($RequestID) {
|
||||
$Artists = G::$Cache->get_value("request_artists_$RequestID");
|
||||
if (is_array($Artists)) {
|
||||
@ -150,28 +167,34 @@ public static function get_artists($RequestID) {
|
||||
return $Results;
|
||||
}
|
||||
|
||||
public static function get_tags($RequestID) {
|
||||
public static function get_tags($RequestIDs) {
|
||||
if (empty($RequestIDs)) {
|
||||
return array();
|
||||
}
|
||||
if (is_array($RequestIDs)) {
|
||||
$RequestIDs = implode(',', $RequestIDs);
|
||||
}
|
||||
$QueryID = G::$DB->get_query_id();
|
||||
G::$DB->query("
|
||||
SELECT
|
||||
rt.RequestID,
|
||||
rt.TagID,
|
||||
t.Name
|
||||
FROM requests_tags AS rt
|
||||
JOIN tags AS t ON rt.TagID = t.ID
|
||||
WHERE rt.RequestID = $RequestID
|
||||
WHERE rt.RequestID IN ($RequestIDs)
|
||||
ORDER BY rt.TagID ASC");
|
||||
$Tags = G::$DB->to_array();
|
||||
$Tags = G::$DB->to_array(false, MYSQLI_NUM, false);
|
||||
G::$DB->set_query_id($QueryID);
|
||||
$Results = array();
|
||||
foreach ($Tags as $TagsRow) {
|
||||
list($TagID, $TagName) = $TagsRow;
|
||||
$Results[$TagID] = $TagName;
|
||||
list($RequestID, $TagID, $TagName) = $TagsRow;
|
||||
$Results[$RequestID][$TagID] = $TagName;
|
||||
}
|
||||
return $Results;
|
||||
}
|
||||
|
||||
public static function get_votes_array($RequestID) {
|
||||
|
||||
$RequestVotes = G::$Cache->get_value("request_votes_$RequestID");
|
||||
if (!is_array($RequestVotes)) {
|
||||
$QueryID = G::$DB->get_query_id();
|
||||
@ -185,22 +208,23 @@ public static function get_votes_array($RequestID) {
|
||||
WHERE rv.RequestID = $RequestID
|
||||
ORDER BY rv.Bounty DESC");
|
||||
if (!G::$DB->has_results()) {
|
||||
error(0);
|
||||
} else {
|
||||
$Votes = G::$DB->to_array();
|
||||
|
||||
$RequestVotes = array();
|
||||
$RequestVotes['TotalBounty'] = array_sum(G::$DB->collect('Bounty'));
|
||||
|
||||
foreach ($Votes as $Vote) {
|
||||
list($UserID, $Bounty, $Username) = $Vote;
|
||||
$VoteArray = array();
|
||||
$VotesArray[] = array('UserID' => $UserID, 'Username' => $Username, 'Bounty' => $Bounty);
|
||||
}
|
||||
|
||||
$RequestVotes['Voters'] = $VotesArray;
|
||||
G::$Cache->cache_value("request_votes_$RequestID", $RequestVotes);
|
||||
return array(
|
||||
'TotalBounty' => 0,
|
||||
'Voters' => array());
|
||||
}
|
||||
$Votes = G::$DB->to_array();
|
||||
|
||||
$RequestVotes = array();
|
||||
$RequestVotes['TotalBounty'] = array_sum(G::$DB->collect('Bounty'));
|
||||
|
||||
foreach ($Votes as $Vote) {
|
||||
list($UserID, $Bounty, $Username) = $Vote;
|
||||
$VoteArray = array();
|
||||
$VotesArray[] = array('UserID' => $UserID, 'Username' => $Username, 'Bounty' => $Bounty);
|
||||
}
|
||||
|
||||
$RequestVotes['Voters'] = $VotesArray;
|
||||
G::$Cache->cache_value("request_votes_$RequestID", $RequestVotes);
|
||||
G::$DB->set_query_id($QueryID);
|
||||
}
|
||||
return $RequestVotes;
|
||||
|
@ -64,7 +64,6 @@
|
||||
require(SERVER_ROOT.'/classes/cache.class.php'); //Require the caching class
|
||||
require(SERVER_ROOT.'/classes/encrypt.class.php'); //Require the encryption class
|
||||
require(SERVER_ROOT.'/classes/time.class.php'); //Require the time class
|
||||
require(SERVER_ROOT.'/classes/search.class.php'); //Require the searching class
|
||||
require(SERVER_ROOT.'/classes/paranoia.class.php'); //Require the paranoia check_paranoia function
|
||||
require(SERVER_ROOT.'/classes/regex.php');
|
||||
require(SERVER_ROOT.'/classes/util.php');
|
||||
@ -76,7 +75,6 @@
|
||||
$DB = new DB_MYSQL;
|
||||
$Cache = new CACHE($MemcachedServers);
|
||||
$Enc = new CRYPT;
|
||||
$SS = new SPHINX_SEARCH;
|
||||
|
||||
// Autoload classes.
|
||||
require(SERVER_ROOT.'/classes/classloader.php');
|
||||
|
@ -1,185 +0,0 @@
|
||||
<?
|
||||
//Require base class
|
||||
if (!extension_loaded('sphinx')) {
|
||||
require(SERVER_ROOT.'/classes/sphinxapi.php');
|
||||
}
|
||||
|
||||
class SPHINX_SEARCH extends SphinxClient {
|
||||
private $Index = '*';
|
||||
public $TotalResults = 0;
|
||||
public $Queries = array();
|
||||
public $Time = 0.0;
|
||||
public $Filters = array();
|
||||
|
||||
function SPHINX_SEARCH() {
|
||||
parent::__construct();
|
||||
$this->SetServer(SPHINX_HOST, SPHINX_PORT);
|
||||
$this->SetMatchMode(SPH_MATCH_EXTENDED2);
|
||||
}
|
||||
|
||||
/****************************************************************
|
||||
/--- Search function --------------------------------------------
|
||||
|
||||
This function queries sphinx for whatever is in $Query, in
|
||||
extended2 mode. It then fetches the records for each primary key
|
||||
from memcached (by joining $CachePrefix and the primary key), and
|
||||
fetches the fields needed ($ReturnData) from the memcached
|
||||
result.
|
||||
|
||||
Any keys not found in memcached are then queried in MySQL, using
|
||||
$SQL. They are then cached, and merged with the memcached matches
|
||||
and returned.
|
||||
|
||||
$Query - sphinx query
|
||||
$CachePrefix - Prefix for memcache key (no underscore)
|
||||
$CacheLength - How long to store data in the cache, if it's found by MySQL
|
||||
$ReturnData - Array of keys to the array in memcached to return.
|
||||
If empty, return all.
|
||||
$SQL - SQL query to fetch results not found in memcached
|
||||
- Should take the format of:
|
||||
SELECT fields FROM table WHERE primary key IN(%ids)
|
||||
where %ids will be replaced by a list of IDs not found in memcached
|
||||
$IDColumn - The primary key of the SQL table - must be the
|
||||
same primary key returned by sphinx!
|
||||
|
||||
****************************************************************/
|
||||
|
||||
function search($Query = '', $CachePrefix = '', $CacheLength = 0, $ReturnData = array(), $SQL = '', $IDColumn = 'ID') {
|
||||
$QueryStartTime = microtime(true);
|
||||
$Result = $this->Query($Query, $this->Index);
|
||||
$QueryEndTime = microtime(true);
|
||||
|
||||
$Filters = array();
|
||||
foreach ($this->Filters as $Name => $Values) {
|
||||
foreach ($Values as $Value) {
|
||||
$Filters[] = "$Name - $Value";
|
||||
}
|
||||
}
|
||||
|
||||
$this->Queries[] = array("Params: $Query Filters: ".implode(', ', $Filters).' Indicies: '.$this->Index, ($QueryEndTime - $QueryStartTime) * 1000);
|
||||
$this->Time += ($QueryEndTime - $QueryStartTime) * 1000;
|
||||
|
||||
if ($Result === false) {
|
||||
if ($this->_connerror && !G::$Cache->get_value('sphinx_crash_reported')) {
|
||||
send_irc('PRIVMSG '.ADMIN_CHAN.' :!dev Connection to searchd failed');
|
||||
G::$Cache->cache_value('sphinx_crash_reported', 1, 3600);
|
||||
}
|
||||
send_irc('PRIVMSG '.LAB_CHAN." :Search for \"$Query\" (".str_replace("\n", '', print_r($this->Filters, true)).') failed: '.$this->GetLastError());
|
||||
}
|
||||
|
||||
$this->TotalResults = $Result['total_found'];
|
||||
$this->SearchTime = $Result['time'];
|
||||
|
||||
if (empty($Result['matches'])) {
|
||||
return false;
|
||||
}
|
||||
$Matches = $Result['matches'];
|
||||
|
||||
$MatchIDs = array_keys($Matches);
|
||||
|
||||
$NotFound = array();
|
||||
$Skip = array();
|
||||
if (!empty($ReturnData)) {
|
||||
$AllFields = false;
|
||||
} else {
|
||||
$AllFields = true;
|
||||
}
|
||||
|
||||
foreach ($MatchIDs as $Match) {
|
||||
$Matches[$Match] = $Matches[$Match]['attrs'];
|
||||
if (!empty($CachePrefix)) {
|
||||
$Data = G::$Cache->get_value($CachePrefix."_$Match");
|
||||
if ($Data == false) {
|
||||
$NotFound[] = $Match;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
$NotFound[] = $Match;
|
||||
}
|
||||
if (!$AllFields) {
|
||||
// Populate list of fields to unset (faster than picking out the ones we need). Should only be run once, on the first cache key
|
||||
if (empty($Skip)) {
|
||||
foreach (array_keys($Data) as $Key) {
|
||||
if (!in_array($Key, $ReturnData)) {
|
||||
$Skip[] = $Key;
|
||||
}
|
||||
}
|
||||
if (empty($Skip)) {
|
||||
$AllFields = true;
|
||||
}
|
||||
}
|
||||
foreach ($Skip as $Key) {
|
||||
unset($Data[$Key]);
|
||||
}
|
||||
reset($Skip);
|
||||
}
|
||||
if (!empty($Data)) {
|
||||
$Matches[$Match] = array_merge($Matches[$Match], $Data);
|
||||
}
|
||||
}
|
||||
|
||||
if ($SQL != '') {
|
||||
if (!empty($NotFound)) {
|
||||
$QueryID = G::$DB->get_query_id();
|
||||
G::$DB->query(str_replace('%ids', implode(',', $NotFound), $SQL));
|
||||
while ($Data = G::$DB->next_record(MYSQLI_ASSOC)) {
|
||||
$Matches[$Data[$IDColumn]] = array_merge($Matches[$Data[$IDColumn]], $Data);
|
||||
G::$Cache->cache_value($CachePrefix.'_'.$Data[$IDColumn], $Data, $CacheLength);
|
||||
}
|
||||
G::$DB->set_query_id($QueryID);
|
||||
}
|
||||
} else {
|
||||
$Matches = array('matches' => $Matches, 'notfound' => $NotFound);
|
||||
}
|
||||
|
||||
return $Matches;
|
||||
}
|
||||
|
||||
function limit($Start, $Length) {
|
||||
$Start = (int)$Start;
|
||||
$Length = (int)$Length;
|
||||
$this->SetLimits($Start, $Length, $Start + $Length);
|
||||
}
|
||||
|
||||
|
||||
function set_index($Index) {
|
||||
$this->Index = $Index;
|
||||
}
|
||||
|
||||
function set_filter($Name, $Vals, $Exclude = false) {
|
||||
foreach ($Vals as $Val) {
|
||||
if ($Exclude) {
|
||||
$this->Filters[$Name][] = "!$Val";
|
||||
} else {
|
||||
$this->Filters[$Name][] = $Val;
|
||||
}
|
||||
}
|
||||
$this->SetFilter($Name, $Vals, $Exclude);
|
||||
}
|
||||
|
||||
function set_filter_range($Name, $Min, $Max, $Exclude) {
|
||||
$this->Filters[$Name] = array("$Min-$Max");
|
||||
$this->SetFilterRange($Name, $Min, $Max, $Exclude);
|
||||
}
|
||||
|
||||
function escape_string($String) {
|
||||
return strtr($String, array(
|
||||
'('=>'\(',
|
||||
')'=>'\)',
|
||||
'|'=>'\|',
|
||||
'-'=>'\-',
|
||||
'@'=>'\@',
|
||||
'~'=>'\~',
|
||||
'&'=>'\&',
|
||||
'!'=>'\!',
|
||||
'"'=>'\"',
|
||||
'/'=>'\/',
|
||||
'\\'=>'\\\\',
|
||||
'*'=>'\*',
|
||||
'?'=>'\?',
|
||||
'^'=>'\^',
|
||||
'$'=>'\$',
|
||||
'='=>'\='));
|
||||
}
|
||||
}
|
||||
?>
|
File diff suppressed because it is too large
Load Diff
@ -288,6 +288,7 @@ private function send_query($GetMeta) {
|
||||
$Errno = $this->Sphinxql->errno;
|
||||
$Error = $this->Sphinxql->error;
|
||||
$this->error("Query returned error $Errno ($Error).\n$this->QueryString");
|
||||
$Meta = null;
|
||||
} else {
|
||||
$Errno = 0;
|
||||
$Error = '';
|
||||
|
@ -31,6 +31,15 @@ public function __call($Name, $Arguments) {
|
||||
return call_user_func_array(array($this->Result, $Name), $Arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* Did the query find anything?
|
||||
*
|
||||
* @return bool results were found
|
||||
*/
|
||||
public function has_results() {
|
||||
return $this->get_meta('total') > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Collect and return the specified key of all results as a list
|
||||
*
|
||||
|
@ -642,10 +642,11 @@ private function to_html ($Array) {
|
||||
$Matches = array();
|
||||
if (preg_match($Pattern, $Block['Val'], $Matches)) {
|
||||
if (isset($Matches[2])) {
|
||||
$Groups = Torrents::get_groups(array($Matches[2]), true, true, false);
|
||||
if (!empty($Groups['matches'][$Matches[2]])) {
|
||||
$Group = $Groups['matches'][$Matches[2]];
|
||||
$Str .= Artists::display_artists($Group['ExtendedArtists']).'<a href="torrents.php?id='.$Matches[2].'">'.$Group['Name'].'</a>';
|
||||
$GroupID = $Matches[2];
|
||||
$Groups = Torrents::get_groups(array($GroupID), true, true, false);
|
||||
if ($Groups[$GroupID]) {
|
||||
$Group = $Groups[$GroupID];
|
||||
$Str .= Artists::display_artists($Group['ExtendedArtists']).'<a href="torrents.php?id='.$GroupID.'">'.$Group['Name'].'</a>';
|
||||
} else {
|
||||
$Str .= '[torrent]'.str_replace('[inlineurl]', '', $Block['Val']).'[/torrent]';
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ public static function render_artist_links($Selected, $View) { ?>
|
||||
<div class="center">
|
||||
<a href="top10.php?type=artists&category=weekly&view=<?=$View?>" class="brackets"><?=self::get_selected_link("Weekly", $Selected == "weekly")?></a>
|
||||
<a href="top10.php?type=artists&category=hyped&view=<?=$View?>" class="brackets"><?=self::get_selected_link("Hyped", $Selected == "hyped")?></a>
|
||||
<a href="top10.php?type=artists&category=all_time&view=<?=$View?>" class="brackets"><?=self::get_selected_link("All Time", $Selected == "all_time")?></a>
|
||||
|
||||
</div>
|
||||
<? }
|
||||
|
||||
@ -40,9 +40,7 @@ private static function get_selected_link($String, $Selected) {
|
||||
|
||||
public static function render_artist_tile($Artist, $Category) {
|
||||
switch ($Category) {
|
||||
case 'all_time':
|
||||
self::render_tile("artist.php?artistname", $Artist['Name'], $Artist['Image']);
|
||||
break;
|
||||
|
||||
case 'weekly':
|
||||
case 'hyped':
|
||||
self::render_tile("artist.php?artistname=", $Artist['name'], $Artist['image'][3]['#text']);
|
||||
@ -65,9 +63,7 @@ private static function render_tile($Url, $Name, $Image) {
|
||||
|
||||
public static function render_artist_list($Artist, $Category) {
|
||||
switch ($Category) {
|
||||
case 'all_time':
|
||||
self::render_list("artist.php?id=", $Artist['id'], $Artist['Image']);
|
||||
break;
|
||||
|
||||
case 'weekly':
|
||||
case 'hyped':
|
||||
self::render_list("artist.php?artistname=", $Artist['name'], $Artist['image'][3]['#text']);
|
||||
|
@ -3,8 +3,7 @@ class Torrents {
|
||||
const FilelistDelim = 0xF7; // Hex for ÷ Must be the same as phrase_boundary in sphinx.conf!
|
||||
|
||||
/*
|
||||
* Function to get data and torrents for an array of GroupIDs.
|
||||
* In places where the output from this is merged with sphinx filters, it will be in a different order.
|
||||
* Function to get data and torrents for an array of GroupIDs. Order of keys doesn't matter
|
||||
*
|
||||
* @param array $GroupIDs
|
||||
* @param boolean $Return if false, nothing is returned. For priming cache.
|
||||
@ -47,15 +46,13 @@ class Torrents {
|
||||
* }
|
||||
*/
|
||||
public static function get_groups($GroupIDs, $Return = true, $GetArtists = true, $Torrents = true) {
|
||||
global $Debug;
|
||||
|
||||
// Make sure there's something in $GroupIDs, otherwise the SQL
|
||||
// will break
|
||||
if (count($GroupIDs) == 0) {
|
||||
return array('matches' => array(), 'notfound' => array());
|
||||
return array();
|
||||
}
|
||||
|
||||
$Found = $NotFound = array_flip($GroupIDs);
|
||||
$Found = $NotFound = array_fill_keys($GroupIDs, false);
|
||||
$Key = $Torrents ? 'torrent_group_' : 'torrent_group_light_';
|
||||
|
||||
foreach ($GroupIDs as $GroupID) {
|
||||
@ -66,7 +63,7 @@ public static function get_groups($GroupIDs, $Return = true, $GetArtists = true,
|
||||
}
|
||||
}
|
||||
|
||||
$IDs = implode(',', array_flip($NotFound));
|
||||
$IDs = implode(',', array_keys($NotFound));
|
||||
|
||||
/*
|
||||
Changing any of these attributes returned will cause very large, very dramatic site-wide chaos.
|
||||
@ -122,7 +119,6 @@ public static function get_groups($GroupIDs, $Return = true, $GetArtists = true,
|
||||
G::$Cache->cache_value("torrent_group_light_$GroupID",
|
||||
array('ver' => CACHE::GROUP_VERSION, 'd' => $GroupInfo), 0);
|
||||
}
|
||||
|
||||
} else {
|
||||
foreach ($Found as $Group) {
|
||||
G::$Cache->cache_value('torrent_group_light_'.$Group['ID'], array('ver' => CACHE::GROUP_VERSION, 'd' => $Found[$Group['ID']]), 0);
|
||||
@ -137,6 +133,9 @@ public static function get_groups($GroupIDs, $Return = true, $GetArtists = true,
|
||||
|
||||
if ($Return) { // If we're interested in the data, and not just caching it
|
||||
foreach ($Artists as $GroupID => $Data) {
|
||||
if (!isset($Found[$GroupID])) {
|
||||
continue;
|
||||
}
|
||||
if (array_key_exists(1, $Data) || array_key_exists(4, $Data) || array_key_exists(6, $Data)) {
|
||||
$Found[$GroupID]['Artists'] = isset($Data[1]) ? $Data[1] : null; // Only use main artists (legacy)
|
||||
// TODO: find a better solution than this crap / rewrite the artist system
|
||||
@ -157,10 +156,7 @@ public static function get_groups($GroupIDs, $Return = true, $GetArtists = true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$Matches = array('matches' => $Found, 'notfound' => array_flip($NotFound));
|
||||
|
||||
return $Matches;
|
||||
return $Found;
|
||||
}
|
||||
}
|
||||
|
||||
@ -174,8 +170,7 @@ public static function get_groups($GroupIDs, $Return = true, $GetArtists = true,
|
||||
* @param array $Group torrent group
|
||||
* @return array Re-key'd array
|
||||
*/
|
||||
public static function array_group (array &$Group)
|
||||
{
|
||||
public static function array_group(array &$Group) {
|
||||
return array(
|
||||
'GroupID' => $Group['ID'],
|
||||
'GroupName' => $Group['Name'],
|
||||
|
@ -86,7 +86,8 @@ public static function user_info($UserID) {
|
||||
'Title' => '',
|
||||
'CatchupTime' => 0,
|
||||
'Visible' => '1',
|
||||
'Levels' => '');
|
||||
'Levels' => '',
|
||||
'Class' => 0);
|
||||
} else {
|
||||
$UserInfo = G::$DB->next_record(MYSQLI_ASSOC, array('Paranoia', 'Title'));
|
||||
$UserInfo['CatchupTime'] = strtotime($UserInfo['CatchupTime']);
|
||||
@ -94,18 +95,16 @@ public static function user_info($UserID) {
|
||||
if ($UserInfo['Paranoia'] === false) {
|
||||
$UserInfo['Paranoia'] = array();
|
||||
}
|
||||
$UserInfo['Class'] = $Classes[$UserInfo['PermissionID']]['Level'];
|
||||
}
|
||||
|
||||
|
||||
$UserInfo['Class'] = $Classes[$UserInfo['PermissionID']]['Level'];
|
||||
|
||||
if (!empty($UserInfo['Levels'])) {
|
||||
$UserInfo['ExtraClasses'] = array_fill_keys(explode(',', $UserInfo['Levels']), 1);
|
||||
} else {
|
||||
$UserInfo['ExtraClasses'] = array();
|
||||
}
|
||||
unset($UserInfo['Levels']);
|
||||
$EffectiveClass = $Classes[$UserInfo['PermissionID']]['Level'];
|
||||
$EffectiveClass = $UserInfo['Class'];
|
||||
foreach ($UserInfo['ExtraClasses'] as $Class => $Val) {
|
||||
$EffectiveClass = max($EffectiveClass, $Classes[$Class]['Level']);
|
||||
}
|
||||
@ -466,7 +465,7 @@ public static function format_username($UserID, $Badges = false, $IsWarned = tru
|
||||
return 'System';
|
||||
}
|
||||
|
||||
$UserInfo = Users::user_info($UserID);
|
||||
$UserInfo = self::user_info($UserID);
|
||||
if ($UserInfo['Username'] == '') {
|
||||
return "Unknown [$UserID]";
|
||||
}
|
||||
@ -489,29 +488,40 @@ public static function format_username($UserID, $Badges = false, $IsWarned = tru
|
||||
}
|
||||
if ($Badges) {
|
||||
$DonorRank = Donations::get_rank($UserID);
|
||||
$SpecialRank = Donations::get_special_rank($UserID);
|
||||
if ($DonorRank >= 2 && $ShowDonorIcon) {
|
||||
$DonorRewards = Donations::get_rewards($UserID);
|
||||
$IconText = $DonorRewards['IconMouseOverText'];
|
||||
if ($DonorRank == 0 && $UserInfo['Donor'] == 1) {
|
||||
$DonorRank = 1;
|
||||
}
|
||||
if ($ShowDonorIcon && $DonorRank > 0) {
|
||||
$IconLink = 'donate.php';
|
||||
$IconImage = 'donor.png';
|
||||
$DonorRank = $DonorRank == 5 ? ($DonorRank - 1) : $DonorRank;
|
||||
if ($DonorRank >= MAX_RANK || $SpecialRank >= MAX_SPECIAL_RANK) {
|
||||
$IconLink = !empty($DonorRewards['CustomIconLink']) ? $DonorRewards['CustomIconLink'] : 'donate.php';
|
||||
if ($SpecialRank >= MAX_SPECIAL_RANK) {
|
||||
$IconText = 'Donor';
|
||||
$DonorHeart = $DonorRank;
|
||||
$SpecialRank = Donations::get_special_rank($UserID);
|
||||
$EnabledRewards = Donations::get_enabled_rewards($UserID);
|
||||
$DonorRewards = Donations::get_rewards($UserID);
|
||||
if ($EnabledRewards['HasDonorIconMouseOverText'] && !empty($DonorRewards['IconMouseOverText'])) {
|
||||
$IconText = display_str($DonorRewards['IconMouseOverText']);
|
||||
}
|
||||
if ($EnabledRewards['HasDonorIconLink'] && !empty($DonorRewards['CustomIconLink'])) {
|
||||
$IconLink = display_str($DonorRewards['CustomIconLink']);
|
||||
}
|
||||
if ($EnabledRewards['HasCustomDonorIcon'] && !empty($DonorRewards['CustomIcon'])) {
|
||||
$IconImage = ImageTools::process($DonorRewards['CustomIcon']);
|
||||
} else {
|
||||
if ($SpecialRank === MAX_SPECIAL_RANK) {
|
||||
$DonorHeart = 6;
|
||||
} else {
|
||||
} elseif ($DonorRank === 5) {
|
||||
$DonorHeart = 4; // Two points between rank 4 and 5
|
||||
} elseif ($DonorRank >= MAX_RANK) {
|
||||
$DonorHeart = 5;
|
||||
}
|
||||
$IconImage = !empty($DonorRewards['CustomIcon']) ? ImageTools::process($DonorRewards['CustomIcon']) : STATIC_SERVER . "common/symbols/donor_$DonorHeart" . '.png';
|
||||
if ($DonorHeart === 1) {
|
||||
$IconImage = STATIC_SERVER . 'common/symbols/donor.png';
|
||||
} else {
|
||||
$IconImage = STATIC_SERVER . "common/symbols/donor_{$DonorHeart}.png";
|
||||
}
|
||||
}
|
||||
else {
|
||||
$IconImage = STATIC_SERVER . "common/symbols/donor_$DonorRank" . '.png';
|
||||
}
|
||||
|
||||
$Str .= "<a href=\"$IconLink\"><img class=\"donor_icon\" src=\"$IconImage\" alt=\"$IconText\" title=\"$IconText\" /></a>";
|
||||
} elseif (($DonorRank == 1 || $UserInfo['Donor'] == 1) && $ShowDonorIcon) {
|
||||
$Str .= '<a href="donate.php"><img src="'.STATIC_SERVER.'common/symbols/donor.png" alt="Donor" title="Donor" /></a>';
|
||||
}
|
||||
}
|
||||
|
||||
@ -592,7 +602,6 @@ public static function get_bookmarks($UserID) {
|
||||
}
|
||||
|
||||
$TorrentList = Torrents::get_groups($GroupIDs);
|
||||
$TorrentList = (isset($TorrentList['matches']) ? $TorrentList['matches'] : array());
|
||||
|
||||
return array($GroupIDs, $BookmarkData, $TorrentList);
|
||||
}
|
||||
|
@ -1,5 +1,8 @@
|
||||
CHANGELOG
|
||||
|
||||
2013-09-12 by porkpie
|
||||
Switch to SphinxQL for request searches
|
||||
|
||||
2013-09-05 by porkpie
|
||||
Fix multi-format uploader when switching from "Music" to something else, then back to "Music"
|
||||
|
||||
|
@ -474,12 +474,14 @@ CREATE TABLE `forums_topics` (
|
||||
`LastPostAuthorID` int(10) NOT NULL,
|
||||
`StickyPostID` int(10) NOT NULL DEFAULT '0',
|
||||
`Ranking` tinyint(2) DEFAULT '0',
|
||||
`CreatedTime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||||
PRIMARY KEY (`ID`),
|
||||
KEY `AuthorID` (`AuthorID`),
|
||||
KEY `ForumID` (`ForumID`),
|
||||
KEY `IsSticky` (`IsSticky`),
|
||||
KEY `LastPostID` (`LastPostID`),
|
||||
KEY `Title` (`Title`)
|
||||
KEY `Title` (`Title`),
|
||||
KEY `CreatedTime` (`CreatedTime`)
|
||||
) ENGINE=InnoDB CHARSET utf8;
|
||||
|
||||
CREATE TABLE `friends` (
|
||||
|
@ -79,31 +79,34 @@ function compare($X, $Y) {
|
||||
}
|
||||
|
||||
// Requests
|
||||
$Requests = $Cache->get_value("artists_requests_$ArtistID");
|
||||
if (!is_array($Requests)) {
|
||||
$DB->query("
|
||||
SELECT
|
||||
r.ID,
|
||||
r.CategoryID,
|
||||
r.Title,
|
||||
r.Year,
|
||||
r.TimeAdded,
|
||||
COUNT(rv.UserID) AS Votes,
|
||||
SUM(rv.Bounty) AS Bounty
|
||||
FROM requests AS r
|
||||
LEFT JOIN requests_votes AS rv ON rv.RequestID = r.ID
|
||||
LEFT JOIN requests_artists AS ra ON r.ID = ra.RequestID
|
||||
WHERE ra.ArtistID = $ArtistID
|
||||
AND r.TorrentID = 0
|
||||
GROUP BY r.ID
|
||||
ORDER BY Votes DESC");
|
||||
|
||||
if ($DB->has_results()) {
|
||||
$Requests = $DB->to_array();
|
||||
} else {
|
||||
$Requests = array();
|
||||
$Requests = array();
|
||||
if (empty($LoggedUser['DisableRequests'])) {
|
||||
$Requests = $Cache->get_value("artists_requests_$ArtistID");
|
||||
if (!is_array($Requests)) {
|
||||
$DB->query("
|
||||
SELECT
|
||||
r.ID,
|
||||
r.CategoryID,
|
||||
r.Title,
|
||||
r.Year,
|
||||
r.TimeAdded,
|
||||
COUNT(rv.UserID) AS Votes,
|
||||
SUM(rv.Bounty) AS Bounty
|
||||
FROM requests AS r
|
||||
LEFT JOIN requests_votes AS rv ON rv.RequestID = r.ID
|
||||
LEFT JOIN requests_artists AS ra ON r.ID = ra.RequestID
|
||||
WHERE ra.ArtistID = $ArtistID
|
||||
AND r.TorrentID = 0
|
||||
GROUP BY r.ID
|
||||
ORDER BY Votes DESC");
|
||||
|
||||
if ($DB->has_results()) {
|
||||
$Requests = $DB->to_array('ID', MYSQLI_ASSOC, false);
|
||||
} else {
|
||||
$Requests = array();
|
||||
}
|
||||
$Cache->cache_value("artists_requests_$ArtistID", $Requests);
|
||||
}
|
||||
$Cache->cache_value("artists_requests_$ArtistID", $Requests);
|
||||
}
|
||||
$NumRequests = count($Requests);
|
||||
|
||||
@ -126,7 +129,6 @@ function compare($X, $Y) {
|
||||
}
|
||||
if (count($GroupIDs) > 0) {
|
||||
$TorrentList = Torrents::get_groups($GroupIDs, true, true);
|
||||
$TorrentList = $TorrentList['matches'];
|
||||
} else {
|
||||
$TorrentList = array();
|
||||
}
|
||||
@ -173,18 +175,19 @@ function compare($X, $Y) {
|
||||
|
||||
$JsonTorrents = array();
|
||||
$Tags = array();
|
||||
$NumTorrents = $NumSeeders = $NumLeechers = $NumSnatches = 0;
|
||||
foreach ($TorrentList as $GroupID => $Group) {
|
||||
extract(Torrents::array_group($Group));
|
||||
|
||||
foreach ($Artists as &$Artist) {
|
||||
$Artist['id'] = (int) $Artist['id'];
|
||||
$Artist['aliasid'] = (int) $Artist['aliasid'];
|
||||
$Artist['id'] = (int)$Artist['id'];
|
||||
$Artist['aliasid'] = (int)$Artist['aliasid'];
|
||||
}
|
||||
|
||||
foreach ($ExtendedArtists as &$ArtistGroup) {
|
||||
foreach ($ArtistGroup as &$Artist) {
|
||||
$Artist['id'] = (int) $Artist['id'];
|
||||
$Artist['aliasid'] = (int) $Artist['aliasid'];
|
||||
$Artist['id'] = (int)$Artist['id'];
|
||||
$Artist['aliasid'] = (int)$Artist['aliasid'];
|
||||
}
|
||||
}
|
||||
|
||||
@ -213,38 +216,38 @@ function compare($X, $Y) {
|
||||
$NumSnatches += $Torrent['Snatched'];
|
||||
|
||||
$InnerTorrents[] = array(
|
||||
'id' => (int) $Torrent['ID'],
|
||||
'groupId' => (int) $Torrent['GroupID'],
|
||||
'id' => (int)$Torrent['ID'],
|
||||
'groupId' => (int)$Torrent['GroupID'],
|
||||
'media' => $Torrent['Media'],
|
||||
'format' => $Torrent['Format'],
|
||||
'encoding' => $Torrent['Encoding'],
|
||||
'remasterYear' => (int) $Torrent['RemasterYear'],
|
||||
'remasterYear' => (int)$Torrent['RemasterYear'],
|
||||
'remastered' => $Torrent['Remastered'] == 1,
|
||||
'remasterTitle' => $Torrent['RemasterTitle'],
|
||||
'remasterRecordLabel' => $Torrent['RemasterRecordLabel'],
|
||||
'scene' => $Torrent['Scene'] == 1,
|
||||
'hasLog' => $Torrent['HasLog'] == 1,
|
||||
'hasCue' => $Torrent['HasCue'] == 1,
|
||||
'logScore' => (int) $Torrent['LogScore'],
|
||||
'fileCount' => (int) $Torrent['FileCount'],
|
||||
'logScore' => (int)$Torrent['LogScore'],
|
||||
'fileCount' => (int)$Torrent['FileCount'],
|
||||
'freeTorrent' => $Torrent['FreeTorrent'] == 1,
|
||||
'size' => (int) $Torrent['Size'],
|
||||
'leechers' => (int) $Torrent['Leechers'],
|
||||
'seeders' => (int) $Torrent['Seeders'],
|
||||
'snatched' => (int) $Torrent['Snatched'],
|
||||
'size' => (int)$Torrent['Size'],
|
||||
'leechers' => (int)$Torrent['Leechers'],
|
||||
'seeders' => (int)$Torrent['Seeders'],
|
||||
'snatched' => (int)$Torrent['Snatched'],
|
||||
'time' => $Torrent['Time'],
|
||||
'hasFile' => (int) $Torrent['HasFile']
|
||||
'hasFile' => (int)$Torrent['HasFile']
|
||||
);
|
||||
}
|
||||
$JsonTorrents[] = array(
|
||||
'groupId' => (int) $GroupID,
|
||||
'groupId' => (int)$GroupID,
|
||||
'groupName' => $GroupName,
|
||||
'groupYear' => (int) $GroupYear,
|
||||
'groupYear' => (int)$GroupYear,
|
||||
'groupRecordLabel' => $GroupRecordLabel,
|
||||
'groupCatalogueNumber' => $GroupCatalogueNumber,
|
||||
'groupCategoryID' => $GroupCategoryID,
|
||||
'tags' => $TagList,
|
||||
'releaseType' => (int) $ReleaseType,
|
||||
'releaseType' => (int)$ReleaseType,
|
||||
'wikiImage' => $WikiImage,
|
||||
'groupVanityHouse' => $GroupVanityHouse == 1,
|
||||
'hasBookmarked' => Bookmarks::has_bookmarked('torrent', $GroupID),
|
||||
@ -274,10 +277,10 @@ function compare($X, $Y) {
|
||||
$SimilarArray = $DB->to_array();
|
||||
foreach ($SimilarArray as $Similar) {
|
||||
$JsonSimilar[] = array(
|
||||
'artistId' => (int) $Similar['ArtistID'],
|
||||
'artistId' => (int)$Similar['ArtistID'],
|
||||
'name' => $Similar['Name'],
|
||||
'score' => (int) $Similar['Score'],
|
||||
'similarId' => (int) $Similar['SimilarID']
|
||||
'score' => (int)$Similar['Score'],
|
||||
'similarId' => (int)$Similar['SimilarID']
|
||||
);
|
||||
}
|
||||
$NumSimilar = count($SimilarArray);
|
||||
@ -285,25 +288,24 @@ function compare($X, $Y) {
|
||||
//If data already exists, use it
|
||||
foreach ($SimilarArray as $Similar) {
|
||||
$JsonSimilar[] = array(
|
||||
'artistId' => (int) $Similar['ArtistID'],
|
||||
'artistId' => (int)$Similar['ArtistID'],
|
||||
'name' => $Similar['Name'],
|
||||
'score' => (int) $Similar['Score'],
|
||||
'similarId' => (int) $Similar['SimilarID']
|
||||
'score' => (int)$Similar['Score'],
|
||||
'similarId' => (int)$Similar['SimilarID']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$JsonRequests = array();
|
||||
foreach ($Requests as $Request) {
|
||||
list($RequestID, $CategoryID, $Title, $Year, $TimeAdded, $Votes, $Bounty) = $Request;
|
||||
foreach ($Requests as $RequestID => $Request) {
|
||||
$JsonRequests[] = array(
|
||||
'requestId' => (int) $RequestID,
|
||||
'categoryId' => (int) $CategoryID,
|
||||
'title' => $Title,
|
||||
'year' => (int) $Year,
|
||||
'timeAdded' => $TimeAdded,
|
||||
'votes' => (int) $Votes,
|
||||
'bounty' => (int) $Bounty
|
||||
'requestId' => (int)$RequestID,
|
||||
'categoryId' => (int)$Request['CategoryID'],
|
||||
'title' => $Request['Title'],
|
||||
'year' => (int)$Request['Year'],
|
||||
'timeAdded' => $Request['TimeAdded'],
|
||||
'votes' => (int)$Request['Votes'],
|
||||
'bounty' => (int)$Request['Bounty']
|
||||
);
|
||||
}
|
||||
|
||||
@ -340,7 +342,7 @@ function compare($X, $Y) {
|
||||
$Cache->cache_value($Key, $Data, 3600);
|
||||
|
||||
json_die("success", array(
|
||||
'id' => (int) $ArtistID,
|
||||
'id' => (int)$ArtistID,
|
||||
'name' => $Name,
|
||||
'notificationsEnabled' => $notificationsEnabled,
|
||||
'hasBookmarked' => Bookmarks::has_bookmarked('artist', $ArtistID),
|
||||
|
@ -18,8 +18,6 @@
|
||||
|
||||
$Results = Torrents::get_groups(array_keys($GroupIDs));
|
||||
|
||||
$Results = $Results['matches'];
|
||||
|
||||
$JsonResults = array();
|
||||
foreach ($Results as $GroupID => $Group) {
|
||||
extract(Torrents::array_group($Group));
|
||||
|
@ -15,7 +15,7 @@
|
||||
$_GET['type'] = display_str($_GET['type']);
|
||||
}
|
||||
}
|
||||
$SphQL = new SphinxQL_Query();
|
||||
$SphQL = new SphinxqlQuery();
|
||||
$SphQL->select('id, groupid')
|
||||
->from('better_transcode')
|
||||
->where('logscore', 100)
|
||||
@ -36,7 +36,6 @@
|
||||
|
||||
$Results = $SphQLResult->to_array('groupid');
|
||||
$Groups = Torrents::get_groups(array_keys($Results));
|
||||
$Groups = $Groups['matches'];
|
||||
|
||||
$TorrentGroups = array();
|
||||
foreach ($Groups as $GroupID => $Group) {
|
||||
|
@ -440,7 +440,7 @@ function header_link($SortKey, $DefaultWay = 'desc') {
|
||||
// Make sure we get TORRENTS_PER_PAGE results, or all of them if there are less than TORRENTS_PER_PAGE hits
|
||||
$SphQL->where('groupid', $GroupIDs, true);
|
||||
$SphQLResult = $SphQL->query();
|
||||
if (!$SphQLResult->get_meta('total')) {
|
||||
if (!$SphQLResult->has_results()) {
|
||||
break;
|
||||
}
|
||||
$Results += $SphQLResult->to_array('groupid');
|
||||
@ -482,8 +482,6 @@ function header_link($SortKey, $DefaultWay = 'desc') {
|
||||
|
||||
if ($TorrentCount) {
|
||||
$Groups = Torrents::get_groups($GroupIDs);
|
||||
$Groups = $Groups['matches'];
|
||||
|
||||
if (!empty($Groups) && $GroupResults) {
|
||||
$TorrentIDs = array();
|
||||
foreach ($Groups as $Group) {
|
||||
|
@ -65,20 +65,19 @@
|
||||
ORDER BY ct.Sort");
|
||||
$GroupIDs = $DB->collect('GroupID');
|
||||
$GroupList = Torrents::get_groups($GroupIDs);
|
||||
$GroupList = $GroupList['matches'];
|
||||
foreach ($GroupIDs as $GroupID) {
|
||||
if (isset($GroupList[$GroupID])) {
|
||||
if (!empty($GroupList[$GroupID])) {
|
||||
$GroupDetails = Torrents::array_group($GroupList[$GroupID]);
|
||||
if ($GroupDetails['GroupCategoryID'] > 0 && $Categories[$GroupDetails['GroupCategoryID'] - 1] == 'Music') {
|
||||
$ArtistForm = $GroupDetails['ExtendedArtists'];
|
||||
$JsonMusicInfo = array(
|
||||
'composers' => ($ArtistForm[4] == null) ? array() : pullmediainfo($ArtistForm[4]),
|
||||
'dj' => ($ArtistForm[6] == null) ? array() : pullmediainfo($ArtistForm[6]),
|
||||
'artists' => ($ArtistForm[1] == null) ? array() : pullmediainfo($ArtistForm[1]),
|
||||
'with' => ($ArtistForm[2] == null) ? array() : pullmediainfo($ArtistForm[2]),
|
||||
'conductor' => ($ArtistForm[5] == null) ? array() : pullmediainfo($ArtistForm[5]),
|
||||
'remixedBy' => ($ArtistForm[3] == null) ? array() : pullmediainfo($ArtistForm[3]),
|
||||
'producer' => ($ArtistForm[7] == null) ? array() : pullmediainfo($ArtistForm[7])
|
||||
'composers' => isset($ArtistForm[4]) ? pullmediainfo($ArtistForm[4]) : array(),
|
||||
'dj' => isset($ArtistForm[6]) ? pullmediainfo($ArtistForm[6]) : array(),
|
||||
'artists' => isset($ArtistForm[1]) ? pullmediainfo($ArtistForm[1]) : array(),
|
||||
'with' => isset($ArtistForm[2]) ? pullmediainfo($ArtistForm[2]) : array(),
|
||||
'conductor' => isset($ArtistForm[5]) ? pullmediainfo($ArtistForm[5]) : array(),
|
||||
'remixedBy' => isset($ArtistForm[3]) ? pullmediainfo($ArtistForm[3]) : array(),
|
||||
'producer' => isset($ArtistForm[7]) ? pullmediainfo($ArtistForm[7]) : array()
|
||||
);
|
||||
} else {
|
||||
$JsonMusicInfo = null;
|
||||
|
@ -30,13 +30,11 @@
|
||||
|
||||
if (count($GroupIDs)) {
|
||||
$TorrentGroups = Torrents::get_groups($GroupIDs);
|
||||
$TorrentGroups = $TorrentGroups['matches'];
|
||||
|
||||
$DB->query("
|
||||
UPDATE users_notify_torrents
|
||||
SET UnRead='0'
|
||||
WHERE UserID=".$LoggedUser['ID']);
|
||||
$Cache->delete_value('notifications_new_'.$LoggedUser['ID']);
|
||||
SET UnRead = '0'
|
||||
WHERE UserID = $LoggedUser[ID]");
|
||||
$Cache->delete_value("notifications_new_$LoggedUser[ID]");
|
||||
}
|
||||
|
||||
$DB->set_query_id($Results);
|
||||
|
@ -20,18 +20,17 @@
|
||||
|
||||
//First things first, lets get the data for the request.
|
||||
|
||||
$Request = Requests::get_requests(array($RequestID));
|
||||
$Request = $Request['matches'][$RequestID];
|
||||
if (empty($Request)) {
|
||||
$Request = Requests::get_request($RequestID);
|
||||
if ($Request === false) {
|
||||
json_die("failure");
|
||||
}
|
||||
|
||||
list($RequestID, $RequestorID, $RequestorName, $TimeAdded, $LastVote, $CategoryID, $Title, $Year, $Image, $Description, $CatalogueNumber, $RecordLabel, $ReleaseType,
|
||||
$BitrateList, $FormatList, $MediaList, $LogCue, $FillerID, $FillerName, $TorrentID, $TimeFilled, $GroupID, $OCLC) = $Request;
|
||||
|
||||
$CategoryID = $Request['CategoryID'];
|
||||
$Requestor = Users::user_info($Request['UserID']);
|
||||
$Filler = $Request['FillerID'] ? Users::user_info($Request['FillerID']) : null;
|
||||
//Convenience variables
|
||||
$IsFilled = !empty($TorrentID);
|
||||
$CanVote = (empty($TorrentID) && check_perms('site_vote'));
|
||||
$IsFilled = !empty($Request['TorrentID']);
|
||||
$CanVote = !$IsFilled && check_perms('site_vote');
|
||||
|
||||
if ($CategoryID == 0) {
|
||||
$CategoryName = 'Unknown';
|
||||
@ -42,21 +41,19 @@
|
||||
//Do we need to get artists?
|
||||
if ($CategoryName == 'Music') {
|
||||
$ArtistForm = Requests::get_artists($RequestID);
|
||||
$ArtistName = Artists::display_artists($ArtistForm, false, true);
|
||||
$ArtistLink = Artists::display_artists($ArtistForm, true, true);
|
||||
|
||||
if (empty($ReleaseType)) {
|
||||
if (empty($Request['ReleaseType'])) {
|
||||
$ReleaseName = 'Unknown';
|
||||
} else {
|
||||
$ReleaseName = $ReleaseTypes[$ReleaseType];
|
||||
$ReleaseName = $ReleaseTypes[$Request['ReleaseType']];
|
||||
}
|
||||
}
|
||||
|
||||
//Votes time
|
||||
$RequestVotes = Requests::get_votes_array($RequestID);
|
||||
$VoteCount = count($RequestVotes['Voters']);
|
||||
$ProjectCanEdit = (check_perms('project_team') && !$IsFilled && (($CategoryID == 0) || ($CategoryName == 'Music' && $Year == 0)));
|
||||
$UserCanEdit = (!$IsFilled && $LoggedUser['ID'] == $RequestorID && $VoteCount < 2);
|
||||
$ProjectCanEdit = (check_perms('project_team') && !$IsFilled && (($CategoryID == 0) || ($CategoryName == 'Music' && $Request['Year'] == 0)));
|
||||
$UserCanEdit = (!$IsFilled && $LoggedUser['ID'] == $Request['UserID'] && $VoteCount < 2);
|
||||
$CanEdit = ($UserCanEdit || $ProjectCanEdit || check_perms('site_moderate_requests'));
|
||||
|
||||
if ($CategoryName == "Music") {
|
||||
@ -67,13 +64,13 @@
|
||||
'with' => $ArtistForm[2] != null ? $ArtistForm[2] : array(),
|
||||
'conductor' => $ArtistForm[5] != null ? $ArtistForm[5] : array(),
|
||||
'remixedBy' => $ArtistForm[3] != null ? $ArtistForm[3] : array()*/
|
||||
'composers' => $ArtistForm[4] == null ? array() : pullmediainfo($ArtistForm[4]),
|
||||
'dj' => $ArtistForm[6] == null ? array() : pullmediainfo($ArtistForm[6]),
|
||||
'artists' => $ArtistForm[1] == null ? array() : pullmediainfo($ArtistForm[1]),
|
||||
'with' => $ArtistForm[2] == null ? array() : pullmediainfo($ArtistForm[2]),
|
||||
'conductor' => $ArtistForm[5] == null ? array() : pullmediainfo($ArtistForm[5]),
|
||||
'remixedBy' => $ArtistForm[3] == null ? array() : pullmediainfo($ArtistForm[3]),
|
||||
'producer' => $ArtistForm[7] == null ? array() : pullmediainfo($ArtistForm[7])
|
||||
'composers' => isset($ArtistForm[4]) ? pullmediainfo($ArtistForm[4]) : array(),
|
||||
'dj' => isset($ArtistForm[6]) ? pullmediainfo($ArtistForm[6]) : array(),
|
||||
'artists' => isset($ArtistForm[1]) ? pullmediainfo($ArtistForm[1]) : array(),
|
||||
'with' => isset($ArtistForm[2]) ? pullmediainfo($ArtistForm[2]) : array(),
|
||||
'conductor' => isset($ArtistForm[5]) ? pullmediainfo($ArtistForm[5]) : array(),
|
||||
'remixedBy' => isset($ArtistForm[3]) ? pullmediainfo($ArtistForm[3]) : array(),
|
||||
'producer' => isset($ArtistForm[7]) ? pullmediainfo($ArtistForm[7]) : array()
|
||||
);
|
||||
} else {
|
||||
$JsonMusicInfo = new stdClass; //json_encodes into an empty object: {}
|
||||
@ -98,17 +95,17 @@
|
||||
list($PostID, $AuthorID, $AddedTime, $Body, $EditedUserID, $EditedTime, $EditedUsername) = array_values($Post);
|
||||
list($AuthorID, $Username, $PermissionID, $Paranoia, $Artist, $Donor, $Warned, $Avatar, $Enabled, $UserTitle) = array_values(Users::user_info($AuthorID));
|
||||
$JsonRequestComments[] = array(
|
||||
'postId' => (int) $PostID,
|
||||
'authorId' => (int) $AuthorID,
|
||||
'postId' => (int)$PostID,
|
||||
'authorId' => (int)$AuthorID,
|
||||
'name' => $Username,
|
||||
'donor' => $Donor == 1,
|
||||
'warned' => ($Warned!='0000-00-00 00:00:00'),
|
||||
'warned' => ($Warned != '0000-00-00 00:00:00'),
|
||||
'enabled' => ($Enabled == 2 ? false : true),
|
||||
'class' => Users::make_class_string($PermissionID),
|
||||
'addedTime' => $AddedTime,
|
||||
'avatar' => $Avatar,
|
||||
'comment' => $Text->full_format($Body),
|
||||
'editedUserId' => (int) $EditedUserID,
|
||||
'editedUserId' => (int)$EditedUserID,
|
||||
'editedUsername' => $EditedUsername,
|
||||
'editedTime' => $EditedTime
|
||||
);
|
||||
@ -118,47 +115,45 @@
|
||||
foreach ($Request['Tags'] as $Tag) {
|
||||
$JsonTags[] = $Tag;
|
||||
}
|
||||
|
||||
json_die("success", array(
|
||||
'requestId' => (int) $RequestID,
|
||||
'requestorId' => (int) $RequestorID,
|
||||
'requestorName' => $RequestorName,
|
||||
json_die('success', array(
|
||||
'requestId' => (int)$RequestID,
|
||||
'requestorId' => (int)$Request['UserID'],
|
||||
'requestorName' => $Requestor['Username'],
|
||||
'isBookmarked' => Bookmarks::has_bookmarked('request', $RequestID),
|
||||
'requestTax' => $RequestTax,
|
||||
'timeAdded' => $TimeAdded,
|
||||
'timeAdded' => $Request['TimeAdded'],
|
||||
'canEdit' => $CanEdit,
|
||||
'canVote' => $CanVote,
|
||||
'minimumVote' => $MinimumVote,
|
||||
'voteCount' => $VoteCount,
|
||||
'lastVote' => $LastVote,
|
||||
'lastVote' => $Request['LastVote'],
|
||||
'topContributors' => $JsonTopContributors,
|
||||
'totalBounty' => (int) $RequestVotes['TotalBounty'],
|
||||
'categoryId' => (int) $CategoryID,
|
||||
'totalBounty' => (int)$RequestVotes['TotalBounty'],
|
||||
'categoryId' => (int)$CategoryID,
|
||||
'categoryName' => $CategoryName,
|
||||
'title' => $Title,
|
||||
'year' => (int) $Year,
|
||||
'image' => $Image,
|
||||
'bbDescription' => $Description,
|
||||
'description' => $Text->full_format($Description),
|
||||
'title' => $Request['Title'],
|
||||
'year' => (int)$Request['Year'],
|
||||
'image' => $Request['Image'],
|
||||
'bbDescription' => $Request['Description'],
|
||||
'description' => $Text->full_format($Request['Description']),
|
||||
'musicInfo' => $JsonMusicInfo,
|
||||
'catalogueNumber' => $CatalogueNumber,
|
||||
'releaseType' => (int) $ReleaseType,
|
||||
'catalogueNumber' => $Request['CatalogueNumber'],
|
||||
'releaseType' => (int)$Request['ReleaseType'],
|
||||
'releaseName' => $ReleaseName,
|
||||
'bitrateList' => preg_split('/\|/', $BitrateList, NULL, PREG_SPLIT_NO_EMPTY),
|
||||
'formatList' => preg_split('/\|/', $FormatList, NULL, PREG_SPLIT_NO_EMPTY),
|
||||
'mediaList' => preg_split('/\|/', $MediaList, NULL, PREG_SPLIT_NO_EMPTY),
|
||||
'logCue' => html_entity_decode($LogCue),
|
||||
'bitrateList' => preg_split('/\|/', $Request['BitrateList'], NULL, PREG_SPLIT_NO_EMPTY),
|
||||
'formatList' => preg_split('/\|/', $Request['FormatList'], NULL, PREG_SPLIT_NO_EMPTY),
|
||||
'mediaList' => preg_split('/\|/', $Request['MediaList'], NULL, PREG_SPLIT_NO_EMPTY),
|
||||
'logCue' => html_entity_decode($Request['LogCue']),
|
||||
'isFilled' => $IsFilled,
|
||||
'fillerId' => (int) $FillerID,
|
||||
'fillerName' => $FillerName,
|
||||
'torrentId' => (int) $TorrentID,
|
||||
'timeFilled' => $TimeFilled,
|
||||
'fillerId' => (int)$Request['FillerID'],
|
||||
'fillerName' => ($Filler ? $Filler['Username'] : ''),
|
||||
'torrentId' => (int)$Request['TorrentID'],
|
||||
'timeFilled' => $Request['TimeFilled'],
|
||||
'tags' => $JsonTags,
|
||||
'comments' => $JsonRequestComments,
|
||||
'commentPage' => (int) $Page,
|
||||
'commentPages' => (int) ceil($NumComments / TORRENT_COMMENTS_PER_PAGE),
|
||||
'recordLabel' => $RecordLabel,
|
||||
'oclc' => $OCLC
|
||||
'commentPage' => (int)$Page,
|
||||
'commentPages' => (int)ceil($NumComments / TORRENT_COMMENTS_PER_PAGE),
|
||||
'recordLabel' => $Request['RecordLabel'],
|
||||
'oclc' => $Request['OCLC']
|
||||
));
|
||||
|
||||
?>
|
||||
|
@ -1,60 +1,99 @@
|
||||
<?php
|
||||
$SphQL = new SphinxqlQuery();
|
||||
$SphQL->select('id, votes, bounty')->from('requests, requests_delta');
|
||||
|
||||
$Queries = array();
|
||||
$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'];
|
||||
|
||||
if (!empty($_GET['sort']) && $_GET['sort'] == 'asc') {
|
||||
$OrderWay = 'asc';
|
||||
} else {
|
||||
$_GET['sort'] = 'desc';
|
||||
$OrderWay = 'desc';
|
||||
}
|
||||
$NewSort = $_GET['sort'] === 'asc' ? 'desc' : 'asc';
|
||||
|
||||
if ($OrderBy === 'random') {
|
||||
$SphQL->order_by('RAND()', '');
|
||||
unset($_GET['page']);
|
||||
} else {
|
||||
$SphQL->order_by($SortOrders[$OrderBy], $OrderWay);
|
||||
}
|
||||
|
||||
$OrderWays = array('year', 'votes', 'bounty', 'created', 'lastvote', 'filled');
|
||||
list($Page, $Limit) = Format::page_limit(REQUESTS_PER_PAGE);
|
||||
$Submitted = !empty($_GET['submit']);
|
||||
|
||||
//Paranoia
|
||||
$UserInfo = Users::user_info((int)$_GET['userid']);
|
||||
$Perms = Permissions::get_permissions($UserInfo['PermissionID']);
|
||||
$UserClass = $Perms['Class'];
|
||||
|
||||
if (!empty($_GET['userid'])) {
|
||||
if (!is_number($_GET['userid'])) {
|
||||
json_die("failure");
|
||||
}
|
||||
$UserInfo = Users::user_info($_GET['userid']);
|
||||
if (empty($UserInfo)) {
|
||||
json_die("failure");
|
||||
}
|
||||
$Perms = Permissions::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));
|
||||
$SphQL->where('visible', 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'])) {
|
||||
json_die("failure");
|
||||
}
|
||||
$Title = "Requests voted for by ".$UserInfo['Username'];
|
||||
$SS->set_filter('voter', array($_GET['userid']));
|
||||
} else {
|
||||
if (!empty($UserInfo)) {
|
||||
if (!check_paranoia('requestsvoted_list', $UserInfo['Paranoia'], $Perms['Class'], $UserInfo['ID'])) {
|
||||
json_die("failure");
|
||||
}
|
||||
$Title = "Requests created by $UserInfo[Username]";
|
||||
$SphQL->where('userid', $UserInfo['ID']);
|
||||
} else {
|
||||
$Title = "Requests I've voted on";
|
||||
$SS->set_filter('voter', array($LoggedUser['ID']));
|
||||
$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'])) {
|
||||
json_die("failure");
|
||||
}
|
||||
$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($_GET['userid']) || !is_number($_GET['userid'])) {
|
||||
json_die("failure");
|
||||
} else {
|
||||
if (!check_paranoia('requestsfilled_list', $UserInfo['Paranoia'], $Perms['Class'], $_GET['userid'])) {
|
||||
if (!empty($UserInfo)) {
|
||||
if (!check_paranoia('requestsfilled_list', $UserInfo['Paranoia'], $Perms['Class'], $UserInfo['ID'])) {
|
||||
json_die("failure");
|
||||
}
|
||||
$Title = "Requests filled by ".$UserInfo['Username'];
|
||||
$SS->set_filter('fillerid', array($_GET['userid']));
|
||||
$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;
|
||||
$SS->set_filter('bookmarker', array($LoggedUser['ID']));
|
||||
$SphQL->where('bookmarker', $LoggedUser['ID']);
|
||||
break;
|
||||
default:
|
||||
json_die("failure");
|
||||
@ -62,50 +101,164 @@
|
||||
}
|
||||
|
||||
if ($Submitted && empty($_GET['show_filled'])) {
|
||||
$SS->set_filter('torrentid', array(0));
|
||||
$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 = array();
|
||||
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 = array();
|
||||
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 = array();
|
||||
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'])) {
|
||||
$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);
|
||||
$SearchString = trim($_GET['search']);
|
||||
if ($SearchString !== '') {
|
||||
$SearchWords = array('include' => array(), 'exclude' => array());
|
||||
$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;
|
||||
}
|
||||
} elseif (strlen($Word) >= 2) {
|
||||
$Word = $SS->EscapeString($Word);
|
||||
} else {
|
||||
unset($Words[$Key]);
|
||||
}
|
||||
}
|
||||
if (!empty($Words)) {
|
||||
$Queries[] = "@* ".implode(' ', $Words);
|
||||
$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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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'])) {
|
||||
$Tags = explode(',', $_GET['tags']);
|
||||
$TagNames = array();
|
||||
$TagNames = $TagsExclude = array();
|
||||
// Remove illegal characters from the given tag names
|
||||
foreach ($Tags as $Tag) {
|
||||
$Tag = ltrim($Tag);
|
||||
$Exclude = ($Tag[0] === '!');
|
||||
$Tag = Misc::sanitize_tag($Tag);
|
||||
if (!empty($Tag)) {
|
||||
$TagNames[] = $Tag;
|
||||
$TagsExclude[$Tag] = $Exclude;
|
||||
}
|
||||
}
|
||||
$AllNegative = !in_array(false, $TagsExclude, true);
|
||||
$Tags = Misc::get_tags($TagNames);
|
||||
|
||||
// Replace the ! characters that sanitize_tag removed
|
||||
if ($TagType === 1 || $AllNegative) {
|
||||
foreach ($TagNames as &$TagName) {
|
||||
if ($TagsExclude[$TagName]) {
|
||||
$TagName = "!$TagName";
|
||||
}
|
||||
}
|
||||
unset($TagName);
|
||||
}
|
||||
} elseif (!isset($_GET['tags_type']) || $_GET['tags_type'] !== '0') {
|
||||
$_GET['tags_type'] = 1;
|
||||
} else {
|
||||
$_GET['tags_type'] = 0;
|
||||
}
|
||||
|
||||
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));
|
||||
// 'All' tags
|
||||
if ($TagType === 1 && !empty($Tags)) {
|
||||
foreach ($Tags as $TagID => $TagName) {
|
||||
$SphQL->where('tagid', $TagID, $TagsExclude[$TagName]);
|
||||
}
|
||||
} else {
|
||||
$_GET['tags_type'] = '1';
|
||||
} elseif (!empty($Tags)) {
|
||||
$SphQL->where('tagid', array_keys($Tags), $AllNegative);
|
||||
}
|
||||
|
||||
if (!empty($_GET['filter_cat'])) {
|
||||
@ -117,7 +270,7 @@
|
||||
}
|
||||
}
|
||||
if (count($CategoryArray) >= 1) {
|
||||
$SS->set_filter('categoryid', $CategoryArray);
|
||||
$SphQL->where('categoryid', $CategoryArray);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -130,165 +283,51 @@
|
||||
unset($ReleaseArray[$Index]);
|
||||
}
|
||||
}
|
||||
|
||||
if (count($ReleaseArray) >= 1) {
|
||||
$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 (isset($Formats[$MasterIndex])) {
|
||||
$FormatNameArray[$Index] = '"'.strtr($Formats[$MasterIndex], '-.', ' ').'"';
|
||||
}
|
||||
}
|
||||
|
||||
if (count($FormatNameArray) >= 1) {
|
||||
$Queries[]='@formatlist (any | '.implode(' | ', $FormatNameArray).')';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($_GET['media'])) {
|
||||
$MediaArray = $_GET['media'];
|
||||
if (count($MediaArray) !== count($Media)) {
|
||||
$MediaNameArray = array();
|
||||
foreach ($MediaArray as $Index => $MasterIndex) {
|
||||
if (isset($Media[$MasterIndex])) {
|
||||
$MediaNameArray[$Index] = '"'.strtr($Media[$MasterIndex], '-.', ' ').'"';
|
||||
}
|
||||
}
|
||||
|
||||
if (count($MediaNameArray) >= 1) {
|
||||
$Queries[]='@medialist (any | '.implode(' | ', $MediaNameArray).')';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($_GET['bitrates'])) {
|
||||
$BitrateArray = $_GET['bitrates'];
|
||||
if (count($BitrateArray) !== count($Bitrates)) {
|
||||
$BitrateNameArray = array();
|
||||
foreach ($BitrateArray as $Index => $MasterIndex) {
|
||||
if (isset($Bitrates[$MasterIndex])) {
|
||||
$BitrateNameArray[$Index] = '"'.strtr($SS->EscapeString($Bitrates[$MasterIndex]), '-.', ' ').'"';
|
||||
}
|
||||
}
|
||||
|
||||
if (count($BitrateNameArray) >= 1) {
|
||||
$Queries[]='@bitratelist (any | '.implode(' | ', $BitrateNameArray).')';
|
||||
$SphQL->where('releasetype', $ReleaseArray);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($_GET['requestor']) && check_perms('site_see_old_requests')) {
|
||||
if (is_number($_GET['requestor'])) {
|
||||
$SS->set_filter('userid', array($_GET['requestor']));
|
||||
$SphQL->where('userid', $_GET['requestor']);
|
||||
} else {
|
||||
json_die("failure");
|
||||
error(404);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_GET['year'])) {
|
||||
if (is_number($_GET['year']) || $_GET['year'] == 0) {
|
||||
$SS->set_filter('year', array($_GET['year']));
|
||||
if (is_number($_GET['year']) || $_GET['year'] === '0') {
|
||||
$SphQL->where('year', $_GET['year']);
|
||||
} else {
|
||||
json_die("failure");
|
||||
error(404);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($_GET['page']) && is_number($_GET['page']) && $_GET['page'] > 0) {
|
||||
$Page = $_GET['page'];
|
||||
$SS->limit(($Page - 1) * REQUESTS_PER_PAGE, REQUESTS_PER_PAGE);
|
||||
$Offset = ($Page - 1) * REQUESTS_PER_PAGE;
|
||||
$SphQL->limit($Offset, REQUESTS_PER_PAGE, $Offset + REQUESTS_PER_PAGE);
|
||||
} else {
|
||||
$Page = 1;
|
||||
$SS->limit(0, REQUESTS_PER_PAGE);
|
||||
$SphQL->limit(0, REQUESTS_PER_PAGE, REQUESTS_PER_PAGE);
|
||||
}
|
||||
|
||||
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 {
|
||||
json_die("failure");
|
||||
}
|
||||
} else {
|
||||
json_die("failure");
|
||||
$SphQLResult = $SphQL->query();
|
||||
$NumResults = (int)$SphQLResult->get_meta('total_found');
|
||||
if ($NumResults > 0) {
|
||||
$SphRequests = $SphQLResult->to_array('id');
|
||||
if ($OrderBy === 'random') {
|
||||
$NumResults = count($RequestIDs);
|
||||
}
|
||||
}
|
||||
|
||||
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 = Requests::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]);
|
||||
if ($NumResults > REQUESTS_PER_PAGE) {
|
||||
if (($Page - 1) * REQUESTS_PER_PAGE > $NumResults) {
|
||||
$Page = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// 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]);
|
||||
}
|
||||
}
|
||||
|
||||
$Requests = $SphinxResults['matches'];
|
||||
|
||||
if ($NumResults == 0) {
|
||||
json_die("success", array(
|
||||
'currentPage' => 1,
|
||||
@ -298,23 +337,18 @@
|
||||
} else {
|
||||
$JsonResults = array();
|
||||
$TimeCompare = 1267643718; // Requests v2 was implemented 2010-03-03 20:15:18
|
||||
foreach ($Requests as $RequestID => $Request) {
|
||||
$Requests = Requests::get_requests(array_keys($SphRequests));
|
||||
foreach ($SphRequests as $RequestID => $SphRequest) {
|
||||
$Request = $Requests[$RequestID];
|
||||
$VoteCount = $SphRequest['votes'];
|
||||
$Bounty = $SphRequest['bounty'] * 1024; // Sphinx stores bounty in kB
|
||||
$Requestor = Users::user_info($Request['UserID']);
|
||||
$Filler = $Request['FillerID'] ? Users::user_info($Request['FillerID']) : null;
|
||||
|
||||
//list($BitrateList, $CatalogueNumber, $CategoryID, $Description, $FillerID, $FormatList, $RequestID, $Image, $LogCue, $MediaList, $ReleaseType,
|
||||
// $Tags, $TimeAdded, $TimeFilled, $Title, $TorrentID, $RequestorID, $RequestorName, $Year, $RequestID, $Categoryid, $FillerID, $LastVote,
|
||||
// $ReleaseType, $TagIDs, $TimeAdded, $TimeFilled, $TorrentID, $RequestorID, $Voters) = array_values($Request);
|
||||
|
||||
list($RequestID, $RequestorID, $RequestorName, $TimeAdded, $LastVote, $CategoryID, $Title, $Year, $Image, $Description, $CatalogueNumber,
|
||||
$ReleaseType, $BitrateList, $FormatList, $MediaList, $LogCue, $FillerID, $FillerName, $TorrentID, $TimeFilled) = $Request;
|
||||
|
||||
$RequestVotes = Requests::get_votes_array($RequestID);
|
||||
|
||||
$VoteCount = count($RequestVotes['Voters']);
|
||||
|
||||
if ($CategoryID == 0) {
|
||||
if ($Request['CategoryID'] == 0) {
|
||||
$CategoryName = 'Unknown';
|
||||
} else {
|
||||
$CategoryName = $Categories[$CategoryID - 1];
|
||||
$CategoryName = $Categories[$Request['CategoryID'] - 1];
|
||||
}
|
||||
|
||||
$JsonArtists = array();
|
||||
@ -326,33 +360,35 @@
|
||||
$Tags = $Request['Tags'];
|
||||
|
||||
$JsonResults[] = array(
|
||||
'requestId' => (int) $RequestID,
|
||||
'requestorId' => (int) $RequestorID,
|
||||
'requestorName' => $RequestorName,
|
||||
'timeAdded' => $TimeAdded,
|
||||
'lastVote' => $LastVote,
|
||||
'voteCount' => $VoteCount,
|
||||
'bounty' => $RequestVotes['TotalBounty'],
|
||||
'categoryId' => (int) $CategoryID,
|
||||
'requestId' => (int)$RequestID,
|
||||
'requestorId' => (int)$Requestor['ID'],
|
||||
'requestorName' => $Requestor['Username'],
|
||||
'timeAdded' => $Request['TimeAdded'],
|
||||
'lastVote' => $Request['LastVote'],
|
||||
'voteCount' => (int)$VoteCount,
|
||||
'bounty' => (int)$Bounty,
|
||||
'categoryId' => (int)$Request['CategoryID'],
|
||||
'categoryName' => $CategoryName,
|
||||
'artists' => $JsonArtists,
|
||||
'title' => $Title,
|
||||
'year' => (int) $Year,
|
||||
'image' => $Image,
|
||||
'description' => $Description,
|
||||
'catalogueNumber' => $CatalogueNumber,
|
||||
'releaseType' => $ReleaseType,
|
||||
'bitrateList' => $BitrateList,
|
||||
'formatList' => $FormatList,
|
||||
'mediaList' => $MediaList,
|
||||
'logCue' => $LogCue,
|
||||
'isFilled' => ($TorrentID > 0),
|
||||
'fillerId' => (int) $FillerID,
|
||||
'fillerName' => $FillerName == 0 ? '' : $FillerName,
|
||||
'torrentId' => (int) $TorrentID,
|
||||
'timeFilled' => $TimeFilled == 0 ? '' : $TimeFilled
|
||||
'title' => $Request['Title'],
|
||||
'year' => (int)$Request['Year'],
|
||||
'image' => $Request['Image'],
|
||||
'description' => $Request['Description'],
|
||||
'recordLabel' => $Request['RecordLabel'],
|
||||
'catalogueNumber' => $Request['CatalogueNumber'],
|
||||
'releaseType' => $ReleaseTypes[$Request['ReleaseType']],
|
||||
'bitrateList' => $Request['BitrateList'],
|
||||
'formatList' => $Request['FormatList'],
|
||||
'mediaList' => $Request['MediaList'],
|
||||
'logCue' => $Request['LogCue'],
|
||||
'isFilled' => ($Request['TorrentID'] > 0),
|
||||
'fillerId' => (int)$Request['FillerID'],
|
||||
'fillerName' => $Filler ? $Filler['Username'] : '',
|
||||
'torrentId' => (int)$Request['TorrentID'],
|
||||
'timeFilled' => $Request['TimeFilled'] == 0 ? '' : $Request['TimeFilled']
|
||||
);
|
||||
}
|
||||
|
||||
json_die("success", array(
|
||||
'currentPage' => intval($Page),
|
||||
'pages' => ceil($NumResults / REQUESTS_PER_PAGE),
|
||||
|
@ -94,7 +94,7 @@ function compare($X, $Y) {
|
||||
ORDER BY Votes DESC");
|
||||
|
||||
if ($DB->has_results()) {
|
||||
$Requests = $DB->to_array();
|
||||
$Requests = $DB->to_array('ID', MYSQLI_ASSOC, false);
|
||||
} else {
|
||||
$Requests = array();
|
||||
}
|
||||
@ -123,7 +123,6 @@ function compare($X, $Y) {
|
||||
}
|
||||
if (count($GroupIDs) > 0) {
|
||||
$TorrentList = Torrents::get_groups($GroupIDs, true, true);
|
||||
$TorrentList = $TorrentList['matches'];
|
||||
} else {
|
||||
$TorrentList = array();
|
||||
}
|
||||
@ -791,47 +790,48 @@ function compare($X, $Y) {
|
||||
</td>
|
||||
</tr>
|
||||
<?
|
||||
foreach ($Requests as $Request) {
|
||||
list($RequestID, $CategoryID, $Title, $Year, $TimeAdded, $Votes, $Bounty) = $Request;
|
||||
|
||||
$CategoryName = $Categories[$CategoryID - 1];
|
||||
|
||||
$Tags = Requests::get_tags(array_keys($Requests));
|
||||
$Row = 0;
|
||||
foreach ($Requests as $RequestID => $Request) {
|
||||
$CategoryName = $Categories[$Request['CategoryID'] - 1];
|
||||
$Title = display_str($Request['Title']);
|
||||
if ($CategoryName == 'Music') {
|
||||
$ArtistForm = Requests::get_artists($RequestID);
|
||||
$ArtistLink = Artists::display_artists($ArtistForm, true, true);
|
||||
$FullName = $ArtistLink."<a href=\"requests.php?action=view&id=$RequestID\">$Title [$Year]</a>";
|
||||
$FullName = $ArtistLink."<a href=\"requests.php?action=view&id=$RequestID\">$Title [$Request[Year]]</a>";
|
||||
} elseif ($CategoryName == 'Audiobooks' || $CategoryName == 'Comedy') {
|
||||
$FullName = "<a href=\"requests.php?action=view&id=$RequestID\">$Title [$Year]</a>";
|
||||
$FullName = "<a href=\"requests.php?action=view&id=$RequestID\">$Title [$Request[Year]]</a>";
|
||||
} else {
|
||||
$FullName = "<a href=\"requests.php?action=view&id=$RequestID\">$Title</a>";
|
||||
}
|
||||
|
||||
$Row = $Row === 'a' ? 'b' : 'a';
|
||||
|
||||
$Tags = Requests::get_tags($RequestID);
|
||||
$ReqTagList = array();
|
||||
foreach ($Tags as $TagID => $TagName) {
|
||||
$ReqTagList[] = "<a href=\"requests.php?tags=$TagName\">".display_str($TagName).'</a>';
|
||||
if (!empty($Tags[$RequestID])) {
|
||||
$ReqTagList = array();
|
||||
foreach ($Tags[$RequestID] as $TagID => $TagName) {
|
||||
$ReqTagList[] = "<a href=\"requests.php?tags=$TagName\">".display_str($TagName).'</a>';
|
||||
}
|
||||
$ReqTagList = implode(', ', $ReqTagList);
|
||||
} else {
|
||||
$ReqTagList = '';
|
||||
}
|
||||
$ReqTagList = implode(', ', $ReqTagList);
|
||||
?>
|
||||
<tr class="row<?=$Row?>">
|
||||
<tr class="row<?=($Row++ & 1 ? 'a' : 'b')?>">
|
||||
<td>
|
||||
<?=$FullName?>
|
||||
<div class="tags"><?=$ReqTagList?></div>
|
||||
</td>
|
||||
<td>
|
||||
<span id="vote_count_<?=$RequestID?>"><?=$Votes?></span>
|
||||
<span id="vote_count_<?=$RequestID?>"><?=$Request['Votes']?></span>
|
||||
<? if (check_perms('site_vote')) { ?>
|
||||
<input type="hidden" id="auth" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
|
||||
<a href="javascript:Vote(0, <?=$RequestID?>)" class="brackets"><strong>+</strong></a>
|
||||
<? } ?>
|
||||
</td>
|
||||
<td>
|
||||
<span id="bounty_<?=$RequestID?>"><?=Format::get_size($Bounty)?></span>
|
||||
<span id="bounty_<?=$RequestID?>"><?=Format::get_size($Request['Bounty'])?></span>
|
||||
</td>
|
||||
<td>
|
||||
<?=time_diff($TimeAdded)?>
|
||||
<?=time_diff($Request['TimeAdded'])?>
|
||||
</td>
|
||||
</tr>
|
||||
<? } ?>
|
||||
|
@ -33,7 +33,6 @@
|
||||
$GroupIDs[] = $Torrent['GroupID'];
|
||||
}
|
||||
$Results = Torrents::get_groups($GroupIDs);
|
||||
$Results = $Results['matches'];
|
||||
?>
|
||||
<div class="header">
|
||||
<? if ($All) { ?>
|
||||
|
@ -33,7 +33,6 @@
|
||||
$GroupIDs[] = $Torrent['GroupID'];
|
||||
}
|
||||
$Results = Torrents::get_groups($GroupIDs);
|
||||
$Results = $Results['matches'];
|
||||
?>
|
||||
<div class="header">
|
||||
<? if ($All) { ?>
|
||||
|
@ -29,7 +29,6 @@
|
||||
<td>Torrent</td>
|
||||
</tr>
|
||||
<?
|
||||
$Results = $Results['matches'];
|
||||
foreach ($Results as $GroupID => $Group) {
|
||||
extract(Torrents::array_group($Group));
|
||||
$TorrentTags = new Tags($TagList);
|
||||
|
@ -57,10 +57,6 @@
|
||||
AND t.Format IN ('FLAC', 'MP3')
|
||||
GROUP BY t.GroupID, RemIdent");
|
||||
|
||||
/*$DB->query('
|
||||
SELECT *
|
||||
FROM t');
|
||||
*/
|
||||
$DB->query("
|
||||
SELECT GroupID
|
||||
FROM temp_sections_better_snatch
|
||||
@ -75,8 +71,6 @@
|
||||
}
|
||||
|
||||
$Groups = Torrents::get_groups(array_keys($GroupIDs));
|
||||
$Groups = $Groups['matches'];
|
||||
|
||||
$TorrentGroups = array();
|
||||
foreach ($Groups as $GroupID => $Group) {
|
||||
if (empty($Group['Torrents'])) {
|
||||
|
@ -33,7 +33,6 @@
|
||||
$GroupIDs[] = $Torrent['GroupID'];
|
||||
}
|
||||
$Results = Torrents::get_groups($GroupIDs);
|
||||
$Results = $Results['matches'];
|
||||
?>
|
||||
<div class="header">
|
||||
<? if ($All) { ?>
|
||||
|
@ -36,9 +36,6 @@
|
||||
|
||||
$Results = $SphQLResult->to_array('groupid');
|
||||
$Groups = Torrents::get_groups(array_keys($Results));
|
||||
$Groups = $Groups['matches'];
|
||||
|
||||
$Debug->log_var(true, 'Excluding '.$Encodings[$_GET['type']]);
|
||||
$TorrentGroups = array();
|
||||
foreach ($Groups as $GroupID => $Group) {
|
||||
if (empty($Group['Torrents'])) {
|
||||
@ -78,7 +75,6 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
$Debug->log_var($TorrentGroups, 'Torrent groups');
|
||||
|
||||
View::show_header('Transcode Search');
|
||||
?>
|
||||
@ -133,7 +129,6 @@
|
||||
|| $Edition['Formats'][$Encodings[$_GET['type']]] == true //the transcode we asked for is already there
|
||||
|| count($Edition['Formats']) === 3) //all 3 transcodes are there already (this can happen due to the caching of Sphinx's better_transcode table)
|
||||
{
|
||||
$Debug->log_var($Edition, 'Skipping '.$RemIdent);
|
||||
continue;
|
||||
}
|
||||
$DisplayName = $ArtistNames . '<a href="torrents.php?id='.$GroupID.'&torrentid='.$Edition['FlacID'].'#torrent'.$Edition['FlacID'].'" title="View Torrent" dir="ltr">'.$GroupName.'</a>';
|
||||
|
@ -138,7 +138,7 @@ function transcode_parse_groups($Groups) {
|
||||
if ($ResultCount != 0) {
|
||||
$Results = $SphQLResult->collect('groupid');
|
||||
$Groups = Torrents::get_groups(array_values($Results));
|
||||
$Groups = transcode_parse_groups($Groups['matches']);
|
||||
$Groups = transcode_parse_groups($Groups);
|
||||
}
|
||||
unset($SphQL, $SphQLResult, $Results);
|
||||
} elseif (in_array($_GET['filter'], array('snatched', 'seeding'))) {
|
||||
@ -168,7 +168,7 @@ function transcode_parse_groups($Groups) {
|
||||
$SphQLResult = $SphQL->query();
|
||||
$ResultsTmp = $SphQLResult->collect('groupid');
|
||||
$GroupsTmp = Torrents::get_groups(array_values($ResultsTmp));
|
||||
$GroupsTmp = transcode_parse_groups($GroupsTmp['matches']);
|
||||
$GroupsTmp = transcode_parse_groups($GroupsTmp);
|
||||
// Since we're asking Sphinxql about groups and remidents, the result can/will contain different editions that are transcodable but weren't snatched, so let's filter them out
|
||||
foreach ($GroupsTmp as $GroupID => $Group) {
|
||||
foreach ($Group['Editions'] as $RemIdent => $Edition) {
|
||||
|
@ -59,8 +59,6 @@
|
||||
}
|
||||
|
||||
$Groups = Torrents::get_groups(array_keys($GroupIDs));
|
||||
$Groups = $Groups['matches'];
|
||||
|
||||
$TorrentGroups = array();
|
||||
foreach ($Groups as $GroupID => $Group) {
|
||||
if (empty($Group['Torrents'])) {
|
||||
|
@ -17,45 +17,47 @@
|
||||
if (!is_number($_GET['id'])) {
|
||||
error(0);
|
||||
}
|
||||
$PageID = $_GET['id'];
|
||||
|
||||
$DB->query("
|
||||
SELECT UserID
|
||||
FROM $Table
|
||||
WHERE UserID='$LoggedUser[ID]'
|
||||
AND $Col='".db_string($_GET['id'])."'");
|
||||
WHERE UserID = '$LoggedUser[ID]'
|
||||
AND $Col = $PageID");
|
||||
if (!$DB->has_results()) {
|
||||
if ($Type === 'torrent') {
|
||||
$DB->query('
|
||||
$DB->query("
|
||||
SELECT MAX(Sort)
|
||||
FROM `bookmarks_torrents`
|
||||
WHERE UserID = ' . $LoggedUser['ID']);
|
||||
WHERE UserID = $LoggedUser[ID]");
|
||||
list($Sort) = $DB->next_record();
|
||||
if (!$Sort) $Sort = 0;
|
||||
if (!$Sort) {
|
||||
$Sort = 0;
|
||||
}
|
||||
$Sort += 1;
|
||||
$DB->query("
|
||||
INSERT IGNORE INTO $Table (UserID, $Col, Time, Sort)
|
||||
VALUES ('$LoggedUser[ID]', '".db_string($_GET['id'])."', '".sqltime()."', $Sort)");
|
||||
VALUES ('$LoggedUser[ID]', $PageID, '".sqltime()."', $Sort)");
|
||||
} else {
|
||||
$DB->query("
|
||||
INSERT IGNORE INTO $Table (UserID, $Col, Time)
|
||||
VALUES ('$LoggedUser[ID]', '".db_string($_GET['id'])."', '".sqltime()."')");
|
||||
VALUES ('$LoggedUser[ID]', $PageID, '".sqltime()."')");
|
||||
}
|
||||
$Cache->delete_value('bookmarks_'.$Type.'_'.$LoggedUser['ID']);
|
||||
if ($Type == 'torrent') {
|
||||
$Cache->delete_value('bookmarks_group_ids_' . $UserID);
|
||||
$GroupID = (int) $_GET['id'];
|
||||
$Cache->delete_value("bookmarks_group_ids_$UserID");
|
||||
|
||||
$DB->query("
|
||||
SELECT Name, Year, WikiBody, TagList
|
||||
FROM torrents_group
|
||||
WHERE ID = '$GroupID'");
|
||||
WHERE ID = $PageID");
|
||||
list($GroupTitle, $Year, $Body, $TagList) = $DB->next_record();
|
||||
$TagList = str_replace('_', '.', $TagList);
|
||||
|
||||
$DB->query("
|
||||
SELECT ID, Format, Encoding, HasLog, HasCue, LogScore, Media, Scene, FreeTorrent, UserID
|
||||
FROM torrents
|
||||
WHERE GroupID = '$GroupID'");
|
||||
WHERE GroupID = $PageID");
|
||||
// RSS feed stuff
|
||||
while ($Torrent = $DB->next_record()) {
|
||||
$Title = $GroupTitle;
|
||||
@ -87,7 +89,7 @@
|
||||
$Text->strip_bbcode($Body),
|
||||
'torrents.php?action=download&authkey=[[AUTHKEY]]&torrent_pass=[[PASSKEY]]&id='.$TorrentID,
|
||||
$UploaderInfo['Username'],
|
||||
"torrents.php?id=$GroupID",
|
||||
"torrents.php?id=$PageID",
|
||||
trim($TagList));
|
||||
$Feed->populate('torrents_bookmarks_t_'.$LoggedUser['torrent_pass'], $Item);
|
||||
}
|
||||
@ -95,8 +97,15 @@
|
||||
$DB->query("
|
||||
SELECT UserID
|
||||
FROM $Table
|
||||
WHERE $Col = '".db_string($_GET['id'])."'");
|
||||
$Bookmarkers = $DB->collect('UserID');
|
||||
$SS->UpdateAttributes('requests requests_delta', array('bookmarker'), array($_GET['id'] => array($Bookmarkers)), true);
|
||||
WHERE $Col = '".db_string($PageID)."'");
|
||||
if ($DB->record_count() < 100) {
|
||||
// Sphinx doesn't like huge MVA updates. Update sphinx_requests_delta
|
||||
// and live with the <= 1 minute delay if we have more than 100 bookmarkers
|
||||
$Bookmarkers = implode(',', $DB->collect('UserID'));
|
||||
$SphQL = new SphinxqlQuery();
|
||||
$SphQL->raw_query("UPDATE requests, requests_delta SET bookmarker = ($Bookmarkers) WHERE id = $PageID");
|
||||
} else {
|
||||
Requests::update_sphinx_requests($PageID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?
|
||||
authorize();
|
||||
|
||||
if (!Bookmarks::can_bookmark($_GET['type'])) {
|
||||
@ -12,20 +12,30 @@
|
||||
if (!is_number($_GET['id'])) {
|
||||
error(0);
|
||||
}
|
||||
$PageID = $_GET['id'];
|
||||
|
||||
$DB->query("
|
||||
DELETE FROM $Table
|
||||
WHERE UserID = '".$LoggedUser['ID']."'
|
||||
AND $Col = '".db_string($_GET['id'])."'");
|
||||
$Cache->delete_value("bookmarks_$Type"."_$UserID");
|
||||
WHERE UserID = $LoggedUser[ID]
|
||||
AND $Col = $PageID");
|
||||
$Cache->delete_value("bookmarks_{$Type}_$UserID");
|
||||
|
||||
if ($Type === 'torrent') {
|
||||
$Cache->delete_value("bookmarks_group_ids_$UserID");
|
||||
} elseif ($Type === 'request') {
|
||||
$DB->query("
|
||||
SELECT UserID
|
||||
FROM $Table
|
||||
WHERE $Col = '".db_string($_GET['id'])."'");
|
||||
$Bookmarkers = $DB->collect('UserID');
|
||||
$SS->UpdateAttributes('requests requests_delta', array('bookmarker'), array($_GET['id'] => array($Bookmarkers)), true);
|
||||
if ($DB->affected_rows()) {
|
||||
if ($Type === 'torrent') {
|
||||
$Cache->delete_value("bookmarks_group_ids_$UserID");
|
||||
} elseif ($Type === 'request') {
|
||||
$DB->query("
|
||||
SELECT UserID
|
||||
FROM $Table
|
||||
WHERE $Col = $PageID");
|
||||
if ($DB->record_count() < 100) {
|
||||
// Sphinx doesn't like huge MVA updates. Update sphinx_requests_delta
|
||||
// and live with the <= 1 minute delay if we have more than 100 bookmarkers
|
||||
$Bookmarkers = implode(',', $DB->collect('UserID'));
|
||||
$SphQL = new SphinxqlQuery();
|
||||
$SphQL->raw_query("UPDATE requests, requests_delta SET bookmarker = ($Bookmarkers) WHERE id = $PageID");
|
||||
} else {
|
||||
Requests::update_sphinx_requests($PageID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,6 @@
|
||||
$CollageDataList = $DB->to_array('GroupID', MYSQLI_ASSOC);
|
||||
if (count($GroupIDs) > 0) {
|
||||
$TorrentList = Torrents::get_groups($GroupIDs);
|
||||
$TorrentList = $TorrentList['matches'];
|
||||
} else {
|
||||
$TorrentList = array();
|
||||
}
|
||||
|
@ -17,7 +17,6 @@
|
||||
$CollageDataList = $DB->to_array('GroupID', MYSQLI_ASSOC);
|
||||
if (count($GroupIDs) > 0) {
|
||||
$TorrentList = Torrents::get_groups($GroupIDs);
|
||||
$TorrentList = $TorrentList['matches'];
|
||||
} else {
|
||||
$TorrentList = array();
|
||||
}
|
||||
|
@ -57,9 +57,9 @@
|
||||
|
||||
$DB->query("
|
||||
INSERT INTO forums_topics
|
||||
(Title, AuthorID, ForumID, LastPostTime, LastPostAuthorID)
|
||||
(Title, AuthorID, ForumID, LastPostTime, LastPostAuthorID, CreatedTime)
|
||||
Values
|
||||
('".db_string($Title)."', '".$LoggedUser['ID']."', '$ForumID', '".sqltime()."', '".$LoggedUser['ID']."')");
|
||||
('".db_string($Title)."', '".$LoggedUser['ID']."', '$ForumID', '".sqltime()."', '".$LoggedUser['ID']."', '".sqltime()."')");
|
||||
$TopicID = $DB->inserted_id();
|
||||
|
||||
$DB->query("
|
||||
|
@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
|
||||
$NewRequest = ($_GET['action'] === 'new' ? true : false);
|
||||
$NewRequest = $_GET['action'] === 'new';
|
||||
|
||||
if (!$NewRequest) {
|
||||
$RequestID = $_GET['id'];
|
||||
@ -24,31 +24,37 @@
|
||||
if (!$NewRequest) {
|
||||
if (empty($ReturnEdit)) {
|
||||
|
||||
$Request = Requests::get_requests(array($RequestID));
|
||||
$Request = $Request['matches'][$RequestID];
|
||||
if (empty($Request)) {
|
||||
$Request = Requests::get_request($RequestID);
|
||||
if ($Request === false) {
|
||||
error(404);
|
||||
}
|
||||
|
||||
list($RequestID, $RequestorID, $RequestorName, $TimeAdded, $LastVote, $CategoryID, $Title, $Year, $Image, $Description, $CatalogueNumber, $RecordLabel,
|
||||
$ReleaseType, $BitrateList, $FormatList, $MediaList, $LogCue, $FillerID, $FillerName, $TorrentID, $TimeFilled, $GroupID, $OCLC) = $Request;
|
||||
// Define these variables to simplify _GET['groupid'] requests later on
|
||||
$CategoryID = $Request['CategoryID'];
|
||||
$Title = $Request['Title'];
|
||||
$Year = $Request['Year'];
|
||||
$Image = $Request['Image'];
|
||||
$ReleaseType = $Request['ReleaseType'];
|
||||
$GroupID = $Request['GroupID'];
|
||||
|
||||
$VoteArray = Requests::get_votes_array($RequestID);
|
||||
$VoteCount = count($VoteArray['Voters']);
|
||||
|
||||
$LogCue = $Request['LogCue'];
|
||||
$NeedCue = (strpos($LogCue, 'Cue') !== false);
|
||||
$NeedLog = (strpos($LogCue, 'Log') !== false);
|
||||
if ($NeedLog) {
|
||||
if (strpos($LogCue, '%') !== false) {
|
||||
preg_match('/\d+/', $LogCue, $Matches);
|
||||
$MinLogScore = (int) $Matches[0];
|
||||
$MinLogScore = (int)$Matches[0];
|
||||
}
|
||||
}
|
||||
|
||||
$IsFilled = !empty($TorrentID);
|
||||
$IsFilled = !empty($Request['TorrentID']);
|
||||
$CategoryName = $Categories[$CategoryID - 1];
|
||||
|
||||
$ProjectCanEdit = (check_perms('project_team') && !$IsFilled && (($CategoryID === '0') || ($CategoryName === 'Music' && $Year === '0')));
|
||||
$CanEdit = ((!$IsFilled && $LoggedUser['ID'] === $RequestorID && $VoteCount < 2) || $ProjectCanEdit || check_perms('site_moderate_requests'));
|
||||
$ProjectCanEdit = (check_perms('project_team') && !$IsFilled && ($CategoryID === '0' || ($CategoryName === 'Music' && $Request['Year'] === '0')));
|
||||
$CanEdit = ((!$IsFilled && $LoggedUser['ID'] === $Request['UserID'] && $VoteCount < 2) || $ProjectCanEdit || check_perms('site_moderate_requests'));
|
||||
|
||||
if (!$CanEdit) {
|
||||
error(403);
|
||||
@ -58,29 +64,28 @@
|
||||
$ArtistForm = Requests::get_artists($RequestID);
|
||||
|
||||
$BitrateArray = array();
|
||||
if ($BitrateList == 'Any') {
|
||||
if ($Request['BitrateList'] == 'Any') {
|
||||
$BitrateArray = array_keys($Bitrates);
|
||||
} else {
|
||||
$BitrateArray = array_keys(array_intersect($Bitrates,explode('|', $BitrateList)));
|
||||
$BitrateArray = array_keys(array_intersect($Bitrates, explode('|', $Request['BitrateList'])));
|
||||
}
|
||||
|
||||
$FormatArray = array();
|
||||
if ($FormatList == 'Any') {
|
||||
if ($Request['FormatList'] == 'Any') {
|
||||
$FormatArray = array_keys($Formats);
|
||||
} else {
|
||||
foreach ($Formats as $Key => $Val) {
|
||||
if (strpos($FormatList, $Val) !== false) {
|
||||
if (strpos($Request['FormatList'], $Val) !== false) {
|
||||
$FormatArray[] = $Key;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$MediaArray = array();
|
||||
if ($MediaList == 'Any') {
|
||||
if ($Request['MediaList'] == 'Any') {
|
||||
$MediaArray = array_keys($Media);
|
||||
} else {
|
||||
$MediaTemp = explode('|', $MediaList);
|
||||
$MediaTemp = explode('|', $Request['MediaList']);
|
||||
foreach ($Media as $Key => $Val) {
|
||||
if (in_array($Val, $MediaTemp)) {
|
||||
$MediaArray[] = $Key;
|
||||
@ -203,32 +208,32 @@
|
||||
<tr>
|
||||
<td class="label">Title</td>
|
||||
<td>
|
||||
<input type="text" name="title" size="45" value="<?=(!empty($Title) ? display_str($Title) : '')?>" />
|
||||
<input type="text" name="title" size="45" value="<?=(!empty($Title) ? $Title : '')?>" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="cataloguenumber_tr">
|
||||
<tr id="recordlabel_tr">
|
||||
<td class="label">Record label</td>
|
||||
<td>
|
||||
<input type="text" name="recordlabel" size="45" value="<?=(!empty($RecordLabel) ? display_str($RecordLabel) : '')?>" />
|
||||
<input type="text" name="recordlabel" size="45" value="<?=(!empty($Request['RecordLabel']) ? $Request['RecordLabel'] : '')?>" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="cataloguenumber_tr">
|
||||
<td class="label">Catalogue number</td>
|
||||
<td>
|
||||
<input type="text" name="cataloguenumber" size="15" value="<?=(!empty($CatalogueNumber) ? display_str($CatalogueNumber) : '')?>" />
|
||||
<input type="text" name="cataloguenumber" size="15" value="<?=(!empty($Request['CatalogueNumber']) ? $Request['CatalogueNumber'] : '')?>" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="oclc_tr">
|
||||
<td class="label">WorldCat (OCLC) ID</td>
|
||||
<td>
|
||||
<input type="text" name="oclc" size="15" value="<?=(!empty($OCLC) ? display_str($OCLC) : '')?>" />
|
||||
<input type="text" name="oclc" size="15" value="<?=(!empty($Request['OCLC']) ? $Request['OCLC'] : '')?>" />
|
||||
</td>
|
||||
</tr>
|
||||
<? } ?>
|
||||
<tr id="year_tr">
|
||||
<td class="label">Year</td>
|
||||
<td>
|
||||
<input type="text" name="year" size="5" value="<?=(!empty($Year) ? display_str($Year) : '')?>" />
|
||||
<input type="text" name="year" size="5" value="<?=(!empty($Year) ? $Year : '')?>" />
|
||||
</td>
|
||||
</tr>
|
||||
<? if ($NewRequest || $CanEdit) { ?>
|
||||
@ -339,7 +344,7 @@
|
||||
<tr>
|
||||
<td class="label">Description</td>
|
||||
<td>
|
||||
<textarea name="description" cols="70" rows="7"><?=(!empty($Description) ? $Description : '')?></textarea> <br />
|
||||
<textarea name="description" cols="70" rows="7"><?=(!empty($Request['Description']) ? $Request['Description'] : '')?></textarea> <br />
|
||||
</td>
|
||||
</tr>
|
||||
<? if (check_perms('site_moderate_requests')) { ?>
|
||||
|
@ -16,24 +16,19 @@
|
||||
|
||||
//First things first, lets get the data for the request.
|
||||
|
||||
$Request = Requests::get_requests(array($RequestID));
|
||||
$Request = $Request['matches'][$RequestID];
|
||||
if (empty($Request)) {
|
||||
$Request = Requests::get_request($RequestID);
|
||||
if ($Request === false) {
|
||||
error(404);
|
||||
}
|
||||
|
||||
// If you change this line, make sure to do the same change to the corresponding line in sections/ajax/request.php
|
||||
list($RequestID, $RequestorID, $RequestorName, $TimeAdded, $LastVote, $CategoryID, $Title, $Year, $Image, $Description, $CatalogueNumber, $RecordLabel, $ReleaseType,
|
||||
$BitrateList, $FormatList, $MediaList, $LogCue, $FillerID, $FillerName, $TorrentID, $TimeFilled, $GroupID, $OCLC) = $Request;
|
||||
|
||||
//Convenience variables
|
||||
$IsFilled = !empty($TorrentID);
|
||||
$CanVote = (empty($TorrentID) && check_perms('site_vote'));
|
||||
$IsFilled = !empty($Request['TorrentID']);
|
||||
$CanVote = !$IsFilled && check_perms('site_vote');
|
||||
|
||||
if ($CategoryID === '0') {
|
||||
if ($Request['CategoryID'] === '0') {
|
||||
$CategoryName = 'Unknown';
|
||||
} else {
|
||||
$CategoryName = $Categories[$CategoryID - 1];
|
||||
$CategoryName = $Categories[$Request['CategoryID'] - 1];
|
||||
}
|
||||
|
||||
//Do we need to get artists?
|
||||
@ -43,41 +38,40 @@
|
||||
$ArtistLink = Artists::display_artists($ArtistForm, true, true);
|
||||
|
||||
if ($IsFilled) {
|
||||
$DisplayLink = "$ArtistLink<a href=\"torrents.php?torrentid=$TorrentID\">$Title</a> [$Year]";
|
||||
$DisplayLink = "$ArtistLink<a href=\"torrents.php?torrentid=$Request[TorrentID]\">$Request[Title]</a> [$Request[Year]]";
|
||||
} else {
|
||||
$DisplayLink = $ArtistLink.$Title." [$Year]";
|
||||
$DisplayLink = $ArtistLink.$Request['Title']." [$Request[Year]]";
|
||||
}
|
||||
$FullName = $ArtistName.$Title." [$Year]";
|
||||
$FullName = $ArtistName.$Request['Title']." [$Request[Year]]";
|
||||
|
||||
if ($BitrateList != '') {
|
||||
$BitrateString = implode(', ', explode('|', $BitrateList));
|
||||
$FormatString = implode(', ', explode('|', $FormatList));
|
||||
$MediaString = implode(', ', explode('|', $MediaList));
|
||||
if ($Request['BitrateList'] != '') {
|
||||
$BitrateString = implode(', ', explode('|', $Request['BitrateList']));
|
||||
$FormatString = implode(', ', explode('|', $Request['FormatList']));
|
||||
$MediaString = implode(', ', explode('|', $Request['MediaList']));
|
||||
} else {
|
||||
$BitrateString = 'Unknown, please read the description.';
|
||||
$FormatString = 'Unknown, please read the description.';
|
||||
$MediaString = 'Unknown, please read the description.';
|
||||
}
|
||||
|
||||
if (empty($ReleaseType)) {
|
||||
if (empty($Request['ReleaseType'])) {
|
||||
$ReleaseName = 'Unknown';
|
||||
} else {
|
||||
$ReleaseName = $ReleaseTypes[$ReleaseType];
|
||||
$ReleaseName = $ReleaseTypes[$Request['ReleaseType']];
|
||||
}
|
||||
|
||||
} elseif ($CategoryName === 'Audiobooks' || $CategoryName === 'Comedy') {
|
||||
$FullName = "$Title [$Year]";
|
||||
$DisplayLink = "$Title [$Year]";
|
||||
$FullName = "$Request[Title] [$Request[Year]]";
|
||||
$DisplayLink = "$Request[Title] [$Request[Year]]";
|
||||
} else {
|
||||
$FullName = $Title;
|
||||
$DisplayLink = $Title;
|
||||
$FullName = $DisplayLink = $Request['Title'];
|
||||
}
|
||||
|
||||
//Votes time
|
||||
$RequestVotes = Requests::get_votes_array($RequestID);
|
||||
$VoteCount = count($RequestVotes['Voters']);
|
||||
$ProjectCanEdit = (check_perms('project_team') && !$IsFilled && (($CategoryID === '0') || ($CategoryName === 'Music' && $Year === '0')));
|
||||
$UserCanEdit = (!$IsFilled && $LoggedUser['ID'] === $RequestorID && $VoteCount < 2);
|
||||
$ProjectCanEdit = (check_perms('project_team') && !$IsFilled && ($Request['CategoryID'] === '0' || ($CategoryName === 'Music' && $Request['Year'] === '0')));
|
||||
$UserCanEdit = (!$IsFilled && $LoggedUser['ID'] === $Request['UserID'] && $VoteCount < 2);
|
||||
$CanEdit = ($UserCanEdit || $ProjectCanEdit || check_perms('site_moderate_requests'));
|
||||
|
||||
View::show_header("View request: $FullName", 'comments,requests,bbcode,subscriptions');
|
||||
@ -101,15 +95,15 @@
|
||||
<a href="#" id="subscribelink_requests<?=$RequestID?>" class="brackets" onclick="SubscribeComments('requests',<?=$RequestID?>);return false;"><?=Subscriptions::has_subscribed_comments('requests', $RequestID) !== false ? 'Unsubscribe' : 'Subscribe'?></a>
|
||||
<a href="reports.php?action=report&type=request&id=<?=$RequestID?>" class="brackets">Report request</a>
|
||||
<? if (!$IsFilled) { ?>
|
||||
<a href="upload.php?requestid=<?=$RequestID?><?=($GroupID ? "&groupid=$GroupID" : '')?>" class="brackets">Upload request</a>
|
||||
<a href="upload.php?requestid=<?=$RequestID?><?=($Request['GroupID'] ? "&groupid=$Request[GroupID]" : '')?>" class="brackets">Upload request</a>
|
||||
<? }
|
||||
if (!$IsFilled && (($CategoryID === '0') || ($CategoryName === 'Music' && $Year === '0'))) { ?>
|
||||
if (!$IsFilled && ($Request['CategoryID'] === '0' || ($CategoryName === 'Music' && $Request['Year'] === '0'))) { ?>
|
||||
<a href="reports.php?action=report&type=request_update&id=<?=$RequestID?>" class="brackets">Request update</a>
|
||||
<? } ?>
|
||||
|
||||
<?
|
||||
// Create a search URL to WorldCat and Google based on title
|
||||
$encoded_title = urlencode(preg_replace("/\([^\)]+\)/", '', $Title));
|
||||
$encoded_title = urlencode(preg_replace("/\([^\)]+\)/", '', $Request['Title']));
|
||||
$encoded_artist = substr(str_replace('&', 'and', $ArtistName), 0, -3);
|
||||
$encoded_artist = str_ireplace('Performed By', '', $encoded_artist);
|
||||
$encoded_artist = preg_replace("/\([^\)]+\)/", '', $encoded_artist);
|
||||
@ -123,15 +117,15 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="sidebar">
|
||||
<? if ($CategoryID !== '0') { ?>
|
||||
<? if ($Request['CategoryID'] !== '0') { ?>
|
||||
<div class="box box_image box_image_albumart box_albumart"><!-- .box_albumart deprecated -->
|
||||
<div class="head"><strong>Cover</strong></div>
|
||||
<?
|
||||
if (!empty($Image)) {
|
||||
if (!empty($Request['Image'])) {
|
||||
?>
|
||||
<p align="center"><img style="max-width: 220px;" src="<?=ImageTools::process($Image, true)?>" alt="<?=$FullName?>" onclick="lightbox.init('<?=ImageTools::process($Image)?>', 220);" /></p>
|
||||
<p align="center"><img style="max-width: 220px;" src="<?=ImageTools::process($Request['Image'], true)?>" alt="<?=$FullName?>" onclick="lightbox.init('<?=ImageTools::process($Request['Image'])?>', 220);" /></p>
|
||||
<? } else { ?>
|
||||
<p align="center"><img src="<?=STATIC_SERVER?>common/noartwork/<?=$CategoryIcons[$CategoryID - 1]?>" alt="<?=$CategoryName?>" title="<?=$CategoryName?>" width="220" height="220" border="0" /></p>
|
||||
<p align="center"><img src="<?=STATIC_SERVER?>common/noartwork/<?=$CategoryIcons[$Request['CategoryID'] - 1]?>" alt="<?=$CategoryName?>" title="<?=$CategoryName?>" width="220" height="220" border="0" /></p>
|
||||
<? } ?>
|
||||
</div>
|
||||
<?
|
||||
@ -273,23 +267,23 @@
|
||||
<tr>
|
||||
<td class="label">Created</td>
|
||||
<td>
|
||||
<?=time_diff($TimeAdded)?> by <strong><?=Users::format_username($RequestorID, false, false, false)?></strong>
|
||||
<?=time_diff($Request['TimeAdded'])?> by <strong><?=Users::format_username($Request['UserID'], false, false, false)?></strong>
|
||||
</td>
|
||||
</tr>
|
||||
<? if ($CategoryName === 'Music') {
|
||||
if (!empty($RecordLabel)) { ?>
|
||||
if (!empty($Request['RecordLabel'])) { ?>
|
||||
<tr>
|
||||
<td class="label">Record label</td>
|
||||
<td>
|
||||
<?=$RecordLabel?>
|
||||
<?=$Request['RecordLabel']?>
|
||||
</td>
|
||||
</tr>
|
||||
<? }
|
||||
if (!empty($CatalogueNumber)) { ?>
|
||||
if (!empty($Request['CatalogueNumber'])) { ?>
|
||||
<tr>
|
||||
<td class="label">Catalogue number</td>
|
||||
<td>
|
||||
<?=$CatalogueNumber?>
|
||||
<?=$Request['CatalogueNumber']?>
|
||||
</td>
|
||||
</tr>
|
||||
<? } ?>
|
||||
@ -317,17 +311,17 @@
|
||||
<?=$MediaString?>
|
||||
</td>
|
||||
</tr>
|
||||
<? if (!empty($LogCue)) { ?>
|
||||
<? if (!empty($Request['LogCue'])) { ?>
|
||||
<tr>
|
||||
<td class="label">Required CD FLAC only extras</td>
|
||||
<td>
|
||||
<?=$LogCue?>
|
||||
<?=$Request['LogCue']?>
|
||||
</td>
|
||||
</tr>
|
||||
<? }
|
||||
}
|
||||
$Worldcat = '';
|
||||
$OCLC = str_replace(' ', '', $OCLC);
|
||||
$OCLC = str_replace(' ', '', $Request['OCLC']);
|
||||
if ($OCLC !== '') {
|
||||
$OCLCs = explode(',', $OCLC);
|
||||
for ($i = 0; $i < count($OCLCs); $i++) {
|
||||
@ -346,14 +340,11 @@
|
||||
</td>
|
||||
</tr>
|
||||
<? }
|
||||
if ($GroupID) {
|
||||
/*$Groups = Torrents::get_groups(array($GroupID), true, true, false);
|
||||
$Group = $Groups['matches'][$GroupID];
|
||||
$GroupLink = Artists::display_artists($Group['ExtendedArtists']).'<a href="torrents.php?id='.$GroupID.'">'.$Group['Name'].'</a>';*/
|
||||
if ($Request['GroupID']) {
|
||||
?>
|
||||
<tr>
|
||||
<td class="label">Torrent group</td>
|
||||
<td><a href="torrents.php?id=<?=$GroupID?>">torrents.php?id=<?=$GroupID?></a></td>
|
||||
<td><a href="torrents.php?id=<?=$Request['GroupID']?>">torrents.php?id=<?=$Request['GroupID']?></a></td>
|
||||
</tr>
|
||||
<? } ?>
|
||||
<tr>
|
||||
@ -366,11 +357,11 @@
|
||||
<? } ?>
|
||||
</td>
|
||||
</tr>
|
||||
<? if ($LastVote > $TimeAdded) { ?>
|
||||
<? if ($Request['LastVote'] > $Request['TimeAdded']) { ?>
|
||||
<tr>
|
||||
<td class="label">Last voted</td>
|
||||
<td>
|
||||
<?=time_diff($LastVote)?>
|
||||
<?=time_diff($Request['LastVote'])?>
|
||||
</td>
|
||||
</tr>
|
||||
<? }
|
||||
@ -421,9 +412,9 @@
|
||||
<tr>
|
||||
<td class="label">Filled</td>
|
||||
<td>
|
||||
<strong><a href="torrents.php?<?=(strtotime($TimeFilled) < $TimeCompare ? 'id=' : 'torrentid=').$TorrentID?>">Yes</a></strong>,
|
||||
by user <?=Users::format_username($FillerID, false, false, false)?>
|
||||
<? if ($LoggedUser['ID'] === $RequestorID || $LoggedUser['ID'] === $FillerID || check_perms('site_moderate_requests')) { ?>
|
||||
<strong><a href="torrents.php?<?=(strtotime($Request['TimeFilled']) < $TimeCompare ? 'id=' : 'torrentid=') . $Request['TorrentID']?>">Yes</a></strong>,
|
||||
by user <?=Users::format_username($Request['FillerID'], false, false, false)?>
|
||||
<? if ($LoggedUser['ID'] == $Request['UserID'] || $LoggedUser['ID'] == $Request['FillerID'] || check_perms('site_moderate_requests')) { ?>
|
||||
<strong><a href="requests.php?action=unfill&id=<?=$RequestID?>" class="brackets">Unfill</a></strong> Unfilling a request without a valid, nontrivial reason will result in a warning.
|
||||
<? } ?>
|
||||
</td>
|
||||
@ -457,7 +448,7 @@
|
||||
<td colspan="2" class="center"><strong>Description</strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><?=$Text->full_format($Description);?></td>
|
||||
<td colspan="2"><?=$Text->full_format($Request['Description']);?></td>
|
||||
</tr>
|
||||
</table>
|
||||
<?
|
||||
|
@ -1,72 +1,99 @@
|
||||
<?php
|
||||
$SphQL = new SphinxqlQuery();
|
||||
$SphQL->select('id, votes, bounty')->from('requests, requests_delta');
|
||||
|
||||
$Queries = array();
|
||||
$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'];
|
||||
|
||||
if (!empty($_GET['sort']) && $_GET['sort'] == 'asc') {
|
||||
$OrderWay = 'asc';
|
||||
} else {
|
||||
$_GET['sort'] = 'desc';
|
||||
$OrderWay = 'desc';
|
||||
}
|
||||
$NewSort = $_GET['sort'] === 'asc' ? 'desc' : 'asc';
|
||||
|
||||
if ($OrderBy === 'random') {
|
||||
$SphQL->order_by('RAND()', '');
|
||||
unset($_GET['page']);
|
||||
} else {
|
||||
$SphQL->order_by($SortOrders[$OrderBy], $OrderWay);
|
||||
}
|
||||
|
||||
$OrderWays = array('year', 'votes', 'bounty', 'created', 'lastvote', 'filled');
|
||||
list($Page, $Limit) = Format::page_limit(REQUESTS_PER_PAGE);
|
||||
$Submitted = !empty($_GET['submit']);
|
||||
|
||||
//Paranoia
|
||||
$UserInfo = Users::user_info((int)$_GET['userid']);
|
||||
$Perms = Permissions::get_permissions($UserInfo['PermissionID']);
|
||||
$UserClass = $Perms['Class'];
|
||||
|
||||
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;
|
||||
|
||||
if (empty($_GET['type'])) {
|
||||
$Title = 'Requests';
|
||||
if (!check_perms('site_see_old_requests') || empty($_GET['showall'])) {
|
||||
$SS->set_filter('visible', array(1));
|
||||
$SphQL->where('visible', 1);
|
||||
}
|
||||
} else {
|
||||
switch ($_GET['type']) {
|
||||
case 'created':
|
||||
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);
|
||||
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';
|
||||
$SS->set_filter('userid', array($LoggedUser['ID']));
|
||||
$SphQL->where('userid', $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);
|
||||
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've voted on";
|
||||
$SS->set_filter('voter', array($LoggedUser['ID']));
|
||||
$Title = 'Requests I have voted on';
|
||||
$SphQL->where('voter', $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'])) {
|
||||
if (!empty($UserInfo)) {
|
||||
if (!check_paranoia('requestsfilled_list', $UserInfo['Paranoia'], $Perms['Class'], $UserInfo['ID'])) {
|
||||
error(403);
|
||||
}
|
||||
$Title = "Requests filled by ".$UserInfo['Username'];
|
||||
$SS->set_filter('fillerid', array($_GET['userid']));
|
||||
$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;
|
||||
$SS->set_filter('bookmarker', array($LoggedUser['ID']));
|
||||
$SphQL->where('bookmarker', $LoggedUser['ID']);
|
||||
break;
|
||||
default:
|
||||
error(404);
|
||||
@ -74,7 +101,7 @@
|
||||
}
|
||||
|
||||
if ($Submitted && empty($_GET['show_filled'])) {
|
||||
$SS->set_filter('torrentid', array(0));
|
||||
$SphQL->where('torrentid', 0);
|
||||
}
|
||||
|
||||
$EnableNegation = false; // Sphinx needs at least one positive search condition to support the NOT operator
|
||||
@ -85,16 +112,17 @@
|
||||
$FormatNameArray = array();
|
||||
foreach ($FormatArray as $Index => $MasterIndex) {
|
||||
if (isset($Formats[$MasterIndex])) {
|
||||
$FormatNameArray[$Index] = '"'.strtr($Formats[$MasterIndex], '-.', ' ').'"';
|
||||
$FormatNameArray[$Index] = '"' . strtr(Sphinxql::sph_escape_string($Formats[$MasterIndex]), '-.', ' ') . '"';
|
||||
}
|
||||
}
|
||||
if (count($FormatNameArray) >= 1) {
|
||||
$EnableNegation = true;
|
||||
if (!empty($_GET['formats_strict'])) {
|
||||
$Queries[] = '@formatlist ('.implode(' | ', $FormatNameArray).')';
|
||||
$SearchString = '(' . implode(' | ', $FormatNameArray) . ')';
|
||||
} else {
|
||||
$Queries[] = '@formatlist (any | '.implode(' | ', $FormatNameArray).')';
|
||||
$SearchString = '(any | ' . implode(' | ', $FormatNameArray) . ')';
|
||||
}
|
||||
$SphQL->where_match($SearchString, 'formatlist', false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -105,17 +133,18 @@
|
||||
$MediaNameArray = array();
|
||||
foreach ($MediaArray as $Index => $MasterIndex) {
|
||||
if (isset($Media[$MasterIndex])) {
|
||||
$MediaNameArray[$Index] = '"'.strtr($Media[$MasterIndex], '-.', ' ').'"';
|
||||
$MediaNameArray[$Index] = '"' . strtr(Sphinxql::sph_escape_string($Media[$MasterIndex]), '-.', ' ') . '"';
|
||||
}
|
||||
}
|
||||
|
||||
if (count($MediaNameArray) >= 1) {
|
||||
$EnableNegation = true;
|
||||
if (!empty($_GET['media_strict'])) {
|
||||
$Queries[] = '@medialist ('.implode(' | ', $MediaNameArray).')';
|
||||
$SearchString = '(' . implode(' | ', $MediaNameArray) . ')';
|
||||
} else {
|
||||
$Queries[] = '@medialist (any | '.implode(' | ', $MediaNameArray).')';
|
||||
$SearchString = '(any | ' . implode(' | ', $MediaNameArray) . ')';
|
||||
}
|
||||
$SphQL->where_match($SearchString, 'medialist', false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -126,17 +155,18 @@
|
||||
$BitrateNameArray = array();
|
||||
foreach ($BitrateArray as $Index => $MasterIndex) {
|
||||
if (isset($Bitrates[$MasterIndex])) {
|
||||
$BitrateNameArray[$Index] = '"'.strtr($SS->EscapeString($Bitrates[$MasterIndex]), '-.', ' ').'"';
|
||||
$BitrateNameArray[$Index] = '"' . strtr(Sphinxql::sph_escape_string($Bitrates[$MasterIndex]), '-.', ' ') . '"';
|
||||
}
|
||||
}
|
||||
|
||||
if (count($BitrateNameArray) >= 1) {
|
||||
$EnableNegation = true;
|
||||
if (!empty($_GET['bitrate_strict'])) {
|
||||
$Queries[] = '@bitratelist ('.implode(' | ', $BitrateNameArray).')';
|
||||
$SearchString = '(' . implode(' | ', $BitrateNameArray) . ')';
|
||||
} else {
|
||||
$Queries[] = '@bitratelist (any | '.implode(' | ', $BitrateNameArray).')';
|
||||
$SearchString = '(any | ' . implode(' | ', $BitrateNameArray) . ')';
|
||||
}
|
||||
$SphQL->where_match($SearchString, 'bitratelist', false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -170,29 +200,32 @@
|
||||
unset($SearchWords['exclude']);
|
||||
}
|
||||
foreach ($SearchWords['include'] as $Word) {
|
||||
$QueryParts[] = $SS->EscapeString($Word);
|
||||
$QueryParts[] = Sphinxql::sph_escape_string($Word);
|
||||
}
|
||||
if (!empty($SearchWords['exclude'])) {
|
||||
foreach ($SearchWords['exclude'] as $Word) {
|
||||
$QueryParts[] = '!'.$SS->EscapeString(substr($Word, 1));
|
||||
$QueryParts[] = '!' . Sphinxql::sph_escape_string(substr($Word, 1));
|
||||
}
|
||||
}
|
||||
if (!empty($QueryParts)) {
|
||||
$Queries[] = "@* ".implode(' ', $QueryParts);
|
||||
$SearchString = implode(' ', $QueryParts);
|
||||
$SphQL->where_match($SearchString, '*', false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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'])) {
|
||||
$Tags = explode(',', $_GET['tags']);
|
||||
$TagNames = array();
|
||||
if (!isset($_GET['tags_type']) || $_GET['tags_type'] === '1') {
|
||||
$TagType = 1;
|
||||
$_GET['tags_type'] = '1';
|
||||
} else {
|
||||
$TagType = 0;
|
||||
$_GET['tags_type'] = '0';
|
||||
}
|
||||
$TagNames = $TagsExclude = array();
|
||||
// Remove illegal characters from the given tag names
|
||||
foreach ($Tags as $Tag) {
|
||||
$Tag = ltrim($Tag);
|
||||
$Exclude = ($Tag[0] === '!');
|
||||
@ -202,7 +235,7 @@
|
||||
$TagsExclude[$Tag] = $Exclude;
|
||||
}
|
||||
}
|
||||
$AllNegative = !in_array(false, $TagsExclude);
|
||||
$AllNegative = !in_array(false, $TagsExclude, true);
|
||||
$Tags = Misc::get_tags($TagNames);
|
||||
|
||||
// Replace the ! characters that sanitize_tag removed
|
||||
@ -223,15 +256,14 @@
|
||||
// 'All' tags
|
||||
if ($TagType === 1 && !empty($Tags)) {
|
||||
foreach ($Tags as $TagID => $TagName) {
|
||||
$SS->set_filter('tagid', array($TagID), $TagsExclude[$TagName]);
|
||||
$SphQL->where('tagid', $TagID, $TagsExclude[$TagName]);
|
||||
}
|
||||
} elseif (!empty($Tags)) {
|
||||
$SS->set_filter('tagid', array_keys($Tags), $AllNegative);
|
||||
$SphQL->where('tagid', array_keys($Tags), $AllNegative);
|
||||
}
|
||||
|
||||
if (!empty($_GET['filter_cat'])) {
|
||||
$CategoryArray = array_keys($_GET['filter_cat']);
|
||||
$Debug->log_var(array($CategoryArray, $Categories));
|
||||
if (count($CategoryArray) !== count($Categories)) {
|
||||
foreach ($CategoryArray as $Key => $Index) {
|
||||
if (!isset($Categories[$Index - 1])) {
|
||||
@ -239,7 +271,7 @@
|
||||
}
|
||||
}
|
||||
if (count($CategoryArray) >= 1) {
|
||||
$SS->set_filter('categoryid', $CategoryArray);
|
||||
$SphQL->where('categoryid', $CategoryArray);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -253,14 +285,14 @@
|
||||
}
|
||||
}
|
||||
if (count($ReleaseArray) >= 1) {
|
||||
$SS->set_filter('releasetype', $ReleaseArray);
|
||||
$SphQL->where('releasetype', $ReleaseArray);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($_GET['requestor']) && check_perms('site_see_old_requests')) {
|
||||
if (is_number($_GET['requestor'])) {
|
||||
$SS->set_filter('userid', array($_GET['requestor']));
|
||||
$SphQL->where('userid', $_GET['requestor']);
|
||||
} else {
|
||||
error(404);
|
||||
}
|
||||
@ -268,7 +300,7 @@
|
||||
|
||||
if (isset($_GET['year'])) {
|
||||
if (is_number($_GET['year']) || $_GET['year'] === '0') {
|
||||
$SS->set_filter('year', array($_GET['year']));
|
||||
$SphQL->where('year', $_GET['year']);
|
||||
} else {
|
||||
error(404);
|
||||
}
|
||||
@ -276,74 +308,29 @@
|
||||
|
||||
if (!empty($_GET['page']) && is_number($_GET['page']) && $_GET['page'] > 0) {
|
||||
$Page = $_GET['page'];
|
||||
$SS->limit(($Page - 1) * REQUESTS_PER_PAGE, REQUESTS_PER_PAGE);
|
||||
$Offset = ($Page - 1) * REQUESTS_PER_PAGE;
|
||||
$SphQL->limit($Offset, REQUESTS_PER_PAGE, $Offset + REQUESTS_PER_PAGE);
|
||||
} else {
|
||||
$Page = 1;
|
||||
$SS->limit(0, REQUESTS_PER_PAGE);
|
||||
$SphQL->limit(0, REQUESTS_PER_PAGE, REQUESTS_PER_PAGE);
|
||||
}
|
||||
|
||||
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);
|
||||
$SphQLResult = $SphQL->query();
|
||||
$NumResults = $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;
|
||||
}
|
||||
} else {
|
||||
error(404);
|
||||
$PageLinks = Format::get_pages($Page, $NumResults, REQUESTS_PER_PAGE);
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
if ($NumResults && $NumResults < ($Page - 1) * REQUESTS_PER_PAGE + 1) {
|
||||
$PageLinks = Format::get_pages(0, $NumResults, REQUESTS_PER_PAGE);
|
||||
} else {
|
||||
$PageLinks = Format::get_pages($Page, $NumResults, REQUESTS_PER_PAGE);
|
||||
}
|
||||
|
||||
$CurrentURL = Format::get_url(array('order', 'sort'));
|
||||
$CurrentURL = Format::get_url(array('order', 'sort', 'page'));
|
||||
View::show_header($Title, 'requests');
|
||||
|
||||
?>
|
||||
@ -372,7 +359,7 @@
|
||||
<? if ($BookmarkView) { ?>
|
||||
<input type="hidden" name="action" value="view" />
|
||||
<input type="hidden" name="type" value="requests" />
|
||||
<? } else { ?>
|
||||
<? } elseif (isset($_GET['type'])) { ?>
|
||||
<input type="hidden" name="type" value="<?=$_GET['type']?>" />
|
||||
<? } ?>
|
||||
<input type="hidden" name="submit" value="true" />
|
||||
@ -444,16 +431,20 @@
|
||||
<td class="label">Release types</td>
|
||||
<td>
|
||||
<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>
|
||||
<? $i = 0;
|
||||
foreach ($ReleaseTypes as $Key => $Val) {
|
||||
if ($i % 8 === 0) {
|
||||
echo '<br />';
|
||||
} ?>
|
||||
<?
|
||||
$i = 0;
|
||||
foreach ($ReleaseTypes as $Key => $Val) {
|
||||
if ($i % 8 === 0) {
|
||||
echo '<br />';
|
||||
}
|
||||
?>
|
||||
<input type="checkbox" name="releases[]" value="<?=$Key?>" id="release_<?=$Key?>"
|
||||
<?=(((!$Submitted) || !empty($ReleaseArray) && in_array($Key, $ReleaseArray)) ? ' checked="checked" ' : '')?>
|
||||
<?=(!$Submitted || (!empty($ReleaseArray) && in_array($Key, $ReleaseArray)) ? ' checked="checked" ' : '')?>
|
||||
/> <label for="release_<?=$Key?>"><?=$Val?></label>
|
||||
<? $i++;
|
||||
} ?>
|
||||
<?
|
||||
$i++;
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="format_list">
|
||||
@ -463,14 +454,18 @@
|
||||
<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>
|
||||
<? foreach ($Formats as $Key => $Val) {
|
||||
if ($Key % 8 === 0) {
|
||||
echo '<br />';
|
||||
} ?>
|
||||
<?
|
||||
foreach ($Formats as $Key => $Val) {
|
||||
if ($Key % 8 === 0) {
|
||||
echo '<br />';
|
||||
}
|
||||
?>
|
||||
<input type="checkbox" name="formats[]" value="<?=$Key?>" id="format_<?=$Key?>"
|
||||
<?=(((!$Submitted) || !empty($FormatArray) && in_array($Key, $FormatArray)) ? ' checked="checked" ' : '')?>
|
||||
<?=(!$Submitted || (!empty($FormatArray) && in_array($Key, $FormatArray)) ? ' checked="checked" ' : '')?>
|
||||
/> <label for="format_<?=$Key?>"><?=$Val?></label>
|
||||
<? } ?>
|
||||
<?
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="bitrate_list">
|
||||
@ -480,14 +475,18 @@
|
||||
<label for="toggle_bitrates">All</label>
|
||||
<input type="checkbox" id="bitrate_strict" name="bitrate_strict"<?=(!empty($_GET['bitrate_strict']) ? ' checked="checked"' : '') ?> />
|
||||
<label for="bitrate_strict">Only specified</label>
|
||||
<? foreach ($Bitrates as $Key => $Val) {
|
||||
if ($Key % 8 === 0) {
|
||||
echo '<br />';
|
||||
} ?>
|
||||
<?
|
||||
foreach ($Bitrates as $Key => $Val) {
|
||||
if ($Key % 8 === 0) {
|
||||
echo '<br />';
|
||||
}
|
||||
?>
|
||||
<input type="checkbox" name="bitrates[]" value="<?=$Key?>" id="bitrate_<?=$Key?>"
|
||||
<?=(((!$Submitted) || !empty($BitrateArray) && in_array($Key, $BitrateArray)) ? ' checked="checked" ' : '')?>
|
||||
<?=(!$Submitted || (!empty($BitrateArray) && in_array($Key, $BitrateArray)) ? ' checked="checked" ' : '')?>
|
||||
/> <label for="bitrate_<?=$Key?>"><?=$Val?></label>
|
||||
<? } ?>
|
||||
<?
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="media_list">
|
||||
@ -497,14 +496,18 @@
|
||||
<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>
|
||||
<? foreach ($Media as $Key => $Val) {
|
||||
if ($Key % 8 === 0) {
|
||||
echo '<br />';
|
||||
} ?>
|
||||
<?
|
||||
foreach ($Media as $Key => $Val) {
|
||||
if ($Key % 8 === 0) {
|
||||
echo '<br />';
|
||||
}
|
||||
?>
|
||||
<input type="checkbox" name="media[]" value="<?=$Key?>" id="media_<?=$Key?>"
|
||||
<?=(((!$Submitted) || !empty($MediaArray) && in_array($Key, $MediaArray)) ? ' checked="checked" ' : '')?>
|
||||
<?=(!$Submitted || (!empty($MediaArray) && in_array($Key, $MediaArray)) ? ' checked="checked" ' : '')?>
|
||||
/> <label for="media_<?=$Key?>"><?=$Val?></label>
|
||||
<? } ?>
|
||||
<?
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@ -515,24 +518,24 @@
|
||||
</table>
|
||||
</form>
|
||||
|
||||
<? if ($NumResults) { ?>
|
||||
<? if (isset($PageLinks)) { ?>
|
||||
<div class="linkbox">
|
||||
<?=$PageLinks?>
|
||||
</div>
|
||||
<? } ?>
|
||||
<? } ?>
|
||||
<table id="request_table" class="request_table border" cellpadding="6" cellspacing="1" border="0" width="100%">
|
||||
<tr class="colhead_dark">
|
||||
<td style="width: 38%;" class="nobr">
|
||||
<strong>Request Name</strong> / <a href="?order=year&sort=<?=(($CurrentOrder === 'year') ? $NewSort : 'desc')?>&<?=$CurrentURL ?>"><strong>Year</strong></a>
|
||||
<strong>Request Name</strong> / <a href="?order=year&sort=<?=($OrderBy === 'year' ? $NewSort : 'desc')?>&<?=$CurrentURL?>"><strong>Year</strong></a>
|
||||
</td>
|
||||
<td class="nobr">
|
||||
<a href="?order=votes&sort=<?=(($CurrentOrder === 'votes') ? $NewSort : 'desc')?>&<?=$CurrentURL ?>"><strong>Votes</strong></a>
|
||||
<a href="?order=votes&sort=<?=($OrderBy === 'votes' ? $NewSort : 'desc')?>&<?=$CurrentURL?>"><strong>Votes</strong></a>
|
||||
</td>
|
||||
<td class="nobr">
|
||||
<a href="?order=bounty&sort=<?=(($CurrentOrder === 'bounty') ? $NewSort : 'desc')?>&<?=$CurrentURL ?>"><strong>Bounty</strong></a>
|
||||
<a href="?order=bounty&sort=<?=($OrderBy === 'bounty' ? $NewSort : 'desc')?>&<?=$CurrentURL?>"><strong>Bounty</strong></a>
|
||||
</td>
|
||||
<td class="nobr">
|
||||
<a href="?order=filled&sort=<?=(($CurrentOrder === 'filled') ? $NewSort : 'desc')?>&<?=$CurrentURL ?>"><strong>Filled</strong></a>
|
||||
<a href="?order=filled&sort=<?=($OrderBy === 'filled' ? $NewSort : 'desc')?>&<?=$CurrentURL?>"><strong>Filled</strong></a>
|
||||
</td>
|
||||
<td class="nobr">
|
||||
<strong>Filled by</strong>
|
||||
@ -541,141 +544,112 @@
|
||||
<strong>Requested by</strong>
|
||||
</td>
|
||||
<td class="nobr">
|
||||
<a href="?order=created&sort=<?=(($CurrentOrder === 'created') ? $NewSort : 'desc')?>&<?=$CurrentURL ?>"><strong>Created</strong></a>
|
||||
<a href="?order=created&sort=<?=($OrderBy === 'created' ? $NewSort : 'desc')?>&<?=$CurrentURL?>"><strong>Created</strong></a>
|
||||
</td>
|
||||
<td class="nobr">
|
||||
<a href="?order=lastvote&sort=<?=(($CurrentOrder === 'lastvote') ? $NewSort : 'desc')?>&<?=$CurrentURL ?>"><strong>Last vote</strong></a>
|
||||
<a href="?order=lastvote&sort=<?=($OrderBy === 'lastvote' ? $NewSort : 'desc')?>&<?=$CurrentURL?>"><strong>Last vote</strong></a>
|
||||
</td>
|
||||
</tr>
|
||||
<? if ($NumResults == 0) { ?>
|
||||
<? if ($NumResults === 0) { ?>
|
||||
<tr class="rowb">
|
||||
<td colspan="8">
|
||||
Nothing found!
|
||||
</td>
|
||||
</tr>
|
||||
<? } elseif ($NumResults < ($Page - 1) * REQUESTS_PER_PAGE + 1) { ?>
|
||||
<? } elseif ($Page === 0) { ?>
|
||||
<tr class="rowb">
|
||||
<td colspan="8">
|
||||
The requested page contains no matches!
|
||||
</td>
|
||||
</tr>
|
||||
<? } else {
|
||||
<? } else {
|
||||
$TimeCompare = 1267643718; // Requests v2 was implemented 2010-03-03 20:15:18
|
||||
$Requests = Requests::get_requests(array_keys($SphRequests));
|
||||
foreach ($SphRequests as $RequestID => $SphRequest) {
|
||||
$Request = $Requests[$RequestID];
|
||||
$Bounty = $SphRequest['bounty'] * 1024; // Sphinx stores bounty in kB
|
||||
$VoteCount = $SphRequest['votes'];
|
||||
|
||||
//We don't use sphinxapi's default cache searcher, we use our own functions
|
||||
if (!empty($SphinxResults['notfound'])) {
|
||||
$SQLResults = Requests::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]);
|
||||
}
|
||||
if ($Request['CategoryID'] == 0) {
|
||||
$CategoryName = 'Unknown';
|
||||
} else {
|
||||
$CategoryName = $Categories[$Request['CategoryID'] - 1];
|
||||
}
|
||||
|
||||
// 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]);
|
||||
if ($Request['TorrentID'] != 0) {
|
||||
$IsFilled = true;
|
||||
$FillerInfo = Users::user_info($Request['FillerID']);
|
||||
} else {
|
||||
$IsFilled = false;
|
||||
}
|
||||
}
|
||||
|
||||
$Requests = $SphinxResults['matches'];
|
||||
|
||||
$Row = 'a';
|
||||
$TimeCompare = 1267643718; // Requests v2 was implemented 2010-03-03 20:15:18
|
||||
foreach ($Requests as $RequestID => $Request) {
|
||||
|
||||
//list($BitrateList, $CatalogueNumber, $CategoryID, $Description, $FillerID, $FormatList, $RequestID, $Image, $LogCue, $MediaList, $ReleaseType,
|
||||
// $Tags, $TimeAdded, $TimeFilled, $Title, $TorrentID, $RequestorID, $RequestorName, $Year, $RequestID, $Categoryid, $FillerID, $LastVote,
|
||||
// $ReleaseType, $TagIDs, $TimeAdded, $TimeFilled, $TorrentID, $RequestorID, $Voters) = array_values($Request);
|
||||
|
||||
list($RequestID, $RequestorID, $RequestorName, $TimeAdded, $LastVote, $CategoryID, $Title, $Year, $Image, $Description, $CatalogueNumber, $RecordLabel,
|
||||
$ReleaseType, $BitrateList, $FormatList, $MediaList, $LogCue, $FillerID, $FillerName, $TorrentID, $TimeFilled) = $Request;
|
||||
|
||||
$RequestVotes = Requests::get_votes_array($RequestID);
|
||||
|
||||
$VoteCount = count($RequestVotes['Voters']);
|
||||
|
||||
if ($CategoryID == 0) {
|
||||
$CategoryName = 'Unknown';
|
||||
} else {
|
||||
$CategoryName = $Categories[$CategoryID - 1];
|
||||
}
|
||||
|
||||
$IsFilled = ($TorrentID != 0);
|
||||
|
||||
if ($CategoryName === 'Music') {
|
||||
$ArtistForm = Requests::get_artists($RequestID);
|
||||
$ArtistLink = Artists::display_artists($ArtistForm, true, true);
|
||||
$FullName = $ArtistLink."<a href=\"requests.php?action=view&id=".$RequestID."\">$Title [$Year]</a>";
|
||||
} elseif ($CategoryName === 'Audiobooks' || $CategoryName === 'Comedy') {
|
||||
$FullName = "<a href=\"requests.php?action=view&id=".$RequestID."\">$Title [$Year]</a>";
|
||||
} else {
|
||||
$FullName ="<a href=\"requests.php?action=view&id=".$RequestID."\">$Title</a>";
|
||||
}
|
||||
|
||||
$Row = ($Row === 'a') ? 'b' : 'a';
|
||||
|
||||
$Tags = $Request['Tags'];
|
||||
if ($CategoryName === 'Music') {
|
||||
$ArtistForm = Requests::get_artists($RequestID);
|
||||
$ArtistLink = Artists::display_artists($ArtistForm, true, true);
|
||||
$FullName = "$ArtistLink<a href=\"requests.php?action=view&id=$RequestID\">$Request[Title] [$Request[Year]]</a>";
|
||||
} elseif ($CategoryName === 'Audiobooks' || $CategoryName === 'Comedy') {
|
||||
$FullName = "<a href=\"requests.php?action=view&id=$RequestID\">$Request[Title] [$Request[Year]]</a>";
|
||||
} else {
|
||||
$FullName ="<a href=\"requests.php?action=view&id=$RequestID\">$Request[Title]</a>";
|
||||
}
|
||||
$Tags = $Request['Tags'];
|
||||
?>
|
||||
<tr class="row<?=$Row?>">
|
||||
<tr class="row<?=($i % 2 ? 'b' : 'a')?>">
|
||||
<td>
|
||||
<?=$FullName?>
|
||||
<div class="tags">
|
||||
<?
|
||||
$TagList = array();
|
||||
foreach ($Tags as $TagID => $TagName) {
|
||||
$TagList[] = '<a href="?tags='.$TagName.($BookmarkView ? '&type=requests' : '').'\">'.display_str($TagName).'</a>';
|
||||
}
|
||||
$TagList = implode(', ', $TagList);
|
||||
$TagList = array();
|
||||
foreach ($Request['Tags'] as $TagID => $TagName) {
|
||||
$TagList[] = '<a href="?tags=$TagName' . ($BookmarkView ? '&type=requests' : '') . '">' . display_str($TagName) . '</a>';
|
||||
}
|
||||
$TagList = implode(', ', $TagList);
|
||||
?>
|
||||
<?=$TagList?>
|
||||
</div>
|
||||
</td>
|
||||
<td class="nobr">
|
||||
<span id="vote_count_<?=$RequestID?>"><?=number_format($VoteCount)?></span>
|
||||
<? if (!$IsFilled && check_perms('site_vote')) { ?>
|
||||
<? if (!$IsFilled && check_perms('site_vote')) { ?>
|
||||
<a href="javascript:Vote(0, <?=$RequestID?>)" class="brackets"><strong>+</strong></a>
|
||||
<? } ?>
|
||||
<? } ?>
|
||||
</td>
|
||||
<td class="number_column nobr">
|
||||
<?=Format::get_size($RequestVotes['TotalBounty'])?>
|
||||
<?=Format::get_size($Bounty)?>
|
||||
</td>
|
||||
<td>
|
||||
<? if ($IsFilled) { ?>
|
||||
<a href="torrents.php?<?=(strtotime($TimeFilled) < $TimeCompare ? 'id=' : 'torrentid=').$TorrentID?>"><strong><?=time_diff($TimeFilled)?></strong></a>
|
||||
<? } else { ?>
|
||||
<? if ($IsFilled) { ?>
|
||||
<a href="torrents.php?<?=(strtotime($Request['TimeFilled']) < $TimeCompare ? 'id=' : 'torrentid=') . $Request['TorrentID']?>"><strong><?=time_diff($Request['TimeFilled'])?></strong></a>
|
||||
<? } else { ?>
|
||||
<strong>No</strong>
|
||||
<? } ?>
|
||||
<? } ?>
|
||||
</td>
|
||||
<td>
|
||||
<? if ($IsFilled) { ?>
|
||||
<a href="user.php?id=<?=$FillerID?>"><?=$FillerName?></a>
|
||||
<? } else { ?>
|
||||
<? if ($IsFilled) { ?>
|
||||
<a href="user.php?id=<?=$FillerInfo['ID']?>"><?=$FillerInfo['Username']?></a>
|
||||
<? } else { ?>
|
||||
—
|
||||
<? } ?>
|
||||
<? } ?>
|
||||
</td>
|
||||
<td>
|
||||
<a href="user.php?id=<?=$RequestorID?>"><?=$RequestorName?></a>
|
||||
<a href="user.php?id=<?=$Request['UserID']?>"><?=Users::format_username($Request['UserID'], false, false, false)?></a>
|
||||
</td>
|
||||
<td>
|
||||
<?=time_diff($TimeAdded)?>
|
||||
<?=time_diff($Request['TimeAdded'])?>
|
||||
</td>
|
||||
<td>
|
||||
<?=time_diff($LastVote)?>
|
||||
<?=time_diff($Request['LastVote'])?>
|
||||
</td>
|
||||
</tr>
|
||||
<?
|
||||
} // while
|
||||
} // else
|
||||
} // foreach
|
||||
} // else
|
||||
?>
|
||||
</table>
|
||||
<? if (isset($PageLinks)) { ?>
|
||||
<div class="linkbox">
|
||||
<?=$PageLinks?>
|
||||
</div>
|
||||
<? } ?>
|
||||
</div>
|
||||
<? View::show_footer(); ?>
|
||||
|
@ -206,8 +206,9 @@
|
||||
$Cache->delete_value("artists_requests_$ArtistID");
|
||||
}
|
||||
|
||||
$SS->UpdateAttributes('requests', array('torrentid', 'fillerid'), array($RequestID => array((int)$TorrentID, (int)$FillerID)));
|
||||
Requests::update_sphinx_requests($RequestID);
|
||||
$SphQL = new SphinxqlQuery();
|
||||
$SphQL->raw_query("UPDATE requests, requests_delta SET torrentid = $TorrentID, fillerid = $FillerID WHERE id = $RequestID", false);
|
||||
|
||||
header("Location: requests.php?action=view&id=$RequestID");
|
||||
?>
|
||||
|
@ -25,23 +25,16 @@
|
||||
error(0);
|
||||
}
|
||||
|
||||
$Request = Requests::get_requests(array($RequestID));
|
||||
$Request = $Request['matches'][$RequestID];
|
||||
if (empty($Request)) {
|
||||
$Request = Requests::get_request($RequestID);
|
||||
if ($Request === false) {
|
||||
error(404);
|
||||
}
|
||||
|
||||
list($RequestID, $RequestorID, $RequestorName, $TimeAdded, $LastVote, $CategoryID, $Title, $Year, $Image, $Description, $CatalogueNumber, $RecordLabel,
|
||||
$ReleaseType, $BitrateList, $FormatList, $MediaList, $LogCue, $FillerID, $FillerName, $TorrentID, $TimeFilled, $GroupID, $OCLC) = $Request;
|
||||
$VoteArray = Requests::get_votes_array($RequestID);
|
||||
$VoteCount = count($VoteArray['Voters']);
|
||||
|
||||
$IsFilled = !empty($TorrentID);
|
||||
|
||||
$CategoryName = $Categories[$CategoryID - 1];
|
||||
|
||||
$ProjectCanEdit = (check_perms('project_team') && !$IsFilled && (($CategoryID === '0') || ($CategoryName === 'Music' && $Year === '0')));
|
||||
$CanEdit = ((!$IsFilled && $LoggedUser['ID'] === $RequestorID && $VoteCount < 2) || $ProjectCanEdit || check_perms('site_moderate_requests'));
|
||||
$IsFilled = !empty($Request['TorrentID']);
|
||||
$CategoryName = $Categories[$Request['CategoryID'] - 1];
|
||||
$ProjectCanEdit = (check_perms('project_team') && !$IsFilled && ($Request['CategoryID'] === '0' || ($CategoryName === 'Music' && $Year === '0')));
|
||||
$CanEdit = ((!$IsFilled && $LoggedUser['ID'] === $Request['UserID'] && $VoteCount < 2) || $ProjectCanEdit || check_perms('site_moderate_requests'));
|
||||
|
||||
if (!$CanEdit) {
|
||||
error(403);
|
||||
|
@ -89,6 +89,8 @@
|
||||
}
|
||||
}
|
||||
|
||||
$SphQL = new SphinxqlQuery();
|
||||
$SphQL->raw_query("UPDATE requests, requests_delta SET torrentid = 0, fillerid = 0 WHERE id = $RequestID", false);
|
||||
|
||||
header("Location: requests.php?action=view&id=$RequestID");
|
||||
?>
|
||||
|
@ -79,7 +79,7 @@
|
||||
while (list($UserID) = $DB->next_record()) {
|
||||
$UserIDs[] = $UserID;
|
||||
}
|
||||
NotificationsManager::notify_users($UserIDs, NotificationsManager::$REQUESTALERTS, Format::get_size($Amount) . " of bounty has been added to a request you've voted on!", "requests.php?action=view&id=" . $RequestID);
|
||||
NotificationsManager::notify_users($UserIDs, NotificationsManager::REQUESTALERTS, Format::get_size($Amount) . " of bounty has been added to a request you've voted on!", "requests.php?action=view&id=" . $RequestID);
|
||||
} elseif ($LoggedUser['BytesUploaded'] < $Amount) {
|
||||
echo 'bankrupt';
|
||||
}
|
||||
|
@ -61,12 +61,16 @@ function next_hour() {
|
||||
SELECT NextHour, NextDay, NextBiWeekly
|
||||
FROM schedule");
|
||||
list($Hour, $Day, $BiWeek) = $DB->next_record();
|
||||
$NextHour = next_hour();
|
||||
$NextDay = next_day();
|
||||
$NextBiWeek = next_biweek();
|
||||
|
||||
$DB->query("
|
||||
UPDATE schedule
|
||||
SET
|
||||
NextHour = ".next_hour().",
|
||||
NextDay = ".next_day().",
|
||||
NextBiWeekly = ".next_biweek());
|
||||
NextHour = $NextHour,
|
||||
NextDay = $NextDay,
|
||||
NextBiWeekly = $NextBiWeek");
|
||||
|
||||
$NoDaily = isset($argv[2]) && $argv[2] == 'nodaily';
|
||||
|
||||
@ -151,7 +155,7 @@ function next_hour() {
|
||||
\*************************************************************************/
|
||||
|
||||
|
||||
if ($Hour != next_hour() || $_GET['runhour'] || isset($argv[2])) {
|
||||
if ($Hour != $NextHour || $_GET['runhour'] || isset($argv[2])) {
|
||||
echo "Ran hourly functions\n";
|
||||
|
||||
//------------- Front page stats ----------------------------------------//
|
||||
@ -500,7 +504,7 @@ function next_hour() {
|
||||
|
||||
\*************************************************************************/
|
||||
|
||||
if (!$NoDaily && $Day != next_day() || $_GET['runday']) {
|
||||
if (!$NoDaily && $Day != $NextDay || $_GET['runday']) {
|
||||
echo "Ran daily functions\n";
|
||||
if ($Day % 2 == 0) { // If we should generate the drive database (at the end)
|
||||
$GenerateDriveDB = true;
|
||||
@ -1306,7 +1310,7 @@ function next_hour() {
|
||||
|
||||
\*************************************************************************/
|
||||
|
||||
if ($BiWeek != next_biweek() || $_GET['runbiweek']) {
|
||||
if ($BiWeek != $NextBiWeek || $_GET['runbiweek']) {
|
||||
echo "Ran bi-weekly functions\n";
|
||||
|
||||
//------------- Cycle auth keys -----------------------------------------//
|
||||
|
@ -15,9 +15,7 @@
|
||||
$View = in_array($View, array('tiles', 'list')) ? $View : 'tiles';
|
||||
|
||||
switch ($Category) {
|
||||
case 'all_time':
|
||||
$Artists = LastFM::get_site_top_artists($Limit);
|
||||
break;
|
||||
|
||||
case 'weekly':
|
||||
$Artists = json_decode(LastFM::get_weekly_artists($Limit), true)['artists']['artist'];
|
||||
break;
|
||||
|
@ -73,7 +73,7 @@
|
||||
|
||||
$TopVotes = array();
|
||||
foreach ($Results as $GroupID) {
|
||||
$TopVotes[$GroupID] = $Groups['matches'][$GroupID];
|
||||
$TopVotes[$GroupID] = $Groups[$GroupID];
|
||||
$TopVotes[$GroupID]['Ups'] = $Data[$GroupID]['Ups'];
|
||||
$TopVotes[$GroupID]['Total'] = $Data[$GroupID]['Total'];
|
||||
$TopVotes[$GroupID]['Score'] = $Data[$GroupID]['Score'];
|
||||
|
@ -539,13 +539,12 @@ function header_link($SortKey, $DefaultWay = 'desc') {
|
||||
$TotalCount = $SphQLResult->get_meta('total_found');
|
||||
$Results = $SphQLResult->to_array('groupid');
|
||||
$GroupIDs = array_keys($Results);
|
||||
$Debug->log_var($SphQLResult->get_meta(), 'Result meta info');
|
||||
$GroupCount = count($GroupIDs);
|
||||
while ($SphQLResult->get_meta('total') < $TotalCount && $GroupCount < TORRENTS_PER_PAGE) {
|
||||
// Make sure we get TORRENTS_PER_PAGE results, or all of them if there are less than TORRENTS_PER_PAGE hits
|
||||
$SphQL->where('groupid', $GroupIDs, true);
|
||||
$SphQLResult = $SphQL->query();
|
||||
if (!$SphQLResult->get_meta('total')) {
|
||||
if (!$SphQLResult->has_results()) {
|
||||
break;
|
||||
}
|
||||
$Results += $SphQLResult->to_array('groupid');
|
||||
@ -587,7 +586,6 @@ function header_link($SortKey, $DefaultWay = 'desc') {
|
||||
|
||||
if ($TorrentCount) {
|
||||
$Groups = Torrents::get_groups($GroupIDs);
|
||||
$Groups = $Groups['matches'];
|
||||
|
||||
if (!empty($Groups) && $GroupResults) {
|
||||
$TorrentIDs = array();
|
||||
|
@ -4,7 +4,7 @@ function get_group_info($GroupID, $Return = true, $RevisionID = 0, $PersonalProp
|
||||
if (!$RevisionID) {
|
||||
$TorrentCache = $Cache->get_value("torrents_details_$GroupID");
|
||||
}
|
||||
if ($RevisionID || !is_array($TorrentCache) || isset($OutdatedCache)) {
|
||||
if ($RevisionID || !is_array($TorrentCache)) {
|
||||
// Fetch the group details
|
||||
|
||||
$SQL = 'SELECT ';
|
||||
@ -245,8 +245,7 @@ function get_group_requests($GroupID) {
|
||||
$Requests = $DB->collect('ID');
|
||||
$Cache->cache_value("requests_group_$GroupID", $Requests, 0);
|
||||
}
|
||||
$Requests = Requests::get_requests($Requests);
|
||||
return $Requests['matches'];
|
||||
return Requests::get_requests($Requests);
|
||||
}
|
||||
|
||||
//Used by both sections/torrents/details.php and sections/reportsv2/report.php
|
||||
|
@ -7,8 +7,8 @@
|
||||
View::show_header("History for Group $GroupID");
|
||||
|
||||
$Groups = Torrents::get_groups(array($GroupID), true, true, false);
|
||||
if (!empty($Groups['matches'][$GroupID])) {
|
||||
$Group = $Groups['matches'][$GroupID];
|
||||
if (!empty($Groups[$GroupID])) {
|
||||
$Group = $Groups[$GroupID];
|
||||
$Title = Artists::display_artists($Group['ExtendedArtists']).'<a href="torrents.php?id='.$GroupID.'">'.$Group['Name'].'</a>';
|
||||
} else {
|
||||
$Title = "Group $GroupID";
|
||||
|
@ -131,7 +131,6 @@ function header_link($SortKey, $DefaultWay = 'desc') {
|
||||
$GroupIDs = array_keys($GroupIDs);
|
||||
$FilterIDs = array_keys($FilterIDs);
|
||||
$TorrentGroups = Torrents::get_groups($GroupIDs);
|
||||
$TorrentGroups = $TorrentGroups['matches'];
|
||||
|
||||
// Get the relevant filter labels
|
||||
$DB->query('
|
||||
|
@ -27,8 +27,7 @@
|
||||
WHERE ID='$TorrentID'");
|
||||
|
||||
$Group = Torrents::get_groups(array($GroupID));
|
||||
$Group = array_pop($Group['matches']);
|
||||
extract(Torrents::array_group($Group));
|
||||
extract(Torrents::array_group($Group[$GroupID]));
|
||||
|
||||
$Name = '';
|
||||
$Name .= Artists::display_artists(array('1' => $Artists), false, true);
|
||||
|
@ -484,7 +484,6 @@ function header_link($SortKey, $DefaultWay = 'DESC') {
|
||||
</td>
|
||||
</tr>
|
||||
<?
|
||||
$Results = $Results['matches'];
|
||||
foreach ($TorrentsInfo as $TorrentID => $Info) {
|
||||
list($GroupID, , $Time) = array_values($Info);
|
||||
|
||||
|
@ -3,10 +3,10 @@
|
||||
include(SERVER_ROOT.'/sections/torrents/ranking_funcs.php');
|
||||
|
||||
$Top10 = $Cache->get_value('similar_albums_'.$GroupID);
|
||||
if ($Top10 === False || isset($Top10[$GroupID])) {
|
||||
if ($Top10 === false || isset($Top10[$GroupID])) {
|
||||
|
||||
$VotePairs = $Cache->get_value('vote_pairs_'.$GroupID, true);
|
||||
if ($VotePairs === False || isset($VotePairs[$GroupID])) {
|
||||
if ($VotePairs === false || isset($VotePairs[$GroupID])) {
|
||||
$DB->query("
|
||||
SELECT v.GroupID, SUM(IF(v.Type='Up',1,0)) AS Ups, COUNT(1) AS Total
|
||||
FROM ( SELECT UserID
|
||||
@ -46,11 +46,11 @@
|
||||
|
||||
$Groups = Torrents::get_groups($Top10Groups, true, true, false);
|
||||
$i = 0;
|
||||
foreach ($Groups['matches'] as $MatchGroupID => $MatchGroup) {
|
||||
foreach ($Groups as $MatchGroupID => $MatchGroup) {
|
||||
$i++;
|
||||
$Str = Artists::display_artists($MatchGroup['ExtendedArtists']).'<a href="torrents.php?id='.$MatchGroupID.'">'.$MatchGroup['Name'].'</a>';
|
||||
?>
|
||||
<tr class="votes_rows hidden <?=($i % 2 ? 'rowb' : 'rowa')?>">
|
||||
<tr class="votes_rows hidden <?=($i & 1) ? 'rowb' : 'rowa'?>">
|
||||
<td><span class="like_ranks"><?=$i?>.</span> <?=$Str?></td>
|
||||
</tr>
|
||||
<? } ?>
|
||||
|
@ -672,8 +672,9 @@ function check_paranoia_here($Setting) {
|
||||
WHERE UserID = '$UserID'
|
||||
AND CategoryID = '0'
|
||||
AND Deleted = '0'
|
||||
ORDER BY Featured DESC, Name ASC");
|
||||
$Collages = $DB->to_array();
|
||||
ORDER BY Featured DESC,
|
||||
Name ASC");
|
||||
$Collages = $DB->to_array(false, MYSQLI_NUM, false);
|
||||
$FirstCol = true;
|
||||
foreach ($Collages as $CollageInfo) {
|
||||
list($CollageID, $CName) = $CollageInfo;
|
||||
@ -686,7 +687,7 @@ function check_paranoia_here($Setting) {
|
||||
WHERE ct.CollageID = '$CollageID'
|
||||
ORDER BY ct.Sort
|
||||
LIMIT 5");
|
||||
$Collage = $DB->to_array();
|
||||
$Collage = $DB->to_array(false, MYSQLI_ASSOC, false);
|
||||
?>
|
||||
<table class="layout recent" id="collage<?=$CollageID?>_box" cellpadding="0" cellspacing="0" border="0">
|
||||
<tr class="colhead">
|
||||
@ -701,9 +702,8 @@ function check_paranoia_here($Setting) {
|
||||
</tr>
|
||||
<tr class="images<?=$FirstCol ? '' : ' hidden'?>">
|
||||
<? foreach ($Collage as $C) {
|
||||
$Group = Torrents::get_groups(array($C['GroupID']));
|
||||
$Group = array_pop($Group['matches']);
|
||||
extract(Torrents::array_group($Group));
|
||||
$Group = Torrents::get_groups(array($C['GroupID']), true, true, false);
|
||||
extract(Torrents::array_group($Group[$C['GroupID']]));
|
||||
|
||||
$Name = '';
|
||||
$Name .= Artists::display_artists(array('1' => $Artists), false, true);
|
||||
@ -774,25 +774,17 @@ function check_paranoia_here($Setting) {
|
||||
|
||||
// Requests
|
||||
if (empty($LoggedUser['DisableRequests']) && check_paranoia_here('requestsvoted_list')) {
|
||||
$DB->query("
|
||||
SELECT
|
||||
r.ID,
|
||||
r.CategoryID,
|
||||
r.Title,
|
||||
r.Year,
|
||||
r.TimeAdded,
|
||||
COUNT(rv.UserID) AS Votes,
|
||||
SUM(rv.Bounty) AS Bounty
|
||||
FROM requests AS r
|
||||
LEFT JOIN users_main AS u ON u.ID = UserID
|
||||
LEFT JOIN requests_votes AS rv ON rv.RequestID = r.ID
|
||||
WHERE r.UserID = $UserID
|
||||
AND r.TorrentID = 0
|
||||
GROUP BY r.ID
|
||||
ORDER BY Votes DESC");
|
||||
|
||||
if ($DB->has_results()) {
|
||||
$Requests = $DB->to_array();
|
||||
$SphQL = new SphinxqlQuery();
|
||||
$SphQLResult = $SphQL->select('id, votes, bounty')
|
||||
->from('requests, requests_delta')
|
||||
->where('userid', $UserID)
|
||||
->where('torrentid', 0)
|
||||
->order_by('votes', 'desc')
|
||||
->order_by('bounty', 'desc')
|
||||
->limit(0, 100, 100) // Limit to 100 requests
|
||||
->query();
|
||||
if ($SphQLResult->has_results()) {
|
||||
$SphRequests = $SphQLResult->to_array('id', MYSQLI_ASSOC);
|
||||
?>
|
||||
<div class="box" id="requests_box">
|
||||
<div class="head">
|
||||
@ -815,33 +807,25 @@ function check_paranoia_here($Setting) {
|
||||
</td>
|
||||
</tr>
|
||||
<?
|
||||
foreach ($Requests as $Request) {
|
||||
list($RequestID, $CategoryID, $Title, $Year, $TimeAdded, $Votes, $Bounty) = $Request;
|
||||
|
||||
$Request = Requests::get_requests(array($RequestID));
|
||||
$Request = $Request['matches'][$RequestID];
|
||||
if (empty($Request)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
list($RequestID, $RequestorID, $RequestorName, $TimeAdded, $LastVote, $CategoryID, $Title, $Year, $Image, $Description, $CatalogueNumber, $ReleaseType,
|
||||
$BitrateList, $FormatList, $MediaList, $LogCue, $FillerID, $FillerName, $TorrentID, $TimeFilled) = $Request;
|
||||
|
||||
$CategoryName = $Categories[$CategoryID - 1];
|
||||
$Row = 0;
|
||||
$Requests = Requests::get_requests(array_keys($SphRequests));
|
||||
foreach ($SphRequests as $RequestID => $SphRequest) {
|
||||
$Request = $Requests[$RequestID];
|
||||
$VotesCount = $SphRequest['votes'];
|
||||
$Bounty = $SphRequest['bounty'] * 1024; // Sphinx stores bounty in kB
|
||||
$CategoryName = $Categories[$Request['CategoryID'] - 1];
|
||||
|
||||
if ($CategoryName == 'Music') {
|
||||
$ArtistForm = Requests::get_artists($RequestID);
|
||||
$ArtistLink = Artists::display_artists($ArtistForm, true, true);
|
||||
$FullName = "$ArtistLink<a href=\"requests.php?action=view&id=$RequestID\">$Title [$Year]</a>";
|
||||
$FullName = "$ArtistLink<a href=\"requests.php?action=view&id=$RequestID\">$Request[Title] [$Request[Year]]</a>";
|
||||
} elseif ($CategoryName == 'Audiobooks' || $CategoryName == 'Comedy') {
|
||||
$FullName = "<a href=\"requests.php?action=view&id=$RequestID\">$Title [$Year]</a>";
|
||||
$FullName = "<a href=\"requests.php?action=view&id=$RequestID\">$Request[Title] [$Request[Year]]</a>";
|
||||
} else {
|
||||
$FullName = "<a href=\"requests.php?action=view&id=$RequestID\">$Title</a>";
|
||||
$FullName = "<a href=\"requests.php?action=view&id=$RequestID\">$Request[Title]</a>";
|
||||
}
|
||||
|
||||
$Row = (empty($Row) || $Row == 'a') ? 'b' : 'a';
|
||||
?>
|
||||
<tr class="row<?=$Row?>">
|
||||
<tr class="row<?=($Row++ & 1) ? 'a' : 'b'?>">
|
||||
<td>
|
||||
<?=$FullName ?>
|
||||
<div class="tags">
|
||||
@ -853,11 +837,11 @@ function check_paranoia_here($Setting) {
|
||||
}
|
||||
$TagList = implode(', ', $TagList);
|
||||
?>
|
||||
<?=($TagList)?>
|
||||
<?=$TagList?>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<span id="vote_count_<?=$RequestID?>"><?=$Votes?></span>
|
||||
<span id="vote_count_<?=$RequestID?>"><?=$VotesCount?></span>
|
||||
<? if (check_perms('site_vote')) { ?>
|
||||
<a href="javascript:Vote(0, <?=$RequestID?>)" class="brackets">+</a>
|
||||
<? } ?>
|
||||
@ -866,7 +850,7 @@ function check_paranoia_here($Setting) {
|
||||
<span id="bounty_<?=$RequestID?>"><?=Format::get_size($Bounty)?></span>
|
||||
</td>
|
||||
<td>
|
||||
<?=time_diff($TimeAdded) ?>
|
||||
<?=time_diff($Request['TimeAdded']) ?>
|
||||
</td>
|
||||
</tr>
|
||||
<? } ?>
|
||||
|
@ -54,7 +54,7 @@
|
||||
$DB->query('SELECT FOUND_ROWS()');
|
||||
list($NumResults) = $DB->next_record();
|
||||
|
||||
$TorrentGroups = $Requests = array();
|
||||
$TorrentGroups = $Requests = array();
|
||||
foreach ($Results as $Result) {
|
||||
if ($Result['Page'] == 'torrents') {
|
||||
$TorrentGroups[] = $Result['PageID'];
|
||||
@ -112,28 +112,28 @@
|
||||
$JumpLink = 'collages.php?action=comments&collageid=' . $Result['PageID'] . '&postid=' . $Result['PostID'] . '#post' . $Result['PostID'];
|
||||
break;
|
||||
case 'requests':
|
||||
if (!isset($Requests['matches'][$Result['PageID']])) {
|
||||
error(0);
|
||||
if (!isset($Requests[$Result['PageID']])) {
|
||||
// Deleted request
|
||||
continue 2;
|
||||
}
|
||||
list(,,,,, $CategoryID, $Title, $Year,,,,,,,,,,,,) = $Requests['matches'][$Result['PageID']];
|
||||
|
||||
$CategoryName = $Categories[$CategoryID - 1];
|
||||
|
||||
$Request = $Requests[$Result['PageID']];
|
||||
$CategoryName = $Categories[$Request['CategoryID'] - 1];
|
||||
$Links = 'Request: ';
|
||||
if($CategoryName == "Music") {
|
||||
$Links .= Artists::display_artists(Requests::get_artists($Result['PageID'])) . '<a href="requests.php?action=view&id=' . $Result['PageID'] . '" dir="ltr">' . $Title . " [" . $Year . "]</a>";
|
||||
$Links .= Artists::display_artists(Requests::get_artists($Result['PageID'])) . '<a href="requests.php?action=view&id=' . $Result['PageID'] . '" dir="ltr">' . $Request['Title'] . " [" . $Request['Year'] . "]</a>";
|
||||
} else if($CategoryName == "Audiobooks" || $CategoryName == "Comedy") {
|
||||
$Links .= '<a href="requests.php?action=view&id=' . $Result['PageID'] . '" dir="ltr">' . $Title . " [" . $Year . "]</a>";
|
||||
$Links .= '<a href="requests.php?action=view&id=' . $Result['PageID'] . '" dir="ltr">' . $Request['Title'] . " [" . $Request['Year'] . "]</a>";
|
||||
} else {
|
||||
$Links .= '<a href="requests.php?action=view&id=' . $Result['PageID'] . '">' . $Title . "</a>";
|
||||
$Links .= '<a href="requests.php?action=view&id=' . $Result['PageID'] . '">' . $Request['Title'] . "</a>";
|
||||
}
|
||||
$JumpLink = 'requests.php?action=view&id=' . $Result['PageID'] . '&postid=' . $Result['PostID'] . '#post' . $Result['PostID'];
|
||||
break;
|
||||
case 'torrents':
|
||||
if (!isset($TorrentGroups['matches'][$Result['PageID']])) {
|
||||
error(0);
|
||||
if (!isset($TorrentGroups[$Result['PageID']])) {
|
||||
// Deleted or moved torrent group
|
||||
continue 2;
|
||||
}
|
||||
$GroupInfo = $TorrentGroups['matches'][$Result['PageID']];
|
||||
$GroupInfo = $TorrentGroups[$Result['PageID']];
|
||||
$Links = 'Torrent: ' . Artists::display_artists($GroupInfo['ExtendedArtists']) . '<a href="torrents.php?id=' . $GroupInfo['ID'] . '" dir="ltr">' . $GroupInfo['Name'] . '</a>';
|
||||
if($GroupInfo['Year'] > 0) {
|
||||
$Links .= " [" . $GroupInfo['Year'] . "]";
|
||||
@ -144,7 +144,7 @@
|
||||
$JumpLink = 'torrents.php?id=' . $GroupInfo['ID'] . '&postid=' . $Result['PostID'] . '#post' . $Result['PostID'];
|
||||
break;
|
||||
default:
|
||||
error(0);
|
||||
continue 2;
|
||||
}
|
||||
?>
|
||||
<table class="forum_post box vertical_margin noavatar">
|
||||
|
@ -89,13 +89,10 @@
|
||||
AND AddedOn > '" . db_string($LastVisit) . "'
|
||||
ORDER BY AddedOn");
|
||||
$NewTorrentCount = $DB->record_count();
|
||||
//$NewTorrents = $DB->to_array();
|
||||
//$Artists = Artists::get_artists($GroupID);
|
||||
|
||||
$GroupIDs = $DB->collect('GroupID');
|
||||
$GroupIDs = $DB->collect('GroupID', false);
|
||||
if (count($GroupIDs) > 0) {
|
||||
$TorrentList = Torrents::get_groups($GroupIDs);
|
||||
$TorrentList = $TorrentList['matches'];
|
||||
} else {
|
||||
$TorrentList = array();
|
||||
}
|
||||
@ -103,10 +100,6 @@
|
||||
$Artists = Artists::get_artists($GroupIDs);
|
||||
$Number = 0;
|
||||
|
||||
// foreach ($NewTorrents as $TorrentGroup) {
|
||||
// list($GroupID, $GroupName, $GroupYear, $ReleaseType, $RecordLabel, $CatalogueNumber, $WikiImage) = $TorrentGroup;
|
||||
// $DisplayName = Artists::display_artists($Artists[$GroupID]);
|
||||
// $AltName = $GroupName;
|
||||
foreach ($TorrentList as $GroupID => $Group) {
|
||||
extract(Torrents::array_group($Group));
|
||||
|
||||
|
@ -153,26 +153,25 @@
|
||||
$JumpLink = 'collages.php?id=' . $Result['PageID'] . '&postid=' . $Result['PostID'] . '#post' . $Result['PostID'];
|
||||
break;
|
||||
case 'requests':
|
||||
if (!isset($Requests['matches'][$Result['PageID']])) {
|
||||
error(0);
|
||||
if (!isset($Requests[$Result['PageID']])) {
|
||||
continue;
|
||||
}
|
||||
list(,,,,, $CategoryID, $Title, $Year,,,,,,,,,,,,) = $Requests['matches'][$Result['PageID']];
|
||||
|
||||
$Request = $Requests[$Result['PageID']];
|
||||
$CategoryName = $Categories[$CategoryID - 1];
|
||||
|
||||
$Links = 'Request: ';
|
||||
if($CategoryName == "Music" || $CategoryName == "Audiobooks" || $CategoryName == "Comedy") {
|
||||
$Links .= ($CategoryName == 'Music' ? Artists::display_artists(Requests::get_artists($Result['PageID'])) : '') . '<a href="requests.php?action=view&id=' . $Result['PageID'] . '" dir="ltr">' . $Title . " [" . $Year . "]</a>";
|
||||
$Links .= ($CategoryName == 'Music' ? Artists::display_artists(Requests::get_artists($Result['PageID'])) : '') . '<a href="requests.php?action=view&id=' . $Result['PageID'] . '" dir="ltr">' . $Request['Title'] . " [" . $Request['Year'] . "]</a>";
|
||||
} else {
|
||||
$Links .= '<a href="requests.php?action=view&id=' . $Result['PageID'] . '">' . $Title . "</a>";
|
||||
$Links .= '<a href="requests.php?action=view&id=' . $Result['PageID'] . '">' . $Request['Title'] . "</a>";
|
||||
}
|
||||
$JumpLink = 'requests.php?action=view&id=' . $Result['PageID'] . '&postid=' . $Result['PostID'] . '#post' . $Result['PostID'];
|
||||
break;
|
||||
case 'torrents':
|
||||
if (!isset($TorrentGroups['matches'][$Result['PageID']])) {
|
||||
error(0);
|
||||
if (!isset($TorrentGroups[$Result['PageID']])) {
|
||||
continue;
|
||||
}
|
||||
$GroupInfo = $TorrentGroups['matches'][$Result['PageID']];
|
||||
$GroupInfo = $TorrentGroups[$Result['PageID']];
|
||||
$Links = 'Torrent: ' . Artists::display_artists($GroupInfo['ExtendedArtists']) . '<a href="torrents.php?id=' . $GroupInfo['ID'] . '" dir="ltr">' . $GroupInfo['Name'] . '</a>';
|
||||
if($GroupInfo['Year'] > 0) {
|
||||
$Links .= " [" . $GroupInfo['Year'] . "]";
|
||||
|
Loading…
Reference in New Issue
Block a user