public function emailAction() { if ($this->getRequest()->isPost()) { $nickname = trim($this->_request->getParam('nickname')); $pwd = trim($this->_request->getParam('pwd')); $oldmail = trim($this->_request->getParam('oldmail')); $newmail = trim($this->_request->getParam('newmail')); $account = new Application_Model_DbTable_Account(); $db = $account->getAdapter(); $select = $db->select(); $select->from('account', array('nickname', 'password', 'email')); $select->where('id = ?', BLOGGER_ID); $data = $db->fetchRow($select); if ($nickname != $data['nickname']) { $response = "用户名错误!"; } else { if ($pwd != $data['password']) { $response = "密码错误!"; } else { if ($oldmail != $data['email']) { $response = "请输入您的原注册邮箱!"; } else { if (!preg_match("/^[\\w\\-\\.]+@[\\w\\-\\.]+(\\.\\w+)+\$/", $newmail)) { $response = "请您输入正确的新邮箱账号!"; } else { $affected = $account->updateMail(BLOGGER_ID, $newmail); 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>"; } } }