/**
  * indexAction
  *
  * Default registration action
  * 
  * @return void
  */
 public function indexAction()
 {
     $request = $this->getRequest();
     if ($request->isPost() && $this->_form->isValid($request->getPost())) {
         $service = $this->_serviceFactory->get('Registration');
         $user = $service->registerAccount($this->_form->getValues());
         if ($user instanceof \Orm\Entity\User) {
             $this->_redirect('/tickets/');
         } else {
             throw new \Exception('Failed to register a valid user account');
         }
     }
     $this->view->form = $this->_form;
 }
 public function registerAction()
 {
     // action body
     $request = $this->getRequest();
     $form = new Application_Form_Registration();
     if ($request->isPost()) {
         if ($form->isValid($request->getPost())) {
             $userMapper = new Application_Model_UserMapper();
             $user = new Application_Model_User($form->getValues());
             $id = $userMapper->save($user);
             $user->setId($id);
             $writer = new Zend_Log_Writer_Stream(APPLICATION_PATH . "/../tmp/log.txt");
             $logger = new Zend_Log($writer);
             try {
                 $this->sendConfirmationEmail($user);
                 $logger->log("Email confirmation sent.", Zend_Log::INFO);
             } catch (Exception $e) {
                 // Log error on production
                 $logger->log("Email confirmation failed." . $e->getMessage(), Zend_Log::EMERG);
             }
             $form = null;
             $request->clearParams();
             $this->view->msg = 'An email with a confirmation link has been sent to your email. Please use the link to complete your registration.';
         }
     }
     $this->view->form = $form;
 }
示例#3
0
 public function roAction()
 {
     $this->view->form = $form = new Application_Form_Registration('ro');
     if ($this->_request->isPost()) {
         $formData = $this->_request->getPost();
         if ($form->isValid($formData)) {
             Registration::saveRegistration($form->getValues(), 'ro');
             $this->_redirect('index/rothanks');
         } else {
             $form->populate($formData);
         }
     }
 }
 public function indexAction()
 {
     //$db	= Zend_Db_Table_Abstract::getDefaultAdapter();
     $registerForm = new Application_Form_Registration($_POST);
     if ($this->getRequest()->isPost()) {
         $this->request = $this->getRequest();
         if (isset($_POST['rbutton']) && $registerForm->isValid($_POST)) {
             $db = Zend_Registry::get('dbc');
             $db->query('SET NAMES utf8;');
             /*
                 			$adapter = new Zend_Auth_Adapter_DbTable(
                 					$db,
                 					'users',
                 					'name',
                 					'password'
                 			);
                 	
                 			$adapter->setIdentity($registerForm->getValue('username'));
                 			$adapter->setCredential($registerForm->getValue('passwor2'));
                 	
                 			$result = $adapter->authenticate($adapter);
                 	
                 			if (User nicht vorhanden) {
             */
             $values = $registerForm->getValues();
             if ($registerForm->getValue('password1') != $registerForm->getValue('password2')) {
                 $success = -1;
                 $this->view->success = $success;
                 //$this->redirect('registration');
             } else {
                 $db->query('SET NAMES utf8;');
                 $stmt = $db->prepare('	INSERT INTO `users`(`name`, `password`, `userstate`) 
 											VALUES ("' . mysql_real_escape_string($registerForm->getValue('username')) . '",
 													"' . mysql_real_escape_string($registerForm->getValue('password2')) . '", 92)	
 									');
                 $stmt->execute();
                 $success = 1;
                 $this->view->success = $success;
                 $this->redirect('index');
                 return;
             }
         }
     }
     $this->view->registerForm = $registerForm;
 }
 public function registerAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender();
     $db = Zend_Db_Table::getDefaultAdapter();
     $users = new Application_Model_Users();
     $registerForm = new Application_Form_Registration();
     if ($this->_request->isPost()) {
         foreach ($this->_request->getPost('dataPost') as $dataArray) {
             $name = $dataArray['name'];
             $formDataForValidation["{$name}"] = $dataArray['value'];
         }
         if ($formDataForValidation['driverCheck'] === "1") {
             $carModel = $registerForm->getElement('carModel');
             $carModel->setRequired(true)->addErrorMessage('Required');
             $carMake = $registerForm->getElement('carMake');
             $carMake->setRequired(true)->addErrorMessage('Required');
             $driverLicense = $registerForm->getElement('driverLicense');
             $driverLicense->setRequired(true)->addErrorMessage('Required');
         }
         if ($registerForm->isValid($formDataForValidation)) {
             $userDataInsert = array('id' => null, 'email' => $formDataForValidation['emailRegister'], 'password' => $formDataForValidation['passwordRegister'], 'last_name' => $formDataForValidation['lastName'], 'first_name' => $formDataForValidation['firstName'], 'driver_flag' => $formDataForValidation['driverCheck'], 'telephone' => $formDataForValidation['telephone']);
             try {
                 $db->insert($users->getTableName(), $userDataInsert);
                 $last_id = $users->getAdapter()->lastInsertId();
             } catch (Zend_Exception $e) {
                 $this->redirect('/error/error');
             }
             if ($formDataForValidation['driverCheck']) {
                 //if the user is a driver => need to update driver data
                 $driver = new Application_Model_Driver();
                 $driverDataInsert = array('id' => null, 'user_id' => $last_id, 'make' => $formDataForValidation['carMake'], 'model' => $formDataForValidation['carModel'], 'license' => $formDataForValidation['driverLicense'], 'completed' => 0);
                 try {
                     $db->insert($driver->getTableName(), $driverDataInsert);
                 } catch (Zend_Exception $e) {
                     $this->redirect('/error/error');
                 }
             }
             $this->_helper->json(0);
         } else {
             $errorMessages = $registerForm->getMessages();
             $this->_helper->json($errorMessages);
         }
     }
 }
