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


PHP WebRequest::getIP方法代码示例

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


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

示例1: testGetIpLackOfRemoteAddrThrowAnException

 /**
  * @expectedException MWException
  * @covers WebRequest::getIP
  */
 public function testGetIpLackOfRemoteAddrThrowAnException()
 {
     // ensure that local install state doesn't interfere with test
     $this->setMwGlobals(array('wgSquidServersNoPurge' => array(), 'wgSquidServers' => array(), 'wgUsePrivateIPs' => false, 'wgHooks' => array()));
     $request = new WebRequest();
     # Next call throw an exception about lacking an IP
     $request->getIP();
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:12,代码来源:WebRequestTest.php

示例2: incrMissesRecent

 /**
  * Roughly increments the cache misses in the last hour by unique visitors
  * @param WebRequest $request
  * @return void
  */
 public function incrMissesRecent(WebRequest $request)
 {
     if (mt_rand(0, self::MISS_FACTOR - 1) == 0) {
         $cache = ObjectCache::getLocalClusterInstance();
         # Get a large IP range that should include the user  even if that
         # person's IP address changes
         $ip = $request->getIP();
         if (!IP::isValid($ip)) {
             return;
         }
         $ip = IP::isIPv6($ip) ? IP::sanitizeRange("{$ip}/32") : IP::sanitizeRange("{$ip}/16");
         # Bail out if a request already came from this range...
         $key = wfMemcKey(get_class($this), 'attempt', $this->mType, $this->mKey, $ip);
         if ($cache->get($key)) {
             return;
             // possibly the same user
         }
         $cache->set($key, 1, self::MISS_TTL_SEC);
         # Increment the number of cache misses...
         $key = $this->cacheMissKey();
         if ($cache->get($key) === false) {
             $cache->set($key, 1, self::MISS_TTL_SEC);
         } else {
             $cache->incr($key);
         }
     }
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:32,代码来源:FileCacheBase.php

示例3: check

 /**
  * Test against the passed WebRequest
  * @param WebRequest $request
  * @return Status
  */
 public function check(WebRequest $request)
 {
     $ok = ['ip' => $this->checkIP($request->getIP())];
     $status = Status::newGood();
     $status->setResult($ok === array_filter($ok), $ok);
     return $status;
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:12,代码来源:MWRestrictions.php

示例4: WebRequest

 /**
  * @expectedException MWException
  */
 function testGetIpLackOfRemoteAddrThrowAnException()
 {
     $request = new WebRequest();
     # Next call throw an exception about lacking an IP
     $request->getIP();
 }
开发者ID:Jobava,项目名称:diacritice-meta-repo,代码行数:9,代码来源:WebRequestTest.php


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