-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
41 lines (37 loc) · 935 Bytes
/
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
<?php
require_once("core/include.php");
// get the name of page requested
@$page = $_GET['page'];
// remove spaces
$page = trim($page,'/');
// make page as array
$page = explode('/',$page);
// return script path
function host(){
$server = $_SERVER['HTTP_HOST'];
if($server == 'localhost')
return dirname($_SERVER['SCRIPT_NAME']).'/view';
else
return 'http://'.$_SERVER['HTTP_HOST'].'/mvc/view';
}
// get page name
$file = 'controller/'.$page[0].'.php';
// check if file exist
if(file_exists($file)){
// if page exist get the page
require_once($file);
new $page[0]();
}
elseif($page[0] == '' || $page[0] == 'home'){
// if page requested is http://www.name.com get index
$file = 'controller/index.php';
require_once($file);
new index();
host();
}else{
// if nothing match get error page
$file = 'controller/error.php';
require_once($file);
new error();
}
?>