diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index dd8adc868e..ff423aebc9 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,22 @@ +2009-02-20 Evi Vanoost + + * pandoradb_migrate_20_to_21.sql, pandoradb.sql: Fixed going up/down + strings + + * godmode/setup/setup.php: Fixed event hours display + + * operation/events/events.php: Fixed several major bugs with pagination + and the new event types. + + * include/functions.php, include/functions_ui.php, + include/functions_html.php: Moved pagination and print_help_tip to + functions_ui.php. Repeat id's are now fixed backwards compatible. + Also fixed a bug in print_select where type comparisons against would + fail since PHP evaluates strings to (int) 0 + + * include/functions_events.php: Added print_event_type_img () and altered + the other functions to work with it + 2009-02-20 Esteban Sanchez * styles/pandora.css: Added input.add to a list which was missing. diff --git a/pandora_console/godmode/setup/setup.php b/pandora_console/godmode/setup/setup.php index c99e96fa09..b4eab45a4f 100644 --- a/pandora_console/godmode/setup/setup.php +++ b/pandora_console/godmode/setup/setup.php @@ -129,27 +129,26 @@ $table->data[13][1] = print_select ($file_styles, 'style', $config["style"], '', $table->data[14][0] = __('Block size for pagination'); $table->data[14][1] = print_input_text ('block_size', $config["block_size"], '', 5, 5, true); -$table->data[14][0] = __('Default hours for event view'); -$table->data[14][1] = print_input_text ('event_view_hr', $config["event_view_hr"], '', 5, 5, true); +$table->data[15][0] = __('Default hours for event view'); +$table->data[15][1] = print_input_text ('event_view_hr', $config["event_view_hr"], '', 5, 5, true); -$table->data[15][0] = __('Timestamp or time comparation') . pandora_help ("time_stamp-comparation", true); -$table->data[15][1] = __('Comparation in rollover').' '; -$table->data[15][1] .= print_radio_button ('prominent_time', "timestamp", '', $config["prominent_time"], true); -$table->data[15][1] .= '
'.__('Timestamp in rollover').' '; -$table->data[15][1] .= print_radio_button ('prominent_time', "comparation", '', $config["prominent_time"], true); +$table->data[16][0] = __('Timestamp or time comparation') . pandora_help ("time_stamp-comparation", true); +$table->data[16][1] = __('Comparation in rollover').' '; +$table->data[16][1] .= print_radio_button ('prominent_time', "timestamp", '', $config["prominent_time"], true); +$table->data[16][1] .= '
'.__('Timestamp in rollover').' '; +$table->data[16][1] .= print_radio_button ('prominent_time', "comparation", '', $config["prominent_time"], true); -$table->data[16][0] = __('Time source') . pandora_help ("timesource", true); +$table->data[17][0] = __('Time source') . pandora_help ("timesource", true); $sources["system"] = __('System'); $sources["sql"] = __('Database'); -$table->data[16][1] = print_select ($sources, 'timesource', $config["timesource"], '', '', '', true); +$table->data[17][1] = print_select ($sources, 'timesource', $config["timesource"], '', '', '', true); -$table->data[17][0] = __('Automatic update check'); -$table->data[17][1] = print_checkbox ('autoupdate', 1, $config["autoupdate"], true); +$table->data[18][0] = __('Automatic update check'); +$table->data[18][1] = print_checkbox ('autoupdate', 1, $config["autoupdate"], true); -$table->data[18][0] = __('Enforce https'); -$table->data[18][1] = print_checkbox ('https', 1, $config["https"], true); +$table->data[19][0] = __('Enforce https'); +$table->data[19][1] = print_checkbox ('https', 1, $config["https"], true); -// 18 enterprise_hook ('load_snmpforward_enterprise'); echo '
'; diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 0a2d5f6bb3..4579a63003 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -258,125 +258,6 @@ function list_files ($directory, $stringSearch, $searchHandler, $return = false) } } -/** - * Prints a pagination menu to browse into a collection of data. - * - * @param int $count Number of elements in the collection. - * @param string $url URL of the pagination links. It must include all form - * values as GET form. - * @param int $offset Current offset for the pagination. Default value would be - * taken from $_REQUEST['offset'] - * @param int $pagination Current pagination size. If a user requests a larger - * pagination than config["block_size"] - * @param bool $return Whether to return or print this - * - * @return string The pagination div or nothing if no pagination needs to be done - */ -function pagination ($count, $url, $offset = 0, $pagination = 0, $return = false) { - global $config; - - if (empty ($pagination)) { - $pagination = $config["block_size"]; - } - - if (empty ($offset)) { - $offset = (int) get_parameter ('offset'); - } - - /* URL passed render links with some parameter - &offset - Offset records passed to next page - &counter - Number of items to be blocked - Pagination needs $url to build the base URL to render links, its a base url, like - " http://pandora/index.php?sec=godmode&sec2=godmode/admin_access_logs " - */ - $block_limit = 15; // Visualize only $block_limit blocks - if ($count <= $pagination) { - return false; - } - // If exists more registers than I can put in a page, calculate index markers - $index_counter = ceil($count/$pagination); // Number of blocks of block_size with data - $index_page = ceil($offset/$pagination)-(ceil($block_limit/2)); // block to begin to show data; - if ($index_page < 0) - $index_page = 0; - - // This calculate index_limit, block limit for this search. - if (($index_page + $block_limit) > $index_counter) - $index_limit = $index_counter; - else - $index_limit = $index_page + $block_limit; - - // This calculate if there are more blocks than visible (more than $block_limit blocks) - if ($index_counter > $block_limit ) - $paginacion_maxima = 1; // If maximum blocks ($block_limit), show only 10 and "...." - else - $paginacion_maxima = 0; - - // This setup first block of query - if ( $paginacion_maxima == 1) - if ($index_page == 0) - $inicio_pag = 0; - else - $inicio_pag = $index_page; - else - $inicio_pag = 0; - - $output = '
'; - // Show GOTO FIRST button - $output .= ' '; - // Show PREVIOUS button - if ($index_page > 0){ - $index_page_prev= ($index_page-(floor($block_limit/2)))*$pagination; - if ($index_page_prev < 0) - $index_page_prev = 0; - $output .= ''; - } - $output .= "  "; - // Draw blocks markers - // $i stores number of page - for ($i = $inicio_pag; $i < $index_limit; $i++) { - $inicio_bloque = ($i * $pagination); - $final_bloque = $inicio_bloque + $pagination; - if ($final_bloque > $count){ // if upper limit is beyond max, this shouldnt be possible ! - $final_bloque = ($i-1) * $pagination + $count-(($i-1) * $pagination); - } - $output .= ""; - - $inicio_bloque_fake = $inicio_bloque + 1; - // To Calculate last block (doesnt end with round data, - // it must be shown if not round to block limit) - $output .= ''; - if ($inicio_bloque == $offset) { - $output .= "[ $i ]"; - } else { - $output .= "[ $i ]"; - } - $output .= ''; - } - $output .= "  "; - // Show NEXT PAGE (fast forward) - // Index_counter stores max of blocks - if (($paginacion_maxima == 1) AND (($index_counter - $i) > 0)) { - $prox_bloque = ($i + ceil ($block_limit / 2)) * $pagination; - if ($prox_bloque > $count) - $prox_bloque = ($count -1) - $pagination; - $output .= ''; - $i = $index_counter; - } - // if exists more registers than i can put in a page (defined by $block_size config parameter) - // get offset for index calculation - // Draw "last" block link, ajust for last block will be the same - // as painted in last block (last integer block). - if (($count - $pagination) > 0) { - $myoffset = floor (($count - 1) / $pagination) * $pagination; - $output .= ''; - } - // End div and layout - $output .= "
"; - if ($return === false) - echo $output; - return $output; -} - /** * Format a number with decimals and thousands separator. * diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index ec7609208b..3fda2982c7 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -225,32 +225,7 @@ function print_events_table ($filter = "", $limit = 10, $width = 440, $return = } /* Event type */ - switch ($event["event_type"]) { - case "alert_recovered": - $data[1] = print_image ("images/error.png", true, array ("title" => __('Alert recovered'))); - break; - case "alert_manual_validation": - $data[1] = print_image ("images/eye.png", true, array ("title" => __('Alert manually validated'))); - break; - case "monitor_up": - $data[1] = print_image ("images/lightbulb.png", true, array ("title" => __('Monitor up'))); - break; - case "monitor_down": - $data[1] = print_image ("images/lightbulb_off.png", true, array ("title" => __('Monitor down'))); - break; - case "alert_fired": - $data[1] = print_image ("images/bell.png", true, array ("title" => __('Alert fired'))); - break; - case "system"; - $data[1] = print_image ("images/cog.png", true, array ("title" => __('System'))); - break; - case "recon_host_detected"; - $data[1] = print_image ("images/network.png", true, array ("title" => __('Host detected by recon server'))); - break; - default: - $data[1] = print_image ("images/err.png", true, array ("title" => $event["event_type"])); - break; - } + $data[1] = print_event_type_img ($event["event_type"], true); // 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) $wrap = floor ($width / 10); @@ -263,7 +238,7 @@ function print_events_table ($filter = "", $limit = 10, $width = 440, $return = if ($event["id_agente"] > 0) { // Agent name - $data[3] = print_agent_name ($event["id_agente"], true, floor ($width / 20)); //At 440 this would be be 22 + $data[3] = print_agent_name ($event["id_agente"], true, floor ($width / 20)); //At 440 this would be be 22. // for System or SNMP generated alerts } elseif ($event["event_type"] == "system") { $data[3] = __('System'); @@ -290,4 +265,43 @@ function print_events_table ($filter = "", $limit = 10, $width = 440, $return = return $return; } } + + +/** + * Prints the event type image + * + * @param string $type Event type from SQL + * @param bool $return Whether to return or print + * + * @return string HTML with img + */ +function print_event_type_img ($type, $return = false) { + switch ($type) { + case "alert_recovered": + return print_image ("images/error.png", $return, array ("title" => __('Alert recovered'))); + case "alert_manual_validation": + return print_image ("images/eye.png", $return, array ("title" => __('Alert manually validated'))); + case "going_up_warning": + return print_image ("images/b_yellow.png", $return, array ("title" => __('Going from critical to warning'))); + case "going_down_critical": + case "going_up_critical": //This is to be backwards compatible + return print_image ("images/b_red.png", $return, array ("title" => __('Going down to critical state'))); + case "going_up_normal": + case "going_down_normal": //This is to be backwards compatible + return print_image ("images/b_green.png", $return, array ("title" => __('Going up to normal state'))); + case "going_down_warning": + return print_image ("images/b_yellow.png", $return, array ("title" => __('Going down from normal to warning'))); + case "alert_fired": + return print_image ("images/bell.png", $return, array ("title" => __('Alert fired'))); + case "system"; + return print_image ("images/cog.png", $return, array ("title" => __('SYSTEM'))); + case "recon_host_detected"; + return print_image ("images/network.png", $return, array ("title" => __('Recon server detected a new host'))); + case "new_agent"; + return print_image ("images/wand.png", $return, array ("title" => __('New agent created'))); + case "unknown": + default: + return print_image ("images/err.png", $return, array ("title" => __('Unknown type:').': '.$type)); + } +} ?> diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index ca6a73d7ce..cf5cf98937 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -39,6 +39,16 @@ function print_select ($fields, $name, $selected = '', $script = '', $nothing = '', $nothing_value = '0', $return = false, $multiple = false, $sort = true, $class = '', $disabled = false) { $output = "\n"; + static $idcounter = array (); + + //If duplicate names exist, it will start numbering. Otherwise it won't (for backwards compatibility) + if (isset ($idcounter[$name])) { + $idcounter[$name]++; + $name = $name.$idcounter; + } else { + $idcounter[$name] = 0; + } + $attributes = ""; if (!empty ($script)) { $attributes .= ' onchange="'.$script.'"'; @@ -72,7 +82,7 @@ function print_select ($fields, $name, $selected = '', $script = '', $nothing = $output .= '