diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 91e44ee453..e0dded9d76 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,8 +1,22 @@ +2009-03-16 Evi Vanoost + + * general/logoff.php: Cleaned up invalid html + + * general/login_page.php: Clean up ampersands + + * include/functions_html.php: Fixes bug #2661439 + + * index.php: Style cleanup + + * godmode/modules/manage_network_templates.php: Export function + gives a CSV file of the templates. Import pending although you + can use it already to import back into pure SQL. + 2009-03-16 Jorge Gonzalez - * include/help/en/help_planned_downtime.php, - include/help/es/help_planned_downtime.php: Added more information - about the scheduled downtime. + * include/help/en/help_planned_downtime.php, + include/help/es/help_planned_downtime.php: Added more information + about the scheduled downtime. 2009-03-16 Esteban Sanchez diff --git a/pandora_console/general/login_page.php b/pandora_console/general/login_page.php index fc357f5cc7..28329f6f2a 100644 --- a/pandora_console/general/login_page.php +++ b/pandora_console/general/login_page.php @@ -20,7 +20,7 @@ $url = '?login=1'; //These variables come from index.php if (!empty ($page) && !empty ($sec)) { foreach ($_GET as $key => $value) { - $url .= '&'.$key.'='.$value; + $url .= '&'.$key.'='.$value; } } @@ -71,8 +71,11 @@ echo ' -
'.__('Your IP').': '.$config["remote_addr"].' -
- - '; +
'.__('Your IP').': '.$config["remote_addr"].'
+'; ?> + \ No newline at end of file diff --git a/pandora_console/general/logoff.php b/pandora_console/general/logoff.php index f96da1d977..1c4b834ced 100644 --- a/pandora_console/general/logoff.php +++ b/pandora_console/general/logoff.php @@ -16,27 +16,20 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ?> - -
-
-

-
-
- -
- - logo
- -
-
'); ?> +
+

+
+ +
+ '; + print_image ("images/pandora_logo.png", false, array ("alt" => "logo", "border" => 0)); + echo ' '.$pandora_version; + ?> + +
'; ?>
-
'.$REMOTE_ADDR.''; ?>
-
- - - - - + \ No newline at end of file diff --git a/pandora_console/godmode/modules/manage_network_templates.php b/pandora_console/godmode/modules/manage_network_templates.php index 67e9dcd371..0eddd436d4 100644 --- a/pandora_console/godmode/modules/manage_network_templates.php +++ b/pandora_console/godmode/modules/manage_network_templates.php @@ -18,7 +18,7 @@ // Load global vars -require("include/config.php"); +require_once ("include/config.php"); check_login (); @@ -29,67 +29,107 @@ if (! give_acl ($config['id_user'], 0, "PM")) { exit; } -if (isset($_GET["delete"])){ // if delete - $id_np = entrada_limpia ($_GET["delete"]); - $sql_delete= "DELETE FROM tnetwork_profile WHERE id_np = ".$id_np; - $result=mysql_query($sql_delete); - if (! $result) - echo "

".__('Not deleted. Error deleting data')."

"; - else - echo "

".__('Deleted successfully')."

"; +if (isset ($_POST["delete_profile"])) { // if delete + $id_np = (int) get_parameter_post ("delete_profile", 0); + $sql = sprintf ("DELETE FROM tnetwork_profile WHERE id_np = %d", $id_np); + $result = process_sql ($sql); + print_error_message ($result, __('Template successfully deleted'), __('Error deleting template')); +} + +if (isset ($_POST["export_profile"])) { + $id_np = (int) get_parameter_post ("export_profile", 0); + $profile_info = get_db_row ("tnetwork_profile", "id_np", $id_np); - $result=mysql_query($sql_delete); -} -echo "

".__('Module management')." > "; -echo __('Module template management')."

"; - - -$sql1='SELECT * FROM tnetwork_profile ORDER BY name'; -$result=mysql_query($sql1); -$color=0; -if (mysql_num_rows($result)) { - echo ""; - echo ""; - echo ""; - echo ""; -} -while ($row=mysql_fetch_array($result)){ - if ($color == 1){ - $tdcolor = "datos"; - $color = 0; + if (empty ($profile_info)) { + print_error_message (false,'', __('This template does not exist')); + return; + } + + //It's important to keep the structure and order in the same way for backwards compatibility. + $sql = sprintf ("SELECT components.name, components.description, components.type, components.max, components.min, components.module_interval, + components.tcp_port, components.tcp_send, components.tcp_rcv, components.snmp_community, components.snmp_oid, + components.id_module_group, components.id_modulo, components.plugin_user, components.plugin_pass, components.plugin_parameter, + components.max_timeout, components.history_data, components.min_warning, components.max_warning, components.min_critical, + components.max_critical, components.min_ff_event, comp_group.name AS group_name + FROM `tnetwork_component` AS components, tnetwork_profile_component AS tpc, tnetwork_component_group AS comp_group + WHERE tpc.id_nc = components.id_nc AND components.id_group = comp_group.id_sg AND tpc.id_np = %d", $id_np); + + $components = get_db_all_rows_sql ($sql); + + $row_names = array (); + $inv_names = array (); + //Find the names of the rows that we are getting and throw away the duplicate numeric keys + foreach ($components[0] as $row_name => $detail) { + if (is_numeric ($row_name)) { + $inv_names[] = $row_name; + } else { + $row_names[] = $row_name; } - else { - $tdcolor = "datos2"; - $color = 1; } - echo " - - - - - "; - + while (@ob_end_clean()); //Clean up output buffering + + //Send headers to tell the browser we're sending a file + header("Content-type: application/octet-stream"); + header("Content-Disposition: attachment; filename=".preg_replace ('/\s/', '_', $profile_info["name"]).".csv"); + header("Pragma: no-cache"); + header("Expires: 0"); + + //Then print the first line (row names) + echo '"'.implode ('","', $row_names).'"'; + echo "\n"; + + //Then print the rest of the data. Encapsulate in quotes in case we have comma's in any of the descriptions + foreach ($components as $row) { + foreach ($inv_names as $bad_key) { + unset ($row[$bad_key]); + } + echo '"'.implode ('","', $row).'"'; + echo "\n"; + } + exit; //We're done here. The original page will still be there. } -if (mysql_num_rows($result)) { - echo "
".__('Name')."".__('Description')."".__('Action')."
- ".$row["name"]." - - ".$row["description"]." - - - -
"; - echo ""; + +echo "

