/[scire]/scire/script.php
Gentoo

Contents of /scire/script.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 174 - (show annotations) (download)
Mon Dec 11 00:53:03 2006 UTC (11 years, 6 months ago) by codeman
File size: 3438 byte(s)
minor change to clients
fixing lots of bugs for script.php
added the insert query code. tested briefly
sensitive but works.

1 <?php
2 include('.lib/common.php');
3
4 $smarty->assign('leftbar', "on");
5 $leftbar_menu = array();
6 $leftbar_submenu = array();
7 $smarty->assign('desc', "Manage scripts.");
8 #add_leftbar($leftbar_menu, "Main Settings", "settings.php");
9 #add_leftbar($leftbar_menu, "Clients Page", "settings.php?View=Clients");
10 $smarty->assign('leftbar_submenu_title', "Actions");
11 add_leftbar($leftbar_submenu, "Add Script", "script.php?Action=create");
12
13 if ($_POST['add_script']) {
14 #What are the required fields?
15 #name, description, location, script_data,log_location, success_code, run_as, priority, permission, pp_location, pp_script_data.
16 if ($_POST['addname'] and $_POST['desc']) {
17 $script['name'] = $_POST['addname'];
18 $script['desc'] = $_POST['desc'];
19 } else {
20 $status .= "Error: name or description missing!";
21 }
22 if ($_POST['script_data_type']) {
23 $script['location'] = "Embedded";
24 if ($_POST['script_data_type'] == "load") {
25 $script['script_data'] = $_POST['script_data_upload']; #FIXME how is this done?
26 } elseif ($_POST['script_data_type'] == "manual") {
27 $script['script_data'] = $_POST['script_data_manual'];
28 }
29 } else {
30 $status .= "Error: You must select a script type (Load from file or manual input!";
31 }
32 if ($_POST['runas_radio']) {
33 $script['run_as'] = $_POST['runas_radio'];
34 } elseif ($_POST['runas']) {
35 $script['run_as'] = $_POST['runas'];
36 } else {
37 $status .= "No run_as selected, defaulting to root!!! ";
38 $script['run_as'] = "root";
39 }
40 if ($_POST['priority']) {
41 $script['priority'] = $_POST['priority'];
42 } else {
43 $status .= "No priority selected, defaulting to 5. ";
44 $script['priority'] = "5";
45 }
46 if ($_POST['success_code']) {
47 $script['success_code'] = $_POST['success_code'];
48 } else {
49 $status .= "No success code selected, defaulting to 0. ";
50 $script['success_code'] = "0";
51 }
52 if ($_POST['permission']) {
53 $script['permission'] = $_POST['permission'];
54 }
55 if ($_POST['pps_type']) {
56 $script['pp_location'] = "Embedded";
57 if ($_POST['pps_type'] == "load") {
58 $script['pp_script_data'] = $_POST['pps_load']; #FIXME how is this done?
59 } elseif ($_POST['pps_type'] == "manual") {
60 $script['pp_script_data'] = $_POST['pps_data'];
61 }
62 }
63 #Ok, i think we got everything, now lets add it
64 $result = scire_add_script($script['name'], $script['desc'], $script['location'], $script['script_data'], $script['log_location'], $script['success_code'], $script['run_as'], $script['priority'], $script['permission'], $script['pp_location'], $script['pp_script_data']);
65 if ($result) { #success
66 $status .= "Scipt addition successfull!";
67 } else {
68 $status .= "BAD BAD! Error during query. $result";
69 }
70 }
71
72 $permissions = array();
73 $perm_categories = array();
74 $smarty->assign('priorities', get_priorities() );
75 $all_permissions = $acl->get_objects(NULL, 1, 'ACO');
76 foreach ($all_permissions as $categoryname => $cat) {
77 #print "Perm: $perm<br>Permname: $permname<br>";
78 if ($categoryname != $scire_ui_section) {
79 foreach ($cat as $perm) {
80 array_push($permissions, $perm);
81 }
82 array_push($perm_categories, $categoryname);
83 }
84 }
85 $smarty->assign('perm_categories',$perm_categories);
86 $smarty->assign('perms', $permissions);
87
88 $smarty->assign('leftbar_menu', $leftbar_menu);
89 $smarty->assign('leftbar_submenu', $leftbar_submenu);
90 $smarty->assign('View', $_GET['View']);
91 $smarty->assign('Action', $_GET['Action']);
92 $smarty->assign('status', $status);
93 $smarty->display('script.tpl');
94 var_dump($_POST);
95 ?>

  ViewVC Help
Powered by ViewVC 1.1.20