// Please see http://pandora.sourceforge.net for full contribution list // 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 for version 2. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // Load global vars require("include/config.php"); if (give_acl($id_user, 0, "AW") != 1) { audit_db($id_user,$REMOTE_ADDR, "ACL Violation", "Trying to access Agent Management"); require ("general/noaccess.php"); exit; } // Take some parameters (GET) $offset = get_parameter ("offset", 0); $group_id = get_parameter ("group_id", 0); $ag_group = get_parameter ("ag_group", -1); if (($ag_group == -1) && ($group_id != 0)) $ag_group = $group_id; if (isset($_GET["ag_group_refresh"])){ $ag_group = $_GET["ag_group_refresh"]; } $search = get_parameter ("search", ""); if (isset($_GET["borrar_agente"])){ // if delete agent $id_agente = entrada_limpia($_GET["borrar_agente"]); $agent_name = dame_nombre_agente($id_agente); $id_grupo = dame_id_grupo($id_agente); if (give_acl($id_user, $id_grupo, "AW")==1){ // Firts delete from agents table $sql_delete= "DELETE FROM tagente WHERE id_agente = ".$id_agente; $result=mysql_query($sql_delete); if (! $result) echo "

".$lang_label["delete_agent_no"]."

"; else echo "

".$lang_label["delete_agent_ok"]."

"; // Delete agent access table $sql_delete = "DELETE FROM tagent_access WHERE id_agent = ".$id_agente; // Delete tagente_datos data $result=mysql_query($sql_delete); $sql_delete4="DELETE FROM tagente_datos WHERE id_agente=".$id_agente; $result=mysql_query($sql_delete4); // Delete tagente_datos_string data $result=mysql_query($sql_delete); $sql_delete4="DELETE FROM tagente_datos_string WHERE id_agente=".$id_agente; $result=mysql_query($sql_delete4); // Delete from tagente_datos $sql1='SELECT * FROM tagente_modulo WHERE id_agente = '.$id_agente; $result1=mysql_query($sql1); while ($row=mysql_fetch_array($result1)){ $sql_delete4="DELETE FROM tagente_datos_inc WHERE id_agente_modulo=".$row["id_agente_modulo"]; $result=mysql_query($sql_delete4); } $sql_delete2 ="DELETE FROM tagente_modulo WHERE id_agente = ".$id_agente; $sql_delete3 ="DELETE FROM tagente_estado WHERE id_agente = ".$id_agente; $result=mysql_query($sql_delete2); $result=mysql_query($sql_delete3); // Delete IPs from tadress table and taddress_agent $sql = "SELECT * FROM taddress_agent where id_agent = $id_agente"; $result=mysql_query($sql); while ($row=mysql_fetch_array($result)){ $sql2="DELETE FROM taddress where id_a = ".$row["id_a"]; $result2=mysql_query($sql2); } $sql = "DELETE FROM taddress_agent where id_agent = $id_agente"; $result=mysql_query($sql); audit_db($id_user,$REMOTE_ADDR, "Agent '$agent_name' deleted", "Agent Management"); } else { // NO permissions. audit_db($id_user,$REMOTE_ADDR, "ACL Violation", "Trying to delete agent '$agent_name'"); require ("general/noaccess.php"); exit; } } echo "

".$lang_label["agent_conf"]." > ".$lang_label["agent_defined2"]."

"; // Show group selector if (isset($_POST["ag_group"])){ $ag_group = $_POST["ag_group"]; echo "
"; } else { echo ""; } echo ""; echo ""; echo "
".$lang_label["group"].""; echo ""; echo " "; echo $lang_label["free_text_search"]; echo ""; // Show group selector if (isset($_POST["ag_group"])){ $group_mod = "&ag_group_refresh=".$_POST["ag_group"]; } else { $group_mod =""; } echo "
"; echo ""; echo "
"; echo ""; echo ""; echo "
"; if ($search != ""){ $search_sql = " AND nombre LIKE '%$search%' "; } else { $search_sql = ""; } // Show only selected groups if ($ag_group > 1){ $sql1="SELECT * FROM tagente WHERE id_grupo=$ag_group AND disabled = 0 $search_sql ORDER BY nombre LIMIT $offset, ".$config["block_size"]; $sql2="SELECT COUNT(id_agente) FROM tagente WHERE id_grupo = $ag_group AND disabled = 0 $search_sql ORDER BY nombre"; } else { // Is admin user ?? if (get_db_sql ("SELECT * FROM tusuario WHERE id_usuario ='$id_user'", "nivel") == 1){ $sql1 = "SELECT * FROM tagente WHERE disabled = 0 $search_sql ORDER BY nombre, id_grupo LIMIT $offset, ".$config["block_size"]; $sql2="SELECT COUNT(id_agente) FROM tagente WHERE disabled = 0 $search_sql ORDER BY nombre, id_grupo"; } else { $sql1="SELECT * FROM tagente WHERE disabled = 0 $search_sql AND id_grupo IN (SELECT id_grupo FROM tusuario_perfil WHERE id_usuario='$id_user') ORDER BY nombre, id_grupo LIMIT $offset, ".$config["block_size"]; $sql2="SELECT COUNT(id_agente) FROM tagente WHERE disabled = 0 $search_sql AND id_grupo IN (SELECT id_grupo FROM tusuario_perfil WHERE id_usuario='$id_user') ORDER BY nombre, id_grupo"; } } $result=mysql_query($sql1); $result2=mysql_query($sql2); $row2=mysql_fetch_array($result2); $total_events = $row2[0]; // Prepare pagination pagination ($total_events, "index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id=$ag_group", $offset); echo "
"; if (mysql_num_rows($result)){ echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; $color=1; while ($row=mysql_fetch_array($result)){ $id_grupo = $row["id_grupo"]; if ($color == 1){ $tdcolor = "datos"; $color = 0; } else { $tdcolor = "datos2"; $color = 1; } if (give_acl($id_user, $id_grupo, "AW")==1){ // Agent name echo ""; // Operating System icon echo ""; // Group icon and name echo ""; // Description echo ""; // Action echo ""; } } echo "
".$lang_label["agent_name"]."".$lang_label["os"]."".$lang_label["group"]."".$lang_label["description"]."".$lang_label["delete"]."
".substr(strtoupper($row["nombre"]),0,20)."   ".dame_grupo($id_grupo)."".$row["comentarios"]."'; echo "
"; echo "
"; } else { echo "
".$lang_label["no_agent_def"]."
"; echo " 
"; } // Create agent button echo "
"; echo ""; echo "
"; ?>