From e3a4734a4e5a7ed268841d18d994385f9e8f556b Mon Sep 17 00:00:00 2001 From: Preston Cody Date: Sun, 17 Feb 2008 19:36:19 +0000 Subject: adding some module support code as well as a prototype page for quickstart. reworking the job page to do what was previously in add_job.php we can now safely get rid of add_job i think. svn path=/trunk/; revision=356 --- scire/.lib/functions.php | 64 +++++ scire/.lib/module_common.php | 4 + scire/.smarty/templates/header.tpl | 2 +- scire/.smarty/templates/job.tpl | 269 ++++++++++++++------- scire/.smarty/templates/modules/Exporter/index.tpl | 36 +++ .../.smarty/templates/modules/quickstart/index.tpl | 86 +++++++ scire/.smarty/templates/script_library.tpl | 2 +- scire/job.php | 118 +++++---- scire/quickstart/index.php | 37 +++ scire/quickstart/sample_data.csv | 5 + 10 files changed, 471 insertions(+), 152 deletions(-) create mode 100644 scire/.lib/module_common.php create mode 100644 scire/.smarty/templates/modules/Exporter/index.tpl create mode 100644 scire/.smarty/templates/modules/quickstart/index.tpl create mode 100644 scire/quickstart/index.php create mode 100644 scire/quickstart/sample_data.csv (limited to 'scire') diff --git a/scire/.lib/functions.php b/scire/.lib/functions.php index 1215d54..7a1996f 100644 --- a/scire/.lib/functions.php +++ b/scire/.lib/functions.php @@ -78,6 +78,70 @@ function get_priorities() { return array('1','2','3','4','5','6','7','8','9'); } +function get_cron_times() { + # Minutes array + $minutes = array( +# "*" => "Every minute", +# "*/2" => "Every other minute", + "*/5" => "Every five minutes", + "*/10" => "Every ten minutes", + "*/15" => "Every fifteen minutes", + ); + foreach (range(0,59) as $val) { + $minutes[(string)$val] = $val; + } + $minutes["other"] = "other"; + # Hours array + $hours = array( + "*" => "Every hour", + "*/2" => "Every other hour"); + foreach (range(0,11) as $val) { + $hours[(string)$val] = (string)$val . " A.M."; + } + $hours["12"] = "12 Noon"; + foreach (range(13,23) as $val) { + $hours[(string)$val] = (string)($val-12) . " P.M."; + } + $hours["other"] = "other"; + + # Days + $days = array( + "*" => "Every day", + "*/2" => "Every other day"); + foreach (range(1,31) as $val) { + $days[(string)$val] = (string)($val); + } + $days["other"] = "other"; + + # Weekdays + $weekdays = array( + "*" => "Every weekday", + "0" => "Sunday", + "1" => "Monday", + "2" => "Tuesday", + "3" => "Wednesday", + "4" => "Thursday", + "5" => "Friday", + "6" => "Saturday"); + $weekdays["other"] = "other"; + + # Months + $months = array("*" => "Every month", + "1" => "January", + "2" => "February", + "3" => "March", + "4" => "April", + "5" => "May", + "6" => "June", + "7" => "July", + "8" => "August", + "9" => "October", + "10" => "September", + "11" => "November", + "12" => "December"); + $months["other"] = "other"; + return array($minutes,$hours,$days,$weekdays,$months); +} ?> diff --git a/scire/.lib/module_common.php b/scire/.lib/module_common.php new file mode 100644 index 0000000..1c51549 --- /dev/null +++ b/scire/.lib/module_common.php @@ -0,0 +1,4 @@ + diff --git a/scire/.smarty/templates/header.tpl b/scire/.smarty/templates/header.tpl index 51f5387..d0d40b5 100644 --- a/scire/.smarty/templates/header.tpl +++ b/scire/.smarty/templates/header.tpl @@ -12,7 +12,7 @@ Scire{if ($title ne "")} - {$title}{if ($subtitle ne "")} - {$subtitle}{/if}{/if} - + {if isset($head)}{$head}{/if} diff --git a/scire/.smarty/templates/job.tpl b/scire/.smarty/templates/job.tpl index 124e03c..8919f02 100644 --- a/scire/.smarty/templates/job.tpl +++ b/scire/.smarty/templates/job.tpl @@ -1,115 +1,210 @@ {include file="header.tpl" title="Jobs"} -
-{if $Action eq "addgroup"} - - - - - -
Add client to group
- - - - - {foreach from=$groups name=ugroup item=item key=id} - - - - - {/foreach} - -
AddGroup Name
{$item}
- - -
-
-{elseif $Action eq "create"} +{if $Action eq "create"} +

Add a Job

+ -
- + + + +
+ - + + +
ClientGroupsScript Selection
- - - - - - - - - - - - + - - - - - - - - + {if isset($get.scriptid)} + + + + {else} + + + {/if} + {if !isset($get.scriptid)} - - - - + + {/if} - - +
- - Selected script:{$script.name}Categories will go here + +
- Or just type in the ID of the script:

Override Script default values:


+ Permission:
+ + Set Priority:
+ Log Location:
+ Success Code: (not worrying bout this now)
+ Set dynamic content:
+
-

+
+ + + + +
Client Selection
- - - -
Assign client to the following groups:
- -
+ + + {if isset($get.clientid)} + + + + {elseif isset($get.cgroupid)} + + + {else} + + + + + + + {/if} + +
Selected client:{$client.hostname}Selected clientgroup:NAME HERE
+ + + +
+ Input staging client hostname (optional):
+ Staging success: Positive Result Code Manually approved
+
+ + {if $dyn_tags} + + + + {foreach from=$dyn_tags item=tag key=tagnum} + + + + {/foreach} + {/if} +
Dynamic TagValue
Tag: {$tag}
+
+Job Description:

+ + + + + +
+
+ Run Schedule + + + + + + + + + + + + + + + + +
+

Minute(s):

+ {html_options name=minutes options=$minutes selected=$selectedMinute size=6} +
     +

Hour(s):

+ {html_options name=hours options=$hours selected=$selectedHour size=6} +
     +

Month(s):

+ {html_options name=months options=$months selected=$selectedMonth size=6} +
+

Day(s):

+ {html_options name=days options=$days selected=$selectedDay size=6} +
+

Weekday(s):

+ {html_options name=weekdays options=$weekdays selected=$selectedWeekday size=6} +
+ +
+ + + + +
+ + + + + +
+
+Job dependency stuff here.CODE ME
+ + + {elseif $Action eq "edit"} -

EDITING

- +

Edit Job

+ +
- + {/foreach} diff --git a/scire/job.php b/scire/job.php index 81a10a1..8adc957 100644 --- a/scire/job.php +++ b/scire/job.php @@ -10,68 +10,7 @@ add_leftbar($leftbar_menu, "««Cancel", "jobs.php"); $jobid = ""; -# Minutes array -$minutes = array( -# "*" => "Every minute", -# "*/2" => "Every other minute", - "*/5" => "Every five minutes", - "*/10" => "Every ten minutes", - "*/15" => "Every fifteen minutes", - ); -foreach (range(0,59) as $val) { - $minutes[(string)$val] = $val; -} -$minutes["other"] = "other"; - -# Hours array -$hours = array( - "*" => "Every hour", - "*/2" => "Every other hour"); -foreach (range(0,11) as $val) { - $hours[(string)$val] = (string)$val . " A.M."; -} -$hours["12"] = "12 Noon"; -foreach (range(13,23) as $val) { - $hours[(string)$val] = (string)($val-12) . " P.M."; -} -$hours["other"] = "other"; - -# Days -$days = array( - "*" => "Every day", - "*/2" => "Every other day"); -foreach (range(1,31) as $val) { - $days[(string)$val] = (string)($val); -} -$days["other"] = "other"; - -# Weekdays -$weekdays = array( - "*" => "Every weekday", - "0" => "Sunday", - "1" => "Monday", - "2" => "Tuesday", - "3" => "Wednesday", - "4" => "Thursday", - "5" => "Friday", - "6" => "Saturday"); -$weekdays["other"] = "other"; - -# Months -$months = array("*" => "Every month", - "1" => "January", - "2" => "February", - "3" => "March", - "4" => "April", - "5" => "May", - "6" => "June", - "7" => "July", - "8" => "August", - "9" => "October", - "10" => "September", - "11" => "November", - "12" => "December"); -$months["other"] = "other"; +list($minutes,$hours,$days,$weekdays,$months) = get_cron_times(); function scheduleUIHelper($cronString) { @@ -206,10 +145,63 @@ if ($_POST['delete_cancel']) { header('Location: ' . $baseurl . 'jobs.php'); } +######################################################## +################## MAIN SWITCH ######################### switch($_GET['Action']) { case "create": check_action_access("Add Job"); #Access check add_leftbar($leftbar_menu, "««Cancel", "jobs.php"); + + if ($_GET['scriptid']) { + $_GET['scriptid'] = (int) $_GET['scriptid']; + $script = get_scire_script($_GET['scriptid']); + $smarty->assign('script', $script); + # print $script['script_data']; + preg_match_all('/%%(.*?)%%/', $script['script_data'], $matches); + $smarty->assign('dyn_tags', $matches[1]); + foreach ($matches[1] as $tag) { + $tag_values[$tag] = get_dyn_tag_value($_GET['scriptid'],$tag); + } + $smarty->assign('tag_values', $tag_values); + + pre_var_dump($tag_values); + } + + if ($_GET['clientid']) { + $_GET['clientid'] = (int) $_GET['clientid']; + $client = get_scire_client($_GET['clientid']); + #$id = $acl->get_object_id("clients",$client['hostname'],'AXO' + + $smarty->assign('client', $client); + } + ######################################################## + + $permissions = array(); + $all_permissions = $acl->get_objects(NULL, 1, 'ACO'); + foreach ($all_permissions as $categoryname => $cat) { + #print "Perm: $perm
Permname: $permname
"; + if ($categoryname != $scire_ui_section) { + foreach ($cat as $perm) { + array_push($permissions, $perm); + } + } + } + $smarty->assign('perms', $permissions); + #pre_var_dump($permissions); + $smarty->assign('priorities', get_priorities()); + + + $scripts = get_scire_scripts(); + $smarty->assign('scripts', $scripts); + + $smarty->assign('cgroups', $acl->format_groups($acl->sort_groups('AXO'), TEXT)); + $clients = get_scire_clients('hostname', 'asc'); + $smarty->assign('clients', $clients); + $smarty->assign('minutes', $minutes); + $smarty->assign('hours', $hours); + $smarty->assign('days', $days); + $smarty->assign('months', $months); + $smarty->assign('weekdays', $weekdays); break; case "edit": @@ -273,7 +265,7 @@ switch($_GET['Action']) { break; } - +$smarty->assign('get', $_GET); $smarty->assign('leftbar_menu', $leftbar_menu); $smarty->assign('Action', $_GET['Action']); $smarty->assign('status', $status); diff --git a/scire/quickstart/index.php b/scire/quickstart/index.php new file mode 100644 index 0000000..40c8528 --- /dev/null +++ b/scire/quickstart/index.php @@ -0,0 +1,37 @@ +assign('leftbar', "on"); +$leftbar_menu = array(); + +add_leftbar($leftbar_menu, "Edit Profiles", "$mod_path/profiles.php"); +add_leftbar($leftbar_menu, "Install Client", "$mod_path/install_client.php"); + +$clients = array(); +#The first thing we need to do is parse the quickstart server data file. +#Find the file. +$fh = fopen("sample_data.csv", "r"); +#Open and loot. +if ($fh) { + while(!feof($fh)) { + $line = trim(fgets($fh)); + #File is a CSV with MAC,profile,status + list($client['mac'], $client['ip'], $client['profile'], $client['status']) = explode(",",$line); + array_push($clients,$client); + } + fclose($fh); +} + + + +#Get a list of the groups to put in the select box. +$profile_list = get_profile_list(); + +$smarty->assign('clients',$clients); +$smarty->assign('profiles',$profile_list); +$smarty->assign('leftbar_menu', $leftbar_menu); +$smarty->display($mod_path."/index.tpl"); +#pre_var_dump($clients); +#var_dump($profile_list); +?> diff --git a/scire/quickstart/sample_data.csv b/scire/quickstart/sample_data.csv new file mode 100644 index 0000000..f736047 --- /dev/null +++ b/scire/quickstart/sample_data.csv @@ -0,0 +1,5 @@ +00:01:02:03:04:0A,1.2.3.4,MTA,Install Complete +AA:BB:CC:DD:EE:FF,65.43.2.1,sample_profile,Scheduled for Install +00:01:02:03:04:05,192.168.1.11,sample_profile,Installing +AA:AB:CC:DD:EE:FF,95.43.2.1,sample_profile,Scheduled for Install +AA:AA:CC:DD:EE:FF,99.43.2.1,sample_profile,Installing -- cgit v1.2.3-65-gdbad
diff --git a/scire/.smarty/templates/modules/Exporter/index.tpl b/scire/.smarty/templates/modules/Exporter/index.tpl new file mode 100644 index 0000000..93cb8e5 --- /dev/null +++ b/scire/.smarty/templates/modules/Exporter/index.tpl @@ -0,0 +1,36 @@ +{include file="header.tpl" title="Server Information Exporter"} +List of clients in group: + + + + + +
+ + + + + + + + +
HOSTNAMESTATUSIPMACASSET IDINSTALL TIME
+
+ + + +{include file="footer.tpl"} diff --git a/scire/.smarty/templates/modules/quickstart/index.tpl b/scire/.smarty/templates/modules/quickstart/index.tpl new file mode 100644 index 0000000..8440724 --- /dev/null +++ b/scire/.smarty/templates/modules/quickstart/index.tpl @@ -0,0 +1,86 @@ +{include file="header.tpl" title="Quickstart Server"} +

Quickstart Server Status Overview

+ +List of clients currently installing:
+ + + + + + + +{foreach from=$clients item=client key=key} + {if $client.status eq 'Installing'} + + + + + + + + {/if} +{/foreach} +
MACIPPROFILESTATUS
{$client.mac}{$client.ip}{$client.profile}{$client.status}
+List of clients pending installation:
+ + + + + + + +{foreach from=$clients item=client key=key} + {if $client.status eq 'Scheduled for Install'} + + + + + + + + {/if} +{/foreach} +
MACIPPROFILESTATUS
{$client.mac}{$client.ip}{$client.profile}{$client.status}
+List of completed installations:
+ + + + + + + +{foreach from=$clients item=client key=key} + {if $client.status eq 'Install Complete'} + + + + + + + + {/if} +{/foreach} +
MACIPPROFILESTATUS
{$client.mac}{$client.ip}{$client.profile}{$client.status}
+List of available profiles:
+ + + + + + + +{foreach from=$profiles item=profile key=key} + + + + + + + +{/foreach} +
Profile IDProfile NameFilename/URIDescription
{$profile.profileid}{$profile.profile_name}{$profile.location}{$profile.description}
+ + + + +{include file="footer.tpl"} diff --git a/scire/.smarty/templates/script_library.tpl b/scire/.smarty/templates/script_library.tpl index 670f00c..be796f5 100644 --- a/scire/.smarty/templates/script_library.tpl +++ b/scire/.smarty/templates/script_library.tpl @@ -13,7 +13,7 @@
LAST USED HERE ADD OS TO SCRIPT TABLE {$script.permission}Create Job|Edit|DeleteCopy as NewCreate Job|Edit|DeleteCopy as New