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


PHP Validation::ip方法代码示例

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


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

示例1: findLocationByIp

 /**
  * @return array or boolean false
  */
 public function findLocationByIp()
 {
     $ip = $this->findIp();
     if (empty($ip)) {
         return false;
     }
     if (Validation::ip($ip)) {
         App::import('Vendor', 'geoip', ['file' => 'geoip' . DS . 'geoip.php']);
         $gi = Net_GeoIP::getInstance(APP . 'vendors' . DS . 'geoip' . DS . 'GeoLiteCity.dat');
         $record = $gi->lookupLocation($ip);
         $gi->close();
     } else {
         $this->log('Invalid IP \'' . h($ip) . '\'', LOG_WARNING);
     }
     return !empty($record) ? $this->findLocationByCoordinates($record->latitude, $record->longitude, 1) : false;
 }
开发者ID:dereuromark,项目名称:cakephp-data,代码行数:19,代码来源:LocationsTable.php

示例2: testIpv6

 /**
  * testIp v6
  *
  * @return void
  */
 public function testIpv6()
 {
     $this->assertTrue(Validation::ip('2001:0db8:85a3:0000:0000:8a2e:0370:7334', 'IPv6'));
     $this->assertTrue(Validation::ip('2001:db8:85a3:0:0:8a2e:370:7334', 'IPv6'));
     $this->assertTrue(Validation::ip('2001:db8:85a3::8a2e:370:7334', 'IPv6'));
     $this->assertTrue(Validation::ip('2001:0db8:0000:0000:0000:0000:1428:57ab', 'IPv6'));
     $this->assertTrue(Validation::ip('2001:0db8:0000:0000:0000::1428:57ab', 'IPv6'));
     $this->assertTrue(Validation::ip('2001:0db8:0:0:0:0:1428:57ab', 'IPv6'));
     $this->assertTrue(Validation::ip('2001:0db8:0:0::1428:57ab', 'IPv6'));
     $this->assertTrue(Validation::ip('2001:0db8::1428:57ab', 'IPv6'));
     $this->assertTrue(Validation::ip('2001:db8::1428:57ab', 'IPv6'));
     $this->assertTrue(Validation::ip('0000:0000:0000:0000:0000:0000:0000:0001', 'IPv6'));
     $this->assertTrue(Validation::ip('::1', 'IPv6'));
     $this->assertTrue(Validation::ip('::ffff:12.34.56.78', 'IPv6'));
     $this->assertTrue(Validation::ip('::ffff:0c22:384e', 'IPv6'));
     $this->assertTrue(Validation::ip('2001:0db8:1234:0000:0000:0000:0000:0000', 'IPv6'));
     $this->assertTrue(Validation::ip('2001:0db8:1234:ffff:ffff:ffff:ffff:ffff', 'IPv6'));
     $this->assertTrue(Validation::ip('2001:db8:a::123', 'IPv6'));
     $this->assertTrue(Validation::ip('fe80::', 'IPv6'));
     $this->assertTrue(Validation::ip('::ffff:192.0.2.128', 'IPv6'));
     $this->assertTrue(Validation::ip('::ffff:c000:280', 'IPv6'));
     $this->assertFalse(Validation::ip('123', 'IPv6'));
     $this->assertFalse(Validation::ip('ldkfj', 'IPv6'));
     $this->assertFalse(Validation::ip('2001::FFD3::57ab', 'IPv6'));
     $this->assertFalse(Validation::ip('2001:db8:85a3::8a2e:37023:7334', 'IPv6'));
     $this->assertFalse(Validation::ip('2001:db8:85a3::8a2e:370k:7334', 'IPv6'));
     $this->assertFalse(Validation::ip('1:2:3:4:5:6:7:8:9', 'IPv6'));
     $this->assertFalse(Validation::ip('1::2::3', 'IPv6'));
     $this->assertFalse(Validation::ip('1:::3:4:5', 'IPv6'));
     $this->assertFalse(Validation::ip('1:2:3::4:5:6:7:8:9', 'IPv6'));
     $this->assertFalse(Validation::ip('::ffff:2.3.4', 'IPv6'));
     $this->assertFalse(Validation::ip('::ffff:257.1.2.3', 'IPv6'));
     $this->assertFalse(Validation::ip('255.255.255.255', 'ipv6'), 'IPv4 is not valid IPv6');
 }
开发者ID:alvaroziqar,项目名称:galei,代码行数:39,代码来源:ValidationTest.php

示例3: addresses

 /**
  * Get all IP addresses associated with the current connection.
  *
  * @return array IP addresses
  */
 public function addresses()
 {
     if (Validation::ip($this->config['host'])) {
         return array($this->config['host']);
     }
     return gethostbynamel($this->config['host']);
 }
开发者ID:ronaldsalazar23,项目名称:ComercialChiriguano,代码行数:12,代码来源:CakeSocket.php

