2008-07-17 Esteban Sanchez <estebans@artica.es>

* include/functions.php: Minimal style correction.

        * include/functions_db.php: Check sql_cache with empty() to avoid
        notices.

        * operation/agentes/status_monitor.php: Tab style correction.

        * general/logon_ok.php: Added missing field to SQL sentence which was 
        causing PHP notices.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@956 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
esanchezm 2008-07-17 06:41:39 +00:00
parent 347570ef42
commit 899619e246
5 changed files with 106 additions and 96 deletions

View File

@ -1,3 +1,15 @@
2008-07-17 Esteban Sanchez <estebans@artica.es>
* include/functions.php: Minimal style correction.
* include/functions_db.php: Check sql_cache with empty() to avoid
notices.
* operation/agentes/status_monitor.php: Tab style correction.
* general/logon_ok.php: Added missing field to SQL sentence which was
causing PHP notices.
2008-07-15 Esteban Sanchez <estebans@artica.es>
* ChangeLog: Fixed some indentation and lines length issues. Fixed
@ -12,7 +24,7 @@
(for security purposes).
* include/functions_db.php: Made all the database queries relying on a
single query function for simpler management. Also made sure that no
single query function for simpler management. Also made sure that no
functions returned NULL because NULL is a valid database value. Also
made a simple query cache array so that duplicate queries to generate
a single page won't be repeated (ACL queries). Also updated some other

View File

