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


PHP auth::generate_random_string方法代码示例

本文整理汇总了PHP中auth::generate_random_string方法的典型用法代码示例。如果您正苦于以下问题:PHP auth::generate_random_string方法的具体用法?PHP auth::generate_random_string怎么用?PHP auth::generate_random_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在auth的用法示例。


在下文中一共展示了auth::generate_random_string方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 function __construct()
 {
     $this->rules = array();
     $this->id = auth::generate_random_string(16, 16);
     $this->js = Kohana::config('xform.js');
     // Singleton instance
     self::$instance = $this;
 }
开发者ID:AsteriaGamer,项目名称:steamdriven-kohana,代码行数:8,代码来源:XformJS.php

示例2: forgotten_credential_email

 /**
  * send forgotten email
  *
  * @return void
  * @author Andy Bennett
  */
 public static function forgotten_credential_email()
 {
     $email = Event::$data->post('form_email');
     $user = ORM::factory('user')->where(array('email' => $email, 'activated' => 1))->find();
     if (!$user->loaded) {
         throw new Exception("auth.no_matching_user");
     }
     // generates the activation code
     $user->forgotten_credential_code = auth::generate_random_string(10, 10);
     $user->save();
     $email_data = array('user' => $user);
     $data = array('data' => $email_data, 'view' => Kohana::config('steamauth.steamauth')->forgotten_credential_email, 'subject' => 'forgotten_credential_email_subject', 'to' => $user->email);
     self::send_email($data);
 }
开发者ID:AsteriaGamer,项目名称:steamdriven-kohana,代码行数:20,代码来源:auth_email_listeners.php

示例3: save

 /**
  * Save an uploaded file to a new location.
  *
  * @param   mixed    name of $_FILE input or array of upload data
  * @param   string   new filename
  * @param   string   new directory
  * @param   integer  chmod mask
  * @return  string   full path to new file
  */
 public static function save($file, $filename = NULL, $directory = NULL, $chmod = 0644)
 {
     // Load file data from FILES if not passed as array
     $file = is_array($file) ? $file : $_FILES[$file];
     if ($filename === NULL) {
         // Use the default filename, with a timestamp pre-pended
         $filename = time() . auth::generate_random_string(8, 8) . '-' . $file['name'];
     }
     if (Kohana::config('upload.remove_spaces') === TRUE) {
         // Remove spaces from the filename
         $filename = preg_replace('/\\s+/', '_', $filename);
     }
     if ($directory === NULL) {
         // Use the pre-configured upload directory
         $directory = Kohana::config('upload.directory', TRUE);
     }
     // Make sure the directory ends with a slash
     $directory = rtrim($directory, '/') . '/';
     if (!is_dir($directory) and Kohana::config('upload.create_directories') === TRUE) {
         // Create the upload directory
         mkdir($directory, 0777, TRUE);
     }
     if (!is_writable($directory)) {
         throw new Kohana_Exception('upload.not_writable', $directory);
     }
     if (is_uploaded_file($file['tmp_name']) and move_uploaded_file($file['tmp_name'], $filename = $directory . $filename)) {
         if ($chmod !== FALSE) {
             // Set permissions on filename
             chmod($filename, $chmod);
         }
         // Return new file path
         return $filename;
     } else {
         $valid_dir = strpos(realpath($file['tmp_name']), DATAPATH . 'tmp') === 0;
         if ($valid_dir and rename($file['tmp_name'], $filename = $directory . $filename)) {
             if ($chmod !== FALSE) {
                 // Set permissions on filename
                 chmod($filename, $chmod);
             }
             // Return new file path
             return $filename;
         }
     }
     return FALSE;
 }
开发者ID:AsteriaGamer,项目名称:steamdriven-kohana,代码行数:54,代码来源:MY_upload.php

示例4: forgotten_credential_reset

 /**
  * reset user's password
  *
  * @return void
  * @author Andy Bennett
  */
 public function forgotten_credential_reset()
 {
     try {
         $segs = array_reverse(URI::instance()->segment_array());
         $code = $segs[0];
         $id = $segs[1];
         // check the passed values
         if (!is_numeric($id) or $id <= 0) {
             throw new Exception("auth.invalid_user_id");
         }
         if (!strlen($code) or !preg_match('/[a-zA-Z0-9]+/', $code)) {
             throw new Exception('auth.invalid_forgotten_code');
         }
         $user = ORM::factory('user')->where(array('id' => $id, 'activated' => 1, 'forgotten_credential_code' => $code))->find();
         if (!$user->loaded) {
             throw new Exception("auth.invalid_user");
         }
         // if they do, generate a new credential
         $conf = Kohana::config('steamauth.steamauth');
         $credential = auth::generate_random_string($conf->user_credential_min, $conf->user_credential_max);
         //encrypts the random credential using the md5 encryption
         $user->credential = auth::encode($credential);
         $user->save();
         // inform the user of their new credential
         $email_data = array('user' => $user, 'credential' => $credential);
         Event::run('steamauth.forgotten_credential_reset', $email_data);
     } catch (Exception $e) {
         Event::run('steamauth.forgotten_credential_reset_error', $error = $e->getMessage());
     }
 }
开发者ID:AsteriaGamer,项目名称:steamdriven-kohana,代码行数:36,代码来源:Steamauth.php


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