-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlevel.php
93 lines (78 loc) · 2.84 KB
/
level.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
<?php
// Start Session
if (!isset($_SESSION)) {
session_start();
}
require_once("lib/config_local.php");
// Gets level progress information from user
// If not logged in defaults to 1 for level 1
if (isset($_SESSION['SESS_MEMBER_ID']) && isset($_SESSION['SESS_USERNAME'])) {
// Get user info
$id = $_SESSION['SESS_MEMBER_ID'];
$user = $_SESSION['SESS_USERNAME'];
// Connect to db
$link = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_DATABASE) or die ("Failed to connect to server " . mysqli_error());
// Get level info
$qry = "SELECT * FROM members where id='" . $id . "' AND username='" . $user . "'";
$result = mysqli_query($link, $qry);
$member = mysqli_fetch_assoc($result);
$level = $member['level'];
} else {
$level = 1;
}
// Sets session level variable
$_SESSION['level'] = $level;
?>
<!DOCTYPE html>
<html>
<head>
<!-- Local Stylesheets -->
<link rel="stylesheet" href="css/base.css">
<link rel="stylesheet" href="css/2048theme.css">
<!-- 3rd Party Stylesheets + Icon Font -->
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<!-- 3rd Party JS libraries -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquerymobile/1.4.5/jquery.mobile.js"></script>
<!-- Local JS -->
<script src="scripts/menus.js"></script>
<!-- Adjust screen nicely for mobile-->
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<title>SwipeAway - Level Select</title>
</head>
<body>
<div id="topBar">
<a name="link" href="index.php" id="icon" rel="external"><i class="material-icons">arrow_back</i></a>
</div>
<div id="subTitle">
<h1>Level</h1>
</div>
<div id="levels">
<?php
// Loops through levels to see if they are unlocked
// If unlocked, link to level page; if locked, link nowhere
for ($i = 1; $i <= 3; $i++) {
if ($i <= $level) {
echo '<a name="link" href="level' .$i. '.php" class="level" id="level' .$i. '" rel="external">' .$i. '</a>';
} else {
echo '<a class="level" id="level' .$i. '" rel="external"><img src="images/lock.png"></a>';
}
}
?>
</div>
<div id="endless">
<?php
// Checks to see if endless mode is unlocked
// If user $level is less equal to 4, the level is unlocked
// If user $level is less than 4, endless is locked
if ($level == 4) {
echo '<a name="link" id="endlessBtn" href="endless.php" rel="external">∞ Endless</a>';
} else {
echo '<a id="endlessBtn" rel="external"><img src="images/lock.png"> Endless</a>';
}
?>
</div>
<audio preload="auto" id="audioClick" src="audio/tick.ogg">
</body>
</html>