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


PHP Users::validate方法代码示例

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


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

示例1: register

 public function register()
 {
     $user = new Users();
     $user->attributes = $this->attributes;
     $salt = md5(uniqid() . time());
     $user->email = $this->email;
     $user->salt = $salt;
     $user->pass = crypt(trim($this->pass) . $salt);
     if ($user->validate() && $user->save()) {
         if (!Settings::model()->getValue('mail_confirm')) {
             $user->status = 1;
             $user->save();
             return 1;
         }
         Yii::import('ext.YiiMailer.YiiMailer');
         $code = md5(md5($user->pass . $user->email));
         $mail = new YiiMailer();
         $mail->setFrom(Settings::model()->getValue('register'));
         $mail->setTo($user->email);
         $mail->setSubject(Yii::t('register', 'Account activation'));
         $mail->setBody(Yii::t('register', "Hello {nick},<br/><br/>Your activation code: {code}<br/>{link}", array('{nick}' => $user->nick, '{code}' => $code, '{link}' => Yii::app()->createAbsoluteUrl('site/confirm', array('user' => $user->nick, 'code' => $code)))));
         $mail->send();
         return 1;
     }
 }
开发者ID:mrtos,项目名称:OpenNVR,代码行数:25,代码来源:RegForm.php

示例2: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     if (Yii::app()->user->checkAccess('createUsers')) {
         $model = new Users();
         $address = new Address();
         if (isset($_POST['Users']) && isset($_POST['Address'])) {
             $model->attributes = $_POST['Users'];
             $address->attributes = $_POST['Address'];
             $model->account_id = Users::model()->findByPk(Yii::app()->user->id)->account_id;
             $valid = $address->validate();
             $valid = $model->validate() && $valid;
             if ($valid) {
                 $address->save(false);
                 $model->address_id = $address->primaryKey;
                 $passBeforeMD5 = $model->user_password;
                 $model->user_password = md5($model->user_password);
                 if ($model->save(false)) {
                     // Guardar log
                     $attributes = array('log_date' => date("Y-m-d G:i:s"), 'log_activity' => 'UserCreated', 'log_resourceid' => $model->primaryKey, 'log_type' => 'created', 'user_id' => Yii::app()->user->id, 'module_id' => Yii::app()->controller->id);
                     Logs::model()->saveLog($attributes);
                     $str = $this->renderPartial('//templates/users/invitation', array('userCreateInvitation' => Yii::app()->user->CompleteName, 'user_email' => $model->user_email, 'user_password' => $passBeforeMD5, 'userInvited' => $model->CompleteName, 'applicationName' => Yii::app()->name, 'applicationUrl' => "http://" . $_SERVER['SERVER_NAME'] . Yii::app()->request->baseUrl), true);
                     $subject = Yii::t('email', 'UserInvitation');
                     Yii::import('application.extensions.phpMailer.yiiPhpMailer');
                     $mailer = new yiiPhpMailer();
                     //$mailer->Ready($subject, $str, array('email'=>$model->user_email, 'name'=>$model->CompleteName));
                     $mailer->pushMail($subject, $str, array('email' => $model->user_email, 'name' => $model->CompleteName), Emails::PRIORITY_NORMAL);
                     $this->redirect(array('view', 'id' => $model->user_id));
                 }
             }
         }
         $this->render('create', array('model' => $model, 'allowEdit' => true, 'userManager' => true, 'address' => $address));
     } else {
         throw new CHttpException(403, Yii::t('site', '403_Error'));
     }
 }
开发者ID:lanzelotik,项目名称:celestic-community,代码行数:39,代码来源:UsersController.php

