forked from harikrishna266/mvc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.php
More file actions
47 lines (43 loc) · 1.15 KB
/
bootstrap.php
File metadata and controls
47 lines (43 loc) · 1.15 KB
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
<?php
session_start();
spl_autoload_register(function ($class_name) {
if($class_name === "db")
require_once('./db/'.$class_name.".php");
else
require_once('./controller/'.$class_name.".php");
});
function getPostData() {
$post = $_POST;
$post = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING,FILTER_FLAG_ENCODE_LOW);
return $post;
//print_r($post);
}
function getGetData() {
$get = $_GET;
$get = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING,FILTER_FLAG_ENCODE_LOW);
return $get;
}
function getSession(){
$session = (isset($_SESSION))?$_SESSION: false;
if($session)
return $_SESSION;
else
header('location:../login/view');
}
class bootstrap {
function __construct() {
$querystring = $_SERVER['REDIRECT_QUERY_STRING'];
parse_str($querystring, $output);
if($output) {
$controller = ($output['controller'])?$output['controller']:'home';
$method = ($output['method'])?$output['method']:'index';
$control = $controller."Controller";
if(file_exists('./controller/'.$control.".php")){
$controllerObj = new $control();
$controllerObj->$method();
}
else die('controller not found');
}
}
}
?>