public function pwdAction() { if ($this->getRequest()->isPost()) { $oldpwd = trim($this->_request->getParam('oldpwd')); $newpwd = trim($this->_request->getParam('newpwd')); $confirmpwd = trim($this->_request->getParam('confirmpwd')); $account = new Application_Model_DbTable_Account(); $db = $account->getAdapter(); $select = $db->select(); $select->from('account', 'password'); $select->where('id = ?', BLOGGER_ID); $data = $db->fetchRow($select); if ($oldpwd != $data['password']) { $response = "请输入原始注册密码!"; } else { if ($newpwd != $confirmpwd) { $response = "两次密码输入不一致!"; } else { $affected = $account->updatePwd(BLOGGER_ID, $newpwd); if ($affected >= 1) { $response = "密码修改成功!"; } else { $response = "系统出错,请稍后再试!"; } } } if ($this->getRequest()->isXmlHttpRequest() || $this->_request->getParam('ajax') == 1) { $this->_helper->layout->setLayout('empty_layout'); $this->_helper->viewRenderer->setNoRender(); $this->_response->appendBody($response); } else { $this->_forward('profile'); echo "<script type='text/javascript'>alert('{$response}')</script>"; } } }