示例3: doValidate

 /**
  * This function performs the validation work for complex object models.
  *
  * In addition to checking the current object, all related objects will
  * also be validated.  If all pass then <code>true</code> is returned; otherwise
  * an aggreagated array of ValidationFailed objects will be returned.
  *
  * @param      array $columns Array of column names to validate.
  * @return     mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
  */
 protected function doValidate($columns = null)
 {
     if (!$this->alreadyInValidation) {
         $this->alreadyInValidation = true;
         $retval = null;
         $failureMap = array();
         // We call the validate method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aUsers !== null) {
             if (!$this->aUsers->validate($columns)) {
                 $failureMap = array_merge($failureMap, $this->aUsers->getValidationFailures());
             }
         }
         if ($this->aUserBikes !== null) {
             if (!$this->aUserBikes->validate($columns)) {
                 $failureMap = array_merge($failureMap, $this->aUserBikes->getValidationFailures());
             }
         }
         if (($retval = UserEquipementPeer::doValidate($this, $columns)) !== true) {
             $failureMap = array_merge($failureMap, $retval);
         }
         if ($this->collUserStatEquips !== null) {
             foreach ($this->collUserStatEquips as $referrerFK) {
                 if (!$referrerFK->validate($columns)) {
                     $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
                 }
             }
         }
         $this->alreadyInValidation = false;
     }
     return !empty($failureMap) ? $failureMap : true;
 }
开发者ID:broschb,项目名称:cyclebrain,代码行数:44,代码来源:BaseUserEquipement.php

