/** * 退出登录 */ public function out() { $admin = \Model\Authorize\Admin::login_admin(); \Db\Log::message('退出', '退出系统', $admin->admin_name); \Core\Session::destory(); redirect(\Core\URI::a2p(array('main' => 'index'))); }
public function index_part() { $limit = 10; $page = \Core\URI::kv('page', 1); $start = ($page - 1) * $limit; $rows = \DB\Log::fetch(null, $limit, $start, array('create_time' => 'desc')); $rs = ''; $v = new \Model\Validation(); if (!empty($rows)) { foreach ($rows as $row) { $view = view('log/index_part.php'); $view->row = $row; $rs .= $view->__toString(); } $v->set_data($rs); } else { $v->required(false)->message('没有更多了...'); } echo json_encode($v->get_error()); exit; }
/** * 保存 */ public function save() { $admin_avatar = \Core\URI::kv('ajax_image'); $admin_name = \Core\URI::kv('admin_name'); $admin_account = \Core\URI::kv('admin_account'); $admin_password = \Core\URI::kv('admin_password'); $admin_mobile = \Core\URI::kv('admin_mobile'); $v = new \Core\Validation(); $v->required($admin_avatar)->message('头像不能为空'); $v->required($admin_name)->message('姓名称不能为空'); $v->required($admin_account)->message('帐号不能为空'); $v->required($admin_password)->message('密码不能为空'); $v->required($admin_mobile)->message('手机号码不能为空'); if (!$v->has_error()) { $id = \Core\URI::kv('id', null); $link = new \Db\Authorize\Admin($id); $link->admin_avatar = $admin_avatar; $link->admin_name = $admin_name; $link->admin_account = $admin_account; $link->admin_mobile = $admin_mobile; // ID if (empty($id)) { $link->admin_password = \Db\Authorize\Admin::gen_password($admin_password); } else { if ($link->admin_password != $admin_password) { $link->admin_password = \Db\Authorize\Admin::gen_password($admin_password); } } $link->create_time = W_START_TIME; $link->save(); if (empty($id)) { \Db\Log::message('添加', "添加角色:" . $admin_name, $this->admin->admin_name); } else { \Db\Log::message('更新', "更新角色:" . $admin_name, $this->admin->admin_name); } } echo json_encode($v->get_error()); exit; }