public function login($username, $password, $code) { $userverify = new UserVerify(); $flag1 = $userverify->verifyUserName($username); $flag2 = $userverify->verifyPasswd($password); $flag3 = $userverify->verifyCode($code); if ($flag1 && $flag2 && $flag3) { return true; } else { return false; } }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = UserVerify::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, Yii::t('phrase', 'The requested page does not exist.')); } return $model; }
/** * After save attributes */ protected function afterSave() { parent::afterSave(); $controller = strtolower(Yii::app()->controller->id); $currentAction = strtolower(Yii::app()->controller->id . '/' . Yii::app()->controller->action->id); // Generate Verification Code if ($this->verified == 0) { $verify = new UserVerify(); $verify->user_id = $this->user_id; $verify->save(); } if ($this->isNewRecord) { $setting = OmmuSettings::model()->findByPk(1, array('select' => 'site_type, signup_welcome, signup_adminemail')); if ($setting->site_type == 1) { $invite = UserInviteQueue::model()->findByAttributes(array('email' => strtolower($this->email)), array('select' => 'queue_id, member_id, reference_id')); if ($invite != null && $invite->member_id == 0) { $invite->member_id = $this->user_id; if ($this->referenceId != '') { $invite->reference_id = $this->referenceId; } $invite->update(); } } // Send Welcome Email if ($setting->signup_welcome == 1) { $welcome_search = array('{$baseURL}', '{$index}', '{$displayname}'); $welcome_replace = array(Utility::getProtocol() . '://' . Yii::app()->request->serverName . Yii::app()->request->baseUrl, Utility::getProtocol() . '://' . Yii::app()->request->serverName . Yii::app()->createUrl('site/index'), $this->displayname); $welcome_template = 'user_welcome'; $welcome_title = 'Welcome to SSO-GTP by BPAD Yogyakarta'; $welcome_message = file_get_contents(YiiBase::getPathOfAlias('webroot.externals.users.template') . '/' . $welcome_template . '.php'); $welcome_ireplace = str_ireplace($welcome_search, $welcome_replace, $welcome_message); SupportMailSetting::sendEmail($this->email, $this->displayname, $welcome_title, $welcome_ireplace, 1); } // Send Account Information $account_search = array('{$baseURL}', '{$login}', '{$displayname}', '{$email}', '{$password}'); $account_replace = array(Utility::getProtocol() . '://' . Yii::app()->request->serverName . Yii::app()->request->baseUrl, Utility::getProtocol() . '://' . Yii::app()->request->serverName . Yii::app()->createUrl('site/login'), $this->displayname, $this->email, $this->newPassword); $account_template = 'user_welcome_account'; $account_title = 'SSO-GTP Account (' . $this->displayname . ')'; $account_message = file_get_contents(YiiBase::getPathOfAlias('webroot.externals.users.template') . '/' . $account_template . '.php'); $account_ireplace = str_ireplace($account_search, $account_replace, $account_message); SupportMailSetting::sendEmail($this->email, $this->displayname, $account_title, $account_ireplace, 1); // Send New Account to Email Administrator if ($setting->signup_adminemail == 1) { SupportMailSetting::sendEmail($this->email, $this->displayname, 'New Member', 'informasi member terbaru', 0); } } else { // Send Account Information //if($this->enabled == 1) {} if ($controller == 'password') { $account_search = array('{$baseURL}', '{$login}', '{$displayname}', '{$email}', '{$password}'); $account_replace = array(Utility::getProtocol() . '://' . Yii::app()->request->serverName . Yii::app()->request->baseUrl, Utility::getProtocol() . '://' . Yii::app()->request->serverName . Yii::app()->createUrl('site/login'), $this->displayname, $this->email, $this->newPassword); $account_template = 'user_forgot_new_password'; $account_title = 'Your password changed'; $account_message = file_get_contents(YiiBase::getPathOfAlias('webroot.externals.users.template') . '/' . $account_template . '.php'); $account_ireplace = str_ireplace($account_search, $account_replace, $account_message); SupportMailSetting::sendEmail($this->email, $this->displayname, $account_title, $account_ireplace, 1); } if ($controller == 'verify') { SupportMailSetting::sendEmail($this->email, $this->displayname, 'Verify Email Success', 'Verify Email Success', 1); } } }
/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * * @param integer $id * the ID of the model to be updated */ public function actionUpdate($id) { $model = $this->loadModel($id); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); $request = Yii::app()->request; $formData = $request->getPost(get_class($model), false); /* TODO * Display a lint to s3 URL * $s3_dirname = sprintf('userid_%s', $model->id); $s3 = new S3(Yii::app()->params['s3d']['access_key'], Yii::app()->params['s3d']['secret_key']); $s3url = $s3->getBucketLocation('mbtx'); */ $s3url = '#'; if ($formData) { $model->attributes = $formData; if (array_key_exists('save', $formData)) { if ($model->save()) { $this->redirect(array('index')); } } elseif (array_key_exists('verify', $formData)) { if ($model->verify) { $model->verify->delete(); } else { $newv = new UserVerify(); $newv->id_user = $model->id; if (!$newv->save()) { Yii::app()->user->setFlash('error', Yii::t('translation', 'Unable to verify user')); } } $this->redirect(array('index')); } elseif (array_key_exists('activate', $formData)) { if ($model->activation_time) { $model->activation_time = 0; } else { $model->activation_time = time(); } if ($model->save()) { $this->redirect(array('index')); } } } $this->render('update', compact('model', 's3url')); }
require path . 'databases/DbOpration.php'; require path . 'common/smarty.php'; require path . 'common/UserVerify.php'; require "vendor/autoload.php"; use Monolog\Logger; use Monolog\Handler\StreamHandler; /** * 开始日志记录 */ $log = new Logger(); $log->pushHandler(new StreamHandler(path . 'logs/two.log', Logger::WARNING)); /** * 是否开启错误信息输出提示 */ //ini_set("display_errors", "On"); //error_reporting(E_ALL | E_STRICT); echo 'database路径:' . path . "<br/>"; $dbo = new DbOpration(); $c1 = $dbo->createTable(); //$c1 = $dbo->deleteTable("table1"); $log->addWarning("log dataBase"); //$c1 = $dbo->testOutput(); $verify_passwd = new UserVerify(); $vp = $verify_passwd->verifyPasswd(); if (!$c1) { $smarty->assign("create", "create table failed."); $smarty->display("create.tpl"); } else { $smarty->assign("create", 'create table finished.'); $smarty->display("create.tpl"); }