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