示例#1
0
 public function actionRegister()
 {
     $model = new RegisterForm();
     if (Yii::app()->request->isPostRequest) {
         $model->attributes = $_POST['RegisterForm'];
         if ($model->validate()) {
             print "Зарегистрирован успешно";
         }
     }
     $this->render("register", array("model" => $model));
 }
示例#2
0
 public function actionIndex()
 {
     if (!config('register.allow')) {
         throw new CHttpException(404, Yii::t('main', 'Регистрация отключена.'));
     }
     $formModel = new RegisterForm();
     if (!$formModel->gs_list) {
         throw new CHttpException(404, Yii::t('main', 'Регистрация невозможна из за отсутствия серверов.'));
     }
     if (isset($_POST['RegisterForm'])) {
         $formModel->setAttributes($_POST['RegisterForm']);
         if ($formModel->validate()) {
             $formModel->registerAccount();
             $this->refresh();
         }
     }
     $this->render('//register', array('model' => $formModel));
 }
 /**
  * Register action
  */
 public function actionindex()
 {
     $model = new RegisterForm();
     if (isset($_POST['RegisterForm'])) {
         $model->attributes = $_POST['RegisterForm'];
         if ($model->validate()) {
             // Save the member and redirect
             $user = new Members();
             $user->scenario = 'register';
             $user->role = 'member';
             $user->attributes = $_POST['RegisterForm'];
             $user->save();
             // Redirect
             Yii::app()->user->setFlash('success', Yii::t('register', 'Registration Completed. Please sign in.'));
             $this->redirect('login/index');
         }
     }
     $this->render('index', array('model' => $model));
 }
 /**
  * Creates a new user account.
  */
 public function actionRegister()
 {
     // TRUE if multiples accounts can be created
     if (!Yii::app()->params['multiplesAccounts']) {
         if (AppTools::masterAdmin()) {
             Yii::app()->user->loginRequired();
             Yii::app()->end();
         }
     }
     $register = new RegisterForm();
     // RegisterForm was sent via POST
     if (isset($_POST['RegisterForm'])) {
         // Get attributes from POST to RegisterForm object model
         $register->attributes = $_POST['RegisterForm'];
         // validate if register has all fields required
         if ($register->validate()) {
             // create new user and account, then redirect to signsucess
             if ($register->create()) {
                 if (Yii::app()->params['multiplesAccounts']) {
                     $this->redirect(Yii::app()->controller->createUrl("site/signsucess"));
                 } else {
                     $this->redirect(Yii::app()->controller->createUrl("site/index"));
                 }
             }
         }
     }
     // output register view
     $this->layout = "login";
     $this->render('register', array('model' => $register));
 }
 public function actionRegister()
 {
     $model = new RegisterForm();
     $arrModels = array('model' => $model);
     if (isset($_POST['RegisterForm'])) {
         $model->attributes = $_POST['RegisterForm'];
         if ($model->validate()) {
             $account = new Account();
             $account->attributes = $_POST['RegisterForm'];
             if ($account->save()) {
                 Yii::app()->user->setFlash('register', Yii::t('flexiblearn', 'Thank you for your registration. Please log in to the system with the new one account.'));
                 $this->refresh();
             }
             $arrModels['account'] = $account;
         } else {
             $model->password = '';
             $model->password_repeat = '';
         }
     }
     $this->render('register', $arrModels);
 }
