Recon-task ACL changed. Ticket #2179

This commit is contained in:
Arturo Gonzalez Diaz 2015-07-23 16:27:20 +02:00
parent 681139e2d3
commit 4ede845c1c
2 changed files with 98 additions and 76 deletions

View File

@ -35,6 +35,9 @@ if (check_acl ($config['id_user'], 0, "AW")) {
$user_groups = users_get_groups(false, 'AW', true, false, null, 'id_grupo');
$user_groups = array_keys($user_groups);
$user_groups_r = users_get_groups(false, 'AR', true, false, null, 'id_grupo');
$user_groups_r = array_keys($user_groups_r);
// Headers
//ui_print_page_header (__('Manage recontask'), "images/gm_servers.png", false, "", true);
ui_print_page_header (__('Manage recontask'), "images/gm_servers.png", false, "", true, $options);
@ -152,10 +155,20 @@ if (isset($_GET["update"])) {
$reason = '';
if ($name != "") {
if (($id_recon_script == 'NULL') && preg_match("/[0-9]+.+[0-9]+.+[0-9]+.+[0-9]+\/+[0-9]/", $network))
if ((db_get_value_filter ('name', 'trecon_task', array ('name' => $name))) && (!preg_match("/[0-9]+.+[0-9]+.+[0-9]+.+[0-9]+\/+[0-9]/", $network))){
$reason = __('Recon-task name already exists and incorrect format in Subnet field');
$result = false;
}
else if(db_get_value_filter ('name', 'trecon_task', array ('name' => $name))){
$reason = __('Recon-task name already exists');
$result = false;
}
else if ((empty($id_recon_script)) && preg_match("/[0-9]+.+[0-9]+.+[0-9]+.+[0-9]+\/+[0-9]/", $network)){
$result = db_process_sql_update('trecon_task', $values, $where);
elseif ($id_recon_script != 'NULL')
}
elseif (!empty($id_recon_script)){
$result = db_process_sql_update('trecon_task', $values, $where);
}
else {
if (!preg_match("/[0-9]+.+[0-9]+.+[0-9]+.+[0-9]+\/+[0-9]/", $network))
$reason = __('Incorrect format in Subnet field');
@ -207,8 +220,21 @@ if (isset($_GET["create"])) {
$name = io_safe_input($name);
$reason = "";
if (($name != "") && (! db_get_value_filter ('name', 'trecon_task', array ('name' => $name)))) {
if (($id_recon_script == 'NULL') && preg_match("/[0-9]+.+[0-9]+.+[0-9]+.+[0-9]+\/+[0-9]/", $network))
if ($name != "") {
if ((db_get_value_filter ('name', 'trecon_task', array ('name' => $name))) && (!preg_match("/[0-9]+.+[0-9]+.+[0-9]+.+[0-9]+\/+[0-9]/", $network))){
$reason = __('Recon-task name already exists and incorrect format in Subnet field');
$result = false;
}
else if (!preg_match("/[0-9]+.+[0-9]+.+[0-9]+.+[0-9]+\/+[0-9]/", $network)){
$reason = __('Incorrect format in Subnet field');
$result = false;
}
else if (db_get_value_filter ('name', 'trecon_task', array ('name' => $name))){
$reason = __('Recon-task name already exists');
$result = false;
}
else if (empty($id_recon_script) && preg_match("/[0-9]+.+[0-9]+.+[0-9]+.+[0-9]+\/+[0-9]/", $network))
{
$result = db_process_sql_insert('trecon_task', $values);
@ -217,18 +243,13 @@ if (isset($_GET["create"])) {
elseif ($id_recon_script != 'NULL') {
$result = db_process_sql_insert('trecon_task', $values);
}
else {
if (!preg_match("/[0-9]+.+[0-9]+.+[0-9]+.+[0-9]+\/+[0-9]/", $network))
$reason = __('Incorrect format in Subnet field');
else{
$reason = __('Error');
$result = false;
}
}
else {
$result = false;
}
if (db_get_value_filter ('name', 'trecon_task', array ('name' => $name))){
$reason = __('Recon-task name already exists');
$reason = 'The field "Task name" is empty';
$result = false;
}
@ -270,8 +291,8 @@ if ($result !== false) {
$table->style[8] = 'text-align: center;';
foreach ($result as $row) {
if (in_array($row["id_group"], $user_groups_r)){
$data = array();
//$data[0] = '<a href="index.php?sec=gservers&sec2=godmode/servers/manage_recontask_form&crt=update&update='.$row["id_rt"].'&upd='.$row["id_rt"].'"><b>'.$row["name"].'</b></a>';
$data[0] = $row["name"];
if ($row["id_recon_script"] == 0)
@ -351,6 +372,7 @@ if ($result !== false) {
}
$table->data[] = $data;
}
}
html_print_table ($table);
unset ($table);

View File

@ -62,11 +62,11 @@ if (is_ajax ()) {
}
// Edit mode
if (isset ($_GET["update"]) or (isset($_GET["crt"]))) {
if (isset ($_GET["update"]) or (isset($_GET["upd"]))) {
$update_recon = true;
if (isset ($_GET["crt"])) {
if ($_GET["crt"] != "update") {
if (isset ($_GET["upd"])) {
if ($_GET["upd"] != "update") {
$update_recon = false;
}
else {