本文整理汇总了PHP中HTTP::getClientIP方法的典型用法代码示例。如果您正苦于以下问题:PHP HTTP::getClientIP方法的具体用法?PHP HTTP::getClientIP怎么用?PHP HTTP::getClientIP使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTTP
的用法示例。
在下文中一共展示了HTTP::getClientIP方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doFetchUser
/**
* Fetch user.
*
* @param string $field Criteria field
* @param mixed $value Criteria value
* @return Auth_User
*/
protected function doFetchUser($field, $value)
{
if (!$this->queryInit || !$this->query instanceof DB_Statement) {
$this->initStatement();
}
$this->query->addCriteria($field, $value);
$result = $this->query->execute();
$this->query->reset();
if (!$result->countRows()) {
return null;
}
$info = array_combine(array('id', 'fullname', 'username', 'host', 'password', 'groups', 'active', 'expire') + $result->getFieldNames(), $result->fetchOrdered());
$info['host'] = HTTP::getClientIP();
return new Auth_User($info);
}
示例2: isBlocked
/**
* Check if host is blocked.
* Returns 0 if unblockable.
*
* @param string $host
* @param boolean $attempt Increment attempts (bool) or attempt (int)
* @return boolean
*/
public function isBlocked($host = null, $attempt = false)
{
if (empty($this->loginAttempts)) {
return 0;
}
if (!isset($host)) {
$host = HTTP::getClientIP(HTTP::CONNECTED_CLIENT);
}
if (empty($host) || in_array($host, $this->unblockableHosts, true)) {
return 0;
}
if (!isset($this->storeAttemps)) {
if (!Cache::hasInstance()) {
return 0;
}
$this->storeAttemps = Cache::i();
} elseif (!$this->storeAttemps instanceof Cache) {
$this->storeAttemps = Cache::with($this->storeAttemps, array('overwrite' => true));
}
if (is_bool($attempt)) {
$attempt = (int) $this->storeAttemps->get("AUTH-login_attempts:{$host}") + 1;
}
if ($attempt) {
$this->storeAttemps->save("AUTH-login_attempts:{$host}", $attempt);
} else {
$this->storeAttemps->remove("AUTH-login_attempts:{$host}");
}
return $this->loginAttempts - $attempt < 0;
}