public static function login_admin() { static $admin = NULL; if (empty($admin)) { $admin_id = \Core\Session::get('admin_id'); if (!empty($admin_id)) { $admin = \DB\Authorize\Admin::row(array('admin_id' => $admin_id)); } } return $admin; }
/** * 登录 */ public function login() { $account = \Core\URI::kv('user_account'); $password = \Core\URI::kv('user_password'); $v = new \Core\Validation(); $v->filter_var(filter_var($account, FILTER_VALIDATE_EMAIL))->message('邮箱帐号错误'); if ($v->has_error()) { \Core\Cookie::set('error', $v->get_error('message')); } else { $gen_password = \DB\Authorize\Admin::gen_password($password); $row = \DB\Authorize\Admin::row(array('admin_account' => $account, 'admin_password' => $gen_password)); //var_dump(!empty($row->admin_account));exit(); if (!empty($row->admin_account)) { \Db\Log::message('登录', '', $row->admin_name); \Core\Session::set('admin_id', $row->admin_id); redirect(\Core\URI::a2p(array('order' => 'index'))); } } redirect(\Core\URI::a2p(array('main' => 'index'))); }
/** * 保存 */ 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; }
public function index() { $this->view->content = view('admin/index.php'); $this->view->content->rows = \DB\Authorize\Admin::fetch(null, NULL, null, array('create_time' => 'desc')); }