$list = "<ol><li>Search string is invalid. Allowed formats:<br>MAC Address: xx:xx:xx:xx:xx<br>IPv4 Address: xxx.xxx.xxx.xxx<br>Hostname: [0-9a-z]</li></ol>"; $error = $err->GenerateErrorLink("help/help.html", "#host_search", $defined['error'], $errors['val_host'] . $list, NULL, NULL); } } else { $sql_success = -1; // check each post element if (!empty($hostname) && !empty($mac_address) && !empty($ip_address) && !empty($subnet_name)) { // perform lookup of available scopes to prevent overlaps between static hosts and scope address $sql = "SELECT `scope-range-1`,`scope-range-2` FROM `conf_subnets` WHERE `scope-range-1` > '' AND `scope-range-2` > ''"; if (($value = $db->dbQuery($val->ValidateSQL($sql, $dbconn), $dbconn)) !== -1) { if ($db->dbNumRows($value) !== 0) { $scopes = $db->dbArrayResultsAssoc($value); } } // begin validation of configuration options if ($val->ValidateHostname($hostname) !== -1 && $val->ValidateMACFormats($mac_address) !== -1 && $val->ValidateIPv4($ip_address) !== -1 && ($val->ValidateParagraph($subnet_name) !== -1 || $val->ValidateParagraph($pxe_group) !== -1) && $val->ValidateIPvsScope($scopes, $ip_address) !== -1) { // since no errors for the mac address were recieved assign the *possibly fixed value $mac_address = $val->ValidateMACFormats($mac_address); // define our sql statements (if group is admin, discard that field) if ($group === "admin") { $insert = "INSERT INTO `conf_hosts` ( `hostname`, `mac-address`, `ip-address`, `subnet-name`, `pxe-group` ) VALUES ( \"" . $hostname . "\",\"" . $mac_address . "\", \"" . $ip_address . "\", \"" . $subnet_name . "\", \"" . $pxe_group . "\" )"; $update = "UPDATE `conf_hosts` SET `hostname` = \"" . $hostname . "\", `mac-address` = \"" . $mac_address . "\", `ip-address` = \"" . $ip_address . "\", `subnet-name` = \"" . $subnet_name . "\", `pxe-group` = \"" . $pxe_group . "\" WHERE `id` = \"" . $id . "\" LIMIT 1"; } else { $insert = "INSERT INTO `conf_hosts` ( `hostname`, `mac-address`, `ip-address`, `subnet-name`, `pxe-group`, `group` ) VALUES ( \"" . $hostname . "\",\"" . $mac_address . "\", \"" . $ip_address . "\", \"" . $subnet_name . "\", \"" . $pxe_group . "\", \"" . $group . "\" )"; if (!empty($_POST['ex_group'])) { $update = "UPDATE `conf_hosts` SET `hostname` = \"" . $hostname . "\", `mac-address` = \"" . $mac_address . "\", `ip-address` = \"" . $ip_address . "\", `subnet-name` = \"" . $subnet_name . "\", `pxe-group` = \"" . $pxe_group . "\", `group` = \"" . $group . "\" WHERE `id` = \"" . $id . "\" LIMIT 1"; } else { $update = "UPDATE `conf_hosts` SET `hostname` = \"" . $hostname . "\", `mac-address` = \"" . $mac_address . "\", `ip-address` = \"" . $ip_address . "\", `subnet-name` = \"" . $subnet_name . "\", `pxe-group` = \"" . $pxe_group . "\", WHERE `id` = \"" . $id . "\" LIMIT 1"; } } $delete = "DELETE FROM `conf_hosts` WHERE `id` = \"" . $id . "\" LIMIT 1";
$circut_id = $_POST['circut_id']; $remote_id = $_POST['remote_id']; $ddns_text = $_POST['ddns_text']; $ddns_fwd_name = $_POST['ddns_fwd_name']; $ddns_client_fqdn = $_POST['ddns_client_fqdn']; $ddns_rev_name = $_POST['ddns_rev_name']; $search = $_POST['search']; $startdate = $_POST['startdate']; $enddate = $_POST['enddate']; // perform search if not empty if (!empty($_POST['SrchLeases'])) { if (empty($search) && empty($startdate) && empty($enddate)) { $error = $err->GenerateErrorLink("help/help.html", "#lease_search", $defined['error'], "Empty search fields, please enter an IP or Hostname to search or enter a start and end date for a list of leases between those dates", NULL, NULL); } else { // perform validation on search string(s) if ($val->ValidateIPv4($search) !== -1 || $val->ValidateMACFormats($search) !== -1 || $val->ValidateHostname($search) !== -1 && $val->ValidateDate($startdate) !== -1 && $val->ValidateDate($enddate) !== -1) { /* define our search query */ if ($group !== "admin") { $having = " HAVING `group` = \"" . $group . "\""; } // search by dates if (!empty($startdate) || !empty($enddate)) { $dates = " `start` > \"" . $startdate . "\" AND `end` < \"" . $enddate . "\""; } // provide fields search if (!empty($search)) { $main = "`hostname` LIKE \"" . $search . "\" OR `hardware` LIKE \"" . $search . "\" OR `ip` LIKE \"" . $search . "\""; } // and apply the attributes $query = "SELECT * FROM `conf_leases` WHERE {$main}{$dates}{$having} ORDER BY `hostname` ASC"; // process our query
$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); } } } } // begin our validation on submitted data if (!empty($_POST)) { // re-assign vars for processing and template assignment $id = $_POST['id']; $shared_network = $_POST['shared_network_name']; $subnet_checkboxes = $_POST['subnet_checkboxes']; // check each post element if (!empty($shared_network) && count($subnet_checkboxes) !== 0) { // begin validation of configuration options if ($val->ValidateHostname($shared_network) !== -1) { // define our sql statements (exclude the group field if user is member of admin group) if ($group !== "admin") { $insert = "INSERT INTO `conf_shared_networks` ( `shared-network-name`, `group` ) VALUES ( \"" . $shared_network . "\", \"" . $group . "\" )"; $update = "UPDATE `conf_shared_networks` SET `shared-network-name` = \"" . $shared_network . "\", `group` = \"" . $group . "\" WHERE `id` = \"" . $id . "\" LIMIT 1"; } else { $insert = "INSERT INTO `conf_shared_networks` ( `shared-network-name` ) VALUES ( \"" . $shared_network . "\" )"; $update = "UPDATE `conf_shared_networks` SET `shared-network-name` = \"" . $shared_network . "\" WHERE `id` = \"" . $id . "\" LIMIT 1"; } $delete = "DELETE FROM `conf_shared_networks` WHERE `id` = \"" . $id . "\" LIMIT 1"; // determine which button was clicked if (!empty($_POST['AddShared'])) { $new = TRUE; $query = $insert; $db_msg_good = $errors['db_insert']; $db_msg_err = $errors['db_insert_err'];