-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
71 lines (42 loc) · 1.44 KB
/
index.php
File metadata and controls
71 lines (42 loc) · 1.44 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
/**
* Created by Md. Atiqur Rahman. <atiqur.su@gmail.com, atiqur@shaficonsultancy.com>
* Date: 11/10/2019
* Time: 12:59 PM
*/
session_start();
date_default_timezone_set('UTC');
//date_default_timezone_set('Asia/Dhaka');
require './config.php';
require './helpers.php';
require './routes.php';
$files = glob('./Core/*.php');
foreach ($files as $file) { require($file); }
$files = glob('./Controller/*Controller.php');
foreach ($files as $file) { require($file); }
$files = glob('./Model/*.php');
foreach ($files as $file) { require($file); }
$urlInfo = parse_url($_SERVER['REQUEST_URI']);
if(array_key_exists($urlInfo['path'], $routes)) {
$con = mysqli_connect($dbConfig['host'], $dbConfig['user'], $dbConfig['password'], $dbConfig['database'], $dbConfig['port']);
if (mysqli_connect_errno()) {
die("Failed to connect to MySQL: " . mysqli_connect_error());
}
$configObj = new \App\Core\Config();
$configObj->setSalt($salt);
$configObj->setDbConnection($con);
$cmStr = $routes[$urlInfo['path']];
$cmStr = explode('@', $cmStr, 2);
$controller = '\Controller\\'.$cmStr[0];
$ins = new $controller($configObj);
$method = $cmStr[1];
$response = $ins->$method($_REQUEST);
if(is_array($response)) {
echo json_encode($response);
return;
}
echo $response;
return;
}
header('HTTP/1.1 404 Not Found');
die('Redirecting to 404 page...... url not defined.');