当前位置: 首页>>代码示例>>PHP>>正文


PHP Random::instance方法代码示例

本文整理汇总了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;
 }
开发者ID:inespons,项目名称:ethanol,代码行数:31,代码来源:Database.php

示例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();
 }
开发者ID:inespons,项目名称:ethanol,代码行数:14,代码来源:Facebook.php


注:本文中的Random::instance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。