Empty commit

This commit is contained in:
Git 2016-02-06 08:00:28 +00:00
parent 933eb28040
commit cbd522aa87
9 changed files with 157 additions and 36 deletions

View File

@ -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)

View File

@ -408,12 +408,15 @@
$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) {

View File

@ -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

View File

@ -19,7 +19,7 @@
// 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':

View File

@ -5,60 +5,46 @@
$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("

View File

@ -7,6 +7,11 @@
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'])

View File

@ -182,6 +182,9 @@
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;

View File

@ -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:&nbsp;
<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>
&nbsp;for reason&nbsp;<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 />&nbsp;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();

View File

@ -201,6 +201,7 @@ function create_row($Title, $URL, $HasPermission = false, $Tooltip = false) {
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"));