示例4: actionCreateUser

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'index' page.
  */
 public function actionCreateUser()
 {
     Yii::log("actionCreate called", "trace", self::LOG_CAT);
     $cancelLink = $this->createUrl('site/login');
     $model = new Users();
     if (isset($_POST['Users'])) {
         $model->attributes = $_POST['Users'];
         $model->roles = $_POST['Users']['roles'];
         if ($model->validate("insert")) {
             if ($model->save() && $model->saveRoles($model->userId, "create")) {
                 // send the user the email link:
                 $toMailName = $model->userName;
                 $email = $model->email;
                 // construct data and set expiry to 24 hrs
                 $resetEncrypt = base64_encode($email . ",resetTrue," . (strtotime(date("H:i:s")) + 86400));
                 $passwordUrl = "http://" . $_SERVER["HTTP_HOST"] . Yii::app()->request->baseUrl . "/index.php/site/changepassword?data={$resetEncrypt}" . "&redirect_uri=" . $cancelLink;
                 $mail = new TTMailer();
                 $subject = Yii::t('translation', 'User created');
                 $altBody = Yii::t('translation', 'To view the message, please use an HTML compatible email viewer!');
                 $message = Yii::t('translation', 'Dear ') . $toMailName . ',<br /><br />' . Yii::t('translation', 'your user account has been created, please visit ');
                 $message .= '<a href="' . $passwordUrl . '">' . $passwordUrl . '</a>' . Yii::t('translation', ' to activate it and set a new password. ') . '<p></p>' . Yii::t('translation', 'This message was automatically generated.') . '<br />' . Yii::t('translation', ' If you think it was sent incorrectly, ') . Yii::t('translation', 'please contact your administrator.');
                 //if mail is not sent successfully issue appropriate message
                 if (!$mail->ttSendMail($subject, $altBody, $message, $email, $toMailName)) {
                     Yii::log("Error in sending the password to the user", "error", self::LOG_CAT);
                     $msg = Yii::t('translation', "Error in sending the password to the user");
                     return $msg;
                 }
                 Yii::app()->user->setFlash('success', "User successfully created.");
                 $this->redirect(array('users/index'));
             }
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:schrapps,项目名称:risksur,代码行数:38,代码来源:UsersController.php

示例5: save

 /**
  * Logs in the user using the given username and password in the model.
  * @return boolean whether login is successful
  */
 public function save()
 {
     $user = new Users();
     $user->setAttributes($this->attributes);
     $user->setAttribute("password", BaseTool::ENPWD($this->password));
     if ($user->validate() && $user->save()) {
         $accountarray = array('user_id' => Yii::app()->db->getLastInsertID(), 'total' => 0, 'use_money' => 0, 'no_use_money' => 0, 'newworth' => 0);
         $newAccount = new Account();
         $newAccount->setAttributes($accountarray);
         $newAccount->save();
         //发送邮件
         $activecode = BaseTool::getActiveMailCode($this->username);
         $message = MailTemplet::getActiveEmail($this->username, $activecode);
         $mail = Yii::app()->Smtpmail;
         $mail->SetFrom(Yii::app()->params['adminEmail']);
         $mail->Subject = "好帮贷测试邮件";
         $mail->MsgHTML($message);
         $mail->AddAddress($this->email);
         if ($mail->Send()) {
             $user->updateAll(array("regtaken" => $activecode, "regativetime" => time() + 60 * 60), "username=:username", array(":username" => $this->username));
         }
         Yii::import("application.models.form.LoginForm", true);
         $loginform = new LoginForm();
         $loginarray = array('rememberMe' => false, 'username' => $this->username, 'password' => $this->password);
         $loginform->setAttributes($loginarray);
         if ($loginform->validate() && $loginform->login()) {
         }
         return true;
     } else {
         $usererror = $user->errors;
         $this->addError("username", current(current($usererror)));
         return false;
     }
 }
开发者ID:bfyang5130,项目名称:zzl,代码行数:38,代码来源:RegeditForm.php

示例6: actionStep2

 public function actionStep2()
 {
     $model = new Users('step2');
     /*if(isset($_POST['ajax']) && $_POST['ajax']==='users-form') //тут ajax-валидация
     		{
     			$model->setScenario('active');
                 $model->verifyCode = $_POST['Users']['verifyCode'];
     			echo CActiveForm::validate($model);
     			Yii::app()->end();
     		}*/
     if (isset($_POST['Users'])) {
         //print_r($_POST); exit();
         $model->name = $_POST['Users']['name'];
         //$model->login = $_POST['Users']['login'];
         $model->email = $_POST['Users']['email'];
         $model->password = $_POST['Users']['password'];
         $model->member = $_POST['Users']['member'];
         //$model->verifyCode = $_POST['Users']['verifyCode'];
         $model->tos = $_POST['Users']['tos'];
         if ($_POST['Users']['member'] == 0) {
             $model->member_type = 'client';
         }
         //$model->scenario = 'registerwcaptcha';
         if ($model->validate()) {
             // and here is the actual HACKY part
             $model->scenario = 'step2';
             if ($model->save()) {
                 if (!is_dir($_SERVER['DOCUMENT_ROOT'] . '/users/' . $model->id)) {
                     mkdir($_SERVER['DOCUMENT_ROOT'] . '/users/' . $model->id);
                 }
                 $key = '';
                 $key = hash('md5', 'uid=' . $model->id . '&activate=1');
                 $name = '=?UTF-8?B?' . base64_encode($model->name) . '?=';
                 $subject = '=?UTF-8?B?' . base64_encode('Регистрация на НМ') . '?=';
                 $headers = "MIME-Version: 1.0\r\n" . "Content-Type: text/plain; charset=UTF-8";
                 $msg = "Подтвердите регистрацию! Ссылка - <a href='" . $this->createUrl('/register/confirm', array('uid' => $model->id, 'key' => $key)) . "'>подтвердить</a>\n                    <br />Если Ваш браузер не открывает ссылку, скопируйте ее адрес в браузер - " . $this->createUrl('/register/confirm', array('uid' => $model->id, 'key' => $key));
                 //if(mail($model->email,$subject,$msg,$headers)) {
                 if (Users::mailsend($model->email, 'hm164@mail.ua', $subject, $msg)) {
                     Yii::app()->user->setFlash('create', 'На Ваш email отправлено письмо для подтверждения регистрации.');
                     //$this->render('activate',array('model'=>$model));
                     //sleep(100);
                     //$this->redirect(array('/profile/view','id'=>$model->id));
                 } else {
                     throw new CHttpException(500, 'Error send mail().');
                 }
                 $this->render('activate', array('model' => $model));
             }
         } else {
             /*echo "not valid"; 
               echo CActiveForm::validate($model);
               Yii::app()->end();*/
             $this->render('step2', array('model' => $model));
         }
     } else {
         $this->render('step2', array('model' => $model));
     }
 }
开发者ID:schur-maksim,项目名称:happymoments.ua,代码行数:57,代码来源:RegisterController.php

示例7: login

 /**
  * login method
  *
  * Uses the reference {@link User} class to handle
  * user validation.
  *
  * @see User
  * @todo Decide which validate method to user instead of both
  * @access public
  * @param string $user account user name
  * @param string $password account password
  * @return boolean
  */
 public function login($user, $password)
 {
     if (empty($user) || empty($password)) {
         return false;
     } else {
         // Проверяем через два метода валидации. Должны работать оба.
         // Статический метод класса User для валидации аккаунта
         $firstValidation = Users::validate($user, $password);
         // 'волшебный' метод класса User validate<username>($password)
         $userLoginFunction = 'validate' . $user;
         $secondValidation = $this->users->{$userLoginFunction}($password);
         return $firstValidation && $secondValidation;
     }
 }
开发者ID:ralf000,项目名称:PHP4,代码行数:27,代码来源:AuthAccounts.php

示例8: register

 public function register()
 {
     $user = new Users();
     $user->attributes = $this->attributes;
     $salt = md5(uniqid() . time());
     $user->email = $this->email;
     $user->salt = $salt;
     if (Yii::app()->user->permissions == 3) {
         $user->status = $this->rang;
     } else {
         $user->status = 1;
     }
     $user->pass = crypt(trim($this->pass) . $salt);
     if ($user->validate() && $user->save()) {
         return 1;
     }
 }
开发者ID:mrtos,项目名称:OpenNVR,代码行数:17,代码来源:UserForm.php

示例9: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new TransaksiRegistrasi();
     $model_user = new Users();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model,$model_user);
     if (isset($_POST['TransaksiRegistrasi'])) {
         // 	if($model->validate() && $model_user->validate()){
         // 	echo "oke";
         // }else{
         // 	echo "ga oke";
         // }
         // die();
         $model->attributes = $_POST['TransaksiRegistrasi'];
         $model_user->attributes = $_POST['Users'];
         $cek = $model->validate();
         $cek = $model_user->validate() && $cek;
         if ($cek) {
             // if($model->save()){
             $number = '';
             for ($i = 0; $i < 16; $i++) {
                 $number .= rand(0, 9);
             }
             $model->ID_FANBASE = 1;
             $model->NO_SAKTI = $number;
             $model->VAD = '-';
             $model->STATUS_REKONSILIASI = 'N';
             $model->STATUS_RELEASE = 'N';
             $tgl = explode('/', $_POST['TransaksiRegistrasi']['TANGGAL']);
             $model->TANGGAL = $tgl[2] . '-' . $tgl[0] . '-' . $tgl[1];
             // print_r($model); die();
             $model->save(false);
             $model_user->PASSWORD = md5($_POST['Users']['PASSWORD']);
             $model_user->ID_FANBASE = $model->ID_FANBASE;
             $model_user->ID_REGISTRASI = $model->ID_REGISTRASI;
             $model_user->ID_JENIS = 4;
             $model_user->VAS = '-';
             $model_user->STATUS = 'N';
             $model_user->save(false);
             $this->redirect(array('site/login', 'id' => $model->ID_REGISTRASI));
         }
     }
     $this->render('create', array('model' => $model, 'model_user' => $model_user));
 }
开发者ID:eripahle,项目名称:rock20083,代码行数:48,代码来源:TransaksiRegistrasiController.php

示例10: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Users('createSubAdmin');
     if (isset($_POST['Users'])) {
         $model->attributes = $_POST['Users'];
         $model->status = $_POST['Users']['status'];
         if ($model->validate()) {
             $model->temp_password = $model->password_hash;
             $model->created_date = date("Y-m-d H:i:s");
             $model->application_id = BE;
             //save user for back end
             $model->save();
             $model->password_hash = md5($model->password_hash);
             $model->update();
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model, 'actions' => $this->listActionsCanAccess));
 }
