From 84d628326f9d8c392bbf2b3b4a5c262b3eab9530 Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Thu, 16 May 2013 08:23:51 +0000 Subject: [PATCH] 2013-05-16 Miguel de Dios * ajax.php: fixed PHP warning when the HTTP_REFERER not set. * godmode/agentes/module_manager_editor_prediction.php, include/functions_ui.php, operation/agentes/ver_agente.php, operation/agentes/stat_win.php: improved the source code style. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8137 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 8 ++++++++ pandora_console/ajax.php | 10 ++++++---- .../module_manager_editor_prediction.php | 18 +++++++++++------- pandora_console/include/functions_ui.php | 17 +++++++++++------ pandora_console/operation/agentes/stat_win.php | 1 + .../operation/agentes/ver_agente.php | 6 ++++-- 6 files changed, 41 insertions(+), 19 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 4119d928f9..688fe9c0fa 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,11 @@ +2013-05-16 Miguel de Dios + + * ajax.php: fixed PHP warning when the HTTP_REFERER not set. + + * godmode/agentes/module_manager_editor_prediction.php, + include/functions_ui.php, operation/agentes/ver_agente.php, + operation/agentes/stat_win.php: improved the source code style. + 2013-05-14 Miguel de Dios * godmode/alerts/alert_commands.php: fixed the ajax of diff --git a/pandora_console/ajax.php b/pandora_console/ajax.php index dc89b85d05..c0138142ac 100644 --- a/pandora_console/ajax.php +++ b/pandora_console/ajax.php @@ -74,10 +74,12 @@ if (file_exists ('./include/languages/'.$user_language.'.mo')) { $l10n = new gettext_reader (new CachedFileReader ('./include/languages/'.$user_language.'.mo')); $l10n->load_tables(); } - -// Not cool way of know if we are executing from metaconsole or normal console -if (strpos($_SERVER['HTTP_REFERER'], ENTERPRISE_DIR . '/meta/') !== false) - define ('METACONSOLE', true); + +if (isset($_SERVER['HTTP_REFERER'])) { + // Not cool way of know if we are executing from metaconsole or normal console + if (strpos($_SERVER['HTTP_REFERER'], ENTERPRISE_DIR . '/meta/') !== false) + define ('METACONSOLE', true); +} session_write_close (); if (file_exists ($page)) { diff --git a/pandora_console/godmode/agentes/module_manager_editor_prediction.php b/pandora_console/godmode/agentes/module_manager_editor_prediction.php index 50b7b93190..a34d0c55c8 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_prediction.php +++ b/pandora_console/godmode/agentes/module_manager_editor_prediction.php @@ -132,8 +132,11 @@ if($id_agente) { $sql = "SELECT id_agente_modulo, nombre FROM tagente_modulo WHERE delete_pending = 0 - AND history_data = 1 AND id_agente = " . $id_agente_clean . " AND id_agente_modulo <> " . $id_agente_modulo; - $data[1] .= html_print_select_from_sql($sql, 'prediction_module', $prediction_module, false, __('Select Module'), 0, true); + AND history_data = 1 + AND id_agente = " . $id_agente_clean . " + AND id_agente_modulo <> " . $id_agente_modulo; + $data[1] .= html_print_select_from_sql($sql, 'prediction_module', + $prediction_module, false, __('Select Module'), 0, true); } else { $data[1] .= ''; @@ -191,9 +194,10 @@ unset ($table_advanced->data[3]); ?> \ No newline at end of file diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 1511e36170..a10ec61073 100644 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -72,6 +72,7 @@ function ui_print_truncate_text($text, $numChars = GENERIC_SIZE_TEXT, $showTextI } } + if ($numChars == 0) { if ($return == true) { return $text; @@ -83,12 +84,15 @@ function ui_print_truncate_text($text, $numChars = GENERIC_SIZE_TEXT, $showTextI $text = io_safe_output($text); if (mb_strlen($text, "UTF-8") > ($numChars)) { - $half_length = intval(($numChars - 3) / 2); // '/2' because [...] is in the middle of the word. + // '/2' because [...] is in the middle of the word. + $half_length = intval(($numChars - 3) / 2); // Depending on the strange behavior of mb_strimwidth() itself, - // the 3rd parameter is not to be $numChars but the length of original text (just means 'large enough'). + // the 3rd parameter is not to be $numChars but the length of + // original text (just means 'large enough'). $truncateText2 = mb_strimwidth($text, - (mb_strlen($text, "UTF-8") - $half_length), mb_strlen($text, "UTF-8"), "", "UTF-8" ); + (mb_strlen($text, "UTF-8") - $half_length), + mb_strlen($text, "UTF-8"), "", "UTF-8" ); $truncateText = mb_strimwidth($text, 0, ($numChars - $half_length), "", "UTF-8") . $suffix; @@ -100,10 +104,11 @@ function ui_print_truncate_text($text, $numChars = GENERIC_SIZE_TEXT, $showTextI $truncateText = $truncateText; } else if ($style !== false) { - $truncateText = ''.$truncateText.''; + $truncateText = '' . + $truncateText . ''; } else { - $truncateText = ''.$truncateText.''; + $truncateText = '' . $truncateText . ''; } } if ($showTextInAToopTip) { @@ -111,7 +116,7 @@ function ui_print_truncate_text($text, $numChars = GENERIC_SIZE_TEXT, $showTextI } else { if ($style !== false) { - $truncateText = ''.$truncateText.''; + $truncateText = '' . $truncateText . ''; } } } diff --git a/pandora_console/operation/agentes/stat_win.php b/pandora_console/operation/agentes/stat_win.php index 7c06a21bf5..046bb8f454 100644 --- a/pandora_console/operation/agentes/stat_win.php +++ b/pandora_console/operation/agentes/stat_win.php @@ -297,6 +297,7 @@ $label = base64_decode(get_parameter('label', '')); $table->data[] = $data; $table->rowclass[] = ''; + switch ($graph_type) { case 'boolean': case 'sparse': diff --git a/pandora_console/operation/agentes/ver_agente.php b/pandora_console/operation/agentes/ver_agente.php index d3adba0175..9aed932085 100644 --- a/pandora_console/operation/agentes/ver_agente.php +++ b/pandora_console/operation/agentes/ver_agente.php @@ -300,9 +300,11 @@ if (is_ajax ()) { } $result = array(); - foreach($nameModules as $nameModule) { + foreach ($nameModules as $nameModule) { if (empty($serialized)) - $result[io_safe_output($nameModule['nombre'])] = ui_print_truncate_text(io_safe_output($nameModule['nombre']), 'module_medium', false, true); + $result[io_safe_output($nameModule['nombre'])] = + ui_print_truncate_text( + io_safe_output($nameModule['nombre']), 'module_medium', false, true); else $result[io_safe_output($nameModule['nombre']).'$*$'.implode('|', $idAgents)] = ui_print_truncate_text(io_safe_output($nameModule['nombre']), 'module_medium', false, true); }