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


PHP IP::isValidBlock方法代码示例

本文整理汇总了PHP中IP::isValidBlock方法的典型用法代码示例。如果您正苦于以下问题:PHP IP::isValidBlock方法的具体用法?PHP IP::isValidBlock怎么用?PHP IP::isValidBlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IP的用法示例。


在下文中一共展示了IP::isValidBlock方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * Construct an IP address representation.
  * @param string $address The textual representation of an IP address or CIDR range.
  */
 public function __construct($address)
 {
     // analyze address format
     $this->is_valid = IP::isIPAddress($address);
     if (!$this->is_valid) {
         return;
     }
     $this->is_ipv4 = IP::isIPv4($address);
     $this->is_ipv6 = !$this->is_ipv4 && IP::isIPv6($address);
     // analyze address range
     $this->is_range = IP::isValidBlock($address);
     $this->encoded_range = IP::parseRange($address);
     $this->range = array(IP::prettifyIP(IP::formatHex($this->encoded_range[self::START])), IP::prettifyIP(IP::formatHex($this->encoded_range[self::END])));
 }
开发者ID:bacoda,项目名称:Wikimedia-contrib,代码行数:18,代码来源:IP.php

示例2: network_add

function network_add()
{
    $tpc = new IP();
    if (!$tpc->isValidBlock($_POST["network-add"])) {
        echo "{$_POST["network-add"]} invalid";
        return;
    }
    $q = new mysql_squid_builder();
    $q->QUERY_SQL("INSERT IGNORE INTO webauth_rules_nets (pattern,ruleid) VALUES ('{$_POST["network-add"]}','{$_POST["ruleid"]}')");
    if (!$q->ok) {
        echo $q->mysql_error;
        return;
    }
    $sock = new sockets();
    $sock->getFrameWork("hotspot.php?remove-cache=yes");
}
开发者ID:articatech,项目名称:artica,代码行数:16,代码来源:webauth.rules.networks.php

示例3: testInvalidBlocks

 /**
  * @covers IP::isValidBlock
  */
 public function testInvalidBlocks()
 {
     $invalid = array('116.17.184.5/33', '0.17.184.5/130', '16.17.184.1/-1', '10.232.52.13/*', '7.232.52.13/ab', '11.232.52.13/', '::e:f:2001/129', '::c:f:2001/228', '::10:f:2001/-1', '::6d:f:2001/*', '::86:f:2001/ab', '::23:f:2001/');
     foreach ($invalid as $i) {
         $this->assertFalse(IP::isValidBlock($i), "{$i} is not a valid IP block");
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:10,代码来源:IPTest.php

示例4: parseTarget

 /**
  * From an existing Block, get the target and the type of target.
  * Note that, except for null, it is always safe to treat the target
  * as a string; for User objects this will return User::__toString()
  * which in turn gives User::getName().
  *
  * @param string|int|User|null $target
  * @return array( User|String|null, Block::TYPE_ constant|null )
  */
 public static function parseTarget($target)
 {
     # We may have been through this before
     if ($target instanceof User) {
         if (IP::isValid($target->getName())) {
             return array($target, self::TYPE_IP);
         } else {
             return array($target, self::TYPE_USER);
         }
     } elseif ($target === null) {
         return array(null, null);
     }
     $target = trim($target);
     if (IP::isValid($target)) {
         # We can still create a User if it's an IP address, but we need to turn
         # off validation checking (which would exclude IP addresses)
         return array(User::newFromName(IP::sanitizeIP($target), false), Block::TYPE_IP);
     } elseif (IP::isValidBlock($target)) {
         # Can't create a User from an IP range
         return array(IP::sanitizeRange($target), Block::TYPE_RANGE);
     }
     # Consider the possibility that this is not a username at all
     # but actually an old subpage (bug #29797)
     if (strpos($target, '/') !== false) {
         # An old subpage, drill down to the user behind it
         $parts = explode('/', $target);
         $target = $parts[0];
     }
     $userObj = User::newFromName($target);
     if ($userObj instanceof User) {
         # Note that since numbers are valid usernames, a $target of "12345" will be
         # considered a User.  If you want to pass a block ID, prepend a hash "#12345",
         # since hash characters are not valid in usernames or titles generally.
         return array($userObj, Block::TYPE_USER);
     } elseif (preg_match('/^#\\d+$/', $target)) {
         # Autoblock reference in the form "#12345"
         return array(substr($target, 1), Block::TYPE_AUTO);
     } else {
         # WTF?
         return array(null, null);
     }
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:51,代码来源:Block.php

示例5: testInvalidBlocks

 /**
  * @covers IP::isValidBlock
  * @dataProvider provideInvalidBlocks
  */
 public function testInvalidBlocks($invalid)
 {
     $this->assertFalse(IP::isValidBlock($invalid), "{$invalid} is not a valid IP block");
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:8,代码来源:IPTest.php

示例6: routes_main_network

function routes_main_network($ligne)
{
    $NetBuilder = new system_nic();
    $NetBuilder->LoadTools();
    $ipClass = new IP();
    $pattern = $ligne["pattern"];
    $gateway = $ligne["gateway"];
    if ($gateway == "0.0.0.0") {
        $gateway = null;
    }
    if (!isset($GLOBALS["PROC_NET_DEV"][$ligne["nic"]])) {
        $GLOBALS["SCRIPTS_ROUTES"][] = "# [{$ligne["nic"]}/" . __LINE__ . "] INTERFACE MATERIAL ERROR";
        return;
    }
    $eth = $NetBuilder->NicToOther($ligne["nic"]);
    $metric = $ligne["metric"];
    if (!$ipClass->isValidBlock($pattern)) {
        $GLOBALS["SCRIPTS_ROUTES"][] = "# [{$eth}/" . __LINE__ . "] {$pattern} is not a valid block";
        return;
    }
    if ($ligne["SourceBasedRouting"] == 1) {
        $table = alphaToNum($ligne["nic"]);
        $f[] = "{$GLOBALS["ipbin"]} add {$pattern}";
        if ($gateway != null) {
            $f[] = "via {$gateway}";
        }
        $f[] = "table {$table}";
        if ($metric > 0) {
            $f[] = "metric {$metric}";
        }
        return @implode(" ", $f);
    }
    if ($gateway == null) {
        $GLOBALS["SCRIPTS_ROUTES"][] = "# [{$ligne["nic"]}/" . __LINE__ . "] No gateway set, add just the net {$pattern} on interface {$eth}";
        $f[] = "{$GLOBALS["ipbin"]} route add {$pattern} dev {$eth}";
        if ($metric > 0) {
            $f[] = "metric {$metric}";
        }
        return @implode(" ", $f);
    }
    $GLOBALS["SCRIPTS_ROUTES"][] = "# [{$ligne["nic"]}/" . __LINE__ . "] {$pattern} via {$gateway} on interface {$eth}";
    $f[] = "{$GLOBALS["routebin"]} add -net {$pattern}";
    $f[] = "gw {$gateway}";
    $f[] = "dev {$eth}";
    if ($metric > 0) {
        $f[] = "metric {$metric}";
    }
    return @implode(" ", $f);
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:49,代码来源:exec.virtuals-ip.php


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