-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
39 lines (33 loc) · 1.12 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
<?php
define( 'INCLUDE_DIR', dirname( __FILE__ ) . '/controller/' );
$rules = array(
'backoffice' => "/backoffice/(?'page'users|faq|cards|devices)",
'php' => "/php/(?'page'[\w\-]+)",
'default' => "/(?'page'[\w\-]+)",
'main' => "/"
);
$uri = rtrim( dirname($_SERVER["SCRIPT_NAME"]), '/' );
$uri = '/' . trim( str_replace( $uri, '', $_SERVER['REQUEST_URI'] ), '/' );
$uri = urldecode( $uri );
foreach ( $rules as $action => $rule ) {
if ( preg_match( '~^'.$rule.'~', $uri, $params ) ) {
if($action === 'php'){
if(file_exists(INCLUDE_DIR . '/php/' . $params['page'] . '.php')){
include( INCLUDE_DIR . '/php/' . $params['page'] . '.php' );
} else {
break;
}
} else if($action === 'default'){
if(file_exists(INCLUDE_DIR . $params['page'] . '.php')){
include( INCLUDE_DIR . $params['page'] . '.php' );
} else {
break;
}
} else {
include( INCLUDE_DIR . $action . '.php' );
}
exit();
}
}
include( INCLUDE_DIR . '404.php' );
?>