示例#6
0
 public function actionRegister()
 {
     $session = Yii::app()->session;
     $step = $session->get('registerStep', 1);
     $userStep = $this->iGet('step', 1);
     if (!Yii::app()->user->isGuest && $step !== 3) {
         $this->redirect(Yii::app()->homeUrl);
     }
     if ($userStep < $step) {
         $step = min($userStep, 1);
         Yii::app()->session->remove(RegisterForm::REGISTER_WCAID);
     }
     $model = new RegisterForm('step' . $step);
     $model->step = $step;
     $model->loadData();
     // collect user input data
     if (isset($_POST['RegisterForm'])) {
         $model->attributes = $_POST['RegisterForm'];
         // validate user input and redirect to the previous page if valid
         if ($model->validate()) {
             $session->add('registerStep', ++$step);
             if ($model->isLastStep()) {
                 if (!$model->register()) {
                     throw new CHttpException(500, Yii::t('common', 'Something goes wrong'));
                 }
             }
             $this->redirect(array('/site/register', 'step' => $step));
         }
         if (ctype_digit($model->birthday)) {
             $model->birthday = date($model::$dateFormat, $model->birthday);
         }
     }
     $this->pageTitle = array('Register');
     $model->verifyCode = '';
     $this->title = 'Register';
     $this->render('register' . $step, array('model' => $model, 'step' => $step));
 }
 /**
  * finish install applcation
  * redirect user to admin panel or home site.
  *
  * @return void
  */
 public function actionStep4()
 {
     //redirect previous step
     if (Yii::app()->session->contains('aemail') === false && Yii::app()->session->contains('password') === false) {
         $this->redirect(array('step3'));
     }
     $model = new RegisterForm();
     if (isset($_POST['RegisterForm'])) {
         $model->attributes = $_POST['RegisterForm'];
         if ($model->validate() === true) {
             //post to www.open-school.org/register
             // create a new cURL resource
             $ch = curl_init();
             $data = http_build_query(CMap::mergeArray($model->attributes, array('ip' => gethostbyname($_SERVER['SERVER_NAME']), 'domain' => Yii::app()->request->hostInfo . Yii::app()->request->baseUrl, 'key' => Yii::app()->session['key'])), null, '&');
             // set URL and other appropriate options
             $options = array(CURLOPT_URL => 'http://licence-server.open-school.org/register.php', CURLOPT_HEADER => false, CURLOPT_POST => true, CURLOPT_POSTFIELDS => $data, CURLOPT_RETURNTRANSFER => true);
             curl_setopt_array($ch, $options);
             $content = curl_exec($ch);
             $content = trim($content, '()');
             $result = CJSON::decode($content, true);
             curl_close($ch);
             $this->initDbConnection();
             $posts_1 = Configurations::model()->findByAttributes(array('id' => 1));
             $posts_1->config_value = $_POST['RegisterForm']['schoolname'];
             $posts_1->save();
             $posts_2 = Configurations::model()->findByAttributes(array('id' => 2));
             $posts_2->config_value = $_POST['RegisterForm']['address'];
             $posts_2->save();
             $this->redirect(array('step5'));
         }
     }
     //Check
     if (isset(Yii::app()->session['key']) and isset(Yii::app()->session['email'])) {
         $key_info['key'] = Yii::app()->session['key'];
         Yii::app()->session->remove('key');
         //Remove
         $key_info['email'] = Yii::app()->session['email'];
         Yii::app()->session->remove('email');
         //Remove
         $serverurl = "http://licence-server.open-school.org/server.php";
         Yii::app()->session['key'] = $key_info['key'];
         Yii::app()->session['email'] = $key_info['email'];
         $this->render('step5', array('model' => $model));
     } else {
         //session expired or direct link
         $this->redirect(array('index'));
     }
 }
