2009-02-04 Esteban Sanchez <estebans@artica.es>

* general/login_page.php: Removed width of login error.

	* godmode/agentes/agent_manager.php,
	godmode/agentes/configurar_agente.php: Fixed various errors when
	creating an agent.

	* godmode/agentes/alert_manager.php: Typo error on em closing element.
	Use invisible class instead of style attribute.

	* godmode/agentes/modificar_agente.php: Style correction. Improved a
	bit the interface so the user can go directly to any tab. Fixed agent
	creation parameter.

	* pandoradb.sql: Make disabled field on tagente_modulo not null. It
	could cause some server side errors.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1422 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
Esteban Sanchez 2009-02-04 11:20:31 +00:00
parent b7efdb8358
commit 5c32051348
7 changed files with 165 additions and 97 deletions

View File

@ -1,3 +1,21 @@
2009-02-04 Esteban Sanchez <estebans@artica.es>
* general/login_page.php: Removed width of login error.
* godmode/agentes/agent_manager.php,
godmode/agentes/configurar_agente.php: Fixed various errors when
creating an agent.
* godmode/agentes/alert_manager.php: Typo error on em closing element.
Use invisible class instead of style attribute.
* godmode/agentes/modificar_agente.php: Style correction. Improved a
bit the interface so the user can go directly to any tab. Fixed agent
creation parameter.
* pandoradb.sql: Make disabled field on tagente_modulo not null. It
could cause some server side errors.
2009-02-02 Esteban Sanchez <estebans@artica.es> 2009-02-02 Esteban Sanchez <estebans@artica.es>
* godmode/agentes/configurar_agente.php, * godmode/agentes/configurar_agente.php,

View File

@ -32,7 +32,7 @@ echo '<div class="databox" id="login">
if (isset ($login_failed)) { if (isset ($login_failed)) {
echo '<tr><td colspan="3">'; echo '<tr><td colspan="3">';
echo '<h3 class="error" style="width: 200px">'.__('Login failed').': '.$config["auth_error"].'</h3>'; echo '<h3 class="error">'.__('Login failed').': '.$config["auth_error"].'</h3>';
echo '</td></tr>'; echo '</td></tr>';
} }

View File

