From 0f823fd08536809fc82edeeae64235962aef4d41 Mon Sep 17 00:00:00 2001 From: guruevi Date: Fri, 13 Feb 2009 20:23:44 +0000 Subject: [PATCH] 2009-02-13 Evi Vanoost * general/logon_ok.php: Simplified and added correct ampersand tags * general/footer.php: Now use print_image function to print image * general/main_menu.php: Wrapped JS into CDATA * include/functions_events.php: Use print_image to print images. Use multibyte so Farsi/Arabian names don't mess up when cut. Also added ­ tags every 8 characters to the Event Description so that long module names (like GigabitEthernet) don't break the table layout. * include/functions.php: Moved pandora_help to functions_ui.php, return valid refresh links and don't double encode safe_input (otherwise & gets encoded as &) * include/functions_ui.php: Added print_help_icon and deprecated pandora_help (new style function naming) * include/functions_html.php: Partially rewrote print_image for fully compatible functionality. Much simplified as well. * extensions/update_manager.php: Print out correct link and image tag * operation/agentes/networkmap.php: Is now correct HTML. Should work in all compliant browsers. If IE6 still doesn't work, upgrade * operation/agentes/tactical.php: Use print_image for images. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1456 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 30 ++++++ pandora_console/extensions/update_manager.php | 2 +- pandora_console/general/footer.php | 4 +- pandora_console/general/logon_ok.php | 26 ++--- pandora_console/general/main_menu.php | 2 + pandora_console/include/functions.php | 22 +--- pandora_console/include/functions_events.php | 25 ++--- pandora_console/include/functions_html.php | 100 +++++++++++------- pandora_console/include/functions_ui.php | 24 ++++- .../operation/agentes/networkmap.php | 49 +++++---- .../operation/agentes/tactical.php | 21 ++-- 11 files changed, 187 insertions(+), 118 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 0ffb6654d0..3ff206e901 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,33 @@ +2009-02-13 Evi Vanoost + + * general/logon_ok.php: Simplified and added correct ampersand tags + + * general/footer.php: Now use print_image function to print image + + * general/main_menu.php: Wrapped JS into CDATA + + * include/functions_events.php: Use print_image to print images. Use + multibyte so Farsi/Arabian names don't mess up when cut. Also added + ­ tags every 8 characters to the Event Description so that long module + names (like GigabitEthernet) don't break the table layout. + + * include/functions.php: Moved pandora_help to functions_ui.php, return + valid refresh links and don't double encode safe_input (otherwise & + gets encoded as &) + + * include/functions_ui.php: Added print_help_icon and deprecated + pandora_help (new style function naming) + + * include/functions_html.php: Partially rewrote print_image for fully + compatible functionality. Much simplified as well. + + * extensions/update_manager.php: Print out correct link and image tag + + * operation/agentes/networkmap.php: Is now correct HTML. Should work in + all compliant browsers. If IE6 still doesn't work, upgrade + + * operation/agentes/tactical.php: Use print_image for images. + 2009-02-13 Sancho Lerena * operation/events/events.php: Added new feature: Group similar event by diff --git a/pandora_console/extensions/update_manager.php b/pandora_console/extensions/update_manager.php index b57f80aa90..2c4b76add9 100644 --- a/pandora_console/extensions/update_manager.php +++ b/pandora_console/extensions/update_manager.php @@ -103,7 +103,7 @@ function pandora_update_manager_login () { if (is_object ($package)) { echo '
'; - echo ' '; + echo 'info '; echo __('There\'s a new update for Pandora'); echo '. '; echo __('More info'); diff --git a/pandora_console/general/footer.php b/pandora_console/general/footer.php index ae71d432b7..21f9cd8035 100644 --- a/pandora_console/general/footer.php +++ b/pandora_console/general/footer.php @@ -30,5 +30,7 @@ if ((isset($develop_bypass)) AND ($develop_bypass == 1)) { echo ' - Saved '.format_numeric ($sql_cache["saved"]).' Queries'; } echo '
'; -echo ''.__('Get Firefox').''; +echo ''; +print_image ("images/firefox.png", false, array ("align" => "middle", "title" => __('Pandora FMS console is best viewed with Firefox web browser'), "alt" => __('Get Firefox'))); +echo ''; ?> diff --git a/pandora_console/general/logon_ok.php b/pandora_console/general/logon_ok.php index 04320686d0..ab153c5c42 100644 --- a/pandora_console/general/logon_ok.php +++ b/pandora_console/general/logon_ok.php @@ -76,14 +76,16 @@ $table->head = array (); $table->data = array (); $table->width = "100%"; +$img = "reporting/fgraph.php?tipo=progress&height=20&width=280&mode=0&percent="; + $table->data[0][0] =''.__('Monitor health').''; -$table->data[1][0] = ''; +$table->data[1][0] = print_image ($img.$data["monitor_health"], true, array ("title" => $data["monitor_health"].'% '.__('of monitors up'))); $table->data[2][0] = ''.__('Module sanity').''; -$table->data[3][0] = ''; +$table->data[3][0] = print_image ($img.$data["module_sanity"], true, array ("title" => $data["module_sanity"].'% '.__('of total modules inited'))); $table->data[4][0] = ''.__('Alert level').''; -$table->data[5][0] = ''; +$table->data[5][0] = print_image ($img.$data["alert_level"], true, array ("title" => $data["alert_level"].'% '.__('of defined alerts not fired'))); print_table ($table); unset ($table); @@ -95,42 +97,42 @@ $cells = array (); $cells[0][0] = __('Total agents'); $cells[0][1] = $data["total_agents"]; $cells[0]["color"] = "#000"; -$cells[0]["href"] = "index.php?sec=estado&sec2=operation/agentes/estado_agente&refr=60"; +$cells[0]["href"] = "index.php?sec=estado&sec2=operation/agentes/estado_agente&refr=60"; $cells[1][0] = __('Total checks'); $cells[1][1] = $data["total_checks"]; $cells[1]["color"] = "#000"; -$cells[1]["href"] = "index.php?sec=estado&sec2=operation/agentes/status_monitor&refr=60&status=-1"; +$cells[1]["href"] = "index.php?sec=estado&sec2=operation/agentes/status_monitor&refr=60&status=-1"; $cells[2][0] = __('Modules critical'); $cells[2][1] = $data["monitor_critical"]; $cells[2]["color"] = "#f00"; -$cells[2]["href"] = "index.php?sec=estado&sec2=operation/agentes/status_monitor&refr=60&status=2"; +$cells[2]["href"] = "index.php?sec=estado&sec2=operation/agentes/status_monitor&refr=60&status=2"; $cells[3][0] = __('Modules warning'); $cells[3][1] = $data["monitor_warning"]; $cells[3]["color"] = "#FFB900"; -$cells[3]["href"] = "index.php?sec=estado&sec2=operation/agentes/status_monitor&refr=60&status=1"; +$cells[3]["href"] = "index.php?sec=estado&sec2=operation/agentes/status_monitor&refr=60&status=1"; $cells[4][0] = __('Modules normal'); $cells[4][1] = $data["monitor_ok"]; $cells[4]["color"] = "#00ff00"; -$cells[4]["href"] = "index.php?sec=estado&sec2=operation/agentes/status_monitor&refr=60&status=0"; +$cells[4]["href"] = "index.php?sec=estado&sec2=operation/agentes/status_monitor&refr=60&status=0"; $cells[5][0] = __('Modules unknown'); $cells[5][1] = $data["monitor_unknown"]; $cells[5]["color"] = "#aaaaaa"; -$cells[5]["href"] = "index.php?sec=estado&sec2=operation/agentes/status_monitor&refr=60&status=3"; +$cells[5]["href"] = "index.php?sec=estado&sec2=operation/agentes/status_monitor&refr=60&status=3"; $cells[6][0] = __('Alerts defined'); $cells[6][1] = $data["total_alerts"]; $cells[6]["color"] = "#000"; -$cells[6]["href"] = "index.php?sec=estado&sec2=operation/agentes/alerts_status&refr=60"; +$cells[6]["href"] = "index.php?sec=estado&sec2=operation/agentes/alerts_status&refr=60"; $cells[7][0] = __('Users defined'); $cells[7][1] = count (get_users ()); $cells[7]["color"] = "#000"; -$cells[7]["href"] = "index.php?sec=usuarios&sec2=operation/users/user"; +$cells[7]["href"] = "index.php?sec=usuarios&sec2=operation/users/user"; foreach ($cells as $key => $row) { //Switch class around @@ -148,7 +150,7 @@ echo '
'; // Show last activity from this user echo "

" . __('This is your last activity in Pandora FMS console') . "

"; -$table->width = '700px'; +$table->width = 700; //Don't specify px $table->data = array (); $table->size = array (); $table->size[2] = '130px'; diff --git a/pandora_console/general/main_menu.php b/pandora_console/general/main_menu.php index 2a456ace70..c1a9efebaa 100644 --- a/pandora_console/general/main_menu.php +++ b/pandora_console/general/main_menu.php @@ -138,6 +138,7 @@ require ("links_menu.php"); $config['jquery'][] = 'cookie'; ?> diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 496fc5f6dc..c06d1ebea7 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -22,22 +22,6 @@ require_once ('functions_ui.php'); define ('ENTERPRISE_NOT_HOOK', -1); -/** - * Prints a help tip icon. - * - * @param string $help_id Id of the help article - * @param bool $return Whether to return or output the result - * - * @return string The help tip - */ -function pandora_help ($help_id, $return = false) { - global $config; - $output = ' '; - if ($return) - return $output; - echo $output; -} - /** * Cleans a string by encoding to UTF-8 and replacing the HTML * entities. UTF-8 is necessary for foreign chars like asian @@ -54,7 +38,7 @@ function safe_input ($value) { array_walk ($value, 'safe_input'); return $value; } - return htmlentities (utf8_encode ($value), ENT_QUOTES, "UTF-8"); + return htmlentities (utf8_encode ($value), ENT_QUOTES, "UTF-8", false); } /** @@ -1039,10 +1023,10 @@ function process_page_head ($string, $bitfield) { /* Avoid the 1=1 */ if ($key == 1) continue; - $query .= '&'.$key.'='.$value; + $query .= '&'.$key.'='.$value; } foreach ($_POST as $key => $value) { - $query .= '&'.$key.'='.$value; + $query .= '&'.$key.'='.$value; } $output .= ''; diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index f462725e8b..ec7609208b 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -219,43 +219,44 @@ function print_events_table ($filter = "", $limit = 10, $width = 440, $return = /* Colored box */ if ($event["estado"] == 0) { - $data[0] = ''; + $data[0] = print_image ("images/pixel_red.png", true, array ("width" => 20, "height" => 20, "title" => get_priority_name ($event["criticity"]))); } else { - $data[0] = ''; + $data[0] = print_image ("images/pixel_green.png", true, array ("width" => 20, "height" => 20, "title" => get_priority_name ($event["criticity"]))); } /* Event type */ switch ($event["event_type"]) { case "alert_recovered": - $data[1] = ''; + $data[1] = print_image ("images/error.png", true, array ("title" => __('Alert recovered'))); break; case "alert_manual_validation": - $data[1] = ''; + $data[1] = print_image ("images/eye.png", true, array ("title" => __('Alert manually validated'))); break; case "monitor_up": - $data[1] = ''; + $data[1] = print_image ("images/lightbulb.png", true, array ("title" => __('Monitor up'))); break; case "monitor_down": - $data[1] = ''; + $data[1] = print_image ("images/lightbulb_off.png", true, array ("title" => __('Monitor down'))); break; case "alert_fired": - $data[1] = ''; + $data[1] = print_image ("images/bell.png", true, array ("title" => __('Alert fired'))); break; case "system"; - $data[1] = ''; + $data[1] = print_image ("images/cog.png", true, array ("title" => __('System'))); break; case "recon_host_detected"; - $data[1] = ''; + $data[1] = print_image ("images/network.png", true, array ("title" => __('Host detected by recon server'))); break; default: - $data[1] = ''; + $data[1] = print_image ("images/err.png", true, array ("title" => $event["event_type"])); break; } // Event description wrap around by default at 44 or ~3 lines (10 seems to be a good ratio to wrap around for most sizes. Smaller number gets longer strings) - $data[2] = ''.safe_input (substr ($event["evento"],0, floor ($width / 10))); + $wrap = floor ($width / 10); + $data[2] = ''.safe_input (chunk_split (mb_substr ($event["evento"],0, $wrap),8, "­")); - if (strlen ($event["evento"]) > floor ($width / 10)) { + if (mb_strlen ($event["evento"]) > floor ($width / 10)) { $data[2] .= "..."; } $data[2] .= ''; diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index e05e7d7634..21c445a7f9 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -50,7 +50,7 @@ function print_select ($fields, $name, $selected = '', $script = '', $nothing = $attributes .= ' class="'.$class.'"'; } if (!empty ($disabled)) { - $attributes .= ' disabled'; + $attributes .= ' disabled="disabled"'; } $output .= ''; - $output .= $value; + $output .= safe_input ($value); $output .= ''; if ($return) @@ -433,7 +433,7 @@ function print_table (&$table, $return = false) { } if (empty ($table->border)) { - $table->border = '0px'; + $table->border = '0'; } if (empty ($table->tablealign) || $table->tablealign != 'left' || $table->tablealign != 'right') { @@ -571,7 +571,7 @@ function print_radio_button_extended ($name, $value, $label, $checkedvalue, $dis $output .= ' checked="checked"'; } if ($disabled) { - $output .= ' disabled'; + $output .= ' disabled="disabled"'; } if ($script != '') { $output .= ' onClick="'. $script . '"'; @@ -624,7 +624,7 @@ function print_radio_button ($name, $value, $label = '', $checkedvalue = '', $re * @return string HTML code if return parameter is true. */ function print_checkbox_extended ($name, $value, $checked, $disabled, $script, $attributes, $return = false) { - $output = ''; + if (!isset ($options["alt"]) && isset ($options["title"])) { + $options["alt"] = $options["title"]; //Set alt to title if it's not set + } elseif (!isset ($options["alt"])) { + $options["alt"] = ''; //Alt is mandatory, empty string will do + } + + if (!empty ($style)) { + $output .= 'style="'.$style.'" '; + } - if ($return) - return $output; - echo $output; + $output .= 'alt="'.safe_input ($options['alt']).'" />'; + + if (!$return) { + echo $output; + } + + return $output; } /** diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 975328d505..25602a76bd 100644 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -205,7 +205,7 @@ function print_os_icon ($id_os, $name = true, $return = false) { */ function print_agent_name ($id_agent, $return = false, $cutoff = 0) { $agent_name = (string) get_agent_name ($id_agent); - $output = ''; + $output = ''; if ($cutoff > 0 && (mb_strlen ($agent_name, "UTF-8") > $cutoff)) { $output .= mb_substr (utf8_decode ($agent_name), 0, $cutoff, "UTF-8").'...'; } else { @@ -388,4 +388,26 @@ function print_alert_template_example ($id_alert_template, $return = false, $pri echo $output; } +/** + * DEPRECATED: Use print_help_icon to avoid confusion with pandora_help javascript function + */ +function pandora_help ($help_id, $return = false) { + return print_help_icon ($help_id, $return); +} + +/** + * Prints a help tip icon. + * + * @param string $help_id Id of the help article + * @param bool $return Whether to return or output the result + * + * @return string The help tip + */ +function print_help_icon ($help_id, $return = false) { + $output = ' '.print_image ("images/help.png", true, array ("class" => "img_help", "title" => __('Help'), "onclick" => "pandora_help ('".$help_id."')")); + if (!$return) + echo $output; + + return $output; +} ?> diff --git a/pandora_console/operation/agentes/networkmap.php b/pandora_console/operation/agentes/networkmap.php index d3b35304df..78905fb08b 100644 --- a/pandora_console/operation/agentes/networkmap.php +++ b/pandora_console/operation/agentes/networkmap.php @@ -16,7 +16,7 @@ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // Load global vars -require ("include/config.php"); +require_once ("include/config.php"); check_login (); @@ -253,11 +253,15 @@ $simple = (boolean) get_parameter ('simple', 0); $regen = (boolean) get_parameter ('regen',1); // Always regen by default $font_size = (int) get_parameter ('font_size', 12); -echo '

'.__('Pandora Agents').' > '.__('Network Map').' '; +echo '

'.__('Pandora Agents').' > '.__('Network Map').' '; if ($pure == 1) { - echo ''; + echo ''; + print_image ("images/monitor.png", false, array ('title' => __('Normal screen'), 'alt' => __('Normal screen'))); + echo ''; } else { - echo ''; + echo ''; + print_image ("images/monitor.png", false, array ('title' => __('Normal screen'), 'alt' => __('Normal screen'))); + echo ''; } echo '

'; @@ -269,7 +273,7 @@ $layout_array = array ( 'spring2' => 'spring 2', 'flat' => 'flat'); -echo '
'; +echo ''; echo ''; echo ''; echo '"; //echo ' Display groups '; echo ''; echo '
' . __('Layout') . '  '; @@ -319,7 +323,7 @@ echo "'; -echo ''; +print_submit_button (__('Update'), "updbutton", false, 'class="sub upd"'); echo '
'; @@ -351,36 +355,35 @@ $filename_dot .= ".dot"; if ($regen != 1 && file_exists ($filename_img) && filemtime ($filename_img) > get_system_time () - 300) { $result = true; } else { - $fh = fopen ($filename_dot, 'w'); + $fh = @fopen ($filename_dot, 'w'); if ($fh === false) { $result = false; - break; + } else { + fwrite ($fh, $graph); + $cmd = "$filter -Tcmapx -o".$filename_map." -Tpng -o".$filename_img." ".$filename_dot; + $result = system ($cmd); + fclose ($fh); + unlink ($filename_dot); } - - fwrite ($fh, $graph); - $cmd = "$filter -Tcmapx -o".$filename_map." -Tpng -o".$filename_img." ".$filename_dot; - $result = system ($cmd); - fclose ($fh); - unlink ($filename_dot); } if ($result !== false) { if (! file_exists ($filename_map)) { echo '

'.__('Map could not be generated').'

'; echo $result; - echo "
Apparently something went wrong reading the output.
Is ".$filter." (usually part of GraphViz) installed and able to be executed by the webserver?"; - echo "
Is ".$config["attachment_store"]." writeable by the webserver?"; + echo "
Apparently something went wrong reading the output.
"; + echo "
Is ".$config["attachment_store"]." readable by the webserver process?"; return; } - echo ''; - include ($filename_map); + print_image ($filename_img, false, array ("alt" => __('Network Map'), "usemap" => "#networkmap")); + require ($filename_map); } else { echo '

'.__('Map could not be generated').'

'; echo $result; - echo "
Apparently something went wrong executing the command."; - echo "
Is ".$filter." (usually part of GraphViz) and echo installed and able to be executed by the webserver?"; - echo "
Is your webserver restricted from executing command line tools through the system() call (PHP Safe Mode or SELinux)"; - + echo "
Apparently something went wrong executing the command or writing the output."; + echo "

Is ".$filter." (usually part of GraphViz) and echo installed and able to be executed by the webserver process?"; + echo "

Is your webserver restricted from executing command line tools through the system() call (PHP Safe Mode or SELinux)"; + echo "

Is ".$config["attachment_store"]." writeable by the webserver process? To change this do the following (POSIX-based systems): chown <apache user> ".$config["attachment_store"]; return; } @@ -388,6 +391,7 @@ $config['css'][] = 'cluetip'; $config['jquery'][] = 'cluetip'; ?> diff --git a/pandora_console/operation/agentes/tactical.php b/pandora_console/operation/agentes/tactical.php index ab613cb006..82a0bd93ed 100644 --- a/pandora_console/operation/agentes/tactical.php +++ b/pandora_console/operation/agentes/tactical.php @@ -42,7 +42,7 @@ function print_cells_temp ($cells) { if ($row[1] === 0) { $row[1] = "-"; } - echo ''.$row[1].''; + echo ''.$row[1].''; } } @@ -63,28 +63,30 @@ $table->head = array (); $table->data = array (); $table->style = array (); +$img = "reporting/fgraph.php?tipo=progress&height=20&width=260&mode=0&percent="; + $table->style[0] = "padding-top:4px; padding-bottom:4px;"; $table->data[0][0] =''.__('Monitor health').''; $table->style[1] = "padding-top:4px; padding-bottom:4px;"; -$table->data[1][0] = ''; +$table->data[1][0] = print_image ($img.$data["monitor_health"], true, array ("title" => $data["monitor_health"].'% '.__('of monitors up'))); $table->style[2] = "padding-top:4px; padding-bottom:4px;"; $table->data[2][0] = ''.__('Module sanity').''; $table->style[3] = "padding-top:4px; padding-bottom:4px;"; -$table->data[3][0] = ''; +$table->data[3][0] = print_image ($img.$data["module_sanity"], true, array ("title" => $data["module_sanity"].'% '.__('of total modules inited'))); $table->style[4] = "padding-top:4px; padding-bottom:4px;"; $table->data[4][0] = ''.__('Alert level').''; $table->style[5] = "padding-top:4px; padding-bottom:4px;"; -$table->data[5][0] = ''; +$table->data[5][0] = print_image ($img.$data["alert_level"], true, array ("title" => $data["alert_level"].'% '.__('of defined alerts not fired'))); print_table ($table); unset ($table); -echo ''; +echo '
'; echo ''; $cells = array (); @@ -180,18 +182,17 @@ if ($serverinfo) { $data[0] = $server_info["name"]; if ($server_info["status"] == 0){ - $data[1] = ''; + $data[1] = print_image ("images/pixel_red.png", true, array ("width" => 20, "height" => 20)); } else { - $data[1] = ''; + $data[1] = print_image ("images/pixel_green.png", true, array ("width" => 20, "height" => 20)); } - if ($server_info["modules"] > 0 && $total_modules > 0) { $percent = $server_info["modules"] / ($total_modules / 100); } else { $percent = 0; } - $data[2] = ''; + $data[2] = print_image ("reporting/fgraph.php?tipo=progress&percent=".$percent."&height=18&width=80", true, array ("title" => $server_info["modules"]." ".__('of')." ".$total_modules)); $data[3] = $server_info["lag"]." / ".$server_info["module_lag"]; @@ -210,7 +211,7 @@ if ($serverinfo) { } echo '
'.__('Monitor checks').'
'; } else { - echo "
".__('There are no servers configured into the database')."
"; + echo '
'.__('There are no servers configured into the database').'
'; } print_events_table ("", 10, 450);