From 05e6e99048ec1c50538a558e2be46b0938602d47 Mon Sep 17 00:00:00 2001 From: Austin Date: Wed, 24 Nov 2021 01:35:57 -0500 Subject: [PATCH] misc usermoderationmanager impl --- globals/config.php | 3 +- globals/functions.php | 66 +----------- globals/userauth.php | 10 +- html/MCP/user-management.php | 198 ----------------------------------- html/profile/view.php | 3 +- 5 files changed, 14 insertions(+), 266 deletions(-) delete mode 100644 html/MCP/user-management.php diff --git a/globals/config.php b/globals/config.php index 246ae95..b0df6bd 100644 --- a/globals/config.php +++ b/globals/config.php @@ -92,6 +92,7 @@ try //alphaland specfic dependencies include "C:/Webserver/nginx/Alphaland/globals/Dependencies/Users/Activation.php"; include "C:/Webserver/nginx/Alphaland/globals/Dependencies/Users/TwoFactor.php"; + include "C:/Webserver/nginx/Alphaland/globals/Dependencies/Moderation/UserModerationManager.php"; //authenticator $authenticator = new PHPGangsta_GoogleAuthenticator(); @@ -134,7 +135,7 @@ try $twofactor = new Alphaland\Users\TwoFactor(); $twofactor = $twofactor::isSession2FAUnlocked(); - + $maintenance = checkIfUnderMaintenance(); $banned = checkIfBanned($GLOBALS['user']->id); diff --git a/globals/functions.php b/globals/functions.php index 1def585..d5a0ea5 100644 --- a/globals/functions.php +++ b/globals/functions.php @@ -762,7 +762,9 @@ function isSignupKeyUserGenerated($signupkey) $key->execute(); if ($key->rowCount() > 0) { - if (!banned($key->fetch(PDO::FETCH_OBJ)->userGen)) + $banned = new Alphaland\Moderation\UserModerationManager(); + $banned = $banned::IsBanned($key->fetch(PDO::FETCH_OBJ)->userGen); + if (!$banned) { return true; } @@ -4194,18 +4196,6 @@ function friendStatus($userid) return ""; } -function banned($id) -{ - $b = $GLOBALS['pdo']->prepare("SELECT COUNT(*) FROM user_bans WHERE uid = :i AND valid = 1"); - $b->bindParam(":i", $id, PDO::PARAM_INT); - $b->execute(); - if ($b->fetchColumn(0) > 0) - { - return true; - } - return false; -} - //end user functions //asset comments stuff { @@ -4993,56 +4983,6 @@ function soapCallService($arbiter, $name, $arguments = []) //end backend communication } -//admin portion { - -function banUser($uid, $reason, $banexpiration, $bantype) -{ - if($GLOBALS['user']->isStaff()) - { - $isstaffcheck = $GLOBALS['pdo']->prepare("SELECT * FROM users WHERE id = :i AND (rank = 1 OR rank = 2 OR rank = 3)"); - $isstaffcheck->bindParam(":i", $uid, PDO::PARAM_INT); - $isstaffcheck->execute(); - - if ($isstaffcheck->rowCount() == 0) - { - if (!banned($uid)) - { - kickUserIfInGame($uid, "You've been banned from Alphaland, '".$reason."'"); - - $ban = $GLOBALS['pdo']->prepare("INSERT INTO user_bans(uid, banReason, whenBanned, banExpiration, banType, whoBanned, valid) VALUES(:u, :br, UNIX_TIMESTAMP(), :be, :bt, :wb, 1)"); - $ban->bindParam(":u", $uid, PDO::PARAM_INT); - $ban->bindParam(":br", $reason, PDO::PARAM_STR); - $ban->bindParam(":be", $banexpiration, PDO::PARAM_INT); - $ban->bindParam(":bt", $bantype, PDO::PARAM_INT); - $ban->bindParam(":wb", $GLOBALS['user']->id, PDO::PARAM_INT); - $ban->execute(); - if ($ban->rowCount() > 0) - { - return true; - } - } - } - } - return false; -} - -function unbanUser($uid) -{ - if($GLOBALS['user']->isStaff()) - { - $ban = $GLOBALS['pdo']->prepare("DELETE FROM user_bans WHERE uid = :u"); - $ban->bindParam(":u", $uid, PDO::PARAM_INT); - $ban->execute(); - if ($ban->rowCount() > 0) - { - return true; - } - } - return false; -} - -//end of admin portion } - //thumbnails portion { function constructRenderHashUrl($hash) diff --git a/globals/userauth.php b/globals/userauth.php index 81627a0..bf1e815 100644 --- a/globals/userauth.php +++ b/globals/userauth.php @@ -69,8 +69,12 @@ class user { //activation stuff $activated = new Alphaland\Users\Activation(); $activated = $activated::isUserActivated($this->id); - - if (!banned($this->id)) + + //banned + $banned = new Alphaland\Moderation\UserModerationManager(); + $banned = $banned::IsBanned($this->id); + + if (!$banned) { //update token interval $updateLastSeen = $GLOBALS['pdo']->prepare("UPDATE users SET lastseen = UNIX_TIMESTAMP() WHERE id = :id"); @@ -84,7 +88,7 @@ class user { $updateip->bindParam(":id", $info->uid, PDO::PARAM_INT); $updateip->execute(); - if ($activated && !banned($this->id)) + if ($activated && !$banned) { //reward currency daily if (($userInfo->dailytime + (86400 * 1)) < time() || $userInfo->dailytime == 0) //its been a day or first time diff --git a/html/MCP/user-management.php b/html/MCP/user-management.php deleted file mode 100644 index 5ec8466..0000000 --- a/html/MCP/user-management.php +++ /dev/null @@ -1,198 +0,0 @@ -isStaff())) -{ - redirect("../404"); //u not admin nigga -} - -$alert = ""; -if(isset($_POST['unbanuser'])) -{ - $id = getID($_POST['unbanuser']); - if (unbanUser($id)) - { - logStaffAction("Unbanned User ".$id); - $alert = ""; - } - else - { - $alert = ""; - } -} - -if(isset($_POST['banuser'])) -{ - $postcount = count($_POST); - - if ($postcount > 3) - { - $alert = ""; - } - elseif (empty($_POST['banuser'])) - { - $alert = ""; - } - elseif(usernameExists($_POST['banuser']) == false) - { - $alert = ""; - } - elseif (empty($_POST['banreason'])) - { - $alert = ""; - } - elseif ($postcount < 3) - { - $alert = ""; - } - else - { - $bantype = 0; //default warning bantype - $banexpiration = 0; - if (isset($_POST['temp_checkbox'])) - { - //tempban - $bantype = 1; - $banexpiration = time() + 86400; //add one day to current time - } - elseif (isset($_POST['perm_checkbox'])) - { - //perm ban - $bantype = 2; - } - - $id = getID($_POST['banuser']); - if (banUser($id, cleanInput($_POST['banreason']), $banexpiration, $bantype)) - { - logStaffAction("Banned User ".$id); - $alert = ""; - } - else - { - $alert = ""; - } - } -} - -$b = $pdo->prepare("SELECT * FROM user_bans WHERE valid = 1"); -$b->bindParam(":i", $id, PDO::PARAM_INT); -$b->execute(); - -$banneduser = ""; -if ($b->rowCount() > 0) -{ - foreach ($b as $bannedplayer) - { - $banneddate = date("m/d/Y", $bannedplayer['whenBanned']); - $bannedusername = getUsername($bannedplayer['uid']); - $bannedreason = cleanOutputNoFilter($bannedplayer['banReason']); - $bannedExpiration = (int)$bannedplayer['banExpiration']; - $bannedType = (int)$bannedplayer['banType']; - - if ($bannedType == 0) - { - $bannedExpiration = "Warning"; - } - elseif ($bannedType == 2) - { - $bannedExpiration = "Permanent"; - } - else - { - $bannedExpiration = date("m/d/Y", $bannedplayer['banExpiration']); - } - - $banneduser .= << - {$banneddate} - {$bannedusername} - {$bannedreason} - {$bannedExpiration} - -EOT; - } -} - -$body = << -{$alert} -
User Management
-
-
-
-
-
-
- - -
- -
-
-
-
-
-
- - -
-
- - -
-
- - -
- -
-
-
-
-
-
- - -
- -
- -
-
-
- -
-
-

- -

-
- - - - - - - - - - - {$banneduser} - -
DateUsernameReasonExpiration
-
-
-
-
- -EOT; - -pageHandler(); -$ph->pageTitle("User Manage"); -$ph->body = $body; -$ph->output(); -?> \ No newline at end of file diff --git a/html/profile/view.php b/html/profile/view.php index 75730b9..682ace5 100644 --- a/html/profile/view.php +++ b/html/profile/view.php @@ -23,7 +23,8 @@ if(isset($_GET['id'])) acceptFriendRequest($info->id); } - if (banned($id)) + $modmanager = new Alphaland\Moderation\UserModerationManager(); + if ($modmanager::IsBanned($id)) { redirect("/404"); }