本文整理汇总了PHP中Addresses::validate_ip方法的典型用法代码示例。如果您正苦于以下问题:PHP Addresses::validate_ip方法的具体用法?PHP Addresses::validate_ip怎么用?PHP Addresses::validate_ip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Addresses
的用法示例。
在下文中一共展示了Addresses::validate_ip方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: explode
$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);
示例2:
$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";