<?php
error_reporting(E_ERROR | E_WARNING | E_PARSE);
define('SYSTEM_ROOT', dirname(__FILE__).'/');
define('ROOT', dirname(SYSTEM_ROOT).'/');
date_default_timezone_set('Asia/Shanghai');

$siteurl = ($_SERVER['SERVER_PORT'] == '443' ? 'https://' : 'http://').$_SERVER['HTTP_HOST'].'/';
include_once(SYSTEM_ROOT."autoloader.php");
Autoloader::register();


//数据库文件配置信息
require ROOT.'config.php';
define('DBQZ', $dbconfig['dbqz']);
$DB = new \lib\PdoHelper($dbconfig);
include SYSTEM_ROOT.'medoo.php';
$medoo=new medoo([
    'database_type' => 'mysql',
    'database_name' => $dbconfig['dbname'],
    'server' => $dbconfig['host'],
    'username' => $dbconfig['user'],
    'password' => $dbconfig['pwd'],
    'charset' => 'utf8',
    'prefix' => $dbconfig['dbqz'].'_',
]);
$authsql=new medoo([
    'database_type' => 'mysql',
    'database_name' => $dbconfig['dbname'],
    'server' => $dbconfig['host'],
    'username' => $dbconfig['user'],
    'password' => $dbconfig['pwd'],
    'charset' => 'utf8',
]);

//缓存和站点配置文件信息
$CACHE=new \lib\Cache();
$conf=$CACHE->pre_fetch();
define('SYS_KEY', $conf['syskey']);
if(!$conf['localurl'])$conf['localurl'] = $siteurl;

// cookie操作信息
$cookie=new \lib\Cookie();

// 函数应用
include SYSTEM_ROOT.'function.php';