Empty commit

This commit is contained in:
Git 2013-12-23 08:00:59 +00:00
parent 0e601692de
commit b43965b123
12 changed files with 78 additions and 26 deletions

View File

@ -84,13 +84,14 @@ public static function donate($UserID, $Args) {
$AdjustedRank = $Rank >= MAX_EXTRA_RANK ? MAX_EXTRA_RANK : $Rank; $AdjustedRank = $Rank >= MAX_EXTRA_RANK ? MAX_EXTRA_RANK : $Rank;
G::$DB->query(" G::$DB->query("
INSERT INTO users_donor_ranks INSERT INTO users_donor_ranks
(UserID, Rank, TotalRank, DonationTime) (UserID, Rank, TotalRank, DonationTime, RankExpirationTime)
VALUES VALUES
('$UserID', '$AdjustedRank', '$TotalRank', '$Date') ('$UserID', '$AdjustedRank', '$TotalRank', '$Date', '$Date')
ON DUPLICATE KEY UPDATE ON DUPLICATE KEY UPDATE
Rank = '$AdjustedRank', Rank = '$AdjustedRank',
TotalRank = '$TotalRank', TotalRank = '$TotalRank',
DonationTime = '$Date'"); DonationTime = '$Date',
RankExpirationTime = '$Date'");
} }
else { else {
// Donations from the store get donor points directly, no need to calculate them // 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(" G::$DB->query("
INSERT INTO users_donor_ranks INSERT INTO users_donor_ranks
(UserID, Rank, TotalRank, DonationTime) (UserID, Rank, TotalRank, DonationTime, RankExpirationTime)
VALUES VALUES
('$UserID', '$AdjustedRank', '$DonorPoints', '$Date') ('$UserID', '$AdjustedRank', '$DonorPoints', '$Date', '$Date')
ON DUPLICATE KEY UPDATE ON DUPLICATE KEY UPDATE
Rank = '$AdjustedRank', Rank = '$AdjustedRank',
TotalRank = TotalRank + '$DonorPoints', TotalRank = TotalRank + '$DonorPoints',
DonationTime = '$Date'"); DonationTime = '$Date',
RankExpirationTime = '$Date'");
} }
// Donor cache key is outdated // Donor cache key is outdated
G::$Cache->delete_value("donor_info_$UserID"); G::$Cache->delete_value("donor_info_$UserID");
@ -216,7 +218,7 @@ public static function schedule() {
self::$IsSchedule = true; self::$IsSchedule = true;
DonationsBitcoin::find_new_donations(); DonationsBitcoin::find_new_donations();
//self::expire_ranks(); self::expire_ranks();
self::get_new_conversion_rates(); self::get_new_conversion_rates();
} }
@ -227,18 +229,20 @@ public static function expire_ranks() {
FROM users_donor_ranks FROM users_donor_ranks
WHERE Rank > 1 WHERE Rank > 1
AND SpecialRank != 3 AND SpecialRank != 3
AND DonationTime < NOW() - INTERVAL 32 DAY"); AND RankExpirationTime < NOW() - INTERVAL 32 DAY");
if (G::$DB->record_count() > 0) { if (G::$DB->record_count() > 0) {
$UserIDs = array(); $UserIDs = array();
while (list($UserID, $Rank) = G::$DB->next_record()) { while (list($UserID, $Rank) = G::$DB->next_record()) {
G::$Cache->delete_value("donor_info_$UserID"); G::$Cache->delete_value("donor_info_$UserID");
G::$Cache->delete_value("donor_title_$UserID");
G::$Cache->delete_value("donor_profile_rewards_$UserID");
$UserIDs[] = $UserID; $UserIDs[] = $UserID;
} }
$In = implode(',', $UserIDs); $In = implode(',', $UserIDs);
G::$DB->query(" G::$DB->query("
UPDATE users_donor_ranks 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)"); WHERE UserID IN ($In)");
} }
G::$DB->set_query_id($QueryID); G::$DB->set_query_id($QueryID);

View File

@ -1,5 +1,14 @@
CHANGE LOG 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 2013-12-16 by alderaan
Remove code to check for public torrents Remove code to check for public torrents

View File

