本文整理汇总了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);
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}