public function signupAction() { $users = new Application_Model_DbTable_Users(); $form = new Application_Form_RegistrationForm(); $this->view->form = $form; if ($this->getRequest()->isPost()) { $formData = $this->_request->getPost(); if ($form->isValid($formData)) { if ($formData['password'] != $formData['password2']) { $this->view->errorMsg = "Password and Confirm Password must match."; $this->render('signup'); return; } unset($formData['password2']); unset($formData['register']); $users->insert($formData); $this->_redirect('auth/login'); } } }
public function saveuserAction() { $ganID = $this->_request->getParam('g'); $request = $this->getRequest(); $user_data = $request->getPost(); $users_DB = new Application_Model_DbTable_Users(); $email = trim($user_data['email']); $password = trim($user_data['password']); if (!strlen($email)) { $this->msger->addMessage('<div class="alert alert-danger text-center" role="alert"><button type="button" class="close" data-dismiss="alert">×</button>' . $this->lang->_('REQUIRED_EMAIL') . '</div>'); $this->_redirect('/admin/adduser/g/' . $ganID); } if (!strlen($password)) { $this->msger->addMessage('<div class="alert alert-danger text-center" role="alert"><button type="button" class="close" data-dismiss="alert">×</button>' . $this->lang->_('REQUIRED_PASSWORD') . '</div>'); $this->_redirect('/admin/adduser/g/' . $ganID); } else { if (strlen($password) < 4) { $this->msger->addMessage('<div class="alert alert-danger text-center" role="alert"><button type="button" class="close" data-dismiss="alert">×</button>' . $this->lang->_('PASSWORD_TOO_SHORT') . '</div>'); $this->_redirect('/admin/adduser/g/' . $ganID); } } if ($users_DB->isExist($email)) { $this->msger->addMessage('<div class="alert alert-danger text-center" role="alert"><button type="button" class="close" data-dismiss="alert">×</button>' . $this->lang->_('EMAIL_EXISTS') . '</div>'); $this->_redirect('/admin/adduser/g/' . $ganID); } $validator = new Zend_Validate_EmailAddress(); if (!$validator->isValid($email)) { $this->msger->addMessage('<div class="alert alert-danger text-center" role="alert"><button type="button" class="close" data-dismiss="alert">×</button>' . $this->lang->_('INVALID_EMAIL') . '</div>'); $this->_redirect('/admin/adduser/g/' . $ganID); } $roles_DB = new Application_Model_DbTable_Roles(); $roleID = $roles_DB->getRoleID($user_data['isAdmin'] ? "admin" : "user"); $hashed_password = crypt($user_data['password']); //the salt is automatically generated $new_user = array('email' => $user_data['email'], 'password' => $hashed_password, 'ganID' => intval($ganID), 'roleID' => $roleID); try { $user_id = $users_DB->insert($new_user); } catch (Exception $ex) { die(json_encode(array('status' => 'danger', 'msg' => $ex->getMessage()))); } $this->_redirect("/admin/editgan/g/" . $ganID); }
private function newClient($fName, $emailAdd) { $userOBJ = new Application_Model_DbTable_Users(); $upass = substr(md5(date('Y-m-d H:i:s')), 0, 8); $userID = $userOBJ->insert(array("fullName" => $fName, "email" => $emailAdd, "level" => "client", "password" => md5($upass), "dateCreated" => date('Y-m-d H:i:s'))); $mail = new Zend_Mail(); $mail->setFrom("*****@*****.**"); $mail->addTo($emailAdd); $mail->setSubject("Confidential: Access details from Okapi "); $emailBody = "\n\t\t\nDear Client,\n\nOkapi Project Preview System \n\nIn order to serve you better with your projects, we have created a Project Viewing System that you can access for collaboration. Please find below your login credentials to access the System.\n\nLogin Credentials:\n\nWeb Address: http://www.dev45.net\n\nRegistered E-Mail: " . $emailAdd . "\n\nPassword : "******"\n(You can choose a new password when you login) \n\nIf you have any questions please email info@dev45.net\n\n\nRegards,\nThe Okapi Development Team.\n\t\t"; $mail->setBodyText($emailBody); $mail->send(); return $userID; }