From 2ddca2c7b40987367109b2d1f4da11ead88659eb Mon Sep 17 00:00:00 2001 From: "What.CD" Date: Sun, 22 May 2011 08:00:06 +0000 Subject: [PATCH] Prevent the merging of non-music groups Include empty values in cache debug table Clear cache when replying to staff pm --- classes/class_cache.php | 2 +- design/privateheader.php | 1 - sections/staffpm/takepost.php | 1 + sections/torrents/editgroupid.php | 9 ++++++--- sections/torrents/merge.php | 9 +++++---- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/classes/class_cache.php b/classes/class_cache.php index 620a354d..3b4fdc8d 100644 --- a/classes/class_cache.php +++ b/classes/class_cache.php @@ -107,7 +107,7 @@ public function get_value($Key, $NoCache=false) { } $Return = $this->get($Key); - if ($Return && !$NoCache) { + if ($Return !== false && !$NoCache) { $this->CacheHits[$Key] = $Return; } $this->Time+=(microtime(true)-$StartTime)*1000; diff --git a/design/privateheader.php b/design/privateheader.php index 7848a6b8..7f77b41d 100644 --- a/design/privateheader.php +++ b/design/privateheader.php @@ -234,7 +234,6 @@ $ModBar[] = ''.$NumStaffPMs.' Staff PMs'; } } - if(check_perms('admin_reports')) { $NumTorrentReports = $Cache->get_value('num_torrent_reportsv2'); if ($NumTorrentReports === false) { diff --git a/sections/staffpm/takepost.php b/sections/staffpm/takepost.php index 5a17ad14..ffd94281 100644 --- a/sections/staffpm/takepost.php +++ b/sections/staffpm/takepost.php @@ -39,6 +39,7 @@ if ($IsFLS) { // FLS/Staff $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"); diff --git a/sections/torrents/editgroupid.php b/sections/torrents/editgroupid.php index c88da4d2..14add738 100644 --- a/sections/torrents/editgroupid.php +++ b/sections/torrents/editgroupid.php @@ -29,9 +29,12 @@ die(); } list($Name) = $DB->next_record(); - $DB->query("SELECT Name FROM torrents_group WHERE ID = ".$GroupID); - list($NewName) = $DB->next_record(); - + $DB->query("SELECT CategoryID, Name FROM torrents_group WHERE ID = ".$GroupID); + list($CategoryID, $NewName) = $DB->next_record(); + if($Categories[$CategoryID-1] != 'Music') { + error('Target must be a music group.'); + } + $Artists = get_artists(array($OldGroupID, $GroupID)); show_header(); diff --git a/sections/torrents/merge.php b/sections/torrents/merge.php index 532b9e0a..24f1bb52 100644 --- a/sections/torrents/merge.php +++ b/sections/torrents/merge.php @@ -10,17 +10,18 @@ if($NewGroupID == $GroupID) { error('Old group ID is the same as new group ID!'); } -$DB->query("SELECT ID FROM torrents_group WHERE ID='$NewGroupID'"); +$DB->query("SELECT CategoryID, Name FROM torrents_group WHERE ID='$NewGroupID'"); if($DB->record_count()==0) { error('Target group does not exist.'); } - +list($CategoryID, $NewName) = $DB->next_record(); +if($Categories[$CategoryID-1] != 'Music') { + error('Only music groups can be merged.'); +} //Everything is legit, let's just confim they're not retarded if(empty($_POST['confirm'])) { $DB->query("SELECT Name FROM torrents_group WHERE ID = ".$GroupID); list($Name) = $DB->next_record(); - $DB->query("SELECT Name FROM torrents_group WHERE ID = ".$NewGroupID); - list($NewName) = $DB->next_record(); $Artists = get_artists(array($GroupID, $NewGroupID));