2008-09-24 Evi Vanoost <vanooste@rcbi.rochester.edu>

* 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

git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1112 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
guruevi 2008-09-24 14:34:52 +00:00
parent cd945556ec
commit 57d4f2bd76
3 changed files with 50 additions and 80 deletions

View File

@ -1,3 +1,12 @@
2008-09-24 Evi Vanoost <vanooste@rcbi.rochester.edu>
* 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 <rnovoa@artica.es>
* extensions/update_manager/sql/update_manager.sql,
@ -7,7 +16,7 @@
2008-09-23 Jorge Gonzalez <jorgegonz@artica.es>
* 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 <raulofpandora@gmail.com>

View File

@ -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 "<table width=100% cellpadding=0 cellspacing=0 style='margin:0px; padding:0px;' border=0>";
echo "<tr>";
echo "<td>";
//First column (logo)
echo '<table width="100%" cellpadding="0" cellspacing="0" style="margin:0px; padding:0px;" border="0"><tr><td>';
// Yes, put here your corporate logo instead pandora_logo_head.png
echo '<a href="index.php"><img src="images/pandora_logo_head.png" border="0" alt="logo" /></a>';
// The style specifies width and height so that oversized images get resized.
// Optimally your logo would be this size.
echo '<a href="index.php"><img src="images/pandora_logo_head.png" alt="logo" style="border-width:0px width:140px; height:60px;" /></a>';
// Margin to logo
echo '</td><td width="20">&nbsp;</td>';
echo "<td width=20>";
// First column
echo "<td>";
echo '<img src="images/user_'.((dame_admin ($_SESSION["id_usuario"]) == 1) ? 'suit' : 'green' ).'.png" class="bot">&nbsp;'.'<a class="white">'.__('You are ').'[<b>'.$_SESSION["id_usuario"].'</b>]</a>';
echo "<br><br>";
// First column (identifier)
echo '<td><img src="images/user_'.((dame_admin ($_SESSION["id_usuario"]) == 1) ? 'suit' : 'green' ).'.png" class="bot">&nbsp;'.'<a class="white">'.__('You are').' [<b>'.$_SESSION["id_usuario"].'</b>]</a>';
//First column, second row (logout button)
echo '<br /><br />';
echo '<a class="white_bold" href="index.php?bye=bye"><img src="images/lock.png" class="bot">&nbsp;'. __('Logout').'</a>';
// Second column
echo "<td>";
// Second column (link to main page)
echo '</td><td>';
echo '<a class="white_bold" href="index.php?sec=main"><img src="images/information.png" class="bot">&nbsp;'.__('General information').'</a>';
echo "<br><br>";
//Second column, second row (System up/down)
echo '<br /><br />';
echo '<a class="white_bold" href="index.php?sec=estado_server&sec2=operation/servers/view_server&refr=60">';
if (check_server_status () == 0)
echo '<img src="images/error.png" class="bot" />&nbsp;'.__('Server status: DOWN');
else
echo '<img src="images/ok.png" class="bot" />&nbsp;'.__('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 '<img src="images/cross.png" class="bot" />&nbsp;'.__('All systems').': '.__('Down');
} elseif ($servers["down"] != 0) {
//Some servers down
echo '<img src="images/error.png" class="bot" />&nbsp;'.$servers["down"].' '.__('servers down');
} else {
//All servers up
echo '<img src="images/ok.png" class="bot" />&nbsp;'.__('All systems').': '.__('Ready');
}
unset ($servers); // Since this is the header, we don't like to trickle down variables.
echo "</a>";
// Third column
// Autorefresh
echo "<td>";
if (get_parameter ("refr") != 0)
echo '<a class="white_grey_bold" href="'.((substr($_SERVER['REQUEST_URI'],-1) != "/") ? $_SERVER['REQUEST_URI'] : 'index.php?' ).'&refr=0"><img src="images/page_lightning.png" class="bot" />&nbsp;'. __('Autorefresh').'</a>';
else
echo '<a class="white_bold" href="'.((substr($_SERVER['REQUEST_URI'],-1) != "/") ? $_SERVER['REQUEST_URI'] : "index.php?" ).'&refr=5"><img src="images/page_lightning.png" class="bot" />&nbsp;'.__('Autorefresh').'</a>';
echo "<br><br>";
echo "</td><td>";
if (get_parameter ("refr") != 0) {
echo '<a class="white_grey_bold" href="'.((substr ($_SERVER['REQUEST_URI'],-1) != "/") ? $_SERVER['REQUEST_URI'] : 'index.php?' ).'&refr=0"><img src="images/page_lightning.png" class="bot" />&nbsp;'. __('Autorefresh').'</a>';
} else {
echo '<a class="white_bold" href="'.((substr ($_SERVER['REQUEST_URI'],-1) != "/") ? $_SERVER['REQUEST_URI'] : "index.php?" ).'&refr=5"><img src="images/page_lightning.png" class="bot" />&nbsp;'.__('Autorefresh').'</a>';
}
//Events
echo '<br /><br />';
echo '<a class="white_bold" href="index.php?sec=eventos&sec2=operation/events/events&refr=5"><img src="images/lightning_go.png" class="bot" />&nbsp;'.__('Events').'</a>';
// logo
echo "<td>";
echo '<div id="head_r"><span id="logo_text1">Pandora</span> <span id="logo_text2">FMS</span></div>';
echo "</table>";
/*
if(!isset ($_SESSION["id_usuario"])) {
echo "</div>";
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
'<img src="images/user_'.((dame_admin ($_SESSION["id_usuario"]) == 1) ? 'suit' : 'green' ).'.png" class="bot">&nbsp;'.'<a class="white">'.__('You are ').'[<b>'.$_SESSION["id_usuario"].'</b>]</a>',
// Second column
'<a class="white_bold" href="index.php?sec=main"><img src="images/information.png" class="bot">&nbsp;'.__('General information').'</a>',
// Third column
// Autorefresh
((get_parameter ("refr") != 0) ?
'<a class="white_grey_bold" href="'.((substr($_SERVER['REQUEST_URI'],-1) != "/") ? $_SERVER['REQUEST_URI'] : 'index.php?' ).'&refr=0"><img src="images/page_lightning.png" class="bot" />&nbsp;'. __('Autorefresh').'</a>'
:
'<a class="white_bold" href="'.((substr($_SERVER['REQUEST_URI'],-1) != "/") ? $_SERVER['REQUEST_URI'] : "index.php?" ).'&refr=5"><img src="images/page_lightning.png" class="bot" />&nbsp;'.__('Autorefresh').'</a>'
)
);
$table->data[] = array (
'<a class="white_bold" href="index.php?bye=bye"><img src="images/lock.png" class="bot">&nbsp;'. __('Logout').'</a>',
'<a class="white_bold" href="index.php?sec=estado_server&sec2=operation/servers/view_server&refr=60">'.
((check_server_status () == 0) ?
'<img src="images/error.png" class="bot" />&nbsp;'.__('Server status: DOWN')
:
'<img src="images/ok.png" class="bot" />&nbsp;'.__('System ready')
).'</a>',
// Event - refresh
'<a class="white_bold" href="index.php?sec=eventos&sec2=operation/events/events&refr=5"><img src="images/lightning_go.png" class="bot" />&nbsp;'.__('Events').'</a>'
);
print_table ($table);
unset ($table);
echo "</div>";
*/
// Styled text
echo '</td><td><div id="head_r"><span id="logo_text1">Pandora</span> <span id="logo_text2">FMS</span></div></td></tr></table>';
?>

View File

@ -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");