diff --git a/.gitignore b/.gitignore
index bb7db37f..4b65b704 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,7 @@
config.php
release/*
static/similar
+static/stylespreview
*.swp
*.project
*.php~
diff --git a/classes/ajax_start.php b/classes/ajax_start.php
index 2b1afca8..a5ed2b80 100644
--- a/classes/ajax_start.php
+++ b/classes/ajax_start.php
@@ -23,7 +23,10 @@
if (!$Enabled = $Cache->get_value('enabled_'.$UserID)) {
require(SERVER_ROOT.'/classes/mysql.class.php'); //Require the database wrapper
$DB=NEW DB_MYSQL; //Load the database wrapper
- $DB->query("SELECT Enabled FROM users_main WHERE ID='$UserID'");
+ $DB->query("
+ SELECT Enabled
+ FROM users_main
+ WHERE ID='$UserID'");
list($Enabled) = $DB->next_record();
$Cache->cache_value('enabled_'.$UserID, $Enabled, 0);
}
diff --git a/classes/alias.class.php b/classes/alias.class.php
index 2e57a2f6..c1b90b31 100644
--- a/classes/alias.class.php
+++ b/classes/alias.class.php
@@ -7,7 +7,9 @@ function convert($str) {
//Alternative approach with potential.
function flush() {
global $Cache, $DB;
- $DB->query("SELECT Alias, ArticleID FROM wiki_aliases");
+ $DB->query("
+ SELECT Alias, ArticleID
+ FROM wiki_aliases");
$Aliases = $DB->to_array('Alias');
$Cache->cache_value('wiki_aliases', $Aliases, 3600 * 24 * 14); // 2 weeks
}
@@ -16,7 +18,9 @@ function to_id($Alias) {
global $Cache, $DB;
$Aliases = $Cache->get_value('wiki_aliases');
if (!$Aliases) {
- $DB->query("SELECT Alias, ArticleID FROM wiki_aliases");
+ $DB->query("
+ SELECT Alias, ArticleID
+ FROM wiki_aliases");
$Aliases = $DB->to_array('Alias');
$Cache->cache_value('wiki_aliases', $Aliases, 3600 * 24 * 14); // 2 weeks
}
@@ -30,7 +34,10 @@ function flush() {
function to_id($Alias) {
global $DB;
$Alias = $this->convert($Alias);
- $DB->query("SELECT ArticleID FROM wiki_aliases WHERE Alias LIKE '$Alias'");
+ $DB->query("
+ SELECT ArticleID
+ FROM wiki_aliases
+ WHERE Alias LIKE '$Alias'");
list($ArticleID) = $DB->next_record();
return $ArticleID;
}
diff --git a/classes/artists.class.php b/classes/artists.class.php
index 6c720425..6ed0eea4 100644
--- a/classes/artists.class.php
+++ b/classes/artists.class.php
@@ -37,7 +37,8 @@ public static function get_artists($GroupIDs) {
if (empty($IDs)) {
$IDs = "null";
}
- $DB->query("SELECT ta.GroupID,
+ $DB->query("
+ SELECT ta.GroupID,
ta.ArtistID,
aa.Name,
ta.Importance,
@@ -217,11 +218,18 @@ public static function display_artist($Artist, $MakeLink = true, $Escape = true)
public static function delete_artist($ArtistID) {
global $DB, $LoggedUser, $Cache;
- $DB->query("SELECT Name FROM artists_group WHERE ArtistID = ".$ArtistID);
+ $DB->query("
+ SELECT Name
+ FROM artists_group
+ WHERE ArtistID = ".$ArtistID);
list($Name) = $DB->next_record(MYSQLI_NUM, false);
// Delete requests
- $DB->query("SELECT RequestID FROM requests_artists WHERE ArtistID=".$ArtistID." AND ArtistID != 0");
+ $DB->query("
+ SELECT RequestID
+ FROM requests_artists
+ WHERE ArtistID = $ArtistID
+ AND ArtistID != 0");
$Requests = $DB->to_array();
foreach ($Requests AS $Request) {
list($RequestID) = $Request;
@@ -251,7 +259,7 @@ public static function delete_artist($ArtistID) {
} else {
$Username = 'System';
}
- Misc::write_log('Artist '.$ArtistID.' ('.$Name.') was deleted by '.$Username);
+ Misc::write_log("Artist $ArtistID ($Name) was deleted by $Username");
}
diff --git a/classes/bookmarks.class.php b/classes/bookmarks.class.php
index 18b23cc4..00790b27 100644
--- a/classes/bookmarks.class.php
+++ b/classes/bookmarks.class.php
@@ -85,7 +85,10 @@ public static function all_bookmarks($Type, $UserID = false) {
$CacheKey = 'bookmarks_' . $Type . '_' . $UserID;
if (($Bookmarks = $Cache->get_value($CacheKey)) === false) {
list ($Table, $Col) = self::bookmark_schema($Type);
- $DB->query("SELECT $Col FROM $Table WHERE UserID = '$UserID'");
+ $DB->query("
+ SELECT $Col
+ FROM $Table
+ WHERE UserID = '$UserID'");
$Bookmarks = $DB->collect($Col);
$Cache->cache_value($CacheKey, $Bookmarks, 0);
}
diff --git a/classes/collages.class.php b/classes/collages.class.php
index 4f5bf93e..cabcfc9d 100644
--- a/classes/collages.class.php
+++ b/classes/collages.class.php
@@ -4,7 +4,10 @@ public static function get_comment_count($CollageID) {
global $DB, $Cache;
$NumComments = $Cache->get_value('collage_comments_'.$CollageID);
if ($NumComments === false) {
- $DB->query("SELECT COUNT(ID) FROM collages_comments WHERE CollageID = '$CollageID'");
+ $DB->query("
+ SELECT COUNT(ID)
+ FROM collages_comments
+ WHERE CollageID = '$CollageID'");
list($NumComments) = $DB->next_record();
$Cache->cache_value('collage_comments_'.$CollageID, $NumComments, 0);
}
@@ -33,13 +36,19 @@ public static function get_comment_catalogue($CollageID, $CatalogueID) {
public static function increase_subscriptions($CollageID) {
global $DB;
- $DB->query("UPDATE collages SET Subscribers = Subscribers + 1 WHERE ID = '$CollageID'");
+ $DB->query("
+ UPDATE collages
+ SET Subscribers = Subscribers + 1
+ WHERE ID = '$CollageID'");
}
public static function decrease_subscriptions($CollageID) {
global $DB;
- $DB->query("UPDATE collages SET Subscribers = IF(Subscribers < 1, 0, Subscribers - 1) WHERE ID = '$CollageID'");
+ $DB->query("
+ UPDATE collages
+ SET Subscribers = IF(Subscribers < 1, 0, Subscribers - 1)
+ WHERE ID = '$CollageID'");
}
-}
\ No newline at end of file
+}
diff --git a/classes/forums.class.php b/classes/forums.class.php
index 3530a791..552580bd 100644
--- a/classes/forums.class.php
+++ b/classes/forums.class.php
@@ -41,12 +41,14 @@ public static function quote_notify($Body, $PostID, $Page, $PageID) {
//remove any dupes in the array (the fast way)
$Usernames = array_flip(array_flip($Usernames));
- $DB->query("SELECT m.ID, p.PushService
- FROM users_main AS m
- LEFT JOIN users_info AS i ON i.UserID = m.ID
- LEFT JOIN users_push_notifications AS p ON p.UserID = m.ID
- WHERE m.Username IN ('" . implode("', '", $Usernames) . "')
- AND i.NotifyOnQuote = '1' AND i.UserID != $LoggedUser[ID]");
+ $DB->query("
+ SELECT m.ID, p.PushService
+ FROM users_main AS m
+ LEFT JOIN users_info AS i ON i.UserID = m.ID
+ LEFT JOIN users_push_notifications AS p ON p.UserID = m.ID
+ WHERE m.Username IN ('" . implode("', '", $Usernames) . "')
+ AND i.NotifyOnQuote = '1'
+ AND i.UserID != $LoggedUser[ID]");
$Results = $DB->to_array();
foreach ($Results as $Result) {
@@ -57,8 +59,11 @@ public static function quote_notify($Body, $PostID, $Page, $PageID) {
$PageID = db_string($PageID);
$PostID = db_string($PostID);
- $DB->query("INSERT IGNORE INTO users_notify_quoted (UserID, QuoterID, Page, PageID, PostID, Date)
- VALUES ('$UserID', '$QuoterID', '$Page', '$PageID', '$PostID', '" . sqltime() . "')");
+ $DB->query("
+ INSERT IGNORE INTO users_notify_quoted
+ (UserID, QuoterID, Page, PageID, PostID, Date)
+ VALUES
+ ('$UserID', '$QuoterID', '$Page', '$PageID', '$PostID', '" . sqltime() . "')");
$Cache->delete_value('notify_quoted_' . $UserID);
}
diff --git a/classes/invite_tree.class.php b/classes/invite_tree.class.php
index 62b9652c..0f365593 100644
--- a/classes/invite_tree.class.php
+++ b/classes/invite_tree.class.php
@@ -24,7 +24,10 @@ function make_tree() {
?>
- $DB->query("SELECT TreePosition, TreeID, TreeLevel FROM invite_tree WHERE UserID=$UserID");
+ $DB->query("
+ SELECT TreePosition, TreeID, TreeLevel
+ FROM invite_tree
+ WHERE UserID = $UserID");
list($TreePosition, $TreeID, $TreeLevel) = $DB->next_record(MYSQLI_NUM, false);
if (!$TreeID) {
@@ -33,9 +36,9 @@ function make_tree() {
$DB->query("
SELECT TreePosition
FROM invite_tree
- WHERE TreeID=$TreeID
- AND TreeLevel=$TreeLevel
- AND TreePosition>$TreePosition
+ WHERE TreeID = $TreeID
+ AND TreeLevel = $TreeLevel
+ AND TreePosition > $TreePosition
ORDER BY TreePosition ASC
LIMIT 1");
if ($DB->record_count()) {
diff --git a/classes/lastfm.class.php b/classes/lastfm.class.php
index d3096d07..af0c8537 100644
--- a/classes/lastfm.class.php
+++ b/classes/lastfm.class.php
@@ -25,7 +25,10 @@ public static function get_user_info($Username) {
public static function compare_user_with($Username1, $Limit = 15) {
global $Cache, $LoggedUser, $DB;
- $DB->query("SELECT username FROM lastfm_users WHERE ID='$LoggedUser[ID]'");
+ $DB->query("
+ SELECT username
+ FROM lastfm_users
+ WHERE ID='$LoggedUser[ID]'");
if ($DB->record_count() > 0) {
list($Username2) = $DB->next_record();
//Make sure the usernames are in the correct order to avoid dupe cache keys.
@@ -104,7 +107,10 @@ public static function clear_cache($Username, $Uid) {
$Cache->delete_value('lastfm_top_artists_' . $Username);
$Cache->delete_value('lastfm_top_albums_' . $Username);
$Cache->delete_value('lastfm_top_tracks_' . $Username);
- $DB->query("SELECT username FROM lastfm_users WHERE ID='$LoggedUser[ID]'");
+ $DB->query("
+ SELECT username
+ FROM lastfm_users
+ WHERE ID='$LoggedUser[ID]'");
if ($DB->record_count() > 0) {
list($Username2) = $DB->next_record();
//Make sure the usernames are in the correct order to avoid dupe cache keys.
diff --git a/classes/misc.class.php b/classes/misc.class.php
index 6ac3224b..8befd92e 100644
--- a/classes/misc.class.php
+++ b/classes/misc.class.php
@@ -108,7 +108,10 @@ public static function send_pm($ToID, $FromID, $Subject, $Body, $ConvID = '') {
$Cache->cache_value('inbox_new_'.$ID, $UnRead);
}
- $DB->query("SELECT Username FROM users_main WHERE ID = '$FromID'");
+ $DB->query("
+ SELECT Username
+ FROM users_main
+ WHERE ID = '$FromID'");
list($SenderName) = $DB->next_record();
foreach ($ToID as $ID) {
$DB->query("
@@ -141,7 +144,10 @@ public static function create_thread($ForumID, $AuthorID, $Title, $PostBody) {
return -1;
}
- $DB->query("SELECT Username FROM users_main WHERE ID=".$AuthorID);
+ $DB->query("
+ SELECT Username
+ FROM users_main
+ WHERE ID=".$AuthorID);
if ($DB->record_count() < 1) {
return -2;
}
diff --git a/classes/mysql.class.php b/classes/mysql.class.php
index 874a036a..9b0eb306 100644
--- a/classes/mysql.class.php
+++ b/classes/mysql.class.php
@@ -20,7 +20,10 @@
* Making a query
-$DB->query("SELECT * FROM table...");
+$DB->query("
+ SELECT *
+ FROM table...");
+
Is functionally equivalent to using mysqli_query("SELECT * FROM table...")
Stores the result set in $this->QueryID
Returns the result set, so you can save it for later (see set_query_id())
@@ -48,13 +51,13 @@
* The conventional way of retrieving a row from a result set is as follows:
-list($All,$Columns,$That,$You,$Select) = $DB->next_record();
+list($All, $Columns, $That, $You, $Select) = $DB->next_record();
-----
* This is how you loop over the result set:
-while (list($All,$Columns,$That,$You,$Select) = $DB->next_record()) {
- echo "Do stuff with ".$All." of the ".$Columns.$That.$You.$Select;
+while (list($All, $Columns, $That, $You, $Select) = $DB->next_record()) {
+ echo "Do stuff with $All of the ".$Columns.$That.$You.$Select;
}
-----
@@ -96,8 +99,12 @@
Example:
- $FoodRS = $DB->query("SELECT * FROM food");
- $DB->query("SELECT * FROM drink");
+ $FoodRS = $DB->query("
+ SELECT *
+ FROM food");
+ $DB->query("
+ SELECT *
+ FROM drink");
$Drinks = $DB->next_record();
$DB->set_query_id($FoodRS);
$Food = $DB->next_record();
diff --git a/classes/permissions.class.php b/classes/permissions.class.php
index 6cda611c..f8024779 100644
--- a/classes/permissions.class.php
+++ b/classes/permissions.class.php
@@ -25,7 +25,10 @@ public static function get_permissions($PermissionID) {
global $DB, $Cache;
$Permission = $Cache->get_value('perm_'.$PermissionID);
if (empty($Permission)) {
- $DB->query("SELECT p.Level AS Class, p.Values as Permissions, p.Secondary, p.PermittedForums FROM permissions AS p WHERE ID='$PermissionID'");
+ $DB->query("
+ SELECT p.Level AS Class, p.Values as Permissions, p.Secondary, p.PermittedForums
+ FROM permissions AS p
+ WHERE ID='$PermissionID'");
$Permission = $DB->next_record(MYSQLI_ASSOC, array('Permissions'));
$Permission['Permissions'] = unserialize($Permission['Permissions']);
$Cache->cache_value('perm_'.$PermissionID, $Permission, 2592000);
@@ -49,8 +52,10 @@ public static function get_permissions_for_user($UserID, $CustomPermissions = fa
// Fetch custom permissions if they weren't passed in.
if ($CustomPermissions === false) {
- $DB->query('SELECT um.CustomPermissions FROM users_main AS um
- WHERE um.ID = '.((int)$UserID));
+ $DB->query('
+ SELECT um.CustomPermissions
+ FROM users_main AS um
+ WHERE um.ID = '.((int)$UserID));
list($CustomPermissions) = $DB->next_record(MYSQLI_NUM, false);
}
diff --git a/classes/requests.class.php b/classes/requests.class.php
index e9d86ab9..9d825eee 100644
--- a/classes/requests.class.php
+++ b/classes/requests.class.php
@@ -8,30 +8,34 @@ class Requests {
public static function update_sphinx_requests($RequestID) {
global $DB, $Cache;
- $DB->query("REPLACE INTO sphinx_requests_delta (
- ID, UserID, TimeAdded, LastVote, CategoryID, Title,
- Year, ReleaseType, CatalogueNumber, BitrateList,
- FormatList, MediaList, LogCue, FillerID, TorrentID,
- TimeFilled, Visible, Votes, Bounty)
- SELECT
- ID, r.UserID, UNIX_TIMESTAMP(TimeAdded) AS TimeAdded,
- UNIX_TIMESTAMP(LastVote) AS LastVote, CategoryID,
- Title, Year, ReleaseType, CatalogueNumber, BitrateList,
- FormatList, MediaList, LogCue, FillerID, TorrentID,
- UNIX_TIMESTAMP(TimeFilled) AS TimeFilled, Visible,
- COUNT(rv.UserID) AS Votes, SUM(rv.Bounty) >> 10 AS Bounty
- FROM requests AS r LEFT JOIN requests_votes AS rv ON rv.RequestID=r.ID
- wHERE ID = ".$RequestID."
- GROUP BY r.ID");
+ $DB->query("
+ REPLACE INTO sphinx_requests_delta (
+ ID, UserID, TimeAdded, LastVote, CategoryID, Title,
+ Year, ReleaseType, CatalogueNumber, BitrateList,
+ FormatList, MediaList, LogCue, FillerID, TorrentID,
+ TimeFilled, Visible, Votes, Bounty)
+ SELECT
+ ID, r.UserID, UNIX_TIMESTAMP(TimeAdded) AS TimeAdded,
+ UNIX_TIMESTAMP(LastVote) AS LastVote, CategoryID,
+ Title, Year, ReleaseType, CatalogueNumber, BitrateList,
+ FormatList, MediaList, LogCue, FillerID, TorrentID,
+ UNIX_TIMESTAMP(TimeFilled) AS TimeFilled, Visible,
+ COUNT(rv.UserID) AS Votes, SUM(rv.Bounty) >> 10 AS Bounty
+ FROM requests AS r
+ LEFT JOIN requests_votes AS rv ON rv.RequestID=r.ID
+ WHERE ID = $RequestID
+ GROUP BY r.ID");
- $DB->query("UPDATE sphinx_requests_delta
- SET ArtistList = (SELECT
- GROUP_CONCAT(aa.Name SEPARATOR ' ')
- FROM requests_artists AS ra
- JOIN artists_alias AS aa ON aa.AliasID=ra.AliasID
- WHERE ra.RequestID = ".$RequestID."
- GROUP BY NULL)
- WHERE ID = ".$RequestID);
+ $DB->query("
+ UPDATE sphinx_requests_delta
+ SET ArtistList = (
+ SELECT GROUP_CONCAT(aa.Name SEPARATOR ' ')
+ FROM requests_artists AS ra
+ JOIN artists_alias AS aa ON aa.AliasID=ra.AliasID
+ WHERE ra.RequestID = $RequestID
+ GROUP BY NULL
+ )
+ WHERE ID = $RequestID");
$Cache->delete_value('requests_'.$RequestID);
}
@@ -72,35 +76,36 @@ public static function get_requests($RequestIDs, $Return = true) {
*/
if (count($NotFound) > 0) {
- $DB->query("SELECT
- r.ID AS ID,
- r.UserID,
- u.Username,
- r.TimeAdded,
- r.LastVote,
- r.CategoryID,
- r.Title,
- r.Year,
- r.Image,
- r.Description,
- r.CatalogueNumber,
- r.RecordLabel,
- r.ReleaseType,
- r.BitrateList,
- r.FormatList,
- r.MediaList,
- r.LogCue,
- r.FillerID,
- filler.Username,
- r.TorrentID,
- r.TimeFilled,
- r.GroupID,
- r.OCLC
- FROM requests AS r
- LEFT JOIN users_main AS u ON u.ID=r.UserID
- LEFT JOIN users_main AS filler ON filler.ID=FillerID AND FillerID!=0
- WHERE r.ID IN (".$IDs.")
- ORDER BY ID");
+ $DB->query("
+ SELECT
+ r.ID AS ID,
+ r.UserID,
+ u.Username,
+ r.TimeAdded,
+ r.LastVote,
+ r.CategoryID,
+ r.Title,
+ r.Year,
+ r.Image,
+ r.Description,
+ r.CatalogueNumber,
+ r.RecordLabel,
+ r.ReleaseType,
+ r.BitrateList,
+ r.FormatList,
+ r.MediaList,
+ r.LogCue,
+ r.FillerID,
+ filler.Username,
+ r.TorrentID,
+ r.TimeFilled,
+ r.GroupID,
+ r.OCLC
+ FROM requests AS r
+ LEFT JOIN users_main AS u ON u.ID=r.UserID
+ LEFT JOIN users_main AS filler ON filler.ID=FillerID AND FillerID!=0
+ WHERE r.ID IN ($IDs)
+ ORDER BY ID");
$Requests = $DB->to_array();
foreach ($Requests as $Request) {
@@ -121,7 +126,10 @@ public static function get_comment_count($RequestID) {
global $Cache, $DB;
$NumComments = $Cache->get_value('request_comments_'.$RequestID);
if ($NumComments === false) {
- $DB->query("SELECT COUNT(ID) FROM requests_comments WHERE RequestID = '$RequestID'");
+ $DB->query("
+ SELECT COUNT(ID)
+ FROM requests_comments
+ WHERE RequestID = '$RequestID'");
list($NumComments) = $DB->next_record();
$Cache->cache_value('request_comments_'.$RequestID, $NumComments, 0);
}
diff --git a/classes/script_start.php b/classes/script_start.php
index c5496bc5..e80e6535 100644
--- a/classes/script_start.php
+++ b/classes/script_start.php
@@ -216,12 +216,14 @@
// Enabled - if the user's enabled or not
// Permissions
-if (isset($_COOKIE['session'])) { $LoginCookie=$Enc->decrypt($_COOKIE['session']); }
+if (isset($_COOKIE['session'])) {
+ $LoginCookie = $Enc->decrypt($_COOKIE['session']);
+}
if (isset($LoginCookie)) {
- list($SessionID, $LoggedUser['ID'])=explode("|~|",$Enc->decrypt($LoginCookie));
+ list($SessionID, $LoggedUser['ID']) = explode("|~|", $Enc->decrypt($LoginCookie));
$LoggedUser['ID'] = (int)$LoggedUser['ID'];
- $UserID=$LoggedUser['ID']; //TODO: UserID should not be LoggedUser
+ $UserID = $LoggedUser['ID']; //TODO: UserID should not be LoggedUser
if (!$LoggedUser['ID'] || !$SessionID) {
logout();
@@ -244,14 +246,17 @@
$Cache->cache_value('users_sessions_'.$UserID, $UserSessions, 0);
}
- if (!array_key_exists($SessionID,$UserSessions)) {
+ if (!array_key_exists($SessionID, $UserSessions)) {
logout();
}
// Check if user is enabled
$Enabled = $Cache->get_value('enabled_'.$LoggedUser['ID']);
if ($Enabled === false) {
- $DB->query("SELECT Enabled FROM users_main WHERE ID='$LoggedUser[ID]'");
+ $DB->query("
+ SELECT Enabled
+ FROM users_main
+ WHERE ID='$LoggedUser[ID]'");
list($Enabled) = $DB->next_record();
$Cache->cache_value('enabled_'.$LoggedUser['ID'], $Enabled, 0);
}
@@ -336,7 +341,10 @@
if (isset($LoggedUser['Permissions']['site_torrents_notify'])) {
$LoggedUser['Notify'] = $Cache->get_value('notify_filters_'.$LoggedUser['ID']);
if (!is_array($LoggedUser['Notify'])) {
- $DB->query("SELECT ID, Label FROM users_notify_filters WHERE UserID='$LoggedUser[ID]'");
+ $DB->query("
+ SELECT ID, Label
+ FROM users_notify_filters
+ WHERE UserID='$LoggedUser[ID]'");
$LoggedUser['Notify'] = $DB->to_array('ID');
$Cache->cache_value('notify_filters_'.$LoggedUser['ID'], $LoggedUser['Notify'], 2592000);
}
@@ -371,7 +379,10 @@
('$LoggedUser[ID]', '$NewIP', '".sqltime()."')");
$ipcc = Tools::geoip($NewIP);
- $DB->query("UPDATE users_main SET IP='$NewIP', ipcc='".$ipcc."' WHERE ID='$LoggedUser[ID]'");
+ $DB->query("
+ UPDATE users_main
+ SET IP='$NewIP', ipcc='$ipcc'
+ WHERE ID='$LoggedUser[ID]'");
$Cache->begin_transaction('user_info_heavy_'.$LoggedUser['ID']);
$Cache->update_row(false, array('IP' => $_SERVER['REMOTE_ADDR']));
$Cache->commit_transaction(0);
@@ -383,7 +394,12 @@
// Get stylesheets
$Stylesheets = $Cache->get_value('stylesheets');
if (!is_array($Stylesheets)) {
- $DB->query('SELECT ID, LOWER(REPLACE(Name," ","_")) AS Name, Name AS ProperName FROM stylesheets');
+ $DB->query('
+ SELECT
+ ID,
+ LOWER(REPLACE(Name," ","_")) AS Name,
+ Name AS ProperName
+ FROM stylesheets');
$Stylesheets = $DB->to_array('ID', MYSQLI_BOTH);
$Cache->cache_value('stylesheets', $Stylesheets, 600);
}
@@ -396,12 +412,10 @@
}
}
-
$Debug->set_flag('end user handling');
$Debug->set_flag('start function definitions');
-
/**
* Log out the current session
*/
@@ -413,7 +427,10 @@ function logout() {
if ($SessionID) {
- $DB->query("DELETE FROM users_sessions WHERE UserID='$LoggedUser[ID]' AND SessionID='".db_string($SessionID)."'");
+ $DB->query("
+ DELETE FROM users_sessions
+ WHERE UserID='$LoggedUser[ID]'
+ AND SessionID='".db_string($SessionID)."'");
$Cache->begin_transaction('users_sessions_'.$LoggedUser['ID']);
$Cache->delete_row($SessionID);
@@ -453,8 +470,6 @@ function authorize($Ajax = false) {
return true;
}
-
-
$Debug->set_flag('ending function definitions');
//Include /sections/*/index.php
$Document = basename(parse_url($_SERVER['SCRIPT_FILENAME'], PHP_URL_PATH), '.php');
diff --git a/classes/tools.class.php b/classes/tools.class.php
index c667a703..e9d3edfa 100644
--- a/classes/tools.class.php
+++ b/classes/tools.class.php
@@ -177,19 +177,28 @@ public static function disable_users($UserIDs, $AdminComment, $BanReason = 1) {
$Cache->delete_value('user_info_heavy_'.$UserID);
$Cache->delete_value('user_stats_'.$UserID);
- $DB->query("SELECT SessionID FROM users_sessions WHERE UserID='$UserID' AND Active = 1");
+ $DB->query("
+ SELECT SessionID
+ FROM users_sessions
+ WHERE UserID='$UserID'
+ AND Active = 1");
while (list($SessionID) = $DB->next_record()) {
$Cache->delete_value('session_'.$UserID.'_'.$SessionID);
}
$Cache->delete_value('users_sessions_'.$UserID);
- $DB->query("DELETE FROM users_sessions WHERE UserID='$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) {
diff --git a/classes/torrents.class.php b/classes/torrents.class.php
index 09ec45d5..8f4f5523 100644
--- a/classes/torrents.class.php
+++ b/classes/torrents.class.php
@@ -77,9 +77,11 @@ public static function get_groups($GroupIDs, $Return = true, $GetArtists = true,
*/
if (count($NotFound) > 0) {
- $DB->query("SELECT
- g.ID, g.Name, g.Year, g.RecordLabel, g.CatalogueNumber, g.TagList, g.ReleaseType, g.VanityHouse, g.WikiImage, g.CategoryID
- FROM torrents_group AS g WHERE g.ID IN ($IDs)");
+ $DB->query("
+ SELECT
+ g.ID, g.Name, g.Year, g.RecordLabel, g.CatalogueNumber, g.TagList, g.ReleaseType, g.VanityHouse, g.WikiImage, g.CategoryID
+ FROM torrents_group AS g
+ WHERE g.ID IN ($IDs)");
while ($Group = $DB->next_record(MYSQLI_ASSOC, true)) {
unset($NotFound[$Group['ID']]);
@@ -96,13 +98,14 @@ public static function get_groups($GroupIDs, $Return = true, $GetArtists = true,
}
if ($Torrents) {
- $DB->query("SELECT
- ID, GroupID, Media, Format, Encoding, RemasterYear, Remastered, RemasterTitle,
- RemasterRecordLabel, RemasterCatalogueNumber, Scene, HasLog, HasCue, LogScore,
- FileCount, FreeTorrent, Size, Leechers, Seeders, Snatched, Time, ID AS HasFile
- FROM torrents AS t
- WHERE GroupID IN($IDs)
- ORDER BY GroupID, Remastered, (RemasterYear != 0) DESC, RemasterYear, RemasterTitle,
+ $DB->query("
+ SELECT
+ ID, GroupID, Media, Format, Encoding, RemasterYear, Remastered, RemasterTitle,
+ RemasterRecordLabel, RemasterCatalogueNumber, Scene, HasLog, HasCue, LogScore,
+ FileCount, FreeTorrent, Size, Leechers, Seeders, Snatched, Time, ID AS HasFile
+ FROM torrents AS t
+ WHERE GroupID IN($IDs)
+ ORDER BY GroupID, Remastered, (RemasterYear != 0) DESC, RemasterYear, RemasterTitle,
RemasterRecordLabel, RemasterCatalogueNumber, Media, Format, Encoding, ID");
while ($Torrent = $DB->next_record(MYSQLI_ASSOC, true)) {
$Found[$Torrent['GroupID']]['Torrents'][$Torrent['ID']] = $Torrent;
@@ -211,8 +214,11 @@ public static function torrent_properties(&$Torrent, &$Flags) {
*/
public static function write_group_log($GroupID, $TorrentID, $UserID, $Message, $Hidden) {
global $DB,$Time;
- $DB->query("INSERT INTO group_log (GroupID, TorrentID, UserID, Info, Time, Hidden) VALUES ("
- .$GroupID.", ".$TorrentID.", ".$UserID.", '".db_string($Message)."', '".sqltime()."', ".$Hidden.")");
+ $DB->query("
+ INSERT INTO group_log
+ (GroupID, TorrentID, UserID, Info, Time, Hidden)
+ VALUES
+ ($GroupID, $TorrentID, $UserID, '".db_string($Message)."', '".sqltime()."', $Hidden)");
}
@@ -223,14 +229,20 @@ public static function write_group_log($GroupID, $TorrentID, $UserID, $Message,
* @param int $GroupID Set it if you have it handy, to save a query. Otherwise, it will be found.
* @param string $OcelotReason The deletion reason for ocelot to report to users.
*/
- public static function delete_torrent($ID, $GroupID=0, $OcelotReason=-1) {
+ public static function delete_torrent($ID, $GroupID = 0, $OcelotReason = -1) {
global $DB, $Cache, $LoggedUser;
if (!$GroupID) {
- $DB->query("SELECT GroupID, UserID FROM torrents WHERE ID='$ID'");
+ $DB->query("
+ SELECT GroupID, UserID
+ FROM torrents
+ WHERE ID='$ID'");
list($GroupID, $UploaderID) = $DB->next_record();
}
if (empty($UserID)) {
- $DB->query("SELECT UserID FROM torrents WHERE ID='$ID'");
+ $DB->query("
+ SELECT UserID
+ FROM torrents
+ WHERE ID='$ID'");
list($UserID) = $DB->next_record();
}
@@ -244,14 +256,22 @@ public static function delete_torrent($ID, $GroupID=0, $OcelotReason=-1) {
}
- $DB->query("SELECT info_hash FROM torrents WHERE ID = ".$ID);
+ $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);
+ $DB->query("
+ DELETE FROM torrents
+ WHERE ID = ".$ID);
Tracker::update_tracker('delete_torrent', array('info_hash' => rawurlencode($InfoHash), 'id' => $ID, 'reason' => $OcelotReason));
$Cache->decrement('stats_torrent_count');
- $DB->query("SELECT COUNT(ID) FROM torrents WHERE GroupID='$GroupID'");
+ $DB->query("
+ SELECT COUNT(ID)
+ FROM torrents
+ WHERE GroupID='$GroupID'");
list($Count) = $DB->next_record();
if ($Count == 0) {
@@ -261,34 +281,56 @@ public static function delete_torrent($ID, $GroupID=0, $OcelotReason=-1) {
}
// Torrent notifications
- $DB->query("SELECT UserID FROM users_notify_torrents WHERE TorrentID='$ID'");
+ $DB->query("
+ SELECT UserID
+ FROM users_notify_torrents
+ WHERE TorrentID='$ID'");
while (list($UserID) = $DB->next_record()) {
$Cache->delete_value('notifications_new_'.$UserID);
}
- $DB->query("DELETE FROM users_notify_torrents WHERE TorrentID='$ID'");
+ $DB->query("
+ DELETE FROM users_notify_torrents
+ WHERE TorrentID='$ID'");
-
- $DB->query("UPDATE reportsv2 SET
+ $DB->query("
+ UPDATE reportsv2
+ SET
Status='Resolved',
LastChangeTime='".sqltime()."',
ModComment='Report already dealt with (Torrent deleted)'
- WHERE TorrentID=".$ID."
+ WHERE TorrentID = $ID
AND Status != 'Resolved'");
$Reports = $DB->affected_rows();
if ($Reports) {
$Cache->decrement('num_torrent_reportsv2', $Reports);
}
- $DB->query("DELETE FROM torrents_files WHERE TorrentID='$ID'");
- $DB->query("DELETE FROM torrents_bad_tags WHERE TorrentID = ".$ID);
- $DB->query("DELETE FROM torrents_bad_folders WHERE TorrentID = ".$ID);
- $DB->query("DELETE FROM torrents_bad_files 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_lossyweb_approved WHERE TorrentID = ".$ID);
+ $DB->query("
+ DELETE FROM torrents_files
+ WHERE TorrentID = '$ID'");
+ $DB->query("
+ DELETE FROM torrents_bad_tags
+ WHERE TorrentID = ".$ID);
+ $DB->query("
+ DELETE FROM torrents_bad_folders
+ WHERE TorrentID = ".$ID);
+ $DB->query("
+ DELETE FROM torrents_bad_files
+ 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_lossyweb_approved
+ WHERE TorrentID = ".$ID);
// Tells Sphinx that the group is removed
- $DB->query("REPLACE INTO sphinx_delta (ID,Time) VALUES ($ID, UNIX_TIMESTAMP())");
+ $DB->query("
+ REPLACE INTO sphinx_delta (ID, Time)
+ VALUES ($ID, UNIX_TIMESTAMP())");
$Cache->delete_value('torrent_download_'.$ID);
$Cache->delete_value('torrent_group_'.$GroupID);
@@ -305,9 +347,12 @@ public static function delete_torrent($ID, $GroupID=0, $OcelotReason=-1) {
public static function delete_group($GroupID) {
global $DB, $Cache;
- Misc::write_log("Group ".$GroupID." automatically deleted (No torrents have this group).");
+ Misc::write_log("Group $GroupID automatically deleted (No torrents have this group).");
- $DB->query("SELECT CategoryID FROM torrents_group WHERE ID='$GroupID'");
+ $DB->query("
+ SELECT CategoryID
+ FROM torrents_group
+ WHERE ID='$GroupID'");
list($Category) = $DB->next_record();
if ($Category == 1) {
$Cache->decrement('stats_album_count');
@@ -317,11 +362,19 @@ public static function delete_group($GroupID) {
// Collages
- $DB->query("SELECT CollageID FROM collages_torrents WHERE GroupID='$GroupID'");
+ $DB->query("
+ SELECT CollageID
+ FROM collages_torrents
+ WHERE GroupID='$GroupID'");
if ($DB->record_count() > 0) {
$CollageIDs = $DB->collect('CollageID');
- $DB->query("UPDATE collages SET NumTorrents=NumTorrents-1 WHERE ID IN (".implode(', ',$CollageIDs).")");
- $DB->query("DELETE FROM collages_torrents WHERE GroupID='$GroupID'");
+ $DB->query("
+ UPDATE collages
+ SET NumTorrents=NumTorrents-1
+ WHERE ID IN (".implode(', ',$CollageIDs).')');
+ $DB->query("
+ DELETE FROM collages_torrents
+ WHERE GroupID='$GroupID'");
foreach ($CollageIDs as $CollageID) {
$Cache->delete_value('collage_'.$CollageID);
@@ -331,10 +384,15 @@ public static function delete_group($GroupID) {
// Artists
// Collect the artist IDs and then wipe the torrents_artist entry
- $DB->query("SELECT ArtistID FROM torrents_artists WHERE GroupID = ".$GroupID);
+ $DB->query("
+ SELECT ArtistID
+ FROM torrents_artists
+ WHERE GroupID = ".$GroupID);
$Artists = $DB->collect('ArtistID');
- $DB->query("DELETE FROM torrents_artists WHERE GroupID='$GroupID'");
+ $DB->query("
+ DELETE FROM torrents_artists
+ WHERE GroupID='$GroupID'");
foreach ($Artists as $ArtistID) {
if (empty($ArtistID)) {
@@ -365,9 +423,15 @@ public static function delete_group($GroupID) {
}
// Requests
- $DB->query("SELECT ID FROM requests WHERE GroupID='$GroupID'");
+ $DB->query("
+ SELECT ID
+ FROM requests
+ WHERE GroupID='$GroupID'");
$Requests = $DB->collect('ID');
- $DB->query("UPDATE requests SET GroupID = NULL WHERE GroupID = '$GroupID'");
+ $DB->query("
+ UPDATE requests
+ SET GroupID = NULL
+ WHERE GroupID = '$GroupID'");
foreach ($Requests as $RequestID) {
$Cache->delete_value('request_'.$RequestID);
}
@@ -404,7 +468,10 @@ public static function update_hash($GroupID) {
WHERE ID='$GroupID'");
// Fetch album vote score
- $DB->query("SELECT Score FROM torrents_votes WHERE GroupID=$GroupID");
+ $DB->query("
+ SELECT Score
+ FROM torrents_votes
+ WHERE GroupID=$GroupID");
if ($DB->record_count()) {
list($VoteScore) = $DB->next_record();
} else {
@@ -559,7 +626,11 @@ public static function filelist_get_file($File) {
if ($Spaces = strspn($Name, ' ')) {
$Name = str_replace(' ', ' ', substr($Name, 0, $Spaces)) . substr($Name, $Spaces);
}
- return array('ext' => $FileExt, 'size' => substr($Size, 1, -1), 'name' => substr($Name, 0, -$DelimLen));
+ return array(
+ 'ext' => $FileExt,
+ 'size' => substr($Size, 1, -1),
+ 'name' => substr($Name, 0, -$DelimLen)
+ );
}
/**
@@ -744,7 +815,10 @@ public static function has_snatched($TorrentID, $AllUsers = false) {
$SnatchedTorrents[$i] = array();
}
// Not found in cache. Since we don't have a suitable index, it's faster to update everything
- $DB->query("SELECT fid, tstamp AS TorrentID FROM xbt_snatched WHERE uid='$UserID'");
+ $DB->query("
+ SELECT fid, tstamp AS TorrentID
+ FROM xbt_snatched
+ WHERE uid = '$UserID'");
while (list($ID) = $DB->next_record(MYSQLI_NUM, false)) {
$SnatchedTorrents[$ID & $LastBucket][(int)$ID] = true;
}
@@ -754,7 +828,11 @@ public static function has_snatched($TorrentID, $AllUsers = false) {
return true;
} else {
// Old cache, check if torrent has been snatched recently
- $DB->query("SELECT fid FROM xbt_snatched WHERE uid='$UserID' AND tstamp>=$LastUpdate");
+ $DB->query("
+ SELECT fid
+ FROM xbt_snatched
+ WHERE uid = '$UserID'
+ AND tstamp >= $LastUpdate");
while (list($ID) = $DB->next_record(MYSQLI_NUM, false)) {
$CurBucketID = $ID & $LastBucket;
if ($SnatchedTorrents[$CurBucketID] === false) {
diff --git a/classes/user_rank.class.php b/classes/user_rank.class.php
index 3040e5ee..ae6c1a2e 100644
--- a/classes/user_rank.class.php
+++ b/classes/user_rank.class.php
@@ -7,9 +7,10 @@ class USER_RANK {
// Returns a 101 row array (101 percentiles - 0 - 100), with the minimum value for that percentile as the value for each row
// BTW - ingenious
function build_table($MemKey, $Query) {
- global $Cache,$DB;
+ global $Cache, $DB;
- $DB->query("DROP TEMPORARY TABLE IF EXISTS temp_stats");
+ $DB->query("
+ DROP TEMPORARY TABLE IF EXISTS temp_stats");
$DB->query("
CREATE TEMPORARY TABLE temp_stats (
@@ -17,9 +18,13 @@ function build_table($MemKey, $Query) {
Val bigint(20) NOT NULL
);");
- $DB->query("INSERT INTO temp_stats (Val) ".$Query);
+ $DB->query("
+ INSERT INTO temp_stats (Val) ".
+ $Query);
- $DB->query("SELECT COUNT(ID) FROM temp_stats");
+ $DB->query("
+ SELECT COUNT(ID)
+ FROM temp_stats");
list($UserCount) = $DB->next_record();
$DB->query("
diff --git a/classes/users.class.php b/classes/users.class.php
index 0936455e..8eace908 100644
--- a/classes/users.class.php
+++ b/classes/users.class.php
@@ -178,7 +178,10 @@ public static function user_heavy_info($UserID) {
}
unset($HeavyInfo['PermittedForums']);
- $DB->query("SELECT PermissionID FROM users_levels WHERE UserID = $UserID");
+ $DB->query("
+ SELECT PermissionID
+ FROM users_levels
+ WHERE UserID = $UserID");
$PermIDs = $DB->collect('PermissionID');
foreach ($PermIDs AS $PermID) {
$Perms = Permissions::get_permissions($PermID);
diff --git a/classes/votes.class.php b/classes/votes.class.php
index 3ac84605..17d8ba61 100644
--- a/classes/votes.class.php
+++ b/classes/votes.class.php
@@ -36,7 +36,10 @@ public static function get_user_votes($UserID) {
$UserVotes = $Cache->get_value('voted_albums_'.$UserID);
if ($UserVotes === false) {
- $DB->query('SELECT GroupID, Type FROM users_votes WHERE UserID='.$UserID);
+ $DB->query('
+ SELECT GroupID, Type
+ FROM users_votes
+ WHERE UserID='.$UserID);
$UserVotes = $DB->to_array('GroupID', MYSQL_ASSOC, false);
$Cache->cache_value('voted_albums_'.$UserID, $UserVotes);
}
@@ -55,7 +58,10 @@ public static function get_group_votes($GroupID) {
$GroupVotes = $Cache->get_value('votes_'.$GroupID);
if ($GroupVotes === false) {
- $DB->query("SELECT Ups AS Ups, Total AS Total FROM torrents_votes WHERE GroupID=$GroupID");
+ $DB->query("
+ SELECT Ups AS Ups, Total AS Total
+ FROM torrents_votes
+ WHERE GroupID = $GroupID");
if ($DB->record_count() == 0) {
$GroupVotes = array('Ups'=>0, 'Total'=>0);
} else {
@@ -166,8 +172,10 @@ public static function binomial_score($Ups, $Total) {
if (($Total <= 0) || ($Ups < 0)) {
return 0;
}
- $phat = $Ups/$Total;
- return ($phat + Z_VAL*Z_VAL/(2*$Total) - Z_VAL*sqrt(($phat*(1-$phat)+Z_VAL*Z_VAL/(4*$Total))/$Total))/(1+Z_VAL*Z_VAL/$Total);
+ $phat = $Ups / $Total;
+ $Numerator = ($phat + Z_VAL * Z_VAL / (2 * $Total) - Z_VAL * sqrt(($phat * (1 - $phat) + Z_VAL * Z_VAL / (4 * $Total)) / $Total));
+ $Denominator = (1 + Z_VAL * Z_VAL / $Total);
+ return ($Numerator / $Denominator);
}
/**
@@ -207,14 +215,18 @@ public static function get_rank_all($GroupID) {
if ($Rankings === false) {
$Rankings = array();
$i = 0;
- $DB->query("SELECT GroupID FROM torrents_votes ORDER BY Score DESC LIMIT 100");
+ $DB->query("
+ SELECT GroupID
+ FROM torrents_votes
+ ORDER BY Score DESC
+ LIMIT 100");
while (list($GID) = $DB->next_record()) {
$Rankings[$GID] = ++$i;
}
$Cache->cache_value('voting_ranks_overall', $Rankings, 259200); // 3 days
}
- return isset($Rankings[$GroupID])?$Rankings[$GroupID]:false;
+ return (isset($Rankings[$GroupID]) ? $Rankings[$GroupID] : false);
}
/**
@@ -238,18 +250,20 @@ public static function get_rank_year($GroupID, $Year) {
if ($Rankings === false) {
$Rankings = array();
$i = 0;
- $DB->query("SELECT GroupID
- FROM torrents_votes AS v
- JOIN torrents_group AS g ON g.ID = v.GroupID
- WHERE g.Year = $Year
- ORDER BY Score DESC LIMIT 100");
+ $DB->query("
+ SELECT GroupID
+ FROM torrents_votes AS v
+ JOIN torrents_group AS g ON g.ID = v.GroupID
+ WHERE g.Year = $Year
+ ORDER BY Score DESC
+ LIMIT 100");
while (list($GID) = $DB->next_record()) {
$Rankings[$GID] = ++$i;
}
$Cache->cache_value('voting_ranks_year_'.$Year , $Rankings, 259200); // 3 days
}
- return isset($Rankings[$GroupID])?$Rankings[$GroupID]:false;
+ return (isset($Rankings[$GroupID]) ? $Rankings[$GroupID] : false);
}
/**
@@ -277,19 +291,21 @@ public static function get_rank_decade($GroupID, $Year) {
if ($Rankings === false) {
$Rankings = array();
$i = 0;
- $DB->query("SELECT GroupID
- FROM torrents_votes AS v
- JOIN torrents_group AS g ON g.ID = v.GroupID
- WHERE g.Year BETWEEN $Year AND ".($Year+9)."
- AND g.CategoryID = 1
- ORDER BY Score DESC LIMIT 100");
+ $DB->query("
+ SELECT GroupID
+ FROM torrents_votes AS v
+ JOIN torrents_group AS g ON g.ID = v.GroupID
+ WHERE g.Year BETWEEN $Year AND " . ($Year + 9) . "
+ AND g.CategoryID = 1
+ ORDER BY Score DESC
+ LIMIT 100");
while (list($GID) = $DB->next_record()) {
$Rankings[$GID] = ++$i;
}
$Cache->cache_value('voting_ranks_decade_'.$Year , $Rankings, 259200); // 3 days
}
- return isset($Rankings[$GroupID])?$Rankings[$GroupID]:false;
+ return (isset($Rankings[$GroupID]) ? $Rankings[$GroupID] : false);
}
}
?>
diff --git a/design/privateheader.php b/design/privateheader.php
index 21e5bf3f..2c5397b0 100644
--- a/design/privateheader.php
+++ b/design/privateheader.php
@@ -271,7 +271,10 @@
if (check_perms('users_mod')) {
global $SBlogReadTime, $LatestSBlogTime;
if (!$SBlogReadTime && ($SBlogReadTime = $Cache->get_value('staff_blog_read_'.$LoggedUser['ID'])) === false) {
- $DB->query("SELECT Time FROM staff_blog_visits WHERE UserID = ".$LoggedUser['ID']);
+ $DB->query("
+ SELECT Time
+ FROM staff_blog_visits
+ WHERE UserID = ".$LoggedUser['ID']);
if (list($SBlogReadTime) = $DB->next_record()) {
$SBlogReadTime = strtotime($SBlogReadTime);
} else {
@@ -280,7 +283,9 @@
$Cache->cache_value('staff_blog_read_'.$LoggedUser['ID'], $SBlogReadTime, 1209600);
}
if (!$LatestSBlogTime && ($LatestSBlogTime = $Cache->get_value('staff_blog_latest_time')) === false) {
- $DB->query("SELECT MAX(Time) FROM staff_blog");
+ $DB->query("
+ SELECT MAX(Time)
+ FROM staff_blog");
if (list($LatestSBlogTime) = $DB->next_record()) {
$LatestSBlogTime = strtotime($LatestSBlogTime);
} else {
@@ -406,7 +411,10 @@
// Torrent reports code
$NumTorrentReports = $Cache->get_value('num_torrent_reportsv2');
if ($NumTorrentReports === false) {
- $DB->query("SELECT COUNT(ID) FROM reportsv2 WHERE Status='New'");
+ $DB->query("
+ SELECT COUNT(ID)
+ FROM reportsv2
+ WHERE Status='New'");
list($NumTorrentReports) = $DB->next_record();
$Cache->cache_value('num_torrent_reportsv2', $NumTorrentReports, 0);
}
@@ -416,7 +424,10 @@
// Other reports code
$NumOtherReports = $Cache->get_value('num_other_reports');
if ($NumOtherReports === false) {
- $DB->query("SELECT COUNT(ID) FROM reports WHERE Status='New'");
+ $DB->query("
+ SELECT COUNT(ID)
+ FROM reports
+ WHERE Status='New'");
list($NumOtherReports) = $DB->next_record();
$Cache->cache_value('num_other_reports', $NumOtherReports, 0);
}
diff --git a/image.php b/image.php
index 48363d25..e4d8f8ac 100644
--- a/image.php
+++ b/image.php
@@ -135,44 +135,66 @@ function image_height($Type, $Data) {
}
-function send_pm($ToID,$FromID,$Subject,$Body,$ConvID='') {
+function send_pm($ToID, $FromID, $Subject, $Body, $ConvID = '') {
global $DB, $Cache;
if ($ToID == 0) {
// Don't allow users to send messages to the system
return;
}
if ($ConvID == '') {
- $DB->query("INSERT INTO pm_conversations(Subject) VALUES ('$Subject')");
+ $DB->query("
+ INSERT INTO pm_conversations (Subject)
+ VALUES ('$Subject')");
$ConvID = $DB->inserted_id();
- $DB->query("INSERT INTO pm_conversations_users
- (UserID, ConvID, InInbox, InSentbox, SentDate, ReceivedDate, UnRead) VALUES
+ $DB->query("
+ INSERT INTO pm_conversations_users
+ (UserID, ConvID, InInbox, InSentbox, SentDate, ReceivedDate, UnRead)
+ VALUES
('$ToID', '$ConvID', '1','0','".sqltime()."', '".sqltime()."', '1')");
if ($FromID != 0) {
- $DB->query("INSERT INTO pm_conversations_users
- (UserID, ConvID, InInbox, InSentbox, SentDate, ReceivedDate, UnRead) VALUES
- ('$FromID', '$ConvID', '0','1','".sqltime()."', '".sqltime()."', '0')");
+ $DB->query("
+ INSERT INTO pm_conversations_users
+ (UserID, ConvID, InInbox, InSentbox, SentDate, ReceivedDate, UnRead)
+ VALUES
+ ('$FromID', '$ConvID', '0','1','".sqltime()."', '".sqltime()."', '0')");
}
} else {
- $DB->query("UPDATE pm_conversations_users SET
+ $DB->query("
+ UPDATE pm_conversations_users
+ SET
InInbox='1',
UnRead='1',
ReceivedDate='".sqltime()."'
- WHERE UserID='$ToID'
+ WHERE UserID='$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'");
}
- $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')");
// Clear the caches of the inbox and sentbox
- //$DB->query("SELECT UnRead from pm_conversations_users WHERE ConvID='$ConvID' AND UserID='$ToID'");
- $DB->query("SELECT COUNT(ConvID) FROM pm_conversations_users WHERE UnRead = '1' and UserID='$ToID' AND InInbox = '1'");
+ /*$DB->query("
+ SELECT UnRead
+ FROM pm_conversations_users
+ WHERE ConvID='$ConvID'
+ AND UserID='$ToID'");
+ */
+ $DB->query("
+ SELECT COUNT(ConvID)
+ FROM pm_conversations_users
+ WHERE UnRead = '1'
+ AND UserID='$ToID'
+ AND InInbox = '1'");
list($UnRead) = $DB->next_record(MYSQLI_BOTH, FALSE);
$Cache->cache_value('inbox_new_'.$ToID, $UnRead);
@@ -218,7 +240,7 @@ function make_utf8($Str) {
$Encoding = 'UTF-8';
}
if (empty($Encoding)) {
- $Encoding = mb_detect_encoding($Str,'UTF-8, ISO-8859-1');
+ $Encoding = mb_detect_encoding($Str, 'UTF-8, ISO-8859-1');
}
if (empty($Encoding)) {
$Encoding = 'ISO-8859-1';
@@ -226,7 +248,7 @@ function make_utf8($Str) {
if ($Encoding == 'UTF-8') {
return $Str;
} else {
- return @mb_convert_encoding($Str,'UTF-8',$Encoding);
+ return @mb_convert_encoding($Str, 'UTF-8', $Encoding);
}
}
}
diff --git a/sections/index/feat_merch.php b/sections/index/feat_merch.php
new file mode 100644
index 00000000..f341908a
--- /dev/null
+++ b/sections/index/feat_merch.php
@@ -0,0 +1,44 @@
+
+
+
+ $FeaturedMerchURL = '';
+
+ $FeaturedMerch = $Cache->get_value('featured_merch');
+ if ($FeaturedMerch === false) {
+ $DB->query('
+ SELECT ProductID, Title, Image, ArtistID
+ FROM featured_merch
+ WHERE Ended = 0');
+ $FeaturedMerch = $DB->next_record(MYSQLI_ASSOC);
+ $Cache->cache_value('featured_merch', $FeaturedMerch, 0);
+ }
+
+ if ($FeaturedMerch != null) {
+?>
+
+
+ Featured Product
+
+
+
+
+
+
+ } else { ?>
+
+
+ It's a mystery!
+
+
+ You may want to put an image here.
+
+
+
+ }
+?>
diff --git a/sections/index/private.php b/sections/index/private.php
index 0e93842a..5bc4e921 100644
--- a/sections/index/private.php
+++ b/sections/index/private.php
@@ -30,7 +30,7 @@