Beispiel #1
0
 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;
 }
Beispiel #2
0
 /**
  * 登录
  */
 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')));
 }