本文整理汇总了PHP中Banner::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP Banner::instance方法的具体用法?PHP Banner::instance怎么用?PHP Banner::instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Banner
的用法示例。
在下文中一共展示了Banner::instance方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: log_log_in_attempt
/**
* Logs an attempt to log in in the database so things like the numner of
* log in attempts can be recorded.
*
* @param int $status One of $ATTEMPT_GOOD, $ATTEMPT_NO_SUCH_USER or $ATTEMPT_BAD_CRIDENTIALS from Model_Log_In_Attempt
* @param string $email The email that's trying to log in.
*/
public function log_log_in_attempt($status, $email)
{
if (!$this->logging_enabled()) {
return;
}
$logEntry = new Model_Log_In_Attempt();
$logEntry->email = is_null($email) ? '' : $email;
$logEntry->status = $status;
$logEntry->save();
//If the entry failed then add a ban too
if ($status != Model_Log_In_Attempt::$ATTEMPT_GOOD) {
Banner::instance()->auto_ban($email);
}
}
示例2: ban
/**
* Bans an email address and/or an ip for the given time
*
* @param string|int $time Number of seconds to ban for or something like "+1 Day"
* @param null|string|true $ip Null to ignore IP, string to specify the ip, true to automatically load the ip
* @param null|string $email
*/
public function ban($time, $ip = null, $email = null)
{
Banner::instance()->ban($time, $ip, $email);
}
示例3: perform_login
/**
* Attemps an oAuth login. Will create a new user if one does not already
* exist with the given email. If a user is logged in the 3rd party account
* is linked with the logged in user.
*
* @param string $email The email passed back from the 3rd party
* @param string $driver Name of the driver the email is from
* @return Ethanol\Model_User
*/
protected function perform_login($email, $driver)
{
//This is the first point that we have an email do make a check for
//banned users
if (Banner::instance()->is_banned($email)) {
throw new LogInFailed(\Lang::get('ethanol.errors.exceededLoginTries'));
}
//Check if a user exists yet.
$oauth = Model_User_Oauth::find('first', array('related' => array('user'), 'where' => array(array('driver', $driver), array('email', $email))));
//if not create
if (is_null($oauth)) {
//Check if we have a guest user or not.
if (Ethanol::instance()->is_guest()) {
$user = new Model_User();
$user->activated = Model_User::$USER_ACTIVATED;
$user->email = $email;
} else {
//Not a guest user so get the current user.
$user = Ethanol::instance()->current_user();
}
//And assocate the new oauth with it.
$oauth = new Model_User_Oauth();
$oauth->driver = $driver;
$oauth->email = $email;
$user->oauth[] = $oauth;
$user->save();
} else {
$user = $oauth->user;
}
return $user;
}