本文整理汇总了PHP中Random::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP Random::instance方法的具体用法?PHP Random::instance怎么用?PHP Random::instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Random
的用法示例。
在下文中一共展示了Random::instance方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create_user
public function create_user($userdata)
{
$password = \Arr::get($userdata, 'password', null);
$email = \Arr::get($userdata, 'email', null);
if (is_null($password) || is_null($email)) {
Logger::instance()->log_log_in_attempt(Model_Log_In_Attempt::$ATTEMPT_BAD_CRIDENTIALS, $email);
throw new LogInFailed(\Lang::get('ethanol.errors.loginInvalid'));
}
$user = Auth_Driver::get_core_user($email);
$security = new Model_User_Security();
//Generate a salt
$security->salt = Hasher::instance()->hash(\Date::time(), Random::instance()->random());
$security->password = Hasher::instance()->hash($password, $security->salt);
if (\Config::get('ethanol.activate_emails', false)) {
$keyLength = \Config::get('ethanol.activation_key_length');
$security->activation_hash = Random::instance()->random($keyLength);
$user->activated = 0;
//Send email
\Package::load('email');
//Build an array of data that can be passed to the email template
$emailData = array('email' => $user->email, 'activation_path' => \Str::tr(\Config::get('ethanol.activation_path'), array('key' => $security->activation_hash)));
$email = \Email::forge()->from(\Config::get('ethanol.activation_email_from'))->to($user->email, $user->username)->subject(\Config::get('ethanol.activation_email_subject'))->html_body(\View::forge('ethanol/activation_email', $emailData))->send();
} else {
$user->activated = 1;
$security->activation_hash = '';
}
$user->security = $security;
$user->save();
$user->clean_security();
return $user;
}
示例2: get_form
/**
* Generates a facebook login page using the facebook template
*
* @return string
*/
public function get_form()
{
$csrf_key = Random::instance()->random();
Session::instance()->get_instance()->set('ethanol.driver.facebook.csrf', $csrf_key);
$redirect_url = urlencode(parent::get_login_controller_path('facebook'));
$app_id = \Config::get('ethanol.facebook.app_id');
$login_url = "https://www.facebook.com/dialog/oauth?client_id={$app_id}&redirect_uri={$redirect_url}&state={$csrf_key}&scope=email";
return \View::forge('ethanol/driver/facebook_login')->set('login_url', $login_url)->render();
}