diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 1206de7e05..4099be603e 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,12 @@ +2008-09-24 Evi Vanoost + + * include/functions_db.php: Fixed a small bug in get_db_value and fixed + check_server_status () to return an int at all times + + * general/header.php: Removed my old table code. Fixed bug #2119102. + + * ChangeLog: Made Jorge's entry use tab instead of spaces + 2008-09-24 Ramon Novoa * extensions/update_manager/sql/update_manager.sql, @@ -7,7 +16,7 @@ 2008-09-23 Jorge Gonzalez - * include/languages/es.po: Updated Spanish translation, fixes a bug. + * include/languages/es.po: Updated Spanish translation, fixes a bug. 2008-09-22 Raul Mateos diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php index b9931ea944..04daef350a 100644 --- a/pandora_console/general/header.php +++ b/pandora_console/general/header.php @@ -16,100 +16,61 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -echo ""; -echo ""; -echo "
"; +//First column (logo) +echo ''; -echo "
'; // Yes, put here your corporate logo instead pandora_logo_head.png - -echo 'logo'; +// The style specifies width and height so that oversized images get resized. +// Optimally your logo would be this size. +echo 'logo'; // Margin to logo +echo ' "; - -// First column -echo ""; -echo ' '.''.__('You are ').'['.$_SESSION["id_usuario"].']'; - -echo "

"; +// First column (identifier) +echo '
 '.''.__('You are').' ['.$_SESSION["id_usuario"].']'; +//First column, second row (logout button) +echo '

'; echo ' '. __('Logout').''; - - -// Second column -echo "
"; +// Second column (link to main page) +echo ''; echo ' '.__('General information').''; -echo "

"; - +//Second column, second row (System up/down) +echo '

'; echo ''; -if (check_server_status () == 0) - echo ' '.__('Server status: DOWN'); -else - echo ' '.__('System ready'); +$servers["all"] = (int) get_db_value ('COUNT(id_server)','tserver'); +$servers["up"] = (int) check_server_status (); +$servers["down"] = $servers["all"] - $servers["up"]; +if ($servers["up"] == 0) { + //All Servers down or no servers at all + echo ' '.__('All systems').': '.__('Down'); +} elseif ($servers["down"] != 0) { + //Some servers down + echo ' '.$servers["down"].' '.__('servers down'); +} else { + //All servers up + echo ' '.__('All systems').': '.__('Ready'); +} +unset ($servers); // Since this is the header, we don't like to trickle down variables. echo ""; // Third column // Autorefresh -echo "
"; -if (get_parameter ("refr") != 0) - echo ' '. __('Autorefresh').''; -else - echo ' '.__('Autorefresh').''; - -echo "

"; +echo "
"; +if (get_parameter ("refr") != 0) { + echo ' '. __('Autorefresh').''; +} else { + echo ' '.__('Autorefresh').''; +} +//Events +echo '

'; echo ' '.__('Events').''; -// logo - -echo "
"; -echo '
Pandora FMS
'; - -echo "
"; -/* -if(!isset ($_SESSION["id_usuario"])) { - echo ""; - return; -} -$table->width=480; -$table->border=0; -$table->cellpadding=3; -$table->size=array("30%"); -$table->class="inherit"; -$table->rowclass=array("inherit","inherit"); - -$table->data[] = array ( - // First column - ' '.''.__('You are ').'['.$_SESSION["id_usuario"].']', - // Second column - ' '.__('General information').'', - // Third column - // Autorefresh - ((get_parameter ("refr") != 0) ? - ' '. __('Autorefresh').'' - : - ' '.__('Autorefresh').'' - ) - ); - -$table->data[] = array ( - ' '. __('Logout').'', - ''. - ((check_server_status () == 0) ? - ' '.__('Server status: DOWN') - : - ' '.__('System ready') - ).'', - // Event - refresh - ' '.__('Events').'' - ); -print_table ($table); -unset ($table); -echo ""; -*/ - +// Styled text +echo '
Pandora FMS
'; ?> diff --git a/pandora_console/include/functions_db.php b/pandora_console/include/functions_db.php index 1521fe32d3..7f4d630798 100644 --- a/pandora_console/include/functions_db.php +++ b/pandora_console/include/functions_db.php @@ -1302,7 +1302,7 @@ $sql_cache = array ('saved' => 0); */ function get_db_value ($field, $table, $field_search = 1, $condition = 1) { if (is_int ($condition)) { - $sql = sprintf ("SELECT %s FROM `%s` WHERE `%s` = %d LIMIT 1", + $sql = sprintf ("SELECT %s FROM `%s` WHERE %s = %d LIMIT 1", $field, $table, $field_search, $condition); } else if (is_float ($condition) || is_double ($condition)) { $sql = sprintf ("SELECT %s FROM `%s` WHERE `%s` = %f LIMIT 1", @@ -1821,7 +1821,7 @@ function lang_string ($string) { */ function check_server_status () { $sql = "SELECT COUNT(id_server) FROM tserver WHERE status = 1 AND keepalive > NOW() - INTERVAL 15 MINUTE"; - $status = get_db_sql ($sql); + $status = (int) get_db_sql ($sql); //Cast as int will assure a number value // Set servers to down if ($status == 0){ process_sql ("UPDATE tserver SET status = 0");