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


PHP Security::generate_token方法代码示例

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


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

示例1: displayForm

 /**
  * Renders the field's form element for editing in the admin site
  */
 public static function displayForm($value, &$settings, $model)
 {
     $class = get_called_class();
     $settings = static::settings($settings);
     $include_label = isset($settings['label']) ? $settings['label'] : true;
     $required = isset($settings['required']) ? $settings['required'] : false;
     $errors = $model->getErrorsForField($settings['mapping']['fieldName']);
     $has_errors = count($errors) > 0;
     $input_attributes = isset($settings['input_attributes']) ? $settings['input_attributes'] : array('class' => 'input-xxlarge');
     if (!isset($input_attributes['id'])) {
         $input_attributes['id'] = 'form_' . $settings['mapping']['fieldName'];
     }
     $attributes = array('class' => 'controls control-group' . ($has_errors ? ' error' : '') . ' field-type-' . $class::type($settings));
     $label_text = $settings['title'] . ($required ? ' *' : '');
     if (empty($value)) {
         $value = substr(\Security::generate_token(), 0, 16);
     }
     // Description?
     $description = isset($settings['description']) ? '<span class="help-block">' . $settings['description'] . '</span>' : '';
     // Build the input
     $input = '<input type="text" name="' . $settings['mapping']['fieldName'] . '" ' . array_to_attr($input_attributes) . ' value="' . \Security::htmlentities(strval($value), ENT_QUOTES) . '" />';
     // Build the label
     $label = !$include_label ? '' : html_tag('label', array('class' => 'item-label', 'for' => $settings['mapping']['fieldName']), $label_text . ($has_errors ? ' - ' . $errors[0] : ''));
     // Don't wrap the input if wrap is set to false
     if (isset($settings['wrap']) && $settings['wrap'] === false) {
         return $label . $input;
     }
     return html_tag('div', $attributes, $label . $description . $input);
 }
开发者ID:soundintheory,项目名称:fuel-cmf,代码行数:32,代码来源:RandomKey.php

示例2: create_instantly

 public static function create_instantly($user_id)
 {
     $obj = self::forge();
     $obj->slug = Site_Util::get_slug();
     $obj->title = date(conf('default.dateFormat')) . 'の' . term('news.view');
     $obj->users_id = $user_id;
     $obj->token = \Security::generate_token();
     $obj->is_published = 0;
     $obj->format = conf('form.formats.default', 'news');
     $obj->save();
     return $obj;
 }
开发者ID:uzura8,项目名称:flockbird,代码行数:12,代码来源:news.php

示例3: save_with_token

 public static function save_with_token($email, $password, $invite_member_id = null)
 {
     $obj = self::forge();
     $obj->email = $email;
     $obj->password = $password;
     $obj->token = Security::generate_token();
     $obj->invite_member_id = $invite_member_id;
     if (!$obj->save()) {
         return false;
     }
     return $obj->token;
 }
开发者ID:uzura8,项目名称:flockbird,代码行数:12,代码来源:memberpre.php

示例4: save_with_token

 public static function save_with_token($member_id, $email)
 {
     if (!($obj = self::get4member_id($member_id))) {
         $obj = self::forge();
     }
     $obj->member_id = $member_id;
     $obj->email = $email;
     $obj->token = Security::generate_token();
     if (!$obj->save()) {
         return false;
     }
     return $obj->token;
 }
开发者ID:uzura8,项目名称:flockbird,代码行数:13,代码来源:memberpasswordpre.php

示例5: save_with_token

 public static function save_with_token($member_id, $email)
 {
     if (!($obj = Model_MemberEmailPre::get4member_id($member_id))) {
         $obj = Model_MemberEmailPre::forge();
     }
     $obj->member_id = $member_id;
     $obj->email = $email;
     $obj->token = Security::generate_token();
     $obj->code = Util_String::get_random_code(static::$_properties['code']['form']['validation']['exact_length'][0]);
     if (!$obj->save()) {
         return false;
     }
     return $obj;
 }
开发者ID:uzura8,项目名称:flockbird,代码行数:14,代码来源:memberemailpre.php

