本文整理匯總了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;
}