From 22829bc85629ff8b6a42d2e31ebe78d13634f3eb Mon Sep 17 00:00:00 2001 From: netniV Date: Sat, 23 Dec 2017 18:58:49 +0000 Subject: [PATCH] Installation now checks the URI path (#1152) * Installation now checks that the URI path matches with configuration setting URL_PATH * Update index.php Fix up coding format --- docs/CHANGELOG | 1 + install/index.php | 53 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/docs/CHANGELOG b/docs/CHANGELOG index 2a4d486ed5..b4cc666440 100644 --- a/docs/CHANGELOG +++ b/docs/CHANGELOG @@ -25,6 +25,7 @@ Cacti CHANGELOG -issue#1131: Make upgrade_database.php use same version compare as /install/ system -issue#1133: Fix issues with variable name and debug log -issue#1143: ss_host_cpu.php - Division by zero / Invalid Return Value +-issue#1146: Installation now checks URI path matchs with configuration option URL_PATH -issue: Updated Graph pagenation and filter reset -issue: Resolve issues with cacti_version_compare() processing -issue: Zoom context menu stays open after zoom out actions diff --git a/install/index.php b/install/index.php index 35b957d267..450c4908a5 100644 --- a/install/index.php +++ b/install/index.php @@ -446,6 +446,59 @@ $enabled = '1'; $enabled = '1'; print '

' . __('Pre-installation Checks') .'

'; + print '

' . __('Location checks') . '

'; + + // Get request URI and break into parts + $test_request_uri = $_SERVER['REQUEST_URI']; + $test_request_parts = parse_url($test_request_uri); + $test_request_path = $test_request_parts['path']; + $test_request_len = strlen($test_request_parts['path']); + + // Get current script name (filename only) + $test_script_name = basename($_SERVER['SCRIPT_NAME']); + $test_script_len = strlen($test_script_name); + + // Get end of the path of URI and see if it's our script + $test_script_part = substr($test_request_path, $test_request_len - $test_script_len); + $test_script_result = strcmp($test_script_part, $test_script_name); + + // Assume desired path is the URI + $test_final_path = $test_request_parts['path']; + + // Script was found in path, so remove it + if ($test_script_result === 0) { + $test_final_path = substr($test_final_path,0,strlen($test_final_path) - $test_script_len); + } + + // Add the install subfolder to defined path location + // and check if it matches, if not there will likely be problems + $test_config_path = $config['url_path'] . 'install/'; + $test_compare_result = strcmp($test_config_path,$test_final_path); + + /* + * Uncmment the following to debug the above change + * + print '

Testing [' . $test_config_path . '] matches [' . $test_final_path .'] result = '.$test_compare_result.'('.gettype($test_compare_result).')

'; + + print '

request_uri = ' . strlen($test_request_uri) . ' [' . $test_request_uri . ']

'; + print '

request_parts = ' . var_export($test_request_parts, true) . '

'; + print '

request_path = ' . strlen($test_request_path) . ' [' . $test_request_path . ']

'; + + print '

script_name = ' . strlen($test_script_name) . ' [' . $test_script_name . ']

'; + print '

script_part = ' . strlen($test_script_part) . ' [' . $test_script_part . ']

'; + print '

script_result = ' . $test_script_result . '

'; + print '

final_path = ' . strlen($test_final_path) . ' [' . $test_final_path . ']

'; + * + * The above code should probably be removed once tested. + */ + + // The path was not what we expected so print an error + if ($test_compare_result !== 0) { + print '

' . __('ERROR:') . ' ' . __('Please update config.php with the correct relative URI location of Cacti (url_path).') . '

'; + } else { + print '

' . __('Your Cacti configuration has the relative correct path (url_path) in config.php.') . '

'; + } + print '

' . __('MySQL TimeZone Support') .'

'; $mysql_timezone_access = db_fetch_assoc('SHOW COLUMNS FROM mysql.time_zone_name', false); if (sizeof($mysql_timezone_access)) {