mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-08-19 09:40:59 +00:00
refactor: Session.php only included once, login procedure optimization
#313
This commit is contained in:
@@ -29,7 +29,7 @@ for ($i = 0; $i < 5; $i++) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
include($autoprefix."GameEngine/Session.php");
|
include_once($autoprefix."GameEngine/Session.php");
|
||||||
|
|
||||||
class Account {
|
class Account {
|
||||||
|
|
||||||
|
|||||||
+11
-5
@@ -1191,13 +1191,19 @@ class MYSQLi_DB implements IDbConnection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function updateActiveUser($username, $time) {
|
function updateActiveUser($username, $time) {
|
||||||
|
static $updated = false;
|
||||||
|
|
||||||
|
if ($updated) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
list($username, $time) = $this->escape_input($username, $time);
|
list($username, $time) = $this->escape_input($username, $time);
|
||||||
|
|
||||||
$q = "REPLACE into " . TB_PREFIX . "active values ('$username',$time)";
|
$res1 = $this->addActiveUser($username, $time);
|
||||||
$q2 = "UPDATE " . TB_PREFIX . "users set timestamp = $time where username = '$username'";
|
$q = "UPDATE " . TB_PREFIX . "users set timestamp = $time where username = '$username'";
|
||||||
$exec1 = mysqli_query($this->dblink,$q);
|
$res2 = mysqli_query($this->dblink,$q);
|
||||||
$exec2 = mysqli_query($this->dblink,$q2);
|
if($res1 && $res2) {
|
||||||
if($exec1 && $exec2) {
|
$updated = true;
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ class Session {
|
|||||||
}
|
}
|
||||||
$this->PopulateVar();
|
$this->PopulateVar();
|
||||||
|
|
||||||
$database->addActiveUser($user_sanitized, $this->time);
|
$database->updateActiveUser($user_sanitized, $this->time);
|
||||||
$database->updateUserField($user_sanitized, "sessid", $_SESSION['sessid'], 0);
|
$database->updateUserField($user_sanitized, "sessid", $_SESSION['sessid'], 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,7 +191,7 @@ class Session {
|
|||||||
//Get and Populate Data
|
//Get and Populate Data
|
||||||
$this->PopulateVar();
|
$this->PopulateVar();
|
||||||
//update database
|
//update database
|
||||||
$database->addActiveUser($user, $this->time);
|
$database->updateActiveUser($user, $this->time);
|
||||||
$database->updateUserField($user, "timestamp", $this->time, 0);
|
$database->updateUserField($user, "timestamp", $this->time, 0);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -9,11 +9,11 @@
|
|||||||
## ##
|
## ##
|
||||||
#################################################################################
|
#################################################################################
|
||||||
|
|
||||||
include("Session.php");
|
include_once("Session.php");
|
||||||
include("Building.php");
|
include_once("Building.php");
|
||||||
include("Market.php");
|
include_once("Market.php");
|
||||||
include_once("GameEngine/Units.php");
|
include_once("GameEngine/Units.php");
|
||||||
include("Technology.php");
|
include_once("Technology.php");
|
||||||
|
|
||||||
class Village {
|
class Village {
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
include("GameEngine/Session.php");
|
include_once("GameEngine/Session.php");
|
||||||
header("Content-Type: application/json;");
|
header("Content-Type: application/json;");
|
||||||
$currentcoor = $database->getCoor($z);
|
$currentcoor = $database->getCoor($z);
|
||||||
$y = $currentcoor['y'];
|
$y = $currentcoor['y'];
|
||||||
|
|||||||
Reference in New Issue
Block a user