當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Utility::getClientIp方法代碼示例

本文整理匯總了PHP中Utility::getClientIp方法的典型用法代碼示例。如果您正苦於以下問題:PHP Utility::getClientIp方法的具體用法?PHP Utility::getClientIp怎麽用?PHP Utility::getClientIp使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Utility的用法示例。


在下文中一共展示了Utility::getClientIp方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testGetClientIp

 /**
  * UtilityTest::testGetClientIp()
  *
  * @covers Utility::getClientIp
  * @return void
  */
 public function testGetClientIp()
 {
     $res = Utility::getClientIp();
     $this->assertEquals(env('REMOTE_ADDR'), $res);
 }
開發者ID:ByMyHandsOnly,項目名稱:BMHO_Web,代碼行數:11,代碼來源:UtilityTest.php

示例2: setUserIp

 /**
  * LogableBehavior::setUserIp()
  *
  * @param Model $Model
  * @param mixed $userIP
  * @return void
  */
 public function setUserIp(Model $Model, $userIP = null)
 {
     if ($userIP === null) {
         $userIP = Utility::getClientIp();
     }
     $this->userIP = $userIP;
 }
開發者ID:Jony01,項目名稱:LLD,代碼行數:14,代碼來源:LogableBehavior.php

示例3: getClientIp

 /**
  * get the current ip address
  * @param bool $safe
  * @return string $ip
  * 2011-11-02 ms
  */
 public static function getClientIp($safe = null)
 {
     return Utility::getClientIp($safe);
 }
開發者ID:robksawyer,項目名稱:grabitdown,代碼行數:10,代碼來源:CommonComponent.php

示例4: _logAttempt

 /**
  * Logs attempts
  *
  * @param bool ErrorsOnly (only if error occured, otherwise always)
  * @returns null if not logged, true otherwise
  */
 protected function _logAttempt($errorsOnly = true)
 {
     if ($errorsOnly === true && empty($this->error) && empty($this->internalError)) {
         return null;
     }
     if (!$this->settings[$this->Model->alias]['log']) {
         return null;
     }
     $msg = 'IP \'' . Utility::getClientIp() . '\', Agent \'' . env('HTTP_USER_AGENT') . '\', Referer \'' . env('HTTP_REFERER') . '\', Host-Referer \'' . Utility::getReferer() . '\'';
     if (!empty($this->error)) {
         $msg .= ', ' . $this->error;
     }
     if (!empty($this->internalError)) {
         $msg .= ' (' . $this->internalError . ')';
     }
     $this->log($msg, 'captcha');
     return true;
 }
開發者ID:Jony01,項目名稱:LLD,代碼行數:24,代碼來源:CaptchaBehavior.php

示例5: traceDetails

 /**
  * Append some more infos to better track down the error
  *
  * @return string
  */
 public static function traceDetails()
 {
     if (empty($_SERVER['REQUEST_URI']) || strpos($_SERVER['REQUEST_URI'], '/test.php?') === 0) {
         return null;
     }
     $currentUrl = Router::url();
     //isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : 'n/a';
     $refererUrl = Utility::getReferer();
     //Router::getRequest()->url().'
     $uid = !empty($_SESSION) && !empty($_SESSION['Auth']['User']['id']) ? $_SESSION['Auth']['User']['id'] : null;
     $data = [Utility::getClientIp(), $currentUrl . (!empty($refererUrl) ? ' (' . $refererUrl . ')' : ''), $uid, env('HTTP_USER_AGENT')];
     return implode(' - ', $data);
 }
開發者ID:ByMyHandsOnly,項目名稱:BMHO_Web,代碼行數:18,代碼來源:MyErrorHandler.php


注:本文中的Utility::getClientIp方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。