diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 7c20c9f98d..95e0064990 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,12 @@ +2007-02-19 Sancho Lerena + + * operation/incidents/incident.php: Pagination finished. + + * operation/events/events.php: Pagination finished. + + * godmode/admin_access_logs.php: Pagination fix (work in progress, + not finished yet). + 2007-02-16 Sancho Lerena * pandoradb.sql: added unixtime field to tagente_datos, diff --git a/pandora_console/godmode/admin_access_logs.php b/pandora_console/godmode/admin_access_logs.php index 8f55c73fd9..793569c863 100644 --- a/pandora_console/godmode/admin_access_logs.php +++ b/pandora_console/godmode/admin_access_logs.php @@ -2,9 +2,9 @@ // Pandora - the Free monitoring system // ==================================== -// Copyright (c) 2004-2006 Sancho Lerena, slerena@gmail.com -// Copyright (c) 2005-2006 Artica Soluciones Tecnológicas S.L, info@artica.es -// Copyright (c) 2004-2006 Raul Mateos Martin, raulofpandora@gmail.com +// Copyright (c) 2004-2007 Sancho Lerena, slerena@gmail.com +// Copyright (c) 2005-2007 Artica Soluciones Tecnoloicas S.L, info@artica.es +// Copyright (c) 2004-2007 Raul Mateos Martin, raulofpandora@gmail.com // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 @@ -20,114 +20,120 @@ // Load global vars require("include/config.php"); -if (comprueba_login() == 0) - $id_usuario= $_SESSION["id_usuario"]; - if ( (dame_admin($id_user)==1) OR (give_acl($id_usuario, 0, "PM")==1)){ - echo "

".$lang_label["audit_title"]."

"; - if (isset($_GET["offset"])) - $offset=$_GET["offset"]; - else - $offset=0; +if (comprueba_login() != 0) { + audit_db("Noauth",$REMOTE_ADDR, "No authenticated acces","Trying to access event viewer"); + require ("general/noaccess.php"); + exit; +} - // Manage GET/POST parameter for subselect on action type. POST parameter are proccessed before GET parameter (if passed) - if (isset($_GET["tipo_log"])){ - $tipo_log = $_GET["tipo_log"]; - $tipo_log_select = " WHERE accion='".$tipo_log."' "; - } elseif (isset($_POST["tipo_log"])){ - $tipo_log = $_POST["tipo_log"]; - if ($tipo_log == "-1"){ - $tipo_log_select = ""; - unset($tipo_log); - } else - $tipo_log_select = " WHERE accion='".$tipo_log."' "; - } - else $tipo_log_select= ""; +$id_usuario =$_SESSION["id_usuario"]; +if (give_acl($id_usuario, 0, "PM")!=1) { + audit_db($id_usuario,$REMOTE_ADDR, "ACL Violation","Trying to access event viewer"); + require ("general/noaccess.php"); + exit; +} - // generate select - - echo "

".$lang_label["filter"]; - echo " -  ".$lang_label["help"]."

"; - echo "
"; - echo "
"; - echo ""; - echo ""; - echo "
"; - $sql2="SELECT COUNT(*) FROM tsesion ".$tipo_log_select." ORDER BY fecha DESC"; - $result2=mysql_query($sql2); - $row2=mysql_fetch_array($result2); - $counter = $row2[0]; - if (isset ($tipo_log)) - $url = "index.php?sec=godmode&sec2=godmode/admin_access_logs&tipo_log=".$tipo_log; + echo "

".$lang_label["audit_title"]."

"; + if (isset($_GET["offset"])) + $offset=$_GET["offset"]; else - $url = "index.php?sec=godmode&sec2=godmode/admin_access_logs"; + $offset=0; - //echo "URLTipolog $tipo_log"; - pagination ($counter, $url, $offset); - echo '
'; - // table header - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - - // Skip offset records - $query1="SELECT * FROM tsesion ".$tipo_log_select." ORDER BY fecha DESC"; - $result=mysql_query($query1); - $offset_counter = 0; - while ($offset_counter < $offset){ - if ($row=mysql_fetch_array($result)) - $offset_counter++; - else - $offset_counter = $offset; //exit condition - } - - $offset_counter = 0; - $color=1; - // Get data - while ($row=mysql_fetch_array($result) and ($offset_counter < $block_size) ){ - if ($color == 1){ - $tdcolor = "datos"; - $color = 0; - } - else { - $tdcolor = "datos2"; - $color = 1; - } - $usuario=$row["ID_usuario"]; - echo ''; - $offset_counter++; - } - - // end table - echo "
'.$lang_label["user"].''.$lang_label["action"].''.$lang_label["date"].''.$lang_label["src_address"].''.$lang_label["comments"].'
'.$usuario; - echo ''.$row["accion"]; - echo ''.$row["fecha"]; - echo ''.$row["IP_origen"]; - echo ''.$row["descripcion"]; - echo '
"; - - } // End security control - else { - audit_db($id_user,$REMOTE_ADDR, "ACL Violation","Trying to access Access Logs section "); - require ("general/noaccess.php"); + // Manage GET/POST parameter for subselect on action type. POST parameter are proccessed before GET parameter (if passed) + if (isset($_GET["tipo_log"])){ + $tipo_log = $_GET["tipo_log"]; + $tipo_log_select = " WHERE accion='".$tipo_log."' "; + } elseif (isset($_POST["tipo_log"])){ + $tipo_log = $_POST["tipo_log"]; + if ($tipo_log == "-1"){ + $tipo_log_select = ""; + unset($tipo_log); + } else + $tipo_log_select = " WHERE accion='".$tipo_log."' "; } + else $tipo_log_select= ""; + +// generate select + +echo "

