/** * @param $method * @param bool $view */ protected function setMethod($method, $view = true) { $this->view->setMethod($method); if ($view && isset($this->methodView[$method]) && is_array($this->methodView[$method])) { $this->view->assign($this->methodView[$method]); } }
/** * action 'login' * @param Request $request * @param Response $response */ public function login(Request $request, Response $response) { $show_page = true; $retmsg = ''; $retuname = ''; $retupass = ''; if (isset($_POST['loginname']) && isset($_POST['password'])) { $loginname = trim($_POST['loginname']); $password = trim($_POST['password']); $verifycode = isset($_POST['verifycode']) ? trim($_POST['verifycode']) : ''; unset($_POST['loginname'], $_POST['password'], $_POST['verifycode']); $retuname = $loginname; $retupass = $password; if ('' == $loginname) { $retmsg = '请输入用户名'; } elseif ('' == $password) { $retmsg = '请输入密码'; } elseif ('' == $verifycode) { $retmsg = '请输入验证码'; } elseif (0 && $verifycode != $_SESSION['verifycode']) { $retmsg = '请输入正确的验证码'; } else { $check = User_Model::check_logined($loginname, $password, $admin); if ($check < 0) { $retmsg = '不存在该用户'; } elseif ($check === 0) { $retmsg = '密码错误!'; } else { //Final Login Success $retmsg = '登录成功!'; unset($_SESSION['verifycode']); $_SESSION['logined_uid'] = $admin['admin_uid']; $_SESSION['logined_uname'] = $admin['admin_uname']; $response->redirect('/home'); } } } if ($show_page) { $v = new PageView('mod_user_login', '_page_front'); $v->assign('retmsg', $retmsg)->assign('retuname', $retuname)->assign('retupass', $retupass); $response->send($v); } }
/** * @param null|string $method * @return PageView */ public function execute($method = null) { if (!$method) { $method = $this->request->getMethod(); } $this->view->setCurrentMethod($method); $execMethod = 'on' . ucwords($method); try { if (!method_exists($this->controller, $execMethod)) { throw new \RuntimeException('no method: ' . $method); } $this->controller->beginController($method); if ($contents = $this->execMethod($execMethod)) { $this->view->assign($contents); } $this->controller->finishController(); } catch (\Exception $e) { $this->view->critical($e->getMessage()); } return $this->view; }
public function member_loginlog(Request $request, Response $response) { $search = array(); $search['stime'] = ''; $search['etime'] = ''; $search['username'] = ''; $search['uid'] = ''; $search['sort'] = 'id_desc'; //排序字段,example:coin_asc,coin_desc //不更新查询条件 if (empty($_POST)) { if (isset($_SESSION['query']['loginlog'])) { $search = $_SESSION['query']['loginlog']; } else { $_SESSION['query']['loginlog'] = $search; } } else { //更新查询条件 $search['stime'] = empty($_POST['stime']) ? '' : addslashes(trim($_POST['stime'])); $search['etime'] = empty($_POST['etime']) ? '' : addslashes(trim($_POST['etime'])); $search['username'] = empty($_POST['username']) ? '' : addslashes(trim($_POST['username'])); $search['uid'] = empty($_POST['uid']) ? '' : addslashes(trim($_POST['uid'])); $search['sort'] = empty($_POST['sort']) ? 'id_desc' : addslashes(trim($_POST['sort'])); $_SESSION['query']['loginlog'] = $search; } $where = ""; if ($search['username'] != '') { $where .= " and username='******'username'] . "'"; } if ($search['uid'] != '') { $where .= " and uid='" . $search['uid'] . "'"; } if ($search['stime'] != '') { $where .= " and login_time>=" . strtotime($search['stime']); } if ($search['etime'] != '') { $where .= " and login_time<=" . strtotime($search['etime']); } //排序 $sort_where = ""; if ($search['sort'] != '') { $sort = explode('_', $search['sort']); if (count($sort) == 2) { switch ($sort[0]) { case 'uid': $sort_field = 'uid '; break; case 'time': $sort_field = 'login_time'; break; default: $sort_field = 'log_id'; } switch ($sort[1]) { case 'asc': $sort_sequ = ' ASC '; break; default: $sort_sequ = ' DESC '; break; } $sort_where = ' ' . $sort_field . $sort_sequ; } } $log = Member_Model::getMemberLoginLog($where, $sort_where); $v = new PageView('mod_member_loginlog'); $v->assign('nav', $this->_nav)->assign('nav_second', 'loginlog'); $v->assign('log', $log)->assign('search', $search); $response->send($v); }
/** * Response error message * @param string $msg */ public function error($msg = '') { $seo_default = array('title' => 'Oops! Error happened.', 'keyword' => '', 'desc' => $msg); $seo_error = C('seo.error', $seo_default); if (empty($seo_error['title'])) { $seo_error['title'] = $seo_default['title']; } if (empty($seo_error['desc'])) { $seo_error['desc'] = $msg; } $v = new PageView('error'); $v->assign('err_msg', $msg)->assign('seo', $seo_error); $this->send($v); }