| <?php | 
|     /** | 
|      * 用户控制器 | 
|      */ | 
|     class UserController extends System_Controller_Web{ | 
|   | 
|         public function init(){ | 
|             $this->request = $this->getRequest(); | 
|             if($this->request->action == "login"){ | 
|                 $this->setLayout(); | 
|             } | 
|             parent::init(); | 
|             $this->user_service = new Service_User(); | 
|         } | 
|          | 
|         /** | 
|          * 管理员登录 | 
|          * @return [type] [description] | 
|          */ | 
|         public function LoginAction(){ | 
|             if($this->request->isXmlHttpRequest()){ | 
|                 $username = $this->request->getPost('username'); | 
|                 $password = $this->request->getPost('password'); | 
|                 //进行管理员登录 | 
|                 if(!$this->user_service->login($username, $password)){ | 
|                     exit($this->showError($this->user_service->error, 400, true)); | 
|                 } | 
|                 else{ | 
|                     exit($this->showSuccess('登录成功', true)); | 
|                 } | 
|             } | 
|             else{ | 
|                 $this->setLayout(); | 
|             }             | 
|         } | 
|   | 
|         /** | 
|          * 退出登录 | 
|          */ | 
|         public function LogoutAction(){ | 
|             $session = Yaf_Session::getInstance(); | 
|             $session->del('user'); | 
|             $this->redirect('/user_login.html'); | 
|         } | 
|   | 
|   | 
|     } | 
|   | 
|          |