-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
69 lines (65 loc) · 2.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
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
<?php
header('Access-Control-Allow-Origin: *');
define('TIMEZONE', 'Asia/Kolkata');
date_default_timezone_set(TIMEZONE);
define('Tot_hours', 80);
// $now = new DateTime();
// $mins = $now->getOffset() / 60;
// $sgn = ($mins < 0 ? -1 : 1);
// $mins = abs($mins);
// $hrs = floor($mins / 60);
// $mins -= $hrs * 60;
// $offset = sprintf('%+d:%02d', $hrs*$sgn, $mins);
// //Your DB Connection - sample
// $db = new PDO('mysql:host=localhost;dbname=test', 'dbuser', 'dbpassword');
// $db->exec("SET time_zone='$offset';");
/**
* New request lands in this class.
* After that it is routed accordingly to the respective controller.
*/
class Routing
{
function __construct()
{
return null;
}
public function Redirect($url)
{
return null;
}
}
// echo "check";
$url = $_SERVER['REQUEST_URI'];
preg_match('@(.*)index.php(.*)$@', $_SERVER['PHP_SELF'], $mat );
$base = '@^'. $mat[1] ;
if (preg_match($base . '$@', $url, $match)) {
require ('controller/index.html');
} elseif (preg_match('/request$/', $url, $match)) {
require ('controller/request_blood.php');
} elseif (preg_match('/think_thank$/', $url, $match)) {
require ('controller/think_thank.php');
} elseif (preg_match('/addHours$/', $url, $match)) {
require ('controller/add_hours.php');
} elseif (preg_match('/removeHours$/', $url, $match)) {
require ('controller/remove_hour.php');
} elseif (preg_match('/getAllHoursDetails$/', $url, $match)) {
require ('controller/get_all_hour_details.php');
} elseif (preg_match('/getOwnHoursDetails$/', $url, $match)) {
require ('controller/get_hour_details_self.php');
} elseif (preg_match('/getHoursDetails$/', $url, $match)) {
require ('controller/get_hour_details.php');
} elseif (preg_match('/login$/', $url, $match)) {
require ('controller/login.php');
} elseif (preg_match('/logout$/', $url, $match)) {
require ('controller/logout.php');
} elseif (preg_match('/register$/', $url, $match)) {
require ('controller/register.php');
} elseif (preg_match($base . 'request/?$@', $url, $match)) {
require ('controller/request_blood.php');
} else {
http_response_code(404);
require ('controller/404.php');
// die('invalid url ' . $url);
die();
}
?>