-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
49 lines (37 loc) · 1.18 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
<?php
define('DIR_SEP', DIRECTORY_SEPARATOR);
define('DIR_ROOT', getcwd());
define('DIR_INC', DIR_ROOT.DIR_SEP.'inc'.DIR_SEP);
define('DIR_PG', DIR_ROOT.DIR_SEP.'pg'.DIR_SEP);
define('DIR_TPL', DIR_ROOT.DIR_SEP.'tpl'.DIR_SEP);
define('DIR_PTL', DIR_ROOT.DIR_SEP.'tpl'.DIR_SEP.'ptl'.DIR_SEP);
$meta = array();
$scripts = array();
$request_uri = $_SERVER['REQUEST_URI'];
$path = array_values(array_filter(explode('/',$request_uri)));
$page = empty($path[0])?'home':implode(DIR_SEP,$path);
$page_path = DIR_ROOT.DIR_SEP.'pg'.DIR_SEP.$page;
$page_file = DIR_ROOT.DIR_SEP.'pg'.DIR_SEP.$page.'.php';
$page_index = DIR_ROOT.DIR_SEP.'pg'.DIR_SEP.$page.DIR_SEP.'index.php';
require_once 'inc/meta.php';
$is_ajax = is_ajax();
if(!$is_ajax)
include DIR_TPL.'header.php';
if(file_exists($page_file))
include $page_file;
elseif(file_exists($page_index))
include $page_index;
else
include DIR_PG.'404.php';
if(!$is_ajax)
include DIR_TPL.'footer.php';
function is_ajax(){
$retval = ((isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'))?true:false;
return $retval;
}
function prp($d){
echo '<pre>';
print_r($d);
echo '</pre>';
}
?>