-
Notifications
You must be signed in to change notification settings - Fork 9
/
level2.php
176 lines (153 loc) · 6.5 KB
/
level2.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
<?php
require( 'config/consts.php' );
session_start();
require_once( DOCUMENT_ROOT . 'classes/LoginHelper.php' );
require_once( DOCUMENT_ROOT . 'config/db.php' );
require( DOCUMENT_ROOT . 'classes/Treasherlocked.php' );
/* Check if the user is logged in */
$loginHelper = new LoginHelper( $db );
if ( !$loginHelper->IsLoggedIn() ) {
$continue = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
header( "Location: " . SITE_URL . "login/?continue=$continue" );
exit;
}
// Check if the event has started
$ts = new Treasherlocked( $db ); // Treasherlocked is the boss
if ( $ts->getEventStatus() == EVENT_NOT_STARTED ) {
header( 'Location: ' . SITE_URL );
exit;
}
$curLevel = $ts->getCurrentLevel(); // Current levels of the user
if ( isset( $_GET['level'] )
&& is_numeric( $_GET['level'] )
&& $_GET['level'] <= $curLevel
) {
$reqLevel = $db->escape( $_GET['level'] ); // Requested level
if ( $reqLevel == 0 && $curLevel == 0 ) {
// Only Faceook users will be forced to like pages
if ( $_SESSION['oauth_type'] == OAUTH_FACEBOOK ) {
require( DOCUMENT_ROOT . 'includes/html/event/facebook_likes.php' );
exit;
} else {
$ts->upgradeLevel( 1 );
header( 'Location: ' . SITE_URL . 'level2/' . $curLevel . '/' );
exit;
}
} elseif ( $reqLevel == 0 && $curLevel != 0) {
header( 'Location: ' . SITE_URL . 'level2/' . $curLevel . '/' );
exit;
}
} else {
if ( $curLevel > NO_OF_LEVELS )
require( DOCUMENT_ROOT . 'includes/html/event/finished.php' );
else
header( 'Location: ' . SITE_URL . 'level2/' . $curLevel . '/' );
exit;
}
// TBD: Check DIVERGENCE && CONVERGENCE
// Load questions
$question = $ts->getQuestion( $reqLevel );
$favicon = ( isset( $question['favicon'] ) ) ? $question['favicon']: false;
var_dump( $question ); var_dump( $favicon ); exit;
/* Begin Page Rendering */
$page = NON_NAV;
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<?php if ( $favicon ) :?>
<link rel="shortcut icon" href="<?php echo SSTATIC . 'img/questions/' . $favicon; ?>" type="image/png">
<link rel="icon" href="<?php echo SSTATIC . 'img/questions/' . $favicon; ?>" type="image/png">
<?php else : ?>
<link rel="shortcut icon" href="<?php echo SSTATIC; ?>favicon.png" type="image/png">
<link rel="icon" href="<?php echo SSTATIC; ?>favicon.png" type="image/png">
<?php endif; ?>
<title>Level <?php echo $reqLevel; ?> - Treasherlocked 2.0 Gameplay</title>
<link href="<?php echo SSTATIC; ?>css/bootstrap.css" rel="stylesheet" />
<link href="<?php echo SSTATIC; ?>css/animate.css" rel="stylesheet" />
<link href="<?php echo SSTATIC; ?>css/base.css" rel="stylesheet" />
<link href="<?php echo SSTATIC; ?>css/game.css" rel="stylesheet" />
<link href="<?php echo SSTATIC; ?>css/queries.css" rel="stylesheet" />
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body id="top">
<?php require( 'includes/html/header.php' ); ?>
<section class="page section-padding">
<div class="container">
<div class="row">
<div class="row box status" id="level-info">
<div class="info">
<div class="level">Level <?php echo $reqLevel; ?></div>
<div class="rank">Rank #<?php echo $ts->getUserRank(); ?></div>
</div>
<div class="progress-bar">
<div class="progress" style="width: <?php echo ( ($curLevel - 1)/NO_OF_LEVELS )*100; ?>%;"></div>
</div>
</div>
<div class="space space-20"></div>
<div class="row box question-box" id="question-box">
<div class="row" id="question">
<?php echo $question['html']; ?>
</div>
<div class="row result wrong-ans" id="wrong-ans">
<h1>Oops!</h1>
<h3>We gotta tell you, that's not correct!</h3>
<a class="btn btn-effect" id="back" href="javascript:void(0);">Back to question</a>
</div>
<div class="row result correct-ans" id="correct-ans">
<h1>Congratulations!</h1>
<h3>That was correct!</h3>
<a class="btn btn-effect" id="back" href="<?php echo SITE_URL; ?>play/">Next question</a>
</div>
</div>
<div class="space space-20"></div>
<?php if ( $reqLevel == $curLevel ) : ?>
<div class="row box answer-box" id="answer-box">
<div class="row">
<form id="mini">
<input type="hidden" name="level" value="<?php echo $curLevel; ?>" />
<input type="text" class="text" id="answer" name="answer" placeholder="Answer" maxlength="254" />
<a class="btn btn-effect inline-block" id="submit" href="javascript:void(0);">Submit</a>
</form>
</div>
</div>
<div class="space space-20"></div>
<?php else: ?>
<div class="row text-center">
<a class="btn btn-effect" href="<?php echo SITE_URL; ?>level/<?php echo $curLevel; ?>/">Go to current level</a>
</div>
<?php endif; ?>
<div class="row box disqus" id="disqus">
<div id="disqus_thread"></div>
<script type="text/javascript">
var disqus_shortname = 'treasherlocked2-0';
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
</div>
</div>
</div>
</section>
<!--FOOTER-->
<?php require('includes/html/footer.php'); ?>
<!-- /FOOTER -->
<script type="text/javascript" src="<?php echo SSTATIC; ?>js/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="<?php echo SSTATIC; ?>js/jquery-ui-1.10.4.min.js"></script>
<script type="text/javascript" src="<?php echo SSTATIC; ?>js/bootstrap.min.js" ></script>
<script type="text/javascript" src="<?php echo SSTATIC; ?>js/smooth-scroll.js"></script>
<script type="text/javascript" src="<?php echo SSTATIC; ?>js/jquery.nicescroll.js"></script>
<script type="text/javascript" src="<?php echo SSTATIC; ?>js/wow.min.js"></script>
<script type="text/javascript" src="<?php echo SSTATIC; ?>js/init.js"></script>
<script type="text/javascript" src="<?php echo SSTATIC; ?>js/init_level.js"></script>
<?php require('includes/html/tracking.php'); ?>
</body>
</html>