diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 8384d0cc17..192749d870 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,27 @@ +2012-02-24 Miguel de Dios + + * pandora_console/include/functions_ui.php: changed the source code into the + function "ui_get_full_url" for accept false for to return url with the home + url or with any string (as query) return url with the php file. + + * pandora_console/include/functions_graph.php, + pandora_console/include/functions_html.php, + pandora_console/include/functions_events.php, + pandora_console/include/functions_reporting.php, + pandora_console/include/functions_api.php, + pandora_console/include/functions.php, pandora_console/index.php, + pandora_console/extensions/system_info.php, + pandora_console/operation/agentes/stat_win.php, + pandora_console/operation/menu.php, + pandora_console/operation/events/events_rss.php, + pandora_console/operation/events/events_marquee.php, + pandora_console/operation/events/events.php: change in more part of source + code to use "ui_get_full_url" instead the hard write method of $_SERVER + vars, now Pandora Console run fine (in all actions I hope) with web servers + in other ports instead the typical 80. + + Merged from branch pandora_4.0 + 2012-02-24 Miguel de Dios * include/functions.php: clean source style. diff --git a/pandora_console/extensions/system_info.php b/pandora_console/extensions/system_info.php index a7b56e3d83..f4dce79ee9 100644 --- a/pandora_console/extensions/system_info.php +++ b/pandora_console/extensions/system_info.php @@ -323,14 +323,9 @@ function mainSystemInfo() { $zipArchive = $config['attachment_store'] . '/last_info.zip'; @unlink($zipArchive); - if ($config['https']) { - $http = 'https://'; - } - else { - $http = "http://"; - } + $url_zip = ui_get_full_url(false); - $url = '' . __('System info file zipped') . ''; + $url = '' . __('System info file zipped') . ''; echo '' . __('File:') . ' ' . $url . '
'; echo '' . __('Location:') . ' ' . $zipArchive; diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index de5d7d5dbc..5029784c2a 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -20,6 +20,7 @@ require_once('functions_agents.php'); require_once('functions_modules.php'); include_once($config['homedir'] . "/include/functions_profile.php"); include_once($config['homedir'] . "/include/functions.php"); +include_once($config['homedir'] . "/include/functions_ui.php"); include_once($config['homedir'] . "/include/functions_events.php"); include_once($config['homedir'] . "/include/functions_groups.php"); include_once($config['homedir'] . "/include/functions_network_components.php"); @@ -4576,14 +4577,8 @@ function get_events__with_user($trash1, $trash2, $other, $returnType, $user_in_d $row['description_event'] = events_print_type_description($row["event_type"], true); $row['img_description'] = events_print_type_img ($row["event_type"], true, true); $row['criticity_name'] = get_priority_name ($row["criticity"]); - if ($config['https']) { - $urlImage = 'https://'; - } - else { - $urlImage = "http://"; - } - $urlImage = $urlImage.$_SERVER['HTTP_HOST'].$config["homeurl"]; + $urlImage = ui_get_full_url(false); switch ($row["criticity"]) { default: case 0: diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index a8ad3fb78f..44c9b7d839 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -14,6 +14,8 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. +include_once("include/functions_ui.php"); + /** * @package Include * @subpackage Events @@ -468,14 +470,7 @@ function events_print_type_img ($type, $return = false, $only_url = false) { $output = ''; - if ($config['https']) { - $urlImage = 'https://'; - } - else { - $urlImage = "http://"; - } - - $urlImage = $urlImage.$_SERVER['HTTP_HOST'].$config["homeurl"]; + $urlImage = ui_get_full_url(false); switch ($type) { case "alert_recovered": diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index fbf8671233..a87b4e3cd8 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -33,6 +33,8 @@ if (!isset($config)) { require_once ($config['homedir'].'/include/functions_users.php'); require_once ($config['homedir'].'/include/functions_groups.php'); +require_once ($config['homedir'].'/include/functions_ui.php'); + /** * Prints the print_r with < pre > tags @@ -1139,10 +1141,14 @@ function html_print_image ($src, $return = false, $options = false, $return_src if ($skin_path) $src = $skin_path; } - - // path to image (relative or absolute) - $src = ($relative? '' : $config["homeurl"] . '/') . $src; - + + if (!$relative) { + $urlImage = ui_get_full_url(false); + + // path to image + $src = $urlImage . $src; + } + // Only return src field of image if ($return_src) { if (!$return) { diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index edc7a4eede..cb8e815612 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -33,6 +33,7 @@ include_once($config['homedir'] . "/include/functions_alerts.php"); include_once($config['homedir'] . '/include/functions_users.php'); enterprise_include_once ('include/functions_metaconsole.php'); include_once($config['homedir'] . "/include/functions_forecast.php"); +include_once($config['homedir'] . "/include/functions_ui.php"); /** * Get the average value of an agent module in a period of time. @@ -2355,11 +2356,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f $table->colspan[1][0] = 3; $data = array (); - $urlImage = 'http://'; - if ($config['https']) { - $urlImage = 'https://'; - } - $urlImage .= $_SERVER['SERVER_NAME'] . $config['homeurl'] . '/'; + $urlImage = ui_get_full_url(false); require_once ($config["homedir"] . '/include/functions_graph.php'); $data[0] = graphic_combined_module( diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index fc691f2b23..75be9ea38f 100644 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -1676,31 +1676,27 @@ function ui_get_url_refresh ($params = false, $relative = true, $add_post = true } /** - * Returns a full URL in Pandora. + * Returns a full URL in Pandora. (with the port and https in some systems) * * An example of full URL is http:/localhost/pandora_console/index.php?sec=gsetup&sec2=godmode/setup/setup * - * @param string If provided, it will be added after the index.php + * @param mixed $url If provided, it will be added after the index.php, but it is false boolean value, put the homeurl in the url. * * @return string A full URL in Pandora. */ -function ui_get_full_url ($url = false) { +function ui_get_full_url ($url = '') { global $config; - $was_empty = false; - if (empty ($url)) { - $was_empty = true; - $url = $_SERVER['REQUEST_URI']; - } - if ($config['https']) { //When $config["https"] is set, always force https $protocol = 'https'; $ssl = true; - } elseif (isset ($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] === true || $_SERVER['HTTPS'] == 'on')) { + } + elseif (isset ($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] === true || $_SERVER['HTTPS'] == 'on')) { $protocol = 'https'; $ssl = true; - } else { + } + else { $protocol = 'http'; $ssl = false; } @@ -1711,14 +1707,20 @@ function ui_get_full_url ($url = false) { $fullurl .= ":".$_SERVER['SERVER_PORT']; } - if (! $was_empty) { + if ($url === '') { + $url = $_SERVER['REQUEST_URI']; + } + elseif ($url === false) { + //Only add the home url + $url = $config['homeurl'] . '/'; + } + else { $fullurl .= $_SERVER['SCRIPT_NAME']; } return $fullurl.$url; } - /** * Return a standard page header (Pandora FMS 3.1 version) * diff --git a/pandora_console/index.php b/pandora_console/index.php index 338c54d823..e4bdab6770 100644 --- a/pandora_console/index.php +++ b/pandora_console/index.php @@ -69,7 +69,7 @@ if (file_exists (ENTERPRISE_DIR."/load_enterprise.php")) { if (!empty ($config["https"]) && empty ($_SERVER['HTTPS'])) { - $query = 'https://' . $_SERVER['SERVER_NAME'].$_SERVER['SCRIPT_NAME']; + $query = ''; if (sizeof ($_REQUEST)) //Some (old) browsers don't like the ?&key=var $query .= '?1=1'; @@ -83,11 +83,12 @@ if (!empty ($config["https"]) && empty ($_SERVER['HTTPS'])) { foreach ($_POST as $key => $value) { $query .= '&'.$key.'='.$value; } + $url = ui_get_full_url($query); // Prevent HTTP response splitting attacks // http://en.wikipedia.org/wiki/HTTP_response_splitting - $query = str_replace ("\n", "", $query); - + $url = str_replace ("\n", "", $url); + header ('Location: '.$query); exit; //Always exit after sending location headers } @@ -96,7 +97,8 @@ if (!empty ($config["https"]) && empty ($_SERVER['HTTPS'])) { $config["pure"] = (bool) get_parameter ("pure"); // Auto Refresh page (can now be disabled anywhere in the script) -$config["refr"] = (int) get_parameter ("refr", $config["refr"]); +$config["refr"] = (int) get_parameter ("refr"); + ob_start (); echo ''."\n"; diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index 70a4838195..c13bd7aacc 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -21,6 +21,7 @@ require_once ("include/functions_alerts.php"); //Alerts processing functions require_once ($config['homedir'].'/include/functions_agents.php'); //Agents functions require_once ($config['homedir'].'/include/functions_users.php'); //Users functions require_once ($config['homedir'].'/include/functions_graph.php'); +require_once ($config['homedir'].'/include/functions_ui.php'); check_login (); @@ -267,7 +268,10 @@ if ($config["pure"] == 0) { ?>