Empty commit

This commit is contained in:
Git 2012-11-01 08:00:21 +00:00
parent e95360f48f
commit 138fa8ed3e
21 changed files with 692 additions and 537 deletions

View File

@ -119,6 +119,9 @@ public function escape_string($String) {
'!'=>'\\\\!', '!'=>'\\\\!',
'"'=>'\\\\"', '"'=>'\\\\"',
'/'=>'\\\\/', '/'=>'\\\\/',
'*'=>'\\\\*',
'$'=>'\\\\$',
'^'=>'\\\\^',
'\\'=>'\\\\\\\\') '\\'=>'\\\\\\\\')
); );
} }
@ -262,35 +265,50 @@ public function where_match($Expr, $Field = '*', $Escape = true) {
/** /**
* Specify the order of the matches. Calling this function multiple times sets secondary priorities * Specify the order of the matches. Calling this function multiple times sets secondary priorities
* *
* @param string $Attribute attribute to use for sorting * @param string $Attribute attribute to use for sorting.
* Passing an empty attribute value will clear the current sort settings
* @param string $Mode sort method to apply to the selected attribute * @param string $Mode sort method to apply to the selected attribute
* @return current SphinxQL query object * @return current SphinxQL query object
*/ */
public function order_by($Attribute, $Mode) { public function order_by($Attribute = false, $Mode) {
if (empty($Attribute)) {
$this->SortBy = array();
} else {
$this->SortBy[] = "$Attribute $Mode"; $this->SortBy[] = "$Attribute $Mode";
}
return $this; return $this;
} }
/** /**
* Specify how the results are grouped * Specify how the results are grouped
* *
* @param string $Attribute group matches with the same $Attribute value * @param string $Attribute group matches with the same $Attribute value.
* Passing an empty attribute value will clear the current group settings
* @return current SphinxQL query object * @return current SphinxQL query object
*/ */
public function group_by($Attribute) { public function group_by($Attribute = false) {
$this->GroupBy = "$Attribute"; if (empty($Attribute)) {
$this->GroupBy = '';
} else {
$this->GroupBy = $Attribute;
}
return $this; return $this;
} }
/** /**
* Specify the order of the results within groups * Specify the order of the results within groups
* *
* @param string $Attribute attribute to use for sorting * @param string $Attribute attribute to use for sorting.
* Passing an empty attribute will clear the current group sort settings
* @param string $Mode sort method to apply to the selected attribute * @param string $Mode sort method to apply to the selected attribute
* @return current SphinxQL query object * @return current SphinxQL query object
*/ */
public function order_group_by($Attribute, $Mode) { public function order_group_by($Attribute = false, $Mode) {
if (empty($Attribute)) {
$this->SortGroupBy = '';
} else {
$this->SortGroupBy = "$Attribute $Mode"; $this->SortGroupBy = "$Attribute $Mode";
}
return $this; return $this;
} }
@ -302,7 +320,7 @@ public function order_group_by($Attribute, $Mode) {
* @param int $MaxMatches number of results to store in the Sphinx server's memory. Must be >= ($Offset+$Limit) * @param int $MaxMatches number of results to store in the Sphinx server's memory. Must be >= ($Offset+$Limit)
* @return current SphinxQL query object * @return current SphinxQL query object
*/ */
public function limit($Offset, $Limit, $MaxMatches = SPHINX_MATCHES_START) { public function limit($Offset, $Limit, $MaxMatches = SPHINX_MAX_MATCHES) {
$this->Limits = "$Offset, $Limit"; $this->Limits = "$Offset, $Limit";
$this->set('max_matches', $MaxMatches); $this->set('max_matches', $MaxMatches);
return $this; return $this;
@ -340,7 +358,7 @@ private function build_query() {
if(!$this->Indexes) { if(!$this->Indexes) {
$this->error('Index name is required.'); $this->error('Index name is required.');
} }
$this->QueryString = "SELECT $this->Select FROM $this->Indexes"; $this->QueryString = "SELECT $this->Select\nFROM $this->Indexes";
if(!empty($this->Expressions)) { if(!empty($this->Expressions)) {
$this->Filters['expr'] = "MATCH('".implode(" ", $this->Expressions)."')"; $this->Filters['expr'] = "MATCH('".implode(" ", $this->Expressions)."')";
} }
@ -524,7 +542,7 @@ public function to_array($Key, $ResultType = MYSQLI_ASSOC) {
*/ */
public function to_pair($Key1, $Key2) { public function to_pair($Key1, $Key2) {
$Return = array(); $Return = array();
while($Row = $this->fetch_row()) { while($Row = $this->fetch_array()) {
$Return[$Row[$Key1]] = $Row[$Key2]; $Return[$Row[$Key1]] = $Row[$Key2];
} }
$this->data_seek(0); $this->data_seek(0);

View File

@ -42,8 +42,7 @@ public static function get_groups($GroupIDs, $Return = true, $GetArtists = true,
return array('matches'=>array(),'notfound'=>array()); return array('matches'=>array(),'notfound'=>array());
} }
$Found = array_flip($GroupIDs); $Found = $NotFound = array_flip($GroupIDs);
$NotFound = array_flip($GroupIDs);
$Key = $Torrents ? 'torrent_group_' : 'torrent_group_light_'; $Key = $Torrents ? 'torrent_group_' : 'torrent_group_light_';
foreach ($GroupIDs as $GroupID) { foreach ($GroupIDs as $GroupID) {
@ -247,6 +246,10 @@ public static function delete_torrent($ID, $GroupID=0, $OcelotReason=-1) {
$DB->query("DELETE FROM torrents_cassette_approved WHERE TorrentID = ".$ID); $DB->query("DELETE FROM torrents_cassette_approved WHERE TorrentID = ".$ID);
$DB->query("DELETE FROM torrents_lossymaster_approved WHERE TorrentID = ".$ID); $DB->query("DELETE FROM torrents_lossymaster_approved WHERE TorrentID = ".$ID);
$DB->query("DELETE FROM torrents_lossyweb_approved WHERE TorrentID = ".$ID); $DB->query("DELETE FROM torrents_lossyweb_approved WHERE TorrentID = ".$ID);
// Tells Sphinx that the group is removed
$DB->query("REPLACE INTO sphinx_delta (ID,Time) VALUES ($ID, UNIX_TIMESTAMP())");
$Cache->delete_value('torrent_download_'.$ID); $Cache->delete_value('torrent_download_'.$ID);
$Cache->delete_value('torrent_group_'.$GroupID); $Cache->delete_value('torrent_group_'.$GroupID);
$Cache->delete_value('torrents_details_'.$GroupID); $Cache->delete_value('torrents_details_'.$GroupID);
@ -332,9 +335,6 @@ public static function delete_group($GroupID) {
$DB->query("DELETE FROM bookmarks_torrents WHERE GroupID='$GroupID'"); $DB->query("DELETE FROM bookmarks_torrents WHERE GroupID='$GroupID'");
$DB->query("DELETE FROM wiki_torrents WHERE PageID='$GroupID'"); $DB->query("DELETE FROM wiki_torrents WHERE PageID='$GroupID'");
// Tells Sphinx that the group is removed
$DB->query("REPLACE INTO sphinx_delta (ID,Time) VALUES ('$GroupID',UNIX_TIMESTAMP())");
$Cache->delete_value('torrents_details_'.$GroupID); $Cache->delete_value('torrents_details_'.$GroupID);
$Cache->delete_value('torrent_group_'.$GroupID); $Cache->delete_value('torrent_group_'.$GroupID);
$Cache->delete_value('groups_artists_'.$GroupID); $Cache->delete_value('groups_artists_'.$GroupID);
@ -356,53 +356,38 @@ public static function update_hash($GroupID) {
WHERE ID='$GroupID'"); WHERE ID='$GroupID'");
$DB->query("REPLACE INTO sphinx_delta $DB->query("REPLACE INTO sphinx_delta
(ID, GroupName, TagList, Year, CategoryID, Time, ReleaseType, RecordLabel, (ID, GroupID, GroupName, TagList, Year, CategoryID, Time, ReleaseType, RecordLabel,
CatalogueNumber, VanityHouse, Size, Snatched, Seeders, Leechers, LogScore, CatalogueNumber, VanityHouse, Size, Snatched, Seeders, Leechers, LogScore,
Scene, HasLog, HasCue, FreeTorrent, Media, Format, Encoding, RemasterYear, Scene, HasLog, HasCue, FreeTorrent, Media, Format, Encoding, RemasterYear,
RemasterTitle, RemasterRecordLabel, RemasterCatalogueNumber, FileList) RemasterTitle, RemasterRecordLabel, RemasterCatalogueNumber, FileList)
SELECT SELECT
g.ID AS ID, t.ID, g.ID, Name, TagList, Year, CategoryID, UNIX_TIMESTAMP(t.Time), ReleaseType,
g.Name AS GroupName, RecordLabel, CatalogueNumber, VanityHouse, Size >> 10 AS Size, Snatched, Seeders,
g.TagList, Leechers, LogScore, CAST(Scene AS CHAR), CAST(HasLog AS CHAR), CAST(HasCue AS CHAR),
g.Year, CAST(FreeTorrent AS CHAR), Media, Format, Encoding,
g.CategoryID, RemasterYear, RemasterTitle, RemasterRecordLabel, RemasterCatalogueNumber,
UNIX_TIMESTAMP(g.Time) AS Time, REPLACE(REPLACE(REPLACE(REPLACE(FileList,
g.ReleaseType, '.flac', ' .flac'),
g.RecordLabel, '.mp3', ' .mp3'),
g.CatalogueNumber, '|||', '\n '),
g.VanityHouse, '_', ' ')
MAX(CEIL(t.Size/1024)) AS Size, AS FileList
SUM(t.Snatched) AS Snatched,
SUM(t.Seeders) AS Seeders,
SUM(t.Leechers) AS Leechers,
MAX(t.LogScore) AS LogScore,
MAX(t.Scene) AS Scene,
MAX(t.HasLog) AS HasLog,
MAX(t.HasCue) AS HasCue,
BIT_OR(t.FreeTorrent-1) AS FreeTorrent,
GROUP_CONCAT(DISTINCT t.Media SEPARATOR ' ') AS Media,
GROUP_CONCAT(DISTINCT t.Format SEPARATOR ' ') AS Format,
GROUP_CONCAT(DISTINCT t.Encoding SEPARATOR ' ') AS Encoding,
GROUP_CONCAT(DISTINCT t.RemasterYear SEPARATOR ' ') AS RemasterYear,
GROUP_CONCAT(DISTINCT t.RemasterTitle SEPARATOR ' ') AS RemasterTitle,
GROUP_CONCAT(DISTINCT t.RemasterRecordLabel SEPARATOR ' ') AS RemasterRecordLabel,
GROUP_CONCAT(DISTINCT t.RemasterCatalogueNumber SEPARATOR ' ') AS RemasterCatalogueNumber,
GROUP_CONCAT(REPLACE(REPLACE(FileList, '|||', '\n '), '_', ' ') SEPARATOR '\n ') AS FileList
FROM torrents AS t FROM torrents AS t
JOIN torrents_group AS g ON g.ID=t.GroupID JOIN torrents_group AS g ON g.ID=t.GroupID
WHERE g.ID=$GroupID WHERE g.ID=$GroupID");
GROUP BY g.ID");
$DB->query("INSERT INTO sphinx_delta $DB->query("INSERT INTO sphinx_delta
(ID, ArtistName) (ID, ArtistName)
SELECT torrents.ID, artists.ArtistName FROM (
SELECT SELECT
GroupID, GroupID,
GROUP_CONCAT(aa.Name separator ' ') GROUP_CONCAT(aa.Name separator ' ') AS ArtistName
FROM torrents_artists AS ta FROM torrents_artists AS ta
JOIN artists_alias AS aa ON aa.AliasID=ta.AliasID JOIN artists_alias AS aa ON aa.AliasID=ta.AliasID
JOIN torrents_group AS tg ON tg.ID=ta.GroupID
WHERE ta.GroupID=$GroupID AND ta.Importance IN ('1', '4', '5', '6') WHERE ta.GroupID=$GroupID AND ta.Importance IN ('1', '4', '5', '6')
GROUP BY tg.ID GROUP BY ta.GroupID
) AS artists
JOIN torrents USING(GroupID)
ON DUPLICATE KEY UPDATE ArtistName=values(ArtistName)"); ON DUPLICATE KEY UPDATE ArtistName=values(ArtistName)");
$Cache->delete_value('torrents_details_'.$GroupID); $Cache->delete_value('torrents_details_'.$GroupID);

View File

@ -487,4 +487,83 @@ function bookmark_data ($UserID)
return array($K, $GroupIDs, $CollageDataList, $TorrentList); return array($K, $GroupIDs, $CollageDataList, $TorrentList);
} }
/**
* Generate HTML for a user's avatar or just return the avatar url
* @param unknown $Avatar
* @param unknown $Username
* @param unknown $Setting
* @param number $Size
* @param string $ReturnHTML
* @return string
*/
public static function show_avatar($Avatar, $Username, $Setting, $Size=150, $ReturnHTML = True) {
global $LoggedUser;
//case 1 is avatars disabled
switch($Setting) {
case 0:
if(!empty($Avatar)) {
$ToReturn = $ReturnHTML ? "<img src='$Avatar' width='$Size' style='max-height:400px;' alt='$Username avatar' />" : $Avatar;
}
else {
$URL = STATIC_SERVER."common/avatars/default.png";
$ToReturn = $ReturnHTML ? "<img src='$URL' width='$Size' style='max-height:400px;' alt='Default Avatar'/>" : $URL;
}
break;
case 2:
$ShowAvatar = True;
case 3:
switch($LoggedUser['Identicons']) {
case 0:
$Type = "identicon";
break;
case 1:
$Type = "monsterid";
break;
case 2:
$Type = "wavatar";
break;
case 3:
$Type = "retro";
break;
case 4:
$Type = "1";
$Robot = True;
break;
case 5:
$Type = "2";
$Robot = True;
break;
case 6:
$Type = "3";
$Robot = True;
break;
default:
$Type = "identicon";
}
$Rating = "pg";
if(!$Robot) {
$URL = "https://www.gravatar.com/avatar/".md5(strtolower(trim($Username)))."?s=$Size&d=$Type&r=$Rating";
}
else {
$URL = "https://static1.robohash.org/".md5($Username)."?set=set".$Type."&size=".$Size."x".$Size;
}
if($ShowAvatar == True && !empty($Avatar)) {
$ToReturn = $ReturnHTML ? "<img src='$Avatar' width='$Size' style='max-height:400px;' alt='$Username avatar' />" : $Avatar;
}
else {
$ToReturn = $ReturnHTML ? "<img src='$URL' width='$Size' style='max-height:400px;' alt='Default Avatar'/>" : $URL;
}
break;
default:
$URL = STATIC_SERVER."common/avatars/default.png";
$ToReturn = $ReturnHTML ? "<img src='$URL' width='$Size' style='max-height:400px;' alt='Default Avatar'/>" : $URL;
}
return $ToReturn;
}
public static function has_avatars_enabled() {
global $HeavyInfo;
return $HeavyInfo['DisableAvatars'] != 1;
}
} }

View File

@ -415,12 +415,6 @@
<div class="rippy" onclick="rippyclick();"></div> <div class="rippy" onclick="rippyclick();"></div>
</div> </div>
<script>
//Random rippy image script, moved to here instead of js file because opera sucks
var n = Math.floor((Math.random()*3)+1);
var background = "transparent url('static/rippy/rippy_halloween_" + n + ".png') no-repeat bottom center";
document.getElementById('rippywrap').style.background = background;
</script>
<? <?
} }
} }

View File

@ -668,6 +668,7 @@ CREATE TABLE `sphinx_delta` (
`RemasterRecordLabel` varchar(50) DEFAULT NULL, `RemasterRecordLabel` varchar(50) DEFAULT NULL,
`RemasterCatalogueNumber` varchar(50) DEFAULT NULL, `RemasterCatalogueNumber` varchar(50) DEFAULT NULL,
`FileList` mediumtext, `FileList` mediumtext,
`VoteScore` float NOT NULL DEFAULT '0',
PRIMARY KEY (`ID`), PRIMARY KEY (`ID`),
KEY `GroupID` (`GroupID`) KEY `GroupID` (`GroupID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8; ) ENGINE=MyISAM DEFAULT CHARSET=utf8;

View File

@ -36,7 +36,7 @@ function compare($X, $Y){
if (!is_array($Data)) { if (!is_array($Data)) {
$Data = unserialize($Data); $Data = unserialize($Data);
} }
list($K, list($Name, $Image, $Body, $NumSimilar, $SimilarArray, ,,,, $VanityHouseArtist)) = each($Data); list($K, list($Name, $Image, $Body, $NumSimilar, $SimilarArray, , , $VanityHouseArtist)) = each($Data);
} else { } else {
if ($RevisionID) { if ($RevisionID) {
$sql = "SELECT $sql = "SELECT
@ -964,15 +964,15 @@ function require(file, callback) {
list($PostID, $AuthorID, $AddedTime, $CommentBody, $EditedUserID, $EditedTime, $EditedUsername) = array_values($Post); list($PostID, $AuthorID, $AddedTime, $CommentBody, $EditedUserID, $EditedTime, $EditedUsername) = array_values($Post);
list($AuthorID, $Username, $PermissionID, $Paranoia, $Artist, $Donor, $Warned, $Avatar, $Enabled, $UserTitle) = array_values(Users::user_info($AuthorID)); list($AuthorID, $Username, $PermissionID, $Paranoia, $Artist, $Donor, $Warned, $Avatar, $Enabled, $UserTitle) = array_values(Users::user_info($AuthorID));
?> ?>
<table class="forum_post box vertical_margin<?=$HeavyInfo['DisableAvatars'] ? ' noavatar' : ''?>" id="post<?=$PostID?>"> <table class="forum_post box vertical_margin<?=!Users::has_avatars_enabled() ? ' noavatar' : ''?>" id="post<?=$PostID?>">
<colgroup> <colgroup>
<? if (empty($HeavyInfo['DisableAvatars'])) { ?> <? if (Users::has_avatars_enabled()) { ?>
<col class="col_avatar" /> <col class="col_avatar" />
<? } ?> <? } ?>
<col class="col_post_body" /> <col class="col_post_body" />
</colgroup> </colgroup>
<tr class="colhead_dark"> <tr class="colhead_dark">
<td colspan="<?=empty($HeavyInfo['DisableAvatars']) ? 2 : 1?>"> <td colspan="<?=Users::has_avatars_enabled() ? 2 : 1?>">
<div style="float:left;"><a class="post_id" href='artist.php?id=<?=$ArtistID?>&amp;postid=<?=$PostID?>#post<?=$PostID?>'>#<?=$PostID?></a> <div style="float:left;"><a class="post_id" href='artist.php?id=<?=$ArtistID?>&amp;postid=<?=$PostID?>#post<?=$PostID?>'>#<?=$PostID?></a>
<strong><?=Users::format_username($AuthorID, true, true, true, true)?></strong> <?=time_diff($AddedTime)?> <strong><?=Users::format_username($AuthorID, true, true, true, true)?></strong> <?=time_diff($AddedTime)?>
- <a href="#quickpost" onclick="Quote('<?=$PostID?>','<?=$Username?>');">[Quote]</a> - <a href="#quickpost" onclick="Quote('<?=$PostID?>','<?=$Username?>');">[Quote]</a>
@ -1006,13 +1006,9 @@ function require(file, callback) {
</td> </td>
</tr> </tr>
<tr> <tr>
<? if (empty($HeavyInfo['DisableAvatars'])) { ?> <? if (Users::has_avatars_enabled()) { ?>
<td class="avatar" valign="top"> <td class="avatar" valign="top">
<? if ($Avatar) { ?> <?=Users::show_avatar($Avatar, $Username, $HeavyInfo['DisableAvatars'])?>
<img src="<?=$Avatar?>" width="150" alt="<?=$Username ?>'s avatar" />
<? } else { ?>
<img src="<?=STATIC_SERVER?>common/avatars/default.png" width="150" alt="Default avatar" />
<? } ?>
</td> </td>
<? } ?> <? } ?>
<td class="body" valign="top"> <td class="body" valign="top">
@ -1042,7 +1038,7 @@ function require(file, callback) {
<div class="box pad"> <div class="box pad">
<table id="quickreplypreview" class="forum_post box vertical_margin hidden" style="text-align:left;"> <table id="quickreplypreview" class="forum_post box vertical_margin hidden" style="text-align:left;">
<colgroup> <colgroup>
<? if (empty($HeavyInfo['DisableAvatars'])) { ?> <? if (Users::has_avatars_enabled()) { ?>
<col class="col_avatar" /> <col class="col_avatar" />
<? } ?> <? } ?>
<col class="col_post_body" /> <col class="col_post_body" />
@ -1060,13 +1056,9 @@ function require(file, callback) {
</td> </td>
</tr> </tr>
<tr> <tr>
<? if (empty($HeavyInfo['DisableAvatars'])) { ?> <? if (Users::has_avatars_enabled()) { ?>
<td class="avatar" valign="top"> <td class="avatar" valign="top">
<? if (!empty($LoggedUser['Avatar'])) { ?> <?=Users::show_avatar($LoggedUser['Avatar'], $LoggedUser['Username'], $HeavyInfo['DisableAvatars'])?>
<img src="<?=$LoggedUser['Avatar']?>" width="150" alt="<?=$LoggedUser['Username']?>'s avatar" />
<? } else { ?>
<img src="<?=STATIC_SERVER?>common/avatars/default.png" width="150" alt="Default avatar" />
<? } ?>
</td> </td>
<? } ?> <? } ?>
<td class="body" valign="top"> <td class="body" valign="top">

View File

@ -72,15 +72,15 @@
list($PostID, $AuthorID, $AddedTime, $Body) = $Post; list($PostID, $AuthorID, $AddedTime, $Body) = $Post;
list($AuthorID, $Username, $PermissionID, $Paranoia, $Artist, $Donor, $Warned, $Avatar, $Enabled, $UserTitle) = array_values(Users::user_info($AuthorID)); list($AuthorID, $Username, $PermissionID, $Paranoia, $Artist, $Donor, $Warned, $Avatar, $Enabled, $UserTitle) = array_values(Users::user_info($AuthorID));
?> ?>
<table class="forum_post box vertical_margin<?=$HeavyInfo['DisableAvatars'] ? ' noavatar' : ''?>" id="post<?=$PostID?>"> <table class="forum_post box vertical_margin<?=!Users::has_avatars_enabled() ? ' noavatar' : ''?>" id="post<?=$PostID?>">
<colgroup> <colgroup>
<? if(empty($HeavyInfo['DisableAvatars'])) { ?> <? if(Users::has_avatars_enabled()) { ?>
<col class="col_avatar" /> <col class="col_avatar" />
<? } ?> <? } ?>
<col class="col_post_body" /> <col class="col_post_body" />
</colgroup> </colgroup>
<tr class="colhead_dark"> <tr class="colhead_dark">
<td colspan="<?=empty($HeavyInfo['DisableAvatars']) ? 2 : 1?>"> <td colspan="<?=Users::has_avatars_enabled() ? 2 : 1?>">
<span style="float:left;"><a href='#post<?=$PostID?>'>#<?=$PostID?></a> <span style="float:left;"><a href='#post<?=$PostID?>'>#<?=$PostID?></a>
by <?=Users::format_username($AuthorID, true, true, true, true, true)?> <?=time_diff($AddedTime)?> <a href="reports.php?action=report&amp;type=collages_comment&amp;id=<?=$PostID?>">[Report Comment]</a> by <?=Users::format_username($AuthorID, true, true, true, true, true)?> <?=time_diff($AddedTime)?> <a href="reports.php?action=report&amp;type=collages_comment&amp;id=<?=$PostID?>">[Report Comment]</a>
<? if (!$ThreadInfo['IsLocked']){ ?> - <a href="#quickpost" onclick="Quote('<?=$PostID?>','<?=$Username?>');">[Quote]</a><? } <? if (!$ThreadInfo['IsLocked']){ ?> - <a href="#quickpost" onclick="Quote('<?=$PostID?>','<?=$Username?>');">[Quote]</a><? }
@ -93,13 +93,9 @@
</td> </td>
</tr> </tr>
<tr> <tr>
<? if(empty($HeavyInfo['DisableAvatars'])) { ?> <? if (Users::has_avatars_enabled()) { ?>
<td class="avatar" valign="top"> <td class="avatar" valign="top">
<? if ($Avatar) { ?> <?=Users::show_avatar($Avatar, $Username, $HeavyInfo['DisableAvatars'])?>
<img src="<?=$Avatar?>" width="150" alt="<?=$Username ?>'s avatar" />
<? } else { ?>
<img src="<?=STATIC_SERVER?>common/avatars/default.png" width="150" alt="Default avatar" />
<? } ?>
</td> </td>
<? } ?> <? } ?>
<td class="body" valign="top"> <td class="body" valign="top">

View File

@ -22,7 +22,7 @@ function compare($X, $Y){
if (!is_array($Data)) { if (!is_array($Data)) {
$Data = unserialize($Data); $Data = unserialize($Data);
} }
list($K, list($Name, $Description, ,,,, $CommentList, $Deleted, $CollageCategoryID, $CreatorID)) = each($Data); list($K, list($Name, $Description, , , $CommentList, $Deleted, $CollageCategoryID, $CreatorID, $Locked, $MaxGroups, $MaxGroupsPerUser)) = each($Data);
} else { } else {
$DB->query("SELECT Name, Description, UserID, Deleted, CategoryID, Locked, MaxGroups, MaxGroupsPerUser FROM collages WHERE ID='$CollageID'"); $DB->query("SELECT Name, Description, UserID, Deleted, CategoryID, Locked, MaxGroups, MaxGroupsPerUser FROM collages WHERE ID='$CollageID'");
if($DB->record_count() > 0) { if($DB->record_count() > 0) {

View File

@ -31,6 +31,7 @@
?> ?>
<div class="thin"> <div class="thin">
<h2>Forums</h2> <h2>Forums</h2>
<div class="forum_list">
<? <?
$Row = 'a'; $Row = 'a';
@ -106,6 +107,7 @@
</tr> </tr>
<? } ?> <? } ?>
</table> </table>
</div>
<div class="linkbox"><a href="forums.php?action=catchup&amp;forumid=all&amp;auth=<?=$LoggedUser['AuthKey']?>">Catch up</a></div> <div class="linkbox"><a href="forums.php?action=catchup&amp;forumid=all&amp;auth=<?=$LoggedUser['AuthKey']?>">Catch up</a></div>
</div> </div>
<? View::show_footer(); <? View::show_footer();

View File

@ -29,7 +29,7 @@
$ForumID = db_string($ForumID); $ForumID = db_string($ForumID);
$TopicID = db_string($TopicID); $TopicID = db_string($TopicID);
$PostID = db_string($PostID); $PostID = db_string($PostID);
$DB->query("INSERT INTO users_notify_quoted (UserID, QuoterID, ForumID, TopicID, PostID, Date) $DB->query("INSERT IGNORE INTO users_notify_quoted (UserID, QuoterID, ForumID, TopicID, PostID, Date)
VALUES ('$UserID', '$QuoterID', '$ForumID', '$TopicID', '$PostID', '" . sqltime() . "')"); VALUES ('$UserID', '$QuoterID', '$ForumID', '$TopicID', '$PostID', '" . sqltime() . "')");
$Cache->delete_value('forums_quotes_' . $UserID); $Cache->delete_value('forums_quotes_' . $UserID);
} }

View File

@ -399,20 +399,20 @@
if (((!$ThreadInfo['IsLocked'] || $ThreadInfo['IsSticky']) && $PostID>$LastRead && strtotime($AddedTime)>$LoggedUser['CatchupTime']) || (isset($RequestKey) && $Key==$RequestKey)) { if (((!$ThreadInfo['IsLocked'] || $ThreadInfo['IsSticky']) && $PostID>$LastRead && strtotime($AddedTime)>$LoggedUser['CatchupTime']) || (isset($RequestKey) && $Key==$RequestKey)) {
echo ' forum_unread'; echo ' forum_unread';
} }
if ($HeavyInfo['DisableAvatars']) { if (!Users::has_avatars_enabled()) {
echo ' noavatar'; echo ' noavatar';
} }
if ($ThreadInfo['OP'] == $AuthorID) { if ($ThreadInfo['OP'] == $AuthorID) {
echo ' important_user'; echo ' important_user';
} ?>" id="post<?=$PostID?>"> } ?>" id="post<?=$PostID?>">
<colgroup> <colgroup>
<? if (empty($HeavyInfo['DisableAvatars'])) { ?> <? if (Users::has_avatars_enabled()) { ?>
<col class="col_avatar" /> <col class="col_avatar" />
<? } ?> <? } ?>
<col class="col_post_body" /> <col class="col_post_body" />
</colgroup> </colgroup>
<tr class="colhead_dark"> <tr class="colhead_dark">
<td colspan="<?=empty($HeavyInfo['DisableAvatars']) ? 2 : 1?>"> <td colspan="<?=Users::has_avatars_enabled() ? 2 : 1?>">
<div style="float:left;"><a class="post_id" href="forums.php?action=viewthread&amp;threadid=<?=$ThreadID?>&amp;postid=<?=$PostID?>#post<?=$PostID?>">#<?=$PostID?></a> <div style="float:left;"><a class="post_id" href="forums.php?action=viewthread&amp;threadid=<?=$ThreadID?>&amp;postid=<?=$PostID?>#post<?=$PostID?>">#<?=$PostID?></a>
<?=Users::format_username($AuthorID, true, true, true, true, true)?> <?=Users::format_username($AuthorID, true, true, true, true, true)?>
<?=time_diff($AddedTime,2)?> <?=time_diff($AddedTime,2)?>
@ -459,16 +459,12 @@
</td> </td>
</tr> </tr>
<tr> <tr>
<? if (empty($HeavyInfo['DisableAvatars'])) { ?> <? if (Users::has_avatars_enabled()) { ?>
<td class="avatar" valign="top"> <td class="avatar" valign="top">
<? if ($Avatar) { ?> <?=Users::show_avatar($Avatar, $Username, $HeavyInfo['DisableAvatars'])?>
<img src="<?=$Avatar?>" width="150" style="max-height:400px;" alt="<?=$Username ?>'s avatar" />
<? } else { ?>
<img src="<?=STATIC_SERVER?>common/avatars/default.png" width="150" alt="Default avatar" />
<? } ?>
</td> </td>
<? } ?> <? } ?>
<td class="body" valign="top"<? if(!empty($HeavyInfo['DisableAvatars'])) { echo ' colspan="2"'; } ?>> <td class="body" valign="top"<? if(!Users::has_avatars_enabled()) { echo ' colspan="2"'; } ?>>
<div id="content<?=$PostID?>"> <div id="content<?=$PostID?>">
<?=$Text->full_format($Body) ?> <?=$Text->full_format($Body) ?>
<? if ($EditedUserID) { ?> <? if ($EditedUserID) { ?>
@ -504,13 +500,13 @@
<div class="box pad"> <div class="box pad">
<table id="quickreplypreview" class="forum_post box vertical_margin hidden" style="text-align:left;"> <table id="quickreplypreview" class="forum_post box vertical_margin hidden" style="text-align:left;">
<colgroup> <colgroup>
<? if(empty($HeavyInfo['DisableAvatars'])) { ?> <? if(Users::has_avatars_enabled()) { ?>
<col class="col_avatar" /> <col class="col_avatar" />
<? } ?> <? } ?>
<col class="col_post_body" /> <col class="col_post_body" />
</colgroup> </colgroup>
<tr class="colhead_dark"> <tr class="colhead_dark">
<td colspan="<?=empty($HeavyInfo['DisableAvatars']) ? 2 : 1?>"> <td colspan="<?=Users::has_avatars_enabled() ? 2 : 1?>">
<span style="float:left;"><a href='#quickreplypreview'>#XXXXXX</a> <span style="float:left;"><a href='#quickreplypreview'>#XXXXXX</a>
by <?=Users::format_username($LoggedUser['ID'], true, true, true, true, true)?> Just now by <?=Users::format_username($LoggedUser['ID'], true, true, true, true, true)?> Just now
</span> </span>
@ -522,13 +518,9 @@
</td> </td>
</tr> </tr>
<tr> <tr>
<? if (empty($HeavyInfo['DisableAvatars'])) { ?> <? if (Users::has_avatars_enabled()) { ?>
<td class="avatar" valign="top"> <td class="avatar" valign="top">
<? if (!empty($LoggedUser['Avatar'])) { ?> <?=Users::show_avatar($LoggedUser['Avatar'], $LoggedUser['Username'], $HeavyInfo['DisableAvatars'])?>
<img src="<?=$LoggedUser['Avatar']?>" width="150" alt="<?=$LoggedUser['Username']?>'s avatar" />
<? } else { ?>
<img src="<?=STATIC_SERVER?>common/avatars/default.png" width="150" alt="Default avatar" />
<? } ?>
</td> </td>
<? } ?> <? } ?>
<td class="body" valign="top"> <td class="body" valign="top">

View File

@ -519,15 +519,15 @@
list($PostID, $AuthorID, $AddedTime, $Body, $EditedUserID, $EditedTime, $EditedUsername) = array_values($Post); 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)); list($AuthorID, $Username, $PermissionID, $Paranoia, $Artist, $Donor, $Warned, $Avatar, $Enabled, $UserTitle) = array_values(Users::user_info($AuthorID));
?> ?>
<table class="forum_post box vertical_margin<?=$HeavyInfo['DisableAvatars'] ? ' noavatar' : ''?>" id="post<?=$PostID?>"> <table class="forum_post box vertical_margin<?=!Users::has_avatars_enabled() ? ' noavatar' : ''?>" id="post<?=$PostID?>">
<colgroup> <colgroup>
<? if(empty($HeavyInfo['DisableAvatars'])) { ?> <? if(Users::has_avatars_enabled()) { ?>
<col class="col_avatar" /> <col class="col_avatar" />
<? } ?> <? } ?>
<col class="col_post_body" /> <col class="col_post_body" />
</colgroup> </colgroup>
<tr class="colhead_dark"> <tr class="colhead_dark">
<td colspan="<?=empty($HeavyInfo['DisableAvatars']) ? 2 : 1?>"> <td colspan="<?=Users::has_avatars_enabled() ? 2 : 1?>">
<div style="float:left;"><a href='#post<?=$PostID?>'>#<?=$PostID?></a> <div style="float:left;"><a href='#post<?=$PostID?>'>#<?=$PostID?></a>
by <strong><?=Users::format_username($AuthorID, true, true, true, true)?></strong> <?=time_diff($AddedTime)?> by <strong><?=Users::format_username($AuthorID, true, true, true, true)?></strong> <?=time_diff($AddedTime)?>
- <a href="#quickpost" onclick="Quote('<?=$PostID?>','<?=$Username?>');">[Quote]</a> - <a href="#quickpost" onclick="Quote('<?=$PostID?>','<?=$Username?>');">[Quote]</a>
@ -546,13 +546,9 @@
</td> </td>
</tr> </tr>
<tr> <tr>
<? if (empty($HeavyInfo['DisableAvatars'])) { ?> <? if (Users::has_avatars_enabled()) { ?>
<td class="avatar" valign="top"> <td class="avatar" valign="top">
<? if ($Avatar) { ?> <?=Users::show_avatar($Avatar, $Username, $HeavyInfo['DisableAvatars'])?>
<img src="<?=$Avatar?>" width="150" alt="<?=$Username ?>'s avatar" />
<? } else { ?>
<img src="<?=STATIC_SERVER?>common/avatars/default.png" width="150" alt="Default avatar" />
<? } ?>
</td> </td>
<? } ?> <? } ?>
<td class="body" valign="top"> <td class="body" valign="top">
@ -582,13 +578,13 @@
<div class="box pad" style="padding:20px 10px 10px 10px;"> <div class="box pad" style="padding:20px 10px 10px 10px;">
<table id="quickreplypreview" class="hidden forum_post box vertical_margin" id="preview"> <table id="quickreplypreview" class="hidden forum_post box vertical_margin" id="preview">
<colgroup> <colgroup>
<? if(empty($HeavyInfo['DisableAvatars'])) { ?> <? if(Users::has_avatars_enabled()) { ?>
<col class="col_avatar" /> <col class="col_avatar" />
<? } ?> <? } ?>
<col class="col_post_body" /> <col class="col_post_body" />
</colgroup> </colgroup>
<tr class="colhead_dark"> <tr class="colhead_dark">
<td colspan="<?=empty($HeavyInfo['DisableAvatars']) ? 2 : 1?>"> <td colspan="<?=Users::has_avatars_enabled() ? 2 : 1?>">
<div style="float:left;"><a href='#quickreplypreview'>#XXXXXX</a> <div style="float:left;"><a href='#quickreplypreview'>#XXXXXX</a>
by <strong><?=Users::format_username($LoggedUser['ID'], true, true, true, true)?></strong> Just now by <strong><?=Users::format_username($LoggedUser['ID'], true, true, true, true)?></strong> Just now
</div> </div>
@ -600,13 +596,9 @@
</td> </td>
</tr> </tr>
<tr> <tr>
<? if(empty($HeavyInfo['DisableAvatars'])) { ?> <? if (Users::has_avatars_enabled()) { ?>
<td class="avatar" valign="top"> <td class="avatar" valign="top">
<? if (!empty($LoggedUser['Avatar'])) { ?> <?=Users::show_avatar($LoggedUser['Avatar'], $LoggedUser['Username'], $HeavyInfo['DisableAvatars'])?>
<img src="<?=$LoggedUser['Avatar']?>" width="150" alt="<?=$LoggedUser['Username']?>'s avatar" />
<? } else { ?>
<img src="<?=STATIC_SERVER?>common/avatars/default.png" width="150" alt="Default avatar" />
<? } ?>
</td> </td>
<? } ?> <? } ?>
<td class="body" valign="top"> <td class="body" valign="top">

View File

@ -932,6 +932,11 @@ function next_hour() {
Misc::send_pm($UserID, 0, db_string('Unseeded torrent notification'), db_string($MessageInfo['Count']." of your uploads will be deleted for inactivity soon. Unseeded torrents are deleted after 4 weeks. If you still have the files, you can seed your uploads by ensuring the torrents are in your client and that they aren't stopped. You can view the time that a torrent has been unseeded by clicking on the torrent description line and looking for the \"Last active\" time. For more information, please go [url=https://what.cd/wiki.php?action=article&amp;id=663]here[/url].\n\nThe following torrent".($MessageInfo['Count']>1?'s':'')." will be removed for inactivity:".$MessageInfo['Msg']."\n\nIf you no longer wish to receive these notifications, please disable them in your profile settings.")); Misc::send_pm($UserID, 0, db_string('Unseeded torrent notification'), db_string($MessageInfo['Count']." of your uploads will be deleted for inactivity soon. Unseeded torrents are deleted after 4 weeks. If you still have the files, you can seed your uploads by ensuring the torrents are in your client and that they aren't stopped. You can view the time that a torrent has been unseeded by clicking on the torrent description line and looking for the \"Last active\" time. For more information, please go [url=https://what.cd/wiki.php?action=article&amp;id=663]here[/url].\n\nThe following torrent".($MessageInfo['Count']>1?'s':'')." will be removed for inactivity:".$MessageInfo['Msg']."\n\nIf you no longer wish to receive these notifications, please disable them in your profile settings."));
} }
} }
$DB->query("UPDATE staff_pm_conversations
SET Status = 'Resolved', ResolverID = '0'
WHERE Date < NOW() - INTERVAL 1 MONTH AND Status = 'Open' AND AssignedToUser IS NULL");
} }
/*************************************************************************\ /*************************************************************************\
//--------------Run twice per month -------------------------------------// //--------------Run twice per month -------------------------------------//

View File

@ -31,11 +31,10 @@ function header_link($SortKey,$DefaultWay="desc") {
if ($OrderWay=="desc") { $NewWay="asc"; } if ($OrderWay=="desc") { $NewWay="asc"; }
else { $NewWay="desc"; } else { $NewWay="desc"; }
} else { $NewWay=$DefaultWay; } } else { $NewWay=$DefaultWay; }
return "torrents.php?order_way=".$NewWay."&amp;order_by=".$SortKey."&amp;".Format::get_url(array('order_way','order_by')); return "torrents.php?order_way=".$NewWay."&amp;order_by=".$SortKey."&amp;".Format::get_url(array('order_way','order_by'));
} }
// Search by infohash /** Start default parameters and validation **/
if (!empty($_GET['searchstr']) || !empty($_GET['groupname'])) { if (!empty($_GET['searchstr']) || !empty($_GET['groupname'])) {
if (!empty($_GET['searchstr'])) { if (!empty($_GET['searchstr'])) {
$InfoHash = $_GET['searchstr']; $InfoHash = $_GET['searchstr'];
@ -43,6 +42,7 @@ function header_link($SortKey,$DefaultWay="desc") {
$InfoHash = $_GET['groupname']; $InfoHash = $_GET['groupname'];
} }
// Search by infohash
if ($InfoHash = is_valid_torrenthash($InfoHash)) { if ($InfoHash = is_valid_torrenthash($InfoHash)) {
$InfoHash = db_string(pack("H*", $InfoHash)); $InfoHash = db_string(pack("H*", $InfoHash));
$DB->query("SELECT ID,GroupID FROM torrents WHERE info_hash='$InfoHash'"); $DB->query("SELECT ID,GroupID FROM torrents WHERE info_hash='$InfoHash'");
@ -84,7 +84,8 @@ function header_link($SortKey,$DefaultWay="desc") {
$Cache->commit_transaction(0); $Cache->commit_transaction(0);
// Use default search options // Use default search options
} elseif((empty($_SERVER['QUERY_STRING']) || (count($_GET) == 1 && isset($_GET['page']))) && !empty($LoggedUser['DefaultSearch'])) { } elseif (empty($_SERVER['QUERY_STRING']) || (count($_GET) == 1 && isset($_GET['page']))) {
if (!empty($LoggedUser['DefaultSearch'])) {
if (!empty($_GET['page'])) { if (!empty($_GET['page'])) {
$Page = $_GET['page']; $Page = $_GET['page'];
parse_str($LoggedUser['DefaultSearch'],$_GET); parse_str($LoggedUser['DefaultSearch'],$_GET);
@ -93,7 +94,57 @@ function header_link($SortKey,$DefaultWay="desc") {
parse_str($LoggedUser['DefaultSearch'],$_GET); parse_str($LoggedUser['DefaultSearch'],$_GET);
} }
} }
}
// Terms were not submitted via the search form
if (!isset($_GET['searchsubmit'])) {
$_GET['group_results'] = !$LoggedUser['DisableGrouping2'];
}
if (isset($_GET['group_results']) && $_GET['group_results']) {
$_GET['group_results'] = 1;
$GroupResults = true;
$SortOrders = array(
// 'url attr' => [global order, order within group]
'year' => array('year', 'year'),
'time' => array('id', 'id'),
'size' => array('maxsize', 'size'),
'seeders' => array('sumseeders', 'seeders'),
'leechers' => array('sumleechers', 'leechers'),
'snatched' => array('sumsnatched', 'snatched'),
'random' => false);
$AggregateExp = array(
'maxsize' => 'MAX(size) AS maxsize',
'sumseeders' => 'SUM(seeders) AS sumseeders',
'sumleechers' => 'SUM(leechers) AS sumleechers',
'sumsnatched' => 'SUM(snatched) AS sumsnatched');
} else {
$SortOrders = array(
'year' => 'year',
'time' => 'id',
'size' => 'size',
'seeders' => 'seeders',
'leechers' => 'leechers',
'snatched' => 'snatched',
'random' => false);
}
if (empty($_GET['order_by']) || !isset($SortOrders[$_GET['order_by']])) {
$_GET['order_by'] = 'time';
$OrderBy = 'time'; // For header links
} else {
$OrderBy = $_GET['order_by'];
}
if(!empty($_GET['order_way']) && $_GET['order_way'] == 'asc') {
$OrderWay = 'asc';
} else {
$_GET['order_way'] = 'desc';
$OrderWay = 'desc';
}
/** End default parameters and validation **/
/** Start preparation of property arrays **/
array_pop($Bitrates); // remove 'other' array_pop($Bitrates); // remove 'other'
$SearchBitrates = array_merge($Bitrates, array('v0','v1','v2','24bit')); $SearchBitrates = array_merge($Bitrates, array('v0','v1','v2','24bit'));
@ -104,25 +155,56 @@ function header_link($SortKey,$DefaultWay="desc") {
foreach ($Formats as $ID => $Val) { foreach ($Formats as $ID => $Val) {
$SearchFormats[$ID] = strtolower($Val); $SearchFormats[$ID] = strtolower($Val);
} }
/** End preparation of property arrays **/
$Queries = array(); /** Start query preparation **/
$SphQLHost = '192.168.5.6';
$SphQLPort = '9307';
$SphQL = new SphinxQL_Query($SphQLHost, $SphQLPort);
$SphQLTor = new SphinxQL_Query($SphQLHost, $SphQLPort);
if ($OrderBy == 'random') {
$SphQL->select('id, groupid, categoryid')
->order_by('RAND()', '');
$Random = true;
} else if ($GroupResults) {
$OrderProperties = $SortOrders[$OrderBy];
$SphQL->select('groupid, categoryid' . (isset($AggregateExp[$OrderProperties[0]]) ? ', '.$AggregateExp[$OrderProperties[0]] : ''))
->group_by('groupid')
->order_by($OrderProperties[0], $OrderWay)
->order_group_by($OrderProperties[1], $OrderWay);
} else {
$SphQL->select('id, groupid, categoryid')
->order_by($SortOrders[$OrderBy], $OrderWay);
}
$SphQL->from('torrents, delta');
$SphQLTor->select('id, groupid')->from('torrents, delta');
/** End query preparation **/
/** Start building search query **/
$Filtered = false;
$EnableNegation = false; // Sphinx needs at least one positive search condition to support the NOT operator $EnableNegation = false; // Sphinx needs at least one positive search condition to support the NOT operator
// Filelist searches makes use of the proximity operator to ensure that all keywords match the same file // Filelist searches makes use of the proximity operator to ensure that all keywords match the same file
if (!empty($_GET['filelist'])) { if (!empty($_GET['filelist'])) {
$SearchString = trim($_GET['filelist']); $SearchString = trim($_GET['filelist']);
if ($SearchString != '') { if ($SearchString != '') {
$Queries[] = '@filelist "'.$SS->escape_string($_GET['filelist']).'"~20'; $SearchString = '"'.SphinxQL::escape_string($_GET['filelist']).'"~20';
$SphQL->where_match($SearchString, 'filelist', false);
$SphQLTor->where_match($SearchString, 'filelist', false);
$EnableNegation = true; $EnableNegation = true;
$Filtered = true;
} }
} }
// Collect all entered search terms to find out whether to enable the NOT operator // Collect all entered search terms to find out whether to enable the NOT operator
$GroupFields = array('artistname','groupname', 'recordlabel', 'cataloguenumber', 'taglist');
$TorrentFields = array('remastertitle', 'remasteryear', 'remasterrecordlabel', 'remastercataloguenumber', 'encoding', 'format', 'media');
$SearchWords = array(); $SearchWords = array();
foreach (array('artistname', 'groupname', 'recordlabel', 'cataloguenumber', foreach (array('artistname', 'groupname', 'recordlabel', 'cataloguenumber',
'remastertitle', 'remasteryear', 'remasterrecordlabel', 'remastercataloguenumber', 'taglist', 'remastertitle', 'remasteryear', 'remasterrecordlabel',
'encoding', 'format', 'media', 'taglist') as $Search) { 'remastercataloguenumber', 'encoding', 'format', 'media') as $Search) {
if (!empty($_GET[$Search])) { if (!empty($_GET[$Search])) {
$SearchString = trim($_GET[$Search]); $SearchString = trim($_GET[$Search]);
if ($SearchString != '') { if ($SearchString != '') {
@ -188,21 +270,30 @@ function header_link($SortKey,$DefaultWay="desc") {
} }
$QueryParts = array(); $QueryParts = array();
foreach ($BasicSearch['include'] as $Word) { foreach ($BasicSearch['include'] as $Word) {
$QueryParts[] = $SS->escape_string($Word); $QueryParts[] = SphinxQL::escape_string($Word);
} }
if (!empty($BasicSearch['exclude'])) { if (!empty($BasicSearch['exclude'])) {
foreach ($BasicSearch['exclude'] as $Word) { foreach ($BasicSearch['exclude'] as $Word) {
$QueryParts[] = '!'.$SS->escape_string(substr($Word,1)); $QueryParts[] = '!'.SphinxQL::escape_string(substr($Word,1));
} }
} }
if (!empty($FilterBitrates)) { if (!empty($FilterBitrates)) {
$Queries[] = "@encoding ".implode(' ', $FilterBitrates); $SearchString = implode(' ', $FilterBitrates);
$SphQL->where_match($SearchString, 'encoding', false);
$SphQLTor->where_match($SearchString, 'encoding', false);
$Filtered = true;
} }
if (!empty($FilterFormats)) { if (!empty($FilterFormats)) {
$Queries[] = "@format ".implode(' ', $FilterFormats); $SearchString = implode(' ', $FilterFormats);
$SphQL->where_match($SearchString, 'format', false);
$SphQLTor->where_match($SearchString, 'format', false);
$Filtered = true;
} }
if (!empty($QueryParts)) { if (!empty($QueryParts)) {
$Queries[] = "@(groupname,artistname,yearfulltext) ".implode(' ', $QueryParts); $SearchString = implode(' ', $QueryParts);
$SphQL->where_match($SearchString, '(groupname,artistname,yearfulltext)', false);
$SphQLTor->where_match($SearchString, '(groupname,artistname,yearfulltext)', false);
$Filtered = true;
} }
} }
} }
@ -215,11 +306,11 @@ function header_link($SortKey,$DefaultWay="desc") {
unset($Tags['exclude']); unset($Tags['exclude']);
} }
foreach ($Tags['include'] as &$Tag) { foreach ($Tags['include'] as &$Tag) {
$Tag = $SS->escape_string($Tag); $Tag = SphinxQL::escape_string($Tag);
} }
if (!empty($Tags['exclude'])) { if (!empty($Tags['exclude'])) {
foreach ($Tags['exclude'] as &$Tag) { foreach ($Tags['exclude'] as &$Tag) {
$Tag = '!'.$SS->escape_string(substr($Tag,1)); $Tag = '!'.SphinxQL::escape_string(substr($Tag,1));
} }
} }
@ -243,7 +334,8 @@ function header_link($SortKey,$DefaultWay="desc") {
} }
} }
if (!empty($QueryParts)) { if (!empty($QueryParts)) {
$Queries[] = "@taglist ".implode(' ', $QueryParts); $SphQL->where_match(implode(' ', $QueryParts), 'taglist', false);
$Filtered = true;
} }
unset($SearchWords['taglist']); unset($SearchWords['taglist']);
} }
@ -258,15 +350,18 @@ function header_link($SortKey,$DefaultWay="desc") {
unset($Words['exclude']); unset($Words['exclude']);
} }
foreach ($Words['include'] as $Word) { foreach ($Words['include'] as $Word) {
$QueryParts[] = $SS->escape_string($Word); $QueryParts[] = SphinxQL::escape_string($Word);
} }
if (!empty($Words['exclude'])) { if (!empty($Words['exclude'])) {
foreach ($Words['exclude'] as $Word) { foreach ($Words['exclude'] as $Word) {
$QueryParts[] = '!'.$SS->escape_string(substr($Word,1)); $QueryParts[] = '!'.SphinxQL::escape_string(substr($Word,1));
} }
} }
if (!empty($QueryParts)) { if (!empty($QueryParts)) {
$Queries[] = "@$Search ".implode(' ', $QueryParts); $SearchString = implode(' ', $QueryParts);
$SphQL->where_match($SearchString, $Search, false);
$SphQLTor->where_match($SearchString, $Search, false);
$Filtered = true;
} }
} }
@ -274,135 +369,165 @@ function header_link($SortKey,$DefaultWay="desc") {
$Years = explode('-', $_GET['year']); $Years = explode('-', $_GET['year']);
if (is_number($Years[0]) || (empty($Years[0]) && !empty($Years[1]) && is_number($Years[1]))) { if (is_number($Years[0]) || (empty($Years[0]) && !empty($Years[1]) && is_number($Years[1]))) {
if (count($Years) == 1) { if (count($Years) == 1) {
$SS->set_filter('year', array((int)$Years[0])); $SphQL->where('year', (int)$Years[0]);
$SphQLTor->where('year', (int)$Years[0]);
} else { } else {
if (empty($Years[1]) || !is_number($Years[1])) { if (empty($Years[1]) || !is_number($Years[1])) {
$Years[1] = PHP_INT_MAX; $Years[1] = PHP_INT_MAX;
} elseif ($Years[0] > $Years[1]) { } elseif ($Years[0] > $Years[1]) {
$Years = array_reverse($Years); $Years = array_reverse($Years);
} }
$SS->set_filter_range('year', (int)$Years[0], (int)$Years[1]); $SphQL->where_between('year', array((int)$Years[0], (int)$Years[1]));
$SphQLTor->where_between('year', array((int)$Years[0], (int)$Years[1]));
} }
$Filtered = true;
} }
} }
if (isset($_GET['haslog']) && $_GET['haslog']!=='') { if (isset($_GET['haslog']) && $_GET['haslog']!=='') {
if ($_GET['haslog'] == 100) { if ($_GET['haslog'] == 100) {
$SS->set_filter('logscore', array(100)); $SphQL->where('logscore', 100);
$SphQLTor->where('logscore', 100);
$Filtered = true;
} elseif ($_GET['haslog'] < 0) { } elseif ($_GET['haslog'] < 0) {
// Exclude torrents with log score equal to 100 // Exclude torrents with log score equal to 100
$SS->set_filter('logscore', array(100), true); $SphQL->where('logscore', 100, true);
$SS->set_filter('haslog', array(1)); $SphQL->where('haslog', 1);
$SphQLTor->where('logscore', 100, true);
$SphQLTor->where('haslog', 1);
$Filtered = true;
} elseif ($_GET['haslog'] == 0) {
$SphQL->where('haslog', 0);
$SphQLTor->where('haslog', 0);
} else { } else {
$SS->set_filter('haslog', array(1)); $SphQL->where('haslog', 1);
$SphQLTor->where('haslog', 1);
$Filtered = true;
} }
} }
foreach (array('hascue','scene','vanityhouse','releasetype') as $Search) {
foreach(array('hascue','scene','vanityhouse','freetorrent','releasetype') as $Search) {
if (isset($_GET[$Search]) && $_GET[$Search] !== '') { if (isset($_GET[$Search]) && $_GET[$Search] !== '') {
if($Search == 'freetorrent') { $SphQL->where($Search, $_GET[$Search]);
switch($_GET[$Search]) { // Release type is group specific
case 0: $SS->set_filter($Search, array(0)); break; if ($Search != 'releasetype') {
case 1: $SS->set_filter($Search, array(1)); break; $SphQLTor->where($Search, $_GET[$Search]);
case 2: $SS->set_filter($Search, array(2)); break;
case 3: $SS->set_filter($Search, array(0), true); break;
} }
} else { if ($_GET[$Search] !== 0) {
$SS->set_filter($Search, array($_GET[$Search])); // Hack! Deleted torrents may show up if we set to true unconditionally. Hope no one notices
$Filtered = true;
} }
} }
} }
if (!empty($_GET['freetorrent'])) {
switch ($_GET['freetorrent']) {
case 0: // Only normal freeleech
$SphQL->where('freetorrent', 0);
$SphQLTor->where('freetorrent', 0);
$Filtered = true;
break;
case 1: // Only free leech
$SphQL->where('freetorrent', 1);
$SphQLTor->where('freetorrent', 1);
$Filtered = true;
break;
case 2: // Only neutral leech
$SphQL->where('freetorrent', 2);
$SphQLTor->where('freetorrent', 2);
$Filtered = true;
break;
case 3: // Free or neutral leech
$SphQL->where('freetorrent', 0, true);
$SphQLTor->where('freetorrent', 0, true);
$Filtered = true;
break;
}
}
if (!empty($_GET['filter_cat'])) { if (!empty($_GET['filter_cat'])) {
$SS->set_filter('categoryid', array_keys($_GET['filter_cat'])); $SphQL->where('categoryid', array_keys($_GET['filter_cat']));
$Filtered = true;
} }
if (!$Filtered) {
$SphQL->where('size', 0, true);
}
/** End building search query **/
/** Run search query and collect results **/
if (isset($Random) && $GroupResults) {
// ORDER BY RAND() can't be used together with GROUP BY, so we need some special tactics
$Page = 1;
$SphQL->limit(0, 5*TORRENTS_PER_PAGE, 5*TORRENTS_PER_PAGE);
$SphQLResult = $SphQL->query();
$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')) {
break;
}
$Results += $SphQLResult->to_array('groupid');
$GroupIDs = array_keys($Results);
$GroupCount = count($GroupIDs);
}
if ($GroupCount > TORRENTS_PER_PAGE) {
$Results = array_slice($Results, 0, TORRENTS_PER_PAGE, true);
}
$GroupIDs = array_keys($Results);
$TorrentCount = count($Results);
} else {
if (!empty($_GET['page']) && is_number($_GET['page']) && $_GET['page'] > 0) { if (!empty($_GET['page']) && is_number($_GET['page']) && $_GET['page'] > 0) {
if (check_perms('site_search_many')) { if (check_perms('site_search_many')) {
$Page = $_GET['page']; $Page = $_GET['page'];
} else { } else {
$Page = min(SPHINX_MAX_MATCHES/TORRENTS_PER_PAGE, $_GET['page']); $Page = min(SPHINX_MAX_MATCHES/TORRENTS_PER_PAGE, $_GET['page']);
} }
$SS->limit(($Page-1)*TORRENTS_PER_PAGE, TORRENTS_PER_PAGE); $Offset = ($Page - 1) * TORRENTS_PER_PAGE;
$SphQL->limit($Offset, TORRENTS_PER_PAGE, $Offset + TORRENTS_PER_PAGE);
} else { } else {
$Page = 1; $Page = 1;
$SS->limit(0, TORRENTS_PER_PAGE); $SphQL->limit(0, TORRENTS_PER_PAGE, TORRENTS_PER_PAGE);
} }
$SphQLResult = $SphQL->query();
if(!empty($_GET['order_way']) && $_GET['order_way'] == 'asc') { $TorrentCount = $SphQLResult->get_meta('total_found');
$Way = SPH_SORT_ATTR_ASC; if ($GroupResults) {
$OrderWay = 'asc'; // For header links $Results = $SphQLResult->to_array('groupid');
$GroupIDs = array_keys($Results);
} else { } else {
$Way = SPH_SORT_ATTR_DESC; $Results = $SphQLResult->to_array('id');
$_GET['order_way'] = 'desc'; $GroupIDs = $SphQLResult->collect('groupid');
$OrderWay = 'desc';
}
if(empty($_GET['order_by']) || !in_array($_GET['order_by'], array('year','time','size','seeders','leechers','snatched','random'))) {
$_GET['order_by'] = 'time';
$OrderBy = 'time'; // For header links
} elseif($_GET['order_by'] == 'random') {
$OrderBy = '@random';
$Way = SPH_SORT_EXTENDED;
$SS->limit(0, TORRENTS_PER_PAGE);
} else {
$OrderBy = $_GET['order_by'];
}
$SS->SetSortMode($Way, $OrderBy);
if(count($Queries)>0) {
$Query = implode(' ',$Queries);
} else {
$Query='';
if(empty($SS->Filters)) {
$SS->set_filter('size', array(0), true);
} }
} }
$SS->set_index(SPHINX_INDEX.' delta'); if (!check_perms('site_search_many') && $TorrentCount > SPHINX_MAX_MATCHES) {
$Results = $SS->search($Query, '', 0, array(), '', ''); $TorrentCount = SPHINX_MAX_MATCHES;
if(check_perms('site_search_many')) {
$TorrentCount = $SS->TotalResults;
} else {
$TorrentCount = min($SS->TotalResults, SPHINX_MAX_MATCHES);
} }
/*
// If some were fetched from memcached, get their artists
if(!empty($Results['matches'])) { // Fetch the artists for groups
$GroupIDs = array_keys($Results['matches']);
$Artists = Artists::get_artists($GroupIDs);
foreach($Artists as $GroupID=>$Data) { if ($TorrentCount) {
if(!empty($Data[1])) { $Groups = Torrents::get_groups($GroupIDs);
$Results['matches'][$GroupID]['Artists']=$Data[1]; // Only use main artists $Groups = $Groups['matches'];
}
ksort($Results['matches'][$GroupID]);
}
}
*/
// These ones were not found in the cache, run SQL
if(!empty($Results['notfound'])) {
$SQLResults = Torrents::get_groups($Results['notfound']);
if(is_array($SQLResults['notfound'])) { // Something wasn't found in the db, remove it from results if (!empty($Groups) && $GroupResults) {
reset($SQLResults['notfound']); $TorrentIDs = array();
foreach($SQLResults['notfound'] as $ID) { foreach ($Groups as $Group) {
unset($SQLResults['matches'][$ID]); if (!empty($Group['Torrents'])) {
unset($Results['matches'][$ID]); $TorrentIDs = array_merge($TorrentIDs, array_keys($Group['Torrents']));
} }
} }
// Merge SQL results with sphinx/memcached results // Get a list of all torrent ids that match the search query
foreach($SQLResults['matches'] as $ID=>$SQLResult) { $SphQLTor->where('id', $TorrentIDs)->limit(0, count($TorrentIDs), count($TorrentIDs));
$Results['matches'][$ID] = array_merge($Results['matches'][$ID], $SQLResult); $SphQLResultTor = $SphQLTor->query();
ksort($Results['matches'][$ID]); $TorrentIDs = array_fill_keys($SphQLResultTor->collect('id'), true);
} }
} }
/** End run search query and collect results **/
$Results = $Results['matches'];
$AdvancedSearch = false; $AdvancedSearch = false;
$Action = 'action=basic'; $Action = 'action=basic';
@ -413,7 +538,6 @@ function header_link($SortKey,$DefaultWay="desc") {
View::show_header('Browse Torrents','browse'); View::show_header('Browse Torrents','browse');
@ -426,8 +550,7 @@ function header_link($SortKey,$DefaultWay="desc") {
(<a href="torrents.php?<? if (!empty($LoggedUser['SearchType'])) { ?>action=basic&amp;<? } echo Format::get_url(array('action')); ?>">Basic Search</a>) (<a href="torrents.php?<? if (!empty($LoggedUser['SearchType'])) { ?>action=basic&amp;<? } echo Format::get_url(array('action')); ?>">Basic Search</a>)
<? } else { ?> <? } else { ?>
(<a href="torrents.php?action=advanced&amp;<?=Format::get_url(array('action'))?>">Advanced Search</a>) (<a href="torrents.php?action=advanced&amp;<?=Format::get_url(array('action'))?>">Advanced Search</a>)
<? } <? } ?>
?>
</h3> </h3>
<div class="box pad"> <div class="box pad">
<table class="layout"> <table class="layout">
@ -599,6 +722,10 @@ function header_link($SortKey,$DefaultWay="desc") {
</select> </select>
</td> </td>
</tr> </tr>
<tr>
<td class="label"><label for="group_results">Group by release:</label></td>
<td><input type="checkbox" value="1" name="group_results" id="group_results" <?Format::selected('group_results',1,'checked')?> /></td>
</tr>
</table> </table>
<table class="layout cat_list"> <table class="layout cat_list">
<? <?
@ -663,9 +790,10 @@ function header_link($SortKey,$DefaultWay="desc") {
<div class="submit"> <div class="submit">
<span style="float:left;"><?=number_format($TorrentCount)?> Results</span> <span style="float:left;"><?=number_format($TorrentCount)?> Results</span>
<input type="submit" value="Filter Torrents" /> <input type="submit" value="Filter Torrents" />
<input type="hidden" name="searchsubmit" value="1" />
<input type="button" value="Reset" onclick="location.href='torrents.php<? if (isset($_GET['action']) && $_GET['action']=="advanced") { ?>?action=advanced<? } ?>'" /> <input type="button" value="Reset" onclick="location.href='torrents.php<? if (isset($_GET['action']) && $_GET['action']=="advanced") { ?>?action=advanced<? } ?>'" />
&nbsp;&nbsp; &nbsp;&nbsp;
<? if (count($Queries)>0 || count($SS->Filters)>0) { ?> <? if ($Filtered) { ?>
<input type="submit" name="setdefault" value="Make Default" /> <input type="submit" name="setdefault" value="Make Default" />
<? <?
} }
@ -679,8 +807,11 @@ function header_link($SortKey,$DefaultWay="desc") {
</div> </div>
</form> </form>
<? if($TorrentCount == 0) { <div class="linkbox"><?=$Pages?></div>
$DB->query("SELECT <?
if ($TorrentCount == 0) {
tags.Name, tags.Name,
((COUNT(tags.Name)-2)*(SUM(tt.PositiveVotes)-SUM(tt.NegativeVotes)))/(tags.Uses*0.8) AS Score ((COUNT(tags.Name)-2)*(SUM(tt.PositiveVotes)-SUM(tt.NegativeVotes)))/(tags.Uses*0.8) AS Score
FROM xbt_snatched AS s FROM xbt_snatched AS s
@ -728,9 +859,11 @@ function header_link($SortKey,$DefaultWay="desc") {
<div class="linkbox"><?=$Pages?></div> <div class="linkbox"><?=$Pages?></div>
<table class="torrent_table cats grouping" id="torrent_table"> <table class="torrent_table cats <?=$GroupResults ? 'grouping' : 'no_grouping'?>" id="torrent_table">
<tr class="colhead"> <tr class="colhead">
<? if ($GroupResults) { ?>
<td class="small"></td> <td class="small"></td>
<? } ?>
<td class="small cats_col"></td> <td class="small cats_col"></td>
<td width="100%">Name / <a href="<?=header_link('year')?>">Year</a></td> <td width="100%">Name / <a href="<?=header_link('year')?>">Year</a></td>
<td>Files</td> <td>Files</td>
@ -741,15 +874,39 @@ function header_link($SortKey,$DefaultWay="desc") {
<td class="sign"><a href="<?=header_link('leechers')?>"><img src="static/styles/<?=$LoggedUser['StyleName']?>/images/leechers.png" alt="Leechers" title="Leechers" /></a></td> <td class="sign"><a href="<?=header_link('leechers')?>"><img src="static/styles/<?=$LoggedUser['StyleName']?>/images/leechers.png" alt="Leechers" title="Leechers" /></a></td>
</tr> </tr>
<? <?
// Start printing torrent list // Start printing torrent list
foreach ($Results as $Result) {
foreach($Results as $GroupID => $Data) { $GroupID = $Result['groupid'];
list($Artists, $GroupCatalogueNumber, $ExtendedArtists, $GroupID2, $GroupName, $GroupRecordLabel, $GroupInfo = $Groups[$GroupID];
$ReleaseType, $TagList, $Torrents, $GroupVanityHouse, $GroupYear, $CategoryID, $FreeTorrent, if (empty($GroupInfo['Torrents'])) {
$HasCue, $HasLog, $TotalLeechers, $LogScore, $ReleaseType, $ReleaseType, $TotalSeeders, continue;
$MaxSize, $TotalSnatched, $GroupTime) = array_values($Data); }
$CategoryID = $Result['categoryid'];
$TagList = explode(' ',str_replace('_','.',$TagList)); $GroupYear = $GroupInfo['Year'];
$ExtendedArtists = $GroupInfo['ExtendedArtists'];
$GroupCatalogueNumber = $GroupInfo['CatalogueNumber'];
$GroupName = $GroupInfo['Name'];
$GroupRecordLabel = $GroupInfo['RecordLabel'];
$ReleaseType = $GroupInfo['ReleaseType'];
if ($GroupResults) {
$Torrents = $GroupInfo['Torrents'];
$GroupTime = $MaxSize = $TotalLeechers = $TotalSeeders = $TotalSnatched = 0;
foreach ($Torrents as $T) {
if ($T['Time'] > $GroupTime) {
$GroupTime = $T['Time'];
}
if ($T['Size'] > $MaxSize) {
$MaxSize = $T['Size'];
}
$TotalLeechers += $T['Leechers'];
$TotalSeeders += $T['Seeders'];
$TotalSnatched += $T['Snatched'];
}
} else {
$Torrents = array($Result['id'] => $GroupInfo['Torrents'][$Result['id']]);
}
$TagList = explode(' ',str_replace('_','.',$GroupInfo['TagList']));
$TorrentTags = array(); $TorrentTags = array();
foreach ($TagList as $Tag) { foreach ($TagList as $Tag) {
@ -757,20 +914,22 @@ function header_link($SortKey,$DefaultWay="desc") {
} }
$TorrentTags = implode(', ', $TorrentTags); $TorrentTags = implode(', ', $TorrentTags);
if(count($Torrents)>1 || $CategoryID==1) {
// These torrents are in a group
if (!empty($ExtendedArtists[1]) || !empty($ExtendedArtists[4]) || !empty($ExtendedArtists[5]) || !empty($ExtendedArtists[6])) { if (!empty($ExtendedArtists[1]) || !empty($ExtendedArtists[4]) || !empty($ExtendedArtists[5]) || !empty($ExtendedArtists[6])) {
unset($ExtendedArtists[2]); unset($ExtendedArtists[2]);
unset($ExtendedArtists[3]); unset($ExtendedArtists[3]);
$DisplayName = Artists::display_artists($ExtendedArtists); $DisplayName = Artists::display_artists($ExtendedArtists);
} elseif(!empty($Artists)) {
$DisplayName = Artists::display_artists(array(1=>$Artists));
} else { } else {
$DisplayName = ''; $DisplayName = '';
} }
if ($GroupResults && (count($Torrents)>1 || isset($GroupedCategories[$CategoryID-1]))) {
// These torrents are in a group
$DisplayName .= '<a href="torrents.php?id='.$GroupID.'" title="View Torrent" dir="ltr">'.$GroupName.'</a>'; $DisplayName .= '<a href="torrents.php?id='.$GroupID.'" title="View Torrent" dir="ltr">'.$GroupName.'</a>';
if($GroupYear>0) { $DisplayName.=" [".$GroupYear."]"; } if ($GroupYear > 0) {
if($GroupVanityHouse) { $DisplayName .= ' [<abbr title="This is a vanity house release">VH</abbr>]'; } $DisplayName .= " [".$GroupYear."]";
}
if ($GroupVanityHouse) {
$DisplayName .= ' [<abbr title="This is a vanity house release">VH</abbr>]';
}
$DisplayName .= ' ['.$ReleaseTypes[$ReleaseType].']'; $DisplayName .= ' ['.$ReleaseTypes[$ReleaseType].']';
?> ?>
<tr class="group"> <tr class="group">
@ -799,7 +958,7 @@ function header_link($SortKey,$DefaultWay="desc") {
</div> </div>
</td> </td>
<td class="nobr"><?=time_diff($GroupTime,1)?></td> <td class="nobr"><?=time_diff($GroupTime,1)?></td>
<td class="nobr"><?=Format::get_size($MaxSize*1024)?> (Max)</td> <td class="nobr"><?=Format::get_size($MaxSize)?> (Max)</td>
<td><?=number_format($TotalSnatched)?></td> <td><?=number_format($TotalSnatched)?></td>
<td<?=($TotalSeeders==0)?' class="r00"':''?>><?=number_format($TotalSeeders)?></td> <td<?=($TotalSeeders==0)?' class="r00"':''?>><?=number_format($TotalSeeders)?></td>
<td><?=number_format($TotalLeechers)?></td> <td><?=number_format($TotalLeechers)?></td>
@ -818,92 +977,7 @@ function header_link($SortKey,$DefaultWay="desc") {
// All of the individual torrents in the group // All of the individual torrents in the group
// If they're using the advanced search and have chosen enabled grouping, we just skip the torrents that don't check out // If they're using the advanced search and have chosen enabled grouping, we just skip the torrents that don't check out
if (!isset($TorrentIDs[$TorrentID])) {
$Filter = false;
$Pass = false;
if(!empty($FilterBitrates)) {
$Filter = true;
$Bitrate = strtolower(array_shift(explode(' ',$Data['Encoding'])));
if(in_array($Bitrate, $FilterBitrates)) {
$Pass = true;
}
}
if(!empty($FilterFormats)) {
$Filter = true;
if(in_array(strtolower($Data['Format']), $FilterFormats)) {
$Pass = true;
}
}
if(!empty($_GET['encoding'])) {
$Filter = true;
if($Data['Encoding']==$_GET['encoding']) {
$Pass = true;
}
}
if(!empty($_GET['format'])) {
$Filter = true;
if($Data['Format']==$_GET['format']) {
$Pass = true;
}
}
if(!empty($_GET['media'])) {
$Filter = true;
if($Data['Media']==$_GET['media']) {
$Pass = true;
}
}
if(isset($_GET['haslog']) && $_GET['haslog']!=='') {
$Filter = true;
if($_GET['haslog'] == '100' && $Data['LogScore']==100) {
$Pass = true;
} elseif (($_GET['haslog'] == '-1') && ($Data['LogScore'] < 100) && ($Data['HasLog'] == '1')) {
$Pass = true;
} elseif(($_GET['haslog'] == '1' || $_GET['haslog'] == '0') && (int)$Data['HasLog']==$_GET['haslog']) {
$Pass = true;
}
}
if(isset($_GET['hascue']) && $_GET['hascue']!=='') {
$Filter = true;
if((int)$Data['HasCue']==$_GET['hascue']) {
$Pass = true;
}
}
if(isset($_GET['scene']) && $_GET['scene']!=='') {
$Filter = true;
if((int)$Data['Scene']==$_GET['scene']) {
$Pass = true;
}
}
if(isset($_GET['vanityhouse']) && $_GET['vanityhouse']!=='') {
$Filter = true;
if((int)$Data['VanityHouse']==$_GET['vanityhouse']) {
$Pass = true;
}
}
if(isset($_GET['freetorrent']) && $_GET['freetorrent']!=='') {
$Filter = true;
if((int)$Data['FreeTorrent'] & $_GET['freetorrent'] || (int)$Data['FreeTorrent'] == $_GET['freetorrent']) {
$Pass = true;
}
}
if(!empty($_GET['remastertitle'])) {
$Filter = true;
$Continue = false;
$RemasterParts = explode(' ', $_GET['remastertitle']);
foreach($RemasterParts as $RemasterPart) {
if(stripos($Data['RemasterTitle'],$RemasterPart) === false) {
$Continue = true;
}
}
if(!$Continue) {
$Pass = true;
}
}
if($Filter && !$Pass) {
continue; continue;
} }
@ -911,8 +985,13 @@ function header_link($SortKey,$DefaultWay="desc") {
$FirstUnknown = !isset($FirstUnknown); $FirstUnknown = !isset($FirstUnknown);
} }
if($CategoryID == 1 && ($Data['RemasterTitle'] != $LastRemasterTitle || $Data['RemasterYear'] != $LastRemasterYear || if (isset($GroupedCategories[$CategoryID-1])
$Data['RemasterRecordLabel'] != $LastRemasterRecordLabel || $Data['RemasterCatalogueNumber'] != $LastRemasterCatalogueNumber) || $FirstUnknown || $Data['Media'] != $LastMedia) { && ($Data['RemasterTitle'] != $LastRemasterTitle
|| $Data['RemasterYear'] != $LastRemasterYear
|| $Data['RemasterRecordLabel'] != $LastRemasterRecordLabel
|| $Data['RemasterCatalogueNumber'] != $LastRemasterCatalogueNumber)
|| $FirstUnknown
|| $Data['Media'] != $LastMedia) {
$EditionID++; $EditionID++;
if ($Data['Remastered'] && $Data['RemasterYear'] != 0) { if ($Data['Remastered'] && $Data['RemasterYear'] != 0) {
@ -976,22 +1055,23 @@ function header_link($SortKey,$DefaultWay="desc") {
// Viewing a type that does not require grouping // Viewing a type that does not require grouping
list($TorrentID, $Data) = each($Torrents); list($TorrentID, $Data) = each($Torrents);
$DisplayName .= '<a href="torrents.php?id='.$GroupID.'&amp;torrentid='.$TorrentID.'#torrent'.$TorrentID.'" title="View Torrent">'.$GroupName.'</a>';
$DisplayName = '<a href="torrents.php?id='.$GroupID.'" title="View Torrent">'.$GroupName.'</a>'; if (isset($GroupedCategories[$CategoryID-1])) {
if ($GroupYear) {
if ($Data['IsSnatched']) { $DisplayName .= " [".$GroupYear."]";
$DisplayName .= ' <strong class="snatched_torrent">Snatched!</strong>';
} }
if ($Data['FreeTorrent'] == '1') { if($CategoryID == 1 && $ReleaseType > 0) {
$DisplayName .= ' <strong>Freeleech!</strong>'; $DisplayName .= ' ['.$ReleaseTypes[$ReleaseType].']';
} elseif ($Data['FreeTorrent'] == '2') { }
$DisplayName .= ' <strong>Neutral Leech!</strong>'; $ExtraInfo = Torrents::torrent_info($Data, true, true);
} elseif ($Data['PersonalFL']) { } else {
$DisplayName .= $AddExtra.' <strong>Personal Freeleech!</strong>'; $ExtraInfo = '';
} }
?> ?>
<tr class="torrent"> <tr class="torrent">
<? if ($GroupResults) { ?>
<td></td> <td></td>
<? } ?>
<td class="center cats_col"> <td class="center cats_col">
<div title="<?=ucfirst(str_replace('.',' ',$TagList[0]))?>" class="cats_<?=strtolower(str_replace(array('-',' '),array('',''),$Categories[$CategoryID-1]))?> tags_<?=str_replace('.','_',$TagList[0])?>"></div> <div title="<?=ucfirst(str_replace('.',' ',$TagList[0]))?>" class="cats_<?=strtolower(str_replace(array('-',' '),array('',''),$Categories[$CategoryID-1]))?> tags_<?=str_replace('.','_',$TagList[0])?>"></div>
</td> </td>
@ -1004,17 +1084,15 @@ function header_link($SortKey,$DefaultWay="desc") {
| <a href="reportsv2.php?action=report&amp;id=<?=$TorrentID?>" title="Report">RP</a> ] | <a href="reportsv2.php?action=report&amp;id=<?=$TorrentID?>" title="Report">RP</a> ]
</span> </span>
<?=$DisplayName?> <?=$DisplayName?>
<br /> <div class="torrent_info"><?=$ExtraInfo?></div>
<div class="tags"> <div class="tags"><?=$TorrentTags?></div>
<?=$TorrentTags?>
</div>
</td> </td>
<td><?=$Data['FileCount']?></td> <td><?=$Data['FileCount']?></td>
<td class="nobr"><?=time_diff($GroupTime,1)?></td> <td class="nobr"><?=time_diff($Data['Time'],1)?></td>
<td class="nobr"><?=Format::get_size($Data['Size'])?></td> <td class="nobr"><?=Format::get_size($Data['Size'])?></td>
<td><?=number_format($TotalSnatched)?></td> <td><?=number_format($Data['Snatched'])?></td>
<td<?=($TotalSeeders==0)?' class="r00"':''?>><?=number_format($TotalSeeders)?></td> <td<?=($Data['Seeders']==0)?' class="r00"':''?>><?=number_format($Data['Seeders'])?></td>
<td><?=number_format($TotalLeechers)?></td> <td><?=number_format($Data['Leechers'])?></td>
</tr> </tr>
<? <?
} }
@ -1022,4 +1100,4 @@ function header_link($SortKey,$DefaultWay="desc") {
?> ?>
</table> </table>
<div class="linkbox"><?=$Pages?></div> <div class="linkbox"><?=$Pages?></div>
<? View::show_footer(array('disclaimer'=>false)); ?> <? View::show_footer(); ?>

View File

@ -802,15 +802,15 @@ function filelist($Str) {
list($PostID, $AuthorID, $AddedTime, $Body, $EditedUserID, $EditedTime, $EditedUsername) = array_values($Post); 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)); list($AuthorID, $Username, $PermissionID, $Paranoia, $Artist, $Donor, $Warned, $Avatar, $Enabled, $UserTitle) = array_values(Users::user_info($AuthorID));
?> ?>
<table class="forum_post box vertical_margin<?=$HeavyInfo['DisableAvatars'] ? ' noavatar' : ''?>" id="post<?=$PostID?>"> <table class="forum_post box vertical_margin<?=!Users::has_avatars_enabled() ? ' noavatar' : ''?>" id="post<?=$PostID?>">
<colgroup> <colgroup>
<? if (empty($HeavyInfo['DisableAvatars'])) { ?> <? if (Users::has_avatars_enabled()) { ?>
<col class="col_avatar" /> <col class="col_avatar" />
<? } ?> <? } ?>
<col class="col_post_body" /> <col class="col_post_body" />
</colgroup> </colgroup>
<tr class="colhead_dark"> <tr class="colhead_dark">
<td colspan="<?=empty($HeavyInfo['DisableAvatars']) ? 2 : 1?>"> <td colspan="<?=Users::has_avatars_enabled() ? 2 : 1?>">
<div style="float:left;"><a class="post_id" href="torrents.php?id=<?=$GroupID?>&amp;postid=<?=$PostID?>#post<?=$PostID?>">#<?=$PostID?></a> <div style="float:left;"><a class="post_id" href="torrents.php?id=<?=$GroupID?>&amp;postid=<?=$PostID?>#post<?=$PostID?>">#<?=$PostID?></a>
<strong><?=Users::format_username($AuthorID, true, true, true, true)?></strong> <?=time_diff($AddedTime)?> <strong><?=Users::format_username($AuthorID, true, true, true, true)?></strong> <?=time_diff($AddedTime)?>
- <a href="#quickpost" onclick="Quote('<?=$PostID?>','<?=$Username?>');">[Quote]</a> - <a href="#quickpost" onclick="Quote('<?=$PostID?>','<?=$Username?>');">[Quote]</a>
@ -844,13 +844,9 @@ function filelist($Str) {
</td> </td>
</tr> </tr>
<tr> <tr>
<? if(empty($HeavyInfo['DisableAvatars'])) { ?> <? if (Users::has_avatars_enabled()) { ?>
<td class="avatar" valign="top"> <td class="avatar" valign="top">
<? if ($Avatar) { ?> <?=Users::show_avatar($Avatar, $Username, $HeavyInfo['DisableAvatars'])?>
<img src="<?=$Avatar?>" width="150" alt="<?=$Username ?>'s avatar" />
<? } else { ?>
<img src="<?=STATIC_SERVER?>common/avatars/default.png" width="150" alt="Default avatar" />
<? } ?>
</td> </td>
<? } ?> <? } ?>
<td class="body" valign="top"> <td class="body" valign="top">
@ -880,13 +876,13 @@ function filelist($Str) {
<div class="box pad"> <div class="box pad">
<table id="quickreplypreview" class="forum_post box vertical_margin hidden" style="text-align:left;"> <table id="quickreplypreview" class="forum_post box vertical_margin hidden" style="text-align:left;">
<colgroup> <colgroup>
<? if(empty($HeavyInfo['DisableAvatars'])) { ?> <? if(Users::has_avatars_enabled()) { ?>
<col class="col_avatar" /> <col class="col_avatar" />
<? } ?> <? } ?>
<col class="col_post_body" /> <col class="col_post_body" />
</colgroup> </colgroup>
<tr class="colhead_dark"> <tr class="colhead_dark">
<td colspan="<?=empty($HeavyInfo['DisableAvatars']) ? 2 : 1?>"> <td colspan="<?=Users::has_avatars_enabled() ? 2 : 1?>">
<span style="float:left;"><a href='#quickreplypreview'>#XXXXXX</a> <span style="float:left;"><a href='#quickreplypreview'>#XXXXXX</a>
by <strong><?=Users::format_username($LoggedUser['ID'], true, true, true, true)?></strong> Just now by <strong><?=Users::format_username($LoggedUser['ID'], true, true, true, true)?></strong> Just now
<a href="#quickreplypreview">[Report Comment]</a> <a href="#quickreplypreview">[Report Comment]</a>
@ -897,13 +893,11 @@ function filelist($Str) {
</td> </td>
</tr> </tr>
<tr> <tr>
<? if (Users::has_avatars_enabled()) { ?>
<td class="avatar" valign="top"> <td class="avatar" valign="top">
<? if (!empty($LoggedUser['Avatar'])) { ?> <?=Users::show_avatar($LoggedUser['Avatar'], $LoggedUser['Username'], $HeavyInfo['DisableAvatars'])?>
<img src="<?=$LoggedUser['Avatar']?>" width="150" alt="<?=$LoggedUser['Username']?>'s avatar" />
<? } else { ?>
<img src="<?=STATIC_SERVER?>common/avatars/default.png" width="150" alt="Default avatar" />
<? } ?>
</td> </td>
<? } ?>
<td class="body" valign="top"> <td class="body" valign="top">
<div id="contentpreview" style="text-align:left;"></div> <div id="contentpreview" style="text-align:left;"></div>
</td> </td>

View File

@ -115,8 +115,8 @@ function checked($Checked) {
<td class="label"><strong>Torrent Grouping</strong></td> <td class="label"><strong>Torrent Grouping</strong></td>
<td> <td>
<select name="disablegrouping" id="disablegrouping"> <select name="disablegrouping" id="disablegrouping">
<option value="0"<? if ($SiteOptions['DisableGrouping'] == 0) { ?>selected="selected"<? } ?>>Group torrents by default</option> <option value="0"<? if ($SiteOptions['DisableGrouping2'] == 0) { ?>selected="selected"<? } ?>>Group torrents by default</option>
<option value="1"<? if ($SiteOptions['DisableGrouping'] == 1) { ?>selected="selected"<? } ?>>DO NOT Group torrents by default</option> <option value="1"<? if ($SiteOptions['DisableGrouping2'] == 1) { ?>selected="selected"<? } ?>>DO NOT Group torrents by default</option>
</select>&nbsp; </select>&nbsp;
<select name="torrentgrouping" id="torrentgrouping"> <select name="torrentgrouping" id="torrentgrouping">
<option value="0"<? if ($SiteOptions['TorrentGrouping'] == 0) { ?>selected="selected"<? } ?>>Groups are open by default</option> <option value="0"<? if ($SiteOptions['TorrentGrouping'] == 0) { ?>selected="selected"<? } ?>>Groups are open by default</option>
@ -266,8 +266,21 @@ function checked($Checked) {
<tr> <tr>
<td class="label"><strong>Avatars</strong></td> <td class="label"><strong>Avatars</strong></td>
<td> <td>
<input type="checkbox" name="disableavatars" id="disableavatars" <? if (!empty($SiteOptions['DisableAvatars'])) { ?>checked="checked"<? } ?> /> <select name="disableavatars" id="disableavatars" onclick="ToggleIdenticons();">
<label for="disableavatars">Disable avatars</label> <option value="1" <? if($SiteOptions['DisableAvatars'] == 1) { ?> selected="selected" <? } ?>/>Disable avatars</option>
<option value="0" <? if($SiteOptions['DisableAvatars'] == 0) { ?> selected="selected" <? } ?>/>Show avatars</option>
<option value="2" <? if($SiteOptions['DisableAvatars'] == 2) { ?> selected="selected" <? } ?>/>Show avatars or:</option>
<option value="3" <? if($SiteOptions['DisableAvatars'] == 3) { ?> selected="selected" <? } ?>/>Replace all avatars with:</option>
</select>
<select name="identicons" id="identicons">
<option value="0" <? if($SiteOptions['Identicons'] == 0) { ?> selected="selected" <? } ?>/>Identicon</option>
<option value="1" <? if($SiteOptions['Identicons'] == 1) { ?> selected="selected" <? } ?>/>MonsterID</option>
<option value="2" <? if($SiteOptions['Identicons'] == 2) { ?> selected="selected" <? } ?>/>Wavatar</option>
<option value="3" <? if($SiteOptions['Identicons'] == 3) { ?> selected="selected" <? } ?>/>Retro</option>
<option value="4" <? if($SiteOptions['Identicons'] == 4) { ?> selected="selected" <? } ?>/>Robots 1</option>
<option value="5" <? if($SiteOptions['Identicons'] == 5) { ?> selected="selected" <? } ?>/>Robots 2</option>
<option value="6" <? if($SiteOptions['Identicons'] == 6) { ?> selected="selected" <? } ?>/>Robots 3</option>
</select>
</td> </td>
</tr> </tr>
<tr> <tr>

View File

@ -181,7 +181,7 @@
if(!empty($LoggedUser['DefaultSearch'])) { if(!empty($LoggedUser['DefaultSearch'])) {
$Options['DefaultSearch'] = $LoggedUser['DefaultSearch']; $Options['DefaultSearch'] = $LoggedUser['DefaultSearch'];
} }
$Options['DisableGrouping'] = (!empty($_POST['disablegrouping']) ? 1 : 0); $Options['DisableGrouping2'] = (!empty($_POST['disablegrouping']) ? 1 : 0);
$Options['TorrentGrouping'] = (!empty($_POST['torrentgrouping']) ? 1 : 0); $Options['TorrentGrouping'] = (!empty($_POST['torrentgrouping']) ? 1 : 0);
$Options['DiscogView'] = (!empty($_POST['discogview']) ? 1 : 0); $Options['DiscogView'] = (!empty($_POST['discogview']) ? 1 : 0);
$Options['PostsPerPage'] = (int) $_POST['postsperpage']; $Options['PostsPerPage'] = (int) $_POST['postsperpage'];
@ -190,7 +190,8 @@
$Options['ShowTags'] = (!empty($_POST['showtags']) ? 1 : 0); $Options['ShowTags'] = (!empty($_POST['showtags']) ? 1 : 0);
$Options['AutoSubscribe'] = (!empty($_POST['autosubscribe']) ? 1 : 0); $Options['AutoSubscribe'] = (!empty($_POST['autosubscribe']) ? 1 : 0);
$Options['DisableSmileys'] = (!empty($_POST['disablesmileys']) ? 1 : 0); $Options['DisableSmileys'] = (!empty($_POST['disablesmileys']) ? 1 : 0);
$Options['DisableAvatars'] = (!empty($_POST['disableavatars']) ? 1 : 0); $Options['DisableAvatars'] = db_string($_POST['disableavatars']);
$Options['Identicons'] = (!empty($_POST['identicons']) ? (int) $_POST['identicons'] : 0);
$Options['DisablePMAvatars'] = (!empty($_POST['disablepmavatars']) ? 1 : 0); $Options['DisablePMAvatars'] = (!empty($_POST['disablepmavatars']) ? 1 : 0);
$Options['NotifyOnQuote'] = (!empty($_POST['notifyquotes']) ? 1 : 0); $Options['NotifyOnQuote'] = (!empty($_POST['notifyquotes']) ? 1 : 0);
$Options['ShowSnatched'] = (!empty($_POST['showsnatched']) ? 1 : 0); $Options['ShowSnatched'] = (!empty($_POST['showsnatched']) ? 1 : 0);

View File

@ -145,3 +145,14 @@ function ToggleWarningAdjust(selector) {
$('#ReduceWarning').raw().disabled = true; $('#ReduceWarning').raw().disabled = true;
} }
} }
addDOMLoadEvent(ToggleIdenticons);
function ToggleIdenticons() {
var selected = $('#disableavatars').raw().selectedIndex;
if(selected == 2 || selected == 3) {
$('#identicons').show();
}
else {
$('#identicons').hide();
}
}

View File

@ -0,0 +1 @@
@import url('https://whatimg.com/htrd/darkmono2/darkmono2.css');

View File

@ -190,7 +190,7 @@ div#AddArtists a {
z-index: 25; z-index: 25;
display: block; display: block;
position: fixed; position: fixed;
background: transparent no-repeat bottom background: transparent url('../rippy/rippy_halloween_1.png') no-repeat bottom
center; center;
color: black; color: black;
text-align: center; text-align: center;

View File

@ -767,7 +767,8 @@ tr.group td,
tr.torrent td { tr.torrent td {
color: #646054; color: #646054;
} }
.torrent_table.grouping tr.torrent { .torrent_table.grouping tr.torrent,
.torrent_table.no_grouping tr.torrent {
background-color:#EFEFEF; background-color:#EFEFEF;
} }