assign('leftbar', "on"); $leftbar_menu = array(); 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"; function scheduleUIHelper($cronString) { $bits = explode(" ", $cronString); if ($bits[0] != $_POST["minutes"] and $_POST["minutes"] != "other") { $bits[0] = $_POST["minutes"]; } if ($bits[1] != $_POST["hours"] and $_POST["hours"] != "other") { $bits[1] = $_POST["hours"]; } if ($bits[2] != $_POST["days"] and $_POST["days"] != "other") { $bits[2] = $_POST["days"]; } if ($bits[3] != $_POST["months"] and $_POST["months"] != "other") { $bits[3] = $_POST["months"]; } if ($bits[4] != $_POST["weekdays"] and $_POST["weekdays"] != "other") { $bits[4] = $_POST["weekdays"]; } print_r($bits); return implode(" ",$bits); } ##################################################### #Deal with submitted forms. ############################################### #Adding a client to clientgroups. // if ($_POST['addgroup_confirm']) { // $ingroups = $acl->get_object_groups($_POST['clientid'],'AXO'); // $clientdata = $acl->get_object_data($_POST['clientid'], 'AXO'); // $newgroups = $_POST['addgroupid']; // #remove first. // foreach ($ingroups as $ingroup) { // if (!in_array($ingroup, $newgroups)) { // $acl->del_group_object($ingroup, $clientdata[0][0], $clientdata[0][1], 'AXO'); // } // } // foreach ($newgroups as $newgroup) { // print "newgroup: $newgroup"; // $acl->add_group_object($newgroup, $clientdata[0][0], $clientdata[0][1], 'AXO'); // } // $_GET['Action'] = "edit"; // $_GET['clientid'] = $_POST['clientid']; // } ############################################### # Adding a client. // if ($_POST['addhostname']) { // if ($_POST['addhostname'] and $_POST['ip'] and $_POST['mac']) { // check_action_access("Add Client");#Access check // #First just incase, we need to check if the object already exists (so we don't make duplicates) // $obj_id = ""; // if ($acl->get_object_id("clients", $_POST['addhostname'], 'AXO') ) { #client already exists // $obj_id = $acl->get_object_id("clients", $_POST['addhostname'], 'AXO'); // $status .= "Found existing object with objectid $obj_id
"; // } else { // $obj_id = $acl->add_object("clients", $_POST['addhostname'], $_POST['addhostname'], 1, 0, 'AXO'); // $status .= "Object id: $obj_id
"; // } // $result = scire_add_client($obj_id, $_POST['digest'], $_POST['addhostname'], $_POST['mac'], $_POST['ip'], $_POST['gli_profile'], $_POST['osid'], $_POST['contact'], $_POST['status'], $_POST['installtime'], $_POST['assetid']); // if ($result == 1) { // $status .= "Client Addition successfull
"; // } else { // $status .= "Error during addition!: $result
"; // } // if ($_POST['groups']) { // $status .= "Adding client to groups ".$_POST['groups']; // foreach( $_POST['groups'] as $group) { // $worked = $acl->add_group_object($group, "clients", $_POST['addhostname'], 'AXO'); // if ($worked) { // $status .= "Group $group Addition successfull.
"; // } else { // $status .= "ERROR adding group $group
"; // } // } // } // } else { // $status = "Error required fields are not filled!"; // } // #header('Location: ' . $baseurl . 'clients.php'); // } ############################################### # Editing a job's information. if ($_POST['editpriority']) { check_action_access("Edit Job"); $jobinfo = get_scire_job($_GET['jobid']); $smarty->assign('job', $jobinfo); if (isset($_POST['editpriority']) and ($_POST['editpriority'] != $jobinfo['priority'])) { $fields['priority'] = $_POST['editpriority']; } if ($_POST['permission'] and ($_POST['permission'] != $jobinfo['permission'])){ $fields['permission'] = $_POST['permission']; } if ($_POST['description'] and ($_POST['description'] != $jobinfo['description'])) { $fields['description'] = trim($_POST['description']); } if ($_POST['script'] and ($_POST['script'] != $jobinfo['script'])) { $fields['script'] = $_POST['script']; } if ($_POST['run_schedule'] and ($_POST['run_schedule'] != $jobinfo['run_schedule'])) { try{ $c = new CronParser($_POST['run_schedule']); $fields['run_schedule'] = $_POST['run_schedule']; } catch (CronException $e) {} } else { $isScheduleUI = $_POST["minutes"] and $_POST["hours"] and $_POST["days"] and $_POST["months"] and $_POST["weekdays"]; if ($isScheduleUI) try{ $tmp = scheduleUIHelper($jobinfo["run_schedule"]); $c = new CronParser($tmp); $fields['run_schedule'] = $tmp; } catch (CronException $e) {} } if ($_POST['validity_period'] and ($_POST['validity_period'] != $jobinfo['validity_period'])) { $fields['validity_period'] = $_POST['validity_period']; } $status = scire_edit_job($_POST['jobid'], $fields); $_GET['Action'] = "edit"; $_GET['jobid'] = $_POST['jobid']; } ############################################### # Delete a client. // if ($_POST['delete_confirm']) { // check_action_access("Delete Client"); // $status = scire_del_client($_POST['clientid']); // $acl->del_object($_POST['clientid'], 'AXO', TRUE); #True means erase referencing objects. // header('Location: ' . $baseurl . 'clients.php'); // } switch($_GET['Action']) { // case "addgroup": // $smarty->assign('desc', "Add a client to a client group."); // $smarty->assign('clientid', $_GET['clientid']); // $smarty->assign('groups', $acl->format_groups($acl->sort_groups('AXO'), TEXT)); // $ingroups = array(); // $ingroups = $acl->get_object_groups($_GET['clientid'],'AXO'); // var_dump($ingroups); // $smarty->assign('ingroups', $ingroups); // case "create": // check_action_access("Add Client");#Access check // $smarty->assign('desc', "Add a client."); // $smarty->assign('groups', $acl->format_groups($acl->sort_groups('AXO'), TEXT)); // $smarty->assign('gli_profiles', get_scire_gli_profiles()); // $smarty->assign('oss', get_scire_oss()); // $smarty->assign('users', get_scire_users('username', 'desc')); // break; case "edit": check_action_access("Edit Job");#Access check $acls = array(); #make the topbar look good $smarty->assign('desc', "Edit client information."); $jobinfo = get_scire_job($_GET['jobid']); $smarty->assign('job', $jobinfo); $smarty->assign('jobid', $_GET['jobid']); $smarty->assign('scripts', get_scire_scripts()); // $cron = new CronParser("*/2 7-18/3 * * *"); // $smarty->assign('cron', $cron); $smarty->assign('minutes', $minutes); $smarty->assign('hours', $hours); $smarty->assign('days', $days); $smarty->assign('months', $months); $smarty->assign('weekdays', $weekdays); $bits = explode(" ", $jobinfo["run_schedule"]); $smarty->assign('selectedMinute', array_key_exists($bits[0], $minutes) ? $bits[0] : "other" ); $smarty->assign('selectedHour', array_key_exists($bits[1], $hours) ? $bits[1] : "other" ); $smarty->assign('selectedDay', array_key_exists($bits[2], $days) ? $bits[2] : "other" ); $smarty->assign('selectedMonth', array_key_exists($bits[3], $months) ? $bits[3] : "other" ); $smarty->assign('selectedWeekday', array_key_exists($bits[4], $minutes) ? $bits[4] : "other" ); // $smarty->assign('gli_profiles', get_scire_gli_profiles()); // $smarty->assign('oss', get_scire_oss()); // $smarty->assign('users', get_scire_users('username', 'desc')); // $clientgroups = array(); $groups = $acl->get_object_groups($_GET['jobid'],'AXO'); if ($groups) { foreach ($groups as $group) { $group_data = $acl->get_group_data($group, 'AXO'); $clientgroups_entry['name'] = $group_data[3]; $clientgroups_entry['id'] = $group_data[0]; if ($group_data[1]) { $parent_group_data = $acl->get_group_data($group_data[1],'AXO'); $clientgroups_entry['parent'] = $parent_group_data[3]; } else { $clientgroups_entry['parent'] = ""; } array_push($clientgroups, $clientgroups_entry); $result_acl_ids = $acl->search_acl(FALSE,FALSE, FALSE,FALSE,FALSE, FALSE,FALSE,$group_data[3],FALSE); foreach ($result_acl_ids as $acl_id) { array_push($acls, $acl->get_acl($acl_id)); } } } $smarty->assign('groups', $clientgroups); // $ugroups = $acl->format_groups($acl->sort_groups('aro'), 'ARRAY'); // $smarty->assign('ugroups', $ugroups); // #Format of search: aco_section, aco_value, aro_section, aro_value, aro_group_name, axo_section, axo_value, axo_group_name, return_value // $result_acl_ids = $acl->search_acl(FALSE,FALSE, // FALSE,FALSE,FALSE, // 'clients',$clientinfo['hostname'],FALSE,FALSE); // foreach ($result_acl_ids as $acl_id) { // array_push($acls, $acl->get_acl($acl_id)); // } // #pre_var_dump($acls); // $smarty->assign('acls',$acls); // break; // case "delete": // check_action_access("Delete Client");#Access check // $clientinfo = get_scire_client($_GET['jobid']); // $smarty->assign('client', $clientinfo); // $smarty->assign('jobid', $_GET['jobid']); // break; } $smarty->assign('leftbar_menu', $leftbar_menu); $smarty->assign('Action', $_GET['Action']); $smarty->assign('status', $status); $smarty->display('job.tpl'); #pre_var_dump($_POST); ?>