".__('Module management')." > ".__('Module template management')."

"; + +$result = get_db_all_rows_in_table ("tnetwork_profile", "name"); + +$table->cellpadding = 4; +$table->cellspacing = 4; +$table->width = "95%"; +$table->class = "databox"; + +$table->head = array (); +$table->head[0] = __('Name'); +$table->head[1] = __('Description'); +$table->head[2] = __('Action'); + +$table->align = array (); +$table->align[2] = "center"; + +$table->data = array (); + +foreach ($result as $row) { + $data = array (); + $data[0] = ''.safe_input ($row["name"]).''; + $data[1] = safe_input ($row["description"]); + $data[2] = print_input_image ("delete_profile", "images/cross.png", $row["id_np"],'', true, array ('onclick' => 'if (!confirm(\''.__('Are you sure?').'\')) return false;', 'border' => 0)); + $data[2] .= print_input_image ("export_profile", "images/lightning_go.png", $row["id_np"], '', true, array ('border' => 0)); + + array_push ($table->data, $data); +} + +if (!empty ($table->data)) { + echo ''; + print_table ($table); + echo ''; } else { - echo "
".__('There are no defined network profiles')."
"; - echo "
"; + echo '
'.__('There are no defined network profiles').'
'; } +unset ($table); -echo "
"; -echo "
"; -echo ""; -echo "
"; +echo '
'; +echo '
'; +print_submit_button (__('Create'), "crt", '', 'class="sub next"'); +echo '
'; ?> diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index dc817c3632..3dfe945bba 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -41,14 +41,15 @@ function print_select ($fields, $name, $selected = '', $script = '', $nothing = static $idcounter = array (); - //If duplicate names exist, it will start numbering. Otherwise it won't (for backwards compatibility) + //If duplicate names exist, it will start numbering. Otherwise it won't if (isset ($idcounter[$name])) { $idcounter[$name]++; - $name = $name.'-'.$idcounter[$name]; } else { $idcounter[$name] = 0; } + $id = preg_replace('/[^a-z0-9\:\;\-\_]/i', '', $name.$idcounter[$name]); + $attributes = ""; if (!empty ($script)) { $attributes .= ' onchange="'.$script.'"'; @@ -63,7 +64,7 @@ function print_select ($fields, $name, $selected = '', $script = '', $nothing = $attributes .= ' disabled="disabled"'; } - $output .= ''; if ($nothing != '' || empty ($fields)) { if ($nothing == '') { @@ -284,13 +285,11 @@ function print_input_image ($name, $src, $value, $style = '', $return = false, $ foreach ($attrs as $attribute) { if (isset ($options[$attribute])) { - $output .= $attribute.'="'.safe_input ($options[$attribute]).'" '; + $output .= ' '.$attribute.'="'.safe_input ($options[$attribute]).'"'; } } - $output .= 'value="'.$value; - - $output .= '" />'; + $output .= ' value="'.$value.'" />'; if ($return) return $output; @@ -697,16 +696,17 @@ function print_checkbox_extended ($name, $value, $checked, $disabled, $script, $ //If duplicate names exist, it will start numbering. Otherwise it won't if (isset ($idcounter[$name])) { $idcounter[$name]++; - $name = $name.$idcounter[$name]; } else { $idcounter[$name] = 0; } - + + $id = preg_replace('/[^a-z0-9\:\;\-\_]/i', '', $name.$idcounter[$name]); + $output = '".__('Attachment directory is not writtable by HTTP Server').""; - echo '

'; - echo __('Please check that {HOMEDIR}/attachment directory has write rights for HTTP server'); - echo "

"; +if (!is_writable ("attachment")){ + echo '

'.__('Attachment directory is not writable by HTTP Server').'

'; + echo '

'.__('Please check that the web server has write rights on the {HOMEDIR}/attachment directory').'

'; } // Page loader / selector