-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
180 lines (148 loc) · 7.16 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
<?php
session_start();
//Include database connection
require_once('includes/db.inc.php');
//Include remember me login
require_once('includes/remember_cookie.inc.php');
//Include CSRFToken generator
require_once('includes/csrf_token.inc.php');
//Print function to avoid XSS
require_once('includes/xss.inc.php');
$num_of_slides = 3; //Dynamic number of slides for home page
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="The Official Page of Engage Games">
<meta name="author" content="Szymon Bialkowski & Shane Doyle">
<link rel="icon" href="assets/img/favicon.ico">
<title>Engage</title>
<!-- Bootstrap core CSS -->
<link href="assets/css/bootstrap.min.css" rel="stylesheet">
<!-- Font Awesome -->
<link href="assets/css/font-awesome.min.css" rel="stylesheet">
<!-- Custom CSS -->
<link href="assets/css/style.css" rel="stylesheet">
<!-- Google Fonts -->
<link href="https://fonts.googleapis.com/css?family=Lato:300,300i,400,700" rel="stylesheet">
<!-- HTML5 shiv and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div id="loading"></div>
<?php
//Navbar
require_once('includes/navbar.inc.php');
?>
<section class="main-body">
<div class="container">
<div class="row">
<div class="col-sm-5">
<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<?php for ($i=0; $i < $num_of_slides; $i++) { ?>
<?php if ($i == 0): ?>
<li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
<?php else: ?>
<li data-target="#carouselExampleIndicators" data-slide-to="<?php xss($i); ?>"></li>
<?php endif; ?>
<?php }//end of for loop ?>
</ol>
<div class="carousel-inner" role="listbox">
<?php
$result = mysqli_query($db, "SELECT game_id, title, cover_path FROM game where deal like 1 order by RAND() limit $num_of_slides");
for ($i = 0; $i < $num_of_slides; $i++) {
$row = mysqli_fetch_row($result); ?>
<?php if ($i == 0): ?>
<div class="carousel-item active">
<?php else: ?>
<div class="carousel-item">
<?php endif; ?>
<a href="game.php?q=<?php xss($row[0]); ?>">
<img class="d-block img-fluid" src="assets/img/games/<?php xss($row[2]); ?>" alt="The cover image of <?php xss($row[1]); ?>">
<div class="carousel-caption d-md-block">
<h3><?php xss($row[1]); ?></h3>
</div>
</a>
</div>
<?php } //end for loop ?>
</div>
<a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
<div class="col-sm-3">
<div class="main-body-first-col">
<h3>Under $5</h3>
<?php
$result = mysqli_query($db, "SELECT game_id, title, price, cover_path FROM game where price < 5 order by RAND() limit 2");
for ($i = 0; $i < 2; $i++)
{
$row = mysqli_fetch_row($result);
?>
<div class="main-body-white-col">
<div class="container">
<div class="row">
<div class="col-sm-12">
<a href="game.php?q=<?php xss ($row[0]); ?>">
<img class="main-body-img" src="assets/img/games/<?php xss ($row[3]); ?>" alt="The cover for <?php xss ($row[1]); ?>">
</a>
<h3 class="text-black main-body-white-col-h3"><?php xss ($row[1]); ?></h3>
<p class="main-body-white-col-p">€<?php xss ($row[2]); ?></p>
</div>
</div>
</div>
</div>
<?php
} //end for loop
?>
</div>
</div>
<div class="col-sm-3">
<div class="main-body-first-col">
<h3>New</h3>
<?php
$result = mysqli_query($db, "SELECT game_id, title, price, cover_path FROM game order by -release_date limit 2");
for ($i = 0; $i < 2; $i++) {
$row = mysqli_fetch_row($result); ?>
<div class="main-body-white-col">
<div class="container">
<div class="row">
<div class="col-sm-12">
<a href="game.php?q=<?php xss ($row[0]); ?>">
<img class="main-body-img" src="assets/img/games/<?php xss ($row[3]); ?>" alt="The cover for <?php xss ($row[1]); ?>">
</a>
<h3 class="text-black main-body-white-col-h3"><?php xss ($row[1]); ?></h3>
<p class="main-body-white-col-p">€<?php xss ($row[2]); ?></p>
</div>
</div>
</div>
</div>
<?php } //end for loop ?>
</div>
</div>
</div>
</div>
</section>
<?php
//Print footer
require_once('includes/footer.inc.php');
?>
<!-- JQuery JavaScript -->
<script src="assets/js/jquery.min.js"></script>
<!-- Bootstrap JavaScript -->
<script src="assets/js/bootstrap.min.js"></script>
<!-- Custom JS -->
<script src="assets/js/custom.js"></script>
</body>