/** * 用户登录页 */ public function loginAction() { if ($this->request->isPost() == true) { if ($this->security->checkToken()) { $username = $this->request->getPost('username'); $password = trim($this->request->getPost('password')); $isUser = SunUser::findFirst("username = '******' "); if ($isUser) { if ($this->security->checkHash($password, $isUser->password_hash)) { $this->cookies->set('username', $username, time() + 3600); $this->response->redirect('?_url=/index/index'); } else { //密码错误 $this->response->redirect('?_url=/login/index'); } } else { //不存在该用户 $this->response->redirect('?_url=/login/index'); } } else { $this->response->setStatusCode(404, "Not Found"); } } else { $this->response->setStatusCode(404, "Not Found"); } }
/** * 用户管理主页 */ public function webAction() { $numberPage = $this->request->getQuery("page", "int") ? $this->request->getQuery("page", "int") : 1; //$parameters["id"] = '3'; $data = SunUser::find(); $paginator = new Paginator(array("data" => $data, "limit" => 10, "page" => $numberPage)); $this->view->page = $paginator->getPaginate(); }
public function indexAction() { echo json_encode(SunUser::findFirst()); echo 'welcome to websocket !'; }
/** * TcpSocket测试样例 */ public function demoAction() { echo json_encode(SunUser::findFirst()); }