當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。