From 3a96085c9a04409b6a35b6385aed4af3645b2703 Mon Sep 17 00:00:00 2001 From: Esteban Sanchez Date: Thu, 17 Jul 2008 06:41:39 +0000 Subject: [PATCH] 2008-07-17 Esteban Sanchez * 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 --- pandora_console/ChangeLog | 14 +- pandora_console/general/logon_ok.php | 2 +- pandora_console/include/functions.php | 2 +- pandora_console/include/functions_db.php | 8 +- .../operation/agentes/status_monitor.php | 176 +++++++++--------- 5 files changed, 106 insertions(+), 96 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index e5ce62cf30..9f521711bb 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,15 @@ +2008-07-17 Esteban Sanchez + + * 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 * 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 diff --git a/pandora_console/general/logon_ok.php b/pandora_console/general/logon_ok.php index 624204aa7d..36ef9d15bc 100644 --- a/pandora_console/general/logon_ok.php +++ b/pandora_console/general/logon_ok.php @@ -44,7 +44,7 @@ echo ""; // Site news ! // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo '

' . $lang_label["site_news"] . '

'; -$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 ''; while ($row = mysql_fetch_array ($result_news)) { diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 104ceb36b3..7046436c87 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -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); } diff --git a/pandora_console/include/functions_db.php b/pandora_console/include/functions_db.php index 373db31746..5854869c86 100644 --- a/pandora_console/include/functions_db.php +++ b/pandora_console/include/functions_db.php @@ -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 } diff --git a/pandora_console/operation/agentes/status_monitor.php b/pandora_console/operation/agentes/status_monitor.php index 59e2d60154..776bf021f3 100644 --- a/pandora_console/operation/agentes/status_monitor.php +++ b/pandora_console/operation/agentes/status_monitor.php @@ -82,25 +82,25 @@ echo lang_string ("Monitor status"); echo ""; + echo ""; + echo ""; + echo ""; + } + echo "
"; echo ""; @@ -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 " - - - - - - - - - "; - $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 "
- ".$lang_label["agent"]."".$lang_label["type"]."".$lang_label["name"]."".$lang_label["description"]."".$lang_label["interval"]."".$lang_label["status"]."".$lang_label["timestamp"]."
+ + + + + + + + "; + $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 ""; - echo ""; - echo ""; - echo ""; - } - echo "
+ ".$lang_label["agent"]."".$lang_label["type"]."".$lang_label["name"]."".$lang_label["description"]."".$lang_label["interval"]."".$lang_label["status"]."".$lang_label["timestamp"]."
"; - echo ""; - echo ""; - echo ""; - echo "".strtoupper(substr($data[1],0,21)).""; - echo ""; - echo "". substr($data[2],0,21). "".substr($data[3],0,30).""; - echo $my_interval; - - echo ""; - if ($data[8] > 0){ - echo ""; - } else { - echo ""; - } - - echo ""; - $seconds = time() - $data[9]; - if ($seconds >= ($my_interval*2)) - echo ""; - else - echo ""; - - echo human_time_comparation($data[10]); - echo "
"; + echo "
"; + echo ""; + echo ""; + echo ""; + echo "".strtoupper(substr($data[1],0,21)).""; + echo ""; + echo "". substr($data[2],0,21). "".substr($data[3],0,30).""; + echo $my_interval; + + echo ""; + if ($data[8] > 0){ + echo ""; + } else { + echo ""; + } + + echo ""; + $seconds = time() - $data[9]; + if ($seconds >= ($my_interval*2)) + echo ""; + else + echo ""; + + echo human_time_comparation ($data[10]); + echo "
"; } else { echo "
".$lang_label["no_monitors_g"]."
"; }