Empty commit

This commit is contained in:
Git 2016-03-18 08:00:27 +00:00
parent 5a007ad9ee
commit 21333a0a27
16 changed files with 923 additions and 5 deletions

View File

@ -0,0 +1,355 @@
<?
class AutoEnable {
// Constants for database values
const APPROVED = 1;
const DENIED = 2;
const DISCARDED = 3;
// Cache key to store the number of enable requests
const CACHE_KEY_NAME = 'num_enable_requests';
// The default request rejected message
const REJECTED_MESSAGE = "Your request to re-enable your account has been rejected.<br />This may be because a request is already pending for your username, or because a recent request was denied.<br /><br />You are encouraged to discuss this with staff by visiting %s on %s";
// The default request received message
const RECEIVED_MESSAGE = "Your request to re-enable your account has been received. You can expect a reply message in your email within 48 hours.<br />If you do not receive an email after 48 hours have passed, please visit us on IRC for assistance.";
/**
* Handle a new enable request
*
* @param string $Username The user's username
* @param string $Email The user's email address
* @return string The output
*/
public static function new_request($Username, $Email) {
if (empty($Username)) {
header("Location: login.php");
die();
}
// Get the user's ID
G::$DB->query("
SELECT um.ID
FROM users_main AS um
JOIN users_info ui ON ui.UserID = um.ID
WHERE um.Username = '$Username'
AND um.Enabled = '2'");
if (G::$DB->has_results()) {
// Make sure the user can make another request
list($UserID) = G::$DB->next_record();
G::$DB->query("
SELECT 1 FROM users_enable_requests
WHERE UserID = '$UserID'
AND (
(
Timestamp > NOW() - INTERVAL 1 WEEK
AND HandledTimestamp IS NULL
)
OR
(
Timestamp > NOW() - INTERVAL 2 MONTH
AND
(Outcome = '".self::DENIED."'
OR Outcome = '".self::DISCARDED."')
)
)");
}
$IP = $_SERVER['REMOTE_ADDR'];
if (G::$DB->has_results() || !isset($UserID)) {
// User already has/had a pending activation request or username is invalid
$Output = sprintf(self::REJECTED_MESSAGE, BOT_DISABLED_CHAN, BOT_SERVER);
if (isset($UserID)) {
Tools::update_user_notes($UserID, sqltime() . " - Enable request rejected from $IP\n\n");
}
} else {
// New disable activation request
$UserAgent = db_string($_SERVER['HTTP_USER_AGENT']);
G::$DB->query("
INSERT INTO users_enable_requests
(UserID, Email, IP, UserAgent, Timestamp)
VALUES ('$UserID', '$Email', '$IP', '$UserAgent', '".sqltime()."')");
// Cache the number of requests for the modbar
G::$Cache->increment_value(self::CACHE_KEY_NAME);
setcookie('username', '', time() - 60 * 60, '/', '', false);
$Output = self::RECEIVED_MESSAGE;
Tools::update_user_notes($UserID, sqltime() . " - Enable request " . G::$DB->inserted_id() . " received from $IP\n\n");
}
return $Output;
}
/*
* Handle requests
*
* @param int|int[] $IDs An array of IDs, or a single ID
* @param int $Status The status to mark the requests as
* @param string $Comment The staff member comment
*/
public static function handle_requests($IDs, $Status, $Comment) {
if ($Status != self::APPROVED && $Status != self::DENIED && $Status != self::DISCARDED) {
error(404);
}
$UserInfo = array();
$IDs = (!is_array($IDs)) ? [$IDs] : $IDs;
if (count($IDs) == 0) {
error(404);
}
foreach ($IDs as $ID) {
if (!is_number($ID)) {
error(404);
}
}
G::$DB->query("SELECT Email, ID, UserID
FROM users_enable_requests
WHERE ID IN (".implode(',', $IDs).")
AND Outcome IS NULL");
$Results = G::$DB->to_array(false, MYSQLI_NUM);
if ($Status != self::DISCARDED) {
// Prepare email
require(SERVER_ROOT . '/classes/templates.class.php');
$TPL = NEW TEMPLATE;
if ($Status == self::APPROVED) {
$TPL->open(SERVER_ROOT . '/templates/enable_request_accepted.tpl');
$TPL->set('SITE_URL', NONSSL_SITE_URL);
} else {
$TPL->open(SERVER_ROOT . '/templates/enable_request_denied.tpl');
}
$TPL->set('SITE_NAME', SITE_NAME);
foreach ($Results as $Result) {
list($Email, $ID, $UserID) = $Result;
$UserInfo[] = array($ID, $UserID);
if ($Status == self::APPROVED) {
// Generate token
$Token = db_string(Users::make_secret());
G::$DB->query("
UPDATE users_enable_requests
SET Token = '$Token'
WHERE ID = '$ID'");
$TPL->set('TOKEN', $Token);
}
// Send email
$Subject = "Your enable request for " . SITE_NAME . " has been ";
$Subject .= ($Status == self::APPROVED) ? 'approved' : 'denied';
Misc::send_email($Email, $Subject, $TPL->get(), 'noreply');
}
} else {
foreach ($Results as $Result) {
list(, $ID, $UserID) = $Result;
$UserInfo[] = array($ID, $UserID);
}
}
// User notes stuff
G::$DB->query("
SELECT Username
FROM users_main
WHERE ID = '" . G::$LoggedUser['ID'] . "'");
list($StaffUser) = G::$DB->next_record();
foreach ($UserInfo as $User) {
list($ID, $UserID) = $User;
$BaseComment = sqltime() . " - Enable request $ID " . strtolower(self::get_outcome_string($Status)) . ' by [user]'.$StaffUser.'[/user]';
$BaseComment .= (!empty($Comment)) ? "\nReason: $Comment\n\n" : "\n\n";
Tools::update_user_notes($UserID, $BaseComment);
}
// Update database values and decrement cache
G::$DB->query("
UPDATE users_enable_requests
SET HandledTimestamp = '".sqltime()."',
CheckedBy = '".G::$LoggedUser['ID']."',
Outcome = '$Status'
WHERE ID IN (".implode(',', $IDs).")");
G::$Cache->decrement_value(self::CACHE_KEY_NAME, count($IDs));
}
/**
* Unresolve a discarded request
*
* @param int $ID The request ID
*/
public static function unresolve_request($ID) {
$ID = (int) $ID;
if (empty($ID)) {
error(404);
}
G::$DB->query("
SELECT UserID
FROM users_enable_requests
WHERE Outcome = '" . self::DISCARDED . "'
AND ID = '$ID'");
if (!G::$DB->has_results()) {
error(404);
} else {
list($UserID) = G::$DB->next_record();
}
G::$DB->query("
SELECT Username
FROM users_main
WHERE ID = '" . G::$LoggedUser['ID'] . "'");
list($StaffUser) = G::$DB->next_record();
Tools::update_user_notes($UserID, sqltime() . " - Enable request $ID unresolved by [user]" . $StaffUser . '[/user]' . "\n\n");
G::$DB->query("
UPDATE users_enable_requests
SET Outcome = NULL, HandledTimestamp = NULL, CheckedBy = NULL
WHERE ID = '$ID'");
G::$Cache->increment_value(self::CACHE_KEY_NAME);
}
/**
* Get the corresponding outcome string for a numerical value
*
* @param int $Outcome The outcome integer
* @return string The formatted output string
*/
public static function get_outcome_string($Outcome) {
if ($Outcome == self::APPROVED) {
$String = "Approved";
} else if ($Outcome == self::DENIED) {
$String = "Rejected";
} else if ($Outcome == self::DISCARDED) {
$String = "Discarded";
} else {
$String = "---";
}
return $String;
}
/**
* Handle a user's request to enable an account
*
* @param string $Token The token
* @return string The error output, or an empty string
*/
public static function handle_token($Token) {
$Token = db_string($Token);
G::$DB->query("
SELECT UserID, HandledTimestamp
FROM users_enable_requests
WHERE Token = '$Token'");
if (G::$DB->has_results()) {
list($UserID, $Timestamp) = G::$DB->next_record();
G::$DB->query("UPDATE users_enable_requests SET Token = NULL WHERE Token = '$Token'");
if ($Timestamp < time_minus(3600 * 48)) {
// Old request
Tools::update_user_notes($UserID, sqltime() . " - Tried to use an expired enable token from ".$_SERVER['REMOTE_ADDR']."\n\n");
$Err = "Token has expired. Please visit ".BOT_DISABLED_CHAN." on ".BOT_SERVER." to discuss this with staff.";
} else {
// Good request, decrement cache value and enable account
G::$Cache->decrement_value(AutoEnable::CACHE_KEY_NAME);
G::$DB->query("UPDATE users_main SET Enabled = '1' WHERE ID = '$UserID'");
G::$DB->query("UPDATE users_info SET BanReason = '0' WHERE UserID = '$UserID'");
$Err = "Your account has been enabled. You may now log in.";
}
} else {
$Err = "Invalid token.";
}
return $Err;
}
/**
* Build the search query, from the searchbox inputs
*
* @param int $UserID The user ID
* @param string $IP The IP
* @param string $SubmittedTimestamp The timestamp representing when the request was submitted
* @param int $HandledUserID The ID of the user that handled the request
* @param string $HandledTimestamp The timestamp representing when the request was handled
* @param int $OutcomeSearch The outcome of the request
* @param boolean $Checked Should checked requests be included?
* @return array The WHERE conditions for the query
*/
public static function build_search_query($Username, $IP, $SubmittedBetween, $SubmittedTimestamp1, $SubmittedTimestamp2, $HandledUsername, $HandledBetween, $HandledTimestamp1, $HandledTimestamp2, $OutcomeSearch, $Checked) {
$Where = array();
if (!empty($Username)) {
$Where[] = "um1.Username = '$Username'";
}
if (!empty($IP)) {
$Where[] = "uer.IP = '$IP'";
}
if (!empty($SubmittedTimestamp1)) {
switch($SubmittedBetween) {
case 'on':
$Where[] = "DATE(uer.Timestamp) = DATE('$SubmittedTimestamp1')";
break;
case 'before':
$Where[] = "DATE(uer.Timestamp) < DATE('$SubmittedTimestamp1')";
break;
case 'after':
$Where[] = "DATE(uer.Timestamp) > DATE('$SubmittedTimestamp1')";
break;
case 'between':
if (!empty($SubmittedTimestamp2)) {
$Where[] = "DATE(uer.Timestamp) BETWEEN DATE('$SubmittedTimestamp1') AND DATE('$SubmittedTimestamp2')";
}
break;
default:
break;
}
}
if (!empty($HandledTimestamp1)) {
switch($HandledBetween) {
case 'on':
$Where[] = "DATE(uer.HandledTimestamp) = DATE('$HandledTimestamp1')";
break;
case 'before':
$Where[] = "DATE(uer.HandledTimestamp) < DATE('$HandledTimestamp1')";
break;
case 'after':
$Where[] = "DATE(uer.HandledTimestamp) > DATE('$HandledTimestamp1')";
break;
case 'between':
if (!empty($HandledTimestamp2)) {
$Where[] = "DATE(uer.HandledTimestamp) BETWEEN DATE('$HandledTimestamp1') AND DATE('$HandledTimestamp2')";
}
break;
default:
break;
}
}
if (!empty($HandledUsername)) {
$Where[] = "um2.Username = '$HandledUsername'";
}
if (!empty($OutcomeSearch)) {
$Where[] = "uer.Outcome = '$OutcomeSearch'";
}
if ($Checked) {
// This is to skip the if statement in enable_requests.php
$Where[] = "(uer.Outcome IS NULL OR uer.Outcome IS NOT NULL)";
}
return $Where;
}
}

View File

@ -69,6 +69,9 @@ define('STARTING_INVITES', 0); //# of invites to give to newly registered users
define('BLOCK_TOR', false); //Set to true to block Tor users
define('BLOCK_OPERA_MINI', false); //Set to true to block Opera Mini proxy
define('DONOR_INVITES', 2);
if (!defined('FEATURE_EMAIL_REENABLE')) {
define('FEATURE_EMAIL_REENABLE', true);
}
// User class IDs needed for automatic promotions. Found in the 'permissions' table
// Name of class Class ID (NOT level)

View File

@ -496,6 +496,18 @@
}
if (check_perms('users_mod') && FEATURE_EMAIL_REENABLE) {
$NumEnableRequests = G::$Cache->get_value(AutoEnable::CACHE_KEY_NAME);
if ($NumEnableRequests === false) {
G::$DB->query("SELECT COUNT(1) FROM users_enable_requests WHERE Outcome IS NULL");
list($NumEnableRequests) = G::$DB->next_record();
G::$Cache->cache_value(AutoEnable::CACHE_KEY_NAME, $NumEnableRequests);
}
if ($NumEnableRequests > 0) {
$ModBar[] = '<a href="tools.php?action=enable_requests">' . $NumEnableRequests . " Enable requests</a>";
}
}
?>
<?
if (!empty($Alerts) || !empty($ModBar)) { ?>

1
enable.php Normal file
View File

@ -0,0 +1 @@
<? require('classes/script_start.php');

View File

@ -1410,6 +1410,24 @@ CREATE TABLE `users_enable_recommendations` (
KEY `Enable` (`Enable`)
) ENGINE=InnoDB CHARSET utf8;
CREATE TABLE `users_enable_requests` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`UserID` int(10) unsigned NOT NULL,
`Email` varchar(255) NOT NULL,
`IP` varchar(15) NOT NULL DEFAULT '0.0.0.0',
`UserAgent` text NOT NULL,
`Timestamp` datetime NOT NULL,
`HandledTimestamp` datetime DEFAULT NULL,
`Token` char(32) DEFAULT NULL,
`CheckedBy` int(10) unsigned DEFAULT NULL,
`Outcome` tinyint(1) DEFAULT NULL COMMENT '1 for approved, 2 for denied, 3 for discarded',
PRIMARY KEY (`ID`),
KEY `UserId` (`UserID`),
KEY `CheckedBy` (`CheckedBy`),
CONSTRAINT `users_enable_requests_ibfk_1` FOREIGN KEY (`UserID`) REFERENCES `users_main` (`ID`),
CONSTRAINT `users_enable_requests_ibfk_2` FOREIGN KEY (`CheckedBy`) REFERENCES `users_main` (`ID`)
) ENGINE=InnoDB CHARSET utf8;
CREATE TABLE `users_freeleeches` (
`UserID` int(10) NOT NULL,
`TorrentID` int(10) NOT NULL,

16
sections/enable/index.php Normal file
View File

@ -0,0 +1,16 @@
<?
if (isset($LoggedUser['ID']) || !isset($_GET['token']) || !FEATURE_EMAIL_REENABLE) {
header("Location: index.php");
die();
}
if (isset($_GET['token'])) {
$Err = AutoEnable::handle_token($_GET['token']);
}
View::show_header("Enable Request");
echo $Err; // This will always be set
View::show_footer();

View File

@ -1,11 +1,31 @@
<?
View::show_header('Disabled');
if (empty($_POST['submit']) || empty($_POST['username'])) {
if (isset($_POST['email']) && FEATURE_EMAIL_REENABLE) {
// Handle auto-enable request
if ($_POST['email'] != '') {
$Output = AutoEnable::new_request(db_string($_POST['username']), db_string($_POST['email']));
} else {
$Output = "Please enter a valid email address.";
}
$Output .= "<br /><br /><a href='login.php?action=disabled'>Back</a>";
}
if ((empty($_POST['submit']) || empty($_POST['username'])) && !isset($Output)) {
?>
<p class="warning">
Your account has been disabled.<br />
This is either due to inactivity or rule violation(s).<br />
To discuss this with staff, come to our IRC network at: <?=BOT_SERVER?><br />
This is either due to inactivity or rule violation(s).<br /><br /></p>
<? if (FEATURE_EMAIL_REENABLE) { ?>
If you believe your account was in good standing and was disabled for inactivity, you may request it be re-enabled via email using the form below.<br />
Please note that you will need access to the email account associated with your account at What.CD for this to work;<br />
if you do not, please see the section after this form.<br /><br />
<form action="" method="POST">
<input type="email" class="inputtext" placeholder="Email Address" name="email" required /> <input type="submit" value="Submit" />
<input type="hidden" name="username" value="<?=$_COOKIE['username']?>" />
</form><br /><br />
<? } ?>
If you are unsure why your account is disabled, or you wish to discuss this with staff, come to our IRC network at: <?=BOT_SERVER?><br />
And join <?=BOT_DISABLED_CHAN?><br /><br />
<strong>Be honest.</strong> At this point, lying will get you nowhere.<br /><br /><br />
</p>
@ -40,7 +60,7 @@ function toggle_visibility(id) {
<input type="submit" name="submit" value="Join WebIRC" />
</form>
<?
} else {
} else if (!isset($Output)) {
$Nick = $_POST['username'];
$Nick = preg_replace('/[^a-zA-Z0-9\[\]\\`\^\{\}\|_]/', '', $Nick);
if (strlen($Nick) == 0) {
@ -76,6 +96,9 @@ function toggle_visibility(id) {
</div>
</div>
<?
} else {
echo $Output;
}
View::show_footer();
?>

View File

@ -330,7 +330,9 @@ function log_attempt($UserID) {
log_attempt($UserID);
if ($Enabled == 2) {
header('location:login.php?action=disabled');
// Save the username in a cookie for the disabled page
setcookie('username', db_string($_POST['username']), time() + 60 * 60, '/', '', false);
header('Location: login.php?action=disabled');
} elseif ($Enabled == 0) {
$Err = 'Your account has not been confirmed.<br />Please check your email.';
}

View File

@ -77,6 +77,19 @@
include(SERVER_ROOT.'/sections/tools/managers/whitelist_alter.php');
break;
case 'enable_requests':
include(SERVER_ROOT.'/sections/tools/managers/enable_requests.php');
break;
case 'ajax_take_enable_request':
if (FEATURE_EMAIL_REENABLE) {
include(SERVER_ROOT.'/sections/tools/managers/ajax_take_enable_request.php');
} else {
// Prevent post requests to the ajax page
header("Location: tools.php");
die();
}
break;
case 'login_watch':
include(SERVER_ROOT.'/sections/tools/managers/login_watch.php');
break;

View File

@ -0,0 +1,48 @@
<?
if (!check_perms('users_mod')) {
json_error(403);
}
if (!FEATURE_EMAIL_REENABLE) {
json_error("This feature is currently disabled.");
}
$Type = $_GET['type'];
if ($Type == "resolve") {
$IDs = $_GET['ids'];
$Comment = db_string($_GET['comment']);
$Status = db_string($_GET['status']);
// Error check and set things up
if ($Status == "Approve" || $Status == "Approve Selected") {
$Status = AutoEnable::APPROVED;
} else if ($Status == "Reject" || $Status == "Reject Selected") {
$Status = AutoEnable::DENIED;
} else if ($Status == "Discard" || $Status == "Discard Selected") {
$Status = AutoEnable::DISCARDED;
} else {
json_error("Invalid resolution option");
}
if (is_array($IDs) && count($IDs) == 0) {
json_error("You must select at least one reuqest to use this option");
} else if (!is_array($IDs) && !is_number($IDs)) {
json_error("You must select at least 1 request");
}
// Handle request
AutoEnable::handle_requests($IDs, $Status, $Comment);
} else if ($Type == "unresolve") {
$ID = (int) $_GET['id'];
AutoEnable::unresolve_request($ID);
} else {
json_error("Invalid type");
}
echo json_encode(array("status" => "success"));
function json_error($Message) {
echo json_encode(array("status" => $Message));
die();
}

View File

@ -0,0 +1,315 @@
<?
if (!check_perms('users_mod')) {
error(403);
}
if (!FEATURE_EMAIL_REENABLE) {
// This feature is disabled
header("Location: tools.php");
die();
}
View::show_header("Enable Requests", 'enable_requests');
// Pagination
$RequestsPerPage = 25;
list($Page, $Limit) = Format::page_limit($RequestsPerPage);
// How can things be ordered?
$OrderBys = array(
'submitted_timestamp' => 'uer.Timestamp',
'outcome' => 'uer.Outcome',
'handled_timestamp' => 'uer.HandledTimestamp');
$Where = [];
$Joins = [];
// Default orderings
$OrderBy = "uer.Timestamp";
$OrderWay = "DESC";
// Build query for different views
if ($_GET['view'] == 'perfect') {
$Where[] = "um.Email = uer.Email";
$Joins[] = "JOIN users_main um ON um.ID = uer.UserID";
$Where[] = "uer.IP = (SELECT IP FROM users_history_ips uhi1 WHERE uhi1.StartTime = (SELECT MAX(StartTime) FROM users_history_ips uhi2 WHERE uhi2.UserID = uer.UserID ORDER BY StartTime DESC LIMIT 1))";
$Where[] = "(SELECT 1 FROM users_history_ips uhi WHERE uhi.IP = uer.IP AND uhi.UserID != uer.UserID) IS NULL";
$Where[] = "ui.BanReason = '3'";
} else if ($_GET['view'] == 'minus_ip') {
$Where[] = "um.Email = uer.Email";
$Joins[] = "JOIN users_main um ON um.ID = uer.UserID";
$Where[] = "ui.BanReason = '3'";
} else if ($_GET['view'] == 'invalid_email') {
$Joins[] = "JOIN users_main um ON um.ID = uer.UserID";
$Where[] = "um.Email != uer.Email";
} else if ($_GET['view'] == 'ip_overlap') {
$Joins[] = "JOIN users_history_ips uhi ON uhi.IP = uer.IP AND uhi.UserID != uer.UserID";
} else if ($_GET['view'] == 'manual_disable') {
$Where[] = "ui.BanReason != '3'";
} else {
$Joins[] = '';
}
// End views
// Build query further based on search
if (isset($_GET['search'])) {
$Username = db_string($_GET['username']);
$IP = db_string($_GET['ip']);
$SubmittedBetween = db_string($_GET['submitted_between']);
$SubmittedTimestamp1 = db_string($_GET['submitted_timestamp1']);
$SubmittedTimestamp2 = db_string($_GET['submitted_timestamp2']);
$HandledUsername = db_string($_GET['handled_username']);
$HandledBetween = db_string($_GET['handled_between']);
$HandledTimestamp1 = db_string($_GET['handled_timestamp1']);
$HandledTimestamp2 = db_string($_GET['handled_timestamp2']);
$OutcomeSearch = (int) $_GET['outcome_search'];
$Checked = (isset($_GET['show_checked']));
if (array_key_exists($_GET['order'], $OrderBys)) {
$OrderBy = $OrderBys[$_GET['order']];
}
if ($_GET['way'] == "asc" || $_GET['way'] == "desc") {
$OrderWay = $_GET['way'];
}
if (!empty($Username)) {
$Joins[] = "JOIN users_main um1 ON um1.ID = uer.UserID";
}
if (!empty($HandledUsername)) {
$Joins[] = "JOIN users_main um2 ON um2.ID = uer.CheckedBy";
}
$Where = array_merge($Where, AutoEnable::build_search_query($Username,
$IP, $SubmittedBetween, $SubmittedTimestamp1, $SubmittedTimestamp2, $HandledUsername,
$HandledBetween, $HandledTimestamp1, $HandledTimestamp2, $OutcomeSearch, $Checked));
}
// End search queries
$ShowChecked = $Checked || !empty($HandledUsername) || !empty($HandledTimestamp1) || !empty($OutcomeSearch);
if (!$ShowChecked || count($Where) == 0) {
// If no search is entered, add this to the query to only show unchecked requests
$Where[] = 'Outcome IS NULL';
}
$QueryID = $DB->query("
SELECT SQL_CALC_FOUND_ROWS
uer.ID,
uer.UserID,
uer.Email,
uer.IP,
uer.UserAgent,
uer.Timestamp,
ui.BanReason,
uer.CheckedBy,
uer.HandledTimestamp,
uer.Outcome
FROM users_enable_requests AS uer
JOIN users_info ui ON ui.UserID = uer.UserID
".implode(' ', $Joins)."
WHERE
".implode(' AND ', $Where)."
ORDER BY $OrderBy $OrderWay
LIMIT $Limit");
$DB->query("SELECT FOUND_ROWS()");
list($NumResults) = $DB->next_record();
$DB->set_query_id($QueryID);
?>
<div class="header">
<h2>Auto-Enable Requests</h2>
</div>
<div align="center">
<a class="brackets tooltip" href="tools.php?action=enable_requests" title="Default view">Main</a>
<a class="brackets tooltip" href="tools.php?action=enable_requests&amp;view=perfect&amp;<?=Format::get_url(array('view', 'action'))?>" title="Valid username, matching email, current IP with no matches, and inactivity disabled">Perfect</a>
<a class="brackets tooltip" href="tools.php?action=enable_requests&amp;view=minus_ip&amp;<?=Format::get_url(array('view', 'action'))?>" title="Valid username, matching email, and inactivity disabled">Perfect Minus IP</a>
<a class="brackets tooltip" href="tools.php?action=enable_requests&amp;view=invalid_email&amp;<?=Format::get_url(array('view', 'action'))?>" title="Non-matching email address">Invalid Email</a>
<a class="brackets tooltip" href="tools.php?action=enable_requests&amp;view=ip_overlap&amp;<?=Format::get_url(array('view', 'action'))?>" title="Requests with IP matches to other accounts">IP Overlap</a>
<a class="brackets tooltip" href="tools.php?action=enable_requests&amp;view=manual_disable&amp;<?=Format::get_url(array('view', 'action'))?>" title="Requests for accounts that were not disabled for inactivity">Manual Disable</a>
<a class="brackets tooltip" href="" title="Show/Hide Search" onclick="$('#search_form').gtoggle(); return false;">Search</a>
<a class="brackets tooltip" href="" title="Show/Hide Search" onclick="$('#scores').gtoggle(); return false;">Scores</a>
</div><br />
<div class="thin">
<table id="scores" class="hidden" style="width: 50%; margin: 0 auto;">
<tr>
<th>Username</th>
<th>Checked</th>
</tr>
<? $DB->query("
SELECT COUNT(CheckedBy), CheckedBy
FROM users_enable_requests
WHERE CheckedBy IS NOT NULL
GROUP BY CheckedBy
ORDER BY COUNT(CheckedBy) DESC
LIMIT 50");
while (list($Checked, $UserID) = $DB->next_record()) { ?>
<tr>
<td><?=Users::format_username($UserID)?></td>
<td><?=$Checked?></td>
</tr>
<? }
$DB->set_query_id($QueryID); ?>
</table>
<form action="" method="GET" id="search_form" <?=!isset($_GET['search']) ? 'class="hidden"' : ''?>>
<input type="hidden" name="action" value="enable_requests" />
<input type="hidden" name="view" value="<?=$_GET['view']?>" />
<input type="hidden" name="search" value="1" />
<table>
<tr>
<td class="label">Username</td>
<td><input type="text" name="username" value="<?=$_GET['username']?>" /></td>
</tr>
<tr>
<td class="label">IP Address</td>
<td><input type="text" name="ip" value="<?=$_GET['ip']?>" /></td>
</tr>
<tr>
<td class="label tooltip" title="This will search between the entered date and 24 hours after it">Submitted Timestamp</td>
<td>
<select name="submitted_between" onchange="ChangeDateSearch(this.value, 'submitted_timestamp2');">
<option value="on" <?=$_GET['submitted_between'] == 'on' ? 'selected' : ''?>>On</option>
<option value="before" <?=$_GET['submitted_between'] == 'before' ? 'selected' : ''?>>Before</option>
<option value="after" <?=$_GET['submitted_between'] == 'after' ? 'selected' : ''?>>After</option>
<option value="between" <?=$_GET['submitted_between'] == 'between' ? 'selected' : ''?>>Between</option>
</select>&nbsp;
<input type="date" name="submitted_timestamp1" value="<?=$_GET['submitted_timestamp1']?>" />
<input type="date" id="submitted_timestamp2" name="submitted_timestamp2" value="<?=$_GET['submitted_timestamp2']?>" <?=$_GET['submitted_between'] != 'between' ? 'style="display: none;"' : ''?>/>
</td>
</tr>
<tr>
<td class="label">Handled By Username</td>
<td><input type="text" name="handled_username" value="<?=$_GET['handled_username']?>" /></td>
</tr>
<tr>
<td class="label tooltip" title="This will search between the entered date and 24 hours after it">Handled Timestamp</td>
<td>
<select name="handled_between" onchange="ChangeDateSearch(this.value, 'handled_timestamp2');">
<option value="on" <?=$_GET['handled_between'] == 'on' ? 'selected' : ''?>>On</option>
<option value="before" <?=$_GET['handled_between'] == 'before' ? 'selected' : ''?>>Before</option>
<option value="after" <?=$_GET['handled_between'] == 'after' ? 'selected' : ''?>>After</option>
<option value="between" <?=$_GET['handled_between'] == 'between' ? 'selected' : ''?>>Between</option>
</select>&nbsp;
<input type="date" name="handled_timestamp1" value="<?=$_GET['handled_timestamp1']?>" />
<input type="date" id="handled_timestamp2" name="handled_timestamp2" value="<?=$_GET['handled_timestamp2']?>" <?=$_GET['handled_between'] != 'between' ? 'style="display: none;"' : ''?>/>
</td>
</tr>
<tr>
<td class="label">Outcome</td>
<td>
<select name="outcome_search">
<option value="">---</option>
<option value="<?=AutoEnable::APPROVED?>" <?=$_GET['outcome_search'] == AutoEnable::APPROVED ? 'selected' : ''?>>Approved</option>
<option value="<?=AutoEnable::DENIED?>" <?=$_GET['outcome_search'] == AutoEnable::DENIED ? 'selected' : ''?>>Denied</option>
<option value="<?=AutoEnable::DISCARDED?>" <?=$_GET['outcome_search'] == AutoEnable::DISCARDED ? 'selected' : ''?>>Discarded</option>
</select>
</td>
</tr>
<tr>
<td class="label">Include Checked</td>
<td><input type="checkbox" name="show_checked" <?=isset($_GET['show_checked']) ? 'checked' : ''?> /></td>
</tr>
<tr>
<td class="label">Order By</td>
<td>
<select name="order">
<option value="submitted_timestamp" <?=$_GET['order'] == 'submitted_timestamp' ? 'selected' : '' ?>>Submitted Timestamp</option>
<option value="outcome" <?=$_GET['order'] == 'outcome' ? 'selected' : '' ?>>Outcome</option>
<option value="handled_timestamp" <?=$_GET['order'] == 'handled_timestamp' ? 'selected' : '' ?>>Handled Timestamp</option>
</select>&nbsp;
<select name="way">
<option value="asc" <?=$_GET['way'] == 'asc' ? 'selected' : '' ?>>Ascending</option>
<option value="desc" <?=!isset($_GET['way']) || $_GET['way'] == 'desc' ? 'selected' : '' ?>>Descending</option>
</select>
</td>
</tr>
<tr>
<td colspan=2><input type="submit" value="Search" /></td>
</tr>
</table>
</form>
</div>
<?
if ($NumResults > 0) { ?>
<div class="linkbox">
<?
$Pages = Format::get_pages($Page, $NumResults, $RequestsPerPage);
echo $Pages;
?>
</div>
<table width="100%">
<tr class="colhead">
<td class="center"><input type="checkbox" id="check_all" /></td>
<td>Username</td>
<td>Email Address</td>
<td>IP Address</td>
<td>User Agent</td>
<td>Age</td>
<td>Ban Reason</td>
<td>Comment<?=$ShowChecked ? '/Checked By' : ''?></td>
<td>Submit<?=$ShowChecked ? '/Checked Date' : ''?></td>
<? if ($ShowChecked) { ?>
<td>Outcome</td>
<? } ?>
</tr>
<?
$Row = 'a';
while (list($ID, $UserID, $Email, $IP, $UserAgent, $Timestamp, $BanReason, $CheckedBy, $HandledTimestamp, $Outcome) = $DB->next_record()) {
$Row = $Row === 'a' ? 'b' : 'a';
?>
<tr class="row<?=$Row?>" id="row_<?=$ID?>">
<td class="center">
<? if (!$HandledTimestamp) { ?>
<input type="checkbox" id="multi" data-id="<?=$ID?>" />
<? } ?>
</td>
<td><?=Users::format_username($UserID)?></td>
<td><?=display_str($Email)?></td>
<td><?=display_str($IP)?></td>
<td><?=display_str($UserAgent)?></td>
<td><?=time_diff($Timestamp)?></td>
<td><?=($BanReason == 3) ? '<b>Inactivity</b>' : 'Other'?></td>
<? if (!$HandledTimestamp) { ?>
<td><input class="inputtext" type="text" id="comment<?=$ID?>" placeholder="Comment" /></td>
<td>
<input type="submit" id="outcome" value="Approve" data-id="<?=$ID?>" />
<input type="submit" id="outcome" value="Reject" data-id="<?=$ID?>" />
<input type="submit" id="outcome" value="Discard" data-id="<?=$ID?>" />
</td>
<? } else { ?>
<td><?=Users::format_username($CheckedBy);?></td>
<td><?=$HandledTimestamp?></td>
<? }
if ($ShowChecked) { ?>
<td><?=AutoEnable::get_outcome_string($Outcome)?>
<? if ($Outcome == AutoEnable::DISCARDED) { ?>
<a href="" id="unresolve" onclick="return false;" class="brackets" data-id="<?=$ID?>">Unresolve</a>
<? } ?>
</td>
<? } ?>
</tr>
<?
}
?>
</table>
<div class="linkbox">
<?
$Pages = Format::get_pages($Page, $NumResults, $RequestsPerPage);
echo $Pages;
?>
</div>
<div style="padding-bottom: 11px;">
<input type="submit" id="outcome" value="Approve Selected" />
<input type="submit" id="outcome" value="Reject Selected" />
<input type="submit" id="outcome" value="Discard Selected" />
</div>
<? } else { ?>
<h2 align="center">No new pending auto enable requests<?=isset($_GET['view']) ? ' in this view' : ''?></h2>
<? }
View::show_footer();

View File

@ -115,6 +115,7 @@ function create_row($Title, $URL, $HasPermission = false, $Tooltip = false) {
<?
// begin Queue category
$ToolsHTML = "";
create_row("Auto-Enable requests", "tools.php?action=enable_requests", check_perms("users_mod"));
create_row("Login watch", "tools.php?action=login_watch", check_perms("admin_login_watch"));
if ($ToolsHTML) {

View File

@ -698,6 +698,7 @@
}
$TrackerUserUpdates['can_leech'] = 0;
}
$UpdateSet[] = "i.BanReason = '0'";
$UpdateSet[] = "Enabled = '1'";
$LightUpdates['Enabled'] = 1;
}

View File

@ -0,0 +1,96 @@
(function() {
var ids = Array();
$(document).ready(function() {
$("input[id^=check_all]").click(function() {
// Check or uncheck all requests
var checked = ($(this).attr('checked') == 'checked') ? true : false;
$("input[id^=multi]").each(function() {
$(this).attr('checked', checked);
var id = $(this).data('id');
if (checked && $.inArray(id, ids) == -1) {
ids.push(id);
} else if (!checked && $.inArray(id, ids) != -1) {
ids = $.grep(ids, function(value) {
return value != id;
});
}
});
});
$("input[id^=multi]").click(function() {
// Put the ID in the array if checked, or removed if unchecked
var checked = ($(this).attr('checked') == 'checked') ? true : false;
var id = $(this).data('id');
if (checked && $.inArray(id, ids) == -1) {
ids.push(id);
} else if (!checked && $.inArray(id, ids) != -1) {
ids = $.grep(ids, function(value) {
return value != id;
});
}
});
$("input[id^=outcome]").click(function() {
if ($(this).val() != 'Discard' && !confirm('Are you sure you wish to do this? This cannot be undone!')) {
return false;
}
var id = $(this).data('id');
if (id !== undefined) {
// Only resolving one row
resolveIDs = [id];
var comment = $("input[id^=comment" + id + "]").val();
} else {
resolveIDs = ids;
comment = '';
}
$.ajax({
type : "GET",
dataType : "json",
url : "tools.php?action=ajax_take_enable_request",
data : {
"ids" : resolveIDs,
"comment" : comment,
"status" : $(this).val(),
"type" : "resolve"
}
}).done(function(response) {
if (response['status'] == 'success') {
for (var i = 0; i < resolveIDs.length; i++) {
$("#row_" + resolveIDs[i]).remove();
}
} else {
alert(response['status']);
}
});
});
$("a[id^=unresolve]").click(function() {
var id = $(this).data('id');
if (id !== undefined) {
$.ajax({
type: "GET",
dataType: "json",
url: "tools.php?action=ajax_take_enable_request",
data : {
"id" : id,
"type" : "unresolve"
}
}).done(function(response) {
if (response['status'] == 'success') {
$("#row_" + id).remove();
alert("The request has been un-resolved. Please refresh your browser to see it.");
} else {
alert(response['status']);
}
});
}
});
});
})();
function ChangeDateSearch(rangeVariable, dateTwoID) {
var fullID = "#" + dateTwoID;
if (rangeVariable === 'between') {
$(fullID).show();
} else {
$(fullID).hide();
}
}

View File

@ -0,0 +1,6 @@
Your request to re-enable your account has been accepted. Please use the following link to activate your account. This link is valid for 48 hours, and can be clicked only once.
https://{{SITE_URL}}/enable.php?token={{TOKEN}}
Thank you,
{{SITE_NAME}} Staff

View File

@ -0,0 +1,8 @@
Your request to re-enable your account was not accepted, for one or more of the following reasons:
* We may require more information to verify your account ownership.
* The e-mail address you provided does not match our records.
* Your account may not qualify for automatic re-enabling due to rule violations.
Thank you,
{{SITE_NAME}} Staff