开发者ID:jasonhai,项目名称:onehome,代码行数:23,代码来源:ManagesubadminController.php

示例11: actionLogin

 public function actionLogin()
 {
     if (Yii::app()->user->isGuest) {
         $model = new Users('login');
         if (Yii::app()->request->isPostRequest) {
             $user = Yii::app()->request->getParam('Users');
             $model->setAttributes($user);
             $user_identity = new UserIdentity($model->username, md5($model->password));
             if ($model->validate() && $user_identity->authenticate()) {
                 Yii::app()->user->login($user_identity, 60 * 60 * 24 * 7);
                 // sign-in for week
                 $this->redirect($this->createUrl(Yii::app()->user->returnUrl && Yii::app()->user->returnUrl != '/' ? Yii::app()->user->returnUrl : 'site/index'));
             } else {
                 $this->render('login', ['model' => $model, 'error' => $user_identity->errorCode]);
             }
         } else {
             $this->render('login', ['model' => $model]);
         }
     } else {
         throw new CHttpException(403);
     }
 }
开发者ID:sc0rp1d,项目名称:studyschedule,代码行数:22,代码来源:SiteController.php

示例12: registerUserAction

 private function registerUserAction()
 {
     $newuser = new Users();
     $name = $this->getParam('name');
     //se ejecutó la opcion para obtener ususrio y contraseña
     $username = $this->getParam('username');
     $password = $this->getParam('password');
     //se ejecutó la opcion para obtener ususrio y contraseña
     $rpassword = $this->getParam('rpassword');
     $email = $this->getParam('email');
     if ($rpassword == $password) {
         if ($newuser->adduser($name, $username, $password, $email)) {
             $id = $newuser->validate($username, $password);
             $newuser->adduserstats($id);
             $this->dataview['msgerror'] = "Successful sign Up!!";
         } else {
             $this->dataview['msgerror'] = "Couldn't write in Database!!";
         }
     } else {
         $this->dataview['msgerror'] = "Passwords do not match!!";
     }
     $this->registerAction();
 }
