Update dependencies and update a confusing ui element on the MCP user
management page ~ I will go through the rest, but you realise you don't have in instantiate a new instance of the class to call a static member? ~ I changed the wording of something on MCP/user-management/index.php, instead of it saying "Ban Reason"/"Ban", it will now say "Moderation Reason" and "Moderate User", because you can warn and suspend users. ~ Added a comment at the top of TwoFactor.php, read it
This commit is contained in:
parent
5a07050cbf
commit
f164eccc22
|
|
@ -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)) {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
Alphaland 2021
|
||||
*/
|
||||
|
||||
// Astro, please make public members start with capital letters
|
||||
|
||||
namespace Alphaland\Users {
|
||||
|
||||
use PDO;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -17,9 +17,9 @@ $body = <<<EOT
|
|||
<div class="col-sm">
|
||||
<div class="input-group">
|
||||
<input type="text" name="banuser" class="form-control" id="ban_username" placeholder="Username" autocomplete="off">
|
||||
<input type="text" name="banreason" class="form-control" id="ban_reason" placeholder="Ban Reason" autocomplete="off">
|
||||
<input type="text" name="banreason" class="form-control" id="ban_reason" placeholder="Moderation Reason" autocomplete="off">
|
||||
<div class="input-group-append">
|
||||
<button type="button" class="btn btn-danger" type="button" onclick="banUser()">Ban</button>
|
||||
<button type="button" class="btn btn-danger" type="button" onclick="banUser()">Moderate User</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -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)));
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
use Alphaland\Moderation\UserModerationManager;
|
||||
|
||||
$alert = "";
|
||||
|
||||
if(isset($_GET['id']))
|
||||
|
|
@ -23,8 +25,7 @@ if(isset($_GET['id']))
|
|||
acceptFriendRequest($info->id);
|
||||
}
|
||||
|
||||
$modmanager = new Alphaland\Moderation\UserModerationManager();
|
||||
if ($modmanager::IsBanned($id))
|
||||
if (UserModerationManager::IsBanned($id))
|
||||
{
|
||||
redirect("/404");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue