Ejemplo n.º 1
0
         $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";