diff --git a/classes/autoenable.class.php b/classes/autoenable.class.php
index 94d6945c3..5af9bba90 100644
--- a/classes/autoenable.class.php
+++ b/classes/autoenable.class.php
@@ -2,354 +2,357 @@
class AutoEnable {
- // Constants for database values
- const APPROVED = 1;
- const DENIED = 2;
- const DISCARDED = 3;
+ // 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';
+ // 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. This may be because a request is already pending for your username, or because a recent request was denied.
You are encouraged to discuss this with staff by visiting %s on %s";
+ // The default request rejected message
+ const REJECTED_MESSAGE = "Your request to re-enable your account has been rejected. This may be because a request is already pending for your username, or because a recent request was denied.
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. If you do not receive an email after 48 hours have passed, please visit us on IRC for assistance.";
+ // 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. 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();
- }
+ /**
+ * 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'");
+ // 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."')
- )
- )");
- }
+ 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'];
+ $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']);
+ 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()."')");
+ 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");
- }
+ // 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;
- }
+ 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);
- }
+ /*
+ * 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;
+ $UserInfo = array();
+ $IDs = (!is_array($IDs)) ? [$IDs] : $IDs;
- if (count($IDs) == 0) {
- error(404);
- }
+ if (count($IDs) == 0) {
+ error(404);
+ }
- foreach ($IDs as $ID) {
- if (!is_number($ID)) {
- 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);
+ 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');
- }
+ 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);
+ $TPL->set('SITE_NAME', SITE_NAME);
- foreach ($Results as $Result) {
- list($Email, $ID, $UserID) = $Result;
- $UserInfo[] = array($ID, $UserID);
+ 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);
- }
+ 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';
+ // 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);
- }
- }
+ 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();
+ // 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);
- }
+ 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));
- }
+ // 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;
+ /**
+ * Unresolve a discarded request
+ *
+ * @param int $ID The request ID
+ */
+ public static function unresolve_request($ID) {
+ $ID = (int) $ID;
- if (empty($ID)) {
- error(404);
- }
+ if (empty($ID)) {
+ error(404);
+ }
- G::$DB->query("
- SELECT UserID
- FROM users_enable_requests
- WHERE Outcome = '" . self::DISCARDED . "'
- AND ID = '$ID'");
+ 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();
- }
+ 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();
+ 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);
- }
+ 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 = "---";
- }
+ /**
+ * 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;
- }
+ 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'");
+ /**
+ * 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.";
- }
+ 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', can_leech = '1' WHERE ID = '$UserID'");
+ G::$DB->query("UPDATE users_info SET BanReason = '0' WHERE UserID = '$UserID'");
+ G::$DB->query("SELECT torrent_pass FROM users_main WHERE ID='{$UserID}'");
+ list($TorrentPass) = G::$DB->next_record();
+ Tracker::update_tracker('add_user', array('id' => $UserID, 'passkey' => $TorrentPass));
+ $Err = "Your account has been enabled. You may now log in.";
+ }
+ } else {
+ $Err = "Invalid token.";
+ }
- return $Err;
- }
+ 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();
+ /**
+ * 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($Username)) {
+ $Where[] = "um1.Username = '$Username'";
+ }
- if (!empty($IP)) {
- $Where[] = "uer.IP = '$IP'";
- }
+ 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($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($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($HandledUsername)) {
+ $Where[] = "um2.Username = '$HandledUsername'";
+ }
- if (!empty($OutcomeSearch)) {
- $Where[] = "uer.Outcome = '$OutcomeSearch'";
- }
+ 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)";
- }
+ 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;
- }
+ return $Where;
+ }
}
diff --git a/classes/script_start.php b/classes/script_start.php
index 6e6576faf..187e3be09 100644
--- a/classes/script_start.php
+++ b/classes/script_start.php
@@ -337,11 +337,11 @@ function logout() {
*/
function logout_all_sessions() {
$UserID = G::$LoggedUser['ID'];
-
+
G::$DB->query("
DELETE FROM users_sessions
WHERE UserID = '$UserID'");
-
+
G::$Cache->delete_value('users_sessions_' . $UserID);
logout();
}
@@ -358,8 +358,8 @@ function enforce_login() {
* Make sure $_GET['auth'] is the same as the user's authorization key
* Should be used for any user action that relies solely on GET.
*
- * @param Are we using ajax?
- * @return authorisation status. Prints an error message to LAB_CHAN on IRC on failure.
+ * @param bool Are we using ajax?
+ * @return bool authorisation status. Prints an error message to LAB_CHAN on IRC on failure.
*/
function authorize($Ajax = false) {
if (empty($_REQUEST['auth']) || $_REQUEST['auth'] != G::$LoggedUser['AuthKey']) {
diff --git a/classes/users.class.php b/classes/users.class.php
index c8e477d5b..d8d37d645 100644
--- a/classes/users.class.php
+++ b/classes/users.class.php
@@ -164,6 +164,7 @@ class Users {
m.IP,
m.CustomPermissions,
m.can_leech AS CanLeech,
+ m.IRCKey,
i.AuthKey,
i.RatioWatchEnds,
i.RatioWatchDownload,
@@ -178,6 +179,7 @@ class Users {
i.DisablePM,
i.DisableRequests,
i.DisableForums,
+ i.DisableIRC,
i.DisableTagging," . "
i.SiteOptions,
i.DownloadAlt,
@@ -243,10 +245,10 @@ class Users {
unset($HeavyInfo['CustomForums']['']);
}
- $HeavyInfo['SiteOptions'] = unserialize($HeavyInfo['SiteOptions']);
- if (!empty($HeavyInfo['SiteOptions'])) {
- $HeavyInfo = array_merge($HeavyInfo, $HeavyInfo['SiteOptions']);
- }
+ $HeavyInfo['SiteOptions'] = !empty($HeavyInfo['SiteOptions']) ? unserialize($HeavyInfo['SiteOptions']) : array();
+ $HeavyInfo['SiteOptions'] = array_merge(static::default_site_options(), $HeavyInfo['SiteOptions']);
+ $HeavyInfo = array_merge($HeavyInfo, $HeavyInfo['SiteOptions']);
+
unset($HeavyInfo['SiteOptions']);
G::$DB->set_query_id($QueryID);
@@ -256,6 +258,16 @@ class Users {
return $HeavyInfo;
}
+ /**
+ * Default settings to use for SiteOptions
+ * @return array
+ */
+ public static function default_site_options() {
+ return array(
+ 'HttpsTracker' => true
+ );
+ }
+
/**
* Updates the site options in the database
*
@@ -279,7 +291,8 @@ class Users {
FROM users_info
WHERE UserID = $UserID");
list($SiteOptions) = G::$DB->next_record(MYSQLI_NUM, false);
- $SiteOptions = unserialize($SiteOptions);
+ $SiteOptions = !empty($SiteOptions) ? unserialize($SiteOptions) : array();
+ $SiteOptions = array_merge(static::default_site_options(), $SiteOptions);
// Get HeavyInfo
$HeavyInfo = Users::user_heavy_info($UserID);
diff --git a/classes/util.php b/classes/util.php
index c0ea2f104..d986fef57 100644
--- a/classes/util.php
+++ b/classes/util.php
@@ -197,4 +197,18 @@ function json_print($Status, $Message) {
function site_url($SSL = true) {
return $SSL ? 'https://' . SSL_SITE_URL . '/' : 'http://' . NONSSL_SITE_URL . '/';
}
-?>
+
+/**
+ * The text of the pop-up confirmation when burning an FL token.
+ *
+ * @param integer $seeders - number of seeders for the torrent
+ * @return string Warns if there are no seeders on the torrent
+ */
+function FL_confirmation_msg($seeders) {
+ /* Coder Beware: this text is emitted as part of a Javascript single quoted string.
+ * Any apostrophes should be avoided or escaped appropriately (with \\').
+ */
+ return ($seeders == 0)
+ ? 'Warning! This torrent is not seeded at the moment, are you sure you want to use a Freeleech token here?'
+ : 'Are you sure you want to use a Freeleech token here?';
+}
diff --git a/design/privateheader.php b/design/privateheader.php
index 95473f05b..3d9bfeaa4 100644
--- a/design/privateheader.php
+++ b/design/privateheader.php
@@ -11,6 +11,7 @@ $UseTooltipster = !isset(G::$LoggedUser['Tooltipster']) || G::$LoggedUser['Toolt
+
diff --git a/design/publicheader.php b/design/publicheader.php
index 36a815b71..b8f11cc23 100644
--- a/design/publicheader.php
+++ b/design/publicheader.php
@@ -8,6 +8,7 @@ define('FOOTER_FILE',SERVER_ROOT.'/design/publicfooter.php');
↑_2.3.17.The torrent artist for classical works should use the full composer name. Before uploading, see this wiki for guidelines on uploading and tagging classical music torrents.
↑_2.3.18.Newly re-tagged torrents trumping badly tagged torrents must reflect a substantial improvement over the previous tags. Small changes that include replacing ASCII characters with proper foreign language characters with diacritical marks, fixing slight misspellings, or missing an alternate spelling of an artist (e.g., excluding "The" before a band name) are insufficient grounds for replacing other torrents. Artist names that are misspelled in the tags are grounds for trumping; this includes character accents and characters that mean one letter in one language and a different letter in another language. Improper capitalization in the tags is grounds for trumping; this includes artist tags (or composer tags) that contain names that are all capitalized or track titles that are all capitalized. Tags with multiple entries in the same tag (e.g., track number and track title in the track title tags; or track number, artist, and track title in the artist tags) are subject to trumping. You may trump a release if the tags do not follow the data from a reputable music cataloguing service such as MusicBrainz or Discogs. In the case of a conflict between reputable listings, either tagged version is equally preferred on the site and cannot trump the other. For example, an album is tagged differently in MusicBrainz and in Discogs. Either style of tagging is permitted; neither is "better" than the other. In that case, any newly tagged torrents replacing an already properly tagged torrent, which follows good tagging convention, will result in a dupe. Note: For classical music, please follow these tagging guidelines.
-
↑_2.3.19.Avoid embedding large images in file metadata. The combined size of embedded images and padding may not exceed 512 KiB per file. You may include the artwork separately if it is too big. When removing embedded images, make sure that the padding is removed or reduced to a few kilobytes. Refer to this wiki article for more information.
+
↑_2.3.19.Avoid embedding large images in file metadata. The combined size of embedded images and padding may not exceed 1024 KiB per file. You may include the artwork separately if it is too big. When removing embedded images, make sure that the padding is removed or reduced to a few kilobytes. Refer to this wiki article for more information.
↑_2.3.20.Leading spaces are not allowed in any file or folder names. Leading spaces cause usability and interoperability problems among various operating systems and programs. Torrents with file or folder names that contain leading space characters are trumpable.
@@ -718,7 +719,6 @@ View::show_header('Uploading Rules', 'rules');
- include('jump.php'); ?>
View::show_footer();
diff --git a/sections/tools/development/clear_cache.php b/sections/tools/development/clear_cache.php
index 0a035ce91..1c95a652b 100644
--- a/sections/tools/development/clear_cache.php
+++ b/sections/tools/development/clear_cache.php
@@ -6,6 +6,27 @@ if (!check_perms('users_mod') || !check_perms('admin_clear_cache')) {
View::show_header('Clear a cache key');
//Make sure the form was sent
+if (isset($_GET['cache'])) {
+ if ($_GET['cache'] === 'users') {
+ $DB->query("SELECT count(*) as count FROM users_main");
+ list($Count) = $DB->next_record();
+
+ for ($i = 1; $i <= $Count; $i++) {
+ $Cache->delete_value('users_stats_' . $i);
+ $Cache->delete_value('users_info_' . $i);
+ $Cache->delete_value('users_info_heavy_' . $i);
+ }
+ echo "
{$Count} users' caches cleared!
";
+ }
+ elseif ($_GET['cache'] === 'torrent_groups') {
+ $DB->query("SELECT count(*) as count FROM torrents_group");
+ list($Count) = $DB->next_record();
+ for ($i = 1; $i <= $Count; $i++) {
+ $Cache->delete_value('torrent_group_' . $i);
+ $Cache->delete_value('groups_artists_' . $i);
+ }
+ }
+}
if (!empty($_GET['key'])) {
if ($_GET['submit'] == 'Multi') {
$Keys = array_map('trim', preg_split('/\s+/', $_GET['key']));
@@ -59,23 +80,30 @@ $MultiKeyTooltip = 'Enter cache keys delimited by any amount of whitespace.';
+
+
Clear Common Caches:
+
Users (clears out users_stats_*, users_info_*, and users_info_heavy_*)
+
+
+
Torrent Groups (clears out torrent_group_* and groups_artists_*)
+
if (isset($Keys) && $_GET['type'] == 'view') {
-?>
+ ?>
-
- foreach ($Keys as $Key) {
-?>
-
-
=display_str($Key)?>
-
-
var_dump($Cache->get_value($Key)); ?>
-
-
- } ?>
+
+ foreach ($Keys as $Key) {
+ ?>
+
+
=display_str($Key)?>
+
+
var_dump($Cache->get_value($Key)); ?>
+
+
+ } ?>
-
+
}
-View::show_footer();
+View::show_footer();
\ No newline at end of file
diff --git a/sections/tools/index.php b/sections/tools/index.php
index 74169cbb1..20791e180 100644
--- a/sections/tools/index.php
+++ b/sections/tools/index.php
@@ -461,38 +461,6 @@ switch ($_REQUEST['action']) {
include(SERVER_ROOT.'/sections/tools/development/rerender_gallery.php');
break;
- case 'sandbox1':
- include(SERVER_ROOT.'/sections/tools/sandboxes/sandbox1.php');
- break;
-
- case 'sandbox2':
- include(SERVER_ROOT.'/sections/tools/sandboxes/sandbox2.php');
- break;
-
- case 'sandbox3':
- include(SERVER_ROOT.'/sections/tools/sandboxes/sandbox3.php');
- break;
-
- case 'sandbox4':
- include(SERVER_ROOT.'/sections/tools/sandboxes/sandbox4.php');
- break;
-
- case 'sandbox5':
- include(SERVER_ROOT.'/sections/tools/sandboxes/sandbox5.php');
- break;
-
- case 'sandbox6':
- include(SERVER_ROOT.'/sections/tools/sandboxes/sandbox6.php');
- break;
-
- case 'sandbox7':
- include(SERVER_ROOT.'/sections/tools/sandboxes/sandbox7.php');
- break;
-
- case 'sandbox8':
- include(SERVER_ROOT.'/sections/tools/sandboxes/sandbox8.php');
- break;
-
case 'public_sandbox':
include(SERVER_ROOT.'/sections/tools/sandboxes/public_sandbox.php');
break;
diff --git a/sections/tools/sandboxes/mod_sandbox.php b/sections/tools/sandboxes/mod_sandbox.php
deleted file mode 100644
index e69de29bb..000000000
diff --git a/sections/tools/sandboxes/public_sandbox.php b/sections/tools/sandboxes/public_sandbox.php
deleted file mode 100644
index e69de29bb..000000000
diff --git a/sections/tools/sandboxes/sandbox1.php b/sections/tools/sandboxes/sandbox1.php
deleted file mode 100644
index e69de29bb..000000000
diff --git a/sections/tools/sandboxes/sandbox2.php b/sections/tools/sandboxes/sandbox2.php
deleted file mode 100644
index e69de29bb..000000000
diff --git a/sections/tools/sandboxes/sandbox3.php b/sections/tools/sandboxes/sandbox3.php
deleted file mode 100644
index e69de29bb..000000000
diff --git a/sections/tools/sandboxes/sandbox4.php b/sections/tools/sandboxes/sandbox4.php
deleted file mode 100644
index e69de29bb..000000000
diff --git a/sections/tools/sandboxes/sandbox5.php b/sections/tools/sandboxes/sandbox5.php
deleted file mode 100644
index e69de29bb..000000000
diff --git a/sections/tools/sandboxes/sandbox6.php b/sections/tools/sandboxes/sandbox6.php
deleted file mode 100644
index e69de29bb..000000000
diff --git a/sections/tools/sandboxes/sandbox7.php b/sections/tools/sandboxes/sandbox7.php
deleted file mode 100644
index e69de29bb..000000000
diff --git a/sections/tools/sandboxes/sandbox8.php b/sections/tools/sandboxes/sandbox8.php
deleted file mode 100644
index e69de29bb..000000000
diff --git a/sections/tools/tools.php b/sections/tools/tools.php
index 6eaf6ed02..929717053 100644
--- a/sections/tools/tools.php
+++ b/sections/tools/tools.php
@@ -66,7 +66,7 @@ View::show_header('Staff Tools');
create_row("News post", "tools.php?action=news", check_perms("admin_manage_news"));
create_row("Vanity House additions", "tools.php?action=recommend", check_perms("site_recommend_own") || check_perms("site_manage_recommendations"));
create_row("Album of the Week", "tools.php?action=weekalbum", check_perms("users_mod"));
-
+
if ($ToolsHTML) {
?>