mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 08:14:38 +02:00
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:
parent
fa1fc24dd8
commit
3a96085c9a
@ -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>
|
2008-07-15 Esteban Sanchez <estebans@artica.es>
|
||||||
|
|
||||||
* ChangeLog: Fixed some indentation and lines length issues. Fixed
|
* ChangeLog: Fixed some indentation and lines length issues. Fixed
|
||||||
@ -12,7 +24,7 @@
|
|||||||
(for security purposes).
|
(for security purposes).
|
||||||
|
|
||||||
* include/functions_db.php: Made all the database queries relying on a
|
* 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
|
functions returned NULL because NULL is a valid database value. Also
|
||||||
made a simple query cache array so that duplicate queries to generate
|
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
|
a single page won't be repeated (ACL queries). Also updated some other
|
||||||
|
@ -44,7 +44,7 @@ echo "<tr><td valign='top'>";
|
|||||||
// Site news !
|
// Site news !
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
echo '<h2>' . $lang_label["site_news"] . '</h2>';
|
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)){
|
if ($result_news = mysql_query ($sql_news)){
|
||||||
echo '<table cellpadding="4" cellspacing="4" width="270" class="databox">';
|
echo '<table cellpadding="4" cellspacing="4" width="270" class="databox">';
|
||||||
while ($row = mysql_fetch_array ($result_news)) {
|
while ($row = mysql_fetch_array ($result_news)) {
|
||||||
|
@ -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";
|
return number_format ($number / 1000, 0, $dec_point, $thousands_sep )." K";
|
||||||
}
|
}
|
||||||
/* If it has decimals */
|
/* 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, $decimals, $dec_point, $thousands_sep);
|
||||||
return number_format ($number, 0, $dec_point, $thousands_sep);
|
return number_format ($number, 0, $dec_point, $thousands_sep);
|
||||||
}
|
}
|
||||||
|
@ -1321,9 +1321,9 @@ function get_db_all_rows_sql ($sql) {
|
|||||||
global $sql_cache;
|
global $sql_cache;
|
||||||
$retval = array();
|
$retval = array();
|
||||||
|
|
||||||
if($sql_cache[$sql]) {
|
if (! empty ($sql_cache[$sql])) {
|
||||||
$retval = $sql_cache[$sql];
|
$retval = $sql_cache[$sql];
|
||||||
$sql_cache[saved]++;
|
$sql_cache['saved']++;
|
||||||
} else {
|
} else {
|
||||||
$result = mysql_query ($sql);
|
$result = mysql_query ($sql);
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
@ -1336,7 +1336,7 @@ function get_db_all_rows_sql ($sql) {
|
|||||||
$sql_cache[$sql] = $retval;
|
$sql_cache[$sql] = $retval;
|
||||||
mysql_free_result ($result);
|
mysql_free_result ($result);
|
||||||
}
|
}
|
||||||
if(!empty ($retval))
|
if (! empty ($retval))
|
||||||
return $retval;
|
return $retval;
|
||||||
return ""; //Return empty because NULL is a possible database value
|
return ""; //Return empty because NULL is a possible database value
|
||||||
}
|
}
|
||||||
|
@ -82,25 +82,25 @@ echo lang_string ("Monitor status");
|
|||||||
echo "<td>";
|
echo "<td>";
|
||||||
echo "<select name='status'>";
|
echo "<select name='status'>";
|
||||||
if ($status == -1){
|
if ($status == -1){
|
||||||
echo "<option value=-1>".lang_string("All");
|
echo "<option value=-1>".lang_string("All");
|
||||||
echo "<option value=0>".lang_string("Monitors down");
|
echo "<option value=0>".lang_string("Monitors down");
|
||||||
echo "<option value=1>".lang_string("Monitors up");
|
echo "<option value=1>".lang_string("Monitors up");
|
||||||
echo "<option value=2>".lang_string("Monitors unknown");
|
echo "<option value=2>".lang_string("Monitors unknown");
|
||||||
} elseif ($status == 0){
|
} elseif ($status == 0){
|
||||||
echo "<option value=0>".lang_string("Monitors down");
|
echo "<option value=0>".lang_string("Monitors down");
|
||||||
echo "<option value=-1>".lang_string("All");
|
echo "<option value=-1>".lang_string("All");
|
||||||
echo "<option value=1>".lang_string("Monitors up");
|
echo "<option value=1>".lang_string("Monitors up");
|
||||||
echo "<option value=2>".lang_string("Monitors unknown");
|
echo "<option value=2>".lang_string("Monitors unknown");
|
||||||
} elseif ($status == 2){
|
} elseif ($status == 2){
|
||||||
echo "<option value=2>".lang_string("Monitors unknown");
|
echo "<option value=2>".lang_string("Monitors unknown");
|
||||||
echo "<option value=0>".lang_string("Monitors down");
|
echo "<option value=0>".lang_string("Monitors down");
|
||||||
echo "<option value=-1>".lang_string("All");
|
echo "<option value=-1>".lang_string("All");
|
||||||
echo "<option value=1>".lang_string("Monitors up");
|
echo "<option value=1>".lang_string("Monitors up");
|
||||||
} else {
|
} else {
|
||||||
echo "<option value=1>".lang_string("Monitors up");
|
echo "<option value=1>".lang_string("Monitors up");
|
||||||
echo "<option value=0>".lang_string("Monitors down");
|
echo "<option value=0>".lang_string("Monitors down");
|
||||||
echo "<option value=2>".lang_string("Monitors unknown");
|
echo "<option value=2>".lang_string("Monitors unknown");
|
||||||
echo "<option value=-1>".lang_string("All");
|
echo "<option value=-1>".lang_string("All");
|
||||||
}
|
}
|
||||||
echo "</select>";
|
echo "</select>";
|
||||||
|
|
||||||
@ -142,26 +142,26 @@ $SQL = " FROM tagente, tagente_modulo, tagente_estado WHERE tagente.id_agente =
|
|||||||
if ($ag_group > 1)
|
if ($ag_group > 1)
|
||||||
$SQL .=" AND tagente.id_grupo = ".$ag_group;
|
$SQL .=" AND tagente.id_grupo = ".$ag_group;
|
||||||
else {
|
else {
|
||||||
// User has explicit permission on group 1 ?
|
// 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");
|
$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)
|
if ($all_group == 0)
|
||||||
$SQL .=" AND tagente.id_grupo IN (SELECT id_grupo FROM tusuario_perfil WHERE id_usuario='$id_user') ";
|
$SQL .=" AND tagente.id_grupo IN (SELECT id_grupo FROM tusuario_perfil WHERE id_usuario='$id_user') ";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Module name selector
|
// Module name selector
|
||||||
// This code thanks for an idea from Nikum, nikun_h@hotmail.com
|
// This code thanks for an idea from Nikum, nikun_h@hotmail.com
|
||||||
if ($ag_modulename != "")
|
if ($ag_modulename != "")
|
||||||
$SQL .= " AND tagente_modulo.nombre = '$ag_modulename'";
|
$SQL .= " AND tagente_modulo.nombre = '$ag_modulename'";
|
||||||
|
|
||||||
// Freestring selector
|
// Freestring selector
|
||||||
if ($ag_freestring != "")
|
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
|
// Status selector
|
||||||
if ($status == 1)
|
if ($status == 1)
|
||||||
$SQL .= " AND tagente_estado.estado = 0 ";
|
$SQL .= " AND tagente_estado.estado = 0 ";
|
||||||
elseif ($status == 0)
|
elseif ($status == 0)
|
||||||
$SQL .= " AND tagente_estado.estado = 1 ";
|
$SQL .= " AND tagente_estado.estado = 1 ";
|
||||||
elseif ($status == 2)
|
elseif ($status == 2)
|
||||||
$SQL .= " AND (UNIX_TIMESTAMP()-tagente_estado.utimestamp ) > (tagente_estado.current_interval * 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;
|
$SQL_COUNT = $SQL_pre_count . $SQL;
|
||||||
|
|
||||||
$counter = get_db_sql ($SQL_COUNT);
|
$counter = get_db_sql ($SQL_COUNT);
|
||||||
if ( $counter > $config["block_size"]) {
|
if ( $counter > $config["block_size"]) {
|
||||||
pagination ($counter, $URL, $offset);
|
pagination ($counter, $URL, $offset);
|
||||||
$SQL_FINAL .= " LIMIT $offset , ".$config["block_size"];
|
$SQL_FINAL .= " LIMIT $offset , ".$config["block_size"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($counter > 0){
|
if ($counter > 0) {
|
||||||
echo "
|
echo "<table cellpadding='4' cellspacing='4' width='750' class='databox'>
|
||||||
<table cellpadding='4' cellspacing='4' width='750' class='databox'>
|
<tr>
|
||||||
<tr>
|
<th>
|
||||||
<th>
|
<th>".$lang_label["agent"]."</th>
|
||||||
<th>".$lang_label["agent"]."</th>
|
<th>".$lang_label["type"]."</th>
|
||||||
<th>".$lang_label["type"]."</th>
|
<th>".$lang_label["name"]."</th>
|
||||||
<th>".$lang_label["name"]."</th>
|
<th>".$lang_label["description"]."</th>
|
||||||
<th>".$lang_label["description"]."</th>
|
<th>".$lang_label["interval"]."</th>
|
||||||
<th>".$lang_label["interval"]."</th>
|
<th>".$lang_label["status"]."</th>
|
||||||
<th>".$lang_label["status"]."</th>
|
<th>".$lang_label["timestamp"]."</th>";
|
||||||
<th>".$lang_label["timestamp"]."</th>";
|
$color =1;
|
||||||
$color =1;
|
$result=mysql_query($SQL_FINAL);
|
||||||
$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 ($status == 2){
|
while ($data=mysql_fetch_array($result)){ //while there are agents
|
||||||
$seconds = time() - $data[9];
|
if ($color == 1){
|
||||||
|
$tdcolor="datos";
|
||||||
if ($seconds < ($my_interval*2))
|
$color =0;
|
||||||
continue;
|
} 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 "<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 "<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 "<img src='images/target.png'></a>";
|
||||||
echo "</td><td class='$tdcolor'>";
|
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 "<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 "</td><td class='$tdcolor'>";
|
||||||
echo "<img src='images/".show_icon_type($data[6])."' border=0></td>";
|
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'>". substr($data[2],0,21). "</td>";
|
||||||
echo "<td class='".$tdcolor."f9' title='".$data[3]."'>".substr($data[3],0,30)."</td>";
|
echo "<td class='".$tdcolor."f9' title='".$data[3]."'>".substr($data[3],0,30)."</td>";
|
||||||
echo "<td class='$tdcolor' align='center' width=25>";
|
echo "<td class='$tdcolor' align='center' width=25>";
|
||||||
echo $my_interval;
|
echo $my_interval;
|
||||||
|
|
||||||
echo "<td class='$tdcolor' align='center' width=20>";
|
echo "<td class='$tdcolor' align='center' width=20>";
|
||||||
if ($data[8] > 0){
|
if ($data[8] > 0){
|
||||||
echo "<img src='images/pixel_green.png' width=40 height=18 title='".lang_string("Monitor up")."'>";
|
echo "<img src='images/pixel_green.png' width=40 height=18 title='".lang_string("Monitor up")."'>";
|
||||||
} else {
|
} else {
|
||||||
echo "<img src='images/pixel_red.png' width=40 height=18 title='".lang_string ("Monitor down")."'>";
|
echo "<img src='images/pixel_red.png' width=40 height=18 title='".lang_string ("Monitor down")."'>";
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "<td class='".$tdcolor."f9'>";
|
echo "<td class='".$tdcolor."f9'>";
|
||||||
$seconds = time() - $data[9];
|
$seconds = time() - $data[9];
|
||||||
if ($seconds >= ($my_interval*2))
|
if ($seconds >= ($my_interval*2))
|
||||||
echo "<span class='redb'>";
|
echo "<span class='redb'>";
|
||||||
else
|
else
|
||||||
echo "<span>";
|
echo "<span>";
|
||||||
|
|
||||||
echo human_time_comparation($data[10]);
|
echo human_time_comparation ($data[10]);
|
||||||
echo "</span></td></tr>";
|
echo "</span></td></tr>";
|
||||||
}
|
}
|
||||||
echo "</table>";
|
echo "</table>";
|
||||||
} else {
|
} else {
|
||||||
echo "<div class='nf'>".$lang_label["no_monitors_g"]."</div>";
|
echo "<div class='nf'>".$lang_label["no_monitors_g"]."</div>";
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user