コード例 #1
0
 public function registerForm($request)
 {
     if (isset($_POST['XSRF'])) {
         if (Kingboard_Form::getXSRFToken() == $_POST['XSRF']) {
             if (!isset($_POST['passwd']) || !isset($_POST['passwd2']) || !isset($_POST['login'])) {
                 $this->_context['registration_failed'] = 'Please fill in all fields';
             } elseif ($_POST['passwd'] != $_POST['passwd2']) {
                 $this->_context['registration_failed'] = 'both Password fields need to have the same value';
             } elseif (!is_null(Kingboard_User::findOne(array('username' => $_POST['login'])))) {
                 $this->_context['registration_failed'] = 'email/login allready in use';
             } elseif (!Kingboard_Form::isEmail($_POST['login'])) {
                 $this->_context['registration_failed'] = 'not a valid email adresse';
             } else {
                 $validationCode = sha1(mktime() . $_POST['login']);
                 $user = new Kingboard_User();
                 $user->username = $_POST['login'];
                 $user->password = $_POST['passwd'];
                 $user->status = Kingboard_User::STATUS_NEW;
                 $user->validationCode = $validationCode;
                 $user->save();
                 $body = King23_Registry::getInstance()->sith->cachedGet('mails/verify_email.html')->render(array('username' => $_POST['login'], 'hostname' => $_SERVER['SERVER_NAME'], 'activationkey' => $validationCode), King23_Registry::getInstance()->sith);
                 mail($_POST['login'], "Kingboard Activation", $body);
                 $this->redirect('/');
             }
         } else {
             $this->_context['registration_failed'] = 'XSRF Token Invalid.';
         }
     }
     $this->render('user/registration.html', $_POST);
 }