diff options
author | Git <git@what.cd> | 2016-02-06 08:00:28 +0000 |
---|---|---|
committer | Git <git@what.cd> | 2016-02-06 08:00:28 +0000 |
commit | cbd522aa87ee3c4f82e078e55b0bffd4b9d8ce5d (patch) | |
tree | cfb13819eb723eff8eed43f8231efcbd58daa662 | |
parent | 933eb280405b034712af40ece6f0d9ad18f7c761 (diff) | |
download | Gazelle-cbd522aa87ee3c4f82e078e55b0bffd4b9d8ce5d.zip Gazelle-cbd522aa87ee3c4f82e078e55b0bffd4b9d8ce5d.tar.gz Gazelle-cbd522aa87ee3c4f82e078e55b0bffd4b9d8ce5d.tar.bz2 |
Empty commit
-rw-r--r-- | classes/permissions.class.php | 12 | ||||
-rw-r--r-- | design/privateheader.php | 5 | ||||
-rw-r--r-- | docs/CHANGES.txt | 3 | ||||
-rw-r--r-- | sections/staffpm/index.php | 2 | ||||
-rw-r--r-- | sections/staffpm/staff_inbox.php | 42 | ||||
-rw-r--r-- | sections/staffpm/viewconv.php | 5 | ||||
-rw-r--r-- | sections/tools/index.php | 3 | ||||
-rw-r--r-- | sections/tools/managers/multiple_freeleech.php | 120 | ||||
-rw-r--r-- | sections/tools/tools.php | 1 |
9 files changed, 157 insertions, 36 deletions
diff --git a/classes/permissions.class.php b/classes/permissions.class.php index 4af3060..fa48245 100644 --- a/classes/permissions.class.php +++ b/classes/permissions.class.php @@ -7,13 +7,13 @@ class Permissions { * @param string $MinClass Return false if the user's class level is below this. */ public static function check_perms($PermissionName, $MinClass = 0) { - - $OverrideClass = 1000; - - $Override = G::$LoggedUser['EffectiveClass'] >= $OverrideClass; + + $OverrideClass = 1000; + + $Override = G::$LoggedUser['EffectiveClass'] >= $OverrideClass; return ( - isset(G::$LoggedUser['Permissions'][$PermissionName]) - && G::$LoggedUser['Permissions'][$PermissionName] + ($PermissionName == null || + (isset(G::$LoggedUser['Permissions'][$PermissionName]) && G::$LoggedUser['Permissions'][$PermissionName])) && (G::$LoggedUser['Class'] >= $MinClass || G::$LoggedUser['EffectiveClass'] >= $MinClass || $Override) diff --git a/design/privateheader.php b/design/privateheader.php index c30d343..73d0587 100644 --- a/design/privateheader.php +++ b/design/privateheader.php @@ -408,12 +408,15 @@ if (check_perms('users_mod') || G::$LoggedUser['PermissionID'] == FORUM_MOD) { $NumStaffPMs = G::$Cache->get_value('num_staff_pms_'.G::$LoggedUser['ID']); if ($NumStaffPMs === false) { if (check_perms('users_mod')) { + + $LevelCap = 1000; + G::$DB->query(" SELECT COUNT(ID) FROM staff_pm_conversations WHERE Status = 'Unanswered' AND (AssignedToUser = ".G::$LoggedUser['ID']." - OR (Level >= ".max(700, $Classes[MOD]['Level'])." + OR (LEAST('$LevelCap', Level) <= '".G::$LoggedUser['EffectiveClass']."' AND Level <= ".G::$LoggedUser['Class']."))"); } if (G::$LoggedUser['PermissionID'] == FORUM_MOD) { diff --git a/docs/CHANGES.txt b/docs/CHANGES.txt index 74e5709..24579ec 100644 --- a/docs/CHANGES.txt +++ b/docs/CHANGES.txt @@ -1,5 +1,8 @@ CHANGE LOG +2016-02-05 by newman +Add tool to mark multiple torrent groups/collages as FL/NL/Regular, optionally NLing torrents above a certain size. Add level cap to Staff PMs + 2016-02-04 by newman Fix regex in reports.js to not remove the last character of each line except the last. Redirect to log.php when attempting to report a deleted torrent diff --git a/sections/staffpm/index.php b/sections/staffpm/index.php index 76ce66f..b470553 100644 --- a/sections/staffpm/index.php +++ b/sections/staffpm/index.php @@ -19,7 +19,7 @@ list($SupportFor, $DisplayStaff) = $DB->next_record(); // Logged in user is staff $IsStaff = ($DisplayStaff == 1); // Logged in user is Staff or FLS -$IsFLS = ($IsStaff || $LoggedUser['ExtraClasses'][41]); +$IsFLS = ($IsStaff || $LoggedUser['ExtraClasses'][FLS_TEAM]); switch ($_REQUEST['action']) { case 'viewconv': diff --git a/sections/staffpm/staff_inbox.php b/sections/staffpm/staff_inbox.php index 1728104..479086f 100644 --- a/sections/staffpm/staff_inbox.php +++ b/sections/staffpm/staff_inbox.php @@ -5,60 +5,46 @@ View::show_header('Staff Inbox'); $View = display_str($_GET['view']); $UserLevel = $LoggedUser['EffectiveClass']; + +$LevelCap = 1000; + + // Setup for current view mode $SortStr = 'IF(AssignedToUser = '.$LoggedUser['ID'].', 0, 1) ASC, '; switch ($View) { case 'unanswered': $ViewString = 'Unanswered'; - $WhereCondition = " - WHERE (Level <= $UserLevel OR AssignedToUser = '".$LoggedUser['ID']."') - AND Status = 'Unanswered'"; + $Status = "Unanswered"; break; case 'open': $ViewString = 'Unresolved'; - $WhereCondition = " - WHERE (Level <= $UserLevel OR AssignedToUser = '".$LoggedUser['ID']."') - AND Status IN ('Open', 'Unanswered')"; + $Status = "Open', 'Unanswered"; $SortStr = ''; break; case 'resolved': $ViewString = 'Resolved'; - $WhereCondition = " - WHERE (Level <= $UserLevel OR AssignedToUser = '".$LoggedUser['ID']."') - AND Status = 'Resolved'"; + $Status = "Resolved"; $SortStr = ''; break; case 'my': $ViewString = 'Your Unanswered'; - $WhereCondition = " - WHERE (Level = $UserLevel OR AssignedToUser = '".$LoggedUser['ID']."') - AND Status = 'Unanswered'"; + $Status = "Unanswered"; break; default: - if ($UserLevel >= 700) { + $Status = "Unanswered"; + if ($UserLevel >= $Classes[MOD]['Level'] || $UserLevel == $Classes[FORUM_MOD]['Level']) { $ViewString = 'Your Unanswered'; - $WhereCondition = " - WHERE ( - (Level >= ".max($Classes[MOD]['Level'], 700)." AND Level <= $UserLevel) - OR AssignedToUser = '".$LoggedUser['ID']."' - ) - AND Status = 'Unanswered'"; - } elseif ($UserLevel == 650) { - // Forum Mods - $ViewString = 'Your Unanswered'; - $WhereCondition = " - WHERE (Level = $UserLevel OR AssignedToUser = '".$LoggedUser['ID']."') - AND Status = 'Unanswered'"; } else { // FLS $ViewString = 'Unanswered'; - $WhereCondition = " - WHERE (Level <= $UserLevel OR AssignedToUser = '".$LoggedUser['ID']."') - AND Status = 'Unanswered'"; } break; } +$WhereCondition = " + WHERE (LEAST($LevelCap, spc.Level) <= $UserLevel OR spc.AssignedToUser = '".$LoggedUser['ID']."') + AND spc.Status IN ('$Status')"; + list($Page, $Limit) = Format::page_limit(MESSAGES_PER_PAGE); // Get messages $StaffPMs = $DB->query(" diff --git a/sections/staffpm/viewconv.php b/sections/staffpm/viewconv.php index 8ee9bde..c7a7824 100644 --- a/sections/staffpm/viewconv.php +++ b/sections/staffpm/viewconv.php @@ -7,6 +7,11 @@ if ($ConvID = (int)$_GET['id']) { FROM staff_pm_conversations WHERE ID = $ConvID"); list($Subject, $UserID, $Level, $AssignedToUser, $Unread, $Status) = $DB->next_record(); + + $LevelCap = 1000; + + + $Level = min($Level, $LevelCap); if (!(($UserID == $LoggedUser['ID']) || ($AssignedToUser == $LoggedUser['ID']) diff --git a/sections/tools/index.php b/sections/tools/index.php index a6b9684..7994e27 100644 --- a/sections/tools/index.php +++ b/sections/tools/index.php @@ -182,6 +182,9 @@ switch ($_REQUEST['action']) { case 'tokens': include(SERVER_ROOT.'/sections/tools/managers/tokens.php'); break; + case 'multiple_freeleech': + include(SERVER_ROOT.'/sections/tools/managers/multiple_freeleech.php'); + break; case 'ocelot': include(SERVER_ROOT.'/sections/tools/managers/ocelot.php'); break; diff --git a/sections/tools/managers/multiple_freeleech.php b/sections/tools/managers/multiple_freeleech.php new file mode 100644 index 0000000..c2e03c2 --- /dev/null +++ b/sections/tools/managers/multiple_freeleech.php @@ -0,0 +1,120 @@ +<? +if (!check_perms('users_mod')) { + error(403); +} + +View::show_header('Multiple freeleech'); + +if (isset($_POST['torrents'])) { + $GroupIDs = array(); + $Elements = explode("\r\n", $_POST['torrents']); + foreach ($Elements as $Element) { + // Get all of the torrent IDs + if (strpos($Element, "torrents.php") !== false) { + $Data = explode("id=", $Element); + if (!empty($Data[1])) { + $GroupIDs[] = (int) $Data[1]; + } + } else if (strpos($Element, "collages.php") !== false) { + $Data = explode("id=", $Element); + if (!empty($Data[1])) { + $CollageID = (int) $Data[1]; + $DB->query(" + SELECT GroupID + FROM collages_torrents + WHERE CollageID = '$CollageID'"); + while (list($GroupID) = $DB->next_record()) { + $GroupIDs[] = (int) $GroupID; + } + } + } + } + + if (sizeof($GroupIDs) == 0) { + $Err = 'Please enter properly formatted URLs'; + } else { + $FreeLeechType = (int) $_POST['freeleechtype']; + $FreeLeechReason = (int) $_POST['freeleechreason']; + + if (!in_array($FreeLeechType, array(0, 1, 2)) || !in_array($FreeLeechReason, array(0, 1, 2, 3))) { + $Err = 'Invalid freeleech type or freeleech reason'; + } else { + // Get the torrent IDs + $DB->query(" + SELECT ID + FROM torrents + WHERE GroupID IN (".implode(', ', $GroupIDs).")"); + $TorrentIDs = $DB->collect('ID'); + + if (sizeof($TorrentIDs) == 0) { + $Err = 'Invalid group IDs'; + } else { + if (isset($_POST['NLOver']) && $FreeLeechType == 1) { + // Only use this checkbox if freeleech is selected + $Size = (int) $_POST['size']; + $Units = db_string($_POST['scale']); + + if (empty($Size) || !in_array($Units, array('k', 'm', 'g'))) { + $Err = 'Invalid size or units'; + } else { + $Bytes = Format::get_bytes($Size . $Units); + + $DB->query(" + SELECT ID + FROM torrents + WHERE ID IN (".implode(', ', $TorrentIDs).") + AND Size > '$Bytes'"); + $LargeTorrents = $DB->collect('ID'); + $TorrentIDs = array_diff($TorrentIDs, $LargeTorrents); + } + } + + if (sizeof($TorrentIDs) > 0) { + Torrents::freeleech_torrents($TorrentIDs, $FreeLeechType, $FreeLeechReason); + } + + if (isset($LargeTorrents) && sizeof($LargeTorrents) > 0) { + Torrents::freeleech_torrents($LargeTorrents, 2, $FreeLeechReason); + } + + $Err = 'Done!'; + } + } + } +} +?> +<div class="thin"> + <div class="box pad box2"> +<? if (isset($Err)) { ?> + <strong class="important_text"><?=$Err?></strong><br /> +<? } ?> + Paste a list of collage or torrent group URLs + </div> + <div class="box pad"> + <form class="send_form center" action="" method="post"> + <input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" /> + <textarea name="torrents" style="width: 95%; height: 200px;"><?=$_POST['torrents']?></textarea><br /><br /> + Mark torrents as: + <select name="freeleechtype"> + <option value="1" <?=$_POST['freeleechtype'] == '1' ? 'selected' : ''?>>FL</option> + <option value="2" <?=$_POST['freeleechtype'] == '2' ? 'selected' : ''?>>NL</option> + <option value="0" <?=$_POST['freeleechtype'] == '0' ? 'selected' : ''?>>Normal</option> + </select> + for reason <select name="freeleechreason"> +<? $FL = array('N/A', 'Staff Pick', 'Perma-FL', 'Vanity House'); + foreach ($FL as $Key => $FLType) { ?> + <option value="<?=$Key?>" <?=$_POST['freeleechreason'] == $Key ? 'selected' : ''?>><?=$FLType?></option> +<? } ?> + </select><br /><br /> + <input type="checkbox" name="NLOver" checked /> NL Torrents over <input type="text" name="size" value="<?=isset($_POST['size']) ? $_POST['size'] : '1'?>" size=1 /> + <select name="scale"> + <option value="k" <?=$_POST['scale'] == 'k' ? 'selected' : ''?>>KB</option> + <option value="m" <?=$_POST['scale'] == 'm' ? 'selected' : ''?>>MB</option> + <option value="g" <?=!isset($_POST['scale']) || $_POST['scale'] == 'g' ? 'selected' : ''?>>GB</option> + </select><br /><br /> + <input type="submit" value="Submit" /> + </form> + </div> +</div> +<? +View::show_footer(); diff --git a/sections/tools/tools.php b/sections/tools/tools.php index 16dd013..62539ec 100644 --- a/sections/tools/tools.php +++ b/sections/tools/tools.php @@ -201,6 +201,7 @@ View::show_header('Staff Tools'); create_row("Collage recovery", "collages.php?action=recover", check_perms("site_collages_recover")); create_row("\"Do Not Upload\" list", "tools.php?action=dnu", check_perms("admin_dnu")); create_row("Manage freeleech tokens", "tools.php?action=tokens", check_perms("users_mod")); + create_row("Multiple freeleech", "tools.php?action=multiple_freeleech", check_perms("users_mod")); create_row("Label aliases", "tools.php?action=label_aliases", check_perms("users_mod")); create_row("Tag aliases", "tools.php?action=tag_aliases", check_perms("users_mod")); create_row("Batch tag editor", "tools.php?action=edit_tags", check_perms("users_mod")); |