From 2d441437a8dd80ccc1f6372554211948dd3c50e7 Mon Sep 17 00:00:00 2001 From: daniel Date: Thu, 8 Jun 2017 11:26:16 +0200 Subject: [PATCH] fixed errors in login page --- pandora_console/include/config_process.php | 46 +++++++++++++++------- pandora_console/include/functions_db.php | 17 +++++++- pandora_console/index.php | 36 +++++++++++++---- 3 files changed, 75 insertions(+), 24 deletions(-) diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index ab7d64137d..de4b022efd 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -113,29 +113,45 @@ require_once ($ownDir . 'functions.php'); // We need a timezone BEFORE calling config_process_config. // 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; +if(!is_dir($_SERVER['DOCUMENT_ROOT'] . $config["homeurl"]) || !is_dir($_SERVER['DOCUMENT_ROOT'] . $config["homeurl_static"])){ + $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]); + } + else if(strpos($value, 'enterprise') !== false || $flag_url){ + $flag_url=1; + unset($url[$key]); } } + $config["homeurl"] = rtrim(join("/", $url),"/"); + $config["homeurl_static"] = $config["homeurl"]; + $config["error"] = "homeurl_bad_defined"; + return; } + + if (!isset($config["homeurl_static"])) { $config["homeurl_static"] = $config["homeurl"]; } else{ if($config["homeurl_static"] != $config["homeurl"]){ + $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]); + } + else if(strpos($value, 'enterprise') !== false || $flag_url){ + $flag_url=1; + unset($url[$key]); + } + } + $config["homeurl"] = rtrim(join("/", $url),"/"); + $config["homeurl_static"] = $config["homeurl"]; $config["error"] = "homeurl_bad_defined"; return; } diff --git a/pandora_console/include/functions_db.php b/pandora_console/include/functions_db.php index f2c1627304..06c85ef194 100644 --- a/pandora_console/include/functions_db.php +++ b/pandora_console/include/functions_db.php @@ -64,8 +64,23 @@ function db_connect($host = null, $db = null, $user = null, $pass = null, $port // Something went wrong if ($return === false) { if ($critical) { + $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]); + } + else if(strpos($value, 'enterprise') !== false || $flag_url){ + $flag_url=1; + unset($url[$key]); + } + } + $config["homeurl"] = rtrim(join("/", $url),"/"); + $config["homeurl_static"] = $config["homeurl"]; + $ownDir = dirname(__FILE__) . DIRECTORY_SEPARATOR; + $config['homedir'] = $ownDir; $login_screen = 'error_authconfig'; - require($config['homedir'] . '/general/error_screen.php'); exit; } diff --git a/pandora_console/index.php b/pandora_console/index.php index 79aaca3ffb..ee3312d486 100755 --- a/pandora_console/index.php +++ b/pandora_console/index.php @@ -27,14 +27,23 @@ if ($develop_bypass != 1) { // If no config file, automatically try to install if (! file_exists ("include/config.php")) { if (! file_exists ("install.php")) { + $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]); + } + else 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_noconfig'; $ownDir = dirname(__FILE__) . DIRECTORY_SEPARATOR; $config['homedir'] = $ownDir; - $config['homeurl'] = $_SERVER['REQUEST_URI']; - $config['homeurl_static'] = $_SERVER['REQUEST_URI']; - - - require('general/error_screen.php'); exit; } @@ -67,11 +76,22 @@ if ($develop_bypass != 1) { if ((substr (sprintf ('%o', fileperms('include/config.php')), -4) != "0600") && (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']); + $flag_url =0; + foreach ($url as $key => $value) { + if (strpos($value, 'index.php') !== false || $flag_url) { + $flag_url=1; + unset($url[$key]); + } + else if(strpos($value, 'enterprise') !== false || $flag_url){ + $flag_url=1; + unset($url[$key]); + } + } + $config["homeurl"] = rtrim(join("/", $url),"/"); + $config["homeurl_static"] = $config["homeurl"]; + $ownDir = dirname(__FILE__) . DIRECTORY_SEPARATOR; $config['homedir'] = $ownDir; - $config['homeurl'] = "/" . $url[1]; - $config['homeurl_static'] = "/" . $url[1]; $login_screen = 'error_perms'; require('general/error_screen.php'); exit;