示例6: action_create

 /**
  * News create
  * 
  * @access  public
  * @return  Response
  */
 public function action_create()
 {
     // if insert image mode, forbidden to display create form.
     if (conf('image.isInsertBody', 'news')) {
         throw new \HttpNotFoundException();
     }
     $news = \News\Model_News::forge();
     $val = self::get_validation_object($news);
     $images = array();
     $files = array();
     $is_enabled_image = \Config::get('news.image.isEnabled');
     $is_enabled_file = \Config::get('news.file.isEnabled');
     $is_enabled_link = \Config::get('news.link.isEnabled');
     $posted_links = array();
     if (\Input::method() == 'POST') {
         \Util_security::check_csrf();
         if ($is_enabled_link) {
             $posted_links = $this->get_posted_links();
             $val = $this->add_validation_object_posted_links($val, $posted_links);
         }
         $image_tmps = array();
         $file_tmps = array();
         $moved_images = array();
         $moved_files = array();
         $news_image_ids = array();
         $news_file_ids = array();
         $error_message = '';
         try {
             if ($is_enabled_image) {
                 $image_tmps = \Site_FileTmp::get_file_tmps_and_check_filesize();
             }
             if ($is_enabled_file) {
                 $file_tmps = \Site_FileTmp::get_file_tmps_and_check_filesize(null, null, 'file');
             }
             if (!$val->run()) {
                 throw new \FuelException($val->show_errors());
             }
             $post = $val->validated();
             if ($post['format'] == 2) {
                 $post['body'] = preg_replace('/^\\&gt;/um', '>', $post['body']);
             }
             $news->set_values($post);
             $news->users_id = $this->u->id;
             $news->token = \Security::generate_token();
             $news->is_published = $post['is_draft'] ? 0 : 1;
             if ($post['published_at_time']) {
                 $news->published_at = $post['published_at_time'] . ':00';
             } elseif ($news->is_published) {
                 $news->published_at = date('Y-m-d H:i:s');
             }
             \DB::start_transaction();
             $news->save();
             if ($is_enabled_image) {
                 list($moved_images, $news_image_ids) = \Site_FileTmp::save_images($image_tmps, $news->id, 'news_id', 'news_image');
             }
             if ($is_enabled_file) {
                 list($moved_files, $news_file_ids) = \Site_FileTmp::save_images($file_tmps, $news->id, 'news_id', 'news_file', null, 'file');
             }
             if ($is_enabled_link) {
                 $this->save_posted_links($posted_links, $news->id);
             }
             if (\Config::get('news.tags.isEnabled')) {
                 \News\Model_NewsTag::save_tags($post['tags'], $news->id);
             }
             //// timeline 投稿
             //if ($note->is_published && is_enabled('timeline'))
             //{
             //	\Timeline\Site_Model::save_timeline($this->u->id, $post['public_flag'], 'note', $note->id);
             //}
             \DB::commit_transaction();
             // thumbnail 作成 & tmp_file thumbnail 削除
             \Site_FileTmp::make_and_remove_thumbnails($moved_images);
             $message = sprintf('%sを%sしました。', term('news.view'), $news->is_published ? term('form.publish') : term('form.draft'));
             \Session::set_flash('message', $message);
             \Response::redirect('admin/news/detail/' . $news->id);
         } catch (\Database_Exception $e) {
             $error_message = \Site_Controller::get_error_message($e, true);
         } catch (\FuelException $e) {
             $error_message = $e->getMessage();
         }
         if ($error_message) {
             if (\DB::in_transaction()) {
                 \DB::rollback_transaction();
             }
             if ($moved_images) {
                 \Site_FileTmp::move_files_to_tmp_dir($moved_images);
             }
             if ($moved_files) {
                 \Site_FileTmp::move_files_to_tmp_dir($moved_files);
             }
             $images = \Site_FileTmp::get_file_objects($image_tmps, $this->u->id, true, 'img');
             $files = \Site_FileTmp::get_file_objects($file_tmps, $this->u->id, true, 'file');
             \Session::set_flash('error', $error_message);
         }
//.........这里部分代码省略.........
开发者ID:uzura8,项目名称:flockbird,代码行数:101,代码来源:news.php


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