-
Notifications
You must be signed in to change notification settings - Fork 1
/
syncout.php
141 lines (98 loc) · 4.53 KB
/
syncout.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
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once("include/mysq.php"); //conatins connection information
require_once("include/func.php");
require_once("include/sign2.php");
require_once("include/glob.php");
session_start();
if (!isset($conn))
die("Unable to connect to mysql"); //checks whether connection is possible
else {
$retval = mysqli_query($conn, "select status from pagecontrol where page='syncout'");
if (!$retval) {
die('ERROR:' . $retval->errorno);
}
if (mysqli_num_rows($retval) == 1) { //TODO also check if team is blocked
$row = mysqli_fetch_assoc($retval);
if ($row['status'] == 0 && isset($_POST['OK']) && isset($_SESSION['teamid'])) {
if ((!isset($_POST['level'])) || (!isset($_POST['qstnno'])) || (!isset($_POST['qry'])))
die("ERR:142");
$level = $_POST['level'];
$team = $_SESSION['teamid'];
$qno = $_POST['qstnno'];
$dat = $_POST['qry'];
$lan = $_SESSION['lang'];
if ($dat == "qs") {
$qry = "select quest from questions where tlevel=$level and qno=$qno and lang='$lan'";
//echo $qry;
$ret4 = mysqli_query($conn, $qry);
//echo $qry;
if (!$ret4)
die("ERR:13");
if (mysqli_num_rows($ret4) == 1) { //gets question
$row = mysqli_fetch_assoc($ret4);
$blb = $row['quest'];
echo $blb;
die();
} else if (mysqli_num_rows($ret4) == 0) {
die();
}
else
die("ERR:14");
} else if ($dat == "dt") {
$qry = "select dat from sync where tlevel=$level and qno=$qno and teamid=$team";
//echo $qry;
$ret4 = mysqli_query($conn, $qry);
//echo $qry;
if (!$ret4)
die("ERR:113");
if (mysqli_num_rows($ret4) == 1) { //gets gets stired data
$row = mysqli_fetch_assoc($ret4);
$blb = $row['dat'];
if (isset($blb))
echo $blb;
die();
} else if (mysqli_num_rows($ret4) == 0) {
die();
} else
die("ERR:114");
} else if ($dat == "df") { //default values
$qry = "select dvalues from questions where tlevel=$level and qno=$qno and lang='$lan'"; //TODO check the code here
//echo $qry;
$ret4 = mysqli_query($conn, $qry);
//echo $qry;
if (!$ret4)
die("ERR:113");
if (mysqli_num_rows($ret4) == 1) { //gets default value
$row = mysqli_fetch_assoc($ret4);
$blb = $row['dvalues'];
if (isset($blb))
echo $blb;
die();
} else if (mysqli_num_rows($ret4) == 0) {
die();
} else
die("ERR:114");
}
else if ($dat == "st") { //default values
$qry = "select status from correct where tlevel=$level and qno=$qno and teamid=$team"; //Any simple query
//echo $qry;
$ret4 = mysqli_query($conn, $qry);
//echo $qry;
if (!$ret4)
die("ERR:313");
if (mysqli_num_rows($ret4) == 1) { //gets default value
die("PA");
} else if (mysqli_num_rows($ret4) == 0) {
die("UN");
} else
die("ERR:154");
} else
die("ERR:451");
} else
die("ERR:213");
} else
die("ERR:47");
}
?>