From 5d3a0c4ab78230b321833e8871238afb2c418c55 Mon Sep 17 00:00:00 2001 From: daniel Date: Tue, 6 Jun 2017 13:57:10 +0200 Subject: [PATCH] fixed errors in login page --- pandora_console/include/config_process.php | 45 ++++++++---- pandora_console/include/functions_db.php | 10 +++ pandora_console/index.php | 81 +++++++++++++++++++--- 3 files changed, 113 insertions(+), 23 deletions(-) diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 69b4bd75d9..abda262e03 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -37,9 +37,21 @@ else { //home dir bad defined if (!is_dir($config['homedir'])) { + $url = explode('/', $_SERVER['REQUEST_URI']); + $flag_url =0; + foreach ($url as $key => $value) { + if (strpos($value, 'index.php?') !== false || $flag_url) { + $flag_url=1; + unset($url[$key]); + } + } + $config["homeurl"] = rtrim(join("/", $url),"/"); + $config["homeurl_static"] = $config["homeurl"]; + $ownDir = dirname(__FILE__) . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR; $config['homedir'] = $ownDir; $config["error"] = "homedir_bad_defined"; + return; } @@ -114,23 +126,28 @@ require_once ($ownDir . 'functions.php'); // If not we will get ugly warnings. Set Europe/Madrid by default // Later will be replaced by the good one. if (!defined('METACONSOLE')) { - if(!isset($config["homeurl"])){ - $url = explode('/', $_SERVER['REQUEST_URI']); - $config["homeurl"] = $url[1]; - $config["homeurl_static"] = $url[1]; - $config["error"] = "homeurl_bad_defined"; - return; - } - else{ - $url = explode('/', $_SERVER['REQUEST_URI']); - if($config["homeurl"] != '/'.$url[1]){ - $config["homeurl"] = '/'.$url[1]; - $config["homeurl_static"] = '/'.$url[1]; - $config["error"] = "homeurl_bad_defined"; - return; + $url = explode('/', $_SERVER['REQUEST_URI']); + $flag_url =0; + foreach ($url as $key => $value) { + if (strpos($value, 'index.php?') !== false || $flag_url) { + $flag_url=1; + unset($url[$key]); } } + $config["homeurl"] = rtrim(join("/", $url),"/"); } +else{ + $url = explode('/', $_SERVER['REQUEST_URI']); + $flag_url =0; + foreach ($url as $key => $value) { + if (strpos($value, 'enterprise') !== false || $flag_url) { + $flag_url=1; + unset($url[$key]); + } + } + $config["homeurl"] = rtrim(join("/", $url),"/"); +} + if (!isset($config["homeurl_static"])) { $config["homeurl_static"] = $config["homeurl"]; } diff --git a/pandora_console/include/functions_db.php b/pandora_console/include/functions_db.php index f2c1627304..cb505f6563 100644 --- a/pandora_console/include/functions_db.php +++ b/pandora_console/include/functions_db.php @@ -64,7 +64,17 @@ function db_connect($host = null, $db = null, $user = null, $pass = null, $port // Something went wrong if ($return === false) { if ($critical) { + $login_screen = 'error_authconfig'; + $url = explode('/', $_SERVER['REQUEST_URI']); + $flag_url =0; + foreach ($url as $key => $value) { + if (strpos($value, 'index.php?') !== false || $flag_url) { + $flag_url=1; + unset($url[$key]); + } + } + $config["homeurl"] = rtrim(join("/", $url),"/"); require($config['homedir'] . '/general/error_screen.php'); exit; diff --git a/pandora_console/index.php b/pandora_console/index.php index 79aaca3ffb..51387e4a36 100755 --- a/pandora_console/index.php +++ b/pandora_console/index.php @@ -28,13 +28,31 @@ if ($develop_bypass != 1) { if (! file_exists ("include/config.php")) { if (! file_exists ("install.php")) { $login_screen = 'error_noconfig'; - $ownDir = dirname(__FILE__) . DIRECTORY_SEPARATOR; + $ownDir = dirname(__FILE__) . DIRECTORY_SEPARATOR; $config['homedir'] = $ownDir; - $config['homeurl'] = $_SERVER['REQUEST_URI']; - $config['homeurl_static'] = $_SERVER['REQUEST_URI']; - - - + if (!defined('METACONSOLE')) { + $url = explode('/', $_SERVER['REQUEST_URI']); + $flag_url =0; + foreach ($url as $key => $value) { + if (strpos($value, 'index.php?') !== false || $flag_url) { + $flag_url=1; + unset($url[$key]); + } + } + $config["homeurl"] = rtrim(join("/", $url),"/"); + } + else{ + $url = explode('/', $_SERVER['REQUEST_URI']); + $flag_url =0; + foreach ($url as $key => $value) { + if (strpos($value, 'enterprise') !== false || $flag_url) { + $flag_url=1; + unset($url[$key]); + } + } + $config["homeurl"] = rtrim(join("/", $url),"/"); + } + $config["homeurl_static"] = $config["homeurl"]; require('general/error_screen.php'); exit; } @@ -58,6 +76,31 @@ if ($develop_bypass != 1) { // Check for installer presence if (file_exists ("install.php")) { + $ownDir = dirname(__FILE__) . DIRECTORY_SEPARATOR; + $config['homedir'] = $ownDir; + if (!defined('METACONSOLE')) { + $url = explode('/', $_SERVER['REQUEST_URI']); + $flag_url =0; + foreach ($url as $key => $value) { + if (strpos($value, 'index.php?') !== false || $flag_url) { + $flag_url=1; + unset($url[$key]); + } + } + $config["homeurl"] = rtrim(join("/", $url),"/"); + } + else{ + $url = explode('/', $_SERVER['REQUEST_URI']); + $flag_url =0; + foreach ($url as $key => $value) { + if (strpos($value, 'enterprise') !== false || $flag_url) { + $flag_url=1; + unset($url[$key]); + } + } + $config["homeurl"] = rtrim(join("/", $url),"/"); + } + $config["homeurl_static"] = $config["homeurl"]; $login_screen = 'error_install'; require('general/error_screen.php'); exit; @@ -68,10 +111,30 @@ if ($develop_bypass != 1) { (substr (sprintf ('%o', fileperms('include/config.php')), -4) != "0660") && (substr (sprintf ('%o', fileperms('include/config.php')), -4) != "0640")) { $ownDir = dirname(__FILE__) . DIRECTORY_SEPARATOR; - $url = explode('/', $_SERVER['REQUEST_URI']); $config['homedir'] = $ownDir; - $config['homeurl'] = "/" . $url[1]; - $config['homeurl_static'] = "/" . $url[1]; + if (!defined('METACONSOLE')) { + $url = explode('/', $_SERVER['REQUEST_URI']); + $flag_url =0; + foreach ($url as $key => $value) { + if (strpos($value, 'index.php?') !== false || $flag_url) { + $flag_url=1; + unset($url[$key]); + } + } + $config["homeurl"] = rtrim(join("/", $url),"/"); + } + else{ + $url = explode('/', $_SERVER['REQUEST_URI']); + $flag_url =0; + foreach ($url as $key => $value) { + if (strpos($value, 'enterprise') !== false || $flag_url) { + $flag_url=1; + unset($url[$key]); + } + } + $config["homeurl"] = rtrim(join("/", $url),"/"); + } + $config["homeurl_static"] = $config["homeurl"]; $login_screen = 'error_perms'; require('general/error_screen.php'); exit;