$id_reconscript)); echo htmlentities (io_safe_output($description), ENT_QUOTES, "UTF-8", true); return; } // Load global vars global $config; check_login (); if (! check_acl ($config['id_user'], 0, "LM")) { db_pandora_audit("ACL Violation", "Trying to access recon script Management"); require ("general/noaccess.php"); return; } /* * Disabled at the moment. if (!check_referer()) { require ("general/noaccess.php"); return; } */ $view = get_parameter ("view", ""); $create = get_parameter ("create", ""); if ($view != "") { $form_id = $view; $reconscript = db_get_row ("trecon_script", "id_recon_script", $form_id); $form_name = $reconscript["name"]; $form_description = $reconscript["description"]; $form_script = $reconscript ["script"]; } if ($create != "") { $form_name = ""; $form_description = ""; $form_script = ""; } // SHOW THE FORM // ================================================================= if (($create != "") OR ($view != "")){ if ($create != "") ui_print_page_header (__('Recon script creation'), "images/gm_servers.png", false, "reconscript_definition", true); else { ui_print_page_header (__('Recon script update'), "images/gm_servers.png", false, "reconscript_definition", true); $id_recon_script = get_parameter ("view",""); } if ($create == "") echo "
"; else echo ""; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo '
' . __('Name') . ''; echo '
' . __('Script fullpath') . ''; echo '
' . __('Description') . '
'; echo ''; echo '
'; if ($create != ""){ echo ""; } else { echo ""; } echo '
'; } else { ui_print_page_header (__('Recon scripts registered in Pandora FMS'), "images/gm_servers.png", false, "", true); // Update reconscript if (isset($_GET["update_reconscript"])) { // if modified any parameter $id_recon_script = get_parameter ("update_reconscript", 0); $reconscript_name = get_parameter ("form_name", ""); $reconscript_description = get_parameter ("form_description", ""); $reconscript_script = get_parameter ("form_script", ""); $sql_update ="UPDATE trecon_script SET name = '$reconscript_name', description = '$reconscript_description', script = '$reconscript_script' WHERE id_recon_script = $id_recon_script"; $result = false; if ($reconscript_name != '' && $reconscript_script != '') $result = db_process_sql ($sql_update); if (! $result) { ui_print_error_message(__('Problem updating')); } else { ui_print_success_message(__('Updated successfully')); } } // Create reconscript if (isset($_GET["create_reconscript"])) { $reconscript_name = get_parameter ("form_name", ""); $reconscript_description = get_parameter ("form_description", ""); $reconscript_script = get_parameter ("form_script", ""); $values = array( 'name' => $reconscript_name, 'description' => $reconscript_description, 'script' => $reconscript_script); $result = false; if ($values['name'] != '' && $values['script'] != '') $result = db_process_sql_insert('trecon_script', $values); if (! $result) { ui_print_error_message(__('Problem creating')); } else { ui_print_success_message(__('Created successfully')); } } if (isset($_GET["kill_reconscript"])) { // if delete alert $reconscript_id = get_parameter ("kill_reconscript", 0); $result = db_process_sql_delete('trecon_script', array('id_recon_script' => $reconscript_id)); if (! $result) { ui_print_error_message(__('Problem deleting reconscript')); } else { ui_print_success_message(__('reconscript deleted successfully')); } if ($reconscript_id != 0){ $result = db_process_sql_delete('trecon_task', array('id_recon_script' => $reconscript_id)); } } // If not edition or insert, then list available reconscripts $rows = db_get_all_rows_in_table('trecon_script'); if ($rows !== false) { echo ''; echo ""; echo ""; echo ""; echo ""; $color = 0; foreach ($rows as $row) { if ($color == 1) { $tdcolor = "datos"; $color = 0; } else { $tdcolor = "datos2"; $color = 1; } echo ""; echo ""; echo ""; } echo "
" . __('Name') . "" . __('Command') . "" . __('Description') . "" . __('Delete') . "
"; echo ""; echo $row["name"]; echo ""; echo $row["script"]; echo ""; echo $row["description"]; echo ""; echo "" . html_print_image("images/cross.png", true, array("border" => '0')) . ""; echo "
"; } else { echo '
'. __('There are no recon scripts in the system') . '
'; echo "
"; } echo ""; echo "
"; echo "
"; echo ""; echo "
"; } ?>