-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathConfig.php
67 lines (47 loc) · 1.25 KB
/
Config.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
session_start();
if(!defined('IS_MyPHP')) exit('拒绝访问!');
//设置编码为UTF-8
header('Content-Type:text/html;Charset=utf-8');
//网站根目录
define('ROOT_PATH', dirname(__FILE__));
//加载Twig类
require_once ROOT_PATH.'/Library/Twig/Autoloader.php';
//加载Medoo类
require_once ROOT_PATH.'/Library/Medoo.php';
//加载phpError类
require_once ROOT_PATH.'/Library/Php_error.php' ;
\php_error\reportErrors();
//加载Session类
require_once ROOT_PATH.'/Library/Session.php';
//使用Medoo
use Medoo\Medoo;
//使用Twig
Twig_Autoloader::register();
//模板路径
$loader = new Twig_Loader_Filesystem(ROOT_PATH.'/Templates');
//缓存路径
$twig = new Twig_Environment($loader, array(
'cache' => ROOT_PATH.'/Cache',
'auto_reload' => true, //根据文件更新时间,自动更新缓存
'debug' => true
));
//配置数据库
require_once ROOT_PATH.'/App/Data.php';
//执行数据库
$_DB= new medoo($_DB['mysql']);
$num = $_DB->select("counter", [
"counter"
]);
$counter_num=++$num[0]['counter'];
if(!session::get('counter'))
{
$result = $_DB->update("counter", [
"counter" => $counter_num
]);
if($result)
{
session::set('counter',TRUE);
}
}
?>