Gazelle/sections/user/takemoderate.php

852 lines
32 KiB
PHP
Raw Normal View History

2011-03-28 14:21:28 +00:00
<?
/*************************************************************************\
//--------------Take moderation -----------------------------------------//
\*************************************************************************/
// Are they being tricky blighters?
if (!$_POST['userid'] || !is_number($_POST['userid'])) {
error(404);
} elseif (!check_perms('users_mod')) {
error(403);
}
authorize();
// End checking for moronity
$UserID = $_POST['userid'];
2012-03-29 08:00:19 +00:00
$DeleteKeys = false;
2011-03-28 14:21:28 +00:00
// Variables for database input
$Class = (int)$_POST['Class'];
$Username = db_string($_POST['Username']);
$Title = db_string($_POST['Title']);
$AdminComment = db_string($_POST['AdminComment']);
2013-11-12 08:00:58 +00:00
$Donor = isset($_POST['Donor']) ? 1 : 0;
$Artist = isset($_POST['Artist']) ? 1 : 0;
2013-04-13 08:00:19 +00:00
$SecondaryClasses = isset($_POST['secondary_classes']) ? $_POST['secondary_classes'] : array();
2012-03-28 08:00:20 +00:00
foreach ($SecondaryClasses as $i => $Val) {
2013-04-13 08:00:19 +00:00
if (!is_number($Val)) {
unset($SecondaryClasses[$i]);
}
2012-03-28 08:00:20 +00:00
}
2013-11-12 08:00:58 +00:00
$Visible = isset($_POST['Visible']) ? 1 : 0;
2011-03-28 14:21:28 +00:00
$Invites = (int)$_POST['Invites'];
$SupportFor = db_string($_POST['SupportFor']);
2012-09-22 08:00:24 +00:00
$Pass = $_POST['ChangePassword'];
2013-11-12 08:00:58 +00:00
$Warned = isset($_POST['Warned']) ? 1 : 0;
2013-02-22 08:00:24 +00:00
$Logs095 = (int)$_POST['095logs'];
2013-04-13 08:00:19 +00:00
if (isset($_POST['Uploaded']) && isset($_POST['Downloaded'])) {
2013-11-12 08:00:58 +00:00
$Uploaded = ($_POST['Uploaded'] === '' ? 0 : $_POST['Uploaded']);
2013-04-13 08:00:19 +00:00
if ($Arithmetic = strpbrk($Uploaded, '+-')) {
2012-10-11 08:00:15 +00:00
$Uploaded += max(-$Uploaded, Format::get_bytes($Arithmetic));
2011-03-28 14:21:28 +00:00
}
2013-11-12 08:00:58 +00:00
$Downloaded = ($_POST['Downloaded'] === '' ? 0 : $_POST['Downloaded']);
2013-04-13 08:00:19 +00:00
if ($Arithmetic = strpbrk($Downloaded, '+-')) {
2012-10-11 08:00:15 +00:00
$Downloaded += max(-$Downloaded, Format::get_bytes($Arithmetic));
2011-04-29 13:49:03 +00:00
}
2013-04-13 08:00:19 +00:00
if (!is_number($Uploaded) || !is_number($Downloaded)) {
2011-04-29 13:49:03 +00:00
error(0);
2011-03-28 14:21:28 +00:00
}
}
2013-04-13 08:00:19 +00:00
$FLTokens = isset($_POST['FLTokens']) ? $_POST['FLTokens'] : 0;
if (!is_number($FLTokens)) {
2011-10-08 08:00:14 +00:00
error(0);
}
2011-03-28 14:21:28 +00:00
$WarnLength = (int)$_POST['WarnLength'];
$ExtendWarning = (int)$_POST['ExtendWarning'];
2012-03-03 08:00:28 +00:00
$ReduceWarning = (int)$_POST['ReduceWarning'];
2011-03-28 14:21:28 +00:00
$WarnReason = $_POST['WarnReason'];
$UserReason = $_POST['UserReason'];
2013-11-12 08:00:58 +00:00
$DisableAvatar = isset($_POST['DisableAvatar']) ? 1 : 0;
$DisableInvites = isset($_POST['DisableInvites']) ? 1 : 0;
$DisablePosting = isset($_POST['DisablePosting']) ? 1 : 0;
$DisableForums = isset($_POST['DisableForums']) ? 1 : 0;
$DisableTagging = isset($_POST['DisableTagging']) ? 1 : 0;
$DisableUpload = isset($_POST['DisableUpload']) ? 1 : 0;
$DisableWiki = isset($_POST['DisableWiki']) ? 1 : 0;
$DisablePM = isset($_POST['DisablePM']) ? 1 : 0;
$DisableIRC = isset($_POST['DisableIRC']) ? 1 : 0;
$DisableRequests = isset($_POST['DisableRequests']) ? 1 : 0;
$DisableLeech = isset($_POST['DisableLeech']) ? 0 : 1;
2011-03-28 14:21:28 +00:00
$RestrictedForums = db_string(trim($_POST['RestrictedForums']));
2011-10-11 08:00:15 +00:00
$PermittedForums = db_string(trim($_POST['PermittedForums']));
2011-03-28 14:21:28 +00:00
$EnableUser = (int)$_POST['UserStatus'];
2013-11-12 08:00:58 +00:00
$ResetRatioWatch = isset($_POST['ResetRatioWatch']) ? 1 : 0;
$ResetPasskey = isset($_POST['ResetPasskey']) ? 1 : 0;
$ResetAuthkey = isset($_POST['ResetAuthkey']) ? 1 : 0;
$SendHackedMail = isset($_POST['SendHackedMail']) ? 1 : 0;
2013-04-13 08:00:19 +00:00
if ($SendHackedMail && !empty($_POST['HackedEmail'])) {
2011-03-28 14:21:28 +00:00
$HackedEmail = $_POST['HackedEmail'];
} else {
$SendHackedMail = false;
}
$MergeStatsFrom = db_string($_POST['MergeStatsFrom']);
$Reason = db_string($_POST['Reason']);
$HeavyUpdates = array();
$LightUpdates = array();
// Get user info from the database
2013-05-01 08:00:16 +00:00
$DB->query("
SELECT
m.Username,
m.IP,
m.Email,
m.PermissionID,
p.Level AS Class,
m.Title,
m.Enabled,
m.Uploaded,
m.Downloaded,
m.Invites,
m.can_leech,
m.Visible,
i.AdminComment,
m.torrent_pass,
i.Donor,
i.Artist,
i.Warned,
i.SupportFor,
i.RestrictedForums,
i.PermittedForums,
DisableAvatar,
DisableInvites,
DisablePosting,
DisableForums,
DisableTagging,
DisableUpload,
DisableWiki,
DisablePM,
DisableIRC,
2013-08-28 23:08:41 +00:00
DisableRequests,
2013-05-01 08:00:16 +00:00
m.RequiredRatio,
m.FLTokens,
i.RatioWatchEnds,
SHA1(i.AdminComment) AS CommentHash,
GROUP_CONCAT(l.PermissionID SEPARATOR ',') AS SecondaryClasses
2011-03-28 14:21:28 +00:00
FROM users_main AS m
2013-04-17 08:00:58 +00:00
JOIN users_info AS i ON i.UserID = m.ID
2013-06-24 08:00:28 +00:00
LEFT JOIN permissions AS p ON p.ID = m.PermissionID
2013-04-17 08:00:58 +00:00
LEFT JOIN users_levels AS l ON l.UserID = m.ID
2012-03-28 08:00:20 +00:00
WHERE m.ID = $UserID
GROUP BY m.ID");
2011-03-28 14:21:28 +00:00
2013-07-10 00:08:53 +00:00
if (!$DB->has_results()) { // If user doesn't exist
2013-06-24 08:00:28 +00:00
header("Location: log.php?search=User+$UserID");
2011-03-28 14:21:28 +00:00
}
$Cur = $DB->next_record(MYSQLI_ASSOC, false);
2012-01-31 08:00:23 +00:00
if ($_POST['comment_hash'] != $Cur['CommentHash']) {
2013-02-07 08:00:47 +00:00
error("Somebody else has moderated this user since you loaded it. Please go back and refresh the page.");
2012-01-31 08:00:23 +00:00
}
2011-03-28 14:21:28 +00:00
//NOW that we know the class of the current user, we can see if one staff member is trying to hax0r us.
2013-04-13 08:00:19 +00:00
if (!check_perms('users_mod', $Cur['Class'])) {
2011-03-28 14:21:28 +00:00
//Son of a fucking bitch
error(403);
die();
}
2014-04-02 08:00:56 +00:00
if (!empty($_POST['donor_points_submit']) && !empty($_POST['donation_value']) && is_number($_POST['donation_value'])) {
2013-08-28 23:08:41 +00:00
Donations::regular_donate($UserID, $_POST['donation_value'], "Add Points", $_POST['donation_reason'], $_POST['donation_currency']);
2013-09-15 08:00:53 +00:00
} elseif (!empty($_POST['donor_values_submit'])) {
2013-08-28 23:08:41 +00:00
Donations::update_rank($UserID, $_POST['donor_rank'], $_POST['total_donor_rank'], $_POST['reason']);
}
2011-03-28 14:21:28 +00:00
// If we're deleting the user, we can ignore all the other crap
2013-11-12 08:00:58 +00:00
if ($_POST['UserStatus'] === 'delete' && check_perms('users_delete_users')) {
2013-06-05 08:01:01 +00:00
Misc::write_log("User account $UserID (".$Cur['Username'].") was deleted by ".$LoggedUser['Username']);
$DB->query("
DELETE FROM users_main
WHERE id = $UserID");
$DB->query("
DELETE FROM users_info
WHERE UserID = $UserID");
2013-11-12 08:00:58 +00:00
$Cache->delete_value("user_info_$UserID");
2013-02-22 08:00:24 +00:00
2012-10-11 08:00:15 +00:00
Tracker::update_tracker('remove_user', array('passkey' => $Cur['torrent_pass']));
2013-02-22 08:00:24 +00:00
2013-11-12 08:00:58 +00:00
header("Location: log.php?search=User+$UserID");
2011-03-28 14:21:28 +00:00
die();
}
// User was not deleted. Perform other stuff.
$UpdateSet = array();
$EditSummary = array();
2015-02-19 08:00:27 +00:00
$TrackerUserUpdates = array('passkey' => $Cur['torrent_pass']);
2011-03-28 14:21:28 +00:00
if ($_POST['ResetRatioWatch'] && check_perms('users_edit_reset_keys')) {
2013-06-05 08:01:01 +00:00
$DB->query("
UPDATE users_info
2013-11-12 08:00:58 +00:00
SET RatioWatchEnds = '0000-00-00 00:00:00', RatioWatchDownload = '0', RatioWatchTimes = '0'
2013-06-24 08:00:28 +00:00
WHERE UserID = '$UserID'");
2013-04-13 08:00:19 +00:00
$EditSummary[] = 'RatioWatch history reset';
2011-03-28 14:21:28 +00:00
}
if ($_POST['ResetIPHistory'] && check_perms('users_edit_reset_keys')) {
2013-06-24 08:00:28 +00:00
$DB->query("
DELETE FROM users_history_ips
WHERE UserID = '$UserID'");
$DB->query("
UPDATE users_main
SET IP = '127.0.0.1'
WHERE ID = '$UserID'");
$DB->query("
UPDATE xbt_snatched
SET IP = ''
WHERE uid = '$UserID'");
$DB->query("
UPDATE users_history_passwords
SET ChangerIP = ''
WHERE UserID = $UserID");
$DB->query("
UPDATE users_history_passkeys
SET ChangerIP = ''
WHERE UserID = $UserID");
2013-05-07 08:00:23 +00:00
2013-04-13 08:00:19 +00:00
$EditSummary[] = 'IP history cleared';
2011-03-28 14:21:28 +00:00
}
if ($_POST['ResetEmailHistory'] && check_perms('users_edit_reset_keys')) {
2013-06-24 08:00:28 +00:00
$DB->query("
DELETE FROM users_history_emails
WHERE UserID = '$UserID'");
2011-03-28 14:21:28 +00:00
if ($_POST['ResetIPHistory']) {
2013-06-05 08:01:01 +00:00
$DB->query("
2013-06-24 08:00:28 +00:00
INSERT INTO users_history_emails
(UserID, Email, Time, IP)
VALUES
('$UserID', '$Username@".SITE_URL."', '0000-00-00 00:00:00', '127.0.0.1')");
2011-03-28 14:21:28 +00:00
} else {
2013-06-05 08:01:01 +00:00
$DB->query("
2013-06-24 08:00:28 +00:00
INSERT INTO users_history_emails
(UserID, Email, Time, IP)
VALUES
('$UserID', '$Username@".SITE_URL."', '0000-00-00 00:00:00', '".$Cur['IP']."')");
2011-03-28 14:21:28 +00:00
}
2013-06-05 08:01:01 +00:00
$DB->query("
UPDATE users_main
2013-06-24 08:00:28 +00:00
SET Email = '$Username@".SITE_URL."'
WHERE ID = '$UserID'");
2013-04-13 08:00:19 +00:00
$EditSummary[] = 'Email history cleared';
2011-03-28 14:21:28 +00:00
}
if ($_POST['ResetSnatchList'] && check_perms('users_edit_reset_keys')) {
2013-06-24 08:00:28 +00:00
$DB->query("
DELETE FROM xbt_snatched
WHERE uid = '$UserID'");
2013-04-13 08:00:19 +00:00
$EditSummary[] = 'Snatch list cleared';
2013-11-23 08:01:14 +00:00
$Cache->delete_value("recent_snatches_$UserID");
2011-03-28 14:21:28 +00:00
}
if ($_POST['ResetDownloadList'] && check_perms('users_edit_reset_keys')) {
2013-06-24 08:00:28 +00:00
$DB->query("
DELETE FROM users_downloads
WHERE UserID = '$UserID'");
2013-04-13 08:00:19 +00:00
$EditSummary[] = 'Download list cleared';
2011-03-28 14:21:28 +00:00
}
if (($_POST['ResetSession'] || $_POST['LogOut']) && check_perms('users_logout')) {
2013-06-24 08:00:28 +00:00
$Cache->delete_value("user_info_$UserID");
$Cache->delete_value("user_info_heavy_$UserID");
$Cache->delete_value("user_stats_$UserID");
$Cache->delete_value("enabled_$UserID");
2013-02-22 08:00:24 +00:00
2013-04-13 08:00:19 +00:00
if ($_POST['LogOut']) {
2013-06-09 08:01:21 +00:00
$DB->query("
SELECT SessionID
FROM users_sessions
2013-06-24 08:00:28 +00:00
WHERE UserID = '$UserID'");
2013-05-01 08:00:16 +00:00
while (list($SessionID) = $DB->next_record()) {
2013-06-24 08:00:28 +00:00
$Cache->delete_value("session_{$UserID}_$SessionID");
2011-03-28 14:21:28 +00:00
}
2013-06-24 08:00:28 +00:00
$Cache->delete_value("users_sessions_$UserID");
2013-05-16 16:15:57 +00:00
2013-06-09 08:01:21 +00:00
$DB->query("
DELETE FROM users_sessions
2013-06-24 08:00:28 +00:00
WHERE UserID = '$UserID'");
2013-05-16 16:15:57 +00:00
2011-03-28 14:21:28 +00:00
}
}
if ($Logs095 !== 0) {
2013-11-12 08:00:58 +00:00
$TargetScore = $Logs095 === 100 ? 99 : 100;
2013-06-05 08:01:01 +00:00
$Logs = $DB->query("
SELECT DISTINCT TorrentID
FROM torrents_logs_new
JOIN torrents ON ID = TorrentID
WHERE Log LIKE 'EAC extraction logfile%'
AND UserID = $UserID
AND Score = $TargetScore
AND (Adjusted = '0' OR Adjusted = '')");
2011-03-28 14:21:28 +00:00
while (list($TorrentID) = $DB->next_record()) {
$Results = array();
if ($Logs095 === 100) {
2013-04-17 08:00:58 +00:00
$Details = '';
2011-03-28 14:21:28 +00:00
} else {
2013-04-17 08:00:58 +00:00
$Results[] = 'The original uploader has chosen to allow this log to be deducted one point for using EAC v0.95., -1 point [1]';
2011-03-28 14:21:28 +00:00
$Details = db_string(serialize($Results));
}
2013-06-05 08:01:01 +00:00
$DB->query("
UPDATE torrents
SET LogScore = $Logs095
WHERE ID = $TorrentID");
$DB->query("
UPDATE torrents_logs_new
SET Score = $Logs095, Details = '$Details'
WHERE TorrentID = $TorrentID");
2011-03-28 14:21:28 +00:00
$DB->set_query_id($Logs);
}
2013-11-12 08:00:58 +00:00
$EditSummary[] = "EAC v0.95 logs rescored to $Logs095";
2011-03-28 14:21:28 +00:00
}
// Start building SQL query and edit summary
2013-06-24 08:00:28 +00:00
if ($Classes[$Class]['Level'] != $Cur['Class']
&& (
($Classes[$Class]['Level'] < $LoggedUser['Class'] && check_perms('users_promote_below', $Cur['Class']))
|| ($Classes[$Class]['Level'] <= $LoggedUser['Class'] && check_perms('users_promote_to', $Cur['Class'] - 1))
)
) {
$UpdateSet[] = "PermissionID = '$Class'";
2013-04-17 08:00:58 +00:00
$EditSummary[] = 'class changed to '.Users::make_class_string($Class);
2013-04-13 08:00:19 +00:00
$LightUpdates['PermissionID'] = $Class;
2012-03-29 08:00:19 +00:00
$DeleteKeys = true;
2013-06-09 08:01:21 +00:00
$DB->query("
SELECT DISTINCT DisplayStaff
FROM permissions
WHERE ID = $Class
OR ID = ".$ClassLevels[$Cur['Class']]['ID']);
2013-07-10 00:08:53 +00:00
if ($DB->record_count() === 2) {
2013-04-13 08:00:19 +00:00
if ($Classes[$Class]['Level'] < $Cur['Class']) {
2011-03-28 14:21:28 +00:00
$SupportFor = '';
}
$ClearStaffIDCache = true;
}
2013-09-12 08:00:52 +00:00
$Cache->delete_value("donor_info_$UserID");
2011-03-28 14:21:28 +00:00
}
2013-04-17 08:00:58 +00:00
if ($Username != $Cur['Username'] && check_perms('users_edit_usernames', $Cur['Class'] - 1)) {
2013-06-05 08:01:01 +00:00
$DB->query("
SELECT ID
FROM users_main
WHERE Username = '$Username'");
2013-04-13 08:00:19 +00:00
if ($DB->next_record() > 0) {
2011-03-28 14:21:28 +00:00
list($UsedUsernameID) = $DB->next_record();
2013-11-12 08:00:58 +00:00
error("Username already in use by <a href=\"user.php?id=$UsedUsernameID\">$Username</a>");
header("Location: user.php?id=$UserID");
2011-03-28 14:21:28 +00:00
die();
2013-06-05 08:01:01 +00:00
} elseif ($Username == '0' || $Username == '1') {
error('You cannot set a username of "0" or "1".');
2013-11-12 08:00:58 +00:00
header("Location: user.php?id=$UserID");
2013-06-05 08:01:01 +00:00
die();
2011-03-28 14:21:28 +00:00
} else {
2013-06-24 08:00:28 +00:00
$UpdateSet[] = "Username = '$Username'";
$EditSummary[] = "username changed from ".$Cur['Username']." to $Username";
2013-04-13 08:00:19 +00:00
$LightUpdates['Username'] = $Username;
2011-03-28 14:21:28 +00:00
}
}
2013-04-13 08:00:19 +00:00
if ($Title != db_string($Cur['Title']) && check_perms('users_edit_titles')) {
2011-12-19 08:00:18 +00:00
// Using the unescaped value for the test to avoid confusion
if (strlen($_POST['Title']) > 1024) {
2013-06-05 08:01:01 +00:00
error("Custom titles have a maximum length of 1,024 characters.");
2013-11-12 08:00:58 +00:00
header("Location: user.php?id=$UserID");
2011-12-19 08:00:18 +00:00
die();
} else {
2013-06-24 08:00:28 +00:00
$UpdateSet[] = "Title = '$Title'";
2013-12-01 08:00:44 +00:00
$EditSummary[] = "title changed to [code]{$Title}[/code]";
2013-04-13 08:00:19 +00:00
$LightUpdates['Title'] = $_POST['Title'];
2011-12-19 08:00:18 +00:00
}
2011-03-28 14:21:28 +00:00
}
2013-04-13 08:00:19 +00:00
if ($Donor != $Cur['Donor'] && check_perms('users_give_donor')) {
2013-06-24 08:00:28 +00:00
$UpdateSet[] = "Donor = '$Donor'";
2013-04-17 08:00:58 +00:00
$EditSummary[] = 'donor status changed';
2013-04-13 08:00:19 +00:00
$LightUpdates['Donor'] = $Donor;
2011-03-28 14:21:28 +00:00
}
2012-03-28 08:00:20 +00:00
// Secondary classes
2013-06-24 08:00:28 +00:00
$OldClasses = $Cur['SecondaryClasses'] ? explode(',', $Cur['SecondaryClasses']) : array();
2012-03-28 08:00:20 +00:00
$DroppedClasses = array_diff($OldClasses, $SecondaryClasses);
$AddedClasses = array_diff($SecondaryClasses, $OldClasses);
if (count($DroppedClasses) > 0) {
$ClassChanges = array();
foreach ($DroppedClasses as $PermID) {
$ClassChanges[] = $Classes[$PermID]['Name'];
}
2013-06-24 08:00:28 +00:00
$EditSummary[] = 'Secondary classes dropped: '.implode(', ', $ClassChanges);
2013-06-05 08:01:01 +00:00
$DB->query("
DELETE FROM users_levels
WHERE UserID = '$UserID'
AND PermissionID IN (".implode(',', $DroppedClasses).')');
2012-03-28 08:00:20 +00:00
if (count($SecondaryClasses) > 0) {
2013-04-13 08:00:19 +00:00
$LightUpdates['ExtraClasses'] = array_fill_keys($SecondaryClasses, 1);
2012-03-28 08:00:20 +00:00
} else {
2013-04-13 08:00:19 +00:00
$LightUpdates['ExtraClasses'] = array();
2012-03-28 08:00:20 +00:00
}
2012-03-29 08:00:19 +00:00
$DeleteKeys = true;
2012-03-28 08:00:20 +00:00
}
if (count($AddedClasses) > 0) {
$ClassChanges = array();
foreach ($AddedClasses as $PermID) {
$ClassChanges[] = $Classes[$PermID]['Name'];
}
2014-02-19 08:00:32 +00:00
$EditSummary[] = "Secondary classes added: ".implode(', ', $ClassChanges);
2012-03-28 08:00:20 +00:00
$Values = array();
foreach ($AddedClasses as $PermID) {
$Values[] = "($UserID, $PermID)";
2013-05-16 16:15:57 +00:00
2012-03-28 08:00:20 +00:00
}
2013-06-24 08:00:28 +00:00
$DB->query("
INSERT INTO users_levels (UserID, PermissionID)
VALUES ".implode(', ', $Values));
2013-04-13 08:00:19 +00:00
//$LightUpdates['ExtraClasses'] = array_fill_keys($SecondaryClasses, 1);
2012-03-29 08:00:19 +00:00
$DeleteKeys = true;
2012-03-28 08:00:20 +00:00
}
2011-03-28 14:21:28 +00:00
2013-04-13 08:00:19 +00:00
if ($Visible != $Cur['Visible'] && check_perms('users_make_invisible')) {
2013-06-24 08:00:28 +00:00
$UpdateSet[] = "Visible = '$Visible'";
2013-06-05 08:01:01 +00:00
$EditSummary[] = 'visibility changed';
2013-04-13 08:00:19 +00:00
$LightUpdates['Visible'] = $Visible;
2015-02-19 08:00:27 +00:00
$TrackerUserUpdates['visible'] = $Visible;
2011-03-28 14:21:28 +00:00
}
2013-04-13 08:00:19 +00:00
if ($Uploaded != $Cur['Uploaded'] && $Uploaded != $_POST['OldUploaded'] && (check_perms('users_edit_ratio')
2013-04-19 08:00:55 +00:00
|| (check_perms('users_edit_own_ratio') && $UserID == $LoggedUser['ID']))) {
2013-06-24 08:00:28 +00:00
$UpdateSet[] = "Uploaded = '$Uploaded'";
$EditSummary[] = "uploaded changed from ".Format::get_size($Cur['Uploaded']).' to '.Format::get_size($Uploaded);
2014-05-07 08:00:45 +00:00
$Cache->delete_value("user_stats_$UserID");
2011-03-28 14:21:28 +00:00
}
2013-04-13 08:00:19 +00:00
if ($Downloaded != $Cur['Downloaded'] && $Downloaded != $_POST['OldDownloaded'] && (check_perms('users_edit_ratio')
2013-04-19 08:00:55 +00:00
|| (check_perms('users_edit_own_ratio') && $UserID == $LoggedUser['ID']))) {
2013-06-24 08:00:28 +00:00
$UpdateSet[] = "Downloaded = '$Downloaded'";
$EditSummary[] = "downloaded changed from ".Format::get_size($Cur['Downloaded']).' to '.Format::get_size($Downloaded);
2014-05-07 08:00:45 +00:00
$Cache->delete_value("user_stats_$UserID");
2011-03-28 14:21:28 +00:00
}
2013-04-13 08:00:19 +00:00
if ($FLTokens != $Cur['FLTokens'] && (check_perms('users_edit_ratio') || (check_perms('users_edit_own_ratio') && $UserID == $LoggedUser['ID']))) {
2013-06-24 08:00:28 +00:00
$UpdateSet[] = "FLTokens = $FLTokens";
$EditSummary[] = "Freeleech Tokens changed from ".$Cur['FLTokens']." to $FLTokens";
2011-10-08 08:00:14 +00:00
$HeavyUpdates['FLTokens'] = $FLTokens;
}
2013-04-13 08:00:19 +00:00
if ($Invites != $Cur['Invites'] && check_perms('users_edit_invites')) {
2013-06-24 08:00:28 +00:00
$UpdateSet[] = "invites = '$Invites'";
2013-04-13 08:00:19 +00:00
$EditSummary[] = "number of invites changed to $Invites";
2011-03-28 14:21:28 +00:00
$HeavyUpdates['Invites'] = $Invites;
}
2013-04-13 08:00:19 +00:00
if ($Warned == 1 && $Cur['Warned'] == '0000-00-00 00:00:00' && check_perms('users_warn')) {
2013-11-13 08:00:59 +00:00
$Weeks = 'week' . ($WarnLength === 1 ? '' : 's');
2013-11-12 08:00:58 +00:00
Misc::send_pm($UserID, 0, 'You have received a warning', "You have been [url=".site_url()."wiki.php?action=article&amp;id=218]warned for $WarnLength {$Weeks}[/url] by [user]".$LoggedUser['Username']."[/user]. The reason given was:
[quote]{$WarnReason}[/quote]");
2013-06-24 08:00:28 +00:00
$UpdateSet[] = "Warned = '".sqltime()."' + INTERVAL $WarnLength WEEK";
2013-05-27 08:00:58 +00:00
$Msg = "warned for $WarnLength $Weeks";
2013-04-13 08:00:19 +00:00
if ($WarnReason) {
2013-11-12 08:00:58 +00:00
$Msg .= " for \"$WarnReason\"";
2013-04-13 08:00:19 +00:00
}
$EditSummary[] = db_string($Msg);
2013-05-27 08:00:58 +00:00
$LightUpdates['Warned'] = time_plus(3600 * 24 * 7 * $WarnLength);
2011-03-28 14:21:28 +00:00
2013-04-13 08:00:19 +00:00
} elseif ($Warned == 0 && $Cur['Warned'] != '0000-00-00 00:00:00' && check_perms('users_warn')) {
2013-06-24 08:00:28 +00:00
$UpdateSet[] = "Warned = '0000-00-00 00:00:00'";
2013-05-27 08:00:58 +00:00
$EditSummary[] = 'warning removed';
2013-04-13 08:00:19 +00:00
$LightUpdates['Warned'] = '0000-00-00 00:00:00';
2011-03-28 14:21:28 +00:00
2013-04-13 08:00:19 +00:00
} elseif ($Warned == 1 && $ExtendWarning != '---' && check_perms('users_warn')) {
2013-11-13 08:00:59 +00:00
$Weeks = 'week' . ($ExtendWarning === 1 ? '' : 's');
2013-11-12 08:00:58 +00:00
Misc::send_pm($UserID, 0, 'Your warning has been extended', "Your warning has been extended by $ExtendWarning $Weeks by [user]".$LoggedUser['Username']."[/user]. The reason given was:
[quote]{$WarnReason}[/quote]");
2013-02-22 08:00:24 +00:00
2013-06-24 08:00:28 +00:00
$UpdateSet[] = "Warned = Warned + INTERVAL $ExtendWarning WEEK";
2013-06-09 08:01:21 +00:00
$DB->query("
SELECT Warned + INTERVAL $ExtendWarning WEEK
FROM users_info
2013-06-24 08:00:28 +00:00
WHERE UserID = '$UserID'");
2012-03-03 08:00:28 +00:00
list($WarnedUntil) = $DB->next_record();
2013-05-27 08:00:58 +00:00
$Msg = "warning extended by $ExtendWarning $Weeks to $WarnedUntil";
2013-04-13 08:00:19 +00:00
if ($WarnReason) {
2013-11-12 08:00:58 +00:00
$Msg .= " for \"$WarnReason\"";
2013-04-13 08:00:19 +00:00
}
$EditSummary[] = db_string($Msg);
$LightUpdates['Warned'] = $WarnedUntil;
2013-02-22 08:00:24 +00:00
2013-05-27 08:00:58 +00:00
} elseif ($Warned == 1 && $ExtendWarning == '---' && $ReduceWarning != '---' && check_perms('users_warn')) {
2013-11-13 08:00:59 +00:00
$Weeks = 'week' . ($ReduceWarning === 1 ? '' : 's');
2013-11-12 08:00:58 +00:00
Misc::send_pm($UserID, 0, 'Your warning has been reduced', "Your warning has been reduced by $ReduceWarning $Weeks by [user]".$LoggedUser['Username']."[/user]. The reason given was:
[quote]{$WarnReason}[/quote]");
2013-06-24 08:00:28 +00:00
$UpdateSet[] = "Warned = Warned - INTERVAL $ReduceWarning WEEK";
2013-06-09 08:01:21 +00:00
$DB->query("
SELECT Warned - INTERVAL $ReduceWarning WEEK
FROM users_info
2013-06-24 08:00:28 +00:00
WHERE UserID = '$UserID'");
2011-03-28 14:21:28 +00:00
list($WarnedUntil) = $DB->next_record();
2013-05-27 08:00:58 +00:00
$Msg = "warning reduced by $ReduceWarning $Weeks to $WarnedUntil";
2013-04-13 08:00:19 +00:00
if ($WarnReason) {
2013-11-12 08:00:58 +00:00
$Msg .= " for \"$WarnReason\"";
2013-04-13 08:00:19 +00:00
}
$EditSummary[] = db_string($Msg);
$LightUpdates['Warned'] = $WarnedUntil;
2011-03-28 14:21:28 +00:00
}
2013-04-13 08:00:19 +00:00
if ($SupportFor != db_string($Cur['SupportFor']) && (check_perms('admin_manage_fls') || (check_perms('users_mod') && $UserID == $LoggedUser['ID']))) {
2013-06-24 08:00:28 +00:00
$UpdateSet[] = "SupportFor = '$SupportFor'";
2013-11-12 08:00:58 +00:00
$EditSummary[] = "First-Line Support status changed to \"$SupportFor\"";
2011-03-28 14:21:28 +00:00
}
if ($RestrictedForums != db_string($Cur['RestrictedForums']) && check_perms('users_mod')) {
2013-06-24 08:00:28 +00:00
$UpdateSet[] = "RestrictedForums = '$RestrictedForums'";
2013-04-13 08:00:19 +00:00
$EditSummary[] = "restricted forum(s): $RestrictedForums";
2013-01-24 08:00:24 +00:00
$DeleteKeys = true;
2011-10-11 08:00:15 +00:00
}
if ($PermittedForums != db_string($Cur['PermittedForums']) && check_perms('users_mod')) {
2013-06-24 08:00:28 +00:00
$ForumSet = explode(',', $PermittedForums);
2011-10-11 08:00:15 +00:00
$ForumList = array();
foreach ($ForumSet as $ForumID) {
2012-03-28 08:00:20 +00:00
if ($Forums[$ForumID]['MinClassCreate'] <= $LoggedUser['EffectiveClass']) {
2011-10-11 08:00:15 +00:00
$ForumList[] = $ForumID;
}
}
2013-06-24 08:00:28 +00:00
$PermittedForums = implode(',', $ForumSet);
$UpdateSet[] = "PermittedForums = '$PermittedForums'";
2013-04-13 08:00:19 +00:00
$EditSummary[] = "permitted forum(s): $PermittedForums";
2013-01-24 08:00:24 +00:00
$DeleteKeys = true;
2011-10-11 08:00:15 +00:00
}
2013-04-13 08:00:19 +00:00
if ($DisableAvatar != $Cur['DisableAvatar'] && check_perms('users_disable_any')) {
2013-06-24 08:00:28 +00:00
$UpdateSet[] = "DisableAvatar = '$DisableAvatar'";
2013-11-17 08:00:47 +00:00
$EditSummary[] = 'avatar privileges ' . ($DisableAvatar ? 'disabled' : 'enabled');
2013-04-13 08:00:19 +00:00
$HeavyUpdates['DisableAvatar'] = $DisableAvatar;
2011-03-28 14:21:28 +00:00
if (!empty($UserReason)) {
2014-07-22 08:00:28 +00:00
Misc::send_pm($UserID, 0, 'Your avatar privileges have been disabled', "Your avatar privileges have been disabled. The reason given was: [quote]{$UserReason}[/quote] If you would like to discuss this, please join ".BOT_DISABLED_CHAN.' on our IRC network. Instructions can be found [url='.site_url().'wiki.php?action=article&amp;name=IRC+-+How+to+join]here[/url].');
2011-03-28 14:21:28 +00:00
}
}
2013-04-13 08:00:19 +00:00
if ($DisableLeech != $Cur['can_leech'] && check_perms('users_disable_any')) {
2013-06-24 08:00:28 +00:00
$UpdateSet[] = "can_leech = '$DisableLeech'";
2013-04-13 08:00:19 +00:00
$EditSummary[] = "leeching status changed (".translateLeechStatus($Cur['can_leech'])." -> ".translateLeechStatus($DisableLeech).")";
$HeavyUpdates['DisableLeech'] = $DisableLeech;
$HeavyUpdates['CanLeech'] = $DisableLeech;
2011-03-28 14:21:28 +00:00
if (!empty($UserReason)) {
2014-07-22 08:00:28 +00:00
Misc::send_pm($UserID, 0, 'Your leeching privileges have been disabled', "Your leeching privileges have been disabled. The reason given was: [quote]{$UserReason}[/quote] If you would like to discuss this, please join ".BOT_DISABLED_CHAN.' on our IRC network. Instructions can be found [url='.site_url().'wiki.php?action=article&amp;name=IRC+-+How+to+join]here[/url].');
2011-03-28 14:21:28 +00:00
}
2015-02-19 08:00:27 +00:00
$TrackerUserUpdates['can_leech'] = $DisableLeech;
2011-03-28 14:21:28 +00:00
}
2013-04-13 08:00:19 +00:00
if ($DisableInvites != $Cur['DisableInvites'] && check_perms('users_disable_any')) {
2013-06-24 08:00:28 +00:00
$UpdateSet[] = "DisableInvites = '$DisableInvites'";
2013-02-22 08:00:24 +00:00
if ($DisableInvites == 1) {
2013-06-24 08:00:28 +00:00
//$UpdateSet[] = "Invites = '0'";
2011-03-28 14:21:28 +00:00
if (!empty($UserReason)) {
2014-07-22 08:00:28 +00:00
Misc::send_pm($UserID, 0, 'Your invite privileges have been disabled', "Your invite privileges have been disabled. The reason given was: [quote]{$UserReason}[/quote] If you would like to discuss this, please join ".BOT_DISABLED_CHAN.' on our IRC network. Instructions can be found [url='.site_url().'wiki.php?action=article&amp;name=IRC+-+How+to+join]here[/url].');
2011-03-28 14:21:28 +00:00
}
}
2013-11-17 08:00:47 +00:00
$EditSummary[] = 'invites privileges ' . ($DisableInvites ? 'disabled' : 'enabled');
2013-04-13 08:00:19 +00:00
$HeavyUpdates['DisableInvites'] = $DisableInvites;
2011-03-28 14:21:28 +00:00
}
2013-04-13 08:00:19 +00:00
if ($DisablePosting != $Cur['DisablePosting'] && check_perms('users_disable_posts')) {
2013-06-24 08:00:28 +00:00
$UpdateSet[] = "DisablePosting = '$DisablePosting'";
2013-11-17 08:00:47 +00:00
$EditSummary[] = 'posting privileges ' . ($DisablePosting ? 'disabled' : 'enabled');
2013-04-13 08:00:19 +00:00
$HeavyUpdates['DisablePosting'] = $DisablePosting;
2011-03-28 14:21:28 +00:00
if (!empty($UserReason)) {
2014-07-22 08:00:28 +00:00
Misc::send_pm($UserID, 0, 'Your forum posting privileges have been disabled', "Your forum posting privileges have been disabled. The reason given was: [quote]{$UserReason}[/quote] If you would like to discuss this, please join ".BOT_DISABLED_CHAN.' on our IRC network. Instructions can be found [url='.site_url().'wiki.php?action=article&amp;name=IRC+-+How+to+join]here[/url].');
2011-03-28 14:21:28 +00:00
}
}
2013-04-13 08:00:19 +00:00
if ($DisableForums != $Cur['DisableForums'] && check_perms('users_disable_posts')) {
2013-06-24 08:00:28 +00:00
$UpdateSet[] = "DisableForums = '$DisableForums'";
2013-11-17 08:00:47 +00:00
$EditSummary[] = 'forums privileges ' . ($DisableForums ? 'disabled' : 'enabled');
2013-04-13 08:00:19 +00:00
$HeavyUpdates['DisableForums'] = $DisableForums;
2011-03-28 14:21:28 +00:00
if (!empty($UserReason)) {
2014-07-22 08:00:28 +00:00
Misc::send_pm($UserID, 0, 'Your forum privileges have been disabled', "Your forum privileges have been disabled. The reason given was: [quote]{$UserReason}[/quote] If you would like to discuss this, please join ".BOT_DISABLED_CHAN.' on our IRC network. Instructions can be found [url='.site_url().'wiki.php?action=article&amp;name=IRC+-+How+to+join]here[/url].');
2011-03-28 14:21:28 +00:00
}
}
2013-04-13 08:00:19 +00:00
if ($DisableTagging != $Cur['DisableTagging'] && check_perms('users_disable_any')) {
2013-06-24 08:00:28 +00:00
$UpdateSet[] = "DisableTagging = '$DisableTagging'";
2013-11-17 08:00:47 +00:00
$EditSummary[] = 'tagging privileges ' . ($DisableTagging ? 'disabled' : 'enabled');
2013-04-13 08:00:19 +00:00
$HeavyUpdates['DisableTagging'] = $DisableTagging;
2011-03-28 14:21:28 +00:00
if (!empty($UserReason)) {
2014-07-22 08:00:28 +00:00
Misc::send_pm($UserID, 0, 'Your tagging privileges have been disabled', "Your tagging privileges have been disabled. The reason given was: [quote]{$UserReason}[/quote] If you would like to discuss this, please join ".BOT_DISABLED_CHAN.' on our IRC network. Instructions can be found [url='.site_url().'wiki.php?action=article&amp;name=IRC+-+How+to+join]here[/url].');
2011-03-28 14:21:28 +00:00
}
}
2013-04-13 08:00:19 +00:00
if ($DisableUpload != $Cur['DisableUpload'] && check_perms('users_disable_any')) {
2013-06-24 08:00:28 +00:00
$UpdateSet[] = "DisableUpload = '$DisableUpload'";
2013-11-17 08:00:47 +00:00
$EditSummary[] = 'upload privileges ' . ($DisableUpload ? 'disabled' : 'enabled');
2013-04-13 08:00:19 +00:00
$HeavyUpdates['DisableUpload'] = $DisableUpload;
2011-03-28 14:21:28 +00:00
if ($DisableUpload == 1) {
2014-07-22 08:00:28 +00:00
Misc::send_pm($UserID, 0, 'Your upload privileges have been disabled', "Your upload privileges have been disabled. The reason given was: [quote]{$UserReason}[/quote] If you would like to discuss this, please join ".BOT_DISABLED_CHAN.' on our IRC network. Instructions can be found [url='.site_url().'wiki.php?action=article&amp;name=IRC+-+How+to+join]here[/url].');
2011-03-28 14:21:28 +00:00
}
}
2013-04-13 08:00:19 +00:00
if ($DisableWiki != $Cur['DisableWiki'] && check_perms('users_disable_any')) {
2013-06-24 08:00:28 +00:00
$UpdateSet[] = "DisableWiki = '$DisableWiki'";
2013-11-17 08:00:47 +00:00
$EditSummary[] = 'wiki privileges ' . ($DisableWiki ? 'disabled' : 'enabled');
2013-04-13 08:00:19 +00:00
$HeavyUpdates['DisableWiki'] = $DisableWiki;
$HeavyUpdates['site_edit_wiki'] = 0;
2011-03-28 14:21:28 +00:00
if (!empty($UserReason)) {
2014-07-22 08:00:28 +00:00
Misc::send_pm($UserID, 0, 'Your site editing privileges have been disabled', "Your site editing privileges have been disabled. The reason given was: [quote]{$UserReason}[/quote] If you would like to discuss this, please join ".BOT_DISABLED_CHAN.' on our IRC network. Instructions can be found [url='.site_url().'wiki.php?action=article&amp;name=IRC+-+How+to+join]here[/url].');
2011-03-28 14:21:28 +00:00
}
2013-02-22 08:00:24 +00:00
2011-03-28 14:21:28 +00:00
}
2013-04-13 08:00:19 +00:00
if ($DisablePM != $Cur['DisablePM'] && check_perms('users_disable_any')) {
2013-06-24 08:00:28 +00:00
$UpdateSet[] = "DisablePM = '$DisablePM'";
2013-11-17 08:00:47 +00:00
$EditSummary[] = 'PM privileges ' . ($DisablePM ? 'disabled' : 'enabled');
2013-04-13 08:00:19 +00:00
$HeavyUpdates['DisablePM'] = $DisablePM;
2011-03-28 14:21:28 +00:00
if (!empty($UserReason)) {
2014-07-22 08:00:28 +00:00
Misc::send_pm($UserID, 0, 'Your PM privileges have been disabled', "Your PM privileges have been disabled. The reason given was: [quote]{$UserReason}[/quote] If you would like to discuss this, please join ".BOT_DISABLED_CHAN.' on our IRC network. Instructions can be found [url='.site_url().'wiki.php?action=article&amp;name=IRC+-+How+to+join]here[/url].');
2011-03-28 14:21:28 +00:00
}
}
2013-04-13 08:00:19 +00:00
if ($DisableIRC != $Cur['DisableIRC'] && check_perms('users_disable_any')) {
2013-06-24 08:00:28 +00:00
$UpdateSet[] = "DisableIRC = '$DisableIRC'";
2013-11-17 08:00:47 +00:00
$EditSummary[] = 'IRC privileges ' . ($DisableIRC ? 'disabled' : 'enabled');
2013-04-13 08:00:19 +00:00
$HeavyUpdates['DisableIRC'] = $DisableIRC;
2011-03-28 14:21:28 +00:00
if (!empty($UserReason)) {
2014-07-22 08:00:28 +00:00
Misc::send_pm($UserID, 0, 'Your IRC privileges have been disabled', "Your IRC privileges have been disabled. The reason given was: [quote]{$UserReason}[/quote] If you would like to discuss this, please join ".BOT_DISABLED_CHAN.' on our IRC network. Instructions can be found [url='.site_url().'wiki.php?action=article&amp;name=IRC+-+How+to+join]here[/url]. This loss of privileges does not affect the ability to join and talk to staff in '.BOT_DISABLED_CHAN.'.');
2011-03-28 14:21:28 +00:00
}
}
2013-04-13 08:00:19 +00:00
if ($DisableRequests != $Cur['DisableRequests'] && check_perms('users_disable_any')) {
2013-06-24 08:00:28 +00:00
$UpdateSet[] = "DisableRequests = '$DisableRequests'";
2013-11-17 08:00:47 +00:00
$EditSummary[] = 'request privileges ' . ($DisableRequests ? 'disabled' : 'enabled');
2013-04-13 08:00:19 +00:00
$HeavyUpdates['DisableRequests'] = $DisableRequests;
2011-03-28 14:21:28 +00:00
if (!empty($UserReason)) {
2014-07-22 08:00:28 +00:00
Misc::send_pm($UserID, 0, 'Your request privileges have been disabled', "Your request privileges have been disabled. The reason given was: [quote]{$UserReason}[/quote] If you would like to discuss this, please join ".BOT_DISABLED_CHAN.' on our IRC network. Instructions can be found [url='.site_url().'wiki.php?action=article&amp;name=IRC+-+How+to+join]here[/url].');
2011-03-28 14:21:28 +00:00
}
}
2013-04-13 08:00:19 +00:00
if ($EnableUser != $Cur['Enabled'] && check_perms('users_disable_users')) {
2011-10-01 08:00:08 +00:00
$EnableStr = 'account '.translateUserStatus($Cur['Enabled']).'->'.translateUserStatus($EnableUser);
2013-04-13 08:00:19 +00:00
if ($EnableUser == '2') {
2012-10-11 08:00:15 +00:00
Tools::disable_users($UserID, '', 1);
2015-02-19 08:00:27 +00:00
$TrackerUserUpdates = array();
2013-04-13 08:00:19 +00:00
} elseif ($EnableUser == '1') {
2011-03-28 14:21:28 +00:00
$Cache->increment('stats_user_count');
2015-02-19 08:00:27 +00:00
$VisibleTrIP = $Visible && $Cur['IP'] != '127.0.0.1' ? '1' : '0';
Tracker::update_tracker('add_user', array('id' => $UserID, 'passkey' => $Cur['torrent_pass'], 'visible' => $VisibleTrIP));
2013-06-24 08:00:28 +00:00
if (($Cur['Downloaded'] == 0) || ($Cur['Uploaded'] / $Cur['Downloaded'] >= $Cur['RequiredRatio'])) {
$UpdateSet[] = "i.RatioWatchEnds = '0000-00-00 00:00:00'";
2011-10-01 08:00:08 +00:00
$CanLeech = 1;
2013-06-24 08:00:28 +00:00
$UpdateSet[] = "m.can_leech = '1'";
$UpdateSet[] = "i.RatioWatchDownload = '0'";
2011-10-01 08:00:08 +00:00
} else {
2013-01-31 08:00:19 +00:00
$EnableStr .= ' (Ratio: '.Format::get_ratio_html($Cur['Uploaded'], $Cur['Downloaded'], false).', RR: '.number_format($Cur['RequiredRatio'],2).')';
2011-10-10 08:00:12 +00:00
if ($Cur['RatioWatchEnds'] != '0000-00-00 00:00:00') {
2013-06-24 08:00:28 +00:00
$UpdateSet[] = "i.RatioWatchEnds = NOW()";
$UpdateSet[] = "i.RatioWatchDownload = m.Downloaded";
2011-10-20 08:00:12 +00:00
$CanLeech = 0;
2011-10-10 08:00:12 +00:00
}
2015-02-19 08:00:27 +00:00
$TrackerUserUpdates['can_leech'] = 0;
2011-10-01 08:00:08 +00:00
}
2013-06-24 08:00:28 +00:00
$UpdateSet[] = "Enabled = '1'";
2011-03-28 14:21:28 +00:00
$LightUpdates['Enabled'] = 1;
}
2013-04-13 08:00:19 +00:00
$EditSummary[] = $EnableStr;
2013-06-24 08:00:28 +00:00
$Cache->replace_value("enabled_$UserID", $EnableUser, 0);
2011-03-28 14:21:28 +00:00
}
if ($ResetPasskey == 1 && check_perms('users_edit_reset_keys')) {
2012-10-11 08:00:15 +00:00
$Passkey = db_string(Users::make_secret());
2013-06-24 08:00:28 +00:00
$UpdateSet[] = "torrent_pass = '$Passkey'";
$EditSummary[] = 'passkey reset';
2013-04-13 08:00:19 +00:00
$HeavyUpdates['torrent_pass'] = $Passkey;
2015-02-19 08:00:27 +00:00
$TrackerUserUpdates['passkey'] = $Passkey;
2011-03-28 14:21:28 +00:00
$Cache->delete_value('user_'.$Cur['torrent_pass']);
//MUST come after the case for updating can_leech.
2012-02-01 08:00:25 +00:00
2013-05-14 08:00:34 +00:00
$DB->query("
INSERT INTO users_history_passkeys
(UserID, OldPassKey, NewPassKey, ChangerIP, ChangeTime)
VALUES
2012-02-01 08:00:25 +00:00
('$UserID', '".$Cur['torrent_pass']."', '$Passkey', '0.0.0.0', '".sqltime()."')");
2012-10-11 08:00:15 +00:00
Tracker::update_tracker('change_passkey', array('oldpasskey' => $Cur['torrent_pass'], 'newpasskey' => $Passkey));
2011-03-28 14:21:28 +00:00
}
if ($ResetAuthkey == 1 && check_perms('users_edit_reset_keys')) {
2012-10-11 08:00:15 +00:00
$Authkey = db_string(Users::make_secret());
2013-06-24 08:00:28 +00:00
$UpdateSet[] = "AuthKey = '$Authkey'";
$EditSummary[] = 'authkey reset';
2013-04-13 08:00:19 +00:00
$HeavyUpdates['AuthKey'] = $Authkey;
2011-03-28 14:21:28 +00:00
}
if ($SendHackedMail && check_perms('users_disable_any')) {
2013-06-24 08:00:28 +00:00
$EditSummary[] = "hacked account email sent to $HackedEmail";
2013-11-12 08:00:58 +00:00
Misc::send_email($HackedEmail, 'Your '.SITE_NAME.' account', 'Your '.SITE_NAME.' account appears to have been compromised. As a security measure, we have disabled your account. To resolve this, please visit us on IRC.
2011-03-28 14:21:28 +00:00
This is the information to connect to our server:
2013-06-24 08:00:28 +00:00
IRC Server: '.BOT_SERVER.'
2013-11-12 08:00:58 +00:00
Port: '.BOT_PORT.' ('.BOT_PORT_SSL.' for SSL)
2011-03-28 14:21:28 +00:00
2013-06-24 08:00:28 +00:00
Once you are connected to our server you will need to join our disabled users channel.
Type: /join '.BOT_DISABLED_CHAN.'
2011-03-28 14:21:28 +00:00
2015-01-28 08:00:26 +00:00
Please visit us soon so we can help you resolve this matter.', 'noreply');
2011-03-28 14:21:28 +00:00
}
if ($MergeStatsFrom && check_perms('users_edit_ratio')) {
2013-06-09 08:01:21 +00:00
$DB->query("
SELECT ID, Uploaded, Downloaded
FROM users_main
WHERE Username LIKE '$MergeStatsFrom'");
2013-07-10 00:08:53 +00:00
if ($DB->has_results()) {
2011-03-28 14:21:28 +00:00
list($MergeID, $MergeUploaded, $MergeDownloaded) = $DB->next_record();
2013-05-14 08:00:34 +00:00
$DB->query("
UPDATE users_main AS um
2013-06-24 08:00:28 +00:00
JOIN users_info AS ui ON um.ID = ui.UserID
2013-05-14 08:00:34 +00:00
SET
um.Uploaded = 0,
um.Downloaded = 0,
2013-11-12 08:00:58 +00:00
ui.AdminComment = CONCAT('".sqltime().' - Stats (Uploaded: '.Format::get_size($MergeUploaded).', Downloaded: '.Format::get_size($MergeDownloaded).', Ratio: '.Format::get_ratio($MergeUploaded, $MergeDownloaded).') merged into '.site_url()."user.php?id=$UserID (".$Cur['Username'].') by '.$LoggedUser['Username']."\n\n', ui.AdminComment)
2013-06-24 08:00:28 +00:00
WHERE ID = $MergeID");
2013-04-13 08:00:19 +00:00
$UpdateSet[] = "Uploaded = Uploaded + '$MergeUploaded'";
$UpdateSet[] = "Downloaded = Downloaded + '$MergeDownloaded'";
2013-11-12 08:00:58 +00:00
$EditSummary[] = 'stats merged from '.site_url()."user.php?id=$MergeID ($MergeStatsFrom) (previous stats: Uploaded: ".Format::get_size($Cur['Uploaded']).', Downloaded: '.Format::get_size($Cur['Downloaded']).', Ratio: '.Format::get_ratio($Cur['Uploaded'], $Cur['Downloaded']).')';
2014-05-07 08:00:45 +00:00
$Cache->delete_value("user_stats_$UserID");
$Cache->delete_value("user_stats_$MergeID");
2011-03-28 14:21:28 +00:00
}
}
if ($Pass && check_perms('users_edit_password')) {
2013-06-24 08:00:28 +00:00
$UpdateSet[] = "PassHash = '".db_string(Users::make_crypt_hash($Pass))."'";
2013-04-13 08:00:19 +00:00
$EditSummary[] = 'password reset';
2013-01-24 08:00:24 +00:00
2013-06-24 08:00:28 +00:00
$Cache->delete_value("user_info_$UserID");
$Cache->delete_value("user_info_heavy_$UserID");
$Cache->delete_value("user_stats_$UserID");
$Cache->delete_value("enabled_$UserID");
2011-03-28 14:21:28 +00:00
2013-06-09 08:01:21 +00:00
$DB->query("
SELECT SessionID
FROM users_sessions
2013-06-24 08:00:28 +00:00
WHERE UserID = '$UserID'");
2013-04-01 08:00:47 +00:00
while (list($SessionID) = $DB->next_record()) {
2013-06-24 08:00:28 +00:00
$Cache->delete_value("session_{$UserID}_$SessionID");
2011-03-28 14:21:28 +00:00
}
2013-06-24 08:00:28 +00:00
$Cache->delete_value("users_sessions_$UserID");
2013-05-16 16:15:57 +00:00
2013-06-09 08:01:21 +00:00
$DB->query("
DELETE FROM users_sessions
WHERE UserID = '$UserID'");
2013-05-16 16:15:57 +00:00
2011-03-28 14:21:28 +00:00
}
if (empty($UpdateSet) && empty($EditSummary)) {
2013-04-13 08:00:19 +00:00
if (!$Reason) {
2011-03-28 14:21:28 +00:00
if (str_replace("\r", '', $Cur['AdminComment']) != str_replace("\r", '', $AdminComment) && check_perms('users_disable_any')) {
2013-06-24 08:00:28 +00:00
$UpdateSet[] = "AdminComment = '$AdminComment'";
2011-03-28 14:21:28 +00:00
} else {
header("Location: user.php?id=$UserID");
die();
}
} else {
2013-04-13 08:00:19 +00:00
$EditSummary[] = 'notes added';
2011-03-28 14:21:28 +00:00
}
}
2015-02-19 08:00:27 +00:00
if (count($TrackerUserUpdates) > 1) {
Tracker::update_tracker('update_user', $TrackerUserUpdates);
}
2012-03-29 08:00:19 +00:00
if ($DeleteKeys) {
2013-06-24 08:00:28 +00:00
$Cache->delete_value("user_info_$UserID");
$Cache->delete_value("user_info_heavy_$UserID");
2012-03-29 08:00:19 +00:00
} else {
2013-06-24 08:00:28 +00:00
$Cache->begin_transaction("user_info_$UserID");
2012-03-29 08:00:19 +00:00
$Cache->update_row(false, $LightUpdates);
$Cache->commit_transaction(0);
2011-03-28 14:21:28 +00:00
2013-06-24 08:00:28 +00:00
$Cache->begin_transaction("user_info_heavy_$UserID");
2012-03-29 08:00:19 +00:00
$Cache->update_row(false, $HeavyUpdates);
$Cache->commit_transaction(0);
}
2011-03-28 14:21:28 +00:00
$Summary = '';
// Create edit summary
if ($EditSummary) {
2013-06-24 08:00:28 +00:00
$Summary = implode(', ', $EditSummary) . ' by ' . $LoggedUser['Username'];
$Summary = sqltime() . ' - ' . ucfirst($Summary);
2013-02-22 08:00:24 +00:00
2013-04-20 08:01:01 +00:00
if ($Reason) {
2013-06-24 08:00:28 +00:00
$Summary .= "\nReason: $Reason";
2011-03-28 14:21:28 +00:00
}
2013-02-22 08:00:24 +00:00
2013-05-16 16:15:57 +00:00
2013-06-24 08:00:28 +00:00
$Summary .= "\n\n$AdminComment";
2013-04-13 08:00:19 +00:00
} elseif (empty($UpdateSet) && empty($EditSummary) && $Cur['AdminComment'] == $_POST['AdminComment']) {
2013-06-24 08:00:28 +00:00
$Summary = sqltime() . ' - Comment added by ' . $LoggedUser['Username'] . ': ' . "$Reason\n\n";
2013-05-16 16:15:57 +00:00
2011-03-28 14:21:28 +00:00
}
2013-04-13 08:00:19 +00:00
if (!empty($Summary)) {
2013-06-24 08:00:28 +00:00
$UpdateSet[] = "AdminComment = '$Summary'";
2011-03-28 14:21:28 +00:00
} else {
2013-06-24 08:00:28 +00:00
$UpdateSet[] = "AdminComment = '$AdminComment'";
2011-03-28 14:21:28 +00:00
}
// Update cache
// Build query
$SET = implode(', ', $UpdateSet);
2013-06-24 08:00:28 +00:00
$SQL = "
UPDATE users_main AS m
JOIN users_info AS i ON m.ID = i.UserID
SET $SET
WHERE m.ID = '$UserID'";
2011-03-28 14:21:28 +00:00
// Perform update
2013-05-16 16:15:57 +00:00
//die($SQL);
$DB->query($SQL);
2011-03-28 14:21:28 +00:00
2013-04-13 08:00:19 +00:00
if (isset($ClearStaffIDCache)) {
2011-03-28 14:21:28 +00:00
$Cache->delete_value('staff_ids');
}
// redirect to user page
header("location: user.php?id=$UserID");
2013-05-16 16:15:57 +00:00
function translateUserStatus($Status) {
switch ($Status) {
2011-03-28 14:21:28 +00:00
case 0:
2013-05-01 08:00:16 +00:00
return 'Unconfirmed';
2011-03-28 14:21:28 +00:00
case 1:
2013-05-01 08:00:16 +00:00
return 'Enabled';
2011-03-28 14:21:28 +00:00
case 2:
2013-05-01 08:00:16 +00:00
return 'Disabled';
2011-03-28 14:21:28 +00:00
default:
2013-05-16 16:15:57 +00:00
return $Status;
2011-03-28 14:21:28 +00:00
}
}
2012-01-24 08:00:19 +00:00
2013-05-16 16:15:57 +00:00
function translateLeechStatus($Status) {
switch ($Status) {
2012-01-24 08:00:19 +00:00
case 0:
2013-05-01 08:00:16 +00:00
return 'Disabled';
2012-01-24 08:00:19 +00:00
case 1:
2013-05-01 08:00:16 +00:00
return 'Enabled';
2012-01-24 08:00:19 +00:00
default:
2013-05-16 16:15:57 +00:00
return $Status;
2012-01-24 08:00:19 +00:00
}
}
2011-03-28 14:21:28 +00:00
?>