當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。