mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-08-28 22:27:15 +00:00
fix: session login check for admin
This commit is contained in:
+20
-5
@@ -164,21 +164,36 @@ class Session {
|
|||||||
|
|
||||||
private function checkLogin(){
|
private function checkLogin(){
|
||||||
global $database;
|
global $database;
|
||||||
if(isset($_SESSION['username']) && isset($_SESSION['sessid'])) {
|
|
||||||
|
$user = '';
|
||||||
|
$id = '';
|
||||||
|
$admin = false;
|
||||||
|
$inAdmin = (strpos($_SERVER['REQUEST_URI'], '/Admin') !== false);
|
||||||
|
|
||||||
|
if (!$inAdmin && isset($_SESSION['username'])) {
|
||||||
|
$user = $_SESSION['username'];
|
||||||
|
$id = (int) $_SESSION['id_user'];
|
||||||
|
} else if ($inAdmin && isset($_SESSION['admin_username'])) {
|
||||||
|
$user = $_SESSION['admin_username'];
|
||||||
|
$id = (int) $_SESSION['id'];
|
||||||
|
$admin = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($user && ($admin || isset($_SESSION['sessid']))) {
|
||||||
// check if this is not a support user, for who only messages and statistics are available
|
// check if this is not a support user, for who only messages and statistics are available
|
||||||
if ($_SESSION['id_user'] == 1) {
|
if ($user == 1) {
|
||||||
$req_file = basename($_SERVER['PHP_SELF']);
|
$req_file = basename($_SERVER['PHP_SELF']);
|
||||||
if (!in_array($req_file, ['nachrichten.php', 'logout.php', 'statistiken.php', 'rules.php', 'karte.php', 'karte2.php', 'spieler.php'])) {
|
if (!in_array($req_file, ['nachrichten.php', 'logout.php', 'statistiken.php', 'rules.php', 'karte.php', 'karte2.php', 'spieler.php'])) {
|
||||||
header('Location:nachrichten.php');
|
header('Location:nachrichten.php');
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Get and Populate Data
|
//Get and Populate Data
|
||||||
$this->PopulateVar();
|
$this->PopulateVar();
|
||||||
//update database
|
//update database
|
||||||
$database->addActiveUser($_SESSION['username'], $this->time);
|
$database->addActiveUser($user, $this->time);
|
||||||
$database->updateUserField($_SESSION['username'], "timestamp", $this->time, 0);
|
$database->updateUserField($user, "timestamp", $this->time, 0);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ martinambrus changes:
|
|||||||
49. Multihunter can no longer build beyond level 20
|
49. Multihunter can no longer build beyond level 20
|
||||||
50. installation final screen shows info to remove install folder and CHMOD folders on Linux
|
50. installation final screen shows info to remove install folder and CHMOD folders on Linux
|
||||||
51. fixed farms generation via Admin - these will be created all over map, not only where new players are currently being placed (players are positioned like this: middle section for first 20 days, then corners, then in between)
|
51. fixed farms generation via Admin - these will be created all over map, not only where new players are currently being placed (players are positioned like this: middle section for first 20 days, then corners, then in between)
|
||||||
|
52. fixed logged-in check (no longer redirects to login.php from admin when not logged-in to the game itself)
|
||||||
|
|
||||||
|
|
||||||
Shadowss changes:
|
Shadowss changes:
|
||||||
|
|||||||
Reference in New Issue
Block a user