".$lang_label["filter"]; +echo "".$lang_label["help"]."

"; +echo "
"; +echo "
"; +echo ""; +echo ""; +echo "
"; + +$sql2="SELECT COUNT(*) FROM tsesion ".$tipo_log_select." ORDER BY fecha DESC"; +$result2=mysql_query($sql2); +$row2=mysql_fetch_array($result2); +$counter = $row2[0]; +if (isset ($tipo_log)) + $url = "index.php?sec=godmode&sec2=godmode/admin_access_logs&tipo_log=".$tipo_log; +else + $url = "index.php?sec=godmode&sec2=godmode/admin_access_logs"; + +//echo "URLTipolog $tipo_log"; + pagination ($counter, $url, $offset); + echo '
'; +// table header + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + +// Skip offset records + $query1="SELECT * FROM tsesion ".$tipo_log_select." ORDER BY fecha DESC"; + $result=mysql_query($query1); + $offset_counter = 0; + while ($offset_counter < $offset){ + if ($row=mysql_fetch_array($result)) + $offset_counter++; + else + $offset_counter = $offset; //exit condition + } + + $offset_counter = 0; + $color=1; +// Get data + while ($row=mysql_fetch_array($result) and ($offset_counter < $block_size) ){ + if ($color == 1){ + $tdcolor = "datos"; + $color = 0; + } + else { + $tdcolor = "datos2"; + $color = 1; + } + $usuario=$row["ID_usuario"]; + echo ''; + $offset_counter++; + } + +// end table + echo "
'.$lang_label["user"].''.$lang_label["action"].''.$lang_label["date"].''.$lang_label["src_address"].''.$lang_label["comments"].'
'.$usuario; + echo ''.$row["accion"]; + echo ''.$row["fecha"]; + echo ''.$row["IP_origen"]; + echo ''.$row["descripcion"]; + echo '
"; + ?> \ No newline at end of file diff --git a/pandora_console/include/config.php b/pandora_console/include/config.php index 2f6f4864c9..1448c06fab 100644 --- a/pandora_console/include/config.php +++ b/pandora_console/include/config.php @@ -24,8 +24,8 @@ $pandora_version="v1.3 devel"; // Database configuration $dbname="pandora"; // MySQL DataBase -$dbuser="pandora"; // DB User -$dbpassword="pandora"; // Password +$dbuser="root"; // DB User +$dbpassword=""; // Password $dbhost="localhost"; // MySQL Host $dbtype="mysql"; // Type of Database, now only "mysql" its supported $attachment_store="/var/www/pandora_console"; //This is directory where placed "attachment" directory, to upload files stores. This MUST be writtable by wwwserver user, and should be in pandora root. Please append "/" to the end :-) diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 51e23af2ee..9cdc8abcfb 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -483,8 +483,8 @@ function pagination ($count, $url, $offset ) { echo ""; } // End div and layout - } echo ""; + } } ?> diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index 7fc50fceef..c1f2dd5d86 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -186,9 +186,9 @@ echo ""; // Fill event type combo (DISTINCT!) if (isset($ev_group) && ($ev_group > 1)) - $sql="SELECT DISTINCT evento FROM tevento WHERE id_grupo = '$ev_group' DESC LIMIT $offset, $block_size"; + $sql="SELECT DISTINCT evento FROM tevento WHERE id_grupo = '$ev_group'"; else - $sql="SELECT DISTINCT evento FROM tevento DESC LIMIT $offset, $block_size"; + $sql="SELECT DISTINCT evento FROM tevento"; $result=mysql_query($sql); // Make query for distinct (to fill combo) while ($row=mysql_fetch_array($result)) @@ -219,66 +219,68 @@ $result3=mysql_query($sql3); $row3=mysql_fetch_array($result3); $total_events = $row3[0]; // Show pagination header -pagination($total_events, "index.php?sec=eventos&sec2=operation/events/events", $offset); - -// Show data. - -echo "
"; -echo ""; -echo ""; -echo ""; -echo ""; -echo ""; -echo ""; -echo ""; -echo ""; -echo ""; -echo "'; -echo ""; -$color = 1; -$id_evento = 0; -// Prepare index for pagination. Prepare queries -if ($event=="All"){ - if (isset($ev_group) && ($ev_group > 1)) { - $sql2="SELECT * FROM tevento WHERE id_grupo = '$ev_group' ORDER BY timestamp DESC LIMIT $offset, $block_size"; - } else { - $sql2="SELECT * FROM tevento ORDER BY timestamp DESC LIMIT $offset, $block_size"; - } -} else { - if (isset($ev_group) && ($ev_group > 1)) { - $sql2="SELECT * FROM tevento WHERE evento = '$event' AND id_grupo = '$ev_group' ORDER BY timestamp DESC LIMIT $offset, $block_size"; - } else { - $sql2="SELECT * FROM tevento WHERE evento = '$event' ORDER BY timestamp DESC LIMIT $offset, $block_size"; - } -} -// Make query for data (all data, not only distinct). -$result2=mysql_query($sql2); -while ($row2=mysql_fetch_array($result2)){ - $id_grupo = $row2["id_grupo"]; - if (give_acl($id_user, $id_grupo, "IR") == 1){ // Only incident read access to view data ! - $id_group = $row2["id_grupo"]; - if ($color == 1){ - $tdcolor = "datos"; - $color = 0; - } - else { - $tdcolor = "datos2"; - $color = 1; - } +if ($total_events > 0){ + pagination($total_events, "index.php?sec=eventos&sec2=operation/events/events", $offset); + // Show data. - echo ""; - echo "
".$lang_label["status"]."".$lang_label["event_name"]."".$lang_label["agent_name"]."".$lang_label["group"]."".$lang_label["id_user"]."".$lang_label["timestamp"]."".$lang_label["action"].""; -echo ""; -echo '
"; - if ($row2["estado"] == 0) - echo ""; - else - echo ""; - echo "".$row2["evento"]; - if ($row2["id_agente"] > 0){ - echo "".dame_nombre_agente($row2["id_agente"]).""; - echo ""; + echo "
"; + echo "
"; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "'; + echo ""; + $color = 1; + $id_evento = 0; + + // Prepare index for pagination. Prepare queries + if ($event=="All"){ + if (isset($ev_group) && ($ev_group > 1)) { + $sql2="SELECT * FROM tevento WHERE id_grupo = '$ev_group' ORDER BY timestamp DESC LIMIT $offset, $block_size"; + } else { + $sql2="SELECT * FROM tevento ORDER BY timestamp DESC LIMIT $offset, $block_size"; + } + } else { + if (isset($ev_group) && ($ev_group > 1)) { + $sql2="SELECT * FROM tevento WHERE evento = '$event' AND id_grupo = '$ev_group' ORDER BY timestamp DESC LIMIT $offset, $block_size"; + } else { + $sql2="SELECT * FROM tevento WHERE evento = '$event' ORDER BY timestamp DESC LIMIT $offset, $block_size"; + } + } + + // Make query for data (all data, not only distinct). + $result2=mysql_query($sql2); + while ($row2=mysql_fetch_array($result2)){ + $id_grupo = $row2["id_grupo"]; + if (give_acl($id_user, $id_grupo, "IR") == 1){ // Only incident read access to view data ! + $id_group = $row2["id_grupo"]; + if ($color == 1){ + $tdcolor = "datos"; + $color = 0; + } + else { + $tdcolor = "datos2"; + $color = 1; + } + echo ""; + echo ""; - //} + } } -} + + echo ""; + echo ""; -echo "
".$lang_label["status"]."".$lang_label["event_name"]."".$lang_label["agent_name"]."".$lang_label["group"]."".$lang_label["id_user"]."".$lang_label["timestamp"]."".$lang_label["action"].""; + echo ""; + echo '
"; + if ($row2["estado"] == 0) + echo ""; + else + echo ""; + echo "".$row2["evento"]; + if ($row2["id_agente"] > 0){ + echo "".dame_nombre_agente($row2["id_agente"]).""; + echo ""; } else { // for SNMP generated alerts echo "".$lang_label["alert"]." / SNMP"; echo ""; @@ -287,33 +289,28 @@ while ($row2=mysql_fetch_array($result2)){ echo " ".dame_nombre_real($row2["id_usuario"])."".substr($row2["id_usuario"],0,8).""; echo "".$row2["timestamp"]; echo ""; - + if (($row2["estado"] == 0) and (give_acl($id_user,$id_group,"IW") ==1)) echo ""; if (give_acl($id_user,$id_group,"IM") ==1) echo " "; - + if (give_acl($id_user,$id_group,"IW") == 1) echo ""; - + echo ""; echo ""; echo "
"; -echo "
"; - -echo " "; -if (give_acl($id_user, 0,"IM") ==1){ - echo ""; -} -echo "
"; - - /* else {echo "

