Fix 2 issues on my part
~ Update User.php to fix the PDO accessor thingy ~ Update WebContextManager.php to fix another PDO thingy
This commit is contained in:
parent
c2d8d6878b
commit
3457dd5cb7
|
|
@ -41,7 +41,7 @@ namespace Alphaland\Users {
|
|||
public function UpdateLastSeen()
|
||||
{
|
||||
if (!UserModerationManager::IsBanned($this->ID)) {
|
||||
$query = $this->pdo->prepare("UPDATE `users` SET `lastseen` = UNIX_TIMESTAMP() WHERE `id` = :id");
|
||||
$query = $GLOBALS['pdo']->prepare("UPDATE `users` SET `lastseen` = UNIX_TIMESTAMP() WHERE `id` = :id");
|
||||
$query->bindParam(":id", $this->ID, PDO::PARAM_INT);
|
||||
$query->execute();
|
||||
}
|
||||
|
|
@ -52,7 +52,7 @@ namespace Alphaland\Users {
|
|||
if (!UserModerationManager::IsBanned($this->ID)) {
|
||||
if (($dailyTime + User::SecondsInDays) < time() || $dailyTime == 0) {
|
||||
// it has been a day or this is their first collection.
|
||||
$query = $this->pdo->prepare("UPDATE `users` SET `dailytime` = UNIX_TIMESTAMP(), `currency` = (`currency` + 20) WHERE `id` = :id");
|
||||
$query = $GLOBALS['pdo']->prepare("UPDATE `users` SET `dailytime` = UNIX_TIMESTAMP(), `currency` = (`currency` + 20) WHERE `id` = :id");
|
||||
$query->bindParam(":id", $this->ID, PDO::PARAM_INT);
|
||||
$query->execute();
|
||||
}
|
||||
|
|
@ -62,7 +62,7 @@ namespace Alphaland\Users {
|
|||
public function UpdateIpAddress()
|
||||
{
|
||||
$ip = WebContextManager::GetCurrentIPAddress();
|
||||
$query = $this->pdo->prepare("UPDATE `users` SET `ip` = :ip WHERE `id` = :id");
|
||||
$query = $GLOBALS['pdo']->prepare("UPDATE `users` SET `ip` = :ip WHERE `id` = :id");
|
||||
$query->bindParam(":ip", $ip, PDO::PARAM_STR);
|
||||
$query->bindParam(":id", $this->ID, PDO::PARAM_INT);
|
||||
$query->execute();
|
||||
|
|
@ -70,7 +70,7 @@ namespace Alphaland\Users {
|
|||
|
||||
public function ValidateToken(string $token): bool
|
||||
{
|
||||
$query = $this->pdo->prepare("SELECT * FROM `users` WHERE `id` = :id");
|
||||
$query = $GLOBALS['pdo']->prepare("SELECT * FROM `users` WHERE `id` = :id");
|
||||
$query->bindParam(":tk", $token, PDO::PARAM_STR);
|
||||
$query->execute();
|
||||
|
||||
|
|
@ -86,7 +86,7 @@ namespace Alphaland\Users {
|
|||
public function Logout()
|
||||
{
|
||||
if ($this->IsLoggedIn) {
|
||||
$query = $this->pdo->prepare("UPDATE `sessions` SET `valid` = 0 WHERE `id` = :id");
|
||||
$query = $GLOBALS['pdo']->prepare("UPDATE `sessions` SET `valid` = 0 WHERE `id` = :id");
|
||||
$query->bindParam(":id", $this->SessionCookieID, PDO::PARAM_INT);
|
||||
$query->execute();
|
||||
}
|
||||
|
|
@ -94,7 +94,7 @@ namespace Alphaland\Users {
|
|||
|
||||
private function ValidateTokenInternal($session): bool
|
||||
{
|
||||
$query = $this->pdo->prepare("SELECT * FROM users WHERE id = :id");
|
||||
$query = $GLOBALS['pdo']->prepare("SELECT * FROM users WHERE id = :id");
|
||||
$query->bindParam(":id", $session->uid, PDO::PARAM_INT);
|
||||
$query->execute();
|
||||
|
||||
|
|
@ -126,8 +126,6 @@ namespace Alphaland\Users {
|
|||
$this->Currency = $userInfo->currency;
|
||||
}
|
||||
|
||||
|
||||
private PDO $pdo = $GLOBALS['pdo'];
|
||||
private const $SecondsInDays = 86400;
|
||||
private const SecondsInDays = 86400;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ namespace Alphaland\Web {
|
|||
|
||||
public static function IsUnderMaintenance(): bool
|
||||
{
|
||||
$query = WebContextManager::$pdo->prepare("SELECT * FROM `websettings` WHERE `maintenance` = 1");
|
||||
$query = $GLOBALS['pdo']->prepare("SELECT * FROM `websettings` WHERE `maintenance` = 1");
|
||||
$query->execute();
|
||||
|
||||
if ($query->rowCount() > 0)
|
||||
|
|
@ -31,7 +31,7 @@ namespace Alphaland\Web {
|
|||
if (!WebContextManager::IsUnderMaintenance()) return true;
|
||||
|
||||
if (
|
||||
!WebContextManager::CurrentUser->IsAdministrator()
|
||||
!WebContextManager::$CurrentUser->IsAdministrator()
|
||||
&& !WebContextManager::IsCurrentIpAddressWhitelisted()
|
||||
) return false;
|
||||
|
||||
|
|
@ -46,8 +46,6 @@ namespace Alphaland\Web {
|
|||
return in_array($currentIp, $ipWhitelist);
|
||||
}
|
||||
|
||||
private static PDO $pdo = $GLOBALS['pdo'];
|
||||
|
||||
public static const $CurrentUser = new User();
|
||||
public static $CurrentUser = new User();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue