-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.php
91 lines (91 loc) · 2.13 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
84
85
86
87
88
89
90
91
<?php
error_reporting(0);
include('config.php');
include('autoloader.php');
$path=$_SERVER['REQUEST_URI'];
$_GET=array();
if(false!==strpos($path,'?')){
$query_string=substr($path,1+strpos($path,'?'));
$path=substr($path,0,strpos($path,'?'));
$pairs=explode('&',$query_string);
foreach($pairs as $pair){
list($name,$value)=explode('=',$pair);
$_GET[$name]=urldecode($value);
}
}
$path_ext=false;
if(false!==strrpos($path,'.')){
$path_ext=substr($path,strrpos($path,'.'));
}
if(!$path_ext){
if('/'!=substr($path,strlen($path)-1)){
if($query_string){
$query_string='?'.$query_string;
}
header('location:'.$path.'/'.$query_string);
exit;
}
}
$path_array=explode('/',trim($path));
$t->open('index.tpl','index');
$module_file=$site_root.'/module/prepare.php';
if(file_exists($module_file)){
include($module_file);
}
$module=mongo_prepare($path_array[1]);
if(!$module){
$module='index';
}
$module_file=$site_root.'/module/'.$module.'.php';
if(file_exists($module_file)){
include($module_file);
}
else{
$module_file=$site_root.'/module/index.php';
include($module_file);
}
if($content){
$replace['pages']=$content;
if(isset($replace)){
foreach ($replace as $name=>$value){
$t->assign($name,$value,'index');
}
}
foreach($l10n as $cat=>$arr){
foreach($arr as $name=>$value){
if(is_array($value)){
foreach($value as $subname=>$subvalue){
$t->assign('l10n_'.$cat.'_'.$name.'_'.$subname,$subvalue,'index');
}
}
else{
$t->assign('l10n_'.$cat.'_'.$name,$value,'index');
}
}
}
$result=$t->get('index');
if(false!==strpos(@$_SERVER['HTTP_ACCEPT_ENCODING'],'gzip')){
header('Content-Encoding: gzip');
print gzencode($result);
}
else{
print $result;
}
}
else{
header('HTTP/1.1 404 Not Found');
print '<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<TITLE>404 Not Found</TITLE>
</head>
<body>
<h1>Not Found</h1>
The requested URL '.$path.' was not found on this server.<P>
<hr>
<address>'.$_SERVER['SERVER_SOFTWARE'].' Server at '.$_SERVER['HTTP_HOST'].' Port '.$_SERVER['SERVER_PORT'].'</address>
</body>
</html>';
}
exit;