@ -44,7 +44,7 @@ echo "<tr><td valign='top'>";
// Site news !
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo '<h2>' . $lang_label["site_news"] . '</h2>';
$sql_news = "SELECT subject,timestamp,text FROM tnews ORDER by timestamp DESC LIMIT 3";
$sql_news = "SELECT subject,timestamp,text,author FROM tnews ORDER by timestamp DESC LIMIT 3";
if ($result_news = mysql_query ($sql_news)){
echo '<table cellpadding="4" cellspacing="4" width="270" class="databox">';
while ($row = mysql_fetch_array ($result_news)) {

View File

@ -434,7 +434,7 @@ function format_for_graph ($number , $decimals = 1, $dec_point = ".", $thousands
return number_format ($number / 1000, 0, $dec_point, $thousands_sep )." K";
}
/* If it has decimals */
if (fmod ($number , 1))
if (fmod ($number, 1))
return number_format ($number, $decimals, $dec_point, $thousands_sep);
return number_format ($number, 0, $dec_point, $thousands_sep);
}

View File

@ -1321,9 +1321,9 @@ function get_db_all_rows_sql ($sql) {
global $sql_cache;
$retval = array();
if($sql_cache[$sql]) {
$retval = $sql_cache[$sql];
$sql_cache[saved]++;
if (! empty ($sql_cache[$sql])) {
$retval = $sql_cache[$sql];
$sql_cache['saved']++;
} else {
$result = mysql_query ($sql);
if (!$result) {
@ -1336,7 +1336,7 @@ function get_db_all_rows_sql ($sql) {
$sql_cache[$sql] = $retval;
mysql_free_result ($result);
}
if(!empty ($retval))
if (! empty ($retval))
return $retval;
return ""; //Return empty because NULL is a possible database value
}

View File

@ -82,25 +82,25 @@ echo lang_string ("Monitor status");
echo "<td>";
echo "<select name='status'>";
if ($status == -1){
echo "<option value=-1>".lang_string("All");
echo "<option value=0>".lang_string("Monitors down");
echo "<option value=1>".lang_string("Monitors up");
echo "<option value=-1>".lang_string("All");
echo "<option value=0>".lang_string("Monitors down");
echo "<option value=1>".lang_string("Monitors up");
echo "<option value=2>".lang_string("Monitors unknown");
} elseif ($status == 0){
echo "<option value=0>".lang_string("Monitors down");
echo "<option value=-1>".lang_string("All");
echo "<option value=1>".lang_string("Monitors up");
echo "<option value=0>".lang_string("Monitors down");
echo "<option value=-1>".lang_string("All");
echo "<option value=1>".lang_string("Monitors up");
echo "<option value=2>".lang_string("Monitors unknown");
} elseif ($status == 2){
echo "<option value=2>".lang_string("Monitors unknown");
echo "<option value=0>".lang_string("Monitors down");
echo "<option value=-1>".lang_string("All");
echo "<option value=1>".lang_string("Monitors up");
echo "<option value=0>".lang_string("Monitors down");
echo "<option value=-1>".lang_string("All");
echo "<option value=1>".lang_string("Monitors up");
} else {
echo "<option value=1>".lang_string("Monitors up");
echo "<option value=0>".lang_string("Monitors down");
echo "<option value=2>".lang_string("Monitors unknown");
echo "<option value=-1>".lang_string("All");
echo "<option value=1>".lang_string("Monitors up");
echo "<option value=0>".lang_string("Monitors down");
echo "<option value=2>".lang_string("Monitors unknown");
echo "<option value=-1>".lang_string("All");
}
echo "</select>";
@ -142,26 +142,26 @@ $SQL = " FROM tagente, tagente_modulo, tagente_estado WHERE tagente.id_agente =
if ($ag_group > 1)
$SQL .=" AND tagente.id_grupo = ".$ag_group;
else {
// User has explicit permission on group 1 ?
$all_group = get_db_sql ("SELECT COUNT(id_grupo) FROM tusuario_perfil WHERE id_usuario='$id_user' AND id_grupo = 1");
if ($all_group == 0)
$SQL .=" AND tagente.id_grupo IN (SELECT id_grupo FROM tusuario_perfil WHERE id_usuario='$id_user') ";
// User has explicit permission on group 1 ?
$all_group = get_db_sql ("SELECT COUNT(id_grupo) FROM tusuario_perfil WHERE id_usuario='$id_user' AND id_grupo = 1");
if ($all_group == 0)
$SQL .=" AND tagente.id_grupo IN (SELECT id_grupo FROM tusuario_perfil WHERE id_usuario='$id_user') ";
}
// Module name selector
// This code thanks for an idea from Nikum, nikun_h@hotmail.com
if ($ag_modulename != "")
$SQL .= " AND tagente_modulo.nombre = '$ag_modulename'";
$SQL .= " AND tagente_modulo.nombre = '$ag_modulename'";
// Freestring selector
if ($ag_freestring != "")
$SQL .= " AND ( tagente.nombre LIKE '%".$ag_freestring."%' OR tagente_modulo.nombre LIKE '%".$ag_freestring."%' OR tagente_modulo.descripcion LIKE '%".$ag_freestring."%') ";
$SQL .= " AND ( tagente.nombre LIKE '%".$ag_freestring."%' OR tagente_modulo.nombre LIKE '%".$ag_freestring."%' OR tagente_modulo.descripcion LIKE '%".$ag_freestring."%') ";
// Status selector
if ($status == 1)
$SQL .= " AND tagente_estado.estado = 0 ";
$SQL .= " AND tagente_estado.estado = 0 ";
elseif ($status == 0)
$SQL .= " AND tagente_estado.estado = 1 ";
$SQL .= " AND tagente_estado.estado = 1 ";
elseif ($status == 2)
$SQL .= " AND (UNIX_TIMESTAMP()-tagente_estado.utimestamp ) > (tagente_estado.current_interval * 2)";
@ -173,79 +173,77 @@ $SQL_FINAL = $SQL_pre . $SQL;
$SQL_COUNT = $SQL_pre_count . $SQL;
$counter = get_db_sql ($SQL_COUNT);
if ( $counter > $config["block_size"]) {
pagination ($counter, $URL, $offset);
$SQL_FINAL .= " LIMIT $offset , ".$config["block_size"];
}
if ( $counter > $config["block_size"]) {
pagination ($counter, $URL, $offset);
$SQL_FINAL .= " LIMIT $offset , ".$config["block_size"];
}
if ($counter > 0){
echo "
<table cellpadding='4' cellspacing='4' width='750' class='databox'>
<tr>
<th>
<th>".$lang_label["agent"]."</th>
<th>".$lang_label["type"]."</th>
<th>".$lang_label["name"]."</th>
<th>".$lang_label["description"]."</th>
<th>".$lang_label["interval"]."</th>
<th>".$lang_label["status"]."</th>
<th>".$lang_label["timestamp"]."</th>";
$color =1;
$result=mysql_query($SQL_FINAL);
while ($data=mysql_fetch_array($result)){ //while there are agents
if ($color == 1){
$tdcolor="datos";
$color =0;
} else {
$tdcolor="datos2";
$color =1;
}
if ($data[7] == 0){
$my_interval = give_agentinterval($data[5]);
} else {
$my_interval = $data[7];
}
if ($counter > 0) {
echo "<table cellpadding='4' cellspacing='4' width='750' class='databox'>
<tr>
<th>
<th>".$lang_label["agent"]."</th>
<th>".$lang_label["type"]."</th>
<th>".$lang_label["name"]."</th>
<th>".$lang_label["description"]."</th>
<th>".$lang_label["interval"]."</th>
<th>".$lang_label["status"]."</th>
<th>".$lang_label["timestamp"]."</th>";
$color =1;
$result=mysql_query($SQL_FINAL);
if ($status == 2){
$seconds = time() - $data[9];
if ($seconds < ($my_interval*2))
continue;
while ($data=mysql_fetch_array($result)){ //while there are agents
if ($color == 1){
$tdcolor="datos";
$color =0;
} else {
$tdcolor="datos2";
$color =1;
}
if ($data[7] == 0){
$my_interval = give_agentinterval($data[5]);
} else {
$my_interval = $data[7];
}
if ($status == 2) {
$seconds = time() - $data[9];
if ($seconds < ($my_interval*2))
continue;
}
echo "<tr><td class='$tdcolor'>";
echo "<a href='index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=".$data["id_agente"]."&id_agente_modulo=".$data[0]."&flag=1&tab=data&refr=60'>";
echo "<img src='images/target.png'></a>";
echo "</td><td class='$tdcolor'>";
echo "<b><a href='index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=".$data[5]."'>".strtoupper(substr($data[1],0,21))."</a></b>";
echo "</td><td class='$tdcolor'>";
echo "<img src='images/".show_icon_type($data[6])."' border=0></td>";
echo "<td class='$tdcolor'>". substr($data[2],0,21). "</td>";
echo "<td class='".$tdcolor."f9' title='".$data[3]."'>".substr($data[3],0,30)."</td>";
echo "<td class='$tdcolor' align='center' width=25>";
echo $my_interval;
echo "<td class='$tdcolor' align='center' width=20>";
if ($data[8] > 0){
echo "<img src='images/pixel_green.png' width=40 height=18 title='".lang_string("Monitor up")."'>";
} else {
echo "<img src='images/pixel_red.png' width=40 height=18 title='".lang_string ("Monitor down")."'>";
}
echo "<td class='".$tdcolor."f9'>";
$seconds = time() - $data[9];
if ($seconds >= ($my_interval*2))
echo "<span class='redb'>";
else
echo "<span>";
echo human_time_comparation($data[10]);
echo "</span></td></tr>";
}
echo "</table>";
echo "<tr><td class='$tdcolor'>";
echo "<a href='index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=".$data["id_agente"]."&id_agente_modulo=".$data[0]."&flag=1&tab=data&refr=60'>";
echo "<img src='images/target.png'></a>";
echo "</td><td class='$tdcolor'>";
echo "<strong><a href='index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=".$data[5]."'>".strtoupper(substr($data[1],0,21))."</a></strong>";
echo "</td><td class='$tdcolor'>";
echo "<img src='images/".show_icon_type($data[6])."' border=0></td>";
echo "<td class='$tdcolor'>". substr($data[2],0,21). "</td>";
echo "<td class='".$tdcolor."f9' title='".$data[3]."'>".substr($data[3],0,30)."</td>";
echo "<td class='$tdcolor' align='center' width=25>";
echo $my_interval;
echo "<td class='$tdcolor' align='center' width=20>";
if ($data[8] > 0){
echo "<img src='images/pixel_green.png' width=40 height=18 title='".lang_string("Monitor up")."'>";
} else {
echo "<img src='images/pixel_red.png' width=40 height=18 title='".lang_string ("Monitor down")."'>";
}
echo "<td class='".$tdcolor."f9'>";
$seconds = time() - $data[9];
if ($seconds >= ($my_interval*2))
echo "<span class='redb'>";
else
echo "<span>";
echo human_time_comparation ($data[10]);
echo "</span></td></tr>";
}
echo "</table>";
} else {
echo "<div class='nf'>".$lang_label["no_monitors_g"]."</div>";
}