From 6cb31f6e792c4bcbaf64fd3ca91851aef8e0c78d Mon Sep 17 00:00:00 2001 From: itismadness Date: Thu, 28 Sep 2017 23:10:59 -0400 Subject: [PATCH 01/17] update rule 2.3.19 and move rules section boxes to the top --- sections/rules/chat.php | 11 +++++------ sections/rules/clients.php | 4 ++-- sections/rules/collages.php | 2 +- sections/rules/jump.php | 2 +- sections/rules/ratio.php | 2 +- sections/rules/requests.php | 3 ++- sections/rules/rules.php | 5 +++-- sections/rules/tag.php | 4 ++-- sections/rules/upload.php | 4 ++-- 9 files changed, 19 insertions(+), 18 deletions(-) diff --git a/sections/rules/chat.php b/sections/rules/chat.php index fe37a6175..37b18fa88 100644 --- a/sections/rules/chat.php +++ b/sections/rules/chat.php @@ -2,26 +2,25 @@ //Include the header View::show_header('Chat Rules'); ?> - +
+

Anything not allowed on the forums is also not allowed on IRC and vice versa. They are separated for convenience only.


-

Forum Rules

+ +

Forum Rules

-
-
-

IRC Rules

+

IRC Rules

-
get_value('whitelisted_clients')) { $Cache->cache_value('whitelisted_clients', $WhitelistedClients, 604800); } ?> -
+
+

Client Whitelist