示例#8
0
 /**
  * Registration page
  *
  **/
 public function actionRegister()
 {
     $this->setPageTitle(Yii::t('ciims.controllers.Site', '{{app_name}} | {{label}}', array('{{app_name}}' => Cii::getConfig('name', Yii::app()->name), '{{label}}' => Yii::t('ciims.controllers.Site', 'Sign Up'))));
     $this->layout = '//layouts/main';
     $model = new RegisterForm();
     $user = new Users();
     $error = '';
     if (isset($_POST) && !empty($_POST)) {
         $model->attributes = $_POST['RegisterForm'];
         if ($model->validate()) {
             if (!function_exists('password_hash')) {
                 require_once YiiBase::getPathOfAlias('ext.bcrypt.bcrypt') . '.php';
             }
             // Bcrypt the initial password instead of just using the basic hashing mechanism
             $hash = Users::model()->encryptHash(Cii::get($_POST['RegisterForm'], 'email'), Cii::get($_POST['RegisterForm'], 'password'), Yii::app()->params['encryptionKey']);
             $cost = Cii::getBcryptCost();
             $password = password_hash($hash, PASSWORD_BCRYPT, array('cost' => $cost));
             $user->attributes = array('email' => Cii::get($_POST['RegisterForm'], 'email'), 'password' => $password, 'firstName' => NULL, 'lastName' => NULL, 'displayName' => Cii::get($_POST['RegisterForm'], 'displayName'), 'user_role' => 1, 'status' => Users::INACTIVE);
             try {
                 if ($user->save()) {
                     $hash = mb_strimwidth(hash("sha256", md5(time() . md5(hash("sha512", time())))), 0, 16);
                     $meta = new UserMetadata();
                     $meta->user_id = $user->id;
                     $meta->key = 'activationKey';
                     $meta->value = $hash;
                     $meta->save();
                     // Send the registration email
                     $this->sendEmail($user, Yii::t('ciims.email', 'Activate Your Account'), '//email/register', array('user' => $user, 'hash' => $hash), true, true);
                     $this->redirect($this->createUrl('/register-success'));
                     return;
                 }
             } catch (CDbException $e) {
                 $model->addError(null, Yii::t('ciims.controllers.Site', 'The email address has already been associated to an account. Do you want to login instead?'));
             }
         }
     }
     $this->render('register', array('model' => $model, 'error' => $error, 'user' => $user));
 }
 /**
  * finish install applcation
  * redirect user to admin panel or home site.
  *
  * @return void
  */
 public function actionStep4()
 {
     //redirect previous step
     if (Yii::app()->session->contains('aemail') === false && Yii::app()->session->contains('password') === false) {
         $this->redirect(array('step3'));
     }
     $model = new RegisterForm();
     if (isset($_POST['RegisterForm'])) {
         $model->attributes = $_POST['RegisterForm'];
         if ($model->validate() === true) {
             //post to www.open-school.org/register
             // create a new cURL resource
             // $ch = curl_init();
             //$data = http_build_query(CMap::mergeArray($model->attributes, array('ip'=>gethostbyname($_SERVER['SERVER_NAME']),'domain'=>Yii::app()->request->hostInfo.Yii::app()->request->baseUrl,'key'=>Yii::app()->session['key'])), null, '&');
             // set URL and other appropriate options
             //         $options = array(
             // CURLOPT_URL => 'http://licence-server.open-school.org/register.php',
             //             CURLOPT_HEADER => false,
             //             CURLOPT_POST => true,
             //             CURLOPT_POSTFIELDS => $data,
             //             CURLOPT_RETURNTRANSFER => true,
             //         );
             //curl_setopt_array($ch, $options);
             //$content = curl_exec($ch);
             //$content=trim($content,'()');
             //$result = CJSON::decode($content, true);
             //curl_close($ch);
             //                if (is_array($result) && isset($result['ReturnedData']) && $result['ReturnedData'] === 'OK') {
             //create Settings.php
             /*Yii::setPathOfAlias('Cms', Yii::getPathOfAlias('application.modules.Cms'));
                                 Yii::setPathOfAlias('User', Yii::getPathOfAlias('application.modules.User'));
                                 Yii::setPathOfAlias('Category', Yii::getPathOfAlias('application.modules.Category'));
                                 Yii::setPathOfAlias('Page', Yii::getPathOfAlias('application.modules.Page'));
                                 Yii::setPathOfAlias('News', Yii::getPathOfAlias('application.modules.News'));
                                 Yii::setPathOfAlias('Statistics', Yii::getPathOfAlias('application.modules.Statistics'));
                                 Yii::setPathOfAlias('Messaging', Yii::getPathOfAlias('application.modules.Messaging'));
                                 Yii::setPathOfAlias('Support', Yii::getPathOfAlias('application.modules.Support'));
                                 
                                 $this->initDbConnection();
                                 //Generate module settings
             
                                 //Modify this array for modules in this package
                                 $modules = array('Cms','User','News','Statistics','Messaging','Support','Gallery','Statistics');
             
                                 foreach($modules as $module)
                                     //SettingsService::db2php(array('Module' => $module));
                                     Cms::rawService('Cms/Settings/db2php', array('Module' => $module));
             
                                 //Cache pages and categories
                                 Cms::rawService('Cms/Page/cache',array());
                                 Cms::rawService('Cms/Category/cache',array());
             
                                 //Permission
                                 Cms::rawService('Cms/Permission/createAuthItems',array('cleanup' => 1));*/
             //update .htaccess
             $this->redirect(array('step5'));
             //                }
         }
     }
     //Check
     if (isset(Yii::app()->session['key']) and isset(Yii::app()->session['email'])) {
         $key_info['key'] = Yii::app()->session['key'];
         Yii::app()->session->remove('key');
         //Remove
         $key_info['email'] = Yii::app()->session['email'];
         Yii::app()->session->remove('email');
         //Remove
         // $serverurl = "http://licence-server.open-school.org/server.php";
         //$ch = curl_init ($serverurl);
         //curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
         //curl_setopt ($ch, CURLOPT_POST, true);
         //curl_setopt ($ch, CURLOPT_POSTFIELDS, $key_info);
         // $result = curl_exec ($ch);
         // $result = json_decode($result, true);
         // if($result['valid'] == 'true')
         if (1) {
             Yii::app()->session['key'] = $key_info['key'];
             Yii::app()->session['email'] = $key_info['email'];
             $this->render('step5', array('model' => $model));
         } else {
             //session contains invalid key
             //die("Invalid Key!");
             echo 'Invalid Key';
             $this->redirect(array('index'));
         }
     } else {
         //session expired or direct link
         $this->redirect(array('index'));
     }
 }
