forked from fex-team/fis3-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
83 lines (74 loc) · 2.19 KB
/
index.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
// PHP 是世界上最好的语言之一
date_default_timezone_set('Asia/Shanghai');
define('ROOT', dirname(__FILE__));
require(ROOT . '/smarty/Smarty.class.php');
$MIMEType = array(
'bmp' => 'image/bmp',
'css' => 'text/css',
'doc' => 'application/msword',
'dtd' => 'text/xml',
'gif' => 'image/gif',
'hta' => 'application/hta',
'htc' => 'text/x-component',
'htm' => 'text/html',
'html' => 'text/html',
'xhtml' => 'text/html',
'ico' => 'image/x-icon',
'jpe' => 'image/jpeg',
'jpeg' => 'image/jpeg',
'jpg' => 'image/jpeg',
'js' => 'text/javascript',
'json' => 'application/json',
'mocha' => 'text/javascript',
'mp3' => 'audio/mp3',
'mp4' => 'video/mpeg4',
'mpeg' => 'video/mpg',
'mpg' => 'video/mpg',
'manifest' => 'text/cache-manifest',
'pdf' => 'application/pdf',
'png' => 'image/png',
'ppt' => 'application/vnd.ms-powerpoint',
'rmvb' => 'application/vnd.rn-realmedia-vbr',
'rm' => 'application/vnd.rn-realmedia',
'rtf' => 'application/msword',
'svg' => 'image/svg+xml',
'swf' => 'application/x-shockwave-flash',
'tif' => 'image/tiff',
'tiff' => 'image/tiff',
'txt' => 'text/plain',
'vml' => 'text/xml',
'vxml' => 'text/xml',
'wav' => 'audio/wav',
'wma' => 'audio/x-ms-wma',
'wmv' => 'video/x-ms-wmv',
'woff' => 'image/woff',
'xml' => 'text/xml',
'xls' => 'application/vnd.ms-excel',
'xq' => 'text/xml',
'xql' => 'text/xml',
'xquery' => 'text/xml',
'xsd' => 'text/xml',
'xsl' => 'text/xml',
'xslt' => 'text/xml'
);
$uri = $_SERVER['REQUEST_URI'];
$script = preg_replace('@\?.*@', '', $uri);
if ((preg_match('@\.([a-z]+)@i', $script, $m))) {
$ext = $m[1];
if (isset($MIMEType[$ext])) {
header('Content-Type: ' . $MIMEType[$ext]);
}
if (file_exists(ROOT . $script)) {
echo file_get_contents(ROOT . $script);
exit(0);
}
}
$smarty = new Smarty();
$smarty->setPluginsDir(array(
ROOT . '/plugin'
));
$smarty->setTemplateDir(ROOT . '/template');
$smarty->setCompileDir(ROOT . '/templates_c');
$smarty->setConfigDir(ROOT . '/config');
$smarty->display('page/index.tpl'); // 从 template_dir 下寻找