".$lang_label["no_event"]."
";} - } */ - - + echo " "; + if (give_acl($id_user, 0,"IM") ==1){ + echo ""; + } + echo ""; +} // no events to show ?> \ No newline at end of file diff --git a/pandora_console/operation/incidents/incident.php b/pandora_console/operation/incidents/incident.php index 634a2210f4..be62dc99c4 100644 --- a/pandora_console/operation/incidents/incident.php +++ b/pandora_console/operation/incidents/incident.php @@ -33,6 +33,14 @@ if (give_acl($id_usuario, 0, "IR")!=1) { exit; } +// Take input parameters + +// Offset adjustment +if (isset($_GET["offset"])) + $offset=$_GET["offset"]; +else + $offset=0; + // Delete incident if (isset($_GET["quick_delete"])){ $id_inc = $_GET["quick_delete"]; @@ -44,8 +52,8 @@ if (isset($_GET["quick_delete"])){ if ((give_acl($id_usuario, $row2["id_grupo"], "IM") ==1) OR ($_SESSION["id_usuario"] == $id_author_inc) ){ borrar_incidencia($id_inc); echo "

".$lang_label["del_incid_ok"]."

"; - } - else { + audit_db($id_author_inc,$REMOTE_ADDR,"Incident deleted","User ".$id_usuario." deleted incident #".$id_inc); + } else { audit_db($id_author_inc,$REMOTE_ADDR,"ACL Forbidden","User ".$_SESSION["id_usuario"]." try to delete incident"); echo "

