예제 #1
0
 function GenMapMenu($table, $field, $order)
 {
     global $defined;
     $db = new dbConn();
     $val = new ValidateStrings();
     if (empty($table) || empty($field)) {
         return -1;
     }
     $conn = $db->dbConnect($defined['dbhost'], $defined['username'], $defined['password'], $defined['dbname']);
     if (empty($order)) {
         $query = "SELECT {$field} FROM `{$table}`";
     } else {
         $query = "SELECT {$field} FROM `{$table}` ORDER BY `{$order}`";
     }
     $query = $val->ValidateSQL($query, $conn);
     if (($value = $db->dbQuery($query, $conn)) === -1) {
         return -1;
     }
     if ($db->dbNumRows($value) === -1 || $db->dbNumRows($value) === 0) {
         return -1;
     } else {
         $list = "<form method=\"get\" action=\"{$_SERVER['PHP_SELF']}\"><b>Existing rides:</b> <select name=\"mapper\" onChange=\"jumpMenu('parent',this,0)\"><option value=\"NULL\">Select Map / Route...</option>";
         $list .= "<option>------------------------------</option>";
         foreach ($db->dbArrayResultsAssoc($value) as $key => $val) {
             $url = $_SERVER['PHP_SELF'] . "?lat=" . $val['lat'] . "&lon=" . $val['lon'] . "&z=" . $val['zoom'] . "&mType=" . $val['type'] . "&driveFrom=" . $val['from'] . "&driveTo=" . $val['to'] . "&driveVia=" . $val['via'] . "&locale=en";
             $list .= "<option name=\"{$url}\" value=\"{$url}\">" . $val['name'] . "</option>";
         }
         $list .= "</select></form>";
         $data = $list;
     }
     $db->dbFreeData($conn);
     $db->dbCloseConn($conn);
     return $data;
 }
