<?php

namespace Agent\Lib;

use Dever;

class Core
{
    protected $uid = -1;
    protected $use = array();
    protected $check = true;
    public $data = array();

    public function __construct()
    {
        $test = Dever::input('test');
        $config = Dever::db('setting/base')->one();
        if($config['type'] == 2 || $test == 1){
            Dever::alert($config['type_desc'], -4);
        }
        $this->uid = Dever::load('passport/user')->check(false);
        if ($this->uid <= 0) {
            $this->uid = 4130;
        }
        if ($this->check) {
            $this->checkLogin();
        }
        
        if ($this->uid) {
            $this->user = Dever::db('agent/member')->find($this->uid);
        }
        if ($this->check) {
            if ($this->user && $this->user['status'] <= 2) {
                $this->user['uid'] = $this->user['id'];
            } else {
                Dever::alert('已被禁用', -3);
            }
        }
    }

    public function checkLogin()
    {
        if (!$this->uid || $this->uid <= 0) {
            Dever::alert('请先登录', -2);
        }
    }
}