-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.php
103 lines (97 loc) · 3.35 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?php
// ini_set( "display_errors", 0);
/**
* New request lands in this class.
* After that it is routed accordingly to the respective controller.
*/
require_once('servConf.php');
// echo "id=".$_SESSION['uID'];
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(!isset($_SESSION['f403'])){
$_SESSION['uID']=null;
}
if(preg_match($base . 'cAPI/checkLogin?$@', $url, $match)){
if(isset($_SESSION['uID'])){
echo json_encode(array(1,$_SESSION['uID'],$_SESSION['uName'])) ;
}else{
echo json_encode(array(0)) ;
}
}elseif (preg_match($base . '$@', $url, $match)) {
if(isset($_SESSION['uID'])){
require ('render/homeAgain.php');
} else{
require ('render/login.html');
}
}
elseif (preg_match($base . 'home?$@', $url, $match)) {
require ('render/home.php');
}
elseif (preg_match($base . 'cAPI/(.*)$@', $url, $match)) {
require ('render/commonAPI.php');
} elseif (preg_match($base . 'login?$@', $url, $match)) {
require ('render/login.php');
} elseif (preg_match($base . 'register?$@', $url, $match)) {
require ('render/register.php');//depreciates
} elseif( !isset($_SESSION['uID']) ) {
header("Location: ".$webRoot);
} elseif (preg_match($base . 'timetable?$@', $url, $match)) {
require ('render/timetable.php');
}elseif (preg_match($base . 'homeAgain?$@', $url, $match)) {
require ('render/homeAgain.php');
} elseif (preg_match($base . 'admin?$@', $url, $match)) {
require ('render/admin.php');
}elseif (preg_match($base . 'news-feed?$@', $url, $match)) {
require ('render/news-feed.php');
}elseif (preg_match($base . 'getting-around?$@', $url, $match)) {
require ('render/maps.php');
} elseif (preg_match($base . 'courses?$@', $url, $match)) {
require ('render/courses.php');
} elseif (preg_match($base . 'events?$@', $url, $match)) {
require ('render/events.php');
} elseif (preg_match($base . 'clubs?$@', $url, $match)) {
require ('render/clubs.php');
} elseif (preg_match($base . 'gall?$@', $url, $match)) {
require ('render/gallery.php');
} elseif (preg_match($base . 'lost-found?$@', $url, $match)) {
require ('render/lost_found.php');
} elseif (preg_match($base . 'upl/(.*)$@', $url, $match)) {
require ('render/fUpload.php');
} elseif (preg_match($base . 'courses/view/(.*)$@', $url, $match)) {
require ('render/viewCourse.php');
} elseif (preg_match($base . 'assignments?$@', $url, $match)) {
require ('render/assignments.php');
} elseif (preg_match($base . 'groups/mpr(.*)$@', $url, $match)) {
require ('render/mpr-grp.php');
} elseif (preg_match($base . 'groups/njack(.*)$@', $url, $match)) {
require ('render/Njack-GSOC.php');
} elseif (preg_match($base . 'groups/byte(.*)$@', $url, $match)) {
require ('render/Byterace.php');
} elseif (preg_match($base . 'assignments/dl/(.*)$@', $url, $match)) {
require ('render/assignmentDL.php');
} elseif (preg_match($base . 'post/new?$@', $url, $match)) {
require ('render/newPost.php');//depreciated
} elseif (preg_match($base . 'post/JSON/(.*)/(.*)/(.*)$@', $url, $match)) {
require ('render/viewPost.php');
} elseif (preg_match($base . 'logout?$@', $url, $match)) {
require ('render/logout.php');//depreciated
} else {
http_response_code(404);
require ('render/404.php');
// die('invalid url ' . $url);
die();
}
?>