@ -1348,6 +1348,7 @@ CREATE TABLE `users_donor_ranks` (
`TotalRank` int(10) NOT NULL DEFAULT '0', `TotalRank` int(10) NOT NULL DEFAULT '0',
`SpecialRank` tinyint(2) DEFAULT '0', `SpecialRank` tinyint(2) DEFAULT '0',
`InvitesRecievedRank` tinyint(4) DEFAULT '0', `InvitesRecievedRank` tinyint(4) DEFAULT '0',
`RankExpirationTime` datetime DEFAULT NULL,
PRIMARY KEY (`UserID`), PRIMARY KEY (`UserID`),
KEY `DonationTime` (`DonationTime`), KEY `DonationTime` (`DonationTime`),
KEY `SpecialRank` (`SpecialRank`), KEY `SpecialRank` (`SpecialRank`),

View File

@ -847,6 +847,17 @@ function next_hour() {
//------------- Disable unconfirmed users ------------------------------// //------------- Disable unconfirmed users ------------------------------//
sleep(10); 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(" $DB->query("
UPDATE users_info AS ui UPDATE users_info AS ui
JOIN users_main AS um ON um.ID = ui.UserID 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) ui.AdminComment = CONCAT('$sqltime - Disabled for inactivity (never logged in)\n\n', ui.AdminComment)
WHERE um.LastAccess = '0000-00-00 00:00:00' WHERE um.LastAccess = '0000-00-00 00:00:00'
AND ui.JoinDate < '".time_minus(60 * 60 * 24 * 7)."' 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()); $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"; echo "disabled unconfirmed\n";
//------------- Demote users --------------------------------------------// //------------- Demote users --------------------------------------------//

View File

@ -33,6 +33,7 @@
SET Status = 'Unanswered', SET Status = 'Unanswered',
Level = $Level Level = $Level
WHERE ID = $ConvID"); WHERE ID = $ConvID");
$Cache->delete_value("num_staff_pms_$LoggedUser[ID]");
header('Location: staffpm.php'); header('Location: staffpm.php');
} else { } else {
error(404); error(404);

View File

@ -28,12 +28,11 @@
$DB->query($Query); $DB->query($Query);
} }
// Clear cache for user // Clear cache for user
$Cache->delete_value('staff_pm_new_'.$LoggedUser['ID']); $Cache->delete_value("staff_pm_new_$LoggedUser[ID]");
$Cache->delete_value('num_staff_pms_'.$LoggedUser['ID']); $Cache->delete_value("num_staff_pms_$LoggedUser[ID]");
// Done! Return to inbox // Done! Return to inbox
header("Location: staffpm.php"); header("Location: staffpm.php");
} else { } else {
// No ID // No ID
header("Location: staffpm.php"); header("Location: staffpm.php");

View File

@ -11,10 +11,10 @@
// Conversation belongs to user or user is staff, resolve it // Conversation belongs to user or user is staff, resolve it
$DB->query(" $DB->query("
UPDATE staff_pm_conversations UPDATE staff_pm_conversations
SET Status = 'Resolved', ResolverID = ".$LoggedUser['ID']." SET Status = 'Resolved', ResolverID = $LoggedUser[ID]
WHERE ID = $ID"); WHERE ID = $ID");
$Cache->delete_value('staff_pm_new_'.$LoggedUser['ID']); $Cache->delete_value("staff_pm_new_$LoggedUser[ID]");
$Cache->delete_value('num_staff_pms_'.$LoggedUser['ID']); $Cache->delete_value("num_staff_pms_$LoggedUser[ID]");
header('Location: staffpm.php'); header('Location: staffpm.php');
} else { } else {

View File

@ -43,20 +43,24 @@
// FLS/Staff // FLS/Staff
$DB->query(" $DB->query("
UPDATE staff_pm_conversations UPDATE staff_pm_conversations
SET Date = '".sqltime()."', Unread = true, Status = 'Open' SET Date = '".sqltime()."',
Unread = true,
Status = 'Open'
WHERE ID = $ConvID"); WHERE ID = $ConvID");
$Cache->delete_value('num_staff_pms_'.$LoggedUser['ID']); $Cache->delete_value("num_staff_pms_$LoggedUser[ID]");
} else { } else {
// User // User
$DB->query(" $DB->query("
UPDATE staff_pm_conversations UPDATE staff_pm_conversations
SET Date = '".sqltime()."', Unread = true, Status = 'Unanswered' SET Date = '".sqltime()."',
Unread = true,
Status = 'Unanswered'
WHERE ID = $ConvID"); WHERE ID = $ConvID");
} }
// Clear cache for user // Clear cache for user
$Cache->delete_value("staff_pm_new_$UserID"); $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"); header("Location: staffpm.php?action=viewconv&id=$ConvID");
} else { } else {
@ -71,11 +75,8 @@
} elseif ($ConvID = (int)$_POST['convid']) { } elseif ($ConvID = (int)$_POST['convid']) {
// No message, but conversation ID // No message, but conversation ID
header("Location: staffpm.php?action=viewconv&id=$ConvID"); header("Location: staffpm.php?action=viewconv&id=$ConvID");
} else { } else {
// No message or conversation ID // No message or conversation ID
header('Location: staffpm.php'); header('Location: staffpm.php');
} }
?> ?>

View File

@ -22,7 +22,7 @@
SET Status = 'Unanswered' SET Status = 'Unanswered'
WHERE ID = $ID"); WHERE ID = $ID");
// Clear cache for user // Clear cache for user
$Cache->delete_value('num_staff_pms_'.$LoggedUser['ID']); $Cache->delete_value("num_staff_pms_$LoggedUser[ID]");
header('Location: staffpm.php'); header('Location: staffpm.php');
} else { } else {

View File

@ -22,7 +22,7 @@
SET Unread = false SET Unread = false
WHERE ID = $ConvID"); WHERE ID = $ConvID");
// Clear cache for user // 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'); View::show_header('Staff PM', 'staffpm,bbcode');

View File

@ -225,6 +225,15 @@ function isNumberKey(e) {
return true; 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({ $.fn.extend({
results: function () { results: function () {
return this.size(); return this.size();

View File

@ -193,6 +193,12 @@ div#AddArtists a {
height: 180px; height: 180px;
bottom: 0px; bottom: 0px;
right: 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 { .rippywrap div.rippy {
@ -202,8 +208,15 @@ div#AddArtists a {
position: fixed; position: fixed;
bottom: 0px; bottom: 0px;
right: 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 { td.label {
vertical-align: top; vertical-align: top;
} }