예제 #2
0
 $FILE = "manage.pools.tpl";
 // initialize a db connection handle
 $dbconn = $db->dbConnect($defined['dbhost'], $defined['username'], $defined['password'], $defined['dbname']);
 // provide count of online users
 $online = "SELECT * FROM `admin_sessions`";
 $ret = $db->dbQuery($val->ValidateSQL($online, $dbconn), $dbconn);
 $usersoline = $db->dbNumRows($ret);
 // decode our authentication token to get our group membership
 $user_details = $encrypt->DecodeAuthToken($_SESSION['token']);
 $group = base64_decode($user_details[3]);
 // get an array of subnets the ISC DHCPD service may listen on
 $query = "SELECT `name`, `broadcast` FROM `conf_adapters` ORDER BY `broadcast` ASC";
 if (($value = $db->dbQuery($val->ValidateSQL($query, $dbconn), $dbconn)) === -1) {
     $error = $err->GenerateErrorLink("help/help.html", "#config_subnets", $defined['error'], $errors['db_select'], NULL, NULL);
 } else {
     $tmp = $db->dbArrayResultsAssoc($value);
     // filter for empty stuff
     for ($x = 0; $x < count($tmp); $x++) {
         if (!empty($tmp[$x]['broadcast'])) {
             $interface_list[$tmp[$x]['name']] = $tmp[$x]['broadcast'];
         }
     }
 }
 // Look for a GET id post to edit existing dnssec keys
 if (!empty($_GET['id'])) {
     if ($val->ValidateInteger($_GET['id']) === -1) {
         $error = $err->GenerateErrorLink("help/help.html", "#config_pools", $defined['error'], $errors['val_num'], NULL, NULL);
     } else {
         // populate the form with database information if already configured
         if ($group === "admin") {
             $query = "SELECT * FROM `conf_pools` WHERE `id` = \"" . $_GET['id'] . "\" LIMIT 1";
             $peer_address_err = $e;
         }
         if (empty($peer_port)) {
             $list .= "<li>Peer Port Field is missing</li>";
             $peer_port_err = $e;
         }
         $list .= "</ol>";
         $error = $err->GenerateErrorLink("help/help.html", "#config_dnssec", $defined['error'], $errors['val_missing'] . $list, NULL, NULL);
     }
 } else {
     // perform a lookup on current values to display for editing
     $query = "SELECT * FROM `conf_failover`";
     if (($value = $db->dbQuery($val->ValidateSQL($query, $dbconn), $dbconn)) === -1) {
         $error = $err->GenerateErrorLink("help/help.html", "#config_failover", $defined['error'], $errors['db_select'], NULL, NULL);
     } else {
         $data = $db->dbArrayResultsAssoc($value);
         $id = $data[0]['id'];
         $peer_name = $data[0]['peer name'];
         $primary = $data[0]['type'];
         $address = $data[0]['address'];
         $port = $data[0]['port'];
         $peer_address = $data[0]['peer address'];
         $peer_port = $data[0]['peer port'];
         $max_response_delay = $data[0]['max-response-delay'];
         $max_unacked_updates = $data[0]['max-unacked-updates'];
         $mclt = $data[0]['mclt'];
         $split = $data[0]['split'];
         $load_balance_max_seconds = $data[0]['load balance max seconds'];
     }
 }
 // Assign form variables
 // generate our sql command
 $insert = "INSERT INTO `conf_hosts` ( `hostname`, `mac-address`, `ip-address`, `subnet-name`, `pxe-group` ) VALUES ( \"" . $tmp[$x]['hostname'] . "\",\"" . $tmp[$x]['mac_address'] . "\", \"" . $tmp[$x]['ip_address'] . "\", \"" . $tmp[$x]['subnet'] . "\", \"" . $tmp[$x]['pxe_group'] . "\" )";
 // insert records or prompt for duplicate errors
 if (($value = $db->dbQuery($val->ValidateSQL($insert, $dbconn), $dbconn)) === -1) {
     // found an existing record?
     if (eregi("duplicate", $db->dbCatchError())) {
         // assign an error message
         $error = $err->GenerateErrorLink("help/help.html", "#import_host", $defined['error'], "Duplicate records found during import, please review and modify the data below accordingly.", NULL, NULL);
         // since we have a duplicate and not an invalid record give them the correct template
         $error_template = "admin.import.hosts.errors.tpl";
         // find the duplicate record so the user can edit it
         $find = "SELECT * FROM `conf_hosts` WHERE `hostname` = \"" . $tmp[$x]['hostname'] . "\" OR `mac-address` = \"" . $tmp[$x]['mac_address'] . "\" OR `ip-address` = \"" . $tmp[$x]['mac_address'] . "\" LIMIT 1";
         if (($value = $db->dbQuery($val->ValidateSQL($find, $dbconn), $dbconn)) === -1) {
             $error = $err->GenerateErrorLink("help/help.html", "#import_host", $defined['error'], "An error occured when attempting to lookup the duplicate record in which '" . $tmp[$x]['hostname'] . "' conflicts with.", NULL, NULL);
         } else {
             $found = $db->dbArrayResultsAssoc($value);
         }
         // populate our subnets list for our imported record
         $sub = "SELECT `subnet-name` FROM `conf_subnets` ORDER BY `subnet-name` ASC";
         if (($return = $db->dbQuery($val->ValidateSQL($sub, $dbconn), $dbconn)) !== -1) {
             $subs = $db->dbArrayResultsAssoc($return);
         }
         if (count($subs) === 0) {
             $subnet = "No subnets defined";
         } else {
             $subnet = $misc->GenDropMenuWSelectedSubnets($subs, $tmp[$x]['subnet'], 'subnet_tmp');
             // quick check to ensure subnet from import matches existing subnet group
             if (!in_array($tmp[$x]['subnet'], $subs) && !empty($tmp[$x]['subnet'])) {
                 $subnet_err[$x] = $err->GenerateErrorImg($defined['error'], "help/help.html#import_host", '800', '800');
                 $list .= "<li>Subnet field from import does match current list of existing subnet groups</li>";
             }
 // Look for a GET id post to edit existing dnssec keys
 if (!empty($_GET['id'])) {
     if ($val->ValidateInteger($_GET['id']) === -1) {
         $message = $err->GenerateErrorLink("help/help.html", "#user_edit", $defined['error'], $errors['val_num'], NULL, NULL);
     } else {
         // populate the form with database information if already configured
         if ($group === "admin") {
             $query = "SELECT * FROM `auth_users` WHERE `id` = \"" . $_GET['id'] . "\" LIMIT 1";
         } else {
             $query = "SELECT * FROM `auth_users` WHERE `group` = \"" . $group . "\" AND `id` = \"" . $_GET['id'] . "\" LIMIT 1";
         }
         if (($value = $db->dbQuery($val->ValidateSQL($query, $dbconn), $dbconn)) === -1) {
             echo $query;
             $message = $err->GenerateErrorLink("help/help.html", "#user_edit", $defined['error'], $errors['db_select'], NULL, NULL);
         } else {
             $data = $db->dbArrayResultsAssoc($value);
             $user_id = $data[0]['id'];
             $user_username = $data[0]['username'];
             $user_fname = $data[0]['first'];
             $user_lname = $data[0]['last'];
             $user_access_level = $data[0]['level'];
             $user_group = $data[0]['group'];
             $user_department = $data[0]['dept'];
             $user_contact = $data[0]['contact'];
             $user_phone = $data[0]['phone'];
             $user_email = $data[0]['email'];
             $message = $err->GenerateErrorLink("help/help.html", "#edit_user", $defined['good'], "You are currently editing record #" . $user_id, NULL, NULL);
         }
     }
 }
 // check for form submission first
 // provide count of online users
 $online = "SELECT * FROM `admin_sessions`";
 $ret = $db->dbQuery($val->ValidateSQL($online, $dbconn), $dbconn);
 $usersoline = $db->dbNumRows($ret);
 // Look for a GET id post to edit existing dnssec keys
 if (!empty($_GET['id'])) {
     if ($val->ValidateInteger($_GET['id']) === -1) {
         $message = $err->GenerateErrorLink("help/help.html", "#group_edit", $defined['error'], $errors['val_num'], NULL, NULL);
     } else {
         // populate the form with database information if already configured
         $query = "SELECT * FROM `auth_groups` WHERE `id` = \"" . $_GET['id'] . "\" LIMIT 1";
         if (($value = $db->dbQuery($val->ValidateSQL($query, $dbconn), $dbconn)) === -1) {
             echo $query;
             $message = $err->GenerateErrorLink("help/help.html", "#group_edit", $defined['error'], $errors['db_select'], NULL, NULL);
         } else {
             $data = $db->dbArrayResultsAssoc($value);
             $group_id = $data[0]['id'];
             $group_name = $data[0]['group'];
             $group_manager = $data[0]['manager'];
             $group_contact = $data[0]['contact'];
             $group_description = $data[0]['description'];
             $message = $err->GenerateErrorLink("help/help.html", "#host_search", $defined['good'], "You are currently editing record #" . $group_id, NULL, NULL);
         }
     }
 }
 // check for form submission first
 if (!empty($_POST)) {
     // setup our form variables
     $group_name = $_POST['group_name'];
     $group_manager = $_POST['group_manager'];
     $group_contact = $_POST['group_contact'];
예제 #7
0
 $group = base64_decode($user_details[3]);
 // Look for a GET id post to edit existing dnssec keys
 if (!empty($_GET['id'])) {
     if ($val->ValidateInteger($_GET['id']) === -1) {
         $error = $err->GenerateErrorLink("help/help.html", "#config_dnssec", $defined['error'], $errors['val_num'], NULL, NULL);
     } else {
         // populate the form with database information if already configured
         //if( $group === "admin" ) {
         $query = "SELECT * FROM `conf_dns_opts` WHERE `id` = \"" . $_GET['id'] . "\" LIMIT 1";
         //} else {
         // $query = "SELECT * FROM `conf_dns_opts` WHERE `id` = \"" . $_GET['id'] . "\" AND `group`	= \"" . $group . "\" LIMIT 1";
         //}
         if (($value = $db->dbQuery($val->ValidateSQL($query, $dbconn), $dbconn)) === -1) {
             $error = $err->GenerateErrorLink("help/help.html", "#config_dnssec", $defined['error'], $errors['db_select'], NULL, NULL);
         } else {
             $data = $db->dbArrayResultsAssoc($value);
             $id = $data[0]['id'];
             $zone = $data[0]['zone'];
             $primary = $data[0]['type'];
             $dnssec_enabled = $data[0]['dnssec-enabled'];
             $dnssec_key = $data[0]['dnssec-key'];
         }
     }
 }
 // begin our validation on submitted data
 if (!empty($_POST)) {
     // re-assign vars for processing and template assignment
     $id = $_POST['id'];
     $zone = $_POST['zone'];
     $primary = $_POST['primary'];
     $dnssec_enabled = $_POST['dnssec_enabled'];
 $FILE = "manage.subnets.tpl";
 // initialize a db connection handle
 $dbconn = $db->dbConnect($defined['dbhost'], $defined['username'], $defined['password'], $defined['dbname']);
 // provide count of online users
 $online = "SELECT * FROM `admin_sessions`";
 $ret = $db->dbQuery($val->ValidateSQL($online, $dbconn), $dbconn);
 $usersoline = $db->dbNumRows($ret);
 // decode our authentication token to get our group membership
 $user_details = $encrypt->DecodeAuthToken($_SESSION['token']);
 $group = base64_decode($user_details[3]);
 // get an array of subnets the ISC DHCPD service may listen on
 $query = "SELECT `name`, `broadcast` FROM `conf_adapters` ORDER BY `broadcast` ASC";
 if (($value = $db->dbQuery($val->ValidateSQL($query, $dbconn), $dbconn)) === -1) {
     $error = $err->GenerateErrorLink("help/help.html", "#config_subnets", $defined['error'], $errors['db_select'], NULL, NULL);
 } else {
     $tmp = $db->dbArrayResultsAssoc($value);
     // filter for empty stuff
     if (count($tmp) > 0) {
         for ($x = 0; $x < count($tmp); $x++) {
             if (!empty($tmp[$x]['broadcast'])) {
                 $interface_list[$tmp[$x]['name']] = $tmp[$x]['broadcast'];
             }
         }
     } else {
         $error = $err->GenerateErrorLink("help/help.html", "#config_subnets", $defined['error'], "It seems the list of available network interfaces that the DHCPD service may bind to is unavailable", NULL, NULL);
     }
 }
 /* get array of resources available for this users group membership */
 if ($group === "admin") {
     $sql = "SELECT * FROM `auth_groups_perms` WHERE `type` = \"subnet\" AND `allowed` = \"" . $group . "\"";
 } else {
예제 #9
0
 $group = base64_decode($user_details[3]);
 // Look for a GET id post to edit existing host records
 if (!empty($_GET['id'])) {
     if ($val->ValidateInteger($_GET['id']) === -1) {
         $error = $err->GenerateErrorLink("help/help.html", "#host_search", $defined['error'], $errors['val_num'], NULL, NULL);
     } else {
         // populate the form with database information if already configured
         if ($group === "admin" || !empty($_GET['allow']) && $val->ValidateInteger($_GET['allow']) === 0) {
             $query = "SELECT * FROM `conf_hosts` WHERE `id` = \"" . $_GET['id'] . "\" LIMIT 1";
         } else {
             $query = "SELECT * FROM `conf_hosts` WHERE `group` = \"" . $group . "\" AND `id` = \"" . $_GET['id'] . "\" LIMIT 1";
         }
         if (($value = $db->dbQuery($val->ValidateSQL($query, $dbconn), $dbconn)) === -1) {
             $error = $err->GenerateErrorLink("help/help.html", "#host_search", $defined['error'], $errors['db_select'], NULL, NULL);
         } else {
             $data = $db->dbArrayResultsAssoc($value);
             /* check resource permissions */
             if ($group !== "admin") {
                 $resource = "SELECT * FROM `auth_groups_perms` WHERE ( `group` = \"" . $group . "\" OR `allowed` = \"" . $group . "\" ) AND `type` = \"host\" AND `resource` = \"" . $data[0]['mac-address'] . "\"";
             } else {
                 $resource = "SELECT * FROM `auth_groups_perms` WHERE `resource` = \"" . $data[0]['mac-address'] . "\"";
             }
             if (($value = $db->dbQuery($val->ValidateSQL($resource, $dbconn), $dbconn)) === -1) {
                 $error = $err->GenerateErrorLink("help/help.html", "#config_subnets", $defined['error'], $errors['db_select'], NULL, NULL);
             } else {
                 $ch = $db->dbArrayResultsAssoc($value);
                 if (count($ch) > 0 || $data[0]['group'] === $group) {
                     $id = $data[0]['id'];
                     $hostname = $data[0]['hostname'];
                     $mac_address = $data[0]['mac-address'];
                     $ip_address = $data[0]['ip-address'];
예제 #10
0
 $group = base64_decode($user_details[3]);
 // Look for a GET id post to edit existing dnssec keys
 if (!empty($_GET['id'])) {
     if ($val->ValidateInteger($_GET['id']) === -1) {
         $error = $err->GenerateErrorLink("help/help.html", "#config_dnssec", $defined['error'], $errors['val_num'], NULL, NULL);
     } else {
         // populate the form with database information if already configured
         //if( $group === "admin" ) {
         $query = "SELECT * FROM `conf_dnssec_opts` WHERE `id` = \"" . $_GET['id'] . "\" LIMIT 1";
         //} else {
         // $query = "SELECT * FROM `conf_dnssec_opts` WHERE `id` = \"" . $_GET['id'] . "\" WHERE `group` = \"" . $group . "\" LIMIT 1";
         //}
         if (($value = $db->dbQuery($val->ValidateSQL($query, $dbconn), $dbconn)) === -1) {
             $error = $err->GenerateErrorLink("help/help.html", "#config_dnssec", $defined['error'], $errors['db_select'], NULL, NULL);
         } else {
             $data = $db->dbArrayResultsAssoc($value);
             $id = $data[0]['id'];
             $key_name = $data[0]['key-name'];
             $algorithm = $data[0]['algorithm'];
             $key = $data[0]['key'];
         }
     }
 }
 // begin our validation on submitted data
 if (!empty($_POST)) {
     // re-assign vars for processing and template assignment
     $id = $_POST['id'];
     $key_name = $_POST['key_name'];
     $algorithm = $_POST['algorithm'];
     $key = $_POST['key'];
     // check each post element
 $group = base64_decode($user_details[3]);
 // Look for a GET id post to edit existing dnssec keys
 if (!empty($_GET['id'])) {
     if ($val->ValidateInteger($_GET['id']) === -1) {
         $error = $err->GenerateErrorLink("help/help.html", "#config_shared", $defined['error'], $errors['val_num'], NULL, NULL);
     } else {
         // populate the form with database information if already configured
         if ($group === "admin") {
             $query = "SELECT * FROM `conf_shared_networks` WHERE `id` = \"" . $_GET['id'] . "\" LIMIT 1";
         } else {
             $query = "SELECT * FROM `conf_shared_networks` WHERE `group` = \"" . $group . "\" AND `id` = \"" . $_GET['id'] . "\" LIMIT 1";
         }
         if (($value = $db->dbQuery($val->ValidateSQL($query, $dbconn), $dbconn)) === -1) {
             $error = $err->GenerateErrorLink("help/help.html", "#config_shared", $defined['error'], $errors['db_select'], NULL, NULL);
         } else {
             $data = $db->dbArrayResultsAssoc($value);
             $id = $data[0]['id'];
             $shared_network = $data[0]['shared-network-name'];
             // populate list of assigned subnets by shared-network-name
             if ($group === "admin") {
                 $sql = "SELECT `subnet-name`, `shared-network` FROM `conf_subnets` WHERE `shared-network` = \"" . $shared_network . "\"";
             } else {
                 $sql = "SELECT `subnet-name`, `shared-network` FROM `conf_subnets` WHERE `shared-network` = \"" . $shared_network . "\" AND `group` = \"" . $group . "\"";
             }
             if (($nets = $db->dbQuery($val->ValidateSQL($sql, $dbconn), $dbconn)) === -1) {
                 $error = $err->GenerateErrorLink("help/help.html", "#config_shared", $defined['error'], $errors['db_select'], NULL, NULL);
             } else {
                 $subnet_checkboxes = $db->dbArrayResultsAssoc($nets);
                 $error = $err->GenerateErrorLink("help/help.html", "#config_subnet", $defined['good'], "You are currently editing the shared-network named '" . $shared_network . "'", NULL, NULL);
             }
         }
예제 #12
0
 if ($level->ChkLevel($_SESSION['token']) === "root" || $level->ChkLevel($_SESSION['token'] === "user")) {
     // define some variables for the template etc.
     $FILE = "loggedin.tpl";
     //hidediv( 'graphs' ); preLoader( 'templates/images/graphs/graph.hosts.php', 'templates/images/graphs/graph.leases.php', 'templates/images/graphs/graph.pxe.php', 'templates/images/graphs/graph.subnets.php', 'templates/images/graphs/graph.traffic.php' );
     $JS = " hidediv( 'subnets'); hidediv( 'adapters' );";
     $FORM = NULL;
     $page = "admin.manage.users.php";
     // decode the auth token for our username data
     $user_details = $encrypt->DecodeAuthToken($_SESSION['token']);
     $username = base64_decode($user_details[0]);
     // get an array of subnets the ISC DHCPD service may listen on
     $query = "SELECT `name`, `broadcast` FROM `conf_adapters` ORDER BY `broadcast` ASC";
     if (($value = $db->dbQuery($val->ValidateSQL($query, $dbconn), $dbconn)) === -1) {
         $error = $err->GenerateErrorLink("help/help.html", "#config_subnets", $defined['error'], $errors['db_select'], NULL, NULL);
     } else {
         $tmp = $db->dbArrayResultsAssoc($value);
         // filter for empty stuff
         for ($x = 0; $x < count($tmp); $x++) {
             if (!empty($tmp[$x]['broadcast'])) {
                 $interface_list[$tmp[$x]['name']] = $tmp[$x]['broadcast'];
             }
         }
     }
     // show the user the list of interfaces and their broadcast address
     if (($ilist = $misc->GenTableFromAssocArray($interface_list)) === -1) {
         $adapters = $err->GenerateErrorLink("help/help.html", "#config_subnet", $defined['error'], "There are no interfaces configured", NULL, NULL);
     } else {
         $adapters = $misc->GenTableFromAssocArray($interface_list);
     }
     // check service status
     if ($misc->GetDHCPDStatus() === 0) {
 function GetAvailableIPAddresses($value, $subnet)
 {
     //echo "<pre>"; print_r( $value ); echo "</pre>";
     global $defined;
     $db = new dbConn();
     $val = new ValidateStrings();
     // initialize a db connection handle
     $dbconn = $db->dbConnect($defined['dbhost'], $defined['username'], $defined['password'], $defined['dbname']);
     // process available scope IP's minus IP's engaged in `conf_leases` table
     preg_match('/([0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3})\\.([0-9]{1,3})/', $value['scope-range-1'], $start);
     preg_match('/([0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3})\\.([0-9]{1,3})/', $value['scope-range-2'], $end);
     // populate a range of valid octets to use
     for ($x = $start[2]; $x < $end[2]; $x++) {
         $tmp[] = $start[1] . "." . $x;
     }
     // mathmatica bitch
     $x = 1;
     for ($i = $start[2]; $i < $end[2]; $i++) {
         $total[$key] = $x;
         $x++;
     }
     // now get list of IP's in use as noted by the `conf_leases` table
     $sql = "SELECT `ip` FROM `conf_leases` WHERE `ip` LIKE \"" . $start[1] . "%\"";
     if (($return = $db->dbQuery($val->ValidateSQL($sql, $dbconn), $dbconn)) !== -1) {
         if ($db->dbNumRows($return) !== 0) {
             $leases = $db->dbArrayResultsAssoc($return);
         }
     }
     // mathmatics
     $amnt = $total[$key];
     $in_use = count($leases);
     $unused = $amnt - $in_use;
     // populate empty list
     if (count($tmp) !== 0) {
         $x = 0;
         foreach ($tmp as $key => $value) {
             for ($i = 0; $i < count($leases); $i++) {
                 if (!in_array($value, $leases[$i])) {
                     $empty[$x][] = $value;
                     $x++;
                 }
             }
         }
         $empty = $this->EliminiateDuplicates($empty);
     }
     // put everything in a simple array, wuka wuka
     $ip_counts[$subnet]['total'] = $amnt;
     $ip_counts[$subnet]['total_used'] = $in_use;
     $ip_counts[$subnet]['total_unused'] = $unused;
     $ip_counts[$subnet]['detail_used'] = $leases;
     $ip_counts[$subnet]['detail_unused'] = $empty;
     // Free db handle and close connection(s)
     $db->dbFreeData($dbconn);
     $db->dbCloseConn($dbconn);
     // give it to them raw, raw
     return $ip_counts;
 }
예제 #14
0
 $group = base64_decode($user_details[3]);
 // Look for a GET id post to edit existing dnssec keys
 if (!empty($_GET['id'])) {
     if ($val->ValidateInteger($_GET['id']) === -1) {
         $error = $err->GenerateErrorLink("help/help.html", "#config_pxegroup", $defined['error'], $errors['val_num'], NULL, NULL);
     } else {
         // populate the form with database information if already configured
         if ($group === "admin") {
             $query = "SELECT * FROM `conf_pxe_groups` WHERE `id` = \"" . $_GET['id'] . "\" LIMIT 1";
         } else {
             $query = "SELECT * FROM `conf_pxe_groups` WHERE `group` = \"" . $group . "\" AND `id` = \"" . $_GET['id'] . "\" LIMIT 1";
         }
         if (($value = $db->dbQuery($val->ValidateSQL($query, $dbconn), $dbconn)) === -1) {
             $error = $err->GenerateErrorLink("help/help.html", "#config_pxegroup", $defined['error'], $errors['db_select'], NULL, NULL);
         } else {
             $data = $db->dbArrayResultsAssoc($value);
             $id = $data[0]['id'];
             $pxe_group_name = $data[0]['pxe-group-name'];
             $pxe_server = $data[0]['pxe-server'];
             $bootp_filename = $data[0]['bootp-filename'];
             $assigned_subnet = $data[0]['assigned-subnet'];
         }
     }
 }
 // begin our validation on submitted data
 if (!empty($_POST)) {
     // re-assign vars for processing and template assignment
     $id = $_POST['id'];
     $pxe_group_name = $_POST['pxe_group_name'];
     $pxe_server = $_POST['pxe_server'];
     $bootp_filename = $_POST['bootp_filename'];
 // define some variables for the template etc.
 $JS = " hidediv('perms');";
 $FILE = "manage.classes.tpl";
 // initialize a db connection handle
 $dbconn = $db->dbConnect($defined['dbhost'], $defined['username'], $defined['password'], $defined['dbname']);
 // provide count of online users
 $online = "SELECT * FROM `admin_sessions`";
 $ret = $db->dbQuery($val->ValidateSQL($online, $dbconn), $dbconn);
 $usersoline = $db->dbNumRows($ret);
 // decode our authentication token to get our group membership
 $user_details = $encrypt->DecodeAuthToken($_SESSION['token']);
 $group = base64_decode($user_details[3]);
 // create list of class options
 $optsquery = "DESCRIBE `conf_classes_opts`";
 if (($current = $db->dbQuery($val->ValidateSQL($optsquery, $dbconn), $dbconn)) !== -1) {
     $optslist = $db->dbArrayResultsAssoc($current);
 }
 if (count($optslist) === 0) {
     $class_option = "Class Options table missing";
 } else {
     foreach ($optslist as $key => $value) {
         if ($value['Field'] !== "id") {
             $encoded[$value['Field']] = $value['Type'];
         }
     }
     $encoded = json_encode($encoded);
 }
 // Look for a GET id post to edit existing dnssec keys
 if (!empty($_GET['id'])) {
     if ($val->ValidateParagraph($_GET['id']) === -1) {
         $error = $err->GenerateErrorLink("help/help.html", "#config_classes", $defined['error'], $errors['val_num'], NULL, NULL);