Permalink
Browse files

set server_selected cookie

  • Loading branch information...
AhmedElywa committed Nov 18, 2018
1 parent 6f6bf44 commit b538f61dbf19ff8bc4cf1188b4576f1b1969faa2
@@ -0,0 +1,2 @@
**/cache/**
**/system/log/**
@@ -28,21 +28,20 @@
$servers_list[$i] = $value['id'];
$i++;
}
if (!isset($_SESSION['server_selected'])) {
$_SESSION['server_selected'] = current($servers_list);
if (!isset($_COOKIE['server_selected'])) {
setcookie('server_selected', 1, time()+60*60*24*365, '/');
}
// Load server configurations
$gameConfig = $m->Serverdata($_SESSION['server_selected']);
$gameConfig = $m->Serverdata($_COOKIE['server_selected']);
$gameConfig['settings'] = json_decode($gameConfig['settings'], true);
$gameConfig['plus'] = json_decode($gameConfig['plus'], true);
$gameConfig['troop'] = json_decode($gameConfig['troop'], true);
$gameConfig['page'] = json_decode($m->GetSettings("page"), true);
$gameConfig['system'] = json_decode($m->GetSettings("system"), true);
require SERVER_DIR . '/db.php';
$user = explode('_', $username);
$loader->init_db($user[0] . $serv);
$loader->init_db('xtatar_' . $_SESSION['server_selected']); // connect database
$user = explode('_', $database);
$db = $user[0] .'_'. $_COOKIE['server_selected'];
$loader->init_db($db); // connect database
#--------------------------------
# Auto Load the Controller
@@ -25,7 +25,7 @@ public function index()
// change server + admin change pass email
if (is_post('change_server')) {
$new_server_name = post('change_server');
$_SESSION['server_selected'] = $new_server_name;
setcookie('server_selected', $new_server_name, time()+60*60*24*365, '/');
$this->is_redirect = true;
redirect('index.php');
} elseif (get('page') == 'logout') {
@@ -28,7 +28,6 @@ public function index()
$password = post("password");
$login = $this->Auth->login($email, $password);
if ($login) {
$this->is_redirect = true;
redirect('index.php');
@@ -5,7 +5,7 @@
global $settings;
$settings['timezone'] = "America/New_York"; // server timezone
$settings['url'] = str_replace( basename( $_SERVER['PHP_SELF'] ), '', 'https://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['SCRIPT_NAME']) .'/' );
$settings['url'] = str_replace( basename( $_SERVER['PHP_SELF'] ), '', 'http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['SCRIPT_NAME']) .'/' );
define( "URL", $settings['url'] ); // base url
########## GAME DEFINES #############
@@ -21,13 +21,13 @@ public function __construct()
$this->viewData['servers_list'] = $servers_list;
// Check server connection
if (db::is_connected() == 0) {
/* if (db::is_connected()) {
$this->viewData['flash_message'] = array(
'error',
'خطأ فى الاتصال بقاعدة البيانات',
1,
);
}
} */
$this->viewData['sessioninfo'] = $this->Auth->sessioninfo($_COOKIE['auth_session']);
// Check user permissions
@@ -447,7 +447,7 @@ public function checksession($hash)
* @param int $length
* @return string $key
*/
private function __randomkey($length = 10)
private function randomkey($length = 10)
{
$chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890";
$key = "";
@@ -843,7 +843,7 @@ public function LogActivity($username, $action, $additionalinfo = "none")
* @return string $password
*/
private function __hashpass($password)
private function hashpass($password)
{
$password = hash("SHA512", base64_encode(str_rot13(hash("SHA512", str_rot13($this->hash_salt_1 . $password . $this->hash_salt_2)))));
return $password;
Oops, something went wrong.

0 comments on commit b538f61

Please sign in to comment.