function indexAction() { $captcha = new Zend_Captcha_Image(); $vi = new Zend_View(); $base = $vi->baseurl(); if (!$this->_request->isPost()) { $captcha->setTimeout('300')->setWordLen('4')->setHeight('50')->setWidth('320')->setImgDir(APPLICATION_PATH . '/../public_html/captcha/images/')->setImgUrl($base . '/captcha/images/')->setFont(APPLICATION_PATH . '/../public_html/font/AHGBold.ttf'); $captcha->generate(); $this->view->captcha = $captcha->render($this->view); $this->view->captchaID = $captcha->getId(); // Dua chuoi Captcha vao session $captchaSession = new Zend_Session_Namespace('Zend_Form_Captcha_' . $captcha->getId()); $captchaSession->word = $captcha->getWord(); } else { $captchaID = $this->_request->captcha_id; $captchaSession = new Zend_Session_Namespace('Zend_Form_Captcha_' . $captchaID); $captchaIterator = $captchaSession->getIterator(); $captchaWord = $captchaIterator['word']; if ($this->_request->captcha == $captchaWord) { $system = new Default_Model_User(); $exist = new Admin_Model_User(); $user = $this->_request->getParam('username'); $pass1 = $this->_request->getParam('password'); $pass2 = $this->_request->getParam('re_password'); $ex = $exist->list_user_2($user); if ($ex == 2) { if ($pass1 == $pass2) { $this->view->purifier = Zend_Registry::get('purifier'); $conf = HTMLPurifier_Config::createDefault(); $purifier = new HTMLPurifier($conf); $username = $purifier->purify($this->_request->getParam('username')); $password = $purifier->purify(md5($this->_request->getParam('password'))); $email = $purifier->purify($this->_request->getParam('email')); $full_name = $purifier->purify($this->_request->getParam('full_name')); $phone = $purifier->purify($this->_request->getParam('phone')); $birth = $purifier->purify($this->_request->getParam('birth')); $sex = $purifier->purify($this->_request->getParam('sex')); $address = $purifier->purify($this->_request->getParam('address')); $system->add_User($username, $password, $email, $full_name, 0, 3, $phone, $birth, $sex, $address); thongbao('Chúc mừng bạn đã đăng ký thành công'); chuyen_trang($base); } } else { thongbao("User này đã tồn tại"); trang_truoc(); } } else { thongbao('Ban nhap sai chuoi Captcha'); //trangtruoc(); } $this->_helper->viewRenderer->setNoRender(); $mask = APPLICATION_PATH . "/../public_html/captcha/images/*.png"; array_map("unlink", glob($mask)); } }
function adduserAction() { $system = new Admin_Model_User(); if ($this->_request->isPost()) { $pass1 = $this->_request->getParam('password'); $pass2 = $this->_request->getParam('re_password'); $user = $this->_request->getParam('username'); $exit = $system->list_user_2($user); if ($exit == 2) { if (strlen($pass1) < 9) { thongbao("Password phải từ 8 ký tự trở lên"); return false; } else { } if ($pass1 == $pass2 && $user != '') { $this->view->purifier = Zend_Registry::get('purifier'); $conf = HTMLPurifier_Config::createDefault(); $purifier = new HTMLPurifier($conf); $username = $purifier->purify($this->_request->getParam('username')); $password = $purifier->purify(sha1(salt . $this->_request->getParam('password'))); $email = $purifier->purify($this->_request->getParam('email')); $full_name = $purifier->purify($this->_request->getParam('full_name')); $status = $purifier->purify($this->_request->getParam('status')); $group_name = $purifier->purify($this->_request->getParam('group_name')); $system->insert_user($username, $password, $email, $full_name, $status, $group_name); } else { thongbao("Bạn đã nhập liệu sai"); } } else { thongbao("User này đã tồn tại"); } } }