".$lang_label["del_incid_no"]."

"; no_permission(); @@ -68,8 +76,11 @@ if ((isset($_GET["action"])) AND ($_GET["action"]=="update")){ $ahora=date("Y/m/d H:i:s"); $sql = "UPDATE tincidencia SET actualizacion = '".$ahora."', titulo = '".$titulo."', origen= '".$origen."', estado = '".$estado."', id_grupo = '".$grupo."', id_usuario = '".$usuario."', prioridad = '".$prioridad."', descripcion = '".$descripcion."' WHERE id_incidencia = ".$id_inc; $result=mysql_query($sql); + audit_db($id_author_inc,$REMOTE_ADDR,"Incident updated","User ".$id_usuario." deleted updated #".$id_inc); if ($result) echo "

".$lang_label["upd_incid_ok"]."

"; + else + echo "

".$lang_label["upd_incid_no"]."

"; } else { audit_db($id_usuario,$REMOTE_ADDR,"ACL Forbidden","User ".$_SESSION["id_usuario"]." try to update incident"); echo "

".$lang_label["upd_incid_no"]."

"; @@ -92,9 +103,11 @@ if ((isset($_GET["action"])) AND ($_GET["action"]=="insert")){ $id_creator = $id_usuario; $estado = entrada_limpia($_POST["estado_form"]); $sql = " INSERT INTO tincidencia (inicio,actualizacion,titulo,descripcion,id_usuario,origen,estado,prioridad,id_grupo, id_creator) VALUES ('".$inicio."','".$actualizacion."','".$titulo."','".$descripcion."','".$usuario."','".$origen."','".$estado."','".$prioridad."','".$grupo."','".$id_creator."') "; - if (mysql_query($sql)) + if (mysql_query($sql)){ echo "

".$lang_label["create_incid_ok"]."

"; $id_inc=mysql_insert_id(); + audit_db($usuario,$REMOTE_ADDR,"Incident created","User ".$id_usuario." created incident #".$id_inc); + } } else { audit_db($id_usuario,$REMOTE_ADDR,"ACL Forbidden","User ".$_SESSION["id_usuario"]." try to create incident"); no_permission(); @@ -167,10 +180,11 @@ if (isset($_POST['estado']) OR (isset($_POST['grupo'])) OR (isset($_POST['priori } } - $sql0="SELECT * FROM tincidencia ".$sql1." ORDER BY actualizacion DESC"; $sql1_count="SELECT COUNT(id_incidencia) FROM tincidencia ".$sql1; $sql1=$sql0; +$sql1=$sql1." LIMIT $offset, $block_size"; + echo "

".$lang_label["incident_manag"]."

"; echo "

".$lang_label["manage_incidents"]." ".$lang_label["help"]."

"; if (isset($_POST['operacion'])){ @@ -192,9 +206,13 @@ if (isset($_POST['operacion'])){ // 3 - Caducada (out of date) // 13 - Cerrada (closed) - if (isset($_GET["estado"])){ - echo "