From b43965b12321a4d1733bca661827e82dcbada409 Mon Sep 17 00:00:00 2001 From: Git Date: Mon, 23 Dec 2013 08:00:59 +0000 Subject: [PATCH] Empty commit --- classes/donations.class.php | 22 +++++++++++++--------- docs/CHANGES.txt | 9 +++++++++ gazelle.sql | 1 + sections/schedule/index.php | 19 +++++++++++++++++-- sections/staffpm/assign.php | 1 + sections/staffpm/multiresolve.php | 5 ++--- sections/staffpm/resolve.php | 6 +++--- sections/staffpm/takepost.php | 15 ++++++++------- sections/staffpm/unresolve.php | 2 +- sections/staffpm/viewconv.php | 2 +- static/functions/script_start.js | 9 +++++++++ static/styles/global.css | 13 +++++++++++++ 12 files changed, 78 insertions(+), 26 deletions(-) diff --git a/classes/donations.class.php b/classes/donations.class.php index 7e68453c..b3a31c5a 100644 --- a/classes/donations.class.php +++ b/classes/donations.class.php @@ -84,13 +84,14 @@ public static function donate($UserID, $Args) { $AdjustedRank = $Rank >= MAX_EXTRA_RANK ? MAX_EXTRA_RANK : $Rank; G::$DB->query(" INSERT INTO users_donor_ranks - (UserID, Rank, TotalRank, DonationTime) + (UserID, Rank, TotalRank, DonationTime, RankExpirationTime) VALUES - ('$UserID', '$AdjustedRank', '$TotalRank', '$Date') + ('$UserID', '$AdjustedRank', '$TotalRank', '$Date', '$Date') ON DUPLICATE KEY UPDATE Rank = '$AdjustedRank', TotalRank = '$TotalRank', - DonationTime = '$Date'"); + DonationTime = '$Date', + RankExpirationTime = '$Date'"); } else { // Donations from the store get donor points directly, no need to calculate them @@ -114,13 +115,14 @@ public static function donate($UserID, $Args) { } G::$DB->query(" INSERT INTO users_donor_ranks - (UserID, Rank, TotalRank, DonationTime) + (UserID, Rank, TotalRank, DonationTime, RankExpirationTime) VALUES - ('$UserID', '$AdjustedRank', '$DonorPoints', '$Date') + ('$UserID', '$AdjustedRank', '$DonorPoints', '$Date', '$Date') ON DUPLICATE KEY UPDATE Rank = '$AdjustedRank', TotalRank = TotalRank + '$DonorPoints', - DonationTime = '$Date'"); + DonationTime = '$Date', + RankExpirationTime = '$Date'"); } // Donor cache key is outdated G::$Cache->delete_value("donor_info_$UserID"); @@ -216,7 +218,7 @@ public static function schedule() { self::$IsSchedule = true; DonationsBitcoin::find_new_donations(); - //self::expire_ranks(); + self::expire_ranks(); self::get_new_conversion_rates(); } @@ -227,18 +229,20 @@ public static function expire_ranks() { FROM users_donor_ranks WHERE Rank > 1 AND SpecialRank != 3 - AND DonationTime < NOW() - INTERVAL 32 DAY"); + AND RankExpirationTime < NOW() - INTERVAL 32 DAY"); if (G::$DB->record_count() > 0) { $UserIDs = array(); while (list($UserID, $Rank) = G::$DB->next_record()) { G::$Cache->delete_value("donor_info_$UserID"); + G::$Cache->delete_value("donor_title_$UserID"); + G::$Cache->delete_value("donor_profile_rewards_$UserID"); $UserIDs[] = $UserID; } $In = implode(',', $UserIDs); G::$DB->query(" UPDATE users_donor_ranks - SET Rank = Rank - IF(Rank = " . MAX_RANK . ", 2, 1) + SET Rank = Rank - IF(Rank = " . MAX_RANK . ", 2, 1), RankExpirationTime = NOW() WHERE UserID IN ($In)"); } G::$DB->set_query_id($QueryID); diff --git a/docs/CHANGES.txt b/docs/CHANGES.txt index e1fc49c3..3977e9c2 100644 --- a/docs/CHANGES.txt +++ b/docs/CHANGES.txt @@ -1,5 +1,14 @@ CHANGE LOG +2013-12-23 by alderaan +Clear "user_info_$UserID" for each user that gets disabled for having never logged in + +2013-12-23 by alderaan +Clear "num_staff_pms_$UserID" cache key when reassigning a Staff PM + +2013-12-22 by Ajax +Donor rank expiration + 2013-12-16 by alderaan Remove code to check for public torrents diff --git a/gazelle.sql b/gazelle.sql index 5bf4e562..e16da53a 100644 --- a/gazelle.sql +++ b/gazelle.sql @@ -1348,6 +1348,7 @@ CREATE TABLE `users_donor_ranks` ( `TotalRank` int(10) NOT NULL DEFAULT '0', `SpecialRank` tinyint(2) DEFAULT '0', `InvitesRecievedRank` tinyint(4) DEFAULT '0', + `RankExpirationTime` datetime DEFAULT NULL, PRIMARY KEY (`UserID`), KEY `DonationTime` (`DonationTime`), KEY `SpecialRank` (`SpecialRank`), diff --git a/sections/schedule/index.php b/sections/schedule/index.php index eeefa902..a7444098 100644 --- a/sections/schedule/index.php +++ b/sections/schedule/index.php @@ -847,6 +847,17 @@ function next_hour() { //------------- Disable unconfirmed users ------------------------------// sleep(10); + // get a list of user IDs for clearing cache keys + $DB->query(" + SELECT UserID + FROM users_info AS ui + JOIN users_main AS um ON um.ID = ui.UserID + WHERE um.LastAccess = '0000-00-00 00:00:00' + AND ui.JoinDate < '".time_minus(60 * 60 * 24 * 7)."' + AND um.Enabled != '2'"); + $UserIDs = $DB->collect('UserID'); + + // disable the users $DB->query(" UPDATE users_info AS ui JOIN users_main AS um ON um.ID = ui.UserID @@ -856,10 +867,14 @@ function next_hour() { ui.AdminComment = CONCAT('$sqltime - Disabled for inactivity (never logged in)\n\n', ui.AdminComment) WHERE um.LastAccess = '0000-00-00 00:00:00' AND ui.JoinDate < '".time_minus(60 * 60 * 24 * 7)."' - AND um.Enabled != '2' - "); + AND um.Enabled != '2'"); $Cache->decrement('stats_user_count', $DB->affected_rows()); + // clear the appropriate cache keys + foreach ($UserIDs as $UserID) { + $Cache->delete_value("user_info_$UserID"); + } + echo "disabled unconfirmed\n"; //------------- Demote users --------------------------------------------// diff --git a/sections/staffpm/assign.php b/sections/staffpm/assign.php index e28043cf..eae5d454 100644 --- a/sections/staffpm/assign.php +++ b/sections/staffpm/assign.php @@ -33,6 +33,7 @@ SET Status = 'Unanswered', Level = $Level WHERE ID = $ConvID"); + $Cache->delete_value("num_staff_pms_$LoggedUser[ID]"); header('Location: staffpm.php'); } else { error(404); diff --git a/sections/staffpm/multiresolve.php b/sections/staffpm/multiresolve.php index 9748f5a9..f115e417 100644 --- a/sections/staffpm/multiresolve.php +++ b/sections/staffpm/multiresolve.php @@ -28,12 +28,11 @@ $DB->query($Query); } // Clear cache for user - $Cache->delete_value('staff_pm_new_'.$LoggedUser['ID']); - $Cache->delete_value('num_staff_pms_'.$LoggedUser['ID']); + $Cache->delete_value("staff_pm_new_$LoggedUser[ID]"); + $Cache->delete_value("num_staff_pms_$LoggedUser[ID]"); // Done! Return to inbox header("Location: staffpm.php"); - } else { // No ID header("Location: staffpm.php"); diff --git a/sections/staffpm/resolve.php b/sections/staffpm/resolve.php index 18064874..4af66bba 100644 --- a/sections/staffpm/resolve.php +++ b/sections/staffpm/resolve.php @@ -11,10 +11,10 @@ // Conversation belongs to user or user is staff, resolve it $DB->query(" UPDATE staff_pm_conversations - SET Status = 'Resolved', ResolverID = ".$LoggedUser['ID']." + SET Status = 'Resolved', ResolverID = $LoggedUser[ID] WHERE ID = $ID"); - $Cache->delete_value('staff_pm_new_'.$LoggedUser['ID']); - $Cache->delete_value('num_staff_pms_'.$LoggedUser['ID']); + $Cache->delete_value("staff_pm_new_$LoggedUser[ID]"); + $Cache->delete_value("num_staff_pms_$LoggedUser[ID]"); header('Location: staffpm.php'); } else { diff --git a/sections/staffpm/takepost.php b/sections/staffpm/takepost.php index 33e6baa2..1c5f70e9 100644 --- a/sections/staffpm/takepost.php +++ b/sections/staffpm/takepost.php @@ -43,20 +43,24 @@ // FLS/Staff $DB->query(" UPDATE staff_pm_conversations - SET Date = '".sqltime()."', Unread = true, Status = 'Open' + SET Date = '".sqltime()."', + Unread = true, + Status = 'Open' WHERE ID = $ConvID"); - $Cache->delete_value('num_staff_pms_'.$LoggedUser['ID']); + $Cache->delete_value("num_staff_pms_$LoggedUser[ID]"); } else { // User $DB->query(" UPDATE staff_pm_conversations - SET Date = '".sqltime()."', Unread = true, Status = 'Unanswered' + SET Date = '".sqltime()."', + Unread = true, + Status = 'Unanswered' WHERE ID = $ConvID"); } // Clear cache for user $Cache->delete_value("staff_pm_new_$UserID"); - $Cache->delete_value('staff_pm_new_'.$LoggedUser['ID']); + $Cache->delete_value("staff_pm_new_$LoggedUser[ID]"); header("Location: staffpm.php?action=viewconv&id=$ConvID"); } else { @@ -71,11 +75,8 @@ } elseif ($ConvID = (int)$_POST['convid']) { // No message, but conversation ID header("Location: staffpm.php?action=viewconv&id=$ConvID"); - } else { // No message or conversation ID header('Location: staffpm.php'); } - - ?> diff --git a/sections/staffpm/unresolve.php b/sections/staffpm/unresolve.php index f1b86cd9..64ddbf50 100644 --- a/sections/staffpm/unresolve.php +++ b/sections/staffpm/unresolve.php @@ -22,7 +22,7 @@ SET Status = 'Unanswered' WHERE ID = $ID"); // Clear cache for user - $Cache->delete_value('num_staff_pms_'.$LoggedUser['ID']); + $Cache->delete_value("num_staff_pms_$LoggedUser[ID]"); header('Location: staffpm.php'); } else { diff --git a/sections/staffpm/viewconv.php b/sections/staffpm/viewconv.php index ac268dbe..5bf80179 100644 --- a/sections/staffpm/viewconv.php +++ b/sections/staffpm/viewconv.php @@ -22,7 +22,7 @@ SET Unread = false WHERE ID = $ConvID"); // Clear cache for user - $Cache->delete_value('staff_pm_new_'.$LoggedUser['ID']); + $Cache->delete_value("staff_pm_new_$LoggedUser[ID]"); } View::show_header('Staff PM', 'staffpm,bbcode'); diff --git a/static/functions/script_start.js b/static/functions/script_start.js index b72e04b4..209f5b7a 100644 --- a/static/functions/script_start.js +++ b/static/functions/script_start.js @@ -225,6 +225,15 @@ function isNumberKey(e) { return true; } +function sleep(milliseconds) { + var start = new Date().getTime(); + for (var i = 0; i < 1e7; i++) { + if ((new Date().getTime() - start) > milliseconds){ + break; + } + } +} + $.fn.extend({ results: function () { return this.size(); diff --git a/static/styles/global.css b/static/styles/global.css index 31469a23..c6c167f9 100644 --- a/static/styles/global.css +++ b/static/styles/global.css @@ -193,6 +193,12 @@ div#AddArtists a { height: 180px; bottom: 0px; right: 0px; + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; } .rippywrap div.rippy { @@ -202,8 +208,15 @@ div#AddArtists a { position: fixed; bottom: 0px; right: 0px; + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; } + td.label { vertical-align: top; }