From 659a08125fddef1e932cdc366d31ded210d59185 Mon Sep 17 00:00:00 2001 From: Esteban Sanchez Date: Thu, 19 Feb 2009 16:10:04 +0000 Subject: [PATCH] 2009-02-19 Esteban Sanchez * include/functions_ui.php: Added require_css_file(), require_javascript_file() and require_jquery_file() to add CSS, javascript and jQuery files to the header easily without changing config object. A path parameter is addded to allow the use on enterprise code. * include/functions_db.php: Added get_db_value_filter(), get_db_all_rows_filter() and process_sql_delete(). Fixed delete_agent() style and use these functions. Added process_page_head() from functions_ui.php and changed a bit the config javascript object part. * include/functions_custom_graphs.php: Get results indexed by id on get_user_custom_graphs(). * include/functions.php: Moved process_page_head to functions_ui.php. * godmode/agentes/manage_delete.php: New interface to perform massive agents deletion. * godmode/menu.php: Added new option to massive agents deletion. * general/main_menu.php, godmode/agentes/manage_config.php, godmode/agentes/module_manager_editor.php, godmode/agentes/planned_downtime.php, godmode/alerts/alert_compounds.php, godmode/alerts/alert_list.php, godmode/alerts/configure_alert_compound.php, godmode/alerts/configure_alert_template.php, godmode/reporting/map_builder.php, operation/agentes/networkmap.php, operation/reporting/reporting_viewer.php, operation/visual_console/render_view.php: Use new functions in include CSS and javascript files. * index.php: Bit of style when printing the header so the HTML can be readed easily in a editor. * include/javascript/pandora.js: Added a variable to determine the enterprise directory. * include/styles/pandora.css: Added style for manage_delete.php git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1467 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 43 ++++ pandora_console/general/header.php | 2 +- pandora_console/general/main_menu.php | 2 +- .../godmode/agentes/manage_config.php | 6 +- .../godmode/agentes/manage_delete.php | 121 +++++++++ .../godmode/agentes/module_manager_editor.php | 5 +- .../godmode/agentes/planned_downtime.php | 8 +- .../godmode/alerts/alert_compounds.php | 2 +- pandora_console/godmode/alerts/alert_list.php | 7 +- .../alerts/configure_alert_compound.php | 12 +- .../alerts/configure_alert_template.php | 8 +- pandora_console/godmode/menu.php | 2 + .../godmode/reporting/map_builder.php | 13 +- pandora_console/include/functions.php | 133 ---------- .../include/functions_custom_graphs.php | 2 +- pandora_console/include/functions_db.php | 217 ++++++++++++---- pandora_console/include/functions_ui.php | 234 ++++++++++++++++++ pandora_console/include/javascript/pandora.js | 2 + pandora_console/include/styles/pandora.css | 3 +- pandora_console/index.php | 9 +- .../operation/agentes/networkmap.php | 4 +- .../operation/reporting/reporting_viewer.php | 8 +- .../operation/visual_console/render_view.php | 4 +- 23 files changed, 620 insertions(+), 227 deletions(-) create mode 100644 pandora_console/godmode/agentes/manage_delete.php diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 70ca34f050..2c02fedafd 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,46 @@ +2009-02-19 Esteban Sanchez + + * include/functions_ui.php: Added require_css_file(), + require_javascript_file() and require_jquery_file() to add CSS, + javascript and jQuery files to the header easily without changing + config object. A path parameter is addded to allow the use on + enterprise code. + + * include/functions_db.php: Added + get_db_value_filter(), get_db_all_rows_filter() and + process_sql_delete(). Fixed delete_agent() style and use these + functions. Added process_page_head() from functions_ui.php and changed + a bit the config javascript object part. + + * include/functions_custom_graphs.php: Get results indexed by id on + get_user_custom_graphs(). + + * include/functions.php: Moved process_page_head to functions_ui.php. + + * godmode/agentes/manage_delete.php: New interface to perform massive + agents deletion. + + * godmode/menu.php: Added new option to massive agents deletion. + + * general/main_menu.php, godmode/agentes/manage_config.php, + godmode/agentes/module_manager_editor.php, + godmode/agentes/planned_downtime.php, + godmode/alerts/alert_compounds.php, godmode/alerts/alert_list.php, + godmode/alerts/configure_alert_compound.php, + godmode/alerts/configure_alert_template.php, + godmode/reporting/map_builder.php, operation/agentes/networkmap.php, + operation/reporting/reporting_viewer.php, + operation/visual_console/render_view.php: Use new functions in include + CSS and javascript files. + + * index.php: Bit of style when printing the header so the HTML can be + readed easily in a editor. + + * include/javascript/pandora.js: Added a variable to determine the + enterprise directory. + + * include/styles/pandora.css: Added style for manage_delete.php + 2009-02-18 Esteban Sanchez * godmode/agentes/alert_manager.php: Removed from repository. Agent diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php index d29ccd6e39..5b5fd5c080 100644 --- a/pandora_console/general/header.php +++ b/pandora_console/general/header.php @@ -95,7 +95,7 @@ echo '
Pandora FMS
'; -$config['jquery'][] = 'countdown'; +require_jquery_file ('countdown'); ?> diff --git a/pandora_console/godmode/agentes/module_manager_editor.php b/pandora_console/godmode/agentes/module_manager_editor.php index 4675806f61..1522ac3523 100644 --- a/pandora_console/godmode/agentes/module_manager_editor.php +++ b/pandora_console/godmode/agentes/module_manager_editor.php @@ -220,8 +220,9 @@ if ($id_agent_module) { } echo ''; echo ''; -$config['jquery'][] = 'ui'; -$config['jquery'][] = 'form'; + +require_jquery_file ('ui'); +require_jquery_file ('form'); ?> diff --git a/pandora_console/godmode/alerts/configure_alert_template.php b/pandora_console/godmode/alerts/configure_alert_template.php index 622e331923..ec9c7681f5 100644 --- a/pandora_console/godmode/alerts/configure_alert_template.php +++ b/pandora_console/godmode/alerts/configure_alert_template.php @@ -502,11 +502,9 @@ if ($step >= LAST_STEP) { echo ''; echo ''; -$config['jquery'][] = 'ui.core'; -$config['jquery'][] = 'timeentry'; -$config['jquery'][] = 'ui.core'; -$config['js'][] = 'pandora_alerts'; - +require_jquery_file ('ui.core'); +require_jquery_file ('timeentry'); +require_javascript_file ('pandora_alerts'); ?> - - - - - '; - - if (!empty ($config['css'])) { - $loaded = array ('', $config["style"], 'ie'); //We can't load empty and we loaded current style and ie - foreach ($config['css'] as $style) { - if (in_array ($style, $loaded)) { - continue; - } - array_push ($loaded, $style); - $output .= ''."\n"; - } - } - - if (!empty ($config['js'])) { - //Load other javascript - $loaded = array ('', 'pandora', 'date_'.$config['language'], 'time_'.$config['language'], 'countdown_'.$config['language']); //We can't load empty and we loaded wz_jsgraphics and pandora - foreach ($config['js'] as $javascript) { - if (in_array ($javascript, $loaded)) { - continue; - } - array_push ($loaded, $javascript); - $output .= ''."\n"; - - } - } - - if (!empty ($config['jquery'])) { - //Load jQuery - $loaded = array ('', 'pandora'); //We automagically load pandora and jquery - - //Then add each script as necessary - foreach ($config['jquery'] as $script) { - if (in_array ($script, $loaded)) { - continue; - } - array_push ($loaded, $script); - $output .= ''; - } - } - - $output .= $string; - - return $output; -} - -/** - * Callback function to add stuff to the body - * - * @param string Callback will fill this with the current buffer. - * @param bitfield Callback will fill this with a bitfield (see ob_start) - * - * @return string String to return to the browser - */ -function process_page_body ($string, $bitfield) { - global $config; - - // Show custom background - if ($config["pure"] == 0) { - $output = ''; - } else { - $output = ''; //Don't enforce a white background color. Let user style sheet do that - } - - $output .= $string; - - $output .= ''; - - return $output; -} ?> diff --git a/pandora_console/include/functions_custom_graphs.php b/pandora_console/include/functions_custom_graphs.php index 18f234aa68..9b2fc0be2a 100644 --- a/pandora_console/include/functions_custom_graphs.php +++ b/pandora_console/include/functions_custom_graphs.php @@ -45,7 +45,7 @@ function get_user_custom_graphs ($id_user = 0, $only_names = false) { if ($only_names) { $graphs[$graph['id_graph']] = $graph['name']; } else { - array_push ($graphs, $graph); + $graphs[$graph['id_graph']] = $graph; } } diff --git a/pandora_console/include/functions_db.php b/pandora_console/include/functions_db.php index 512ae11fed..0550961636 100644 --- a/pandora_console/include/functions_db.php +++ b/pandora_console/include/functions_db.php @@ -1454,6 +1454,50 @@ function get_db_value ($field, $table, $field_search = 1, $condition = 1) { return $result[0][$field]; } +/** + * Get the first value of the first row of a table in the database from an + * array with filter conditions. + * + * Example: + +get_db_value_filter ('name', 'talert_templates', + array ('value' => 2, 'type' => 'equal')); +// Equivalent to: +// SELECT name FROM talert_templates WHERE value = 2 AND type = 'equal' LIMIT 1 + +get_db_value_filter ('description', 'talert_templates', + array ('name' => 'My alert', 'type' => 'regex'), 'OR'); +// Equivalent to: +// SELECT description FROM talert_templates WHERE name = 'My alert' OR type = 'equal' LIMIT 1 + + * + * @param string Field name to get + * @param string Table to retrieve the data + * @param array Conditions to filter the element. See format_array_to_where_clause_sql() + * for the format + * @param string Join operator for the elements in the filter. + * + * @return mixed Value of first column of the first row. False if there were no row. + */ +function get_db_value_filter ($field, $table, $filter, $join = 'AND') { + if (! is_array ($filter) || empty ($filter)) + return false; + + /* Avoid limit and offset if given */ + unset ($filter['limit']); + unset ($filter['offset']); + + $sql = sprintf ("SELECT %s FROM %s WHERE %s LIMIT 1", + $field, $table, + format_array_to_where_clause_sql ($filter, $join)); + $result = get_db_all_rows_sql ($sql); + + if ($result === false) + return false; + + return $result[0][$field]; +} + /** * Get the first row of an SQL database query. * @@ -1533,6 +1577,22 @@ function get_db_all_rows_sql ($sql) { return false; } +function get_db_all_rows_filter ($table, $filter, $fields = false) { + if (empty ($fields)) { + $fields = '*'; + } else { + if (is_array ($fields)) + $fields = implode (',', $fields); + else if (! is_string ($fields)) + return false; + } + + $sql = sprintf ('SELECT %s FROM %s WHERE %s', + $fields, $table, format_array_to_where_clause_sql ($filter)); + + return get_db_all_rows_sql ($sql); +} + /** * Error handler function when an SQL error is triggered. * @@ -1722,7 +1782,7 @@ function format_array_to_update_sql ($values) { $values['name'] = "Name"; $values['description'] = "Long description"; $values['limit'] = $config['block_size']; // Assume it's 20 - $sql = 'SELECT * FROM table WHERE '.format_array_to_where_sql ($values); + $sql = 'SELECT * FROM table WHERE '.format_array_to_where_clause_sql ($values); echo $sql; * Will return: @@ -1780,7 +1840,7 @@ function format_array_to_where_clause_sql ($values, $join = 'AND') { } if ($i < $max) { - $query .= $join; + $query .= ' '.$join.' '; } $i++; } @@ -2267,52 +2327,62 @@ function server_status ($id_server) { * @return bool False if error, true if success. */ function delete_agent ($id_agents) { - //Init vars - $errors = 0; + global $config; + + $error = false; //Subfunciton for less typing /** * @ignore */ function temp_sql_delete ($table, $row, $value) { - global $errors; //Globalize the errors variable - $sql = sprintf ("DELETE FROM %s WHERE %s = %s", $table, $row, $value); - $result = process_sql ($sql); - if ($result === false) - $errors++; + global $error; //Globalize the errors variable + $result = process_sql_delete ($table, $row.' = '.$value); + if ($result === false) { + $error = true; + echo $table, $row.' = '.$value; + } } //Convert single values to an array - if (!is_array ($id_agents)) { - $id_agents[0] = (int) $id_agents; - } + if (! is_array ($id_agents)) + $id_agents = (array) $id_agents; //Start transaction process_sql ("SET AUTOCOMMIT = 0;"); $trerr = process_sql ("START TRANSACTION;"); - if ($trerr === false) { - echo "Error starting transaction"; + if ($trerr === false) return false; - } foreach ($id_agents as $id_agent) { $id_agent = (int) $id_agent; //Cast as integer - $agent_name = get_agent_name ($id_agent); if ($id_agent < 1) - continue; //If an agent is not an integer or invalid, don't process it - + continue; + + /* Check for deletion permissions */ + $id_group = get_agent_group ($id_agent); + if (! give_acl ($config['id_user'], $id_group, "AW")) { + process_sql ("ROLLBACK;"); + process_sql ("SET AUTOCOMMIT = 1;"); + return false; + } + //A variable where we store that long subquery thing for //modules - $tmodbase = "ANY(SELECT id_agente_modulo FROM tagente_modulo WHERE id_agente = ".$id_agent.")"; + $where_modules = "ANY(SELECT id_agente_modulo FROM tagente_modulo WHERE id_agente = ".$id_agent.")"; //IP address - $sql = sprintf ("SELECT id_ag FROM taddress_agent, taddress WHERE taddress_agent.id_a = taddress.id_a AND id_agent = %d", $id_agent); - $result = get_db_all_rows_sql ($sql); + $sql = sprintf ("SELECT id_ag FROM taddress_agent, taddress + WHERE taddress_agent.id_a = taddress.id_a + AND id_agent = %d", + $id_agent); + $addresses = get_db_all_rows_sql ($sql); - if ($result) - foreach ($result as $row) { - temp_sql_delete ("taddress_agent", "id_ag", $row["id_ag"]); + if ($addresses === false) + $addresses = array (); + foreach ($addresses as $address) { + temp_sql_delete ("taddress_agent", "id_ag", $address["id_ag"]); } // We cannot delete tagente_datos and tagente_datos_string here @@ -2321,53 +2391,58 @@ function delete_agent ($id_agents) { // daily maintance process, all data for that modules are deleted //Alert - /* TODO: Compound alert */ - //temp_sql_delete ("tcompound_alert", "id_aam", "ANY(SELECT id_aam FROM talerta_agente_modulo WHERE id_agent = ".$id_agent.")"); - temp_sql_delete ("talert_template_modules", "id_agent_module", $tmodbase); + temp_sql_delete ("talert_compound", "id_agent", $id_agent); + temp_sql_delete ("talert_template_modules", "id_agent_module", $where_modules); //Events (up/down monitors) temp_sql_delete ("tevento", "id_agente", $id_agent); //Graphs, layouts & reports - temp_sql_delete ("tgraph_source", "id_agent_module", $tmodbase); - temp_sql_delete ("tlayout_data", "id_agente_modulo", $tmodbase); - temp_sql_delete ("treport_content", "id_agent_module", $tmodbase); + temp_sql_delete ("tgraph_source", "id_agent_module", $where_modules); + temp_sql_delete ("tlayout_data", "id_agente_modulo", $where_modules); + temp_sql_delete ("treport_content", "id_agent_module", $where_modules); //Planned Downtime temp_sql_delete ("tplanned_downtime_agents", "id_agent", $id_agent); //The status of the module - temp_sql_delete ("tagente_estado", "id_agente_modulo", $tmodbase); + temp_sql_delete ("tagente_estado", "id_agente_modulo", $where_modules); //The actual modules, don't put anything based on //tagente_modulo after this temp_sql_delete ("tagente_modulo", "id_agente", $id_agent); - process_sql ('UPDATE tagente_modulo SET delete_pending = 1, disabled = 1 WHERE id_agente = '. $id_agent); + process_sql_update ('tagente_modulo', + array ('delete_pending' => 1, 'disabled' => 1), + 'id_agente = '. $id_agent); //Access entries temp_sql_delete ("tagent_access", "id_agent", $id_agent); //tagente_datos_inc - temp_sql_delete ("tagente_datos_inc", "id_agente_modulo", $tmodbase); + temp_sql_delete ("tagente_datos_inc", "id_agente_modulo", $where_modules); + // Delete remote configuration + if (isset ($config["remote_config"])) { + $agent_md5 = md5 (get_agent_name ($id_agent), FALSE); + if (file_exists ($config["remote_config"]."/".$agent_md5.".md5")) { + // Agent remote configuration editor + $file_name = $config["remote_config"]."/".$agent_md5.".conf"; + @unlink ($file_name); + $file_name = $config["remote_config"]."/".$agent_md5.".md5"; + @unlink ($file_name); + } + } + //And at long last, the agent temp_sql_delete ("tagente", "id_agente", $id_agent); - // Delete remote configuration - $agent_md5 = md5($agent_name, FALSE); - - if (isset($config["remote_config"])) - if (file_exists($config["remote_config"] . "/" . $agent_md5 . ".md5")) { - // Agent remote configuration editor - $file_name = $config["remote_config"] . "/" . $agent_md5 . ".conf"; - unlink ($file_name); - $file_name = $config["remote_config"] . "/" . $agent_md5 . ".md5"; - unlink ($file_name); - } + /* Break the loop on error */ + if ($error) + break; } - - if ($errors > 0) { + + if ($error) { process_sql ("ROLLBACK;"); process_sql ("SET AUTOCOMMIT = 1;"); return false; @@ -2581,7 +2656,7 @@ function process_sql_insert ($table, $values) { } /** - * Inserts strings into database + * Updates a database record. * * All values should be cleaned before passing. Quoting isn't necessary. * Examples: @@ -2642,4 +2717,52 @@ function process_sql_update ($table, $values, $where = false, $where_join = 'AND return process_sql ($query); } + +/** + * Delete database records. + * + * All values should be cleaned before passing. Quoting isn't necessary. + * Examples: + * + * +process_sql_delete ('table', array ('id' => 1)); +// DELETE FROM table WHERE id = 1 +process_sql_delete ('table', array ('id' => 1, 'name' => 'example')); +// DELETE FROM table WHERE id = 1 AND name = 'example' +process_sql_delete ('table', array ('id' => 1, 'name' => 'example'), 'OR'); +// DELETE FROM table WHERE id = 1 OR name = 'example' +process_sql_delete ('table', 'id in (1, 2, 3) OR id > 10'); +// DELETE FROM table WHERE id in (1, 2, 3) OR id > 10 + * + * + * @param string Table to insert into + * @param array An associative array of values to update + * @param mixed An associative array of field and value matches. Will be joined + * with operator specified by $where_join. A custom string can also be provided. + * If nothing is provided, the update will affect all rows. + * @param string When a $where parameter is given, this will work as the glue + * between the fields. "AND" operator will be use by default. Other values might + * be "OR", "AND NOT", "XOR" + * + * @return mixed False in case of error or invalid values passed. Affected rows otherwise + */ +function process_sql_delete ($table, $where, $where_join = 'AND') { + if (empty ($where)) + /* Should avoid any mistake that lead to deleting all data */ + return false; + + $query = sprintf ("DELETE FROM `%s` WHERE ", $table); + + if ($where) { + if (is_string ($where)) { + /* FIXME: Should we clean the string for sanity? + Who cares if this is deleting data... */ + $query .= $where; + } else if (is_array ($where)) { + $query .= format_array_to_where_clause_sql ($where); + } + } + + return process_sql ($query); +} ?> diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index ae585cf9df..78cf647e38 100644 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -413,4 +413,238 @@ function print_help_icon ($help_id, $return = false) { return $output; } + +/** + * Add a CSS file to the HTML head tag. + * + * To make a CSS file available just put it in include/styles. The + * file name should be like "name.css". The "name" would be the value + * needed to pass to this function. + + * @param string Script name to add without the "jquery." prefix and the ".js" + * suffix. Example: + +require_css_file ('pandora'); +// Would include include/styles/pandora.js + + * + * @return bool True if the file was added. False if the file doesn't exist. + */ +function require_css_file ($name, $path = 'include/styles/') { + global $config; + + $filename = $path.$name.'.css'; + + if (! isset ($config['css'])) + $config['css'] = array (); + if (isset ($config['css'][$name])) + return true; + if (! file_exists ($filename) && ! file_exists ($config['homedir'].'/'.$filename)) + return false; + $config['css'][$name] = $filename; + return true; +} + +/** + * Add a javascript file to the HTML head tag. + * + * To make a javascript file available just put it in include/javascript. The + * file name should be like "name.js". The "name" would be the value + * needed to pass to this function. + + * @param string Script name to add without the "jquery." prefix and the ".js" + * suffix. Example: + +require_javascript_file ('pandora'); +// Would include include/javascript/pandora.js + + * + * @return bool True if the file was added. False if the file doesn't exist. + */ +function require_javascript_file ($name, $path = 'include/javascript/') { + global $config; + + $filename = $path.$name.'.js'; + + if (! isset ($config['js'])) + $config['js'] = array (); + if (isset ($config['js'][$name])) + return true; + /* We checks two paths because it may fails on enterprise */ + if (! file_exists ($filename) && ! file_exists ($config['homedir'].'/'.$filename)) + return false; + $config['js'][$name] = $filename; + return true; +} + +/** + * Add a jQuery file to the HTML head tag. + * + * To make a jQuery script available just put it in include/javascript. The + * file name should be like "jquery.name.js". The "name" would be the value + * needed to pass to this function. Notice that this function does not manage + * jQuery denpendencies. + + * @param string Script name to add without the "jquery." prefix and the ".js" + * suffix. Example: + +require_jquery_file ('form'); +// Would include include/javascript/jquery.form.js + + * + * @return bool True if the file was added. False if the file doesn't exist. + */ +function require_jquery_file ($name, $path = 'include/javascript/') { + global $config; + + $filename = $path.'jquery.'.$name.'.js'; + + if (! isset ($config['jquery'])) + $config['jquery'] = array (); + if (isset ($config['jquery'][$name])) + return true; + /* We checks two paths because it may fails on enterprise */ + if (! file_exists ($filename) && ! file_exists ($config['homedir'].'/'.$filename)) + return false; + + $config['jquery'][$name] = $filename; + return true; +} + +/** + * Callback function to add stuff to the head. This allows us to add scripts + * to the header after the fact as well as extensive validation. + * + * DO NOT CALL print_f, echo, ob_start, ob_flush, ob_end functions here. + * + * To add css just put them in include/styles and then add them to the + * $config['css'] array + * + * @param string Callback will fill this with the current buffer. + * @param bitfield Callback will fill this with a bitfield (see ob_start) + * + * @return string String to return to the browser + */ +function process_page_head ($string, $bitfield) { + global $config; + $output = ''; + + if ($config["refr"] > 0) { + // Agent selection filters and refresh + $query = 'http' . (isset ($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == TRUE ? 's': '') . '://' . $_SERVER['SERVER_NAME']; + if ($_SERVER['SERVER_PORT'] != 80 && (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == TRUE && $_SERVER['SERVER_PORT'] != 443)) { + $query .= ":" . $_SERVER['SERVER_PORT']; + } + $query .= $_SERVER['SCRIPT_NAME']; + + if (sizeof ($_REQUEST)) + //Some (old) browsers don't like the ?&key=var + $query .= '?1=1'; + + //We don't clean these variables up as they're only being passed along + foreach ($_GET as $key => $value) { + /* Avoid the 1=1 */ + if ($key == 1) + continue; + $query .= '&'.$key.'='.$value; + } + foreach ($_POST as $key => $value) { + $query .= '&'.$key.'='.$value; + } + + $output .= ''; + } + $output .= "\n\t"; + $output .= 'Pandora FMS - '.__('the Flexible Monitoring System').' + + + + + + + + + + + + + + + + + + '."\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); + $output .= ''."\n\t"; + } + } + + 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"; + + } + } + + if (!empty ($config['jquery'])) { + //Load jQuery + $loaded = array ('', 'pandora'); + + //Then add each script as necessary + foreach ($config['jquery'] as $name => $filename) { + if (in_array ($name, $loaded)) + continue; + + array_push ($loaded, $name); + $output .= ''."\n\t"; + } + } + + $output .= $string; + + return $output; +} + +/** + * Callback function to add stuff to the body + * + * @param string Callback will fill this with the current buffer. + * @param bitfield Callback will fill this with a bitfield (see ob_start) + * + * @return string String to return to the browser + */ +function process_page_body ($string, $bitfield) { + global $config; + + // Show custom background + if ($config["pure"] == 0) { + $output = ''; + } else { + $output = ''; //Don't enforce a white background color. Let user style sheet do that + } + + $output .= $string; + + $output .= ''; + + return $output; +} ?> diff --git a/pandora_console/include/javascript/pandora.js b/pandora_console/include/javascript/pandora.js index 678ba882b0..b8a0befa1a 100644 --- a/pandora_console/include/javascript/pandora.js +++ b/pandora_console/include/javascript/pandora.js @@ -1,3 +1,5 @@ +var ENTERPRISE_DIR = 'enterprise'; + /* Function to hide/unhide a specific Div id */ function toggleDiv (divid){ if (document.getElementById(divid).style.display == 'none') { diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 3ee74c1339..993bed5509 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -761,7 +761,8 @@ table#source_table select, table#destiny_table select, table#target_table select, table#filter_compound_table select, -table#filter_compound_table #text-search { +table#filter_compound_table #text-search, +table#delete_table select { width: 100%; } table#simple select#network_component_group, diff --git a/pandora_console/index.php b/pandora_console/index.php index 2aee7ce05a..99056d65fa 100644 --- a/pandora_console/index.php +++ b/pandora_console/index.php @@ -98,7 +98,9 @@ if (!empty ($config["https"]) && empty ($_SERVER['HTTPS'])) { } -echo ''; +echo ''."\n"; +echo ''."\n"; +echo ''; //This starts the page head. In the call back function, things from $page['head'] array will be processed into the head ob_start ('process_page_head'); // Pure mode (without menu, header and footer). @@ -108,10 +110,9 @@ $config["pure"] = (bool) get_parameter ("pure"); $config["refr"] = (int) get_parameter ("refr"); enterprise_include ('index.php'); -enterprise_hook ('load_html_header'); //This tag is included in the buffer passed to process_page_head so technically it can be stripped -echo ''; +echo ''."\n"; ob_start ('process_page_body'); @@ -247,4 +248,4 @@ if ($config["pure"] == 0) { echo ''; //container div while (@ob_end_flush ()); echo ''; -?> \ No newline at end of file +?> diff --git a/pandora_console/operation/agentes/networkmap.php b/pandora_console/operation/agentes/networkmap.php index 78905fb08b..1761cbc3b3 100644 --- a/pandora_console/operation/agentes/networkmap.php +++ b/pandora_console/operation/agentes/networkmap.php @@ -387,8 +387,8 @@ if ($result !== false) { return; } -$config['css'][] = 'cluetip'; -$config['jquery'][] = 'cluetip'; +require_css_file ('cluetip'); +require_jquery_file ('cluetip'); ?>