开发者ID:eduarguzher,项目名称:BlackJackApp,代码行数:23,代码来源:Application.php

示例13: actionCreate

 public function actionCreate()
 {
     try {
         $model = new Users('create_register');
         if (isset($_POST['Users'])) {
             $model->attributes = $_POST['Users'];
             $model->role_id = ROLE_REGISTER_MEMBER;
             $model->temp_password = $_POST['Users']['password_hash'];
             $model->application_id = FE;
             $model->validate();
             if (!$model->hasErrors()) {
                 $model->scenario = NULL;
                 $model->password_hash = md5($_POST['Users']['password_hash']);
                 $model->save();
                 $this->redirect(array('view', 'id' => $model->id));
             }
         }
         $this->render('create', array('model' => $model, 'actions' => $this->listActionsCanAccess));
     } catch (Exception $e) {
         Yii::log("Exception " . print_r($e, true), 'error');
         throw new CHttpException("Exception " . print_r($e, true));
     }
 }
开发者ID:jasonhai,项目名称:onehome,代码行数:23,代码来源:UsersRegisteredController.php

示例14: renderContent

    public function renderContent()
    {
        // Форма регистрации
        $form = new Users();
        $login = new LoginForm();
        // Проверка если пришли данные из формы
        if (!empty($_POST['User'])) {
            $form->attributes = $_POST['User'];

            // Валидация формы
            if ($form->validate()) {
                if ($form->model()->count('username = :username', array(':username' => strtolower($form->username)))) {
                    $form->addError('username', 'Такое имя пользователя уже зарегистрировано!');
                    $this->render('userauth', array(
                        'form' => $form,
                        'login' => $login
                    ));
                } else {
                    $form->save();
                    Yii::app()->user->setFlash('register', 'Вы подписаны на рассылку новостей');
                }
            } else {
                $this->render('userauth', array(
                    'form' => $form,
                    'login' => $login
                ));
            }
        } else {
            $this->render('userauth', array(
                'form' => $form,
                'login' => $login
            ));
        }


    }
开发者ID:schiz,项目名称:teff,代码行数:36,代码来源:UserAuth.php

示例15: addUser

 public static function addUser($weixinUser)
 {
     #注册新用户
     $newuser = new Users();
     $newuser->setAttribute('username', $weixinUser);
     $newuser->setAttribute('password', 'ooxxooxx');
     $newuser->setAttribute('wangwang', $weixinUser);
     $newuser->setAttribute('privacy', uniqid());
     if ($newuser->validate() && $newuser->save()) {
         $accountarray = array('user_id' => Yii::app()->db->getLastInsertID(), 'total' => 0, 'use_money' => 0, 'no_use_money' => 0, 'newworth' => 0);
         $newAccount = new Account();
         $newAccount->setAttributes($accountarray);
         $newAccount->save();
     }
     $user = Users::model()->find("username=:username", array(":username", $weixinUser));
     return $user;
 }
开发者ID:bfyang5130,项目名称:zzl,代码行数:17,代码来源:WechatCheck.php


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