@ -28,8 +28,8 @@ if (!isset ($id_agente)) {
// ======================== // ========================
echo "<h2>".__('Agent configuration'); echo "<h2>".__('Agent configuration');
if (isset($_GET["create_agent"])) { $new_agent = (bool) get_parameter ('new_agent');
$create_agent = 1; if ($new_agent) {
echo " &gt; ".__('Create agent'); echo " &gt; ".__('Create agent');
} else { } else {
echo " &gt; ".__('Update agent'); echo " &gt; ".__('Update agent');
@ -82,7 +82,7 @@ if (file_exists ($filename['md5'])) {
$table->data[1][0] = '<b>'.__('IP Address').'</b>'; $table->data[1][0] = '<b>'.__('IP Address').'</b>';
$table->data[1][1] = print_input_text ('direccion', $direccion_agente, '', 16, 100, true); $table->data[1][1] = print_input_text ('direccion', $direccion_agente, '', 16, 100, true);
if ($create_agent != 1) { if (! $new_agent) {
$table->data[1][1] .= '&nbsp;&nbsp;&nbsp;&nbsp;'; $table->data[1][1] .= '&nbsp;&nbsp;&nbsp;&nbsp;';
$ip_all = get_agent_addresses ($id_agente); $ip_all = get_agent_addresses ($id_agente);
@ -159,7 +159,7 @@ print_table ($table);
unset ($table); unset ($table);
echo '<div style="width: 650px; text-align: right;">'; echo '<div style="width: 650px; text-align: right;">';
if ($create_agent == 1) { if ($new_agent) {
print_submit_button (__('Create'), 'crtbutton', false, 'class="sub wand"'); print_submit_button (__('Create'), 'crtbutton', false, 'class="sub wand"');
print_input_hidden ('create_agent', 1); print_input_hidden ('create_agent', 1);
} else { } else {

View File

@ -135,7 +135,7 @@ foreach ($modules as $id_agent_module => $module) {
$table->data[0][0] .= '<span class="module_values" style="float: right;">'; $table->data[0][0] .= '<span class="module_values" style="float: right;">';
$table->data[0][0] .= '<em>'.__('Latest value').'</em>: '; $table->data[0][0] .= '<em>'.__('Latest value').'</em>: ';
if ($last_data == '') if ($last_data == '')
$table->data[0][0] .= '<em>'.__('Empty').'</emp>'; $table->data[0][0] .= '<em>'.__('Empty').'</em>';
elseif (is_numeric ($last_data)) elseif (is_numeric ($last_data))
$table->data[0][0] .= format_numeric ($last_data); $table->data[0][0] .= format_numeric ($last_data);
else else
@ -239,7 +239,7 @@ foreach ($modules as $id_agent_module => $module) {
} }
$alert_data[1] .= '</ul>'; $alert_data[1] .= '</ul>';
$alert_data[1] .= '<div class="actions left" style="visibility: hidden; clear: left">'; $alert_data[1] .= '<div class="actions left invisible" style="clear: left">';
$alert_data[1] .= '<a class="add_action" id="add-action-'.$alert['id'].'" href="#">'; $alert_data[1] .= '<a class="add_action" id="add-action-'.$alert['id'].'" href="#">';
$alert_data[1] .= __('Add action'); $alert_data[1] .= __('Add action');
$alert_data[1] .= '</a>'; $alert_data[1] .= '</a>';
@ -261,7 +261,7 @@ if (isset($module)){
print_input_hidden ('add_action', 1); print_input_hidden ('add_action', 1);
print_input_hidden ('id_alert_module', 0); print_input_hidden ('id_alert_module', 0);
echo '<form class="add_alert_form" method="post" style="display: none" echo '<form class="add_alert_form" method="post" class="invisible"
action="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=alert&id_agente='. action="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=alert&id_agente='.
$module['id_agente'].'">'; $module['id_agente'].'">';
echo '<div style="float:left">'; echo '<div style="float:left">';
@ -278,7 +278,7 @@ if (isset($module)){
print_select ($actions, 'action', '', '', __('None'), 0); print_select ($actions, 'action', '', '', __('None'), 0);
echo '<br />'; echo '<br />';
echo '<span><a href="#" class="show_advanced_actions">'.__('Advanced options').' &raquo; </a></span>'; echo '<span><a href="#" class="show_advanced_actions">'.__('Advanced options').' &raquo; </a></span>';
echo '<span class="advanced_actions" style="display: none">'; echo '<span class="advanced_actions invisible">';
echo __('From').' '; echo __('From').' ';
print_input_text ('fires_min', -1, '', 4, 10); print_input_text ('fires_min', -1, '', 4, 10);
echo ' '.__('to').' '; echo ' '.__('to').' ';

View File

@ -28,7 +28,7 @@ $id_agente = (int) get_parameter ("id_agente", -1);
$group = get_agent_group ($id_agente); $group = get_agent_group ($id_agente);
if (! give_acl($config["id_user"], $group, "AW")) { if (! give_acl ($config["id_user"], $group, "AW")) {
audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation", audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation",
"Trying to access agent manager"); "Trying to access agent manager");
require ("general/noaccess.php"); require ("general/noaccess.php");
@ -163,7 +163,7 @@ if ($create_agent) {
if ($id_agent_module !== false) { if ($id_agent_module !== false) {
// Create agent_keepalive in tagente_estado table // Create agent_keepalive in tagente_estado table
$result = process_sql_insert ('tagente_modulo', $result = process_sql_insert ('tagente_estado',
array ('id_agente_modulo' => $id_agent_module, array ('id_agente_modulo' => $id_agent_module,
'datos' => '', 'datos' => '',
'timestamp' => 0, 'timestamp' => 0,

View File

@ -24,15 +24,23 @@ require_once ("include/config.php");
check_login (); check_login ();
// Take some parameters (GET) // Take some parameters (GET)
$offset = get_parameter ("offset", 0); $offset = (int) get_parameter ("offset");
$group_id = get_parameter ("group_id", 0); $group_id = (int) get_parameter ("group_id");
$ag_group = get_parameter ("ag_group", -1); $ag_group = get_parameter ("ag_group_refresh", -1);
if (($ag_group == -1) && ($group_id != 0)) {
if ($ag_group == -1 )
$ag_group = (int) get_parameter ("ag_group", -1);
if (($ag_group == -1) && ($group_id != 0))
$ag_group = $group_id; $ag_group = $group_id;
if (! give_acl ($config["id_user"], $ag_group, "AW")) {
audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation",
"Trying to access agent manager");
require ("general/noaccess.php");
exit;
} }
if (isset ($_GET["ag_group_refresh"])){
$ag_group = get_parameter_get ("ag_group_refresh", -1);
}
$search = get_parameter ("search", ""); $search = get_parameter ("search", "");
if (isset ($_GET["borrar_agente"])) { // if delete agent if (isset ($_GET["borrar_agente"])) { // if delete agent
@ -68,7 +76,7 @@ echo "<td valign='top'>";
echo "<select name='ag_group' onChange='javascript:this.form.submit();' echo "<select name='ag_group' onChange='javascript:this.form.submit();'
class='w130'>"; class='w130'>";
if ( $ag_group > 1 ){ if ($ag_group > 1) {
echo "<option value='".$ag_group."'>".get_group_name ($ag_group). echo "<option value='".$ag_group."'>".get_group_name ($ag_group).
"</option>"; "</option>";
} }
@ -77,8 +85,7 @@ $mis_grupos = list_group ($config["id_user"]); //Print combo for groups and set
echo "</select>"; echo "</select>";
echo "<td valign='top'> echo "<td valign='top'>
<noscript> <noscript>
<input name='uptbutton' type='submit' class='sub upd' <input name='uptbutton' type='submit' class='sub upd' value='".__('Show')."'>
value='".__('Show')."'>
</noscript> </noscript>
</td> </td>
</form> </form>
@ -89,54 +96,65 @@ echo "</td><td>";
// Show group selector // Show group selector
if (isset($_POST["ag_group"])){ if (isset($_POST["ag_group"])){
$group_mod = "&ag_group_refresh=".get_parameter_post ("ag_group"); $group_mod = "&ag_group_refresh=".get_parameter_post ("ag_group");
} else { } else {
$group_mod =""; $group_mod ="";
} }
echo "<form method='post' action='index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&refr=60$group_mod'>"; echo "<form method='post' action='index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&refr=60$group_mod'>";
echo "<input type=text name='search' size='15' >"; echo "<input type=text name='search' size='15' >";
echo "</td><td valign='top'>"; echo "</td><td valign='top'>";
echo "<input name='srcbutton' type='submit' class='sub' echo "<input name='srcbutton' type='submit' class='sub' value='".__('Search')."'>";
value='".__('Search')."'>";
echo "</form>"; echo "</form>";
echo "</td></table>"; echo "</td></table>";
$search_sql = '';
if ($search != ""){ if ($search != ""){
$search_sql = " nombre LIKE '%$search%' "; $search_sql = " AND nombre LIKE '%$search%' ";
} else { } else {
$search_sql = " 1 = 1";
} }
// Show only selected groups // Show only selected groups
if ($ag_group > 1){ if ($ag_group > 1) {
$sql1="SELECT * FROM tagente WHERE id_grupo = $ag_group $sql = sprintf ('SELECT COUNT(*)
AND $search_sql ORDER BY nombre LIMIT $offset, ".$config["block_size"]; FROM tagente
$sql2="SELECT COUNT(id_agente) FROM tagente WHERE id_grupo = $ag_group WHERE id_grupo = %d
AND $search_sql ORDER BY nombre"; %s',
$ag_group, $search_sql);
$total_agents = get_db_sql ($sql);
$sql = sprintf ('SELECT *
FROM tagente
WHERE id_grupo = %d
%s
ORDER BY nombre LIMIT %d, %d',
$ag_group, $search_sql, $offset, $config["block_size"]);
} else { } else {
// Is admin user ?? $sql = sprintf ('SELECT COUNT(*)
if (is_user_admin ($config["id_user"])) { FROM tagente
$sql1 = "SELECT * FROM tagente WHERE $search_sql ORDER BY nombre, id_grupo LIMIT $offset, ".$config["block_size"]; WHERE id_grupo IN (%s)
$sql2="SELECT COUNT(id_agente) FROM tagente WHERE $search_sql ORDER BY nombre, id_grupo"; %s',
} else { implode (',', array_keys (get_user_groups ())),
$sql1="SELECT * FROM tagente WHERE $search_sql AND id_grupo IN (SELECT id_grupo FROM tusuario_perfil WHERE id_usuario='".$config["id_user"]."') $search_sql);
ORDER BY nombre, id_grupo LIMIT $offset, ".$config["block_size"]; $total_agents = get_db_sql ($sql);
$sql2="SELECT COUNT(id_agente) FROM tagente WHERE $search_sql AND id_grupo IN (SELECT id_grupo FROM tusuario_perfil WHERE id_usuario='".$config["id_user"]."') ORDER BY nombre, id_grupo";
} $sql = sprintf ('SELECT *
FROM tagente
WHERE id_grupo IN (%s)
%s
ORDER BY nombre LIMIT %d, %d',
implode (',', array_keys (get_user_groups ())),
$search_sql, $offset, $config["block_size"]);
} }
$result=mysql_query($sql1); $agents = get_db_all_rows_sql ($sql);
$result2=mysql_query($sql2);
$row2=mysql_fetch_array($result2);
$total_events = $row2[0];
// Prepare pagination // Prepare pagination
pagination ($total_events, "index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id=$ag_group", $offset); pagination ($total_agents, "index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id=$ag_group", $offset);
echo "<div style='height: 20px'> </div>"; echo "<div style='height: 20px'> </div>";
if (mysql_num_rows($result)){ if ($agents !== false) {
echo "<table cellpadding='4' cellspacing='4' width='750' class='databox'>"; echo "<table cellpadding='4' id='agent_list' cellspacing='4' width='95%' class='databox'>";
echo "<th>".__('Agent name')."</th>"; echo "<th>".__('Agent name')."</th>";
echo "<th title='".__('Remote agent configuration')."'>".__('R')."</th>"; echo "<th title='".__('Remote agent configuration')."'>".__('R')."</th>";
echo "<th>".__('OS')."</th>"; echo "<th>".__('OS')."</th>";
@ -144,8 +162,10 @@ if (mysql_num_rows($result)){
echo "<th>".__('Description')."</th>"; echo "<th>".__('Description')."</th>";
echo "<th>".__('Delete')."</th>"; echo "<th>".__('Delete')."</th>";
$color=1; $color=1;
while ($row=mysql_fetch_array($result)){ foreach ($agents as $agent) {
$id_grupo = $row["id_grupo"]; $id_grupo = $agent["id_grupo"];
if (! give_acl ($config["id_user"], $id_grupo, "AW"))
continue;
if ($color == 1){ if ($color == 1){
$tdcolor = "datos"; $tdcolor = "datos";
$color = 0; $color = 0;
@ -154,58 +174,88 @@ if (mysql_num_rows($result)){
$tdcolor = "datos2"; $tdcolor = "datos2";
$color = 1; $color = 1;
} }
if (give_acl($config["id_user"], $id_grupo, "AW")==1){
// Agent name
echo "<tr><td class='$tdcolor'>";
if ($row["disabled"] == 1){
echo "<i>";
}
echo "<b><a href='index.php?sec=gagente&
sec2=godmode/agentes/configurar_agente&tab=main&
id_agente=".$row["id_agente"]."'>".substr(strtoupper($row["nombre"]),0,20)."</a></b>";
if ($row["disabled"] == 1){
echo "<i>";
}
echo "</td>";
echo "<td align='center' class='$tdcolor'>"; // Agent name
// Has remote configuration ? echo "<tr><td class='$tdcolor' width='40%'>";
$agent_md5 = md5($row["nombre"], FALSE); if ($agent["disabled"]){
if (file_exists($config["remote_config"] . "/" . $agent_md5 . ".md5")){ echo "<em>";
echo "<a href='index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=main&id_agente=".$row["id_agente"]."&disk_conf=" . $agent_md5 . "'>";
echo "<img src='images/application_edit.png' border='0' align='middle' title='".__('Edit remote config')."'>";
echo "</A>";
}
echo "</td>";
// Operating System icon
echo "<td class='$tdcolor' align='center'>";
print_os_icon ($row["id_os"], false);
echo "</td>";
// Group icon and name
echo "<td class='$tdcolor' align='center'>".print_group_icon ($id_grupo, true)."</td>";
// Description
echo "<td class='".$tdcolor."f9'>".$row["comentarios"]."</td>";
// Action
echo "<td class='$tdcolor' align='center'><a href='index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&
borrar_agente=".$row["id_agente"]."'";
echo ' onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">';
echo "<img border='0' src='images/cross.png'></a></td>";
} }
echo '<span class="left">';
echo "<strong><a href='index.php?sec=gagente&
sec2=godmode/agentes/configurar_agente&tab=main&
id_agente=".$agent["id_agente"]."'>".substr(strtoupper($agent["nombre"]),0,20)."</a></strong>";
if ($agent["disabled"]) {
echo "</em>";
}
echo '</span><div class="left actions" style="visibility: hidden; clear: left">';
echo '<a href="index.php?sec=gagente&
sec2=godmode/agentes/configurar_agente&tab=main&
id_agente='.$agent["id_agente"].'">'.__('Edit').'</a>';
echo ' | ';
echo '<a href="index.php?sec=gagente&
sec2=godmode/agentes/configurar_agente&tab=module&
id_agente='.$agent["id_agente"].'">'.__('Modules').'</a>';
echo ' | ';
echo '<a href="index.php?sec=gagente&
sec2=godmode/agentes/configurar_agente&tab=alert&
id_agente='.$agent["id_agente"].'">'.__('Alerts').'</a>';
echo ' | ';
echo '<a href="index.php?sec=estado
&sec2=operation/agentes/ver_agente
&id_agente='.$agent["id_agente"].'">'.__('View').'</a>';
echo '</div>';
echo "</td>";
echo "<td align='center' class='$tdcolor'>";
// Has remote configuration ?
$agent_md5 = md5 ($agent["nombre"], false);
if (file_exists($config["remote_config"]."/".$agent_md5.".md5")) {
echo "<a href='index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=main&id_agente=".$agent["id_agente"]."&disk_conf=" . $agent_md5 . "'>";
echo "<img src='images/application_edit.png' border='0' align='middle' title='".__('Edit remote config')."'>";
echo "</a>";
}
echo "</td>";
// Operating System icon
echo "<td class='$tdcolor' align='center'>";
print_os_icon ($agent["id_os"], false);
echo "</td>";
// Group icon and name
echo "<td class='$tdcolor' align='center'>".print_group_icon ($id_grupo, true)."</td>";
// Description
echo "<td class='".$tdcolor."f9'>".$agent["comentarios"]."</td>";
// Action
echo "<td class='$tdcolor' align='center'><a href='index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&
borrar_agente=".$agent["id_agente"]."'";
echo ' onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">';
echo "<img border='0' src='images/cross.png'></a></td>";
} }
echo "</table>"; echo "</table>";
echo "<table width='750'><tr><td align='right'>"; echo "<table width='95%'><tr><td align='right'>";
} else { } else {
echo "<div class='nf'>".__('There are no defined agents')."</div>"; echo "<div class='nf'>".__('There are no defined agents')."</div>";
echo "&nbsp;</td></tr><tr><td>"; echo "&nbsp;</td></tr><tr><td>";
} }
// Create agent button // Create agent button
echo "<form method='post' action='index.php?sec=gagente& echo "<form method='post' action='index.php?sec=gagente&
sec2=godmode/agentes/configurar_agente&create_agent=1'>"; sec2=godmode/agentes/configurar_agente'>";
echo "<input type='submit' class='sub next' name='crt' print_input_hidden ('new_agent', 1);
value='".__('Create agent')."'>"; echo "<input type='submit' class='sub next' name='crt'
echo "</form></td></tr></table>"; value='".__('Create agent')."'>";
echo "</form></td></tr></table>";
?> ?>
<script type="text/javascript">
$(document).ready (function () {
$("table#agent_list tr").hover (function () {
$(".actions", this).css ("visibility", "");
},
function () {
$(".actions", this).css ("visibility", "hidden");
});
});
</script>

View File

@ -145,7 +145,7 @@ CREATE TABLE IF NOT EXISTS `tagente_modulo` (
`id_module_group` int(4) unsigned default '0', `id_module_group` int(4) unsigned default '0',
`flag` tinyint(1) unsigned default '1', `flag` tinyint(1) unsigned default '1',
`id_modulo` int(10) unsigned default '0', `id_modulo` int(10) unsigned default '0',
`disabled` tinyint(1) unsigned default '0', `disabled` tinyint(1) unsigned NOT NULL default '0',
`id_export` smallint(4) unsigned default '0', `id_export` smallint(4) unsigned default '0',
`plugin_user` varchar(250) default '', `plugin_user` varchar(250) default '',
`plugin_pass` varchar(250) default '', `plugin_pass` varchar(250) default '',