forked from Celesta-IITP/celesta-backend-legacy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
executable file
·53 lines (53 loc) · 1.45 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
<?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(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/index.html');
// }
}
elseif (preg_match($base . 'login?$@', $url, $match)) {
require ('render/loginController.php');
} elseif (preg_match($base . 'register?$@', $url, $match)) {
require ('render/signUpController.php');
} elseif (preg_match($base . 'switchtoCA?$@', $url, $match)) {
require ('render/switchtoCA.php');
} elseif (preg_match($base . 'cAPI/(.*)$@', $url, $match)) {
require ('render/commonAPI.php');
} elseif (preg_match($base . 'event/([0-9]{2})/([0])|([0-9]{4})/(.*)$@', $url, $match)) {
require ('render/eveReg.php');
} else {
http_response_code(404);
require ('render/404.php');
// die('invalid url ' . $url);
die();
}
?>