示例#10
0
 public function actionRegister()
 {
     if (isset(Yii::app()->user->roles)) {
         $this->render('return', array('returnurl' => Yii::app()->user->returnUrl));
     } else {
         $model = new RegisterForm();
         if (isset($_POST['RegisterForm'])) {
             // collect user input data
             $model->attributes = $_POST['RegisterForm'];
             //if the input is valid
             if ($model->validate()) {
                 $newuser = new User();
                 $newuser->name = $model->username;
                 $newuser->password = $model->password;
                 $newuser->auth = 1;
                 //update the database
                 if ($newuser->save()) {
                     $login = new LoginForm();
                     $login->attributes = $_POST['RegisterForm'];
                     // validate user input and redirect to the previous page if valid
                     if ($login->validate() && $login->login()) {
                         $this->redirect(Yii::app()->homeUrl);
                     } else {
                         print_r($login->getErrors());
                         exit;
                     }
                 } else {
                     print_r($newuser->getErrors());
                     exit;
                 }
             } else {
                 print_r($model->getErrors());
                 exit;
             }
             // validate user input and redirect to the previous page if valid
         }
         // display the login form
         $this->render('register', array('model' => $model));
     }
 }
示例#11
0
 public function actionRegister()
 {
     $model = new RegisterForm();
     $processOutput = true;
     $isMobileClient = false;
     // collect user input data
     if (isset($_POST['RegisterForm'])) {
         $isMobileClient = false;
         if (isset($_REQUEST['client']) && $_REQUEST['client'] == 'mobile') {
             $isMobileClient = true;
         }
         $model->attributes = $_POST['RegisterForm'];
         // validate user input and if ok return json data and end application.
         if ($model->validate()) {
             $time = date('Y-m-d h:i:s');
             $userCandidates = new UserCandidates();
             $userCandidates->email = $model->email;
             $userCandidates->realname = $model->name;
             $userCandidates->password = md5($model->password);
             $userCandidates->time = $time;
             if ($userCandidates->save()) {
                 $key = md5($model->email . $time);
                 $message = 'Hi ' . $model->name . ',<br/> <a href="http://' . Yii::app()->request->getServerName() . $this->createUrl('site/activate', array('email' => $model->email, 'key' => $key)) . '">' . 'Click here to register to traceper</a> <br/>';
                 $message .= '<br/> Your Password is :' . $model->password;
                 $message .= '<br/> The Traceper Team';
                 $headers = 'MIME-Version: 1.0' . "\r\n";
                 $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
                 $headers .= 'From: ' . Yii::app()->params->contactEmail . '' . "\r\n";
                 //echo $message;
                 mail($model->email, "Traceper Activation", $message, $headers);
                 echo CJSON::encode(array("result" => "1"));
             } else {
                 echo CJSON::encode(array("result" => "Unknown error"));
             }
             Yii::app()->end();
         }
         if (Yii::app()->request->isAjaxRequest) {
             $processOutput = false;
         }
     }
     if ($isMobileClient == true) {
         if ($model->getError('password') != null) {
             $result = $model->getError('password');
         } else {
             if ($model->getError('email') != null) {
                 $result = $model->getError('email');
             } else {
                 if ($model->getError('passwordAgain') != null) {
                     $result = $model->getError('passwordAgain');
                 } else {
                     if ($model->getError('passwordAgain') != null) {
                         $result = $model->getError('passwordAgain');
                     }
                 }
             }
         }
         echo CJSON::encode(array("result" => $result));
         Yii::app()->end();
     } else {
         Yii::app()->clientScript->scriptMap['jquery.js'] = false;
         Yii::app()->clientScript->scriptMap['jquery-ui.min.js'] = false;
         $this->renderPartial('register', array('model' => $model), false, $processOutput);
     }
 }
