- This tree has =$Count?> entries, =$Branches?> branches, and a depth of =$MaxTreeLevel - $OriginalTreeLevel?>.
+ This tree has =number_format($Count)?> entries, =number_format($Branches)?> branches, and a depth of =number_format($MaxTreeLevel - $OriginalTreeLevel)?>.
It has
$ClassStrings = array();
@@ -208,10 +211,10 @@ function make_tree() {
echo 'The total amount uploaded by direct invitees (the top level) was '.Format::get_size($TopLevelUpload);
echo '; the total amount downloaded was '.Format::get_size($TopLevelDownload);
echo '; and the total ratio is '.Format::get_ratio_html($TopLevelUpload, $TopLevelDownload).'. ';
-
-
+
+
echo 'These numbers include the stats of paranoid users and will be factored into the invitation giving script.
';
-
+
if ($ParanoidCount) {
echo '
';
echo $ParanoidCount;
diff --git a/classes/class_misc.php b/classes/class_misc.php
index 12c6d132..478b7b2c 100644
--- a/classes/class_misc.php
+++ b/classes/class_misc.php
@@ -72,21 +72,30 @@ public static function send_pm($ToID,$FromID,$Subject,$Body,$ConvID='') {
WHERE UserID IN (".implode(',', $ToID).")
AND ConvID='$ConvID'");
- $DB->query("UPDATE pm_conversations_users SET
+ $DB->query("
+ UPDATE pm_conversations_users
+ SET
InSentbox='1',
SentDate='".sqltime()."'
- WHERE UserID='$FromID'
+ WHERE UserID='$FromID'
AND ConvID='$ConvID'");
}
// Now that we have a $ConvID for sure, send the message.
- $DB->query("INSERT INTO pm_messages
- (SenderID, ConvID, SentDate, Body) VALUES
- ('$FromID', '$ConvID', '".sqltime()."', '".$Body."')");
+ $DB->query("
+ INSERT INTO pm_messages
+ (SenderID, ConvID, SentDate, Body)
+ VALUES
+ ('$FromID', '$ConvID', '".sqltime()."', '$Body')");
// Update the cached new message count.
foreach ($ToID as $ID) {
- $DB->query("SELECT COUNT(ConvID) FROM pm_conversations_users WHERE UnRead = '1' and UserID='$ID' AND InInbox = '1'");
+ $DB->query("
+ SELECT COUNT(ConvID)
+ FROM pm_conversations_users
+ WHERE UnRead = '1'
+ AND UserID='$ID'
+ AND InInbox = '1'");
list($UnRead) = $DB->next_record();
$Cache->cache_value('inbox_new_'.$ID, $UnRead);
}
@@ -94,15 +103,20 @@ public static function send_pm($ToID,$FromID,$Subject,$Body,$ConvID='') {
$DB->query("SELECT Username FROM users_main WHERE ID = '$FromID'");
list($SenderName) = $DB->next_record();
foreach ($ToID as $ID) {
- $DB->query("SELECT COUNT(ConvID) FROM pm_conversations_users WHERE UnRead = '1' and UserID='$ID' AND InInbox = '1'");
+ $DB->query("
+ SELECT COUNT(ConvID)
+ FROM pm_conversations_users
+ WHERE UnRead = '1'
+ AND UserID='$ID'
+ AND InInbox = '1'");
list($UnRead) = $DB->next_record();
$Cache->cache_value('inbox_new_'.$ID, $UnRead);
-
+
}
return $ConvID;
}
-
+
/**
* Create thread function, things should already be escaped when sent here.
@@ -129,34 +143,40 @@ public static function create_thread($ForumID, $AuthorID, $Title, $PostBody) {
$ThreadInfo['IsLocked'] = 0;
$ThreadInfo['IsSticky'] = 0;
- $DB->query("INSERT INTO forums_topics
- (Title, AuthorID, ForumID, LastPostTime, LastPostAuthorID)
- Values
- ('".$Title."', '".$AuthorID."', '$ForumID', '".sqltime()."', '".$AuthorID."')");
+ $DB->query("
+ INSERT INTO forums_topics
+ (Title, AuthorID, ForumID, LastPostTime, LastPostAuthorID)
+ VALUES
+ ('$Title', '$AuthorID', '$ForumID', '".sqltime()."', '$AuthorID')");
$TopicID = $DB->inserted_id();
$Posts = 1;
- $DB->query("INSERT INTO forums_posts
+ $DB->query("
+ INSERT INTO forums_posts
(TopicID, AuthorID, AddedTime, Body)
- VALUES
- ('$TopicID', '".$AuthorID."', '".sqltime()."', '".$PostBody."')");
+ VALUES
+ ('$TopicID', '$AuthorID', '".sqltime()."', '$PostBody')");
$PostID = $DB->inserted_id();
- $DB->query("UPDATE forums SET
- NumPosts = NumPosts+1,
- NumTopics = NumTopics+1,
- LastPostID = '$PostID',
- LastPostAuthorID = '".$AuthorID."',
- LastPostTopicID = '$TopicID',
- LastPostTime = '".sqltime()."'
- WHERE ID = '$ForumID'");
+ $DB->query("
+ UPDATE forums
+ SET
+ NumPosts = NumPosts+1,
+ NumTopics = NumTopics+1,
+ LastPostID = '$PostID',
+ LastPostAuthorID = '$AuthorID',
+ LastPostTopicID = '$TopicID',
+ LastPostTime = '".sqltime()."'
+ WHERE ID = '$ForumID'");
- $DB->query("UPDATE forums_topics SET
+ $DB->query("
+ UPDATE forums_topics
+ SET
NumPosts = NumPosts+1,
LastPostID = '$PostID',
- LastPostAuthorID = '".$AuthorID."',
+ LastPostAuthorID = '$AuthorID',
LastPostTime = '".sqltime()."'
- WHERE ID = '$TopicID'");
+ WHERE ID = '$TopicID'");
// Bump this topic to head of the cache
list($Forum,,,$Stickies) = $Cache->get_value('forums_'.$ForumID);
@@ -164,12 +184,14 @@ public static function create_thread($ForumID, $AuthorID, $Title, $PostBody) {
if (count($Forum) == TOPICS_PER_PAGE && $Stickies < TOPICS_PER_PAGE) {
array_pop($Forum);
}
- $DB->query("SELECT f.IsLocked, f.IsSticky, f.NumPosts FROM forums_topics AS f
+ $DB->query("
+ SELECT f.IsLocked, f.IsSticky, f.NumPosts
+ FROM forums_topics AS f
WHERE f.ID ='$TopicID'");
- list($IsLocked,$IsSticky,$NumPosts) = $DB->next_record();
- $Part1 = array_slice($Forum,0,$Stickies,true); //Stickys
+ list($IsLocked, $IsSticky, $NumPosts) = $DB->next_record();
+ $Part1 = array_slice($Forum, 0, $Stickies, true); //Stickys
$Part2 = array(
- $TopicID=>array(
+ $TopicID => array(
'ID' => $TopicID,
'Title' => $Title,
'AuthorID' => $AuthorID,
@@ -181,10 +203,10 @@ public static function create_thread($ForumID, $AuthorID, $Title, $PostBody) {
'LastPostAuthorID' => $AuthorID,
)
); //Bumped thread
- $Part3 = array_slice($Forum,$Stickies,TOPICS_PER_PAGE,true); //Rest of page
+ $Part3 = array_slice($Forum, $Stickies, TOPICS_PER_PAGE, true); //Rest of page
if ($Stickies > 0) {
- $Part1 = array_slice($Forum,0,$Stickies,true); //Stickies
- $Part3 = array_slice($Forum,$Stickies,TOPICS_PER_PAGE-$Stickies-1,true); //Rest of page
+ $Part1 = array_slice($Forum, 0, $Stickies, true); //Stickies
+ $Part3 = array_slice($Forum, $Stickies, TOPICS_PER_PAGE - $Stickies - 1, true); //Rest of page
} else {
$Part1 = array();
$Part3 = $Forum;
@@ -192,7 +214,7 @@ public static function create_thread($ForumID, $AuthorID, $Title, $PostBody) {
if (is_null($Part1)) { $Part1 = array(); }
if (is_null($Part3)) { $Part3 = array(); }
$Forum = $Part1 + $Part2 + $Part3;
- $Cache->cache_value('forums_'.$ForumID, array($Forum,'',0,$Stickies), 0);
+ $Cache->cache_value('forums_'.$ForumID, array($Forum, '', 0, $Stickies), 0);
}
//Update the forum root
@@ -209,12 +231,12 @@ public static function create_thread($ForumID, $AuthorID, $Title, $PostBody) {
'IsSticky'=>$ThreadInfo['IsSticky']
);
- $UpdateArray['NumTopics']='+1';
+ $UpdateArray['NumTopics'] = '+1';
$Cache->update_row($ForumID, $UpdateArray);
$Cache->commit_transaction(0);
- $CatalogueID = floor((POSTS_PER_PAGE*ceil($Posts/POSTS_PER_PAGE)-POSTS_PER_PAGE)/THREAD_CATALOGUE);
+ $CatalogueID = floor((POSTS_PER_PAGE * ceil($Posts / POSTS_PER_PAGE) - POSTS_PER_PAGE) / THREAD_CATALOGUE);
$Cache->begin_transaction('thread_'.$TopicID.'_catalogue_'.$CatalogueID);
$Post = array(
'ID'=>$PostID,
@@ -271,7 +293,7 @@ public static function in_array_partial($Needle, $Haystack) {
}
foreach ($Haystack as $String) {
if (substr($String, -1) == '*') {
- if (!strncmp($Needle, $String, strlen($String)-1)) {
+ if (!strncmp($Needle, $String, strlen($String) - 1)) {
$Searches[$Needle] = true;
return true;
}
@@ -293,7 +315,7 @@ public static function in_array_partial($Needle, $Haystack) {
* @param boolean $AllowEmpty If set to true, a key that is in the request but blank will not throw an error.
* @param int $Error The error code to throw if one of the keys isn't in the array.
*/
- public static function assert_isset_request($Request, $Keys=NULL, $AllowEmpty = False, $Error=0) {
+ public static function assert_isset_request($Request, $Keys = NULL, $AllowEmpty = False, $Error = 0) {
if (isset($Keys)) {
foreach ($Keys as $K) {
if (!isset($Request[$K]) || ($AllowEmpty == False && $Request[$K] == '')) {
@@ -329,7 +351,10 @@ public static function get_tags($TagNames) {
}
}
if (count($TagNames) > 0) {
- $DB->query("SELECT ID, Name FROM tags WHERE Name IN ('".implode("', '", $TagNames)."')");
+ $DB->query("
+ SELECT ID, Name
+ FROM tags
+ WHERE Name IN ('".implode("', '", $TagNames)."')");
$SQLTagIDs = $DB->to_array();
foreach ($SQLTagIDs as $Tag) {
$TagIDs[$Tag['ID']] = $Tag['Name'];
@@ -348,13 +373,13 @@ public static function get_tags($TagNames) {
* @return string The aliased tag.
*/
public static function get_alias_tag($BadTag) {
- global $DB;
- $DB->query("SELECT AliasTag FROM tag_aliases WHERE BadTag = '". $BadTag ."' LIMIT 1");
- if ($DB->record_count() > 0) {
- list($AliasTag) = $DB->next_record();
- return $AliasTag;
- }
- return $BadTag;
+ global $DB;
+ $DB->query("SELECT AliasTag FROM tag_aliases WHERE BadTag = '". $BadTag ."' LIMIT 1");
+ if ($DB->record_count() > 0) {
+ list($AliasTag) = $DB->next_record();
+ return $AliasTag;
+ }
+ return $BadTag;
}
@@ -365,8 +390,9 @@ public static function get_alias_tag($BadTag) {
*/
public static function write_log($Message) {
global $DB,$Time;
- $DB->query('INSERT INTO log (Message, Time) VALUES (\''
- .db_string($Message).'\', \''.sqltime().'\')');
+ $DB->query("
+ INSERT INTO log (Message, Time)
+ VALUES ('" . db_string($Message) . "', '" . sqltime() . "')");
}
@@ -417,10 +443,10 @@ public static function is_new_torrent(&$Data) {
public static function display_recommend($ID, $Type, $Hide = true) {
global $DB, $LoggedUser;
if ($Hide) {
- $Hide = 'style="display: none;"';
+ $Hide = ' style="display: none;"';
}
?>
-
class="center">
+
class="center">
Recommend to:
-
+
}
}
?>
diff --git a/classes/class_text.php b/classes/class_text.php
index ae2da922..43fac825 100644
--- a/classes/class_text.php
+++ b/classes/class_text.php
@@ -831,7 +831,7 @@ private function to_html ($Array) {
}
break;
-
+
}
}
}
@@ -857,7 +857,7 @@ private function raw_text ($Array) {
case 'size':
case 'quote':
case 'align':
-
+
$Str.=$this->raw_text($Block['Val']);
break;
case 'tex': //since this will never strip cleanly, just remove it
diff --git a/classes/class_text2.php b/classes/class_text2.php
index 7dc4bbb7..27ffda6a 100644
--- a/classes/class_text2.php
+++ b/classes/class_text2.php
@@ -600,9 +600,8 @@ function to_html($Array) {
$Str.=''.$Block['Attr'].'';
}
}
-
break;
-
+
}
}
$this->Levels--;
@@ -626,7 +625,7 @@ function raw_text($Array) {
case 'size':
case 'quote':
case 'align':
-
+
$Str.=$this->raw_text($Block['Val']);
break;
case 'tex': //since this will never strip cleanly, just remove it
diff --git a/classes/class_text3.php b/classes/class_text3.php
index 862718a6..450b05ee 100644
--- a/classes/class_text3.php
+++ b/classes/class_text3.php
@@ -565,7 +565,7 @@ function to_html($Array) {
}
break;
-
+
}
}
$this->Levels--;
@@ -589,7 +589,7 @@ function raw_text($Array) {
case 'size':
case 'quote':
case 'align':
-
+
$Str.=$this->raw_text($Block['Val']);
break;
case 'tex': //since this will never strip cleanly, just remove it
diff --git a/classes/class_tools.php b/classes/class_tools.php
index fc60a952..3fe310a1 100644
--- a/classes/class_tools.php
+++ b/classes/class_tools.php
@@ -130,7 +130,7 @@ public static function lookup_ip($IP) {
public static function display_ip($IP) {
$Line = display_str($IP).' ('.Tools::get_country_code_by_ajax($IP).') ';
$Line .= 'S';
-
+
return $Line;
}
@@ -141,7 +141,7 @@ public static function get_country_code_by_ajax($IP) {
}
-
+
/**
* Disable an array of users.
@@ -161,7 +161,7 @@ public static function disable_users($UserIDs, $AdminComment, $BanReason = 1) {
m.can_leech='0',
i.AdminComment = CONCAT('".sqltime()." - ".($AdminComment ? $AdminComment : 'Disabled by system')."\n\n', i.AdminComment),
i.BanDate='".sqltime()."',
- i.BanReason='".$BanReason."',
+ i.BanReason='$BanReason',
i.RatioWatchDownload=".($BanReason == 2 ? 'm.Downloaded' : "'0'")."
WHERE m.ID IN(".implode(',',$UserIDs).") ");
$Cache->decrement('stats_user_count',$DB->affected_rows());
@@ -176,14 +176,14 @@ public static function disable_users($UserIDs, $AdminComment, $BanReason = 1) {
$Cache->delete_value('session_'.$UserID.'_'.$SessionID);
}
$Cache->delete_value('users_sessions_'.$UserID);
-
-
+
+
$DB->query("DELETE FROM users_sessions WHERE UserID='$UserID'");
-
+
}
// Remove the users from the tracker.
- $DB->query("SELECT torrent_pass FROM users_main WHERE ID in (".implode(", ",$UserIDs).")");
+ $DB->query("SELECT torrent_pass FROM users_main WHERE ID in (".implode(', ',$UserIDs).')');
$PassKeys = $DB->collect('torrent_pass');
$Concat = '';
foreach ($PassKeys as $PassKey) {
@@ -223,10 +223,12 @@ public static function warn_user($UserID, $Duration, $Reason) {
$AdminComment = date('Y-m-d').' - Warning (Clash) extended to expire at '.$NewExpDate.' by '.$LoggedUser['Username']."\nReason: $Reason\n\n";
- $DB->query('UPDATE users_info SET
- Warned=\''.db_string($NewExpDate).'\',
- WarnedTimes=WarnedTimes+1,
- AdminComment=CONCAT(\''.db_string($AdminComment).'\',AdminComment)
+ $DB->query('
+ UPDATE users_info
+ SET
+ Warned=\''.db_string($NewExpDate).'\',
+ WarnedTimes=WarnedTimes+1,
+ AdminComment=CONCAT(\''.db_string($AdminComment).'\',AdminComment)
WHERE UserID=\''.db_string($UserID).'\'');
} else {
//Not changing, user was not already warned
@@ -238,10 +240,12 @@ public static function warn_user($UserID, $Duration, $Reason) {
$AdminComment = date('Y-m-d').' - Warned until '.$WarnTime.' by '.$LoggedUser['Username']."\nReason: $Reason\n\n";
- $DB->query('UPDATE users_info SET
- Warned=\''.db_string($WarnTime).'\',
- WarnedTimes=WarnedTimes+1,
- AdminComment=CONCAT(\''.db_string($AdminComment).'\',AdminComment)
+ $DB->query('
+ UPDATE users_info
+ SET
+ Warned=\''.db_string($WarnTime).'\',
+ WarnedTimes=WarnedTimes+1,
+ AdminComment=CONCAT(\''.db_string($AdminComment).'\',AdminComment)
WHERE UserID=\''.db_string($UserID).'\'');
}
}
@@ -253,9 +257,10 @@ public static function warn_user($UserID, $Duration, $Reason) {
*/
public static function update_user_notes($UserID, $AdminComment) {
global $DB;
- $DB->query('UPDATE users_info SET
- AdminComment=CONCAT(\''.db_string($AdminComment).'\',AdminComment)
- WHERE UserID=\''.db_string($UserID).'\'');
+ $DB->query('
+ UPDATE users_info
+ SET AdminComment=CONCAT(\''.db_string($AdminComment).'\',AdminComment)
+ WHERE UserID=\''.db_string($UserID).'\'');
}
}
?>
diff --git a/classes/class_torrents.php b/classes/class_torrents.php
index b888459c..65fce62e 100644
--- a/classes/class_torrents.php
+++ b/classes/class_torrents.php
@@ -243,7 +243,7 @@ public static function delete_torrent($ID, $GroupID=0, $OcelotReason=-1) {
}
}
-
+
$DB->query("SELECT info_hash FROM torrents WHERE ID = ".$ID);
list($InfoHash) = $DB->next_record(MYSQLI_BOTH, false);
$DB->query("DELETE FROM torrents WHERE ID = ".$ID);
@@ -314,7 +314,7 @@ public static function delete_group($GroupID) {
}
$Cache->decrement('stats_group_count');
-
+
// Collages
$DB->query("SELECT CollageID FROM collages_torrents WHERE GroupID='$GroupID'");
diff --git a/classes/class_user_rank.php b/classes/class_user_rank.php
index fc4869f8..2d7e335a 100644
--- a/classes/class_user_rank.php
+++ b/classes/class_user_rank.php
@@ -48,10 +48,9 @@ function table_query($TableName) {
$Query = "SELECT COUNT(p.ID) AS Posts FROM users_main AS um JOIN forums_posts AS p ON p.AuthorID=um.ID WHERE um.Enabled='1' GROUP BY um.ID ORDER BY Posts;";
break;
case 'bounty':
-
-
+
$Query = "SELECT SUM(rv.Bounty) AS Bounty FROM users_main AS um JOIN requests_votes AS rv ON rv.UserID=um.ID WHERE um.Enabled='1' GROUP BY um.ID ORDER BY Bounty;";
-
+
break;
case 'artists':
$Query = "SELECT COUNT(ta.ArtistID) AS Artists FROM torrents_artists AS ta JOIN torrents_group AS tg ON tg.ID=ta.GroupID JOIN torrents AS t ON t.GroupID = tg.ID WHERE t.UserID != ta.UserID GROUP BY tg.ID ORDER BY Artists ASC";
diff --git a/classes/class_users.php b/classes/class_users.php
index cd79a949..fa3de6c6 100644
--- a/classes/class_users.php
+++ b/classes/class_users.php
@@ -16,7 +16,7 @@ public static function get_classes() {
$Cache->cache_value('classes', array($Classes, $ClassLevels), 0);
}
$Debug->set_flag('Loaded permissions');
-
+
return array($Classes, $ClassLevels);
}
@@ -47,30 +47,31 @@ public static function user_info($UserID) {
// the !isset($UserInfo['Paranoia']) can be removed after a transition period
if (empty($UserInfo) || empty($UserInfo['ID']) || !isset($UserInfo['Paranoia']) || empty($UserInfo['Class'])) {
$OldQueryID = $DB->get_query_id();
-
-
- $DB->query("SELECT
- m.ID,
- m.Username,
- m.PermissionID,
- m.Paranoia,
- i.Artist,
- i.Donor,
- i.Warned,
- i.Avatar,
- m.Enabled,
- m.Title,
- i.CatchupTime,
- m.Visible,
- GROUP_CONCAT(ul.PermissionID SEPARATOR ',') AS Levels
+
+
+ $DB->query("
+ SELECT
+ m.ID,
+ m.Username,
+ m.PermissionID,
+ m.Paranoia,
+ i.Artist,
+ i.Donor,
+ i.Warned,
+ i.Avatar,
+ m.Enabled,
+ m.Title,
+ i.CatchupTime,
+ m.Visible,
+ GROUP_CONCAT(ul.PermissionID SEPARATOR ',') AS Levels
FROM users_main AS m
- INNER JOIN users_info AS i ON i.UserID=m.ID
- LEFT JOIN users_levels AS ul ON ul.UserID = m.ID
+ INNER JOIN users_info AS i ON i.UserID=m.ID
+ LEFT JOIN users_levels AS ul ON ul.UserID = m.ID
WHERE m.ID='$UserID'
GROUP BY m.ID");
if ($DB->record_count() == 0) { // Deleted user, maybe?
$UserInfo = array('ID'=>'','Username'=>'','PermissionID'=>0,'Artist'=>false,'Donor'=>false,'Warned'=>'0000-00-00 00:00:00','Avatar'=>'','Enabled'=>0,'Title'=>'', 'CatchupTime'=>0, 'Visible'=>'1');
-
+
} else {
$UserInfo = $DB->next_record(MYSQLI_ASSOC, array('Paranoia', 'Title'));
$UserInfo['CatchupTime'] = strtotime($UserInfo['CatchupTime']);
@@ -118,39 +119,40 @@ public static function user_heavy_info($UserID) {
global $DB, $Cache;
$HeavyInfo = $Cache->get_value('user_info_heavy_'.$UserID);
-
+
if (empty($HeavyInfo)) {
-
- $DB->query("SELECT
- m.Invites,
- m.torrent_pass,
- m.IP,
- m.CustomPermissions,
- m.can_leech AS CanLeech,
- i.AuthKey,
- i.RatioWatchEnds,
- i.RatioWatchDownload,
- i.StyleID,
- i.StyleURL,
- i.DisableInvites,
- i.DisablePosting,
- i.DisableUpload,
- i.DisableWiki,
- i.DisableAvatar,
- i.DisablePM,
- i.DisableRequests,
- i.DisableForums,
- i.DisableTagging,
- i.SiteOptions,
- i.DownloadAlt,
- i.LastReadNews,
- i.LastReadBlog,
- i.RestrictedForums,
- i.PermittedForums,
- m.FLTokens,
- m.PermissionID
+
+ $DB->query("
+ SELECT
+ m.Invites,
+ m.torrent_pass,
+ m.IP,
+ m.CustomPermissions,
+ m.can_leech AS CanLeech,
+ i.AuthKey,
+ i.RatioWatchEnds,
+ i.RatioWatchDownload,
+ i.StyleID,
+ i.StyleURL,
+ i.DisableInvites,
+ i.DisablePosting,
+ i.DisableUpload,
+ i.DisableWiki,
+ i.DisableAvatar,
+ i.DisablePM,
+ i.DisableRequests,
+ i.DisableForums,
+ i.DisableTagging,
+ i.SiteOptions,
+ i.DownloadAlt,
+ i.LastReadNews,
+ i.LastReadBlog,
+ i.RestrictedForums,
+ i.PermittedForums,
+ m.FLTokens,
+ m.PermissionID
FROM users_main AS m
- INNER JOIN users_info AS i ON i.UserID=m.ID
+ INNER JOIN users_info AS i ON i.UserID=m.ID
WHERE m.ID='$UserID'");
$HeavyInfo = $DB->next_record(MYSQLI_ASSOC, array('CustomPermissions', 'SiteOptions'));
diff --git a/classes/script_start.php b/classes/script_start.php
index 76dbf34e..739189a9 100644
--- a/classes/script_start.php
+++ b/classes/script_start.php
@@ -11,7 +11,9 @@
/********************************************************/
require 'config.php'; //The config contains all site wide configuration information
//Deal with dumbasses
-if (isset($_REQUEST['info_hash']) && isset($_REQUEST['peer_id'])) { die('d14:failure reason40:Invalid .torrent, try downloading again.e'); }
+if (isset($_REQUEST['info_hash']) && isset($_REQUEST['peer_id'])) {
+ die('d14:failure reason40:Invalid .torrent, try downloading again.e');
+}
require(SERVER_ROOT.'/classes/class_proxies.php');
@@ -221,15 +223,16 @@
$UserSessions = $Cache->get_value('users_sessions_'.$UserID);
if (!is_array($UserSessions)) {
- $DB->query("SELECT
- SessionID,
- Browser,
- OperatingSystem,
- IP,
- LastUpdate
+ $DB->query("
+ SELECT
+ SessionID,
+ Browser,
+ OperatingSystem,
+ IP,
+ LastUpdate
FROM users_sessions
WHERE UserID='$UserID'
- AND Active = 1
+ AND Active = 1
ORDER BY LastUpdate DESC");
$UserSessions = $DB->to_array('SessionID',MYSQLI_ASSOC);
$Cache->cache_value('users_sessions_'.$UserID, $UserSessions, 0);
@@ -243,20 +246,21 @@
$Enabled = $Cache->get_value('enabled_'.$LoggedUser['ID']);
if ($Enabled === false) {
$DB->query("SELECT Enabled FROM users_main WHERE ID='$LoggedUser[ID]'");
- list($Enabled)=$DB->next_record();
+ list($Enabled) = $DB->next_record();
$Cache->cache_value('enabled_'.$LoggedUser['ID'], $Enabled, 0);
}
- if ($Enabled==2) {
-
+ if ($Enabled == 2) {
+
logout();
}
-
-
// Up/Down stats
$UserStats = $Cache->get_value('user_stats_'.$LoggedUser['ID']);
if (!is_array($UserStats)) {
- $DB->query("SELECT Uploaded AS BytesUploaded, Downloaded AS BytesDownloaded, RequiredRatio FROM users_main WHERE ID='$LoggedUser[ID]'");
+ $DB->query("
+ SELECT Uploaded AS BytesUploaded, Downloaded AS BytesDownloaded, RequiredRatio
+ FROM users_main
+ WHERE ID='$LoggedUser[ID]'");
$UserStats = $DB->next_record(MYSQLI_ASSOC);
$Cache->cache_value('user_stats_'.$LoggedUser['ID'], $UserStats, 3600);
}
@@ -273,11 +277,11 @@
$LoggedUser['RSS_Auth']=md5($LoggedUser['ID'].RSS_HASH.$LoggedUser['torrent_pass']);
- //$LoggedUser['RatioWatch'] as a bool to disable things for users on Ratio Watch
+ // $LoggedUser['RatioWatch'] as a bool to disable things for users on Ratio Watch
$LoggedUser['RatioWatch'] = (
$LoggedUser['RatioWatchEnds'] != '0000-00-00 00:00:00' &&
time() < strtotime($LoggedUser['RatioWatchEnds']) &&
- ($LoggedUser['BytesDownloaded']*$LoggedUser['RequiredRatio'])>$LoggedUser['BytesUploaded']
+ ($LoggedUser['BytesDownloaded'] * $LoggedUser['RequiredRatio']) > $LoggedUser['BytesUploaded']
);
if (!isset($LoggedUser['ID'])) {
$Debug->log_var($LightInfo, 'LightInfo');
@@ -286,19 +290,30 @@
$Debug->log_var($UserStats, 'UserStats');
}
- //Load in the permissions
+ // Load in the permissions
$LoggedUser['Permissions'] = Permissions::get_permissions_for_user($LoggedUser['ID'], $LoggedUser['CustomPermissions']);
- //Change necessary triggers in external components
+ // Change necessary triggers in external components
$Cache->CanClear = check_perms('admin_clear_cache');
// Because we <3 our staff
if (check_perms('site_disable_ip_history')) { $_SERVER['REMOTE_ADDR'] = '127.0.0.1'; }
// Update LastUpdate every 10 minutes
- if (strtotime($UserSessions[$SessionID]['LastUpdate'])+600
=$Text->full_format($Body)?>
-
+
next_record();
- list($Page,$Limit) = Format::page_limit(TORRENT_COMMENTS_PER_PAGE,$PostNum);
+ list($Page, $Limit) = Format::page_limit(TORRENT_COMMENTS_PER_PAGE, $PostNum);
} else {
- list($Page,$Limit) = Format::page_limit(TORRENT_COMMENTS_PER_PAGE,$Results);
+ list($Page, $Limit) = Format::page_limit(TORRENT_COMMENTS_PER_PAGE, $Results);
}
//Get the cache catalogue
@@ -937,12 +937,12 @@ function require(file, callback) {
WHERE c.ArtistID = '$ArtistID'
ORDER BY c.ID
LIMIT $CatalogueLimit");
- $Catalogue = $DB->to_array(false,MYSQLI_ASSOC);
+ $Catalogue = $DB->to_array(false, MYSQLI_ASSOC);
$Cache->cache_value('artist_comments_'.$ArtistID.'_catalogue_'.$CatalogueID, $Catalogue, 0);
}
//This is a hybrid to reduce the catalogue down to the page elements: We use the page limit % catalogue
-$Thread = array_slice($Catalogue,((TORRENT_COMMENTS_PER_PAGE * $Page - TORRENT_COMMENTS_PER_PAGE) % THREAD_CATALOGUE),TORRENT_COMMENTS_PER_PAGE,true);
+$Thread = array_slice($Catalogue, ((TORRENT_COMMENTS_PER_PAGE * $Page - TORRENT_COMMENTS_PER_PAGE) % THREAD_CATALOGUE), TORRENT_COMMENTS_PER_PAGE, true);
?>
-
+
/*
* THIS IS WHERE SEXY AJAX COMES IN
* The following malarky is needed so that if you get sent back here the fields are filled in
diff --git a/sections/reportsv2/static.php b/sections/reportsv2/static.php
index 768be64f..89b78bc9 100644
--- a/sections/reportsv2/static.php
+++ b/sections/reportsv2/static.php
@@ -122,69 +122,70 @@
-$DB->query("SELECT SQL_CALC_FOUND_ROWS
- r.ID,
- r.ReporterID,
- reporter.Username,
- r.TorrentID,
- r.Type,
- r.UserComment,
- r.ResolverID,
- resolver.Username,
- r.Status,
- r.ReportedTime,
- r.LastChangeTime,
- r.ModComment,
- r.Track,
- r.Image,
- r.ExtraID,
- r.Link,
- r.LogMessage,
- tg.Name,
- tg.ID,
- CASE COUNT(ta.GroupID)
- WHEN 1 THEN aa.ArtistID
- WHEN 0 THEN '0'
- ELSE '0'
- END AS ArtistID,
- CASE COUNT(ta.GroupID)
- WHEN 1 THEN aa.Name
- WHEN 0 THEN ''
- ELSE 'Various Artists'
- END AS ArtistName,
- tg.Year,
- tg.CategoryID,
- t.Time,
- t.Remastered,
- t.RemasterTitle,
- t.RemasterYear,
- t.Media,
- t.Format,
- t.Encoding,
- t.Size,
- t.HasCue,
- t.HasLog,
- t.LogScore,
- t.UserID AS UploaderID,
- uploader.Username
- FROM reportsv2 AS r
- LEFT JOIN torrents AS t ON t.ID=r.TorrentID
- LEFT JOIN torrents_group AS tg ON tg.ID=t.GroupID
- LEFT JOIN torrents_artists AS ta ON ta.GroupID=tg.ID AND ta.Importance='1'
- LEFT JOIN artists_alias AS aa ON aa.AliasID=ta.AliasID
- LEFT JOIN users_main AS resolver ON resolver.ID=r.ResolverID
- LEFT JOIN users_main AS reporter ON reporter.ID=r.ReporterID
- LEFT JOIN users_main AS uploader ON uploader.ID=t.UserID "
- .$Where."
- GROUP BY r.ID "
- .$Order."
- LIMIT ".$Limit);
+$DB->query("
+ SELECT SQL_CALC_FOUND_ROWS
+ r.ID,
+ r.ReporterID,
+ reporter.Username,
+ r.TorrentID,
+ r.Type,
+ r.UserComment,
+ r.ResolverID,
+ resolver.Username,
+ r.Status,
+ r.ReportedTime,
+ r.LastChangeTime,
+ r.ModComment,
+ r.Track,
+ r.Image,
+ r.ExtraID,
+ r.Link,
+ r.LogMessage,
+ tg.Name,
+ tg.ID,
+ CASE COUNT(ta.GroupID)
+ WHEN 1 THEN aa.ArtistID
+ WHEN 0 THEN '0'
+ ELSE '0'
+ END AS ArtistID,
+ CASE COUNT(ta.GroupID)
+ WHEN 1 THEN aa.Name
+ WHEN 0 THEN ''
+ ELSE 'Various Artists'
+ END AS ArtistName,
+ tg.Year,
+ tg.CategoryID,
+ t.Time,
+ t.Remastered,
+ t.RemasterTitle,
+ t.RemasterYear,
+ t.Media,
+ t.Format,
+ t.Encoding,
+ t.Size,
+ t.HasCue,
+ t.HasLog,
+ t.LogScore,
+ t.UserID AS UploaderID,
+ uploader.Username
+ FROM reportsv2 AS r
+ LEFT JOIN torrents AS t ON t.ID=r.TorrentID
+ LEFT JOIN torrents_group AS tg ON tg.ID=t.GroupID
+ LEFT JOIN torrents_artists AS ta ON ta.GroupID=tg.ID AND ta.Importance='1'
+ LEFT JOIN artists_alias AS aa ON aa.AliasID=ta.AliasID
+ LEFT JOIN users_main AS resolver ON resolver.ID=r.ResolverID
+ LEFT JOIN users_main AS reporter ON reporter.ID=r.ReporterID
+ LEFT JOIN users_main AS uploader ON uploader.ID=t.UserID
+ $Where
+ GROUP BY r.ID
+ $Order
+ LIMIT $Limit");
$Reports = $DB->to_array();
$DB->query('SELECT FOUND_ROWS()');
list($Results) = $DB->next_record();
-$PageLinks=Format::get_pages($Page,$Results,REPORTS_PER_PAGE,11);
+$PageLinks = Format::get_pages($Page, $Results, REPORTS_PER_PAGE, 11);
View::show_header('Reports V2!', 'reportsv2,bbcode');
@@ -222,19 +223,21 @@
} else {
foreach ($Reports as $Report) {
-
-
+
+
list($ReportID, $ReporterID, $ReporterName, $TorrentID, $Type, $UserComment, $ResolverID, $ResolverName, $Status, $ReportedTime, $LastChangeTime,
$ModComment, $Tracks, $Images, $ExtraIDs, $Links, $LogMessage, $GroupName, $GroupID, $ArtistID, $ArtistName, $Year, $CategoryID, $Time, $Remastered, $RemasterTitle,
$RemasterYear, $Media, $Format, $Encoding, $Size, $HasCue, $HasLog, $LogScore, $UploaderID, $UploaderName) = Misc::display_array($Report, array("ModComment"));
-
+
if (!$GroupID && $Status != 'Resolved') {
//Torrent already deleted
- $DB->query("UPDATE reportsv2 SET
- Status='Resolved',
- LastChangeTime='".sqltime()."',
- ModComment='Report already dealt with (torrent deleted)'
- WHERE ID=".$ReportID);
+ $DB->query("
+ UPDATE reportsv2
+ SET
+ Status='Resolved',
+ LastChangeTime='".sqltime()."',
+ ModComment='Report already dealt with (torrent deleted)'
+ WHERE ID=".$ReportID);
$Cache->decrement('num_torrent_reportsv2');
?>
@@ -406,41 +409,41 @@
$Extras = explode(' ', $ExtraIDs);
foreach ($Extras as $ExtraID) {
-
- $DB->query("SELECT
- tg.Name,
- tg.ID,
- CASE COUNT(ta.GroupID)
- WHEN 1 THEN aa.ArtistID
- WHEN 0 THEN '0'
- ELSE '0'
- END AS ArtistID,
- CASE COUNT(ta.GroupID)
- WHEN 1 THEN aa.Name
- WHEN 0 THEN ''
- ELSE 'Various Artists'
- END AS ArtistName,
- tg.Year,
- t.Time,
- t.Remastered,
- t.RemasterTitle,
- t.RemasterYear,
- t.Media,
- t.Format,
- t.Encoding,
- t.Size,
- t.HasCue,
- t.HasLog,
- t.LogScore,
- t.UserID AS UploaderID,
- uploader.Username
- FROM torrents AS t
- LEFT JOIN torrents_group AS tg ON tg.ID=t.GroupID
- LEFT JOIN torrents_artists AS ta ON ta.GroupID=tg.ID AND ta.Importance='1'
- LEFT JOIN artists_alias AS aa ON aa.AliasID=ta.AliasID
- LEFT JOIN users_main AS uploader ON uploader.ID=t.UserID
- WHERE t.ID='$ExtraID'
- GROUP BY tg.ID");
+ $DB->query("
+ SELECT
+ tg.Name,
+ tg.ID,
+ CASE COUNT(ta.GroupID)
+ WHEN 1 THEN aa.ArtistID
+ WHEN 0 THEN '0'
+ ELSE '0'
+ END AS ArtistID,
+ CASE COUNT(ta.GroupID)
+ WHEN 1 THEN aa.Name
+ WHEN 0 THEN ''
+ ELSE 'Various Artists'
+ END AS ArtistName,
+ tg.Year,
+ t.Time,
+ t.Remastered,
+ t.RemasterTitle,
+ t.RemasterYear,
+ t.Media,
+ t.Format,
+ t.Encoding,
+ t.Size,
+ t.HasCue,
+ t.HasLog,
+ t.LogScore,
+ t.UserID AS UploaderID,
+ uploader.Username
+ FROM torrents AS t
+ LEFT JOIN torrents_group AS tg ON tg.ID=t.GroupID
+ LEFT JOIN torrents_artists AS ta ON ta.GroupID=tg.ID AND ta.Importance='1'
+ LEFT JOIN artists_alias AS aa ON aa.AliasID=ta.AliasID
+ LEFT JOIN users_main AS uploader ON uploader.ID=t.UserID
+ WHERE t.ID='$ExtraID'
+ GROUP BY tg.ID");
list($ExtraGroupName, $ExtraGroupID, $ExtraArtistID, $ExtraArtistName, $ExtraYear, $ExtraTime, $ExtraRemastered, $ExtraRemasterTitle,
$ExtraRemasterYear, $ExtraMedia, $ExtraFormat, $ExtraEncoding, $ExtraSize, $ExtraHasCue, $ExtraHasLog, $ExtraLogScore, $ExtraUploaderID, $ExtraUploaderName) = Misc::display_array($DB->next_record());
diff --git a/sections/requests/takevote.php b/sections/requests/takevote.php
index 7cfb057a..12eb6878 100644
--- a/sections/requests/takevote.php
+++ b/sections/requests/takevote.php
@@ -62,7 +62,7 @@
// Subtract amount from user
$DB->query("UPDATE users_main SET Uploaded = (Uploaded - $Amount) WHERE ID = ".$LoggedUser['ID']);
$Cache->delete_value('user_stats_'.$LoggedUser['ID']);
-
+
Requests::update_sphinx_requests($RequestID);
echo 'success';
} elseif ($LoggedUser['BytesUploaded'] < $Amount) {
diff --git a/sections/rules/upload.php b/sections/rules/upload.php
index e46a9e74..0ac6fd75 100644
--- a/sections/rules/upload.php
+++ b/sections/rules/upload.php
@@ -361,7 +361,7 @@
- Note: The "Year" tag is optional, but strongly encouraged. However, if missing or incorrect, this is not grounds for trumping a torrent.
+ Note: The "Year" tag is optional but strongly encouraged. However, if missing or incorrect, this is not grounds for trumping a torrent.
↑_2.3.17.The torrent artist for classical works should use the full composer name. Before uploading see this wiki for guidelines on uploading classical music torrents. Also, consult this wiki for a full explanation of the classical music tagging system.
↑_2.3.18.Newly re-tagged torrents trumping badly tagged torrents must reflect a substantial improvement over the previous tags. Small changes that include replacing ASCII characters with proper foreign language characters with diacritical marks, fixing slight misspellings, or missing an alternate spelling of an artist (e.g., excluding "The" before a band name) are insufficient grounds for replacing other torrents. Artist names that are misspelled in the tags are grounds for trumping; this includes character accents and characters that mean one letter in one language and a different letter in another language. Improper capitalization in the tags is grounds for trumping; this includes artist tags (or composer tags) that contain names that are all capitalized or track titles that are all capitalized. Tags with multiple entries in the same tag (e.g., track number and track title in the track title tags; or track number, artist, and track title in the artist tags) are subject to trumping. You may trump a release if the tags do not follow the data from a reputable music cataloguing service such as MusicBrainz or Discogs. In the case of a conflict between reputable listings, either tagged version is equally preferred on the site and cannot trump the other. For example, an album is tagged differently in MusicBrainz and in Discogs. Either style of tagging is permitted; neither is "better" than the other. In that case, any newly tagged torrents replacing an already properly tagged torrent, which follows good tagging convention, will result in a dupe. Note: For classical music, please follow these tagging guidelines.
diff --git a/sections/schedule/index.php b/sections/schedule/index.php
index 4a902229..5b526678 100644
--- a/sections/schedule/index.php
+++ b/sections/schedule/index.php
@@ -302,7 +302,7 @@ function next_hour() {
$AgoMins = time_minus(60 * 30);
$AgoDays = time_minus(3600 * 24 * 30);
-
+
$SessionQuery = $DB->query("SELECT UserID, SessionID
FROM users_sessions
@@ -316,7 +316,7 @@ function next_hour() {
$Cache->commit_transaction(0);
}
-
+
//------------- Lower Login Attempts ------------------------------------//
$DB->query("UPDATE login_attempts SET Attempts=Attempts-1 WHERE Attempts>0");
$DB->query("DELETE FROM login_attempts WHERE LastAttempt<'".time_minus(3600 * 24 * 90)."'");
@@ -593,7 +593,7 @@ function next_hour() {
i.AdminComment=CONCAT('$sqltime - Leeching ability disabled by ratio watch system - required ratio: ', m.RequiredRatio,'', i.AdminComment)
WHERE m.ID IN(".implode(',',$UserIDs).")");
-
+
$DB->query("DELETE FROM users_torrent_history WHERE UserID IN (".implode(',',$UserIDs).")");
}
@@ -770,7 +770,7 @@ function next_hour() {
// Exceptions for inactivity deletion
$InactivityExceptionsMade = array(//UserID => expiry time of exception
-
+
);
foreach ($TorrentIDs as $TorrentID) {
list($ID, $GroupID, $Name, $ArtistName, $LastAction, $Format, $Encoding, $UserID, $Media, $InfoHash) = $TorrentID;
@@ -821,7 +821,7 @@ function next_hour() {
$DB->query("DELETE FROM artists_similar_votes WHERE SimilarID IN($SimilarIDs)");
}
-
+
// Daily top 10 history.
$DB->query("INSERT INTO top10_history (Date, Type) VALUES ('".$sqltime."', 'Daily')");
diff --git a/sections/staffpm/assign.php b/sections/staffpm/assign.php
index 0306fcd8..374b9ab6 100644
--- a/sections/staffpm/assign.php
+++ b/sections/staffpm/assign.php
@@ -70,7 +70,7 @@
AssignedToUser=$NewLevel,
Level=$Level
WHERE ID=$ConvID");
-
+
}
echo '1';
diff --git a/sections/staffpm/takepost.php b/sections/staffpm/takepost.php
index bb6e3867..49d6657d 100644
--- a/sections/staffpm/takepost.php
+++ b/sections/staffpm/takepost.php
@@ -1,7 +1,7 @@
if ($Message = db_string($_POST['message'])) {
if ($Subject = db_string($_POST['subject'])) {
- // New staff pm conversation
+ // New staff PM conversation
$Level = db_string($_POST['level']);
$DB->query("
INSERT INTO staff_pm_conversations
@@ -25,8 +25,6 @@
// Check if conversation belongs to user
$DB->query("SELECT UserID, AssignedToUser FROM staff_pm_conversations WHERE ID=$ConvID");
list($UserID, $AssignedToUser) = $DB->next_record();
-
-
if ($UserID == $LoggedUser['ID'] || $IsFLS || $UserID == $AssignedToUser) {
// Response to existing conversation
@@ -40,11 +38,17 @@
// Update conversation
if ($IsFLS) {
// FLS/Staff
- $DB->query("UPDATE staff_pm_conversations SET Date='".sqltime()."', Unread=true, Status='Open' WHERE ID=$ConvID");
+ $DB->query("
+ UPDATE staff_pm_conversations
+ SET Date='".sqltime()."', Unread=true, Status='Open'
+ WHERE ID=$ConvID");
$Cache->delete_value('num_staff_pms_'.$LoggedUser['ID']);
} else {
// User
- $DB->query("UPDATE staff_pm_conversations SET Date='".sqltime()."', Unread=true, Status='Unanswered' WHERE ID=$ConvID");
+ $DB->query("
+ UPDATE staff_pm_conversations
+ SET Date='".sqltime()."', Unread=true, Status='Unanswered'
+ WHERE ID=$ConvID");
}
// Clear cache for user
@@ -56,18 +60,17 @@
// User is trying to respond to conversation that does no belong to them
error(403);
}
-
} else {
- // Message but no subject or conversation id
+ // Message but no subject or conversation ID
header("Location: staffpm.php?action=viewconv&id=$ConvID");
}
} elseif ($ConvID = (int)$_POST['convid']) {
- // No message, but conversation id
+ // No message, but conversation ID
header("Location: staffpm.php?action=viewconv&id=$ConvID");
} else {
- // No message or conversation id
+ // No message or conversation ID
header('Location: staffpm.php');
}
diff --git a/sections/stats/users.php b/sections/stats/users.php
index d6bbb134..8caf71e2 100644
--- a/sections/stats/users.php
+++ b/sections/stats/users.php
@@ -59,14 +59,14 @@
}
if (!$PlatformDistribution = $Cache->get_value('platform_distribution')) {
include_once(SERVER_ROOT.'/classes/class_charts.php');
-
-
+
+
$DB->query("
SELECT OperatingSystem, COUNT(UserID) AS Users
FROM users_sessions
GROUP BY OperatingSystem
ORDER BY Users DESC");
-
+
$Platforms = $DB->to_array();
$Pie = new PIE_CHART(750,400,array('Other'=>1,'Percentage'=>1));
foreach ($Platforms as $Platform) {
@@ -82,7 +82,7 @@
if (!$BrowserDistribution = $Cache->get_value('browser_distribution')) {
include_once(SERVER_ROOT.'/classes/class_charts.php');
-
+
$DB->query("
SELECT Browser, COUNT(UserID) AS Users
diff --git a/sections/tools/index.php b/sections/tools/index.php
index 26768799..860c301c 100644
--- a/sections/tools/index.php
+++ b/sections/tools/index.php
@@ -163,7 +163,7 @@
$DB->query("INSERT INTO news (UserID, Title, Body, Time)
VALUES ('$LoggedUser[ID]', '".db_string($_POST['title'])."', '".db_string($_POST['body'])."', '".sqltime()."')");
-
+
$Cache->cache_value('news_latest_id', $DB->inserted_id(), 0);
$Cache->delete_value('news');
diff --git a/sections/tools/tools.php b/sections/tools/tools.php
index ece44b85..8361ebbe 100644
--- a/sections/tools/tools.php
+++ b/sections/tools/tools.php
@@ -51,7 +51,7 @@
- This has =number_format($UpVotes)?> =(($UpVotes==1) ? 'upvote' : 'upvotes')?> out of =number_format($TotalVotes)?> total>, including your upvote>, including your downvote.
+ This has =number_format($UpVotes)?> =(($UpVotes == 1) ? 'upvote' : 'upvotes')?> out of =number_format($TotalVotes)?> total>, including your upvote>, including your downvote.
if (check_perms('site_album_votes')) { ?>
id="vote_message">Upvote - Downvote
diff --git a/sections/upload/insert_extra_torrents.php b/sections/upload/insert_extra_torrents.php
index 6d3f25c2..f12efdec 100644
--- a/sections/upload/insert_extra_torrents.php
+++ b/sections/upload/insert_extra_torrents.php
@@ -22,7 +22,7 @@
Tracker::update_tracker('add_torrent', array('id' => $ExtraTorrentID, 'info_hash' => rawurlencode($ExtraTorrent['InfoHash']), 'freetorrent' => $T['FreeLeech']));
-
+
//******************************************************************************//
//--------------- Write torrent file -------------------------------------------//
diff --git a/sections/user/advancedsearch.php b/sections/user/advancedsearch.php
index 67f4ab22..ec84d11a 100644
--- a/sections/user/advancedsearch.php
+++ b/sections/user/advancedsearch.php
@@ -195,27 +195,30 @@ function num_compare($Field, $Operand, $Num1, $Num2 = '') {
$Order = '';
- $SQL = 'SQL_CALC_FOUND_ROWS
- um1.ID,
- um1.Username,
- um1.Uploaded,
- um1.Downloaded,';
+ $SQL = '
+ SQL_CALC_FOUND_ROWS
+ um1.ID,
+ um1.Username,
+ um1.Uploaded,
+ um1.Downloaded,';
if ($_GET['snatched'] == "off") {
$SQL .= "'X' AS Snatches,";
} else {
$SQL .= "(SELECT COUNT(uid) FROM xbt_snatched AS xs WHERE xs.uid=um1.ID) AS Snatches,";
}
- $SQL .= 'um1.PermissionID,
- um1.Email,
- um1.Enabled,
- um1.IP,
- um1.Invites,
- ui1.DisableInvites,
- ui1.Warned,
- ui1.Donor,
- ui1.JoinDate,
- um1.LastAccess
- FROM users_main AS um1 JOIN users_info AS ui1 ON ui1.UserID=um1.ID ';
+ $SQL .= '
+ um1.PermissionID,
+ um1.Email,
+ um1.Enabled,
+ um1.IP,
+ um1.Invites,
+ ui1.DisableInvites,
+ ui1.Warned,
+ ui1.Donor,
+ ui1.JoinDate,
+ um1.LastAccess
+ FROM users_main AS um1
+ JOIN users_info AS ui1 ON ui1.UserID=um1.ID ';
if (!empty($_GET['username'])) {
@@ -225,17 +228,19 @@ function num_compare($Field, $Operand, $Num1, $Num2 = '') {
if (!empty($_GET['email'])) {
if (isset($_GET['email_history'])) {
$Distinct = 'DISTINCT ';
- $Join['he']=' JOIN users_history_emails AS he ON he.UserID=um1.ID ';
- $Where[]= ' he.Email '.$Match.wrap($_GET['email']);
-
+ $Join['he'] = ' JOIN users_history_emails AS he ON he.UserID=um1.ID ';
+ $Where[] = ' he.Email '.$Match.wrap($_GET['email']);
} else {
- $Where[]='um1.Email'.$Match.wrap($_GET['email']);
+ $Where[] = 'um1.Email'.$Match.wrap($_GET['email']);
}
}
-
if (!empty($_GET['email_cnt']) && is_number($_GET['email_cnt'])) {
- $Query = "SELECT UserID FROM users_history_emails GROUP BY UserID HAVING COUNT(DISTINCT Email) ";
+ $Query = "
+ SELECT UserID
+ FROM users_history_emails
+ GROUP BY UserID
+ HAVING COUNT(DISTINCT Email) ";
if ($_GET['emails_opt'] === 'equal') {
$operator = '=';
}
@@ -249,7 +254,7 @@ function num_compare($Field, $Operand, $Num1, $Num2 = '') {
$DB->query($Query);
$Users = implode(',', $DB->collect('UserID'));
if (!empty($Users)) {
- $Where[] = "um1.ID IN (".$Users.")";
+ $Where[] = "um1.ID IN ($Users)";
}
}
@@ -257,37 +262,35 @@ function num_compare($Field, $Operand, $Num1, $Num2 = '') {
if (!empty($_GET['ip'])) {
if (isset($_GET['ip_history'])) {
$Distinct = 'DISTINCT ';
- $Join['hi']=' JOIN users_history_ips AS hi ON hi.UserID=um1.ID ';
- $Where[]= ' hi.IP '.$Match.wrap($_GET['ip'], '', true);
-
+ $Join['hi'] = ' JOIN users_history_ips AS hi ON hi.UserID=um1.ID ';
+ $Where[] = ' hi.IP '.$Match.wrap($_GET['ip'], '', true);
} else {
- $Where[]='um1.IP'.$Match.wrap($_GET['ip'], '', true);
+ $Where[] = 'um1.IP'.$Match.wrap($_GET['ip'], '', true);
}
}
-
if (!empty($_GET['cc'])) {
if ($_GET['cc_op'] == "equal") {
- $Where[]="um1.ipcc = '".db_string($_GET['cc'])."'";
+ $Where[] = "um1.ipcc = '".db_string($_GET['cc'])."'";
} else {
- $Where[]="um1.ipcc != '".db_string($_GET['cc'])."'";
+ $Where[] = "um1.ipcc != '".db_string($_GET['cc'])."'";
}
}
if (!empty($_GET['tracker_ip'])) {
$Distinct = 'DISTINCT ';
- $Join['xfu']=' JOIN xbt_files_users AS xfu ON um1.ID=xfu.uid ';
- $Where[]= ' xfu.ip '.$Match.wrap($_GET['tracker_ip'], '', true);
+ $Join['xfu'] = ' JOIN xbt_files_users AS xfu ON um1.ID=xfu.uid ';
+ $Where[] = ' xfu.ip '.$Match.wrap($_GET['tracker_ip'], '', true);
}
// if (!empty($_GET['tracker_ip'])) {
// $Distinct = 'DISTINCT ';
-// $Join['xs']=' JOIN xbt_snatched AS xs ON um1.ID=xs.uid ';
-// $Where[]= ' xs.IP '.$Match.wrap($_GET['ip']);
+// $Join['xs'] = ' JOIN xbt_snatched AS xs ON um1.ID=xs.uid ';
+// $Where[] = ' xs.IP '.$Match.wrap($_GET['ip']);
// }
if (!empty($_GET['comment'])) {
- $Where[]='ui1.AdminComment'.$Match.wrap($_GET['comment']);
+ $Where[] = 'ui1.AdminComment'.$Match.wrap($_GET['comment']);
}
if (!empty($_GET['lastfm'])) {
@@ -300,27 +303,27 @@ function num_compare($Field, $Operand, $Num1, $Num2 = '') {
if (strlen($_GET['invites1'])) {
$Invites1 = round($_GET['invites1']);
$Invites2 = round($_GET['invites2']);
- $Where[]=implode(' AND ', num_compare('Invites', $_GET['invites'], $Invites1, $Invites2));
+ $Where[] = implode(' AND ', num_compare('Invites', $_GET['invites'], $Invites1, $Invites2));
}
if ($_GET['disabled_invites'] == 'yes') {
- $Where[]='ui1.DisableInvites=\'1\'';
+ $Where[] = 'ui1.DisableInvites=\'1\'';
} elseif ($_GET['disabled_invites'] == 'no') {
- $Where[]='ui1.DisableInvites=\'0\'';
+ $Where[] = 'ui1.DisableInvites=\'0\'';
}
if ($_GET['disabled_uploads'] == 'yes') {
- $Where[]='ui1.DisableUpload=\'1\'';
+ $Where[] = 'ui1.DisableUpload=\'1\'';
} elseif ($_GET['disabled_uploads'] == 'no') {
- $Where[]='ui1.DisableUpload=\'0\'';
+ $Where[] = 'ui1.DisableUpload=\'0\'';
}
if ($_GET['join1']) {
- $Where[]=implode(' AND ', date_compare('ui1.JoinDate', $_GET['joined'], $_GET['join1'], $_GET['join2']));
+ $Where[] = implode(' AND ', date_compare('ui1.JoinDate', $_GET['joined'], $_GET['join1'], $_GET['join2']));
}
if ($_GET['lastactive1']) {
- $Where[]=implode(' AND ', date_compare('um1.LastAccess', $_GET['lastactive'], $_GET['lastactive1'], $_GET['lastactive2']));
+ $Where[] = implode(' AND ', date_compare('um1.LastAccess', $_GET['lastactive'], $_GET['lastactive1'], $_GET['lastactive2']));
}
if ($_GET['ratio1']) {
@@ -328,16 +331,16 @@ function num_compare($Field, $Operand, $Num1, $Num2 = '') {
if (!$Decimals) {
$Decimals = 0;
}
- $Where[]=implode(' AND ', num_compare("ROUND(Uploaded/Downloaded,$Decimals)", $_GET['ratio'], $_GET['ratio1'], $_GET['ratio2']));
+ $Where[] = implode(' AND ', num_compare("ROUND(Uploaded/Downloaded,$Decimals)", $_GET['ratio'], $_GET['ratio1'], $_GET['ratio2']));
}
if (strlen($_GET['uploaded1'])) {
$Upload1 = round($_GET['uploaded1']);
$Upload2 = round($_GET['uploaded2']);
- if ($_GET['uploaded']!='buffer') {
- $Where[]=implode(' AND ', num_compare('ROUND(Uploaded/1024/1024/1024)', $_GET['uploaded'], $Upload1, $Upload2));
+ if ($_GET['uploaded'] != 'buffer') {
+ $Where[] = implode(' AND ', num_compare('ROUND(Uploaded/1024/1024/1024)', $_GET['uploaded'], $Upload1, $Upload2));
} else {
- $Where[]=implode(' AND ', num_compare('ROUND((Uploaded/1024/1024/1024)-(Downloaded/1024/1024/1023))', 'between', $Upload1*0.9, $Upload1*1.1));
+ $Where[] = implode(' AND ', num_compare('ROUND((Uploaded/1024/1024/1024)-(Downloaded/1024/1024/1023))', 'between', $Upload1 * 0.9, $Upload1 * 1.1));
}
}
@@ -360,7 +363,6 @@ function num_compare($Field, $Operand, $Num1, $Num2 = '') {
if ($_GET['class'] != '') {
$Where[]='um1.PermissionID='.wrap($_GET['class'], '=');
}
-
if ($_GET['secclass'] != '') {
$Join['ul']=' JOIN users_levels AS ul ON um1.ID=ul.UserID ';
diff --git a/sections/user/community_stats.php b/sections/user/community_stats.php
index 0224bb47..02c20265 100644
--- a/sections/user/community_stats.php
+++ b/sections/user/community_stats.php
@@ -2,10 +2,11 @@
// These stats used to be all together in one UNION'd query
// But we broke them up because they had a habit of locking each other to death.
// They all run really quickly anyways.
-$DB->query("SELECT COUNT(x.uid), COUNT(DISTINCT x.fid)
- FROM xbt_snatched AS x
- INNER JOIN torrents AS t ON t.ID=x.fid
- WHERE x.uid='$UserID'");
+$DB->query("
+ SELECT COUNT(x.uid), COUNT(DISTINCT x.fid)
+ FROM xbt_snatched AS x
+ INNER JOIN torrents AS t ON t.ID=x.fid
+ WHERE x.uid='$UserID'");
list($Snatched, $UniqueSnatched) = $DB->next_record();
$DB->query("SELECT COUNT(ID) FROM torrents_comments WHERE AuthorID='$UserID'");
@@ -20,27 +21,30 @@
$DB->query("SELECT COUNT(ID) FROM collages WHERE Deleted='0' AND UserID='$UserID'");
list($NumCollages) = $DB->next_record();
-$DB->query("SELECT COUNT(DISTINCT CollageID)
- FROM collages_torrents AS ct
- JOIN collages ON CollageID = ID
- WHERE Deleted='0' AND ct.UserID='$UserID'");
+$DB->query("
+ SELECT COUNT(DISTINCT CollageID)
+ FROM collages_torrents AS ct
+ JOIN collages ON CollageID = ID
+ WHERE Deleted='0'
+ AND ct.UserID='$UserID'");
list($NumCollageContribs) = $DB->next_record();
$DB->query("SELECT COUNT(DISTINCT GroupID) FROM torrents WHERE UserID = '$UserID'");
list($UniqueGroups) = $DB->next_record();
-$DB->query("SELECT COUNT(ID)
- FROM torrents
- WHERE ((LogScore = 100 AND Format = 'FLAC')
- OR (Media = 'Vinyl' AND Format = 'FLAC')
- OR (Media = 'WEB' AND Format = 'FLAC')
- OR (Media = 'DVD' AND Format = 'FLAC')
- OR (Media = 'Soundboard' AND Format = 'FLAC')
- OR (Media = 'Cassette' AND Format = 'FLAC')
- OR (Media = 'SACD' AND Format = 'FLAC')
- OR (Media = 'Blu-ray' AND Format = 'FLAC')
- OR (Media = 'DAT' AND Format = 'FLAC'))
- AND UserID = '$UserID'");
+$DB->query("
+ SELECT COUNT(ID)
+ FROM torrents
+ WHERE ((LogScore = 100 AND Format = 'FLAC')
+ OR (Media = 'Vinyl' AND Format = 'FLAC')
+ OR (Media = 'WEB' AND Format = 'FLAC')
+ OR (Media = 'DVD' AND Format = 'FLAC')
+ OR (Media = 'Soundboard' AND Format = 'FLAC')
+ OR (Media = 'Cassette' AND Format = 'FLAC')
+ OR (Media = 'SACD' AND Format = 'FLAC')
+ OR (Media = 'Blu-ray' AND Format = 'FLAC')
+ OR (Media = 'DAT' AND Format = 'FLAC'))
+ AND UserID = '$UserID'");
list($PerfectFLACs) = $DB->next_record();
?>
}
if (check_paranoia_here('seeding+') || check_paranoia_here('leeching+')) {
- $DB->query("SELECT IF(remaining=0,'Seeding','Leeching') AS Type, COUNT(x.uid)
- FROM xbt_files_users AS x
- INNER JOIN torrents AS t ON t.ID=x.fid
- WHERE x.uid='$UserID' AND x.active=1
- GROUP BY Type");
+ $DB->query("
+ SELECT IF(remaining=0,'Seeding','Leeching') AS Type, COUNT(x.uid)
+ FROM xbt_files_users AS x
+ INNER JOIN torrents AS t ON t.ID=x.fid
+ WHERE x.uid='$UserID'
+ AND x.active=1
+ GROUP BY Type");
$PeerCount = $DB->to_array(0, MYSQLI_NUM, false);
- $Seeding = isset($PeerCount['Seeding'][1]) ? $PeerCount['Seeding'][1] : 0;
- $Leeching = isset($PeerCount['Leeching'][1]) ? $PeerCount['Leeching'][1] : 0;
+ $Seeding = (isset($PeerCount['Seeding'][1]) ? $PeerCount['Seeding'][1] : 0);
+ $Leeching = (isset($PeerCount['Leeching'][1]) ? $PeerCount['Leeching'][1] : 0);
} ?>
if (($Override = check_paranoia_here('seeding+'))) { ?>
-
}
if (($Override = check_perms('site_view_torrent_snatchlist', $Class))) {
- $DB->query("SELECT COUNT(ud.UserID), COUNT(DISTINCT ud.TorrentID)
- FROM users_downloads AS ud
- INNER JOIN torrents AS t ON t.ID=ud.TorrentID
- WHERE ud.UserID='$UserID'");
+ $DB->query("
+ SELECT COUNT(ud.UserID), COUNT(DISTINCT ud.TorrentID)
+ FROM users_downloads AS ud
+ INNER JOIN torrents AS t ON t.ID=ud.TorrentID
+ WHERE ud.UserID='$UserID'");
list($NumDownloads, $UniqueDownloads) = $DB->next_record();
?>
-