-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.php
89 lines (85 loc) · 2.95 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
<?php
/*
*This is file should be locked.
*you can only add routes to the $routes array, don't change anything else
*if you want to change something in the theme consider visiting php/theme_header and php/theme_footer
*/
session_start();
$isIndex=true;
require_once('./php/functions.php');
require_once('./php/config.php');
require_once('./php/User.class.php');
require_once('./php/database.php');
$routes = array('home',
'profile',
'go',
'add','addToDB',//ToReview just for the moment
'game',
'signup',
'signin',
'signout');
$requestURI = explode('/',$_SERVER['REQUEST_URI']);
$scriptName = explode('/',$_SERVER['SCRIPT_NAME']);
for($i= 0;$i < sizeof($scriptName);$i++){
if($requestURI[$i] == $scriptName[$i]){
unset($requestURI[$i]);
}
}
$requestURI = array_values($requestURI);
@$action = $requestURI[0];
$params = array_slice($requestURI,1);
if(empty($action)){
$action = "home";
}
if( ($action == 'game' || $action == 'go') && !User::isConnected()){//if not connected he can see only home
setAlert('warning','in order to play please sign in first');
header('location: /home');
exit(0);
}
//why not, i think he should be able to see home if he's connected...
if($action=='gameMaker'){//it looks ugly but hey, it works
require_once("./php/gameMaker.php");
exit(0);
}
?>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/png" href="/img/icon.png">
<title>Game For King</title>
<link rel="stylesheet" href="/css/bootstrap.min.css">
<link rel="stylesheet" href="/css/font-awesome.min.css">
<link rel="stylesheet" href="/css/bootstrap-social.min.css">
<link rel="stylesheet" href="/css/style.css">
<!--[if lt IE 9]>
<script src="/js/html5shiv.min.js"></script>
<script src="/js/respond.min.js"></script>
<![endif]-->
<script type="text/javascript" src="/js/jquery.min.js"></script>
<script type="text/javascript" src="/js/bootstrap.min.js"></script>
<?php if($action=="profile"){ ?>
<link rel="stylesheet" href="/css/profile-style.css">
<?php }else if($action=="go"){ ?>
<link rel="stylesheet" href="/css/go-style.css">
<script type="text/javascript" src="/js/go.js"></script>
<?php }else if($action=="game"){ ?>
<script type="text/javascript" src="/js/game.js"></script>
<?php } ?>
</head>
<body class="bg-color" style='margin-top:0;margin-left:0;margin-right:0;'>
<?php
if(in_array($action,$routes)){
require_once("./php/theme_header.php");
require_once("./php/".$action.".php");
require_once("./php/theme_footer.php");
$link->close();//close session
}
else{
require_once("./php/error.php");
}
?>
</body>
</html>