diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 84f102388b..0cbf6cd49c 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,28 @@ +2009-02-24 Evi Vanoost + + * include/config_process.php: Added compact_header. If you want to + save on server hits and increase performance (slightly) enable it. + Page loads (on my system) ~500ms faster and feels faster since it + doesn't block the page while waiting on css and javascript + + * include/functions_agents.php: Moved process_manage_config from + configurar_agente. + + * include/functions_ui.php: Added compact_header functionality + + * include/functions_html.php: Fixed some id issues which caused + manage_config to not work correctly. id's can't have [] in them. + Also fixed the comparison for numeric (string to int) comparisons + + * include/styles/pandora.css: Moved @import to functions_ui.php + + * godmode/agentes/manage_config.php: Fixed ids and some validation + + * godmode/agentes/configurar_agente.php, godmode/agentes/agent_manager: + Fixed HTML output and use functions for images + + * godmode/setup/setup.php: Added compact_header to setup + 2009-02-24 Esteban Sanchez * include/functions_db.php: Fixed a bug in diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index c84dee7a11..d498427242 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -55,7 +55,7 @@ if (isset($_GET["disk_conf_delete"])) { unlink ($filename['conf']); } -echo '
'; +echo ''; $table->width = 650; $table->cellpadding = 4; @@ -69,14 +69,16 @@ $table->data[0][0] = ''.__('Agent name').''.print_help_tip (__("The agent $table->data[0][1] = print_input_text ('agente', $nombre_agente, '', 30, 100,true); if (isset ($id_agente) && $id_agente != "") { - $table->data[0][1] .= ' - '; + $table->data[0][1] .= ''; + $table->data[0][1] .= print_image ("images/lupa.png", true, array ("border" => 0, "title" => __('Agent detail'))); + $table->data[0][1] .= ''; } // Remote configuration available if (file_exists ($filename['md5'])) { - $table->data[0][1] .= ' - '.print_help_tip (__('You can remotely edit this agent configuration'), true); + $table->data[0][1] .= ''; + $table->data[0][1] .= print_image ("images/application_edit.png", false, array ("border" => 0, "title" => __('This agent can be remotely configured'))); + $table->data[0][1] .= ''.print_help_tip (__('You can remotely edit this agent configuration'), true); } $table->data[1][0] = ''.__('IP Address').''; @@ -150,7 +152,8 @@ $table->data[15][0] = ''.__('Remote configuration').''; if (file_exists ($filename['md5'])) { $table->data[15][1] = date ("F d Y H:i:s.", fileatime ($filename['md5'])); // Delete remote configuration - $table->data[15][1] .= ''; + $table->data[15][1] .= ''; + $table->data[15][1] .= print_image ("images/cross.png", true).''; } else { $table->data[15][1] = ''.__('Not available').''; } @@ -167,5 +170,5 @@ if ($new_agent) { print_input_hidden ('update_agent', 1); print_input_hidden ('id_agente', $id_agente); } -echo ''; -?> +echo '
'; +?> \ No newline at end of file diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index f4e81cf375..d17aa546a6 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -187,70 +187,50 @@ if ($create_agent) { } // Show tabs -echo ""; // Make some space between tabs and title // IE might not always show an empty div, added space -echo "
 
"; +echo '
 
'; // Show agent creation results if ($create_agent) { - if (! $agent_created_ok) { - echo "

".__('There was a problem creating agent')."

"; - echo __('There was a problem creating agent_keepalive module'); - } else { - echo "

".__('Agent successfully created')."

"; - } + print_error_message ($agent_created_ok, __('Agent successfully created'), __('There was a problem creating the agent')); } // Fix / Normalize module data @@ -270,11 +250,7 @@ if (isset($_GET["fix_module"])){ $error = " - ".__('No data to normalize'); } - if ($result !== false) { - echo '

'.__('Deleted data above').' '.$media.'

'; - } else { - echo '

'.__('Error normalizing module').$error.'

