diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index a33d6acb11..7b12e8bae6 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -3,6 +3,13 @@ * general/pandora_help.php: Added a require of a functions file. Added missing HTML tags. +2008-08-21 Evi Vanoost + + * godmode/servers/modificar_server.php. + godmode/servers/manage_recontask_form.php, + godmode/servers/manage_recontask.php: HTML and SQL overhaul. Now uses + the new functions that are available in functions_html.php. + 2008-08-20 Evi Vanoost * godmode/profiles/profile_list.php: HTML overhaul (close tags, put diff --git a/pandora_console/godmode/servers/manage_recontask.php b/pandora_console/godmode/servers/manage_recontask.php index bcfa70cf32..2ce419b21f 100644 --- a/pandora_console/godmode/servers/manage_recontask.php +++ b/pandora_console/godmode/servers/manage_recontask.php @@ -1,5 +1,4 @@ ".__('Deleted successfully').""; - else - echo "

".__('Not deleted. Error deleting data')."

"; +if (isset ($_GET["delete"])) { + $id = get_parameter_get ("delete"); + $sql = sprintf("DELETE FROM trecon_task WHERE id_rt = '%d'",$id); + $result = process_sql ($sql); + if ($result !== false) { + echo '

'.__('Succesfully deleted recon task').'

'; + } else { + echo '

'.__('Error deleting recon task').'

'; + } } - -if ((isset($_GET["update"])) OR ((isset($_GET["create"])))){ - $name = entrada_limpia($_POST["name"]); - $network = entrada_limpia($_POST["network"]); - $description = entrada_limpia($_POST["description"]); - $id_recon_server = entrada_limpia($_POST["id_recon_server"]); - $interval = entrada_limpia($_POST["interval"]); - $id_group = entrada_limpia($_POST["id_group"]); - $create_incident = entrada_limpia($_POST["create_incident"]); - $id_network_profile = entrada_limpia($_POST["id_network_profile"]); - $id_os = get_parameter ("id_os", 10); - +// -------------------------------- +// GET PARAMETERS IF UPDATE OR CREATE +// -------------------------------- +if ((isset ($_GET["update"])) OR ((isset ($_GET["create"])))) { + $name = get_parameter_post ("name"); + $network = get_parameter_post ("network"); + $description = get_parameter_post ("description"); + $id_recon_server = get_parameter_post ("id_recon_server"); + $interval = get_parameter_post ("interval"); + $id_group = get_parameter_post ("id_group"); + $create_incident = get_parameter_post ("create_incident"); + $id_network_profile = get_parameter_post ("id_network_profile"); + $id_os = get_parameter_post ("id_os", 10); } // -------------------------------- // UPDATE A RECON TASK // -------------------------------- if (isset($_GET["update"])) { - $id = entrada_limpia($_GET["update"]); - $sql = "UPDATE trecon_task SET id_os = $id_os, name = '$name', subnet = '$network', - description='$description', id_recon_server = $id_recon_server, - create_incident = $create_incident, id_group = $id_group, interval_sweep = $interval, - id_network_profile = $id_network_profile WHERE id_rt = $id"; - $result=mysql_query($sql); - if ($result) - echo "

".__('Updated successfully')."

"; - else - echo "

".__('Not updated. Error updating data')."

"; + $id = get_parameter_get ("update"); + $sql = sprintf ("UPDATE trecon_task SET id_os = %d, name = '%s', subnet = '%s', + description = '%s', id_recon_server = %d, create_incident = %b, id_group = %d, interval_sweep = %u, + id_network_profile = %d WHERE id_rt = %u",$id_os,$name,$network,$description,$id_recon_server,$create_incident,$id_group,$interval,$id_network_profile,$id); + + if (process_sql ($sql) !== false) { + echo '

'.__('Successfully updated recon task').'

'; + } else { + echo '

'.__('Error updating recon task').'

'; + } } // -------------------------------- // CREATE A RECON TASK // -------------------------------- if (isset($_GET["create"])) { - $sql = "INSERT INTO trecon_task (name, subnet, description, id_recon_server, create_incident, id_group, id_network_profile, interval_sweep, id_os) VALUES ( '$name', '$network', '$description', $id_recon_server, $create_incident, $id_group, $id_network_profile, $interval, $id_os)"; - $result=mysql_query($sql); - if ($result) - echo "

".__('Created successfully')."

"; - else - echo "

".__('Not created. Error inserting data')."

"; + $sql = sprintf ("INSERT INTO trecon_task + (name, subnet, description, id_recon_server, create_incident, id_group, id_network_profile, interval_sweep, id_os) + VALUES ( '%s', '%s', '%s', %u, %b, %d, %d, %u, %d)",$name,$network,$description,$id_recon_server,$create_incident,$id_group,$id_network_profile,$interval,$id_os); + + if (process_sql ($sql) !== false) { + echo '

'.__('Successfully created recon task').'

'; + } else { + echo '

'.__('Error creating recon task').'

'; + } } // -------------------------------- // SHOW TABLE WITH ALL RECON TASKs // -------------------------------- -echo "

".__('Pandora servers')." > "; -echo __('Manage recontask')."

"; -$query="SELECT * FROM trecon_task"; -$result=mysql_query($query); +echo "

".__('Pandora servers')." > ".__('Manage recontask')."

"; + +$result = get_db_all_rows_in_table ("trecon_task"); $color=1; -if (mysql_num_rows($result)){ - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; +if ($result !== false) { + $table->head = array (__('Name'), __('Network'), __('Network profile'), __('Group'), __('Incident'), __('OS'), __('Interval'), __('Action')); + $table->align = array ("","","","center","","","center","center"); + $table->width = 700; + $table->cellpadding = 4; + $table->cellspacing = 4; + $table->class = "databox"; + + foreach ($result as $row) { + $table->data[] = array ( + ''.$row["name"].'', + // Network (subnet) + $row["subnet"], + // Network profile name + ''.give_network_profile_name ($row["id_network_profile"]).'', + // GROUP + '', + // INCIDENT + (($row["create_incident"] == 1) ? __('Yes') : __('No')), + // OS + (($row["id_os"] > 0) ? '' : __('Any')), + // INTERVAL + human_time_description_raw($row["interval_sweep"]), + // ACTION + ' +    + ' + ); + } + print_table ($table); + unset ($table); +} else { + echo '
'.__('There are no recon task configured').'
'; } -while ($row=mysql_fetch_array($result)){ - $id_rt = $row["id_rt"]; - $name = $row["name"]; - $network = $row["subnet"]; - $description = $row["description"]; -// $id_server = $row["server"]; - $type = $row["type"]; - $id_recon_server = $row["id_recon_server"]; - $interval = $row["interval_sweep"]; - $id_group = $row["id_group"]; - $create_incident = $row["create_incident"]; - $id_network_profile = $row["id_network_profile"]; - $id_os = $row["id_os"]; - - if ($color == 1){ - $tdcolor = "datos"; - $color = 0; - } - else { - $tdcolor = "datos2"; - $color = 1; - } - echo ""; - echo ""; -} -echo "
".__('Name')."".__('Type')."".__('Network')."".__('Network profile')."".__('Group')."".__('Incident')."".__('OS')."".__('Interval')."".__('Action')."
"; - echo "$name"; - - echo ""; - if ($type ==1) - echo "ICMP"; - - // Network - echo ""; - echo $network; - - // Network profile name - echo ""; - echo "".give_network_profile_name($id_network_profile).""; - - // GROUP - echo ""; - echo ""; - - // INCIDENT - echo ""; - if ($create_incident == 1) - echo __('Yes'); - else - echo __('No'); - - // OS - echo ""; - if ($id_os > 0){ - $icon = get_db_sql ("SELECT icon_name FROM tconfig_os WHERE id_os = $id_os"); - echo ""; - } - - // INTERVAL - echo ""; - echo human_time_description_raw($interval); - - // ACTION - echo ""; - echo "  "; - echo ""; - echo "
"; - -if (!mysql_num_rows($result)){ - echo "
".__('There are no recon task configured')."
"; -} - -echo ""; -echo "
"; -echo "
"; -echo ""; -echo "
"; +$table->align = array ("right"); +$table->width = 700; +$table->data[] = array ('
'.print_submit_button (__('Create'),"crt",false,'class="sub next"',true).'
'); +print_table($table); +unset($table); ?> diff --git a/pandora_console/godmode/servers/manage_recontask_form.php b/pandora_console/godmode/servers/manage_recontask_form.php index b3d1065410..7f595c7b54 100644 --- a/pandora_console/godmode/servers/manage_recontask_form.php +++ b/pandora_console/godmode/servers/manage_recontask_form.php @@ -28,160 +28,126 @@ if (! give_acl ($config['id_user'], 0, "PM")) { } if (isset ($_GET["update"])) { // Edit mode - $id_rt = $_GET["update"]; - $query="SELECT * FROM trecon_task where id_rt = $id_rt"; - $result=mysql_query($query); - $row=mysql_fetch_array($result); + $id_rt = (int) get_parameter_get ("update"); + $row = get_db_row ("trecon_task","id_rt",$id_rt); $name = $row["name"]; $network = $row["subnet"]; $id_recon_server = $row["id_recon_server"]; $description = $row["description"]; - $type = $row["type"]; $interval = $row["interval_sweep"]; $id_group = $row["id_group"]; $create_incident = $row["create_incident"]; $id_network_profile = $row["id_network_profile"]; $id_os = $row["id_os"]; - } elseif (isset ($_GET["create"])) { $id_rt = -1; $name = ""; $network = ""; $description = ""; $id_recon_server = 0; - $type = 1; $interval = 43200; $id_group = 1; $create_incident = 1; $id_network_profile = 1; - $id_os = 10; // Other + $id_os = -1; // Any } -echo '

'.__('Pandora servers').' > '; -echo __('Manage recontask'); +echo '

'.__('Pandora servers').' > '.__('Manage recontask'); pandora_help ("recontask"); echo '

'; -echo ''; + +$table->width=700; +$table->cellspacing=4; +$table->cellpadding=4; +$table->class="databox_color"; // Different Form url if it's a create or if it's a update form -if ($id_rt != -1) - echo ""; -else - echo ""; +echo ''; // Name -echo '"; -echo ''; -echo ''; +$table->data[] = array (__('Network'),print_input_text ('network',$network,'',25,0,true)); // Interval -echo ''; -echo '"; -echo ""; -echo ""; +$sql = sprintf("SELECT id_np, name FROM tnetwork_profile"); +$result = get_db_all_rows_sql ($sql); +foreach($result as $row) { + $selectbox[$row["id_np"]] = $row["name"]; +} + +$table->data[] = array (__('Network profile'),print_select ($selectbox, "id_network_profile", $id_network_profile,'','','',true)); +unset ($selectbox); // OS -echo ""; -echo ""; +$sql = "SELECT id_os, name FROM tconfig_os ORDER BY name"; +$result = get_db_all_rows_sql ($sql); +$selectbox[-1] = __('Any'); +foreach ($result as $row) { + $selectbox[$row["id_os"]] = $row["name"]; +} + +$table->data[] = array (__('OS'),print_select ($selectbox, "id_os", $id_os,'','','',true)); +unset ($selectbox); // Group -echo ""; -echo ""; -echo ""; +$sql = "SELECT id_grupo, nombre FROM tgrupo"; +$result = get_db_all_rows_sql ($sql); +foreach ($result as $row) { + $selectbox[$row["id_grupo"]] = $row["nombre"]; +} +$table->data[] = array (__('Group'),print_select ($selectbox, "id_group", $id_group,'','','',true)); +unset ($selectbox); // Incident -echo ""; -echo ""; -echo ""; -echo ""; +$selectbox = array ( 0 => __('No'), 1 => __('Yes') ); +$table->data[] = array (__('Incident'),print_select ($selectbox, "create_incident", $create_incident,'','','',true)); // Comments -echo '"; -echo "
'.__('Task name'); -echo ""; +$table->data[] = array (__('Task name'),print_input_text ('name',$name,'',25,0,true)); // Recon server -echo "".__('Recon Server'); -echo ' '.__('You must select a Recon Server for the Task, otherwise the Recon Task will never run').''; -echo ""; -echo '"; +$table->data[] = array (__('Recon Server').' '.__('You must select a Recon Server for the Task, otherwise the Recon Task will never run').'', + print_select ($selectbox, "id_recon_server", $id_recon_server,'','','',true)); +unset ($selectbox); // Network -echo "
'.__('Network').''; -echo ''.__('Interval').''; -echo ""; +$selectbox = array ( + 3600 => '1 '.__('hour'), + 7200 => '2 '.__('hours'), + 21600 => '6 '.__('hours'), + 43200 => '12 '.__('hours'), + 86400 => '1 '.__('day'), + 432000 => '5 '.__('days'), + 604800 => '1 '.__('week'), + 1209600 => '2 '.__('weeks'), + 2592000 => '1 '.__('month') + ); + +$table->data[] = array (__('Interval'),print_select ($selectbox, "interval", $interval,'','','',true)); +unset ($selectbox); // Network profile -echo "
".__('Network profile') . ""; -echo "". __('OS') . ""; -echo "
".__('Group').""; -echo "
".__('Incident').""; -echo "
'.__('Comments'); -echo ''; -echo '"; -echo "
"; +$table->data[] = array (__('Comments'),print_textarea ("description", 2, 70, $description,'',true)); +print_table ($table); +unset ($table); + +//Table with buttons +$table->align = array ("right"); +$table->width = 700; +$table->cellpadding = 4; +$table->cellspacing = 4; +if ($id_rt != "-1") { + $table->data[] = array (''); +} else { + $table->data[] = array (''); +} +print_table($table); +unset($table); -echo ""; -echo "
"; -if ($id_rt != "-1") - echo ''; -else - echo ''; echo ""; -echo "
"; ?> diff --git a/pandora_console/godmode/servers/modificar_server.php b/pandora_console/godmode/servers/modificar_server.php index 3b0cacce14..89af613ec4 100644 --- a/pandora_console/godmode/servers/modificar_server.php +++ b/pandora_console/godmode/servers/modificar_server.php @@ -24,159 +24,114 @@ if (! give_acl ($config["id_user"], 0, "AR") && ! give_acl($config['id_user'], 0 audit_db ($config["id_user"], $REMOTE_ADDR, "ACL Violation", "Trying to access Server Management"); require ("general/noaccess.php"); + exit; } if (isset ($_GET["delete"])) { - $id_server = entrada_limpia($_GET["server_del"]); - $sql = "DELETE FROM tserver WHERE id_server='".$id_server."'"; - $result=mysql_query($sql); - if ($result) echo "

".__('Server deleted successfully')."

"; - else echo "

".__('There was a problem deleting server')."

"; -} - -if (isset($_GET["update"])) { - $name=entrada_limpia($_POST["name"]); - $address=entrada_limpia($_POST["address"]); - $description=entrada_limpia($_POST["description"]); - $id_server=entrada_limpia($_POST["server"]); - $sql = "UPDATE tserver SET name='".$name."', ip_address='".$address."', description='".$description."' WHERE id_server='".$id_server."'"; - $result=mysql_query($sql); - if ($result) echo "

".__('Server updated successfully')."

"; - else echo "

".__('There was a problem updating server')."

"; + $id_server = get_parameter_get ("server_del"); + $sql = sprintf ("DELETE FROM tserver WHERE id_server='%d'",$id_server); + $result = process_sql ($sql); + if ($result !== false) { + echo '

'.__('Server deleted successfully').'

'; + } else { + echo '

'.__('There was a problem deleting the server').'

'; + } +} elseif (isset($_GET["update"])) { + $name = get_parameter_post ("name"); + $address = get_parameter_post ("address"); + $description = get_parameter_post ("description"); + $id_server = get_parameter_post ("server"); + $sql = sprintf ("UPDATE tserver SET name = '%s', ip_address = '%s', description = '%s' WHERE id_server = %d",$name,$address,$description,$server); + $result = process_sql ($sql); + if ($result !== false) { + echo '

'.__('Server updated successfully').'

'; + } else { + echo '

'.__('There was a problem updating the server').'

'; + } } if (isset($_GET["server"])) { - $id_server=entrada_limpia($_GET["server"]); - echo "

".__('Pandora servers')." > "; - echo __('Update Server')."

"; + $id_server= get_parameter_get ("server"); + echo "

".__('Pandora servers')." > ".__('Update Server')."

"; + $sql = sprintf("SELECT name, ip_address, description FROM tserver WHERE id_server = %d",$id_server); + $row = get_db_row_sql ($sql); + echo '
'; + print_input_hidden ("server",$id_server); + + $table->cellpadding=4; + $table->cellspacing=4; + $table->width=450; + $table->class="databox_color"; + + $table->data[] = array (__('Name'),print_input_text ('name',$row["name"],'',50,0,true)); + $table->data[] = array (__('IP Address'),print_input_text ('address',$row["ip_address"],'',50,0,true)); + $table->data[] = array (__('Description'),print_input_text ('description',$row["description"],'',50,0,true)); + + print_table($table); + unset ($table->data, $table->class); - $query="SELECT * FROM tserver WHERE id_server=".$id_server; - $result=mysql_query($query); - if (mysql_num_rows($result)){ - $row=mysql_fetch_array($result); - $name = $row["name"]; - $address = $row["ip_address"]; - $status = $row["status"]; - $laststart = $row["laststart"]; - $keepalive = $row["keepalive"]; - $network_server = $row["network_server"]; - $data_server = $row["data_server"]; - $snmp_server = $row["snmp_server"]; - $master = $row["master"]; - $checksum = $row["checksum"]; - $description = $row["description"]; - echo ''; - echo ""; - echo ""; - echo "
".__('Name').""; - echo "
".__('IP Address').""; - echo "
".__('Description').""; - } - else { - echo "
".__('There are no servers configured into the database')."
"; - } - echo '
'; - echo ''; - echo '
'; - echo '
'; -} -else { + $table->align=array ("right"); + $table->data[] = array (''); + print_table($table); + unset ($table); +} else { + $result = get_db_all_rows_in_table ("tserver"); + echo "

".__('Pandora servers')." > ".__('Manage servers')."

"; - $sql='SELECT * FROM tserver'; - echo "

".__('Pandora servers')." > "; - echo __('Manage servers')."

"; - - $result=mysql_query($sql); - if (mysql_num_rows($result)){ - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - $color=1; - while ($row=mysql_fetch_array($result)){ - $name = $row["name"]; - $address = $row["ip_address"]; - $status = $row["status"]; - $laststart = $row["laststart"]; - $keepalive = $row["keepalive"]; - $network_server = $row["network_server"]; - $data_server = $row["data_server"]; - $snmp_server = $row["snmp_server"]; - $master = $row["master"]; - $checksum = $row["checksum"]; - $description = $row["description"]; - $id_server = $row["id_server"]; - - if ($color == 1){ - $tdcolor = "datos"; - $color = 0; + if ($result !== false) { + $table->cellpadding = 4; + $table->cellspacing = 4; + $table->width = "100%"; + $table->class = "databox"; + $table->align = array ('',"center","center","center","center","center","center","center"); + $table->head = array (__('Name'),__('Status'),__('IP Address'),__('Description'),__('Type'),__('Started at'),__('Updated at'),__('Delete')); + + foreach ($result as $row) { + $server = ""; + if($row["network_server"] == 1) { + $server .= ' '; } - else { - $tdcolor = "datos2"; - $color = 1; + if ($row["data_server"] == 1) { + $server .= ' '; } - echo ""; - echo ""; - echo ""; - echo ""; + if ($row["checksum"] == 1) { + $server .= ' '; + } + + $table->data[] = array ( + ''.$row["name"].'', + '', + $row["ip_address"], + substr($row["description"],0,25), + $server, + $LOCALE->fmt_time($row["laststart"],"MYSQL","DATE").' '.$LOCALE->fmt_time($row["laststart"],"MYSQL","LONGTIME"), + $LOCALE->fmt_time($row["keepalive"],"MYSQL","DATE").' '.$LOCALE->fmt_time($row["keepalive"],"MYSQL","LONGTIME"), + '' + ); + } - echo '
".__('Name')."".__('Status')."".__('IP Address')."".__('Description')."".__('Type')."".__('Started at')."".__('Updated at')."".__('Delete')."
"; - echo "$name"; - echo ""; - if ($status ==0){ - echo ""; - } else { - echo ""; + if ($row["snmp_server"] == 1) { + $server .= ' '; } - echo ""; - echo "$address"; - echo "".substr($description,0,25); - echo ""; - if ($network_server == 1){ - echo "  "; - } - if ($data_server == 1){ - echo "  "; - } - if ($snmp_server == 1){ - echo "  "; - } - if ($master == 1){ - echo "  "; - } - if ($checksum == 1){ - echo "  "; + if ($row["master"] == 1) { + $server .= ' '; } - echo "".substr($laststart,0,25)."".substr($keepalive,0,25)." - -
'; - echo ""; - echo " - - - - - - - "; - echo "
- ".__('Network Server')." - - ".__('Master')." - - ".__('Data Server')." - - ".__('MD5 Check')." - - ".__('SNMP Console')." -
"; - } - else { + print_table ($table); + unset ($table); + + //Lagend + $table->cellpadding = 2; + $table->cellspacing = 0; + $table->data[] = array ( + ''.__('Network Server').'', + ''.__('Master').'', + ''.__('Data Server').'', + ''.__('MD5 Check').'', + ''.__('SNMP Console').'' + ); + print_table ($table); + unset ($table); + } else { echo "
".__('There are no servers configured into the database')."
"; } }