public function verifyAction($code) { if ($code) { $results = VerifyEmail::FindFirst("verifyCode = '" . $code . "'"); if (!isset($results->cid)) { return $this->response->redirect("index/index"); } $form = new RegisterForm(); if (isset($results) && $results != '') { if ($results->active == 'Y') { if (md5($results->time . '+' . $results->email) == $code) { $this->view->form = $form; Tag::setDefault('password', null); Tag::setDefault('cid', $results->cid); Tag::setDefault('email', $results->email); $this->view->setVar("email", $results->email); } else { $this->flash->error('邮箱验证错误!'); $this->response->redirect("account/index"); } } else { $this->flash->error('邮箱已经验证通过,请登录!'); $this->response->redirect("account/index"); } } else { $this->flash->error('验证码已过期!'); $this->response->redirect("index/index"); } } else { $this->response->redirect("index/index"); } }
public function registerAction() { if ($this->request->isPost()) { $iscustomer = $this->request->getPost('iscustomer'); $email = $this->request->getPost('email'); $username = $this->request->getPost('username'); $password = $this->request->getPost('password'); $name = $this->request->getPost('name'); $user = new Users(); $user->iscustomer = $iscustomer; $user->username = trim($username); $user->name = trim($name); $user->password = sha1($password); $user->email = trim($email); $user->created_at = new Phalcon\Db\RawValue('now()'); $user->did = $this->request->getPost('did'); $user->active = 'Y'; if ($user->save() == false) { foreach ($user->getMessages() as $message) { $this->flash->error((string) $message); return $this->forward('register/cregister'); } } else { $verifyEmail = VerifyEmail::FindFirst("email = '" . $email . "'"); $verifyEmail->active = 'N'; $verifyEmail->save(); $this->tag->setDefault('email', ' '); $this->tag->setDefault('password', ''); $this->flash->success('注册成功,登录即可进入系统!'); return $this->forward('session/index'); } } }