当前位置: 首页>>代码示例>>PHP>>正文


PHP Addresses::validate_ip方法代码示例

本文整理汇总了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);
开发者ID:routenull0,项目名称:phpipam,代码行数:31,代码来源:address-modify-submit.php

示例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";
开发者ID:routenull0,项目名称:phpipam,代码行数:31,代码来源:import-ipaddr-check.php


注:本文中的Addresses::validate_ip方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。