示例#6
0
 public function forgetpasswordAction()
 {
     $form2 = new Application_Form_Registration();
     $form2->getElement('register')->setLabel('send');
     $form2->removeElement('name');
     $form2->removeElement('password');
     $form2->removeElement('confirmPassword');
     $form2->removeElement('image');
     $form2->removeElement('room_no');
     $form2->removeElement('ext');
     $this->view->form = $form2;
     if ($this->getRequest()->isPost()) {
         if ($form2->isValid($this->getRequest()->getParams())) {
             $email = $this->_request->getParam('email');
             var_dump($email);
             $usermodel = new Application_Model_User();
             if ($userid = $usermodel->checkuserEmail($email)) {
                 $newpassword = substr(hash('sha512', rand()), 0, 8);
                 //////////////////// mail && password ///////////////////////////
                 $smtpoptions = array('auth' => 'login', 'username' => '*****@*****.**', 'password' => 'Marwaspassword', 'ssl' => 'tls', 'port' => 587);
                 $mailtransport = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $smtpoptions);
                 $mail = new Zend_Mail();
                 $mail->addTo($email, 'to..');
                 $mail->setSubject('Hi');
                 $mail->setBodyText('your new password is ' . $newpassword);
                 $mail->setFrom('*****@*****.**', 'Cafee Prohect');
                 //Send it!
                 $sent = true;
                 try {
                     $mail->send($mailtransport);
                 } catch (Exception $e) {
                     $sent = false;
                 }
                 //Do stuff (display error message, log it, redirect user, etc)
                 if ($sent) {
                     if ($usermodel->updateuseremail(md5($newpassword), $userid[0]['id'])) {
                         echo 'Successfully Sent Please Check your Email';
                     } else {
                         echo 'Error in Server';
                     }
                 } else {
                     echo 'Failed Sending to your Email Please Check your Settings';
                 }
             } else {
                 echo 'This Email is not Existed in my Database';
             }
         }
     }
 }