示例4: testIpV6

 /**
  * testIpV6 method
  *
  * @access public
  * @return void
  */
 function testIpV6()
 {
     $this->assertFalse(Validation::ip('', '6'));
     $this->assertFalse(Validation::ip(':', '6'));
     $this->assertTrue(Validation::ip('::', '6'));
     $this->assertFalse(Validation::ip(':::', '6'));
     $this->assertFalse(Validation::ip('::::', '6'));
     $this->assertTrue(Validation::ip('::1', '6'));
     $this->assertTrue(Validation::ip('4:4:4:4:4:4:4:4:4', '6'));
     $this->assertTrue(Validation::ip('0:123:af00:fff:0C67:0:0:8787', '6'));
     $this->assertTrue(Validation::ip('0::af00:ffff:0C67:0:0:8787', '6'));
     $this->assertTrue(Validation::ip('0af4:0af4:0af4:0af4:0af4:0af4:0af4:0af4', '6'));
     $this->assertTrue(Validation::ip('af4:af4:af4:af4:af4:af4:af4:af4', '6'));
     $this->assertTrue(Validation::ip('f4:f4:f4:f4:f4:f4:f4:f4', '6'));
     $this->assertTrue(Validation::ip('4:4:4:4:4:4:4:4', '6'));
     $this->assertTrue(Validation::ip('4::4:4:4:4:4:4', '6'));
     $this->assertTrue(Validation::ip('4::4:4:4:4:4', '6'));
     $this->assertTrue(Validation::ip('4::4:4:4:4', '6'));
     $this->assertTrue(Validation::ip('4::4:4:4', '6'));
     $this->assertTrue(Validation::ip('4::4:4', '6'));
     $this->assertTrue(Validation::ip('4::4', '6'));
     $this->assertTrue(Validation::ip('4::', '6'));
     $this->assertTrue(Validation::ip('::ffff:12.34.56.78', '6'));
     $this->assertFalse(Validation::ip('::01.02.03.04', '6'));
     $this->assertFalse(Validation::ip('0:0:0:255.255.255.255', '6'));
     $this->assertFalse(Validation::ip('1fff::a88:85a3::172.31.128.1', '6'));
 }
开发者ID:evrard,项目名称:cakephp2x,代码行数:33,代码来源:validation.test.php

示例5: testIpBoth

 /**
  * testIpBoth method
  *
  * @return void
  * @access public
  */
 function testIpBoth()
 {
     $this->assertTrue(Validation::ip('0.0.0.0'));
     $this->assertTrue(Validation::ip('192.168.1.156'));
     $this->assertTrue(Validation::ip('255.255.255.255'));
     $this->assertFalse(Validation::ip('127.0.0'));
     $this->assertFalse(Validation::ip('127.0.0.a'));
     $this->assertFalse(Validation::ip('127.0.0.256'));
     $this->assertTrue(Validation::ip('2001:0db8:85a3:0000:0000:8a2e:0370:7334'));
     $this->assertTrue(Validation::ip('2001:db8:85a3:0:0:8a2e:370:7334'));
     $this->assertTrue(Validation::ip('2001:db8:85a3::8a2e:370:7334'));
     $this->assertFalse(Validation::ip('2001:db8:85a3::8a2e:37023:7334'));
     $this->assertFalse(Validation::ip('2001:db8:85a3::8a2e:370k:7334'));
     $this->assertFalse(Validation::ip('1:2:3:4:5:6:7:8:9'));
 }
开发者ID:ryo01u,项目名称:fb_driland_modoki,代码行数:21,代码来源:validation.test.php

示例6: testIp

 /**
  * testIp method
  *
  * @access public
  * @return void
  */
 function testIp()
 {
     $this->assertTrue(Validation::ip('0.0.0.0'));
     $this->assertTrue(Validation::ip('192.168.1.156'));
     $this->assertTrue(Validation::ip('255.255.255.255'));
     $this->assertFalse(Validation::ip('127.0.0'));
     $this->assertFalse(Validation::ip('127.0.0.a'));
     $this->assertFalse(Validation::ip('127.0.0.256'));
 }
开发者ID:BGCX067,项目名称:fake-as3-svn-to-git,代码行数:15,代码来源:validation.test.php

示例7: testInvalidIpAsMalformed

 /**
  * @testdox ip should return false to malformed IPs
  */
 public function testInvalidIpAsMalformed()
 {
     $value = '123456789';
     $this->assertFalse(Validation::ip($value));
 }
开发者ID:klawdyo,项目名称:spaghettiphp,代码行数:8,代码来源:ValidationTest.php

示例8: ipFormat

 /**
  * @deprecated - use IpLip instead!
  * @return string v4/v6 or FALSE on failure
  */
 public function ipFormat($ip)
 {
     if (Validation::ip($ip, 'ipv4')) {
         return 'ipv4';
     }
     if (Validation::ip($ip, 'ipv6')) {
         return 'ipv6';
     }
     return false;
 }
开发者ID:robksawyer,项目名称:grabitdown,代码行数:14,代码来源:CommonComponent.php


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