forked from Teamexe/Paradox-2017
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparadox.php
executable file
·155 lines (140 loc) · 5.62 KB
/
paradox.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="google-signin-client_id" content="307712715810-5gqv439ef8l9hmmod3ggpbdplcc7t7gq.apps.googleusercontent.com">
<meta name="description" content="Paradox - Team .EXE is the technical team of Computer Science & Engineering Department for technical fest NIMBUS at NIT Hamirpur.">
<meta name="author" content="Team .EXE">
<link rel="icon" href="images/head.png">
<meta name="description" content="Paradox is an online event by Team .EXE which is the technical team of Computer
Science & Engineering Department at NIT Hamirpur">
<meta name="keywords" content="paradox, paradox nith, paradox team .exe, paradox nimbus, paradox nimbus 2016,
team .exe, exe, NITH , nit hamirpur, CSED, CSED NITH, team exe, paradox, web-o-magica, nimbus nith
nimbus 2016, nimbus 2k16, nit hamirpur, nith">
<meta property="og:title" content="Paradox - Team .EXE">
<meta property="og:image" content="http://exe.nith.ac.in/images/paradox.jpeg">
<meta property="og:description" content="Paradox is an online event by Team .EXE which is the technical team of Computer Science & Engineering Department at NIT Hamirpur">
<title>Paradox - Team .EXE</title>
<style type="text/css">
.demo-card {
padding-top: 20px;
padding-left: 5%;
padding-right: 5%;
padding-bottom: 10px;
}
.panel-body img {
width: 70%;
float: left;
}
</style>
</head>
<?php
include_once('stylesheets.php');
include_once('header.php');
include_once('sessions.php');
include_once('dbconnect.php');
//echo $session_usr;
if(!isset($_SESSION['login_user']))
{
//header("Location:index.php");
echo "<script type='text/javascript'>window.location.href = 'index.php';</script>";
exit();
}
$ab=mysqli_query($link,"SELECT level,name,attempts from users WHERE google_id='$session_usr'");
$out=mysqli_fetch_array($ab);
$l=$out['level'];
$nam=$out['name'];
$atmpt=$out['attempts'];
/*
For debugging the code
echo "\n";
echo $l;
echo $nam;
echo $atmpt;
echo "thsfjklsadfjkl";
*/
$bc=mysqli_query($link,"SELECT * from imag WHERE level=$l");
$out1=mysqli_fetch_array($bc);
$leve=$out1['location'];
if(isset($_POST['ans']))
{
$answer=$_POST['ans'];
//convert to lowercase for matching
$answer=strtolower($answer);
//echo $answer;
++$atmpt;
//echo $atmpt;
//fetching answer
$abc=mysqli_query($link,"SELECT chek from imag WHERE level=$l");
$out3=mysqli_fetch_array($abc);
$ansd=$out3['chek'];
//checking the answer & no. of attempt
if ($answer==$ansd)
{
//increase the level no. & the attempt count
++$l;
$abd=mysqli_query($link,"UPDATE users SET level='$l', attempts='$atmpt' WHERE google_id=$session_usr");
include_once('paradox_right.php');
echo "<center>Well done! Correct answer</center>";
include_once('paradox_bottom.php');
$bc=mysqli_query($link,"SELECT * from imag WHERE level=$l");
$out1=mysqli_fetch_array($bc);
$leve=$out1['location'];
}
else
{
//increase attempt count only
$abd=mysqli_query($link,"UPDATE users SET attempts='$atmpt' WHERE google_id=$session_usr");
//checking if message is empty/not
if ($answer)
{
include_once('paradox_wrong.php');
echo "<center>Wrong Answer : Try again!</center>";
include_once('paradox_bottom.php');
}
else
{
include_once('paradox_wrong.php');
echo "<center>Submitting answer without entering value is increasing your no. of attempts. It really matters.</center>";
include_once('paradox_bottom.php');
}
}
}
?>
<div class="demo-card">
<div class="panel panel-info">
<div class="panel-heading">
<h3 class="panel-title">Paradox Level #<?php echo $l; ?><span style="float: right"><?php echo $nam; ?></span>
</h3>
</div>
<div class="panel-body">
<?php
//echo '<pre>Your Total Attempts - '.$atmpt.'</pre>';
if ($l==17)
{
echo "Congratulations, Paradox completed\n";
}
else
{
echo "<img src=".$leve." />";
}
echo ' <a href="instructions.php"><button class="btn btn-default" > View Paradox - Instructions </button></a>';
echo "<br><br>";
echo ' <a href="leaderboard.php"><button class="btn btn-default" > View Paradox - Leaderboard </button></a>';
echo "<br><br>";
echo ' <a href="hints.php"><button class="btn btn-default" > View Paradox - Hints </button></a>';
?>
</div>
<div class="panel-footer">
<form action="" method="post">
<input type="text" name="ans">
<input class="btn" type="submit" value="Submit Answer">
</form>
</div>
</div>
</div>
<?php
include_once('footer.php');
?>