User dep impl update

This commit is contained in:
Astrologies 2021-12-19 00:20:44 -05:00
parent ece63ed1cf
commit a671625523
44 changed files with 76 additions and 76 deletions

View File

@ -12,7 +12,7 @@ namespace Alphaland\Users
use Alphaland\Web\WebContextManager;
use PDO;
class user
class User
{
public $id = -1;
public $name = "";
@ -24,27 +24,27 @@ namespace Alphaland\Users
private const SecondsInDays = 86400;
function __construct() {
public function __construct() {
if(isset($_COOKIE['token'])) {
$this->ValidateSession($_COOKIE['token']);
}
}
function isOwner() {
public function IsOwner() {
if ($this->rank == 3) {
return true;
}
return false;
}
function isAdmin() {
public function IsAdmin() {
if($this->rank == 2 || $this->rank == 3) {
return true;
}
return false;
}
function isStaff() {
public function IsStaff() {
if($this->rank == 1 || $this->rank == 2 || $this->rank == 3) {
return true;
}
@ -119,7 +119,7 @@ namespace Alphaland\Users
return false;
}
function logout()
public function Logout()
{
if($this->logged_in) {
$logout = $GLOBALS['pdo']->prepare("DELETE FROM sessions WHERE id = :id");

View File

@ -21,7 +21,7 @@ namespace Alphaland\Web {
public static function CanBypassMaintenance()
{
return $GLOBALS['user']->isStaff() || WebContextManager::IsCurrentIpAddressWhitelisted();
return $GLOBALS['user']->IsStaff() || WebContextManager::IsCurrentIpAddressWhitelisted();
}
public static function IsUnderMaintenance(bool $status = false)

View File

@ -978,7 +978,7 @@ function userGroupsCount()
function createGroup($name, $description, $approval, $base64emblem)
{
if (userGroupsCount() == 6 && !$GLOBALS['user']->isAdmin())
if (userGroupsCount() == 6 && !$GLOBALS['user']->IsAdmin())
{
return "Limited to 6 groups per player";
}
@ -1728,7 +1728,7 @@ function isGroupOwner($groupid)
$owner->bindParam(":gid", $groupid, PDO::PARAM_INT);
$owner->bindParam(":cid", $localplayer, PDO::PARAM_INT);
$owner->execute();
if ($owner->rowCount() > 0 || $GLOBALS['user']->isAdmin())
if ($owner->rowCount() > 0 || $GLOBALS['user']->IsAdmin())
{
return true;
}
@ -1815,7 +1815,7 @@ function wallViewPermission($groupid)
{
$role = groupRoleInfo($groupid, groupMemberInfo($groupid, $localplayer)->rank);
if ($role->AccessGroupWall == 1 || $GLOBALS['user']->isAdmin())
if ($role->AccessGroupWall == 1 || $GLOBALS['user']->IsAdmin())
{
return true;
}
@ -1831,7 +1831,7 @@ function wallPostPermission($groupid)
{
$role = groupRoleInfo($groupid, groupMemberInfo($groupid, $localplayer)->rank);
if ($role->PostGroupWall == 1 || $GLOBALS['user']->isAdmin())
if ($role->PostGroupWall == 1 || $GLOBALS['user']->IsAdmin())
{
return true;
}
@ -1847,7 +1847,7 @@ function wallDeletePermission($groupid)
{
$role = groupRoleInfo($groupid, groupMemberInfo($groupid, $localplayer)->rank);
if ($role->DeleteGroupWallPosts == 1 || $GLOBALS['user']->isAdmin())
if ($role->DeleteGroupWallPosts == 1 || $GLOBALS['user']->IsAdmin())
{
return true;
}
@ -1863,7 +1863,7 @@ function postShoutPermission($groupid)
{
$role = groupRoleInfo($groupid, groupMemberInfo($groupid, $localplayer)->rank);
if ($role->PostGroupShout == 1 || $GLOBALS['user']->isAdmin())
if ($role->PostGroupShout == 1 || $GLOBALS['user']->IsAdmin())
{
return true;
}
@ -1879,7 +1879,7 @@ function manageLowerRankPermission($groupid)
{
$role = groupRoleInfo($groupid, groupMemberInfo($groupid, $localplayer)->rank);
if ($role->ManageLowerRanks == 1 || $GLOBALS['user']->isAdmin())
if ($role->ManageLowerRanks == 1 || $GLOBALS['user']->IsAdmin())
{
return true;
}
@ -1895,7 +1895,7 @@ function kickLowerRankPermission($groupid)
{
$role = groupRoleInfo($groupid, groupMemberInfo($groupid, $localplayer)->rank);
if ($role->KickLowerRanks == 1 || $GLOBALS['user']->isAdmin())
if ($role->KickLowerRanks == 1 || $GLOBALS['user']->IsAdmin())
{
return true;
}
@ -1911,7 +1911,7 @@ function acceptJoinRequestPermission($groupid)
{
$role = groupRoleInfo($groupid, groupMemberInfo($groupid, $localplayer)->rank);
if ($role->AcceptJoinRequests == 1 || $GLOBALS['user']->isAdmin())
if ($role->AcceptJoinRequests == 1 || $GLOBALS['user']->IsAdmin())
{
return true;
}
@ -1927,7 +1927,7 @@ function viewAuditLogPermission($groupid)
{
$role = groupRoleInfo($groupid, groupMemberInfo($groupid, $localplayer)->rank);
if ($role->ViewAuditLog == 1 || $GLOBALS['user']->isAdmin())
if ($role->ViewAuditLog == 1 || $GLOBALS['user']->IsAdmin())
{
return true;
}
@ -1939,9 +1939,9 @@ function configPermission($groupid)
{
$localplayer = $GLOBALS['user']->id;
if (isGroupMember($localplayer, $groupid) || $GLOBALS['user']->isAdmin())
if (isGroupMember($localplayer, $groupid) || $GLOBALS['user']->IsAdmin())
{
if (manageLowerRankPermission($groupid) || kickLowerRankPermission($groupid) || acceptJoinRequestPermission($groupid) || viewAuditLogPermission($groupid) || $GLOBALS['user']->isAdmin())
if (manageLowerRankPermission($groupid) || kickLowerRankPermission($groupid) || acceptJoinRequestPermission($groupid) || viewAuditLogPermission($groupid) || $GLOBALS['user']->IsAdmin())
{
return true;
}
@ -1961,7 +1961,7 @@ function userAccessToGame($placeid, $userid)
$whitelist->bindParam(":pid", $placeid, PDO::PARAM_INT);
$whitelist->bindParam(":uid", $userid, PDO::PARAM_INT);
$whitelist->execute();
if ($whitelist->rowCount() > 0 || $userid == getAssetInfo($placeid)->CreatorId || $GLOBALS['user']->isAdmin())
if ($whitelist->rowCount() > 0 || $userid == getAssetInfo($placeid)->CreatorId || $GLOBALS['user']->IsAdmin())
{
return true;
}
@ -2842,7 +2842,7 @@ function userPlaying($userid)
function isUserInventoryPrivate($userid)
{
if(userInfo($userid)->privateInventory && !$GLOBALS['user']->isAdmin())
if(userInfo($userid)->privateInventory && !$GLOBALS['user']->IsAdmin())
{
return true;
}
@ -4254,14 +4254,14 @@ function isOwner($id, $userid=NULL)
//handle game assets
if ($assettypeid == 9) {
if ($creatorid == $userid || $GLOBALS['user']->isOwner()) {
if ($creatorid == $userid || $GLOBALS['user']->IsOwner()) {
return true;
}
return false;
}
//others
if ($creatorid == $userid || $GLOBALS['user']->isStaff()) {
if ($creatorid == $userid || $GLOBALS['user']->IsStaff()) {
return true;
}
}
@ -5233,7 +5233,7 @@ function getNav()
$modbutton = "";
$pendingassetscount = 0;
if ($GLOBALS['user']->isStaff())
if ($GLOBALS['user']->IsStaff())
{
$pendingassetscount = fetchPendingAssets()->rowCount();
@ -5315,7 +5315,7 @@ function getNav()
<a class="nav-link" href="/create/">Create</a>
</li>
'.$modbutton.'
'.(($user->isAdmin())? '
'.(($user->IsAdmin())? '
<li class="nav-item">
<a class="nav-link" href="https://crackpot.alphaland.cc">Admin</a>
</li>':'').'

View File

@ -14,7 +14,7 @@ if(isset($_POST['submit_2fa'])) {
}
if(isset($_POST['logout'])) {
$user->logout();
$user->Logout();
WebContextManager::Redirect("/");
}

View File

@ -14,7 +14,7 @@ header("Access-Control-Allow-Origin: https://www.alphaland.cc");
header("access-control-allow-credentials: true");
if(!$user->isStaff())
if(!$user->IsStaff())
{
WebContextManager::Redirect("/");
}

View File

@ -2,7 +2,7 @@
use Alphaland\Web\WebContextManager;
if(!$user->isStaff())
if(!$user->IsStaff())
{
WebContextManager::Redirect("/");
}

View File

@ -2,7 +2,7 @@
use Alphaland\Web\WebContextManager;
if(!$user->isStaff())
if(!$user->IsStaff())
{
WebContextManager::Redirect("/");
}

View File

@ -12,7 +12,7 @@ header("Access-Control-Allow-Origin: https://www.alphaland.cc");
header("access-control-allow-credentials: true");
header('Content-Type: application/json');
if(!$user->isStaff())
if(!$user->IsStaff())
{
WebContextManager::Redirect("/");
}

View File

@ -2,7 +2,7 @@
use Alphaland\Web\WebContextManager;
if(!($user->isStaff()))
if(!($user->IsStaff()))
{
WebContextManager::Redirect("/");
}

View File

@ -2,7 +2,7 @@
use Alphaland\Web\WebContextManager;
if(!$user->isStaff())
if(!$user->IsStaff())
{
WebContextManager::Redirect("/");
}

View File

@ -2,7 +2,7 @@
use Alphaland\Web\WebContextManager;
if(!$user->isStaff())
if(!$user->IsStaff())
{
WebContextManager::Redirect("/");
}

View File

@ -14,7 +14,7 @@ header("Access-Control-Allow-Origin: https://www.alphaland.cc");
header("access-control-allow-credentials: true");
if(!$user->isStaff())
if(!$user->IsStaff())
{
WebContextManager::Redirect("/");
}

View File

@ -6,7 +6,7 @@ Alphaland 2021
use Alphaland\Web\WebContextManager;
if(!$user->isStaff())
if(!$user->IsStaff())
{
WebContextManager::Redirect("/");
}

View File

@ -13,7 +13,7 @@ header('Content-Type: application/json');
$id = (int)$_GET['id'];
if(!$user->isStaff() || !$id) {
if(!$user->IsStaff() || !$id) {
WebContextManager::Redirect("/");
}

View File

@ -13,7 +13,7 @@ header('Content-Type: application/json');
$id = (int)$_GET['id'];
if(!$user->isStaff() || !$id) {
if(!$user->IsStaff() || !$id) {
WebContextManager::Redirect("/");
}

View File

@ -10,7 +10,7 @@ header("Access-Control-Allow-Origin: https://www.alphaland.cc");
header("access-control-allow-credentials: true");
header('Content-Type: application/json');
if(!$user->isStaff()) {
if(!$user->IsStaff()) {
WebContextManager::Redirect("/");
}

View File

@ -7,7 +7,7 @@
use Alphaland\Web\WebContextManager;
if(!$user->isStaff()) {
if(!$user->IsStaff()) {
WebContextManager::Redirect("/");
}

View File

@ -7,7 +7,7 @@
use Alphaland\Web\WebContextManager;
if(!$user->isStaff()) {
if(!$user->IsStaff()) {
WebContextManager::Redirect("/");
}

View File

@ -7,7 +7,7 @@ Alphaland 2021
use Alphaland\Moderation\UserModerationManager;
use Alphaland\Web\WebContextManager;
if(!$user->isStaff()) {
if(!$user->IsStaff()) {
WebContextManager::Redirect("/");
}

View File

@ -10,7 +10,7 @@ header("Access-Control-Allow-Origin: https://www.alphaland.cc");
header("access-control-allow-credentials: true");
header('Content-Type: application/json');
if(!$user->isStaff()) {
if(!$user->IsStaff()) {
WebContextManager::Redirect("/");
}

View File

@ -3,7 +3,7 @@
use Alphaland\Web\WebContextManager;
$body = '';
if(!($user->isStaff())) {
if(!($user->IsStaff())) {
WebContextManager::Redirect("/");
}

View File

@ -7,7 +7,7 @@ Alphaland 2021
use Alphaland\Moderation\UserModerationManager;
use Alphaland\Web\WebContextManager;
if(!$user->isStaff()) {
if(!$user->IsStaff()) {
WebContextManager::Redirect("/");
}

View File

@ -52,7 +52,7 @@ if ($id)
{
if(isLoggedIn())
{
if ($iteminfo->IsPublicDomain == true or $iteminfo->CreatorId == $user->id or $user->isOwner())
if ($iteminfo->IsPublicDomain == true or $iteminfo->CreatorId == $user->id or $user->IsOwner())
{
ReturnAsset($iteminfo->Hash, $iteminfo->AssetTypeId);
}

View File

@ -17,7 +17,7 @@ if (UserModerationManager::IsBanned($user->id))
if(isset($_POST['logout']))
{
$user->logout();
$user->Logout();
WebContextManager::Redirect("/");
}

View File

@ -105,7 +105,7 @@ if(isset($_GET['id']))
}
else
{
if ($user->isStaff())
if ($user->IsStaff())
{
UserModerationManager::LogAction("Configure Item ".$id);
}
@ -133,7 +133,7 @@ if(isset($_GET['id']))
if (isset($_POST['onsale_checkbox']))
{
if ($user->isStaff())
if ($user->IsStaff())
{
UserModerationManager::LogAction("Configure Item Onsale ".$id);
}
@ -164,7 +164,7 @@ if(isset($_GET['id']))
}
elseif (isset($_POST['RegenItem'])) //for admin regen stuff
{
if ($user->isStaff())
if ($user->IsStaff())
{
$script = "";
$scripttype = "";
@ -298,7 +298,7 @@ if(isset($_GET['id']))
}
elseif (isset($_POST['ModerateItem'])) //for mods
{
if ($user->isStaff())
if ($user->IsStaff())
{
$moderation = moderateAsset($id);
@ -333,7 +333,7 @@ else
$moderatebutton = '';
$regenbutton = '';
if ($user->isStaff())
if ($user->IsStaff())
{
$regenbutton = '<button type="Submit" name="RegenItem" class="btn btn-danger w-100 mb-2">Regen '.$itemtype.'</button>';
$moderatebutton = '<button type="Submit" name="ModerateItem" class="btn btn-danger w-100 mb-2">Moderate '.$itemtype.'</button>';

View File

@ -121,7 +121,7 @@ if(isset($_GET['id']))
//only allow shirts, pants and t shirts to be modified by the end user (admins can regardless)
$configbutton_html = "";
if ($itemtypeint == 2 or $itemtypeint == 11 or $itemtypeint == 12 or $user->isAdmin())
if ($itemtypeint == 2 or $itemtypeint == 11 or $itemtypeint == 12 or $user->IsAdmin())
{
if (isOwner($id) && !isAssetModerated($id)) //owner of the item or admin
{

View File

@ -238,7 +238,7 @@ function newPlace()
$description = $_POST['place_desc'];
//how many games the user has
if (getAllGames($GLOBALS['user']->id)->rowCount() >= 6 && !$GLOBALS['user']->isAdmin())
if (getAllGames($GLOBALS['user']->id)->rowCount() >= 6 && !$GLOBALS['user']->IsAdmin())
{
return "Games limit reached";
}
@ -275,7 +275,7 @@ function newPBSPlace($placetype)
$description = $_POST['place_desc'];
//how many games the user has
if (getAllGames($GLOBALS['user']->id)->rowCount() > 6 && !$GLOBALS['user']->isAdmin())
if (getAllGames($GLOBALS['user']->id)->rowCount() > 6 && !$GLOBALS['user']->IsAdmin())
{
return "Games limit reached";
}

View File

@ -99,7 +99,7 @@ if(isset($_GET['id']))
if($q->rowCount() > 0)
{
if (isOwner($id) or $user->isAdmin()) //if the user is the owner of the game, or staff
if (isOwner($id) or $user->IsAdmin()) //if the user is the owner of the game, or staff
{
//item parameters
$gameinfo = getAssetInfo($id);

View File

@ -2,5 +2,5 @@
use Alphaland\Web\WebContextManager;
$user->logout();
$user->Logout();
WebContextManager::Redirect("/");

View File

@ -4,7 +4,7 @@ use Alphaland\Web\WebContextManager;
WebContextManager::ForceHttpsCloudflare();
if(!($user->isOwner())) {
if(!($user->IsOwner())) {
die('bababooey');
}

View File

@ -5,8 +5,8 @@ use Alphaland\Web\WebContextManager;
WebContextManager::ForceHttpsCloudflare();
//permissions
if(!($user->isOwner())) {
if ($user->isAdmin()) {
if(!($user->IsOwner())) {
if ($user->IsAdmin()) {
WebContextManager::Redirect("/");
}
die('bababooey');

View File

@ -4,8 +4,8 @@ use Alphaland\Web\WebContextManager;
WebContextManager::ForceHttpsCloudflare();
if(!($user->isOwner())) {
if ($user->isAdmin()) {
if(!($user->IsOwner())) {
if ($user->IsAdmin()) {
WebContextManager::Redirect("/");
}
die('bababooey');

View File

@ -4,8 +4,8 @@ use Alphaland\Web\WebContextManager;
WebContextManager::ForceHttpsCloudflare();
if(!($user->isOwner())) {
if ($user->isAdmin()) {
if(!($user->IsOwner())) {
if ($user->IsAdmin()) {
WebContextManager::Redirect("/");
}
die('bababooey');

View File

@ -5,7 +5,7 @@ use Alphaland\Web\WebContextManager;
WebContextManager::ForceHttpsCloudflare();
if(!($user->isAdmin())) {
if(!($user->IsAdmin())) {
die('bababooey');
}

View File

@ -4,7 +4,7 @@ use Alphaland\Web\WebContextManager;
WebContextManager::ForceHttpsCloudflare();
if(!($user->isAdmin())) {
if(!($user->IsAdmin())) {
die('bababooey');
}

View File

@ -7,7 +7,7 @@ WebContextManager::ForceHttpsCloudflare();
header("Access-Control-Allow-Origin: https://crackpot.alphaland.cc");
header("access-control-allow-credentials: true");
if(!($user->isAdmin())) {
if(!($user->IsAdmin())) {
die('bababooey');
}

View File

@ -4,8 +4,8 @@ use Alphaland\Web\WebContextManager;
WebContextManager::ForceHttpsCloudflare();
if(!($user->isOwner())) {
if ($user->isAdmin()) {
if(!($user->IsOwner())) {
if ($user->IsAdmin()) {
WebContextManager::Redirect("/");
}
die('bababooey');

View File

@ -4,7 +4,7 @@ use Alphaland\Web\WebContextManager;
WebContextManager::ForceHttpsCloudflare();
if(!($user->isAdmin())) {
if(!($user->IsAdmin())) {
die('bababooey');
}

View File

@ -4,7 +4,7 @@ use Alphaland\Web\WebContextManager;
WebContextManager::ForceHttpsCloudflare();
if(!($user->isAdmin())) {
if(!($user->IsAdmin())) {
die('bababooey');
}

View File

@ -5,7 +5,7 @@ use Alphaland\Web\WebContextManager;
WebContextManager::ForceHttpsCloudflare();
if(!($user->isAdmin())) {
if(!($user->IsAdmin())) {
die('bababooey');
}

View File

@ -4,7 +4,7 @@ use Alphaland\Web\WebContextManager;
WebContextManager::ForceHttpsCloudflare();
if(!($user->isAdmin())) {
if(!($user->IsAdmin())) {
die('bababooey');
}

View File

@ -4,8 +4,8 @@ use Alphaland\Web\WebContextManager;
WebContextManager::ForceHttpsCloudflare();
if(!($user->isOwner())) {
if ($user->isAdmin()) {
if(!($user->IsOwner())) {
if ($user->IsAdmin()) {
WebContextManager::Redirect("/");
}
die('bababooey');

View File

@ -5,7 +5,7 @@ use Alphaland\Web\WebContextManager;
WebContextManager::ForceHttpsCloudflare();
if(!($user->isAdmin())) {
if(!($user->IsAdmin())) {
die('bababooey');
}

View File

@ -31,7 +31,7 @@ $userInfo = array(
"CreatorId" => $assetinfo->CreatorId,
"isPersonalServer" => boolval($assetinfo->isPersonalServer),
"playPermission" => userAccessToGame($assetinfo->id, $user->id),
"canManage" => boolval($assetinfo->CreatorId == $user->id || $user->isAdmin()),
"canManage" => boolval($assetinfo->CreatorId == $user->id || $user->IsAdmin()),
"CommentsEnabled" => boolval($assetinfo->IsCommentsEnabled),
"PersonalServerWhitelist" => boolval($assetinfo->isGameWhitelisted),
"MaxPlayers" => $assetinfo->MaxPlayers,