diff --git a/globals/Dependencies/Moderation/UserModerationManager.php b/globals/Dependencies/Moderation/UserModerationManager.php index ec0be9e..0699067 100644 --- a/globals/Dependencies/Moderation/UserModerationManager.php +++ b/globals/Dependencies/Moderation/UserModerationManager.php @@ -17,7 +17,7 @@ namespace Alphaland\Moderation { return false; } - public static function UnbanUser($uid) + public static function UnbanUser(int $uid) { if($GLOBALS['user']->isStaff()) { if (userExists($uid)) { @@ -33,7 +33,8 @@ namespace Alphaland\Moderation { return false; } - public static function BanUser($uid, $reason, $banexpiration, $bantype) + // Nikita: TODO: Convert the bantype to a an enum + public static function BanUser(int $uid, string $reason, int $banexpiration, int $bantype) { if($GLOBALS['user']->isStaff()) { if (userExists($uid)) { @@ -73,7 +74,7 @@ namespace Alphaland\Moderation { return false; } - public static function ReferralLimbBan($userid, $reason) + public static function ReferralLimbBan(int $userid, string $reason) { $query = $GLOBALS['pdo']->prepare("SELECT * FROM `users_invited` WHERE `whoInvited` = :userid"); $query->bindParam(":userid", $userid, PDO::PARAM_INT); @@ -89,7 +90,7 @@ namespace Alphaland\Moderation { return false; } - public static function PoisonBan($userid, $reason) + public static function PoisonBan(int $userid, string $reason) { $ip = userInfo($userid)->ip; if (UserModerationManager::BanUser($userid, $reason, 0, 2)) { diff --git a/globals/Dependencies/Users/TwoFactor.php b/globals/Dependencies/Users/TwoFactor.php index 408e11c..a7b9f86 100644 --- a/globals/Dependencies/Users/TwoFactor.php +++ b/globals/Dependencies/Users/TwoFactor.php @@ -4,6 +4,8 @@ Alphaland 2021 */ +// Astro, please make public members start with capital letters + namespace Alphaland\Users { use PDO; diff --git a/globals/functions.php b/globals/functions.php index d5a0ea5..c384d9c 100644 --- a/globals/functions.php +++ b/globals/functions.php @@ -8,6 +8,8 @@ //img tools (potentially high resource usage) (probably blocking) +use Alphaland\Moderation\UserModerationManager; + function imagecopymerge_alpha($dst_im, $src_im, $dst_x, $dst_y, $src_x, $src_y, $src_w, $src_h, $pct) { $cut = imagecreatetruecolor($src_w, $src_h); imagecopy($cut, $dst_im, 0, 0, $dst_x, $dst_y, $src_w, $src_h); @@ -762,8 +764,7 @@ function isSignupKeyUserGenerated($signupkey) $key->execute(); if ($key->rowCount() > 0) { - $banned = new Alphaland\Moderation\UserModerationManager(); - $banned = $banned::IsBanned($key->fetch(PDO::FETCH_OBJ)->userGen); + $banned = UserModerationManager::IsBanned($key->fetch(PDO::FETCH_OBJ)->userGen); if (!$banned) { return true; diff --git a/globals/userauth.php b/globals/userauth.php index bf1e815..d66907a 100644 --- a/globals/userauth.php +++ b/globals/userauth.php @@ -5,6 +5,8 @@ User class */ +use Alphaland\Moderation\UserModerationManager; + class user { public $id = -1; public $name = ""; @@ -71,8 +73,7 @@ class user { $activated = $activated::isUserActivated($this->id); //banned - $banned = new Alphaland\Moderation\UserModerationManager(); - $banned = $banned::IsBanned($this->id); + $banned = UserModerationManager::IsBanned($this->id); if (!$banned) { diff --git a/html/MCP/user-management/ban.php b/html/MCP/user-management/ban.php index 82d0612..3aac0a0 100644 --- a/html/MCP/user-management/ban.php +++ b/html/MCP/user-management/ban.php @@ -4,6 +4,8 @@ Alphaland 2021 */ +use Alphaland\Moderation\UserModerationManager; + if(!$user->isStaff()) { redirect("/"); } @@ -13,8 +15,6 @@ header('Content-Type: application/json'); header("Access-Control-Allow-Origin: https://www.alphaland.cc"); header("access-control-allow-credentials: true"); -$modmanager = new Alphaland\Moderation\UserModerationManager(); - $data = json_decode(file_get_contents('php://input')); $ban = false; @@ -29,19 +29,19 @@ if ($data) { $reason = cleanInput($reason); switch ($type) { case "warn": - $ban = $modmanager::BanUser($userid, $reason, $expiration, 0); //0 warning type + $ban = UserModerationManager::BanUser($userid, $reason, $expiration, 0); //0 warning type break; case "temp": - $ban = $modmanager::BanUser($userid, $reason, $expiration, 1); //1 temp type + $ban = UserModerationManager::BanUser($userid, $reason, $expiration, 1); //1 temp type break; case "perm": - $ban = $modmanager::BanUser($userid, $reason, $expiration, 2); //2 perm type + $ban = UserModerationManager::BanUser($userid, $reason, $expiration, 2); //2 perm type break; case "poison": - $ban = $modmanager::PoisonBan($userid, $reason); + $ban = UserModerationManager::PoisonBan($userid, $reason); break; case "limb": - $ban = $modmanager::ReferralLimbBan($userid, $reason); + $ban = UserModerationManager::ReferralLimbBan($userid, $reason); break; default: break; diff --git a/html/MCP/user-management/index.php b/html/MCP/user-management/index.php index 7332e8a..ced8585 100644 --- a/html/MCP/user-management/index.php +++ b/html/MCP/user-management/index.php @@ -17,9 +17,9 @@ $body = <<
- +
- +
diff --git a/html/MCP/user-management/unban.php b/html/MCP/user-management/unban.php index c22b6f5..00e8afa 100644 --- a/html/MCP/user-management/unban.php +++ b/html/MCP/user-management/unban.php @@ -4,6 +4,8 @@ Alphaland 2021 */ +use Alphaland\Moderation\UserModerationManager; + if(!$user->isStaff()) { redirect("/"); } @@ -13,7 +15,7 @@ header('Content-Type: application/json'); header("Access-Control-Allow-Origin: https://www.alphaland.cc"); header("access-control-allow-credentials: true"); -$modmanager = new Alphaland\Moderation\UserModerationManager(); +// if it's static you don't need to instantiate the class $data = json_decode(file_get_contents('php://input')); @@ -22,7 +24,7 @@ if ($data) { $username = $data->username; if($username) { - $unban = $modmanager::UnbanUser(getID($username)); + $unban = UserModerationManager::UnbanUser(getID($username)); } } die(json_encode(array("success" => $unban))); \ No newline at end of file diff --git a/html/profile/view.php b/html/profile/view.php index 682ace5..dd0f2fa 100644 --- a/html/profile/view.php +++ b/html/profile/view.php @@ -1,5 +1,7 @@ id); } - $modmanager = new Alphaland\Moderation\UserModerationManager(); - if ($modmanager::IsBanned($id)) + if (UserModerationManager::IsBanned($id)) { redirect("/404"); }