$not_strict = @$address['nostrict'] == "yes" ? true : false; # check if subnet is multicast $subnet_is_multicast = $Subnets->is_multicast($subnet['subnet']); # are we adding/editing range? if (strlen(strstr($address['ip_addr'], "-")) > 0) { # set flag for updating $address['type'] = "series"; # remove possible spaces $address['ip_addr'] = str_replace(" ", "", $address['ip_addr']); # get start and stop of range $range = explode("-", $address['ip_addr']); $address['start'] = $range[0]; $address['stop'] = $range[1]; # verify both IP addresses if ($subnet['isFolder'] == "1") { if ($Addresses->validate_ip($address['start']) === false) { $Result->show("danger", _("Invalid IP address") . "!", true); } if ($Addresses->validate_ip($address['stop']) === false) { $Result->show("danger", _("Invalid IP address") . "!", true); } } else { $Addresses->verify_address($address['start'], "{$subnet['ip']}/{$subnet['mask']}", $not_strict); $Addresses->verify_address($address['stop'], "{$subnet['ip']}/{$subnet['mask']}", $not_strict); } # go from start to stop and insert / update / delete IPs $start = $Subnets->transform_to_decimal($address['start']); $stop = $Subnets->transform_to_decimal($address['stop']); # start cannot be higher than stop! if ($start > $stop) { $Result->show("danger", _("Invalid address range") . "!", true);
$action = "error"; } else { $cdata['state'] = $tag_data[$cdata['tag']]['id']; } } else { # no tag provided, using default $cdata['state'] = 2; } # Verify gateway if (in_array(strtolower($cdata['is_gateway']), array("yes", "true", "1"))) { $cdata['is_gateway'] = 1; } else { $cdata['is_gateway'] = 0; } if ($action != "error") { if (!$Addresses->validate_ip($cdata['ip_addr'])) { $msg .= "Invalid IP address."; $action = "error"; } if (!empty($cdata['dns_name']) and !preg_match("/^(?=.{1,255}\$)[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?(?:\\.[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?)*\\.?\$/", $cdata['dns_name'])) { $msg .= "Invalid DNS name."; $action = "error"; } if (preg_match("/[;'\"]/", $cdata['description'])) { $msg .= "Invalid characters in description."; $action = "error"; } if ($cdata['mac']) { if (!preg_match("/^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})\$/", $cdata['mac'])) { $msg .= "Invalid MAC address."; $action = "error";