示例#12
0
文件: page.php 项目: biniweb/form
<?php

require __DIR__ . '/../vendor/autoload.php';
require __DIR__ . '/RegisterForm.php';
$form = new RegisterForm();
if (!$form->validate()) {
    echo $form->render();
} else {
    $form->runFollowUps();
}
示例#13
0
 public function actionEditStudentManagement()
 {
     $form = new RegisterForm();
     if (isset($_POST['id_student']) && $_POST['id_student']) {
         $student = RsStudent::model()->findByPk($_POST['id_student']);
         if ($student) {
             $form->id = $student->id;
             $form->reg_code = $student->reg_code;
             $form->student_code = $student->student_code;
             $form->reg_code = $student->reg_code;
             $form->first_name = $student->first_name;
             $form->last_name = $student->last_name;
             $form->first_kana = $student->first_kana;
             $form->last_kana = $student->last_kana;
             $form->faculty = $student->faculty;
             $form->professor_code = $student->professor_code;
             $form->email = $student->email;
             $form->password = $student->password;
             $form->repeat_password = $student->password;
             $form->faculty_name = $student->faculty_name;
         }
     } elseif (isset($_POST['action'])) {
         if ($_POST['action'] == 'update') {
             if (isset($_POST['RegisterForm']) && isset($_POST['RegisterForm']['id'])) {
                 $student = RsStudent::model()->findByPk($_POST['RegisterForm']['id']);
                 $form->attributes = $_POST['RegisterForm'];
                 if ($_POST['RegisterForm']['password'] == '' && $_POST['RegisterForm']['repeat_password'] == '' || $_POST['RegisterForm']['password'] == $_POST['RegisterForm']['repeat_password'] && $_POST['RegisterForm']['password'] == $student->password) {
                     $form->password = $student->password;
                     $form->repeat_password = $student->password;
                 } else {
                     $student->password = md5($form->password);
                 }
             }
             if ($form->validate()) {
                 $student->student_code = $form->student_code;
                 $student->first_name = $form->first_name;
                 $student->last_name = $form->last_name;
                 $student->first_kana = $form->first_kana;
                 $student->last_kana = $form->last_kana;
                 $student->faculty = $form->faculty;
                 $student->professor_code = $form->professor_code;
                 $student->email = $form->email;
                 $student->faculty_name = $form->faculty_name;
                 if ($student->save()) {
                     Yii::app()->user->setFlash('success', Yii::t("backend", "受講者情報の更新は完了しました。"));
                 } else {
                     Yii::app()->user->setFlash('success', Yii::t("backend", "受講者情報の更新は失敗しました。"));
                 }
                 return;
             }
         } elseif ($_POST['action'] == 'delete') {
             $id = $_POST['id'];
             if (RsStudent::model()->deleteByPk($id)) {
                 Yii::app()->user->setFlash('success', Yii::t("backend", "受講者情報の削除は完了しました。"));
             } else {
                 Yii::app()->user->setFlash('success', Yii::t("backend", "受講者情報の削除は失敗しました。"));
             }
             return;
         }
     } elseif ($_POST['RegisterForm']) {
     }
     $this->renderPartial('_editStudentManagement', array('model' => $form));
 }