@@ -35,6 +36,5 @@ if (!$WhitelistedClients = $Cache->get_value('whitelisted_clients')) {
-
diff --git a/sections/rules/collages.php b/sections/rules/collages.php index 624b9c738..8e50ea68b 100644 --- a/sections/rules/collages.php +++ b/sections/rules/collages.php @@ -3,6 +3,7 @@ View::show_header('Collages Rules'); ?>
+

Collages

@@ -52,7 +53,6 @@ View::show_header('Collages Rules');
- -

Other Sections

+

Rule Sections

diff --git a/sections/rules/ratio.php b/sections/rules/ratio.php index 45a4829b3..fd54ba075 100644 --- a/sections/rules/ratio.php +++ b/sections/rules/ratio.php @@ -3,6 +3,7 @@ View::show_header('Ratio Requirements'); ?>
+

Ratio Rules

@@ -197,7 +198,6 @@ View::show_header('Ratio Requirements');

-
+

Requests

@@ -25,7 +26,7 @@ View::show_header('Request Rules');
- +
+
-

Golden Rules

+

Golden Rules

The Golden Rules encompass all of and our IRC Network. These rules are paramount; non-compliance will jeopardize your account.

- +
+
-

Tagging rules

+

Tagging rules

-
+

Uploading Rules

@@ -375,7 +376,7 @@ View::show_header('Uploading Rules', 'rules');
  • ↑_ 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'); - Date: Sun, 1 Oct 2017 10:06:27 -0400 Subject: [PATCH 02/17] fix bug with unserializing empty array --- classes/users.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/classes/users.class.php b/classes/users.class.php index 0cb02dec0..07a81a1f1 100644 --- a/classes/users.class.php +++ b/classes/users.class.php @@ -227,7 +227,8 @@ class Users { unset($HeavyInfo['CustomForums']['']); } - $HeavyInfo['SiteOptions'] = array_merge(static::default_site_options(), unserialize($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']); From 700d174b31d00c3b68460d585de18aa3863b59a2 Mon Sep 17 00:00:00 2001 From: itismadness Date: Sun, 1 Oct 2017 10:09:43 -0400 Subject: [PATCH 03/17] add another check' --- classes/users.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/classes/users.class.php b/classes/users.class.php index 07a81a1f1..65955c4f0 100644 --- a/classes/users.class.php +++ b/classes/users.class.php @@ -268,7 +268,8 @@ class Users { FROM users_info WHERE UserID = $UserID"); list($SiteOptions) = G::$DB->next_record(MYSQLI_NUM, false); - $SiteOptions = array_merge(static::default_site_options(), unserialize($SiteOptions)); + $SiteOptions = !empty($SiteOptions) ? unserialize($SiteOptions) : array(); + $SiteOptions = array_merge(static::default_site_options(), $SiteOptions); // Get HeavyInfo $HeavyInfo = Users::user_heavy_info($UserID); From 6fbddd62ce074341ac348f6ffe84638af7295809 Mon Sep 17 00:00:00 2001 From: itismadness Date: Sun, 1 Oct 2017 10:18:13 -0400 Subject: [PATCH 04/17] fix branch --- classes/autoenable.class.php | 608 +++++++++++++++++------------------ classes/script_start.php | 8 +- 2 files changed, 308 insertions(+), 308 deletions(-) diff --git a/classes/autoenable.class.php b/classes/autoenable.class.php index 94d6945c3..0f12891cb 100644 --- a/classes/autoenable.class.php +++ b/classes/autoenable.class.php @@ -2,354 +2,354 @@ 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'"); + 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'"); - $Err = "Your account has been enabled. You may now log in."; - } - } else { - $Err = "Invalid token."; - } + $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 5d8b6bc3c..99d5b46e4 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']) { From 0f0d774db764db61aeb27e2368296a36f96a0cfc Mon Sep 17 00:00:00 2001 From: itismadness Date: Sun, 1 Oct 2017 10:21:44 -0400 Subject: [PATCH 05/17] add back in referrer policy --- design/privateheader.php | 1 + design/publicheader.php | 1 + 2 files changed, 2 insertions(+) diff --git a/design/privateheader.php b/design/privateheader.php index 5eee830f9..e7e89ee7f 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..82d2725db 100644 --- a/design/publicheader.php +++ b/design/publicheader.php @@ -8,6 +8,7 @@ define('FOOTER_FILE',SERVER_ROOT.'/design/publicfooter.php'); <?=display_str($PageTitle)?> + From ef703dc6339c65941ad53802c046a87cf58758cc Mon Sep 17 00:00:00 2001 From: itismadness Date: Wed, 4 Oct 2017 09:47:33 -0400 Subject: [PATCH 06/17] add reenabled user back to the tracker --- classes/autoenable.class.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/classes/autoenable.class.php b/classes/autoenable.class.php index 0f12891cb..5af9bba90 100644 --- a/classes/autoenable.class.php +++ b/classes/autoenable.class.php @@ -262,7 +262,10 @@ class AutoEnable { // 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("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 { From 62075b7befa55e46d4f9efd19fe552654b5deef0 Mon Sep 17 00:00:00 2001 From: itismadness Date: Thu, 5 Oct 2017 18:38:58 -0400 Subject: [PATCH 07/17] update referrer policy to be a bit better --- design/privateheader.php | 2 +- design/publicheader.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/design/privateheader.php b/design/privateheader.php index e7e89ee7f..2de9c986c 100644 --- a/design/privateheader.php +++ b/design/privateheader.php @@ -11,7 +11,7 @@ $UseTooltipster = !isset(G::$LoggedUser['Tooltipster']) || G::$LoggedUser['Toolt - + diff --git a/design/publicheader.php b/design/publicheader.php index 82d2725db..6a8b5dd9d 100644 --- a/design/publicheader.php +++ b/design/publicheader.php @@ -8,7 +8,7 @@ define('FOOTER_FILE',SERVER_ROOT.'/design/publicfooter.php'); <?=display_str($PageTitle)?> - + From 92f233ca350aeb2bd010bdd00756aa5a29a6d20f Mon Sep 17 00:00:00 2001 From: itismadness Date: Thu, 5 Oct 2017 18:56:24 -0400 Subject: [PATCH 08/17] re-add stuff for this MR --- classes/users.class.php | 10 ++++ sections/tools/development/clear_cache.php | 54 ++++++++++++++++----- sections/tools/index.php | 32 ------------ sections/tools/sandboxes/mod_sandbox.php | 0 sections/tools/sandboxes/public_sandbox.php | 0 sections/tools/sandboxes/sandbox1.php | 0 sections/tools/sandboxes/sandbox2.php | 0 sections/tools/sandboxes/sandbox3.php | 0 sections/tools/sandboxes/sandbox4.php | 0 sections/tools/sandboxes/sandbox5.php | 0 sections/tools/sandboxes/sandbox6.php | 0 sections/tools/sandboxes/sandbox7.php | 0 sections/tools/sandboxes/sandbox8.php | 0 sections/tools/tools.php | 12 +---- sections/torrents/browse.php | 8 ++- sections/user/edit.php | 7 +-- 16 files changed, 57 insertions(+), 66 deletions(-) delete mode 100644 sections/tools/sandboxes/mod_sandbox.php delete mode 100644 sections/tools/sandboxes/public_sandbox.php delete mode 100644 sections/tools/sandboxes/sandbox1.php delete mode 100644 sections/tools/sandboxes/sandbox2.php delete mode 100644 sections/tools/sandboxes/sandbox3.php delete mode 100644 sections/tools/sandboxes/sandbox4.php delete mode 100644 sections/tools/sandboxes/sandbox5.php delete mode 100644 sections/tools/sandboxes/sandbox6.php delete mode 100644 sections/tools/sandboxes/sandbox7.php delete mode 100644 sections/tools/sandboxes/sandbox8.php diff --git a/classes/users.class.php b/classes/users.class.php index 7703c3f0c..58c9fe7e1 100644 --- a/classes/users.class.php +++ b/classes/users.class.php @@ -241,6 +241,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 * 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_*)
    + ?> - - - - - - + + + + + +
    -
    get_value($Key)); ?>
    -
    +
    get_value($Key)); ?>
    +
    -
    @@ -150,17 +150,7 @@ View::show_header('Staff Tools'); // begin Developer Sandboxes category $ToolsHTML = ""; - create_row("Sandbox (1)", "tools.php?action=sandbox1", check_perms("site_debug")); - create_row("Sandbox (2)", "tools.php?action=sandbox2", check_perms("site_debug")); - create_row("Sandbox (3)", "tools.php?action=sandbox3", check_perms("site_debug")); - create_row("Sandbox (4)", "tools.php?action=sandbox4", check_perms("site_debug")); - create_row("Sandbox (5)", "tools.php?action=sandbox5", check_perms("site_debug")); - create_row("Sandbox (6)", "tools.php?action=sandbox6", check_perms("site_debug")); - create_row("Sandbox (7)", "tools.php?action=sandbox7", check_perms("site_debug")); - create_row("Sandbox (8)", "tools.php?action=sandbox8", check_perms("site_debug")); create_row("BBCode sandbox", "tools.php?action=bbcode_sandbox", check_perms("users_mod")); - create_row("Public sandbox", "tools.php?action=public_sandbox", check_perms("users_mod"), "Do not click this!"); - create_row("Mod-level sandbox", "tools.php?action=mod_sandbox", check_perms("users_mod"), "Do not click this!"); create_row("Testing", "testing.php", check_perms("users_mod")); if ($ToolsHTML) { diff --git a/sections/torrents/browse.php b/sections/torrents/browse.php index 62ac6de93..cce0359cc 100644 --- a/sections/torrents/browse.php +++ b/sections/torrents/browse.php @@ -49,11 +49,9 @@ if (!empty($_GET['setdefault'])) { FROM users_info WHERE UserID = '".db_string($LoggedUser['ID'])."'"); list($SiteOptions) = $DB->next_record(MYSQLI_NUM, false); - if (!empty($SiteOptions)) { - $SiteOptions = unserialize($SiteOptions); - } else { - $SiteOptions = array(); - } + $SiteOptions = (!empty($SiteOptions)) ? unserialize($SiteOptions) : array(); + $SiteOptions = array_merge(Users::default_site_options(), $SiteOptions); + $SiteOptions['DefaultSearch'] = preg_replace($UnsetRegexp, '', $_SERVER['QUERY_STRING']); $DB->query(" UPDATE users_info diff --git a/sections/user/edit.php b/sections/user/edit.php index 4ea477bd7..ec481eeb8 100644 --- a/sections/user/edit.php +++ b/sections/user/edit.php @@ -51,11 +51,8 @@ function checked($Checked) { return ($Checked ? ' checked="checked"' : ''); } -if ($SiteOptions) { - $SiteOptions = unserialize($SiteOptions); -} else { - $SiteOptions = array(); -} +$SiteOptions = (!empty($SiteOptions)) ? unserialize($SiteOptions) : array(); +$SiteOptions = array_merge(Users::default_site_options(), $SiteOptions); View::show_header("$Username > Settings", 'user,jquery-ui,release_sort,password_validate,validate,cssgallery,preview_paranoia,bbcode,user_settings,donor_titles'); From 306e6015c159e8c974a990f338ddc6d45e66aae7 Mon Sep 17 00:00:00 2001 From: itismadness Date: Fri, 6 Oct 2017 10:48:44 -0400 Subject: [PATCH 09/17] update API --- classes/users.class.php | 4 +- sections/api/User.php | 157 ++++++++++++++++++++++------------------ 2 files changed, 88 insertions(+), 73 deletions(-) diff --git a/classes/users.class.php b/classes/users.class.php index e99c182b1..58ff18808 100644 --- a/classes/users.class.php +++ b/classes/users.class.php @@ -150,6 +150,7 @@ class Users { m.IP, m.CustomPermissions, m.can_leech AS CanLeech, + m.IRCKey, i.AuthKey, i.RatioWatchEnds, i.RatioWatchDownload, @@ -163,6 +164,7 @@ class Users { i.DisablePM, i.DisableRequests, i.DisableForums, + i.DisableIRC, i.DisableTagging," . " i.SiteOptions, i.DownloadAlt, @@ -551,7 +553,7 @@ class Users { . (G::$LoggedUser['ID'] === $UserID ? ' - Expires ' . date('Y-m-d H:i', strtotime($UserInfo['Warned'])) : '') . '" class="tooltip" />' : ''; $Str .= ($IsEnabled && $UserInfo['Enabled'] == 2) ? 'Banned' : ''; - + if ($Badges) { $ClassesDisplay = array(); foreach (array_intersect_key($SecondaryClasses, $UserInfo['ExtraClasses']) as $PermID => $PermShort) { diff --git a/sections/api/User.php b/sections/api/User.php index 81861d187..6a0eaf435 100644 --- a/sections/api/User.php +++ b/sections/api/User.php @@ -1,76 +1,89 @@ db->query(" -SELECT - um.ID, um.Username, um.Email, um.IRCKey, um.Uploaded, um.Downloaded, um.Paranoia, um.Enabled, - um.Invites, um.PermissionID, um.LastAccess, p.Level as PermissionLevel, p.Name as PermissionName, ui.* -FROM users_main as um -LEFT JOIN ( - SELECT UserID, AdminComment, Donor, JoinDate, Inviter, DisableIRC, BanDate, BanReason - FROM users_info -) AS ui ON ui.UserID = um.ID -LEFT JOIN (SELECT ID, Level, Name FROM permissions) AS p ON p.ID = um.PermissionID -WHERE {$where}"); - if ($this->db->record_count() === 0) { - error('No user found'); - } - $this->user = $this->db->next_record(MYSQLI_ASSOC, false); - $this->user['Paranoia'] = unserialize($this->user['Paranoia']); - - $this->user['Ratio'] = Format::get_ratio($this->user['Uploaded'], $this->user['Downloaded']); - $this->user['DisplayStats'] = array('Downloaded' => Format::get_size($this->user['Downloaded']), - 'Uploaded' => Format::get_size($this->user['Uploaded']), - 'Ratio' => $this->user['Ratio']); - foreach (array('Downloaded', 'Uploaded', 'Ratio') as $key) { - if (in_array(strtolower($key), $this->user['Paranoia'])) { - $this->user['DisplayStats'][$key] = "Hidden"; - } - } - $this->user['UserPage'] = "http"; - if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != "") { - $this->user['UserPage'] .= "s"; - } - $this->user['UserPage'] .= "://" . SITE_URL . "/user.php?id={$this->user['ID']}"; - - switch($_GET['req']) { - case 'enable': - return $this->disableUser(); - break; - case 'disable': - return $this->enableUser(); - break; - default: - case 'stats': - return $this->getStats(); - break; - } - } - - private function getStats() { - return $this->user; - } - - private function disableUser() { - $this->db->query("UPDATE users_main SET Enabled='2' WHERE ID='{$this->user['ID']}'"); - return array('disabled' => true, 'user_id' => $this->user['ID'], 'username' => $this->user['Username']); - } - - private function enableUser() { - $this->db->query("UPDATE users_main SET Enabled='1' WHERE ID='{$this->user['ID']}'"); - return array('enabled' => true, 'user_id' => $this->user['ID'], 'username' => $this->user['Username']); - } + private $id = null; + private $username = null; + + public function run() { + if (isset($_GET['user_id'])) { + $this->id = intval($_GET['user_id']); + } + else if (isset($_GET['username'])) { + $this->username = $_GET['username']; + } + else { + json_error("Need to supply either user_id or username"); + } + + switch($_GET['req']) { + case 'enable': + return $this->disableUser(); + break; + case 'disable': + return $this->enableUser(); + break; + default: + case 'stats': + return $this->getUser(); + break; + } + } + + private function getUser() { + $where = ($this->id !== null) ? "um.ID = '{$this->id}'" : "um.Username = '".db_strign($this->username)."'"; + $this->db->query(" + SELECT + um.ID, + um.Username, + um.IRCKey, + um.Uploaded, + um.Downloaded, + um.BonusPoints, + um.PermissionID AS Class, + um.Paranoia, + ui.DisableIRC, + p.Name as ClassName + p.Level, + GROUP_CONCAT(ul.PermissionID SEPARATOR ',') AS SecondaryClasses + FROM + users_main AS um + INNER JOIN users_info AS ui ON ui.UserID = um.ID + INNER JOIN permissions AS p ON p.ID = um.PermissionID + LEFT JOIN users_levels AS ul ON ul.UserID = um.ID + WHERE + {$where}"); + + $user = $this->db->next_record(); + if (!empty($user['Username'])) { + $user['Paranoia'] = !empty($user['Paranoia']) ? unserialize($user['Paranoia']) : array(); + + $user['Ratio'] = Format::get_ratio($user['Uploaded'], $user['Downloaded']); + $user['DisplayStats'] = array( + 'Downloaded' => Format::get_size($user['Downloaded']), + 'Uploaded' => Format::get_size($user['Uploaded']), + 'Ratio' => $user['Ratio'] + ); + foreach (array('Downloaded', 'Uploaded', 'Ratio') as $key) { + if (in_array(strtolower($key), $user['Paranoia'])) { + $user['DisplayStats'][$key] = "Hidden"; + } + } + $user['UserPage'] = "http"; + if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != "") { + $user['UserPage'] .= "s"; + } + $user['UserPage'] .= "://" . SITE_URL . "/user.php?id={$user['ID']}"; + } + return $user; + } + + private function disableUser() { + $this->db->query("UPDATE users_main SET Enabled='2' WHERE ID='{$this->id}'"); + return array('disabled' => true, 'user_id' => $user['ID'], 'username' => $user['Username']); + } + + private function enableUser() { + $this->db->query("UPDATE users_main SET Enabled='1' WHERE ID='{$this->id}'"); + return array('enabled' => true, 'user_id' => $user['ID'], 'username' => $user['Username']); + } } \ No newline at end of file From 0a2affc255b2275b10c9f66b41b662c04d2f04d7 Mon Sep 17 00:00:00 2001 From: itismadness Date: Fri, 6 Oct 2017 13:40:09 -0400 Subject: [PATCH 10/17] fix up api stuff --- sections/api/User.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/sections/api/User.php b/sections/api/User.php index 6a0eaf435..46d1211d6 100644 --- a/sections/api/User.php +++ b/sections/api/User.php @@ -30,7 +30,7 @@ class User extends AbstractAPI { } private function getUser() { - $where = ($this->id !== null) ? "um.ID = '{$this->id}'" : "um.Username = '".db_strign($this->username)."'"; + $where = ($this->id !== null) ? "um.ID = '{$this->id}'" : "um.Username = '".db_string($this->username)."'"; $this->db->query(" SELECT um.ID, @@ -42,7 +42,7 @@ class User extends AbstractAPI { um.PermissionID AS Class, um.Paranoia, ui.DisableIRC, - p.Name as ClassName + p.Name as ClassName, p.Level, GROUP_CONCAT(ul.PermissionID SEPARATOR ',') AS SecondaryClasses FROM @@ -53,8 +53,12 @@ class User extends AbstractAPI { WHERE {$where}"); - $user = $this->db->next_record(); + $user = $this->db->next_record(MYSQLI_ASSOC, array('Paranoia')); if (!empty($user['Username'])) { + $user['SecondaryClasses'] = array_map("intval", explode(",", $user['SecondaryClasses'])); + foreach (array('ID', 'Uploaded', 'Downloaded', 'BonusPoints', 'Class', 'Level') as $key) { + $user[$key] = intval($user[$key]); + } $user['Paranoia'] = !empty($user['Paranoia']) ? unserialize($user['Paranoia']) : array(); $user['Ratio'] = Format::get_ratio($user['Uploaded'], $user['Downloaded']); From 9f49d96499580464f4388599516338be0fe4c411 Mon Sep 17 00:00:00 2001 From: itismadness Date: Sat, 7 Oct 2017 11:20:50 -0400 Subject: [PATCH 11/17] remove bonus points for now --- sections/api/User.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sections/api/User.php b/sections/api/User.php index 46d1211d6..753b42620 100644 --- a/sections/api/User.php +++ b/sections/api/User.php @@ -31,6 +31,7 @@ class User extends AbstractAPI { private function getUser() { $where = ($this->id !== null) ? "um.ID = '{$this->id}'" : "um.Username = '".db_string($this->username)."'"; + // TODO: add um.BonusPoints, $this->db->query(" SELECT um.ID, @@ -38,7 +39,6 @@ class User extends AbstractAPI { um.IRCKey, um.Uploaded, um.Downloaded, - um.BonusPoints, um.PermissionID AS Class, um.Paranoia, ui.DisableIRC, @@ -56,7 +56,7 @@ class User extends AbstractAPI { $user = $this->db->next_record(MYSQLI_ASSOC, array('Paranoia')); if (!empty($user['Username'])) { $user['SecondaryClasses'] = array_map("intval", explode(",", $user['SecondaryClasses'])); - foreach (array('ID', 'Uploaded', 'Downloaded', 'BonusPoints', 'Class', 'Level') as $key) { + foreach (array('ID', 'Uploaded', 'Downloaded', 'Class', 'Level') as $key) { $user[$key] = intval($user[$key]); } $user['Paranoia'] = !empty($user['Paranoia']) ? unserialize($user['Paranoia']) : array(); From 981807f12a38d52bc2281b6a3ebef339b016b889 Mon Sep 17 00:00:00 2001 From: Spine Date: Sat, 7 Oct 2017 22:41:12 +0200 Subject: [PATCH 12/17] bugfix: restore broken multi-torrent upload sections/upload/insert_extra_torrents.php was nuked in 1d61bb10b1c9f1a2bc2927d65fefbff8f1872322. Its contents were restored and then merged into upload_handle.php. Also fold in the other two *_extra_torrents.php files. --- sections/upload/generate_extra_torrents.php | 67 -------- sections/upload/get_extra_torrents.php | 43 ----- sections/upload/upload_handle.php | 171 +++++++++++++++++++- 3 files changed, 168 insertions(+), 113 deletions(-) delete mode 100644 sections/upload/generate_extra_torrents.php delete mode 100644 sections/upload/get_extra_torrents.php diff --git a/sections/upload/generate_extra_torrents.php b/sections/upload/generate_extra_torrents.php deleted file mode 100644 index d54297c8f..000000000 --- a/sections/upload/generate_extra_torrents.php +++ /dev/null @@ -1,67 +0,0 @@ -Dec['encrypted_files'])) { - $Err = 'At least one of the torrents contain an encrypted file list which is not supported here'; - break; - } - if (!$ExtraTor->is_private()) { - $ExtraTor->make_private(); // The torrent is now private. - $PublicTorrent = true; - } - - // File list and size - list($ExtraTotalSize, $ExtraFileList) = $ExtraTor->file_list(); - $ExtraDirName = isset($ExtraTor->Dec['info']['files']) ? Format::make_utf8($ExtraTor->get_name()) : ''; - - $ExtraTmpFileList = array(); - foreach ($ExtraFileList as $ExtraFile) { - list($ExtraSize, $ExtraName) = $ExtraFile; - - check_file($Type, $ExtraName); - - // Make sure the file name is not too long - if (mb_strlen($ExtraName, 'UTF-8') + mb_strlen($ExtraDirName, 'UTF-8') + 1 > MAX_FILENAME_LENGTH) { - $Err = "The torrent contained one or more files with too long of a name:
    $ExtraDirName/$ExtraName"; - break; - } - // Add file and size to array - $ExtraTmpFileList[] = Torrents::filelist_format_file($ExtraFile); - } - - // To be stored in the database - $ThisInsert['FilePath'] = db_string($ExtraDirName); - $ThisInsert['FileString'] = db_string(implode("\n", $ExtraTmpFileList)); - $ThisInsert['InfoHash'] = pack('H*', $ExtraTor->info_hash()); - $ThisInsert['NumFiles'] = count($ExtraFileList); - $ThisInsert['TorEnc'] = db_string($ExtraTor->encode()); - $ThisInsert['TotalSize'] = $ExtraTotalSize; - - $Debug->set_flag('upload: torrent decoded'); - $DB->query(" - SELECT ID - FROM torrents - WHERE info_hash = '" . db_string($ThisInsert['InfoHash']) . "'"); - if ($DB->has_results()) { - list($ExtraID) = $DB->next_record(); - $DB->query(" - SELECT TorrentID - FROM torrents_files - WHERE TorrentID = $ExtraID"); - if ($DB->has_results()) { - $Err = "The exact same torrent file already exists on the site!"; - } else { - //One of the lost torrents. - $DB->query(" - INSERT INTO torrents_files (TorrentID, File) - VALUES ($ExtraID, '$ThisInsert[TorEnc]')"); - $Err = "Thank you for fixing this torrent."; - } - } -} -unset($ThisInsert); -?> diff --git a/sections/upload/get_extra_torrents.php b/sections/upload/get_extra_torrents.php deleted file mode 100644 index d71b27dab..000000000 --- a/sections/upload/get_extra_torrents.php +++ /dev/null @@ -1,43 +0,0 @@ - diff --git a/sections/upload/upload_handle.php b/sections/upload/upload_handle.php index 80d7c840b..f48a4c8aa 100644 --- a/sections/upload/upload_handle.php +++ b/sections/upload/upload_handle.php @@ -254,7 +254,46 @@ if (!is_uploaded_file($TorrentName) || !filesize($TorrentName)) { } if ($Type == 'Music') { - include(SERVER_ROOT.'/sections/upload/get_extra_torrents.php'); + //extra torrent files + $ExtraTorrents = array(); + $DupeNames = array(); + $DupeNames[] = $_FILES['file_input']['name']; + + if (isset($_POST['extra_format']) && isset($_POST['extra_bitrate'])) { + for ($i = 1; $i <= 5; $i++) { + if (isset($_FILES["extra_file_$i"])) { + $ExtraFile = $_FILES["extra_file_$i"]; + $ExtraTorrentName = $ExtraFile['tmp_name']; + if (!is_uploaded_file($ExtraTorrentName) || !filesize($ExtraTorrentName)) { + $Err = 'No extra torrent file uploaded, or file is empty.'; + } elseif (substr(strtolower($ExtraFile['name']), strlen($ExtraFile['name']) - strlen('.torrent')) !== '.torrent') { + $Err = 'You seem to have put something other than an extra torrent file into the upload field. (' . $ExtraFile['name'] . ').'; + } elseif (in_array($ExtraFile['name'], $DupeNames)) { + $Err = 'One or more torrents has been entered into the form twice.'; + } else { + $j = $i - 1; + $ExtraTorrents[$ExtraTorrentName]['Name'] = $ExtraTorrentName; + $ExtraFormat = $_POST['extra_format'][$j]; + if (empty($ExtraFormat)) { + $Err = 'Missing format for extra torrent.'; + break; + } else { + $ExtraTorrents[$ExtraTorrentName]['Format'] = db_string(trim($ExtraFormat)); + } + $ExtraBitrate = $_POST['extra_bitrate'][$j]; + if (empty($ExtraBitrate)) { + $Err = 'Missing bitrate for extra torrent.'; + break; + } else { + $ExtraTorrents[$ExtraTorrentName]['Encoding'] = db_string(trim($ExtraBitrate)); + } + $ExtraReleaseDescription = $_POST['extra_release_desc'][$j]; + $ExtraTorrents[$ExtraTorrentName]['TorrentDescription'] = db_string(trim($ExtraReleaseDescription)); + $DupeNames[] = $ExtraFile['name']; + } + } + } + } } @@ -400,7 +439,71 @@ $FileString = db_string(implode("\n", $TmpFileList)); $Debug->set_flag('upload: torrent decoded'); if ($Type == 'Music') { - include(SERVER_ROOT.'/sections/upload/generate_extra_torrents.php'); + $ExtraTorrentsInsert = array(); + foreach ($ExtraTorrents as $ExtraTorrent) { + $Name = $ExtraTorrent['Name']; + $ExtraTorrentsInsert[$Name] = $ExtraTorrent; + $ThisInsert =& $ExtraTorrentsInsert[$Name]; + $ExtraTor = new BencodeTorrent($Name, true); + if (isset($ExtraTor->Dec['encrypted_files'])) { + $Err = 'At least one of the torrents contain an encrypted file list which is not supported here'; + break; + } + if (!$ExtraTor->is_private()) { + $ExtraTor->make_private(); // The torrent is now private. + $PublicTorrent = true; + } + + // File list and size + list($ExtraTotalSize, $ExtraFileList) = $ExtraTor->file_list(); + $ExtraDirName = isset($ExtraTor->Dec['info']['files']) ? Format::make_utf8($ExtraTor->get_name()) : ''; + + $ExtraTmpFileList = array(); + foreach ($ExtraFileList as $ExtraFile) { + list($ExtraSize, $ExtraName) = $ExtraFile; + + check_file($Type, $ExtraName); + + // Make sure the file name is not too long + if (mb_strlen($ExtraName, 'UTF-8') + mb_strlen($ExtraDirName, 'UTF-8') + 1 > MAX_FILENAME_LENGTH) { + $Err = "The torrent contained one or more files with too long of a name:
    $ExtraDirName/$ExtraName"; + break; + } + // Add file and size to array + $ExtraTmpFileList[] = Torrents::filelist_format_file($ExtraFile); + } + + // To be stored in the database + $ThisInsert['FilePath'] = db_string($ExtraDirName); + $ThisInsert['FileString'] = db_string(implode("\n", $ExtraTmpFileList)); + $ThisInsert['InfoHash'] = pack('H*', $ExtraTor->info_hash()); + $ThisInsert['NumFiles'] = count($ExtraFileList); + $ThisInsert['TorEnc'] = db_string($ExtraTor->encode()); + $ThisInsert['TotalSize'] = $ExtraTotalSize; + + $Debug->set_flag('upload: torrent decoded'); + $DB->query(" + SELECT ID + FROM torrents + WHERE info_hash = '" . db_string($ThisInsert['InfoHash']) . "'"); + if ($DB->has_results()) { + list($ExtraID) = $DB->next_record(); + $DB->query(" + SELECT TorrentID + FROM torrents_files + WHERE TorrentID = $ExtraID"); + if ($DB->has_results()) { + $Err = "The exact same torrent file already exists on the site!"; + } else { + //One of the lost torrents. + $DB->query(" + INSERT INTO torrents_files (TorrentID, File) + VALUES ($ExtraID, '$ThisInsert[TorEnc]')"); + $Err = "Thank you for fixing this torrent."; + } + } + } + unset($ThisInsert); } if (!empty($Err)) { // Show the upload form, with the data the user entered @@ -715,6 +818,69 @@ Torrents::write_group_log($GroupID, $TorrentID, $LoggedUser['ID'], 'uploaded ('. Torrents::update_hash($GroupID); $Debug->set_flag('upload: sphinx updated'); +foreach ($ExtraTorrentsInsert as $ExtraTorrent) { + $ExtraHasLog = 0; + $ExtraHasCue = 0; + $LogScore = 0; + // Torrent + $DB->query(" + INSERT INTO torrents + (GroupID, UserID, Media, Format, Encoding, + Remastered, RemasterYear, RemasterTitle, RemasterRecordLabel, RemasterCatalogueNumber, + HasLog, HasCue, info_hash, FileCount, FileList, FilePath, Size, Time, + Description, LogScore, FreeTorrent, FreeLeechType) + VALUES + ($GroupID, $LoggedUser[ID], $T[Media], '$ExtraTorrent[Format]', '$ExtraTorrent[Encoding]', + $T[Remastered], $T[RemasterYear], $T[RemasterTitle], $T[RemasterRecordLabel], $T[RemasterCatalogueNumber], + $ExtraHasLog, $ExtraHasCue, '".db_string($ExtraTorrent['InfoHash'])."', $ExtraTorrent[NumFiles], + '$ExtraTorrent[FileString]', '$ExtraTorrent[FilePath]', $ExtraTorrent[TotalSize], '".sqltime()."', + '$ExtraTorrent[TorrentDescription]', $LogScore, '$T[FreeLeech]', '$T[FreeLeechType]')"); + + $Cache->increment('stats_torrent_count'); + $ExtraTorrentID = $DB->inserted_id(); + + Tracker::update_tracker('add_torrent', array('id' => $ExtraTorrentID, 'info_hash' => rawurlencode($ExtraTorrent['InfoHash']), 'freetorrent' => $T['FreeLeech'])); + + //******************************************************************************// + //--------------- Write torrent file -------------------------------------------// + + $DB->query(" + INSERT INTO torrents_files + (TorrentID, File) + VALUES + ($ExtraTorrentID, '$ExtraTorrent[TorEnc]')"); + + Misc::write_log("Torrent $ExtraTorrentID ($LogName) (" . number_format($ExtraTorrent['TotalSize'] / (1024 * 1024), 2) . ' MB) was uploaded by ' . $LoggedUser['Username']); + Torrents::write_group_log($GroupID, $ExtraTorrentID, $LoggedUser['ID'], 'uploaded (' . number_format($ExtraTorrent['TotalSize'] / (1024 * 1024), 2) . ' MB)', 0); + + Torrents::update_hash($GroupID); + + // IRC + $Announce = ''; + $Announce .= Artists::display_artists($ArtistForm, false); + $Announce .= trim($Properties['Title']) . ' '; + $Announce .= '[' . trim($Properties['Year']) . ']'; + if (($Properties['ReleaseType'] > 0)) { + $Announce .= ' [' . $ReleaseTypes[$Properties['ReleaseType']] . ']'; + } + $Announce .= ' - '; + $Announce .= trim(str_replace("'", '', $ExtraTorrent['Format'])) . ' / ' . trim(str_replace("'", '', $ExtraTorrent['Encoding'])); + $Announce .= ' / ' . trim($Properties['Media']); + if ($T['FreeLeech'] == '1') { + $Announce .= ' / Freeleech!'; + } + + $AnnounceSSL = $Announce . ' - ' . site_url() . "torrents.php?id=$GroupID / " . site_url() . "torrents.php?action=download&id=$ExtraTorrentID"; + $Announce .= ' - ' . site_url() . "torrents.php?id=$GroupID / " . site_url() . "torrents.php?action=download&id=$ExtraTorrentID"; + + $AnnounceSSL .= ' - ' . trim($Properties['TagList']); + $Announce .= ' - ' . trim($Properties['TagList']); + + // ENT_QUOTES is needed to decode single quotes/apostrophes + //send_irc('PRIVMSG #' . NONSSL_SITE_URL . '-announce :' . html_entity_decode($Announce, ENT_QUOTES)); + //send_irc('PRIVMSG #' . SSL_SITE_URL . '-announce-ssl :' . html_entity_decode($AnnounceSSL, ENT_QUOTES)); +} + //******************************************************************************// //--------------- Stupid Recent Uploads ----------------------------------------// @@ -1065,4 +1231,3 @@ $Cache->delete_value("torrents_details_$GroupID"); // Allow deletion of this torrent now $Cache->delete_value("torrent_{$TorrentID}_lock"); - From ce31719cad2b6683329d2fb5644050eae3bd2825 Mon Sep 17 00:00:00 2001 From: Spine Date: Sun, 8 Oct 2017 18:52:07 +0200 Subject: [PATCH 13/17] Change the JS pop-up text to warn if burning an FL token on a non-seeded torrent --- classes/util.php | 16 +++++++++++++++- sections/artist/artist.php | 3 +-- sections/bookmarks/torrents.php | 4 ++-- sections/collages/torrent_collage.php | 5 ++--- sections/top10/votes.php | 5 ++--- sections/torrents/browse.php | 7 ++++--- sections/torrents/details.php | 5 +++-- sections/torrents/functions.php | 2 +- sections/torrents/notify.php | 5 +++-- 9 files changed, 33 insertions(+), 19 deletions(-) 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/sections/artist/artist.php b/sections/artist/artist.php index 7a5b0e3a6..8bdf3c444 100644 --- a/sections/artist/artist.php +++ b/sections/artist/artist.php @@ -456,7 +456,7 @@ foreach ($Importances as $Group) { [ - | FL + | FL | [apollo.rip].json" class="tooltip" title="Download JSON">JS ] @@ -998,4 +998,3 @@ if ($RevisionID) { $Data = array(array($Name, $Image, $Body, $NumSimilar, $SimilarArray, array(), array(), $VanityHouseArtist)); $Cache->cache_value($Key, $Data, 3600); -?> diff --git a/sections/bookmarks/torrents.php b/sections/bookmarks/torrents.php index 4b036bf57..07bb9325a 100644 --- a/sections/bookmarks/torrents.php +++ b/sections/bookmarks/torrents.php @@ -147,7 +147,7 @@ foreach ($GroupIDs as $GroupID) { [ DL - | FL + | FL | RP ] @@ -189,7 +189,7 @@ foreach ($GroupIDs as $GroupID) { [ DL - | FL + | FL | RP ] diff --git a/sections/collages/torrent_collage.php b/sections/collages/torrent_collage.php index b605d0c63..da6ffce05 100644 --- a/sections/collages/torrent_collage.php +++ b/sections/collages/torrent_collage.php @@ -172,7 +172,7 @@ foreach ($GroupIDs as $GroupID) { DL - | FL + | FL | RP @@ -214,7 +214,7 @@ foreach ($GroupIDs as $GroupID) { DL - | FL + | FL | RP @@ -620,4 +620,3 @@ if ($CollageCovers != 0) { ?>
    diff --git a/sections/top10/votes.php b/sections/top10/votes.php index 5ce19ba97..09daa09d3 100644 --- a/sections/top10/votes.php +++ b/sections/top10/votes.php @@ -294,7 +294,7 @@ foreach ($TopVotes as $GroupID => $Group) { [ DL - | FL + | FL | RP ] @@ -342,7 +342,7 @@ foreach ($TopVotes as $GroupID => $Group) { [ DL - | FL + | FL | RP @@ -395,4 +395,3 @@ if ($TopVotes === false) { ?>
    diff --git a/sections/torrents/browse.php b/sections/torrents/browse.php index 62ac6de93..5d07bf741 100644 --- a/sections/torrents/browse.php +++ b/sections/torrents/browse.php @@ -655,7 +655,7 @@ $ShowGroups = !(!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGr [ - | FL + | FL | RP ] @@ -707,7 +707,7 @@ $ShowGroups = !(!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGr [ DL - | FL + | FL | RP ] @@ -730,4 +730,5 @@ $ShowGroups = !(!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGr - + [ - | FL + | FL | RP @@ -939,4 +939,5 @@ CommentsView::render_comments($Thread, $LastRead, "torrents.php?id=$GroupID"); - + [ - | FL + | FL | RP diff --git a/sections/torrents/notify.php b/sections/torrents/notify.php index 958739b81..2c5d1eefc 100644 --- a/sections/torrents/notify.php +++ b/sections/torrents/notify.php @@ -301,7 +301,7 @@ if (empty($Results)) { [ DL - | FL + | FL @@ -347,4 +347,5 @@ if (empty($Results)) { - + Date: Wed, 11 Oct 2017 14:11:56 +0000 Subject: [PATCH 14/17] fix filter on rules that have lists --- static/functions/rules.js | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/static/functions/rules.js b/static/functions/rules.js index bb0832f07..461abbcb8 100644 --- a/static/functions/rules.js +++ b/static/functions/rules.js @@ -1,11 +1,11 @@ function findRule() { var query_string = $('#search_string').val(); var q = query_string.replace(/\s+/gm, '').split('+'); - var regex = new Array(); + var regex = []; for (var i = 0; i < q.length; i++) { regex[i] = new RegExp(q[i], 'mi'); } - $('#actual_rules li').each(function() { + $('#actual_rules li[id^=r]').each(function() { var show = true; for (var i = 0; i < regex.length; i++) { if (!regex[i].test($(this).html())) { @@ -15,21 +15,22 @@ function findRule() { } $(this).toggle(show); }); - $('.before_rules').toggle(query_string.length == 0); + $('.before_rules').toggle(query_string.length === 0); } $(document).ready(function() { - var original_value = $('#search_string').val(); - $('#search_string').keyup(findRule); - $('#search_string').focus(function() { - if ($(this).val() == original_value) { - $(this).val(''); - } - }); - $('#search_string').blur(function() { - if ($(this).val() == '') { - $(this).val(original_value); - $('.before_rules').show(); - } - }) + var search_string = $('#search_string'); + var original_value = search_string.val(); + search_string.keyup(findRule); + search_string.focus(function() { + if ($(this).val() === original_value) { + $(this).val(''); + } + }); + search_string.blur(function() { + if ($(this).val() === '') { + $(this).val(original_value); + $('.before_rules').show(); + } + }); }); From aa2b3413ca73e6fa8fa174b536acecbf2af12070 Mon Sep 17 00:00:00 2001 From: itismadness Date: Wed, 11 Oct 2017 16:04:21 -0400 Subject: [PATCH 15/17] hide links --- design/publicheader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/design/publicheader.php b/design/publicheader.php index 6a8b5dd9d..b8f11cc23 100644 --- a/design/publicheader.php +++ b/design/publicheader.php @@ -36,9 +36,9 @@ define('FOOTER_FILE',SERVER_ROOT.'/design/publicfooter.php'); From b16db37fd3cb41a08b200f9aeb699efdb080721d Mon Sep 17 00:00:00 2001 From: itismadness Date: Fri, 13 Oct 2017 11:26:28 -0400 Subject: [PATCH 16/17] add type hinting for variables in G class --- classes/g.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/classes/g.class.php b/classes/g.class.php index 67718e776..f9df0c04a 100644 --- a/classes/g.class.php +++ b/classes/g.class.php @@ -1,6 +1,8 @@ Date: Fri, 13 Oct 2017 13:33:37 -0400 Subject: [PATCH 17/17] remove dead peers agin --- sections/schedule/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sections/schedule/index.php b/sections/schedule/index.php index 01115c930..f0e96eaa7 100644 --- a/sections/schedule/index.php +++ b/sections/schedule/index.php @@ -426,10 +426,10 @@ if ($Hour != $NextHour || $_GET['runhour'] || isset($argv[2])) { AND TimeFilled != '0000-00-00 00:00:00'"); //------------- Remove dead peers ---------------------------------------// - /* sleep(3); + sleep(3); $DB->query(" DELETE FROM xbt_files_users - WHERE mtime < unix_timestamp(NOW() - INTERVAL 6 HOUR)"); */ + WHERE mtime < unix_timestamp(NOW() - INTERVAL 6 HOUR)"); //------------- Remove dead sessions ---------------------------------------// sleep(3);