usermoderationmanager logaction

This commit is contained in:
Astrologies 2021-12-01 21:08:35 -05:00
parent cfc7148b51
commit 7d51370742
5 changed files with 22 additions and 18 deletions

View File

@ -2,11 +2,21 @@
namespace Alphaland\Moderation { namespace Alphaland\Moderation {
use Alphaland\Users\User;
use Alphaland\Web\WebContextManager; use Alphaland\Web\WebContextManager;
use PDO; use PDO;
class UserModerationManager 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) public static function IsBanned(int $userId)
{ {
$query = $GLOBALS['pdo']->prepare("SELECT * FROM `user_bans` WHERE `uid` = :i AND `valid` = 1"); $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->bindParam(":u", $uid, PDO::PARAM_INT);
$unban->execute(); $unban->execute();
if ($unban->rowCount() > 0) { if ($unban->rowCount() > 0) {
logStaffAction("Unbanned User ".$uid); UserModerationManager::LogAction("Unbanned User ".$uid);
return true; return true;
} }
} }
@ -54,7 +64,7 @@ namespace Alphaland\Moderation {
$ban->execute(); $ban->execute();
if ($ban->rowCount() > 0) { if ($ban->rowCount() > 0) {
kickUserIfInGame($uid, "You've been banned from Alphaland, '".$reason."'"); kickUserIfInGame($uid, "You've been banned from Alphaland, '".$reason."'");
logStaffAction("Banned User ".$uid); UserModerationManager::LogAction("Banned User ".$uid);
//ban user from discord with bot //ban user from discord with bot
if($bantype == 2) { //perm ban if($bantype == 2) { //perm ban

View File

@ -6832,14 +6832,4 @@ function isIPAssociatedWithAccount($ip)
return false; 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 } //end utility }

View File

@ -7,6 +7,7 @@ Alphaland 2021
//headers //headers
use Alphaland\Moderation\UserModerationManager;
use Alphaland\Web\WebContextManager; use Alphaland\Web\WebContextManager;
header("Access-Control-Allow-Origin: https://www.alphaland.cc"); header("Access-Control-Allow-Origin: https://www.alphaland.cc");
@ -29,7 +30,7 @@ else
if (isThumbnailerAlive()) { if (isThumbnailerAlive()) {
$approve = approveAsset($assetid); $approve = approveAsset($assetid);
if ($approve === true) { if ($approve === true) {
logStaffAction("Approved Asset ".$assetid); UserModerationManager::LogAction("Approved Asset ".$assetid);
$approve = "Approved Asset"; $approve = "Approved Asset";
} }
} else { } else {

View File

@ -7,6 +7,7 @@ Alphaland 2021
//headers //headers
use Alphaland\Moderation\UserModerationManager;
use Alphaland\Web\WebContextManager; use Alphaland\Web\WebContextManager;
header("Access-Control-Allow-Origin: https://www.alphaland.cc"); header("Access-Control-Allow-Origin: https://www.alphaland.cc");
@ -28,7 +29,7 @@ else
{ {
$moderate = moderateAsset($assetid); $moderate = moderateAsset($assetid);
if ($moderate === true) { if ($moderate === true) {
logStaffAction("Moderated Asset ".$assetid); UserModerationManager::LogAction("Moderated Asset ".$assetid);
$moderate = "Moderated Asset"; $moderate = "Moderated Asset";
} }
header('Content-Type: application/json'); header('Content-Type: application/json');

View File

@ -1,5 +1,7 @@
<?php <?php
use Alphaland\Moderation\UserModerationManager;
use Alphaland\Users\User;
use Alphaland\Web\WebContextManager; use Alphaland\Web\WebContextManager;
$body = ''; $body = '';
@ -104,7 +106,7 @@ if(isset($_GET['id']))
{ {
if ($user->isStaff()) if ($user->isStaff())
{ {
logStaffAction("Configure Item ".$id); UserModerationManager::LogAction("Configure Item ".$id);
} }
//update item name //update item name
@ -132,7 +134,7 @@ if(isset($_GET['id']))
{ {
if ($user->isStaff()) if ($user->isStaff())
{ {
logStaffAction("Configure Item Onsale ".$id); UserModerationManager::LogAction("Configure Item Onsale ".$id);
} }
//update onsale //update onsale
@ -145,7 +147,7 @@ if(isset($_GET['id']))
} }
else else
{ {
logStaffAction("Configure Item Offsale ".$id); UserModerationManager::LogAction("Configure Item Offsale ".$id);
//update onsale //update onsale
$onsale = 0; $onsale = 0;
@ -166,7 +168,7 @@ if(isset($_GET['id']))
$script = ""; $script = "";
$scripttype = ""; $scripttype = "";
logStaffAction("Render Item ".$id); UserModerationManager::LogAction("Render Item ".$id);
if ($itemtypeint == 8) if ($itemtypeint == 8)
{ {
//Hat //Hat