本文整理匯總了PHP中yii\web\Request::getUserIP方法的典型用法代碼示例。如果您正苦於以下問題:PHP Request::getUserIP方法的具體用法?PHP Request::getUserIP怎麽用?PHP Request::getUserIP使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類yii\web\Request
的用法示例。
在下文中一共展示了Request::getUserIP方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: allows
/**
* Checks whether the Web user is allowed to perform the specified action.
* @param Action $action the action to be performed
* @param User $user the user object
* @param Request $request
* @return boolean|null true if the user is allowed, false if the user is denied, null if the rule does not apply to the user
*/
public function allows($action, $user, $request)
{
if ($this->matchAction($action) && $this->matchRole($user) && $this->matchIP($request->getUserIP()) && $this->matchVerb($request->getMethod()) && $this->matchController($action->controller) && $this->matchCustom($action)) {
return $this->allow ? true : false;
} else {
return null;
}
}
示例2: getUserIP
public function getUserIP()
{
return empty($_SERVER["HTTP_CF_CONNECTING_IP"]) ? empty($_SERVER['HTTP_X_FORWARDED_FOR']) ? parent::getUserIP() : $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER["HTTP_CF_CONNECTING_IP"];
}