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


PHP UserIdentity::crypt方法代码示例

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


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

示例1: actionStep2

 public function actionStep2()
 {
     $model = new Step2();
     $form = new Form('install.Step2', $model);
     $this->performAjaxValidation($model);
     if ($form->submitted() && $model->validate()) {
         $configs = CMap::mergeArray(Yii::app()->user->getState('install_configs'), $model->getConfigs());
         Yii::app()->user->setState('install_configs', $configs);
         $step1 = Step1::loadFromSession();
         Yii::app()->setComponent('db', $step1->createDbConnection());
         //install modules
         Yii::app()->setModules($model->modules);
         //$step1->deleteDisableModules();
         //migrate
         Yii::app()->getModule('users');
         Yii::app()->executor->migrate('up --module=main');
         foreach (Yii::app()->getModules() as $id => $data) {
             if ($id == 'main') {
                 continue;
             }
             Yii::app()->getModule($id);
             if (is_dir(Yii::getPathOfAlias($id . '.migrations'))) {
                 $response = Yii::app()->executor->migrate('up --module=' . $id);
                 if (stripos($response, 'successfully') === false) {
                     echo $response;
                     die;
                 }
             }
         }
         //create admin user
         $user = new User();
         list($user->name) = explode('@', $model->admin_email);
         $user->name = ucfirst($user->name);
         $user->email = $model->admin_email;
         $user->password = UserIdentity::crypt($model->admin_pass);
         $user->status = User::STATUS_ACTIVE;
         $user->save(false);
         //set admin
         $auth = Yii::app()->authManager;
         $auth->clearAll();
         $auth->createRole('Admin');
         $auth->assign('Admin', $user->id);
         //commands collect
         Yii::app()->executor->addCommandsFromModules(Yii::app()->getModules());
         //run install method
         foreach (Yii::app()->getModules() as $id => $conf) {
             @mkdir(Yii::getPathOfAlias('webroot.upload.' . $id), 0755, true);
             Yii::app()->getModule($id)->install();
         }
         $model->saveInSession();
         //install base modules
         $this->redirect('/install.php?r=/install/install/step3');
     }
     $this->render('step2', array('form' => $form));
 }
开发者ID:blindest,项目名称:Yii-CMS-2.0,代码行数:55,代码来源:InstallController.php

示例2: afterValidate

 protected function afterValidate()
 {
     if ($this->isNewRecord) {
         $this->password = UserIdentity::crypt($this->password);
     } else {
         if ($this->newPassword) {
             $this->password = UserIdentity::crypt($this->newPassword);
         }
     }
     return parent::afterValidate();
 }
开发者ID:Bodya91,项目名称:yii-rest,代码行数:11,代码来源:User.php

示例3: up

 public function up()
 {
     $user = new User();
     $user->name = 'admin';
     $user->email = 'admin@admin.ru';
     $user->password = UserIdentity::crypt('123456');
     $user->status = 'active';
     $user->birthdate = '2011-01-01';
     $user->gender = User::GENDER_MAN;
     $user->save();
 }
开发者ID:blindest,项目名称:Yii-CMS-2.0,代码行数:11,代码来源:m121128_201845_create_admin_user.php

示例4: up

 public function up()
 {
     $this->createTable('user', array('id' => 'pk', 'fname' => 'string', 'lname' => 'string', 'username' => 'string', 'password' => 'string', 'pw_reset_token' => 'string', 'email' => 'string', 'role' => 'string', 'is_deleted' => 'int', 'create_date' => 'datetime'), 'ENGINE=InnoDB');
     $this->createTable('cookie', array('id' => 'pk', 'username' => 'string', 'token' => 'string', 'create_date' => 'datetime'), 'ENGINE=InnoDB');
     $this->createTable('event', array('id' => 'pk', 'user_id' => 'int', 'place' => 'string', 'start' => 'datetime', 'end' => 'datetime', 'comment' => 'text', 'create_date' => 'datetime'), 'ENGINE=InnoDB');
     //---Add users
     $password = UserIdentity::crypt('1111');
     // => md5('1111'.UserIdentity::$salt);
     $this->insert('user', array('fname' => 'Admin', 'lname' => 'Adminovich', 'username' => 'admin', 'password' => $password, 'pw_reset_token' => '', 'email' => 'admin@admin.loc', 'role' => 'admin', 'is_deleted' => 0, 'create_date' => new CDbExpression('NOW()')));
     $adminId = Yii::app()->db->getLastInsertId();
     $this->insert('user', array('fname' => 'User', 'lname' => 'Userovich', 'username' => 'user', 'password' => $password, 'pw_reset_token' => '', 'email' => 'user@user.loc', 'role' => 'user', 'is_deleted' => 0, 'create_date' => new CDbExpression('NOW()')));
     $userId = Yii::app()->db->getLastInsertId();
     //--- Add base event
     $this->insert('event', array('user_id' => $userId, 'place' => 'Italia', 'start' => new CDbExpression('NOW() - INTERVAL 1 DAY'), 'end' => new CDbExpression('NOW() + INTERVAL 2 DAY'), 'comment' => 'Unitary state', 'create_date' => new CDbExpression('NOW()')));
     $this->insert('event', array('user_id' => $userId, 'place' => 'Francia', 'start' => new CDbExpression('NOW() + INTERVAL 3 DAY'), 'end' => new CDbExpression('NOW() + INTERVAL 7 DAY'), 'comment' => 'I want romance!', 'create_date' => new CDbExpression('NOW()')));
     $this->insert('event', array('user_id' => $userId, 'place' => 'Mexico', 'start' => new CDbExpression('NOW()  + INTERVAL 10 DAY'), 'end' => new CDbExpression('NOW() + INTERVAL 15 DAY'), 'comment' => 'I <3 TEQUILA', 'create_date' => new CDbExpression('NOW()')));
     $this->insert('event', array('user_id' => $userId, 'place' => 'Ukraine', 'start' => new CDbExpression('NOW() - INTERVAL 20 DAY'), 'end' => new CDbExpression('NOW() - INTERVAL 15 DAY'), 'comment' => 'Oh... We want the European Union...', 'create_date' => new CDbExpression('NOW()')));
     $this->insert('event', array('user_id' => $userId, 'place' => 'USA', 'start' => new CDbExpression('NOW()'), 'end' => new CDbExpression('NOW() + INTERVAL 10 DAY'), 'comment' => 'O say, can you see, by the dawn’s early light...', 'create_date' => new CDbExpression('NOW()')));
     $this->insert('event', array('user_id' => $userId, 'place' => 'Russia', 'start' => new CDbExpression('NOW() - INTERVAL 7 DAY'), 'end' => new CDbExpression('NOW() - INTERVAL 3 DAY'), 'comment' => 'I would drink vodka with a bear on unicycle', 'create_date' => new CDbExpression('NOW()')));
 }
开发者ID:Bodya91,项目名称:yii-rest,代码行数:20,代码来源:m120328_085408_base_db.php

示例5: beforeSave

 protected function beforeSave()
 {
     if (parent::beforeSave()) {
         if ($this->isNewRecord) {
             if (UserIdentity::isCrypted($this->password)) {
                 $this->password = UserIdentity::crypt($this->password);
             }
         }
         return true;
     }
     return false;
 }
开发者ID:blindest,项目名称:Yii-CMS-2.0,代码行数:12,代码来源:User.php


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