diff --git a/classes/class_mass_user_torrents_table_view.php b/classes/class_mass_user_torrents_table_view.php
index 3f0f792c..96f60546 100644
--- a/classes/class_mass_user_torrents_table_view.php
+++ b/classes/class_mass_user_torrents_table_view.php
@@ -226,10 +226,10 @@ public function row ($Sort, $GroupID, $GroupYear, $DisplayName, $TorrentLink, $D
=$this->NumGroups?>
- =$GroupYear?trim($GroupYear):' '?>
- =$DisplayName?trim($DisplayName):' '?>
- =$TorrentLink?trim($TorrentLink):' '?>
- =$DateAdded?time_diff($DateAdded):' '?>
+ =$GroupYear ? trim($GroupYear) : ' '?>
+ =$DisplayName ? trim($DisplayName) : ' '?>
+ =$TorrentLink ? trim($TorrentLink) : ' '?>
+ =$DateAdded ? time_diff($DateAdded) : ' '?>
@@ -246,13 +246,15 @@ public function row ($Sort, $GroupID, $GroupYear, $DisplayName, $TorrentLink, $D
static public function display_name (array &$ExtendedArtists, array &$Artists, $VanityHouse) {
$DisplayName = '';
if (!empty($ExtendedArtists[1]) || !empty($ExtendedArtists[4])
- || !empty($ExtendedArtists[5]) || !empty($ExtendedArtists[6])) {
+ || !empty($ExtendedArtists[5]) || !empty($ExtendedArtists[6])) {
unset($ExtendedArtists[2], $ExtendedArtists[3]);
$DisplayName = Artists::display_artists($ExtendedArtists, true, false);
} elseif (count($Artists) > 0) {
$DisplayName = Artists::display_artists(array('1'=>$Artists), true, false);
}
- if ($VanityHouse) $DisplayName .= ' [VH ]';
+ if ($VanityHouse) {
+ $DisplayName .= ' [VH ]';
+ }
return $DisplayName;
}
diff --git a/classes/permissions_form.php b/classes/permissions_form.php
index 206cb944..d401f8be 100644
--- a/classes/permissions_form.php
+++ b/classes/permissions_form.php
@@ -63,7 +63,7 @@
'users_give_donor' => 'Can give donor access.',
'users_warn' => 'Can warn users.',
'users_disable_users' => 'Can disable users.',
- 'users_disable_posts' => 'Can disable users\' posting rights.',
+ 'users_disable_posts' => 'Can disable users\' posting privileges.',
'users_disable_any' => 'Can disable any users\' rights.',
'users_delete_users' => 'Can delete users.',
'users_view_invites' => 'Can view who user has invited.',
@@ -193,7 +193,7 @@ function permissions_form() { ?>
display_perm('users_give_donor', 'Can give donor access.'); ?>
display_perm('users_warn', 'Can warn users.'); ?>
display_perm('users_disable_users', 'Can disable users.'); ?>
- display_perm('users_disable_posts', 'Can disable users\' posting rights.'); ?>
+ display_perm('users_disable_posts', 'Can disable users\' posting privileges.'); ?>
display_perm('users_disable_any', 'Can disable any users\' rights.'); ?>
display_perm('users_delete_users', 'Can delete anyone\'s account'); ?>
display_perm('users_view_invites', 'Can view who user has invited'); ?>
diff --git a/sections/ajax/announcements.php b/sections/ajax/announcements.php
index a76f57d7..2c92c4a6 100644
--- a/sections/ajax/announcements.php
+++ b/sections/ajax/announcements.php
@@ -1,20 +1,19 @@
-
-
include(SERVER_ROOT.'/classes/class_text.php');
$Text = new TEXT;
if (!$News = $Cache->get_value('news')) {
- $DB->query("SELECT
- ID,
- Title,
- Body,
- Time
+ $DB->query("
+ SELECT
+ ID,
+ Title,
+ Body,
+ Time
FROM news
ORDER BY Time DESC
LIMIT 5");
$News = $DB->to_array(false,MYSQLI_NUM,false);
- $Cache->cache_value('news',$News,3600*24*30);
+ $Cache->cache_value('news',$News,3600 * 24 * 30);
$Cache->cache_value('news_latest_id', $News[0][0], 0);
}
@@ -26,15 +25,17 @@
$LoggedUser['LastReadNews'] = $News[0][0];
}
-if(($Blog = $Cache->get_value('blog')) === false) {
- $DB->query("SELECT
- b.ID,
- um.Username,
- b.Title,
- b.Body,
- b.Time,
- b.ThreadID
- FROM blog AS b LEFT JOIN users_main AS um ON b.UserID=um.ID
+if (($Blog = $Cache->get_value('blog')) === false) {
+ $DB->query("
+ SELECT
+ b.ID,
+ um.Username,
+ b.Title,
+ b.Body,
+ b.Time,
+ b.ThreadID
+ FROM blog AS b
+ LEFT JOIN users_main AS um ON b.UserID=um.ID
ORDER BY Time DESC
LIMIT 20");
$Blog = $DB->to_array();
diff --git a/sections/ajax/better/single.php b/sections/ajax/better/single.php
index 5679df92..b6a67fd5 100644
--- a/sections/ajax/better/single.php
+++ b/sections/ajax/better/single.php
@@ -1,16 +1,19 @@
-if(($GroupIDs = $Cache->get_value('better_single_groupids')) === false) {
- $DB->query("SELECT t.ID AS TorrentID,
+if (($GroupIDs = $Cache->get_value('better_single_groupids')) === false) {
+ $DB->query("
+ SELECT
+ t.ID AS TorrentID,
t.GroupID AS GroupID
FROM xbt_files_users AS x
JOIN torrents AS t ON t.ID=x.fid
WHERE t.Format='FLAC'
GROUP BY x.fid
- HAVING COUNT(x.uid) = 1
- ORDER BY t.LogScore DESC, t.Time ASC LIMIT 30");
+ HAVING COUNT(x.uid) = 1
+ ORDER BY t.LogScore DESC, t.Time ASC
+ LIMIT 30");
$GroupIDs = $DB->to_array('GroupID');
- $Cache->cache_value('better_single_groupids', $GroupIDs, 30*60);
+ $Cache->cache_value('better_single_groupids', $GroupIDs, 30 * 60);
}
$Results = Torrents::get_groups(array_keys($GroupIDs));
@@ -23,7 +26,7 @@
$FlacID = $GroupIDs[$GroupID]['TorrentID'];
$JsonArtists = array();
- if(count($Artists)>0) {
+ if (count($Artists) > 0) {
foreach ($Artists as $Artist) {
$JsonArtists[] = array(
'id' => (int) $Artist['id'],
diff --git a/sections/ajax/better/transcode.php b/sections/ajax/better/transcode.php
index 761d21ec..a605d3bf 100644
--- a/sections/ajax/better/transcode.php
+++ b/sections/ajax/better/transcode.php
@@ -1,5 +1,5 @@
-if(!isset($_GET['type']) || !is_number($_GET['type']) || $_GET['type'] > 3) {
+if (!isset($_GET['type']) || !is_number($_GET['type']) || $_GET['type'] > 3) {
error(0);
}
@@ -11,7 +11,7 @@
$List = "!(v0 | v2 | 320)";
} else {
$List = '!'.$Options[$_GET['type']];
- if($_GET['type'] == 0) {
+ if ($_GET['type'] == 0) {
$_GET['type'] = '0';
} else {
$_GET['type'] = display_str($_GET['type']);
@@ -25,7 +25,7 @@
->where_match($List, 'encoding', false)
->order_by('RAND()')
->limit(0, TORRENTS_PER_PAGE, TORRENTS_PER_PAGE);
-if(!empty($_GET['search'])) {
+if (!empty($_GET['search'])) {
$SphQL->where_match($_GET['search'], '(groupname,artistname,year,taglist)');
}
diff --git a/sections/ajax/bookmarks/artists.php b/sections/ajax/bookmarks/artists.php
index b7045e84..cb9fcbe1 100644
--- a/sections/ajax/bookmarks/artists.php
+++ b/sections/ajax/bookmarks/artists.php
@@ -1,7 +1,7 @@
-if(!empty($_GET['userid'])) {
- if(!check_perms('users_override_paranoia')) {
+if (!empty($_GET['userid'])) {
+ if (!check_perms('users_override_paranoia')) {
print
json_encode(
array(
@@ -12,7 +12,7 @@
}
$UserID = $_GET['userid'];
$Sneaky = ($UserID != $LoggedUser['ID']);
- if(!is_number($UserID)) {
+ if (!is_number($UserID)) {
print
json_encode(
array(
@@ -31,15 +31,16 @@
//$ArtistList = Bookmarks::all_bookmarks('artist', $UserID);
-$DB->query('SELECT ag.ArtistID, ag.Name
+$DB->query('
+ SELECT ag.ArtistID, ag.Name
FROM bookmarks_artists AS ba
- INNER JOIN artists_group AS ag ON ba.ArtistID = ag.ArtistID
+ INNER JOIN artists_group AS ag ON ba.ArtistID = ag.ArtistID
WHERE ba.UserID = '.$UserID);
$ArtistList = $DB->to_array();
$JsonArtists = array();
-foreach($ArtistList as $Artist) {
+foreach ($ArtistList as $Artist) {
list($ArtistID, $Name) = $Artist;
$JsonArtists[] = array(
'artistId' => (int) $ArtistID,
diff --git a/sections/ajax/checkprivate.php b/sections/ajax/checkprivate.php
index a75c304d..9cacec26 100644
--- a/sections/ajax/checkprivate.php
+++ b/sections/ajax/checkprivate.php
@@ -9,7 +9,7 @@
}
$DB->query("SELECT File FROM torrents_files WHERE TorrentID='$TorrentID'");
-if($DB->record_count() == 0) {
+if ($DB->record_count() == 0) {
echo('Torrent not found.');
die();
}
diff --git a/sections/ajax/forum/index.php b/sections/ajax/forum/index.php
index cdfddf4b..65d3002e 100644
--- a/sections/ajax/forum/index.php
+++ b/sections/ajax/forum/index.php
@@ -21,34 +21,35 @@
}
//This variable contains all our lovely forum data
- if(!$Forums = $Cache->get_value('forums_list')) {
- $DB->query("SELECT
- f.ID,
- f.CategoryID,
- f.Name,
- f.Description,
- f.MinClassRead,
- f.MinClassWrite,
- f.MinClassCreate,
- f.NumTopics,
- f.NumPosts,
- f.LastPostID,
- f.LastPostAuthorID,
- f.LastPostTopicID,
- f.LastPostTime,
- COUNT(sr.ThreadID) AS SpecificRules,
- t.Title,
- t.IsLocked,
- t.IsSticky
+ if (!$Forums = $Cache->get_value('forums_list')) {
+ $DB->query("
+ SELECT
+ f.ID,
+ f.CategoryID,
+ f.Name,
+ f.Description,
+ f.MinClassRead,
+ f.MinClassWrite,
+ f.MinClassCreate,
+ f.NumTopics,
+ f.NumPosts,
+ f.LastPostID,
+ f.LastPostAuthorID,
+ f.LastPostTopicID,
+ f.LastPostTime,
+ COUNT(sr.ThreadID) AS SpecificRules,
+ t.Title,
+ t.IsLocked,
+ t.IsSticky
FROM forums AS f
- JOIN forums_categories AS fc ON fc.ID = f.CategoryID
- LEFT JOIN forums_topics as t ON t.ID = f.LastPostTopicID
- LEFT JOIN forums_specific_rules AS sr ON sr.ForumID = f.ID
+ JOIN forums_categories AS fc ON fc.ID = f.CategoryID
+ LEFT JOIN forums_topics as t ON t.ID = f.LastPostTopicID
+ LEFT JOIN forums_specific_rules AS sr ON sr.ForumID = f.ID
GROUP BY f.ID
ORDER BY fc.Sort, fc.Name, f.CategoryID, f.Sort");
$Forums = $DB->to_array('ID', MYSQLI_ASSOC, false);
- foreach($Forums as $ForumID => $Forum) {
- if(count($Forum['SpecificRules'])) {
+ foreach ($Forums as $ForumID => $Forum) {
+ if (count($Forum['SpecificRules'])) {
$DB->query("SELECT ThreadID FROM forums_specific_rules WHERE ForumID = ".$ForumID);
$ThreadIDs = $DB->collect('ThreadID');
$Forums[$ForumID]['SpecificRules'] = $ThreadIDs;
@@ -58,7 +59,7 @@
$Cache->cache_value('forums_list', $Forums, 0); //Inf cache.
}
- if(empty($_GET['type']) || $_GET['type'] == 'main') {
+ if (empty($_GET['type']) || $_GET['type'] == 'main') {
include(SERVER_ROOT.'/sections/ajax/forum/main.php');
} else {
switch ($_GET['type']) {
@@ -80,18 +81,19 @@
function get_forum_info($ForumID) {
global $DB, $Cache;
$Forum = $Cache->get_value('ForumInfo_'.$ForumID);
- if(!$Forum) {
- $DB->query("SELECT
- Name,
- MinClassRead,
- MinClassWrite,
- MinClassCreate,
- COUNT(forums_topics.ID) AS Topics
+ if (!$Forum) {
+ $DB->query("
+ SELECT
+ Name,
+ MinClassRead,
+ MinClassWrite,
+ MinClassCreate,
+ COUNT(forums_topics.ID) AS Topics
FROM forums
- LEFT JOIN forums_topics ON forums_topics.ForumID=forums.ID
+ LEFT JOIN forums_topics ON forums_topics.ForumID=forums.ID
WHERE forums.ID='$ForumID'
GROUP BY ForumID");
- if($DB->record_count() == 0) {
+ if ($DB->record_count() == 0) {
return false;
}
// Makes an array, with $Forum['Name'], etc.
diff --git a/sections/ajax/giveback_report.php b/sections/ajax/giveback_report.php
index c76f2095..1908ce03 100644
--- a/sections/ajax/giveback_report.php
+++ b/sections/ajax/giveback_report.php
@@ -1,15 +1,18 @@
-if(!check_perms('admin_reports')) {
+if (!check_perms('admin_reports')) {
error(403);
}
-if(!is_number($_GET['id'])) {
+if (!is_number($_GET['id'])) {
error(0);
}
$DB->query("SELECT Status FROM reportsv2 WHERE ID=".$_GET['id']);
list($Status) = $DB->next_record();
-if(isset($Status)) {
- $DB->query("UPDATE reportsv2 SET Status='New', ResolverID = 0 WHERE ID=".$_GET['id']);
+if (isset($Status)) {
+ $DB->query("
+ UPDATE reportsv2
+ SET Status='New', ResolverID = 0
+ WHERE ID=".$_GET['id']);
}
?>
diff --git a/sections/ajax/grab_report.php b/sections/ajax/grab_report.php
index 16521c4a..e527db12 100644
--- a/sections/ajax/grab_report.php
+++ b/sections/ajax/grab_report.php
@@ -1,16 +1,20 @@
-if(!check_perms('admin_reports')) {
+if (!check_perms('admin_reports')) {
error(403);
}
-if(!is_number($_GET['id'])) {
+if (!is_number($_GET['id'])) {
error(0);
}
-$DB->query("UPDATE reportsv2 SET Status='New' WHERE ID=".$_GET['id']." AND Status <> 'Resolved'");
-if($DB->affected_rows() > 0) {
+$DB->query("
+ UPDATE reportsv2
+ SET Status='New'
+ WHERE ID=".$_GET['id']."
+ AND Status <> 'Resolved'");
+if ($DB->affected_rows() > 0) {
//Win
} else {
- echo 'You just tried to grab a resolved or non existent report!';
+ echo 'You just tried to grab a resolved or non-existent report!';
}
?>
diff --git a/sections/ajax/inbox/inbox.php b/sections/ajax/inbox/inbox.php
index 2ac43576..8bf6316b 100644
--- a/sections/ajax/inbox/inbox.php
+++ b/sections/ajax/inbox/inbox.php
@@ -4,11 +4,12 @@
$UserID = $LoggedUser['ID'];
-if(empty($_GET['type'])) { $Section = 'inbox'; }
-else {
+if (empty($_GET['type'])) {
+ $Section = 'inbox';
+} else {
$Section = $_GET['type']; // either 'inbox' or 'sentbox'
}
-if(!in_array($Section, array('inbox', 'sentbox'))) {
+if (!in_array($Section, array('inbox', 'sentbox'))) {
print
json_encode(
array(
@@ -22,45 +23,46 @@
$Sort = empty($_GET['sort']) || $_GET['sort'] != "unread" ? "Date DESC" : "cu.Unread = '1' DESC, DATE DESC";
-$sql = "SELECT
- SQL_CALC_FOUND_ROWS
- c.ID,
- c.Subject,
- cu.Unread,
- cu.Sticky,
- cu.ForwardedTo,
- um2.Username AS ForwardedName,
- cu2.UserID,
- um.Username,
- ui.Donor,
- ui.Warned,
- um.Enabled,";
+$sql = "
+ SELECT
+ SQL_CALC_FOUND_ROWS
+ c.ID,
+ c.Subject,
+ cu.Unread,
+ cu.Sticky,
+ cu.ForwardedTo,
+ um2.Username AS ForwardedName,
+ cu2.UserID,
+ um.Username,
+ ui.Donor,
+ ui.Warned,
+ um.Enabled,";
$sql .= ($Section == 'sentbox')? ' cu.SentDate ' : ' cu.ReceivedDate ';
$sql .= "AS Date
FROM pm_conversations AS c
- LEFT JOIN pm_conversations_users AS cu ON cu.ConvID=c.ID AND cu.UserID='$UserID'
- LEFT JOIN pm_conversations_users AS cu2 ON cu2.ConvID=c.ID AND cu2.UserID!='$UserID' AND cu2.ForwardedTo=0
- LEFT JOIN users_main AS um ON um.ID=cu2.UserID
- LEFT JOIN users_info AS ui ON ui.UserID=um.ID
- LEFT JOIN users_main AS um2 ON um2.ID=cu.ForwardedTo";
+ LEFT JOIN pm_conversations_users AS cu ON cu.ConvID=c.ID AND cu.UserID='$UserID'
+ LEFT JOIN pm_conversations_users AS cu2 ON cu2.ConvID=c.ID AND cu2.UserID!='$UserID' AND cu2.ForwardedTo=0
+ LEFT JOIN users_main AS um ON um.ID=cu2.UserID
+ LEFT JOIN users_info AS ui ON ui.UserID=um.ID
+ LEFT JOIN users_main AS um2 ON um2.ID=cu.ForwardedTo";
-if(!empty($_GET['search']) && $_GET['searchtype'] == "message") {
+if (!empty($_GET['search']) && $_GET['searchtype'] == "message") {
$sql .= " JOIN pm_messages AS m ON c.ID=m.ConvID";
}
$sql .= " WHERE ";
-if(!empty($_GET['search'])) {
+if (!empty($_GET['search'])) {
$Search = db_string($_GET['search']);
- if($_GET['searchtype'] == "user") {
+ if ($_GET['searchtype'] == "user") {
$sql .= "um.Username LIKE '".$Search."' AND ";
- } elseif($_GET['searchtype'] == "subject") {
+ } elseif ($_GET['searchtype'] == "subject") {
$Words = explode(' ', $Search);
$sql .= "c.Subject LIKE '%".implode("%' AND c.Subject LIKE '%", $Words)."%' AND ";
- } elseif($_GET['searchtype'] == "message") {
+ } elseif ($_GET['searchtype'] == "message") {
$Words = explode(' ', $Search);
$sql .= "m.Body LIKE '%".implode("%' AND m.Body LIKE '%", $Words)."%' AND ";
}
}
-$sql .= ($Section == 'sentbox')? ' cu.InSentbox' : ' cu.InInbox';
+$sql .= ($Section == 'sentbox') ? ' cu.InSentbox' : ' cu.InInbox';
$sql .="='1'";
$sql .=" GROUP BY c.ID
@@ -71,16 +73,16 @@
$DB->set_query_id($Results);
$CurURL = Format::get_url(array('sort'));
-if(empty($CurURL)) {
+if (empty($CurURL)) {
$CurURL = "inbox.php?";
} else {
$CurURL = "inbox.php?".$CurURL."&";
}
-$Pages=Format::get_pages($Page,$NumResults,MESSAGES_PER_PAGE,9);
+$Pages = Format::get_pages($Page,$NumResults,MESSAGES_PER_PAGE,9);
$JsonMessages = array();
-while(list($ConvID, $Subject, $Unread, $Sticky, $ForwardedID, $ForwardedName, $SenderID, $Username, $Donor, $Warned, $Enabled, $Date) = $DB->next_record()) {
+while (list($ConvID, $Subject, $Unread, $Sticky, $ForwardedID, $ForwardedName, $SenderID, $Username, $Donor, $Warned, $Enabled, $Date) = $DB->next_record()) {
$JsonMessage = array(
'convId' => (int) $ConvID,
'subject' => $Subject,
@@ -104,9 +106,9 @@
'status' => 'success',
'response' => array(
'currentPage' => (int) $Page,
- 'pages' => ceil($NumResults/MESSAGES_PER_PAGE),
+ 'pages' => ceil($NumResults / MESSAGES_PER_PAGE),
'messages' => $JsonMessages
)
)
);
-?>
\ No newline at end of file
+?>
diff --git a/sections/ajax/inbox/viewconv.php b/sections/ajax/inbox/viewconv.php
index 3b680b2c..7d2608a9 100644
--- a/sections/ajax/inbox/viewconv.php
+++ b/sections/ajax/inbox/viewconv.php
@@ -3,7 +3,7 @@
$Text = new TEXT;
$ConvID = $_GET['id'];
-if(!$ConvID || !is_number($ConvID)) {
+if (!$ConvID || !is_number($ConvID)) {
print json_encode(array('status' => 'failure'));
die();
}
@@ -11,8 +11,12 @@
$UserID = $LoggedUser['ID'];
-$DB->query("SELECT InInbox, InSentbox FROM pm_conversations_users WHERE UserID='$UserID' AND ConvID='$ConvID'");
-if($DB->record_count() == 0) {
+$DB->query("
+ SELECT InInbox, InSentbox
+ FROM pm_conversations_users
+ WHERE UserID='$UserID'
+ AND ConvID='$ConvID'");
+if ($DB->record_count() == 0) {
print json_encode(array('status' => 'failure'));
die();
}
@@ -27,24 +31,27 @@
}
// Get information on the conversation
-$DB->query("SELECT
- c.Subject,
- cu.Sticky,
- cu.UnRead,
- cu.ForwardedTo,
- um.Username
+$DB->query("
+ SELECT
+ c.Subject,
+ cu.Sticky,
+ cu.UnRead,
+ cu.ForwardedTo,
+ um.Username
FROM pm_conversations AS c
- JOIN pm_conversations_users AS cu ON c.ID=cu.ConvID
- LEFT JOIN users_main AS um ON um.ID=cu.ForwardedTo
- WHERE c.ID='$ConvID' AND UserID='$UserID'");
+ JOIN pm_conversations_users AS cu ON c.ID=cu.ConvID
+ LEFT JOIN users_main AS um ON um.ID=cu.ForwardedTo
+ WHERE c.ID='$ConvID'
+ AND UserID='$UserID'");
list($Subject, $Sticky, $UnRead, $ForwardedID, $ForwardedName) = $DB->next_record();
-$DB->query("SELECT um.ID, Username
+$DB->query("
+ SELECT um.ID, Username
FROM pm_messages AS pm
- JOIN users_main AS um ON um.ID=pm.SenderID
+ JOIN users_main AS um ON um.ID=pm.SenderID
WHERE pm.ConvID='$ConvID'");
-while(list($PMUserID, $Username) = $DB->next_record()) {
+while (list($PMUserID, $Username) = $DB->next_record()) {
$PMUserID = (int)$PMUserID;
$Users[$PMUserID]['UserStr'] = Users::format_username($PMUserID, true, true, true, true);
$Users[$PMUserID]['Username'] = $Username;
@@ -54,18 +61,26 @@
-if($UnRead=='1') {
+if ($UnRead == '1') {
- $DB->query("UPDATE pm_conversations_users SET UnRead='0' WHERE ConvID='$ConvID' AND UserID='$UserID'");
+ $DB->query("
+ UPDATE pm_conversations_users
+ SET UnRead='0'
+ WHERE ConvID='$ConvID'
+ AND UserID='$UserID'");
// Clear the caches of the inbox and sentbox
$Cache->decrement('inbox_new_'.$UserID);
}
// Get messages
-$DB->query("SELECT SentDate, SenderID, Body, ID FROM pm_messages AS m WHERE ConvID='$ConvID' ORDER BY ID");
+$DB->query("
+ SELECT SentDate, SenderID, Body, ID
+ FROM pm_messages AS m
+ WHERE ConvID='$ConvID'
+ ORDER BY ID");
$JsonMessages = array();
-while(list($SentDate, $SenderID, $Body, $MessageID) = $DB->next_record()) {
+while (list($SentDate, $SenderID, $Body, $MessageID) = $DB->next_record()) {
$JsonMessage = array(
'messageId' => (int) $MessageID,
'senderId' => (int) $SenderID,
@@ -83,7 +98,7 @@
'status' => 'success',
'response' => array(
'convId' => (int) $ConvID,
- 'subject' => $Subject.($ForwardedID > 0 ? ' (Forwarded to '.$ForwardedName.')':''),
+ 'subject' => $Subject.($ForwardedID > 0 ? " (Forwarded to $ForwardedName)" : ''),
'sticky' => $Sticky == 1,
'messages' => $JsonMessages
)
diff --git a/sections/ajax/notifications.php b/sections/ajax/notifications.php
index 7dd05968..552c445f 100644
--- a/sections/ajax/notifications.php
+++ b/sections/ajax/notifications.php
@@ -1,32 +1,40 @@
-
-
-if(!check_perms('site_torrents_notify')) {
+if (!check_perms('site_torrents_notify')) {
json_die("failure");
}
define('NOTIFICATIONS_PER_PAGE', 50);
list($Page,$Limit) = Format::page_limit(NOTIFICATIONS_PER_PAGE);
-$Results = $DB->query("SELECT SQL_CALC_FOUND_ROWS unt.TorrentID, unt.UnRead, unt.FilterID, unf.Label, t.GroupID
+$Results = $DB->query("
+ SELECT SQL_CALC_FOUND_ROWS
+ unt.TorrentID,
+ unt.UnRead,
+ unt.FilterID,
+ unf.Label,
+ t.GroupID
FROM users_notify_torrents AS unt
- JOIN torrents AS t ON t.ID = unt.TorrentID
- LEFT JOIN users_notify_filters AS unf ON unf.ID = unt.FilterID
+ JOIN torrents AS t ON t.ID = unt.TorrentID
+ LEFT JOIN users_notify_filters AS unf ON unf.ID = unt.FilterID
WHERE unt.UserID=$LoggedUser[ID]".
((!empty($_GET['filterid']) && is_number($_GET['filterid']))
? " AND unf.ID='$_GET[filterid]'"
- : "")."
- ORDER BY TorrentID DESC LIMIT $Limit");
+ : '')."
+ ORDER BY TorrentID DESC
+ LIMIT $Limit");
$GroupIDs = array_unique($DB->collect('GroupID'));
$DB->query('SELECT FOUND_ROWS()');
list($TorrentCount) = $DB->next_record();
-if(count($GroupIDs)) {
+if (count($GroupIDs)) {
$TorrentGroups = Torrents::get_groups($GroupIDs);
$TorrentGroups = $TorrentGroups['matches'];
- $DB->query("UPDATE users_notify_torrents SET UnRead='0' WHERE UserID=".$LoggedUser['ID']);
+ $DB->query("
+ UPDATE users_notify_torrents
+ SET UnRead='0'
+ WHERE UserID=".$LoggedUser['ID']);
$Cache->delete_value('notifications_new_'.$LoggedUser['ID']);
}
@@ -36,11 +44,11 @@
$NumNew = 0;
$FilterGroups = array();
-while($Result = $DB->next_record(MYSQLI_ASSOC)) {
- if(!$Result['FilterID']) {
+while ($Result = $DB->next_record(MYSQLI_ASSOC)) {
+ if (!$Result['FilterID']) {
$Result['FilterID'] = 0;
}
- if(!isset($FilterGroups[$Result['FilterID']])) {
+ if (!isset($FilterGroups[$Result['FilterID']])) {
$FilterGroups[$Result['FilterID']] = array();
$FilterGroups[$Result['FilterID']]['FilterLabel'] = $Result['Label'] ? $Result['Label'] : false;
}
@@ -48,9 +56,9 @@
}
unset($Result);
-foreach($FilterGroups as $FilterID => $FilterResults) {
+foreach ($FilterGroups as $FilterID => $FilterResults) {
unset($FilterResults['FilterLabel']);
- foreach($FilterResults as $Result) {
+ foreach ($FilterResults as $Result) {
$TorrentID = $Result['TorrentID'];
// $GroupID = $Result['GroupID'];
@@ -58,7 +66,9 @@
extract(Torrents::array_group($GroupInfo)); // all group data
$TorrentInfo = $GroupInfo['Torrents'][$TorrentID];
- if ($Result['UnRead'] == 1) $NumNew++;
+ if ($Result['UnRead'] == 1) {
+ $NumNew++;
+ }
$JsonNotifications[] = array(
'torrentId' => (int) $TorrentID,
@@ -95,4 +105,4 @@
'pages' => ceil($TorrentCount / NOTIFICATIONS_PER_PAGE),
'numNew' => $NumNew,
'results' => $JsonNotifications
-));
\ No newline at end of file
+));
diff --git a/sections/ajax/preview.php b/sections/ajax/preview.php
index 2ec6b0ab..446a2809 100644
--- a/sections/ajax/preview.php
+++ b/sections/ajax/preview.php
@@ -4,7 +4,7 @@
include(SERVER_ROOT.'/classes/class_text.php'); // Text formatting class
$Text = new TEXT(true);
-if(!empty($_POST['AdminComment'])) {
+if (!empty($_POST['AdminComment'])) {
echo $Text->full_format($_POST['AdminComment']);
} else {
$Content = $_REQUEST['body']; // Don't use URL decode.
diff --git a/sections/ajax/request.php b/sections/ajax/request.php
index adc78b29..e6f38e49 100644
--- a/sections/ajax/request.php
+++ b/sections/ajax/request.php
@@ -16,7 +16,7 @@
include(SERVER_ROOT.'/classes/class_text.php');
$Text = new TEXT;
-if(empty($_GET['id']) || !is_number($_GET['id'])) {
+if (empty($_GET['id']) || !is_number($_GET['id'])) {
json_die("failure");
}
@@ -26,7 +26,7 @@
$Request = Requests::get_requests(array($RequestID));
$Request = $Request['matches'][$RequestID];
-if(empty($Request)) {
+if (empty($Request)) {
json_die("failure");
}
diff --git a/sections/ajax/requests.php b/sections/ajax/requests.php
index dd78c0cd..960dc821 100644
--- a/sections/ajax/requests.php
+++ b/sections/ajax/requests.php
@@ -43,7 +43,7 @@
}
break;
case 'filled':
- if(empty($_GET['userid']) || !is_number($_GET['userid'])) {
+ if (empty($_GET['userid']) || !is_number($_GET['userid'])) {
json_die("failure");
} else {
if (!check_paranoia('requestsfilled_list', $UserInfo['Paranoia'], $Perms['Class'], $_GET['userid'])) {
@@ -314,13 +314,13 @@
$VoteCount = count($RequestVotes['Voters']);
if ($CategoryID == 0) {
- $CategoryName = "Unknown";
+ $CategoryName = 'Unknown';
} else {
$CategoryName = $Categories[$CategoryID - 1];
}
$JsonArtists = array();
- if ($CategoryName == "Music") {
+ if ($CategoryName == 'Music') {
$ArtistForm = get_request_artists($RequestID);
$JsonArtists = array_values($ArtistForm);
}
@@ -350,9 +350,9 @@
'logCue' => $LogCue,
'isFilled' => ($TorrentID > 0),
'fillerId' => (int) $FillerID,
- 'fillerName' => $FillerName == 0 ? "" : $FillerName,
+ 'fillerName' => $FillerName == 0 ? '' : $FillerName,
'torrentId' => (int) $TorrentID,
- 'timeFilled' => $TimeFilled == 0 ? "" : $TimeFilled
+ 'timeFilled' => $TimeFilled == 0 ? '' : $TimeFilled
);
}
json_die("success", array(
diff --git a/sections/ajax/stats.php b/sections/ajax/stats.php
index bb3da2fd..13d3c71e 100644
--- a/sections/ajax/stats.php
+++ b/sections/ajax/stats.php
@@ -1,5 +1,5 @@
-if(in_array($_GET['stat'], array('inbox', 'uploads', 'bookmarks', 'notifications', 'subscriptions', 'comments', 'friends'))) {
+if (in_array($_GET['stat'], array('inbox', 'uploads', 'bookmarks', 'notifications', 'subscriptions', 'comments', 'friends'))) {
$Cache->begin_transaction('stats_links');
$Cache->update_row(false, array($_GET['stat'] => '+1'));
$Cache->commit_transaction(0);
diff --git a/sections/ajax/tcomments.php b/sections/ajax/tcomments.php
index 8608b313..f5a9ca0d 100644
--- a/sections/ajax/tcomments.php
+++ b/sections/ajax/tcomments.php
@@ -7,17 +7,22 @@
$GroupID=ceil($_GET['id']);
$Results = $Cache->get_value('torrent_comments_'.$GroupID);
-if($Results === false) {
- $DB->query("SELECT
+if ($Results === false) {
+ $DB->query("
+ SELECT
COUNT(c.ID)
- FROM torrents_comments as c
- WHERE c.GroupID = '$GroupID'");
+ FROM torrents_comments as c
+ WHERE c.GroupID = '$GroupID'");
list($Results) = $DB->next_record();
$Cache->cache_value('torrent_comments_'.$GroupID, $Results, 0);
}
-if(isset($_GET['postid']) && is_number($_GET['postid']) && $Results > TORRENT_COMMENTS_PER_PAGE) {
- $DB->query("SELECT COUNT(ID) FROM torrents_comments WHERE GroupID = $GroupID AND ID <= $_GET[postid]");
+if (isset($_GET['postid']) && is_number($_GET['postid']) && $Results > TORRENT_COMMENTS_PER_PAGE) {
+ $DB->query("
+ SELECT COUNT(ID)
+ FROM torrents_comments
+ WHERE GroupID = $GroupID
+ AND ID <= $_GET[postid]");
list($PostNum) = $DB->next_record();
list($Page,$Limit) = Format::page_limit(TORRENT_COMMENTS_PER_PAGE,$PostNum);
} else {
@@ -25,15 +30,16 @@
}
//Get the cache catalogue
-$CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE*$Page-TORRENT_COMMENTS_PER_PAGE)/THREAD_CATALOGUE);
-$CatalogueLimit=$CatalogueID*THREAD_CATALOGUE . ', ' . THREAD_CATALOGUE;
+$CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE * $Page - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
+$CatalogueLimit = $CatalogueID * THREAD_CATALOGUE . ', ' . THREAD_CATALOGUE;
//---------- Get some data to start processing
// Cache catalogue from which the page is selected, allows block caches and future ability to specify posts per page
$Catalogue = $Cache->get_value('torrent_comments_'.$GroupID.'_catalogue_'.$CatalogueID);
-if($Catalogue === false) {
- $DB->query("SELECT
+if ($Catalogue === false) {
+ $DB->query("
+ SELECT
c.ID,
c.AuthorID,
c.AddedTime,
@@ -41,17 +47,17 @@
c.EditedUserID,
c.EditedTime,
u.Username
- FROM torrents_comments as c
+ FROM torrents_comments as c
LEFT JOIN users_main AS u ON u.ID=c.EditedUserID
- WHERE c.GroupID = '$GroupID'
- ORDER BY c.ID
- LIMIT $CatalogueLimit");
+ WHERE c.GroupID = '$GroupID'
+ ORDER BY c.ID
+ LIMIT $CatalogueLimit");
$Catalogue = $DB->to_array(false,MYSQLI_ASSOC);
$Cache->cache_value('torrent_comments_'.$GroupID.'_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);
//---------- Begin printing
$JsonComments = array();
diff --git a/sections/ajax/top10/tags.php b/sections/ajax/top10/tags.php
index 20745edd..4ed5ce64 100644
--- a/sections/ajax/top10/tags.php
+++ b/sections/ajax/top10/tags.php
@@ -2,8 +2,8 @@
// error out on invalid requests (before caching)
-if(isset($_GET['details'])) {
- if(in_array($_GET['details'],array('ut','ur','v'))) {
+if (isset($_GET['details'])) {
+ if (in_array($_GET['details'],array('ut','ur','v'))) {
$Details = $_GET['details'];
} else {
print json_encode(array('status' => 'failure'));
@@ -20,19 +20,20 @@
if ($Details == 'all' || $Details == 'ut') {
if (!$TopUsedTags = $Cache->get_value('topusedtag_'.$Limit)) {
- $DB->query("SELECT
- t.ID,
- t.Name,
- COUNT(tt.GroupID) AS Uses,
- SUM(tt.PositiveVotes-1) AS PosVotes,
- SUM(tt.NegativeVotes-1) AS NegVotes
+ $DB->query("
+ SELECT
+ t.ID,
+ t.Name,
+ COUNT(tt.GroupID) AS Uses,
+ SUM(tt.PositiveVotes-1) AS PosVotes,
+ SUM(tt.NegativeVotes-1) AS NegVotes
FROM tags AS t
- JOIN torrents_tags AS tt ON tt.TagID=t.ID
+ JOIN torrents_tags AS tt ON tt.TagID=t.ID
GROUP BY tt.TagID
ORDER BY Uses DESC
LIMIT $Limit");
$TopUsedTags = $DB->to_array();
- $Cache->cache_value('topusedtag_'.$Limit,$TopUsedTags,3600*12);
+ $Cache->cache_value('topusedtag_'.$Limit,$TopUsedTags,3600 * 12);
}
$OuterResults[] = generate_tag_json('Most Used Torrent Tags', 'ut', $TopUsedTags, $Limit);
@@ -40,18 +41,19 @@
if ($Details == 'all' || $Details == 'ur') {
if (!$TopRequestTags = $Cache->get_value('toprequesttag_'.$Limit)) {
- $DB->query("SELECT
- t.ID,
- t.Name,
- COUNT(r.RequestID) AS Uses,
- '',''
+ $DB->query("
+ SELECT
+ t.ID,
+ t.Name,
+ COUNT(r.RequestID) AS Uses,
+ '',''
FROM tags AS t
- JOIN requests_tags AS r ON r.TagID=t.ID
+ JOIN requests_tags AS r ON r.TagID=t.ID
GROUP BY r.TagID
ORDER BY Uses DESC
LIMIT $Limit");
$TopRequestTags = $DB->to_array();
- $Cache->cache_value('toprequesttag_'.$Limit,$TopRequestTags,3600*12);
+ $Cache->cache_value('toprequesttag_'.$Limit,$TopRequestTags,3600 * 12);
}
$OuterResults[] = generate_tag_json('Most Used Request Tags', 'ur', $TopRequestTags, $Limit);
@@ -59,19 +61,20 @@
if ($Details == 'all' || $Details == 'v') {
if (!$TopVotedTags = $Cache->get_value('topvotedtag_'.$Limit)) {
- $DB->query("SELECT
- t.ID,
- t.Name,
- COUNT(tt.GroupID) AS Uses,
- SUM(tt.PositiveVotes-1) AS PosVotes,
- SUM(tt.NegativeVotes-1) AS NegVotes
+ $DB->query("
+ SELECT
+ t.ID,
+ t.Name,
+ COUNT(tt.GroupID) AS Uses,
+ SUM(tt.PositiveVotes-1) AS PosVotes,
+ SUM(tt.NegativeVotes-1) AS NegVotes
FROM tags AS t
- JOIN torrents_tags AS tt ON tt.TagID=t.ID
+ JOIN torrents_tags AS tt ON tt.TagID=t.ID
GROUP BY tt.TagID
ORDER BY PosVotes DESC
LIMIT $Limit");
$TopVotedTags = $DB->to_array();
- $Cache->cache_value('topvotedtag_'.$Limit,$TopVotedTags,3600*12);
+ $Cache->cache_value('topvotedtag_'.$Limit,$TopVotedTags,3600 * 12);
}
$OuterResults[] = generate_tag_json('Most Highly Voted Tags', 'v', $TopVotedTags, $Limit);
diff --git a/sections/api/index.php b/sections/api/index.php
index 2978ea89..b7e0bc04 100644
--- a/sections/api/index.php
+++ b/sections/api/index.php
@@ -2,7 +2,6 @@
$Available = array(
'access_request',
'access_state',
-
'user_stats_ratio',
'user_stats_torrent',
'user_stats_comumnity',
@@ -25,7 +24,7 @@
$UserID = $_GET['uid'];
$App = $Cache->get_value('api_apps_'.$AppID);
-if(!is_array($App)) {
+if (!is_array($App)) {
if (!isset($DB)) {
require(SERVER_ROOT.'/classes/class_mysql.php');
$DB = new DB_MYSQL;
@@ -43,12 +42,16 @@
}
} else {
$User = $Cache->get_value('api_users_'.$UserID);
- if(!is_array($User)) {
+ if (!is_array($User)) {
if (!isset($DB)) {
require(SERVER_ROOT.'/classes/class_mysql.php');
$DB = new DB_MYSQL;
}
- $DB->query("SELECT AppID, Token, State, Time, Access FROM api_users WHERE UserID='$UserID' LIMIT 1"); //int, no db_string
+ $DB->query("
+ SELECT AppID, Token, State, Time, Access
+ FROM api_users
+ WHERE UserID='$UserID'
+ LIMIT 1"); //int, no db_string
$User = $DB->to_array('AppID',MYSQLI_ASSOC);
$Cache->cache_value('api_users_'.$UserID, $User, 0);
}
diff --git a/sections/artist/add_alias.php b/sections/artist/add_alias.php
index 05d191ac..00ece71d 100644
--- a/sections/artist/add_alias.php
+++ b/sections/artist/add_alias.php
@@ -1,18 +1,22 @@
authorize();
-if(!check_perms('torrents_edit')) { error(403); }
+if (!check_perms('torrents_edit')) {
+ error(403);
+}
$ArtistID = $_POST['artistid'];
$Redirect = $_POST['redirect'];
$AliasName = Artists::normalise_artist_name($_POST['name']);
$DBAliasName = db_string($AliasName);
-if(!$Redirect) { $Redirect = 0; }
+if (!$Redirect) {
+ $Redirect = 0;
+}
-if(!is_number($ArtistID) || !($Redirect === 0 || is_number($Redirect)) || !$ArtistID) {
+if (!is_number($ArtistID) || !($Redirect === 0 || is_number($Redirect)) || !$ArtistID) {
error(0);
}
-if($AliasName == '') {
+if ($AliasName == '') {
error('Blank artist name.');
}
@@ -24,17 +28,23 @@
* 3. For foo, there's two, same ArtistID, diff names, no redirect
*/
-$DB->query("SELECT AliasID, ArtistID, Name, Redirect FROM artists_alias WHERE Name = '".$DBAliasName."'");
-if($DB->record_count()) {
- while(list($CloneAliasID, $CloneArtistID, $CloneAliasName, $CloneRedirect) = $DB->next_record(MYSQLI_NUM, false)) {
- if(!strcasecmp($CloneAliasName, $AliasName)) {
+$DB->query("
+ SELECT AliasID, ArtistID, Name, Redirect
+ FROM artists_alias
+ WHERE Name = '".$DBAliasName."'");
+if ($DB->record_count()) {
+ while (list($CloneAliasID, $CloneArtistID, $CloneAliasName, $CloneRedirect) = $DB->next_record(MYSQLI_NUM, false)) {
+ if (!strcasecmp($CloneAliasName, $AliasName)) {
break;
}
}
- if($CloneAliasID) {
- if($ArtistID == $CloneArtistID && $Redirect == 0) {
- if($CloneRedirect != 0) {
- $DB->query("UPDATE artists_alias SET ArtistID='".$ArtistID."', Redirect=0 WHERE AliasID='".$CloneAliasID."'");
+ if ($CloneAliasID) {
+ if ($ArtistID == $CloneArtistID && $Redirect == 0) {
+ if ($CloneRedirect != 0) {
+ $DB->query("
+ UPDATE artists_alias
+ SET ArtistID='".$ArtistID."', Redirect=0
+ WHERE AliasID='".$CloneAliasID."'");
Misc::write_log("Redirection for the alias $CloneAliasID ($DBAliasName) for the artist $ArtistID was removed by user $LoggedUser[ID] ($LoggedUser[Username])");
} else {
error('No changes were made as the target alias did not redirect anywhere.');
@@ -44,29 +54,29 @@
}
}
}
-if(!$CloneAliasID) {
- if($Redirect) {
+if (!$CloneAliasID) {
+ if ($Redirect) {
$DB->query("SELECT ArtistID, Redirect FROM artists_alias WHERE AliasID = $Redirect");
- if(!$DB->record_count()) {
+ if (!$DB->record_count()) {
error('Cannot redirect to a nonexistent artist alias.');
}
list($FoundArtistID, $FoundRedirect) = $DB->next_record();
- if($ArtistID != $FoundArtistID) {
+ if ($ArtistID != $FoundArtistID) {
error('Redirection must target an alias for the current artist.');
}
- if($FoundRedirect != 0) {
+ if ($FoundRedirect != 0) {
$Redirect = $FoundRedirect;
}
}
- $DB->query("INSERT INTO artists_alias(ArtistID, Name, Redirect, UserID)
- VALUES
- (".$ArtistID.", '".$DBAliasName."', ".$Redirect.", ".$LoggedUser['ID'].")");
+ $DB->query("
+ INSERT INTO artists_alias(ArtistID, Name, Redirect, UserID)
+ VALUES ($ArtistID, '$DBAliasName', $Redirect, ".$LoggedUser['ID'].')');
$AliasID = $DB->inserted_id();
$DB->query("SELECT Name FROM artists_group WHERE ArtistID = ".$ArtistID);
list($ArtistName) = $DB->next_record(MYSQLI_NUM, false);
- Misc::write_log("The alias ".$AliasID." (".$DBAliasName.") was added to the artist ".$ArtistID." (".db_string($ArtistName).") by user ".$LoggedUser['ID']." (".$LoggedUser['Username'].")");
+ Misc::write_log("The alias $AliasID ($DBAliasName) was added to the artist $ArtistID (".db_string($ArtistName).") by user ".$LoggedUser['ID'].' ('.$LoggedUser['Username'].')');
}
header('Location: '.$_SERVER['HTTP_REFERER']);
?>
diff --git a/sections/artist/autocomplete.php b/sections/artist/autocomplete.php
index 24155278..519e7ab0 100644
--- a/sections/artist/autocomplete.php
+++ b/sections/artist/autocomplete.php
@@ -2,7 +2,9 @@
header('Content-type: application/x-suggestions+json');
require('classes/ajax_start.php');
-if(empty($_GET['name'])) { die('["",[],[],[]]'); }
+if (empty($_GET['name'])) {
+ die('["",[],[],[]]');
+}
$FullName = rawurldecode($_GET['name']);
@@ -14,25 +16,26 @@
$Letters = strtolower(substr($FullName,0,$KeySize));
$AutoSuggest = $Cache->get('autocomplete_artist_'.$KeySize.'_'.$Letters);
-if(!is_array($AutoSuggest)) {
- if(!isset($DB) || !is_object($DB)) {
+if (!is_array($AutoSuggest)) {
+ if (!isset($DB) || !is_object($DB)) {
require(SERVER_ROOT.'/classes/class_mysql.php'); //Require the database wrapper
$DB=NEW DB_MYSQL; //Load the database wrapper
}
- $Limit = (($KeySize === $MaxKeySize)?250:10);
- $DB->query("SELECT
- a.ArtistID,
- a.Name,
- SUM(t.Snatched) AS Snatches
+ $Limit = (($KeySize === $MaxKeySize) ? 250 : 10);
+ $DB->query("
+ SELECT
+ a.ArtistID,
+ a.Name,
+ SUM(t.Snatched) AS Snatches
FROM artists_group AS a
- INNER JOIN torrents_artists AS ta ON ta.ArtistID=a.ArtistID
- INNER JOIN torrents AS t ON t.GroupID=ta.GroupID
+ INNER JOIN torrents_artists AS ta ON ta.ArtistID=a.ArtistID
+ INNER JOIN torrents AS t ON t.GroupID=ta.GroupID
WHERE a.Name LIKE '".db_string(str_replace('\\','\\\\',$Letters),true)."%'
GROUP BY ta.ArtistID
ORDER BY Snatches DESC
LIMIT $Limit");
$AutoSuggest = $DB->to_array(false,MYSQLI_NUM,false);
- $Cache->cache_value('autocomplete_artist_'.$KeySize.'_'.$Letters,$AutoSuggest,1800+7200*($MaxKeySize-$KeySize)); // Can't cache things for too long in case names are edited
+ $Cache->cache_value('autocomplete_artist_'.$KeySize.'_'.$Letters,$AutoSuggest,1800 + 7200 * ($MaxKeySize - $KeySize)); // Can't cache things for too long in case names are edited
}
$Matched = 0;
diff --git a/sections/artist/change_artistid.php b/sections/artist/change_artistid.php
index 20bc7a5d..1d2a9890 100644
--- a/sections/artist/change_artistid.php
+++ b/sections/artist/change_artistid.php
@@ -1,9 +1,11 @@
authorize();
-if (!check_perms('torrents_edit')) { error(403); }
+if (!check_perms('torrents_edit')) {
+ error(403);
+}
if (!empty($_POST['newartistid']) && !empty($_POST['newartistname'])) {
- error("Please enter a valid artist ID number or a valid artist name.");
+ error('Please enter a valid artist ID number or a valid artist name.');
}
$ArtistID = (int)$_POST['artistid'];
$NewArtistID = (int)$_POST['newartistid'];
@@ -18,20 +20,20 @@
}
$DB->query("SELECT Name FROM artists_group WHERE ArtistID = $ArtistID LIMIT 1");
-if(!(list($ArtistName) = $DB->next_record(MYSQLI_NUM, false))) {
+if (!(list($ArtistName) = $DB->next_record(MYSQLI_NUM, false))) {
error('An error has occured.');
}
if ($NewArtistID > 0) {
// Make sure that's a real artist ID number, and grab the name
$DB->query("SELECT Name FROM artists_group WHERE ArtistID = $NewArtistID LIMIT 1");
- if(!(list($NewArtistName) = $DB->next_record())) {
+ if (!(list($NewArtistName) = $DB->next_record())) {
error('Please enter a valid artist ID number.');
}
} else {
// Didn't give an ID, so try to grab based on the name
$DB->query("SELECT ArtistID FROM artists_alias WHERE Name = '".db_string($NewArtistName)."' LIMIT 1");
- if(!(list($NewArtistID) = $DB->next_record())) {
+ if (!(list($NewArtistID) = $DB->next_record())) {
error('No artist by that name was found.');
}
}
@@ -47,10 +49,11 @@
$Requests = $DB->collect('RequestID');
$DB->query("SELECT DISTINCT UserID FROM bookmarks_artists WHERE ArtistID = $ArtistID");
$BookmarkUsers = $DB->collect('UserID');
- $DB->query("SELECT DISTINCT ct.CollageID
- FROM collages_torrents AS ct
- JOIN torrents_artists AS ta ON ta.GroupID = ct.GroupID
- WHERE ta.ArtistID = $ArtistID");
+ $DB->query("
+ SELECT DISTINCT ct.CollageID
+ FROM collages_torrents AS ct
+ JOIN torrents_artists AS ta ON ta.GroupID = ct.GroupID
+ WHERE ta.ArtistID = $ArtistID");
$Collages = $DB->collect('CollageID');
// And the info to avoid double-listing an artist if it and the target are on the same group
@@ -70,42 +73,51 @@
$NewArtistBookmarks = implode(',',$NewArtistBookmarks);
// Merge all of this artist's aliases onto the new artist
- $DB->query("UPDATE artists_alias SET ArtistID = $NewArtistID WHERE ArtistID = $ArtistID");
+ $DB->query("
+ UPDATE artists_alias
+ SET ArtistID = $NewArtistID
+ WHERE ArtistID = $ArtistID");
// Update the torrent groups, requests, and bookmarks
- $DB->query("UPDATE IGNORE torrents_artists SET ArtistID = $NewArtistID
- WHERE ArtistID = $ArtistID
- AND GroupID NOT IN ($NewArtistGroups)");
+ $DB->query("
+ UPDATE IGNORE torrents_artists
+ SET ArtistID = $NewArtistID
+ WHERE ArtistID = $ArtistID
+ AND GroupID NOT IN ($NewArtistGroups)");
$DB->query("DELETE FROM torrents_artists WHERE ArtistID = $ArtistID");
- $DB->query("UPDATE IGNORE requests_artists SET ArtistID = $NewArtistID
- WHERE ArtistID = $ArtistID
- AND RequestID NOT IN ($NewArtistRequests)");
+ $DB->query("
+ UPDATE IGNORE requests_artists
+ SET ArtistID = $NewArtistID
+ WHERE ArtistID = $ArtistID
+ AND RequestID NOT IN ($NewArtistRequests)");
$DB->query("DELETE FROM requests_artists WHERE ArtistID = $ArtistID");
- $DB->query("UPDATE IGNORE bookmarks_artists SET ArtistID = $NewArtistID
- WHERE ArtistID = $ArtistID
- AND UserID NOT IN ($NewArtistBookmarks)");
+ $DB->query("
+ UPDATE IGNORE bookmarks_artists
+ SET ArtistID = $NewArtistID
+ WHERE ArtistID = $ArtistID
+ AND UserID NOT IN ($NewArtistBookmarks)");
$DB->query("DELETE FROM bookmarks_artists WHERE ArtistID = $ArtistID");
// Cache clearing
- if(!empty($Groups)) {
- foreach($Groups as $GroupID) {
+ if (!empty($Groups)) {
+ foreach ($Groups as $GroupID) {
$Cache->delete_value('groups_artists_'.$GroupID);
Torrents::update_hash($GroupID);
}
}
- if(!empty($Requests)) {
- foreach($Requests as $RequestID) {
+ if (!empty($Requests)) {
+ foreach ($Requests as $RequestID) {
$Cache->delete_value('request_artist_'.$RequestID);
Requests::update_sphinx_requests($RequestID);
}
}
- if(!empty($BookmarkUsers)) {
- foreach($BookmarkUsers as $UserID) {
+ if (!empty($BookmarkUsers)) {
+ foreach ($BookmarkUsers as $UserID) {
$Cache->delete_value('notify_artists_'.$UserID);
}
}
- if(!empty($Collages)) {
- foreach($Collages as $CollageID) {
+ if (!empty($Collages)) {
+ foreach ($Collages as $CollageID) {
$Cache->delete_value('collage_'.$CollageID);
}
}
@@ -118,7 +130,7 @@
// Delete the old artist
$DB->query("DELETE FROM artists_group WHERE ArtistID = $ArtistID");
- Misc::write_log("The artist ".$ArtistID." (".$ArtistName.") was made into a non-redirecting alias of artist ".$NewArtistID." (".$NewArtistName.") by user ".$LoggedUser['ID']." (".$LoggedUser['Username'].")");
+ Misc::write_log("The artist $ArtistID ($ArtistName) was made into a non-redirecting alias of artist $NewArtistID ($NewArtistName) by user ".$LoggedUser['ID']." (".$LoggedUser['Username'].')');
header("Location: artist.php?action=edit&artistid=$NewArtistID");
} else {
diff --git a/sections/artist/delete.php b/sections/artist/delete.php
index 947dcdf5..4d75a37a 100644
--- a/sections/artist/delete.php
+++ b/sections/artist/delete.php
@@ -10,22 +10,26 @@
authorize();
$ArtistID = $_GET['artistid'];
-if(!is_number($ArtistID) || empty($ArtistID)) { error(0); }
+if (!is_number($ArtistID) || empty($ArtistID)) {
+ error(0);
+}
-if(!check_perms('site_delete_artist') || !check_perms('torrents_delete')) { error(403); }
+if (!check_perms('site_delete_artist') || !check_perms('torrents_delete')) {
+ error(403);
+}
View::show_header('Artist deleted');
$DB->query('SELECT Name FROM artists_group WHERE ArtistID='.$ArtistID);
list($Name) = $DB->next_record();
-$DB->query('SELECT tg.Name,
- tg.ID
- FROM torrents_group AS tg
- LEFT JOIN torrents_artists AS ta ON ta.GroupID=tg.ID
- WHERE ta.ArtistID='.$ArtistID);
+$DB->query('
+ SELECT tg.Name, tg.ID
+ FROM torrents_group AS tg
+ LEFT JOIN torrents_artists AS ta ON ta.GroupID=tg.ID
+ WHERE ta.ArtistID='.$ArtistID);
$Count = $DB->record_count();
-if($DB->record_count() > 0) {
+if ($DB->record_count() > 0) {
?>
There are still torrents that have
=$Name?> as an artist.
@@ -33,7 +37,7 @@
- while(list($GroupName, $GroupID) = $DB->next_record(MYSQLI_NUM, true)) {
+ while (list($GroupName, $GroupID) = $DB->next_record(MYSQLI_NUM, true)) {
?>
=$GroupName?>
@@ -47,13 +51,13 @@
}
-$DB->query('SELECT r.Title,
- r.ID
- FROM requests AS r
- LEFT JOIN requests_artists AS ra ON ra.RequestID=r.ID
- WHERE ra.ArtistID='.$ArtistID);
+$DB->query('
+ SELECT r.Title, r.ID
+ FROM requests AS r
+ LEFT JOIN requests_artists AS ra ON ra.RequestID=r.ID
+ WHERE ra.ArtistID='.$ArtistID);
$Count += $DB->record_count();
-if($DB->record_count() > 0) {
+if ($DB->record_count() > 0) {
?>
There are still requests that have
=$Name?> as an artist.
@@ -61,7 +65,7 @@
- if(check_perms('torrents_edit')) { ?>
+ if (check_perms('torrents_edit')) { ?>
Rename