<?php namespace Place_interface\Lib;
use Dever;
use Place;
use Dever\Helper\Secure;
class Core
{
    protected $login = false;
    protected $entry = false;
    public function __construct()
    {
        Place::init();
        $t = Dever::input('t');
        if ($this->login && !$t) {
            $this->showLogin();
        }
        if ($t) {
            if ($t = Secure::checkLogin($t)) {
                if ($t['uid'] && $t['uid'] > 0) {
                    Place::user($t['uid']);
                }
                if ($this->login && !Place::$uid) {
                    $this->showLogin();
                }
            } elseif ($this->login) {
                $this->showLogin();
            }
        }
        if ($this->entry) {
            if (Place::$info['type'] >= 2 && !Place::$uid) {
                Dever::error('您没有权限');
            }
            /*
            if (Place::$member && Place::$user['entry_type'] <= 2) {
                Dever::error('您没有权限');
            }*/
        }
    }

    protected function showLogin()
    {
        Dever::error('请先登录', 300);
    }
}