public function loginAction() { $username = strip_tags(trim($this->getRequest()->getParam('username'))); $password = md5(strip_tags(trim($this->getRequest()->getParam('password')))); $UserMapper = new Application_Model_UserMapper(); $arr = $UserMapper->checkUser($username, $password); if (!empty($arr)) { if ($arr[0]['Activate'] == 1) { $DeptMapper = new Application_Model_DepartmentMapper(); $DeptID = $arr[0]['Department']; $arrDept = $DeptMapper->findDept($DeptID); if (!empty($arrDept)) { $DeptCode = $arrDept[0]['DeptCode']; $DeptName = $arrDept[0]['DeptName']; } $session = new Zend_Session_Namespace('user'); $session->UserID = $arr[0]['UID']; $session->UserName = $arr[0]['UserName']; $session->RealName = $arr[0]['RealName']; $session->DeptID = $arr[0]['Department']; $session->DeptCode = $DeptCode; $session->DeptName = $DeptName; $session->Type = $arr[0]['Type']; $session->LastLoginTime = $arr[0]['LastLoginTime']; if ($this->getRequest()->getParam('remember') == "on") { $session->setExpirationSeconds(3600); } else { $session->setExpirationSeconds(1800); } $res = $UserMapper->updateLastLoginTime($arr[0]['UID']); $this->_redirect('/admin'); } else { $string = "<meta http-equiv='content-type' content='text/html; charset=UTF-8'><script language=\"JavaScript\">alert(\"未授权用户!\");location.href = \"/login\";</script>"; echo $string; exit; } } else { $string = "<meta http-equiv='content-type' content='text/html; charset=UTF-8'><script language=\"JavaScript\">alert(\"登陆失败!\");location.href = \"/login\";</script>"; echo $string; exit; } }
/** * 修改密码 */ public function modifypwdAction() { $type = $this->_request->getParam("type"); $this->view->Type = $type; if ($type == 'post') { $oldpwd = md5(strip_tags(trim($this->_request->getParam("oldpwd")))); $newpwd = strip_tags(trim($this->_request->getParam("newpwd"))); $repeatnewpwd = strip_tags(trim($this->_request->getParam("repeatnewpwd"))); $UserMapper = new Application_Model_UserMapper(); $arr = $UserMapper->checkUser($_SESSION['user']['UserName'], $oldpwd); if (!empty($arr)) { if ($newpwd != "" && $newpwd == $repeatnewpwd) { $res = $UserMapper->modifyUserPwd($arr[0]['UID'], $newpwd); if (!isset($res)) { $string = "<meta http-equiv='content-type' content='text/html; charset=UTF-8'><script language=\"JavaScript\">alert(\"修改失败 %>_<%\");history.back();</script>"; echo $string; exit; } else { $string = "<meta http-equiv='content-type' content='text/html; charset=UTF-8'><script language=\"JavaScript\">alert(\"修改成功!\\n请用新密码重新登录\");location.href = \"/login/logout/type/noalert\";</script>"; echo $string; exit; } } else { $string = "<meta http-equiv='content-type' content='text/html; charset=UTF-8'><script language=\"JavaScript\">alert(\"新密码有问题\\n请修改后重新提交\");history.back();</script>"; echo $string; exit; } } else { $string = "<meta http-equiv='content-type' content='text/html; charset=UTF-8'><script language=\"JavaScript\">alert(\"原密码错误\");history.back();</script>"; echo $string; exit; } } else { if ($type == 'facebox') { $this->_helper->layout->disableLayout(); } } }