diff options
author | Git <git@what.cd> | 2015-12-08 08:00:30 +0000 |
---|---|---|
committer | Git <git@what.cd> | 2015-12-08 08:00:30 +0000 |
commit | ad9a42b16a3ebcfcbf2a8c29e54dadbff7c27222 (patch) | |
tree | 694e345f85d364260af6aeb7dafbd9b077f7327a | |
parent | 0d6f52aa6cee7929db313055b284dec88be0db85 (diff) | |
download | Gazelle-ad9a42b16a3ebcfcbf2a8c29e54dadbff7c27222.zip Gazelle-ad9a42b16a3ebcfcbf2a8c29e54dadbff7c27222.tar.gz Gazelle-ad9a42b16a3ebcfcbf2a8c29e54dadbff7c27222.tar.bz2 |
Empty commit
-rw-r--r-- | classes/lockedaccounts.class.php | 60 | ||||
-rw-r--r-- | sections/login/index.php | 4 | ||||
-rw-r--r-- | sections/schedule/index.php | 1 |
3 files changed, 62 insertions, 3 deletions
diff --git a/classes/lockedaccounts.class.php b/classes/lockedaccounts.class.php new file mode 100644 index 0000000..a2ffcd0 --- /dev/null +++ b/classes/lockedaccounts.class.php @@ -0,0 +1,60 @@ +<? + +/** + * Class to manage locked accounts + */ +class LockedAccounts +{ + + /** + * Lock an account + * + * @param int $UserID The ID of the user to lock + * @param int $Type The lock type, should be a constant value + * @param string $Message The message to write to user notes + * @param string $Reason The reason for the lock + * @param int $LockedByUserID The ID of the staff member that locked $UserID's account. 0 for system + */ + public static function lock_account($UserID, $Type, $Message, $Reason, $LockedByUserID) + { + + if ($LockedByUserID == 0) { + $Username = "System"; + } else { + G::$DB->query("SELECT Username FROM users_main WHERE ID = '" . $UserID . "'"); + list($Username) = G::$DB->next_record(); + } + + G::$DB->query(" + INSERT INTO locked_accounts (UserID, Type) + VALUES ('" . $UserID . "', " . $Type . ")"); + Tools::update_user_notes($UserID, sqltime() . " - " . db_string($Message) . " by $Username\nReason: " . db_string($Reason) . "\n\n"); + G::$Cache->delete_value('user_info_' . $UserID); + } + + /** + * Unlock an account + * + * @param int $UserID The ID of the user to unlock + * @param int $Type The lock type, should be a constant value. Used for database verification + * to avoid deleting the wrong lock type + * @param string $Reason The reason for unlock + * @param int $UnlockedByUserID The ID of the staff member unlocking $UserID's account. 0 for system + */ + public static function unlock_account($UserID, $Type, $Message, $Reason, $UnlockedByUserID) + { + if ($UnlockedByUserID == 0) { + $Username = "System"; + } else { + G::$DB->query("SELECT Username FROM users_main WHERE ID = '" . $UserID . "'"); + list($Username) = G::$DB->next_record(); + } + + G::$DB->query("DELETE FROM locked_accounts WHERE UserID = '$UserID' AND Type = '". $Type ."'"); + + if (G::$DB->affected_rows() == 1) { + G::$Cache->delete_value("user_info_" . $UserID); + Tools::update_user_notes($UserID, sqltime() . " - " . db_string($Message) . " by $Username\nReason: " . db_string($Reason) . "\n\n"); + } + } +}
\ No newline at end of file diff --git a/sections/login/index.php b/sections/login/index.php index 63bd1b1..2e80bf3 100644 --- a/sections/login/index.php +++ b/sections/login/index.php @@ -66,14 +66,14 @@ if (isset($_REQUEST['act']) && $_REQUEST['act'] == 'recover') { i.ResetExpires = '0000-00-00 00:00:00' WHERE m.ID = '$UserID' AND i.UserID = m.ID"); - $DB->query(" INSERT INTO users_history_passwords (UserID, ChangerIP, ChangeTime) VALUES ('$UserID', '$_SERVER[REMOTE_ADDR]', '".sqltime()."')"); $Reset = true; // Past tense form of "to reset", meaning that password has now been reset - G::$LoggedUser['ID'] = $UserID; // Set $LoggedUser['ID'] for logout_all_sessions() to work + $LoggedUser['ID'] = $UserID; // Set $LoggedUser['ID'] for logout_all_sessions() to work + logout_all_sessions(); diff --git a/sections/schedule/index.php b/sections/schedule/index.php index 7df8c98..b844235 100644 --- a/sections/schedule/index.php +++ b/sections/schedule/index.php @@ -1344,7 +1344,6 @@ if (!$NoDaily && $Day != $NextDay || $_GET['runday']) { AND AssignedToUser IS NULL"); Donations::schedule(); - } /*************************************************************************\ //--------------Run twice per month -------------------------------------// |