'; - } + print_error_message ($result, __('Deleted data above').' '.$media, __('Error normalizing module').' '.$error); } // ================ @@ -343,16 +319,11 @@ if (isset($_POST["update_agent"])) { // if modified some agent paramenter } } -if ((isset($agent_created_ok)) && ($agent_created_ok == 1)){ - $_GET["id_agente"] = $id_agente; -} - // Read agent data -// This should be at the end of all operation checks, to read the changess -if (isset($_REQUEST["id_agente"])) { +// This should be at the end of all operation checks, to read the changes - $id_agente doesn't have to be retrieved +if ($id_agente > 0) { //This has been done in the beginning of the page, but if an agent was created, this id might change - $id_agente = (int) get_parameter ('id_agente'); - $id_grupo = dame_id_grupo ($id_agente); + $id_grupo = get_agent_group ($id_agente); if (give_acl ($config["id_user"], $id_grupo, "AW") != 1) { audit_db($config["id_user"],$REMOTE_ADDR, "ACL Violation","Trying to admin an agent without access"); require ("general/noaccess.php"); @@ -389,7 +360,7 @@ $edit_module = (bool) get_parameter ('edit_module'); // GET DATA for MODULE UPDATE OR MODULE INSERT if ($update_module || $create_module) { - $id_grupo = dame_id_grupo ($id_agente); + $id_grupo = get_agent_group ($id_agente); if (! give_acl ($config["id_user"], $id_grupo, "AW")) { audit_db ($config["id_user"], $REMOTE_ADDR, "ACL Violation", diff --git a/pandora_console/godmode/agentes/manage_config.php b/pandora_console/godmode/agentes/manage_config.php index 634f42759b..80e3b3f81b 100644 --- a/pandora_console/godmode/agentes/manage_config.php +++ b/pandora_console/godmode/agentes/manage_config.php @@ -32,75 +32,6 @@ require_once ('include/functions_modules.php'); echo '

'.__('Agent configuration'). ' » '. __('Configuration Management').'

'; -function process_manage_config ($source_id_agent, $destiny_id_agents) { - if (empty ($source_id_agent)) { - echo '

'.__('No source agent to copy').'

'; - return false; - } - - if (empty ($destiny_id_agents)) { - echo '

'.__('No destiny agent(s) to copy').'

'; - return false; - } - - $copy_modules = (bool) get_parameter ('copy_modules'); - $copy_alerts = (bool) get_parameter ('copy_alerts'); - - if ($copy_modules) { - $target_modules = (array) get_parameter ('target_modules', array ()); - if (empty ($target_modules)) { - echo '

'.__('No modules have been selected').'

'; - return false; - } - - process_sql ('SET AUTOCOMMIT = 0'); - process_sql ('START TRANSACTION'); - $error = false; - $alerts = array (); - foreach ($destiny_id_agents as $id_destiny_agent) { - foreach ($target_modules as $id_agent_module) { - $result = copy_agent_module_to_agent ($id_agent_module, - $id_destiny_agent); - - if ($result === false) { - $error = true; - break; - } - - $id_destiny_module = $result; - if (! isset ($alerts[$id_agent_module])) - $alerts[$id_agent_module] = get_alerts_agent_module ($id_agent_module, - true); - - if ($alerts[$id_agent_module] === false) - continue; - - if ($copy_alerts) { - foreach ($alerts[$id_agent_module] as $alert) { - $result = copy_alert_agent_module_to_agent_module ($alert['id'], - $id_destiny_module); - if ($result === false) { - $error = true; - break; - } - } - } - } - if ($error) - break; - } - - if ($error) { - echo '

'.__('There was an error copying the agent configuration, the copy has been cancelled').'

'; - process_sql ('ROLLBACK'); - } else { - echo '

'.__('Successfully copied').'

'; - process_sql ('COMMIT'); - } - process_sql ('SET AUTOCOMMIT = 1'); - } -} - $source_id_group = (int) get_parameter ('source_id_group'); $source_id_agent = (int) get_parameter ('source_id_agent'); $destiny_id_group = (int) get_parameter ('destiny_id_group'); @@ -133,12 +64,12 @@ $table->data[0][1] = print_select ($groups, 'source_id_group', $source_id_group, false, '', '', true); $table->data[0][2] = __('Agent'); $table->data[0][2] .= ' '; $table->data[0][3] = print_select (get_group_agents ($source_id_group, false, "none"), 'source_id_agent', $source_id_agent, false, __('Select'), 0, true); -echo '
'; +echo ''; echo '
'; echo ''.__('Source'); @@ -156,22 +87,22 @@ if ($source_id_agent) $modules = get_agent_modules ($source_id_agent, 'nombre'); $table->data['operations'][0] = __('Operations'); -$table->data['operations'][1] = ''; +$table->data['operations'][1] = ''; $table->data['operations'][1] .= print_checkbox ('copy_modules', 1, true, true); $table->data['operations'][1] .= print_label (__('Copy modules'), 'checkbox-copy_modules', true); $table->data['operations'][1] .= '
'; -$table->data['operations'][1] .= ''; +$table->data['operations'][1] .= ''; $table->data['operations'][1] .= print_checkbox ('copy_alerts', 1, true, true); $table->data['operations'][1] .= print_label (__('Copy alerts'), 'checkbox-copy_alerts', true); $table->data['operations'][1] .= ''; $table->data[1][0] = __('Modules'); -$table->data[1][1] = ''; +$table->data[1][1] = ''; $table->data[1][1] .= print_select ($modules, 'target_modules[]', 0, false, '', '', true, true); $table->data[1][1] .= ''; -$table->data[1][1] .= ''; +$table->data[1][1] .= ''; $table->data[1][1] .= ''.__('No modules for this agent').''; $table->data[1][1] .= ''; @@ -186,16 +117,16 @@ foreach ($agent_alerts as $alert) { $name .= ' ('.$modules[$alert['id_agent_module']].')'; $alerts[$alert['id']] = $name; } -$table->data[2][1] = ''; +$table->data[2][1] = ''; $table->data[2][1] .= print_select ($alerts, 'target_alerts[]', 0, false, '', '', true, true); $table->data[2][1] .= ''; -$table->data[2][1] .= ''; +$table->data[2][1] .= ''; $table->data[2][1] .= ''.__('No alerts for this agent').''; $table->data[2][1] .= ''; echo ''; @@ -213,7 +144,7 @@ $table->data[0][1] = print_select ($groups, 'destiny_id_group', $destiny_id_grou $table->data[1][0] = __('Agent'); $table->data[1][0] .= ''; $table->data[1][1] = print_select (get_group_agents ($destiny_id_group, false, "none"), 'destiny_id_agent[]', 0, false, '', '', true, true); @@ -229,13 +160,13 @@ print_submit_button (__('Go'), 'go', false, 'class="sub next"'); echo ''; echo ''; -echo ''; +echo ''; require_jquery_file ('form'); require_jquery_file ('pandora.controls'); ?> - diff --git a/pandora_console/godmode/setup/setup.php b/pandora_console/godmode/setup/setup.php index b4eab45a4f..31770abfbd 100644 --- a/pandora_console/godmode/setup/setup.php +++ b/pandora_console/godmode/setup/setup.php @@ -56,6 +56,7 @@ if ($update_settings) { $config["event_view_hr"] = (int) get_parameter ('event_view_hr', $config["event_view_hr"]); $config["style"] = substr ($config["style"], 0, strlen ($config["style"]) - 4); $config["https"] = (bool) get_parameter ('https', $config["https"]); + $config["compact_header"] = (bool) get_parameter ('compact_header', $config["compact_header"]); process_sql ("UPDATE tconfig SET VALUE='".$config["remote_config"]."' WHERE token = 'remote_config'"); process_sql ("UPDATE tconfig SET VALUE='".$config["block_size"]."' WHERE token = 'block_size'"); @@ -77,6 +78,7 @@ if ($update_settings) { process_sql ("UPDATE tconfig SET VALUE='".$config["event_view_hr"]."' WHERE token = 'event_view_hr'"); process_sql ("UPDATE tconfig SET VALUE='".$config["loginhash_pwd"]."' WHERE token = 'loginhash_pwd'"); process_sql ("UPDATE tconfig SET VALUE='".$config["https"]."' WHERE token = 'https'"); + process_sql ("UPDATE tconfig SET VALUE='".$config["compact_header"]."' WHERE token = 'compact_header'"); } echo "

".__('Setup')." > "; @@ -149,6 +151,9 @@ $table->data[18][1] = print_checkbox ('autoupdate', 1, $config["autoupdate"], tr $table->data[19][0] = __('Enforce https'); $table->data[19][1] = print_checkbox ('https', 1, $config["https"], true); +$table->data[20][0] = __('Compact CSS and JS into header'); +$table->data[20][1] = print_checkbox ('compact_header', 1, $config["compact_header"], true); + enterprise_hook ('load_snmpforward_enterprise'); echo '
'; @@ -158,10 +163,10 @@ echo '
'; print_submit_button (__('Update'), 'update_button', false, 'class="sub upd"'); echo '
'; echo '
'; -?> - - +require_css_file ("color-picker"); +require_jquery_file ("colorpicker"); +?> - - '; + '; if ($config["language"] != "en") { - //Load translated strings - echo ' - - '; + //Load translated strings - load them last so they overload all the objects + require_javascript_file ("time_".$config["language"]); + require_javascript_file ("date".$config["language"]); + require_javascript_file ("countdown_".$config["language"]); } $output .= "\n\t"; - if (!empty ($config['css'])) { - //We can't load empty and we loaded current style and ie - $loaded = array ('', $config["style"], 'ie'); - foreach ($config['css'] as $name => $filename) { - if (in_array ($name, $loaded)) - continue; - - array_push ($loaded, $name); + //Load CSS + if (empty ($config['css'])) { + $config['css'] = array (); //If it's empty, false or not init set array to empty just in case + } + + //Style should go first + $config['css'] = array_merge (array ($config['style'] => "include/styles/".$config['style'].".css", + "menu" => "include/styles/menu.css", + "tip", "include/styles/tip.css"), $config['css']); + + //We can't load empty and we loaded (conditionally) ie + $loaded = array ('', 'ie'); + foreach ($config['css'] as $name => $filename) { + if (in_array ($name, $loaded)) + continue; + + array_push ($loaded, $name); + if (!empty ($config["compact_header"])) { + $output .= ''; + } else { $output .= ''."\n\t"; } } + //End load CSS - if (!empty ($config['js'])) { - //Load other javascript - //We can't load empty and we loaded wz_jsgraphics and pandora - $loaded = array ('', 'pandora', 'date_'.$config['language'], - 'time_'.$config['language'], 'countdown_'.$config['language']); - foreach ($config['js'] as $name => $filename) { - if (in_array ($name, $loaded)) - continue; - - array_push ($loaded, $name); - $output .= ''."\n\t"; - - } + //Load JS + if (empty ($config['js'])) { + $config['js'] = array (); //If it's empty, false or not init set array to empty just in case } - if (!empty ($config['jquery'])) { - //Load jQuery - $loaded = array ('', 'pandora'); + //Pandora specific JavaScript should go first + $config['js'] = array_merge (array ("pandora" => "include/javascript/pandora.js"), $config['js']); - //Then add each script as necessary - foreach ($config['jquery'] as $name => $filename) { - if (in_array ($name, $loaded)) - continue; + //Load other javascript + //We can't load empty + $loaded = array (''); + foreach ($config['js'] as $name => $filename) { + if (in_array ($name, $loaded)) + continue; - array_push ($loaded, $name); + array_push ($loaded, $name); + if (!empty ($config["compact_header"])) { + $output .= ''; + } else { $output .= ''."\n\t"; } } + //End load JS + + //Load jQuery + if (empty ($config['jquery'])) { + $config['jquery'] = array (); //If it's empty, false or not init set array to empty just in case + } + //Pandora specific jquery should go first + $config['jquery'] = array_merge (array ("jquery" => "include/javascript/jquery.js", "pandora" => "include/javascript/jquery.pandora.js"), $config['jquery']); + + + //Then add each script as necessary + $loaded = array (''); + foreach ($config['jquery'] as $name => $filename) { + if (in_array ($name, $loaded)) + continue; + + array_push ($loaded, $name); + if (!empty ($config["compact_header"])) { + $output .= ''; + } else { + $output .= ''."\n\t"; + } + } + $output .= $string; return $output; diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 03b29db73a..df0767bc98 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -16,8 +16,6 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -@import url(menu.css); -@import url(tip.css); * { font-family: verdana, sans-serif; font-size: 8pt;