diff --git a/globals/Dependencies/Moderation/UserModerationManager.php b/globals/Dependencies/Moderation/UserModerationManager.php index 890b1b2..b971364 100644 --- a/globals/Dependencies/Moderation/UserModerationManager.php +++ b/globals/Dependencies/Moderation/UserModerationManager.php @@ -2,11 +2,21 @@ namespace Alphaland\Moderation { + use Alphaland\Users\User; use Alphaland\Web\WebContextManager; use PDO; class UserModerationManager { + public static function LogAction(string $action) + { + $localuser = $GLOBALS['user']->id; + $log = $GLOBALS['pdo']->prepare('INSERT INTO staff_actions(userid, action, whenOccurred) VALUES (:uid, :action, UNIX_TIMESTAMP())'); + $log->bindParam(':uid', $localuser, PDO::PARAM_INT); + $log->bindParam(':action', $action, PDO::PARAM_STR); + $log->execute(); + } + public static function IsBanned(int $userId) { $query = $GLOBALS['pdo']->prepare("SELECT * FROM `user_bans` WHERE `uid` = :i AND `valid` = 1"); @@ -26,7 +36,7 @@ namespace Alphaland\Moderation { $unban->bindParam(":u", $uid, PDO::PARAM_INT); $unban->execute(); if ($unban->rowCount() > 0) { - logStaffAction("Unbanned User ".$uid); + UserModerationManager::LogAction("Unbanned User ".$uid); return true; } } @@ -54,7 +64,7 @@ namespace Alphaland\Moderation { $ban->execute(); if ($ban->rowCount() > 0) { kickUserIfInGame($uid, "You've been banned from Alphaland, '".$reason."'"); - logStaffAction("Banned User ".$uid); + UserModerationManager::LogAction("Banned User ".$uid); //ban user from discord with bot if($bantype == 2) { //perm ban diff --git a/globals/functions.php b/globals/functions.php index b31a145..fd9218c 100644 --- a/globals/functions.php +++ b/globals/functions.php @@ -6832,14 +6832,4 @@ function isIPAssociatedWithAccount($ip) return false; } -function logStaffAction($action) -{ - $localuser = $GLOBALS['user']->id; - - $log = $GLOBALS['pdo']->prepare('INSERT INTO staff_actions(userid, action, whenOccurred) VALUES (:uid, :action, UNIX_TIMESTAMP())'); - $log->bindParam(':uid', $localuser, PDO::PARAM_INT); - $log->bindParam(':action', $action, PDO::PARAM_STR); - $log->execute(); -} - //end utility } diff --git a/html/MCP/approveasset.php b/html/MCP/approveasset.php index a5d009f..31c5d3b 100644 --- a/html/MCP/approveasset.php +++ b/html/MCP/approveasset.php @@ -7,6 +7,7 @@ Alphaland 2021 //headers +use Alphaland\Moderation\UserModerationManager; use Alphaland\Web\WebContextManager; header("Access-Control-Allow-Origin: https://www.alphaland.cc"); @@ -29,7 +30,7 @@ else if (isThumbnailerAlive()) { $approve = approveAsset($assetid); if ($approve === true) { - logStaffAction("Approved Asset ".$assetid); + UserModerationManager::LogAction("Approved Asset ".$assetid); $approve = "Approved Asset"; } } else { diff --git a/html/MCP/moderateasset.php b/html/MCP/moderateasset.php index 4484cd2..053b7f4 100644 --- a/html/MCP/moderateasset.php +++ b/html/MCP/moderateasset.php @@ -7,6 +7,7 @@ Alphaland 2021 //headers +use Alphaland\Moderation\UserModerationManager; use Alphaland\Web\WebContextManager; header("Access-Control-Allow-Origin: https://www.alphaland.cc"); @@ -28,7 +29,7 @@ else { $moderate = moderateAsset($assetid); if ($moderate === true) { - logStaffAction("Moderated Asset ".$assetid); + UserModerationManager::LogAction("Moderated Asset ".$assetid); $moderate = "Moderated Asset"; } header('Content-Type: application/json'); diff --git a/html/catalog/config.php b/html/catalog/config.php index 6b904fc..b6e45bf 100644 --- a/html/catalog/config.php +++ b/html/catalog/config.php @@ -1,5 +1,7 @@ isStaff()) { - logStaffAction("Configure Item ".$id); + UserModerationManager::LogAction("Configure Item ".$id); } //update item name @@ -132,7 +134,7 @@ if(isset($_GET['id'])) { if ($user->isStaff()) { - logStaffAction("Configure Item Onsale ".$id); + UserModerationManager::LogAction("Configure Item Onsale ".$id); } //update onsale @@ -145,7 +147,7 @@ if(isset($_GET['id'])) } else { - logStaffAction("Configure Item Offsale ".$id); + UserModerationManager::LogAction("Configure Item Offsale ".$id); //update onsale $onsale = 0; @@ -166,7 +168,7 @@ if(isset($_GET['id'])) $script = ""; $scripttype = ""; - logStaffAction("Render Item ".$id); + UserModerationManager::LogAction("Render Item ".$id); if ($itemtypeint == 8) { //Hat