-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeohry.php
591 lines (555 loc) · 21 KB
/
geohry.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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
<?
function getVar($arr, $var, $def=null) {
if(!isset($arr) || !is_array($arr)) return $def;
if(!isset($arr[$var])) return $def;
return $arr[$var];
}
function GET($var, $def=null, $empty=false) { return getVar($_GET, $var, $def); }
function GETB($var) { return isset($_GET[$var]); }
function POST($var, $def=null, $empty=false) { return getVar($_POST, $var, $def); }
function SESS($var, $def=null, $empty=false) { return getVar($_SESSION, $var, $def); }
function fGET() {
$keys = func_get_args();
foreach($keys as $key) {
$val = GET($key);
if(is_string($val)) $val = trim($val);
$GLOBALS[$key] = $val;
}
}
function fPOST() {
$keys = func_get_args();
foreach($keys as $key) {
$val = POST($key);
if(is_string($val)) $val = trim($val);
$GLOBALS[$key] = $val;
}
}
function debuglog($data) {
file_put_contents("log/debug.log", var_export($data, true)."\n", FILE_APPEND);
}
include "config.php";
class MySQL extends mysqli {
function __construct() {
parent::__construct(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DB);
}
public $key;
public $debug;
function format($type, $var) {
switch($type) {
case "i":
case "d": return (int)$var;
case "f": return (float)$var;
case "%": return "%";
case "s": return "'".$this->real_escape_string(trim($var))."'";
default: return "''"; break;
}
}
private $args = array();
function buildQuery($query) {
$this->args = func_get_args();
array_shift($this->args);
$callback = function($m) { return $this->format($m[1], array_shift($this->args)); };
$result = preg_replace_callback("/%([^%])/", $callback, $query);
if($this->debug) debuglog($result);
return $result;
}
function runQuery($query) {
$result = $this->query($query);
if($this->error) debuglog($this->error);
return $result;
}
function exec($query) {
$args = func_get_args();
$query = call_user_func_array(array($this, "buildQuery"), $args);
return $this->runQuery($query);
}
function select($query) {
$return = array();
$args = func_get_args();
$query = call_user_func_array(array($this, "buildQuery"), $args);
$result = $this->runQuery($query);
if($result) while($row=$result->fetch_assoc()) {
if($this->key) $return[$row[$this->key]] = $row;
else $return[] = $row;
}
$this->key = null;
return $return;
}
function selectOne($query) {
$args = func_get_args();
$query = call_user_func_array(array($this, "buildQuery"), $args);
$result = $this->runQuery($query);
$return = $result->fetch_assoc();
if($return===null) $return = [];
return $return;
}
function insert($table, $data) {
$keys = array_keys($data);
$atts = []; $types = [];
foreach($keys as $key) {
$i = explode("=", $key);
$atts[] = $i[0];
$types[] = $i[1] ?: "%s";
}
$query = sprintf("INSERT INTO %s (%s) VALUES (%s)", $table, implode(",", $atts), implode(",", $types));
$values = array_values($data);
array_unshift($values, $query);
return call_user_func_array(array($this, "exec"), $values);
}
function update($table, $data, $where) {
$keys = array_keys($data);
foreach($keys as $i=>$key) {
if(strpos($key,"=")===false) $keys[$i].= "=%s";
}
$values = array_values($data);
$query = sprintf("UPDATE %s SET %s WHERE %s LIMIT 1", $table, implode(",",$keys), $where);
array_unshift($values, $query);
return call_user_func_array(array($this, "exec"), $values);
}
}
class Model extends MySQL {
protected $version;
function __construct($version) {
parent::__construct();
$this->version = $version;
}
function fsdata($obj) {
if(is_dir($obj)) return "dir";
else if(is_file($obj)) return "file";
else return "";
}
function registerUser($login, $pass) {
$exists = $this->selectOne("SELECT id FROM logins%d WHERE login=%s", $this->version, $login);
if($exists) return 0;
$this->exec("INSERT INTO logins%d SET login=%s, hash=MD5(%s)", $this->version, $login, $pass);
return md5($pass);
}
function registerGame($game, $pass) {
$game = strtr($game, [".."=>"", "\\"=>""]);
$exists = $this->selectOne("SELECT url FROM games%d WHERE url=%s", $this->version, $game);
if($exists) return 0;
$this->exec("INSERT INTO games%d SET url=%s, hash=MD5(%s)", $this->version, $game, $pass);
mkdir("games/$game");
return md5($pass);
}
function loginUser($login, $pass) {
$exists = $this->selectOne("SELECT hash FROM logins%d WHERE login=%s AND hash=MD5(%s)", $this->version, $login, $pass);
if(!$exists) return "";
return $exists["hash"];
}
function loginGame($game, $pass) {
$exists = $this->selectOne("SELECT hash FROM games%d WHERE url=%s AND hash=MD5(%s)", $this->version, $game, $pass);
if(!$exists) return "";
return $exists["hash"];
}
function approveGame($game, $login, $pass) {
$trusted = $this->selectOne("SELECT trusted FROM logins%d WHERE login=%s AND hash=MD5(%s)", $this->version, $login, $pass);
if(!$trusted || !$trusted["trusted"]) return "";
$this->exec("UPDATE games%d SET approved=%s WHERE url=%s", $this->version, $login, $game);
return "1";
}
function gamesInDistrict($district) {
$demo = "CASE WHEN COALESCE(demo,'')='' THEN 0 ELSE 1 END AS demo";
return json_encode($this->select("SELECT *,$demo FROM games%d WHERE district=%s", $this->version, $district));
}
function approvedGames() {
$demo = "CASE WHEN COALESCE(demo,'')='' THEN 0 ELSE 1 END AS demo";
return json_encode($this->select("SELECT *,$demo FROM games%d WHERE approved!=''", $this->version));
}
function getGame($game, $pass) {
$result = $this->selectOne("SELECT * FROM games%d WHERE url=%s AND hash=%s", $this->version, $game, $pass);
if(!$result) return "";
return json_encode($result);
}
function getDemoGame($game, $demo) {
$result = $this->selectOne("SELECT * FROM games%d WHERE url=%s AND demo=%s", $this->version, $game, $demo);
if(!$result) return "";
return json_encode($result);
}
function setGame($in) {
$keys = ["lat","lng","radius","name","reason","personal","welcome","start","goodbye1","goodbye2","goodbye3","message","demo"];
$data = []; foreach($keys as $key) $data[$key] = $in[$key];
$where = $this->buildQuery("url=%s AND hash=%s", $in["url"], $in["hash"]);
$this->update("games$this->version", $data, $where);
return $this->affected_rows;
}
function verifyGame($url, $hash) {
$found = $this->selectOne("SELECT url FROM games%d WHERE url=%s AND hash=%s", $this->version, $url, $hash);
$result = !empty($found);
if(!$result) header("X-status: unauthorized", true, 404);
return $result;
}
function explForm($in) {
extract($in);
if(!$this->verifyGame($url, $hash)) return "";
$photo = $_FILES["photo"];
$max = $this->selectOne("SELECT MAX(ordnung) AS ordMax FROM questions%d WHERE url=%s", $this->version, $url);
$ordnung = $max ? $max["ordMax"] + 1 : 1;
$uniqid = uniqid("q");
if(!$name) $name = $uniqid;
$data = [
"url" => $url,
"uniqid" => $uniqid,
"ordnung" => $ordnung,
"lat" => $lat,
"lng" => $lng,
"radius" => 20,
"name" => $name,
"type" => "TEXT"
];
$this->insert("questions$this->version", $data);
$data["id"] = $this->insert_id;
move_uploaded_file($photo["tmp_name"], "games/$url/$uniqid.jpg");
return json_encode($data);
}
function getQuestions($game) {
return json_encode($this->select("SELECT * FROM questions%d WHERE url=%s ORDER BY ordnung", $this->version, $game));
}
function getQuestion($game, $uniqid) {
return json_encode($this->selectOne("SELECT * FROM questions%d WHERE url=%s AND uniqid=%s", $this->version, $game, $uniqid));
}
function delQuestion($uniqid, $game, $pass) {
if(!$this->verifyGame($game, $pass)) return "";
$o = $this->selectOne("SELECT ordnung FROM questions%d WHERE uniqid=%s AND url=%s LIMIT 1", $this->version, $uniqid, $game);
$this->exec("DELETE FROM questions%d WHERE url=%s AND uniqid=%s LIMIT 1", $this->version, $game, $uniqid);
$this->exec("UPDATE questions%d SET ordnung=ordnung-1 WHERE url=%s AND ordnung>%d", $this->version, $game, $o["ordnung"]);
if(is_file($file="games/$game/$uniqid.jpg")) unlink($file);
}
function setQuestionsOrder($order, $game, $pass) {
if(!$this->verifyGame($game, $pass)) return "no";
$order = explode(";", $order);
foreach($order as $key=>$val) {
list($o, $uid) = explode(",", $val);
$this->exec("UPDATE questions%d SET ordnung=%d WHERE uniqid=%s LIMIT 1", $this->version, $o, $uid);
}
}
function setQuestion($in) {
extract($in);
if(!$this->verifyGame($game, $pass)) return "no";
if(!$uniqid) $uniqid = uniqid();
if(!isset($answer)) $answer = "";
if(!isset($name) || !$name || strlen($name) == 0) {
$name = "nepojmenovaná otázka";
}
if(!isset($transport) || !$transport || strlen($transport) == 0) {
$transport = "Dostaňte se do červeného kruhu na mapě.";
}
switch($type) {
case "TEXT": $answer = $answerText; break;
case "CHOICE": $answer = $answerChoice; break;
case "NUMBER": $answer = $answerNumber; break;
case "QRCODE": $answer = $answerQRcode; break;
case "QRMAN":
$answer = $answerQRman;
$this->qrmen($uniqid, $game, $answer);
break;
case "QUIZ":
$answer = $answerQuiz;
mkdir("games/$game/$uniqid"); //quiz folder for images
break;
}
$data = [
"lat" => $lat,
"lng" => $lng,
"radius" => $radius,
"transport" => $transport,
"name" => $name,
"question" => $question,
"type" => $type,
"answer" => $answer,
"hint" => $hint,
"after" => $after,
];
if(isset($_FILES["picture"])) {
$pic = $_FILES["picture"];
move_uploaded_file($pic["tmp_name"], "games/$game/$uniqid.jpg");
}
if($isNew) {
$data["uniqid"] = $uniqid;
$data["url"] = $game;
$ord = $this->selectOne("SELECT MAX(ordnung) AS ord FROM questions%d WHERE url=%s", $this->version, $game);
if(!$ord) $ord = ["ord" => 1];
$data["ordnung"] = $ord["ord"] + 1;
$ordnung = $data['ordnung'];
$this->insert("questions$this->version", $data);
}
else {
$where = $this->buildQuery("uniqid=%s", $uniqid);
$this->update("questions$this->version", $data, $where);
}
return $uniqid;
}
function offlineMap($url, $hash, $files) {
if(!$this->verifyGame($url, $hash)) return "no";
if(isset($_FILES["map"])) {
$map = $_FILES["map"];
move_uploaded_file($map["tmp_name"], "games/$url/map.jpg");
}
if(isset($_FILES["data"])) {
$data = $_FILES["data"];
move_uploaded_file($data["tmp_name"], "games/$url/map.dat");
}
//$this->commerce($url, $hash, $commercial);
}
function delOfflineMap($url, $hash) {
if(!$this->verifyGame($url, $hash)) return "no";
if(is_file($f="games/$url/map.jpg")) unlink($f);
if(is_file($f="games/$url/map.dat")) unlink($f);
$this->exec("UPDATE games%d SET commercial=%s WHERE url=%s LIMIT 1", $this->version, "", $url);
}
function offlinePic($url, $hash, $files) {
if(!$this->verifyGame($url, $hash)) return "no";
if(isset($_FILES["intro"])) {
$map = $_FILES["intro"];
move_uploaded_file($map["tmp_name"], "games/$url/intro.jpg");
}
if(isset($_FILES["outro1"])) {
$map = $_FILES["outro1"];
move_uploaded_file($map["tmp_name"], "games/$url/outro1.jpg");
}
if(isset($_FILES["outro2"])) {
$map = $_FILES["outro2"];
move_uploaded_file($map["tmp_name"], "games/$url/outro2.jpg");
}
if(isset($_FILES["outro3"])) {
$map = $_FILES["outro3"];
move_uploaded_file($map["tmp_name"], "games/$url/outro3.jpg");
}
return "done";
}
function deletePic($url, $hash) {
if(!$this->verifyGame($url, $hash)) return "no";
if(is_file($f="games/$url/intro.jpg")) unlink($f);
if(is_file($f="games/$url/outro1.jpg")) unlink($f);
if(is_file($f="games/$url/outro2.jpg")) unlink($f);
if(is_file($f="games/$url/outro3.jpg")) unlink($f);
return "done";
}
function deleteQuestionPic($url, $hash, $picUrl) {
if(!$this->verifyGame($url, $hash)) return "no";
if(is_file($picUrl)) unlink($picUrl);
return "done";
}
function duplicateQuestion($url, $hash, $questionId) {
if(!$this->verifyGame($url, $hash)) return "no";
$q = $this->getQuestion($url, $questionId);
$in = json_decode($q, true);
$in["game"] = $url;
$in["pass"] = $hash;
$in["uniqid"] = NULL;
$in["name"] .= " - kopie";
$in["isNew"] = 1;
switch($in["type"]) {
case "TEXT": $in["answerText"] = $in["answer"]; break;
case "CHOICE": $in["answerChoice"] = $in["answer"]; break;
case "NUMBER": $in["answerNumber"] = $in["answer"]; break;
case "QRCODE": $in["answerQRcode"] = $in["answer"]; break;
case "QRMAN":
$this->qrmen($uniqid, $in["game"], $in["answer"]);
break;
case "QUIZ":
mkdir("games/$in[game]/$uniqid"); //quiz folder for images
break;
}
$qUid = $this->setQuestion($in);
copy("games/$in[game]/$questionId.jpg", "games/$in[game]/$qUid.jpg");
return json_encode($in);
}
function demo($demo, $game) {
$data = $this->selectOne("SELECT url FROM games%d WHERE url=%s AND demo=%s", $this->version, $game, $demo);
echo $data["url"] ? 1 : 0;
}
function storeAnswers($url, $user, $answers) {
$data = $this->selectOne("SELECT MAX(attempt) AS attempt FROM answers%d WHERE user=%s AND url=%s", $this->version, $user, $url);
$attempt = $data ? $data["attempt"] : 0;
$attempt += 1;
foreach($answers as $uniqid=>$points) {
$this->insert("answers$this->version", [
"url" => $url,
"uniqid" => $uniqid,
"user" => $user,
"attempt" => $attempt,
"points" => $points
]);
}
return true;
}
function getAllAnswers($url) {
$result = [];
$data = $this->select("SELECT user, uniqid, GROUP_CONCAT(points ORDER BY attempt) AS data FROM answers%d WHERE url=%s GROUP BY user, uniqid", $this->version, $url);
foreach($data as $item) {
$user = $item["user"];
if(!isset($result[$user])) $result[$user] = [];
$result[$user][$item["uniqid"]] = explode(",", $item["data"]);
}
return json_encode($result);
}
//dirs
function getDirGames($dirId) {
$data = $this->select("SELECT G.* FROM dirGames%d G JOIN dirNames%d N ON N.id = G.dirId WHERE G.dirId = %s", $this->version, $this->version, $dirId);
return json_encode($data);
}
function getGameDirs($gameUrl) {
$data = $this->select("SELECT N.* FROM dirNames%d N JOIN dirGames%d G ON N.id = G.dirId WHERE G.gameUrl = %s", $this->version, $this->version, $gameUrl);
return json_encode($data);
}
function gamesInDir() {
$data = $this->select("SELECT G.* FROM games%d G LEFT JOIN dirGames%d D ON D.gameUrl = G.url WHERE D.dirId IS NOT NULL", $this->version, $this->version);
return json_encode($data);
}
function gamesNotInDir() {
$data = $this->select("SELECT G.* FROM games%d G LEFT JOIN dirGames%d D ON D.gameUrl = G.url WHERE D.dirId IS NULL GROUP BY G.url", $this->version, $this->version);
return json_encode($data);
}
function getGameDetails($gameUrl) {
$data = $this->select("SELECT * FROM games%d WHERE url = %s", $this->version, $gameUrl);
return json_encode($data);
}
//quizes
function getQuizQuestions($quizId) {
$data = $this->select("SELECT * FROM quiz%d WHERE quizUniqid = %s", $this->version, $quizId);
return json_encode($data);
}
function setQuizQuestion($in/*, $quizUniqid, $qName, $qText, $qType, $qAnswer, $qHint*/) {
extract($in);
if(!$uniqid) $uniqid = uniqid();
if(!isset($answer)) $answer = "";
if(!isset($name) || !$name || strlen($name) == 0) {
$name = "nepojmenovaná otázka";
}
switch($type) {
case "TEXT": $answer = $answerText; break;
case "CHOICE": $answer = $answerChoice; break;
case "NUMBER": $answer = $answerNumber; break;
case "QRCODE": $answer = $answerQRcode; break;
case "QRMAN":
$answer = $answerQRman;
$this->qrmen($uniqid, $game, $answer);
break;
}
$data = [
"name" => $name,
"question" => $question,
"type" => $type,
"answer" => $answer,
"hint" => $hint
];
if(isset($_FILES["picture"])) {
$pic = $_FILES["picture"];
move_uploaded_file($pic["tmp_name"], "games/$game/$quizUniqid/$uniqid.jpg");
}
if($isNew) {
$data["id"] = $id;
$data["quizUniqid"] = $quizUniqid;
$data["uniqid"] = $uniqid;
$ord = $this->selectOne("SELECT MAX(ordnung) AS ord FROM quiz%d WHERE quizUniqid=%s", $this->version, $quizUniqid);
if(!$ord) $ord = ["ord" => 1];
$data["ordnung"] = $ord["ord"] + 1;
$this->insert("quiz$this->version", $data);
}
else {
$where = $this->buildQuery("uniqid=%s", $uniqid);
$this->update("quiz$this->version", $data, $where);
}
}
function setQuizQuestionsOrder($order) {
$order = explode(";", $order);
foreach($order as $key=>$val) {
list($o, $uid) = explode(",", $val);
$this->exec("UPDATE quiz%d SET ordnung=%d WHERE uniqid=%s LIMIT 1", $this->version, $o, $uid);
}
}
function delQuizQuestion($uniqid, $quizUniqid, $game) {
$o = $this->selectOne("SELECT ordnung FROM quiz%d WHERE uniqid=%s AND quizUniqid=%s LIMIT 1", $this->version, $uniqid, $quizUniqid);
$this->exec("DELETE FROM quiz%d WHERE quizUniqid=%s AND uniqid=%s LIMIT 1", $this->version, $quizUniqid, $uniqid);
$this->exec("UPDATE quiz%d SET ordnung=ordnung-1 WHERE quizUniqid=%s AND ordnung>%d", $this->version, $quizUniqid, $o["ordnung"]);
if(is_file($file="games/$game/$uniqid.jpg")) unlink($file);
}
function delQuiz($quizUniqid, $game) {
$allQuestions = $this->select("SELECT FROM quiz%d WHERE quizUniqid=%s", $this->version, $quizUniqid);
foreach($allQuestions as $question) {
$uid = $question['uniqid'];
if(is_file($file="games/$game/$quizUniqid/$uid.jpg")) unlink($file);
}
$this->exec("DELETE FROM quiz%d WHERE quizUniqid=%s", $this->version, $quizUniqid);
}
function commerce($url, $hash, $commercial) {
if(!$this->verifyGame($url, $hash)) return "no";
$this->exec("UPDATE games%d SET commercial=%s WHERE url=%s LIMIT 1", $this->version, $commercial, $url);
}
function qrmen($uniqid, $game, $logins) {
$logins = preg_replace('/\s+/', "", $logins);
if(strlen($logins) == 0) {
$this->exec("DELETE FROM qrmen%d WHERE uniqid=%s AND gameUrl=%s", $this->version, $uniqid, $game);
return;
}
$loginsArr = explode(";", $logins);
$existsLogins = $this->select("SELECT login FROM qrmen%d WHERE uniqid=%s AND gameUrl=%s", $this->version, $uniqid, $game);
foreach($existsLogins as $existsLogin) {
$existsLogin = $existsLogin["login"];
if(in_array($existsLogin, $loginsArr)) { //do nothing with no updates logins
if (($key = array_search($existsLogin, $loginsArr)) !== false) {
unset($loginsArr[$key]);
}
} else {
//delete from logins
$this->exec("DELETE FROM qrmen%d WHERE login=%s", $this->version, $existsLogin);
}
}
//add new logins
foreach($loginsArr as $newLoginQrmen) {
if(strlen($newLoginQrmen) > 0) {
$this->insert("qrmen$this->version", [
"uniqid" => $uniqid,
"login" => $newLoginQrmen,
"gameUrl" => $game
]);
}
}
}
function getQrmanQuestions($login) {
$questionsLoginQrMen = $this->select("SELECT * FROM qrmen%d WHERE login=%s", $this->version, $login);
return json_encode($questionsLoginQrMen);
}
function lastUpdate() {
$stat = stat('pages');
$mtime = $stat['mtime'];
return $mtime;
}
function getGameByUrlOnly($url) {
$game = $this->selectOne("SELECT * FROM games%d WHERE url=%s", $this->version, $url);
return json_encode($game);
}
/* feedback */
function addFeedback($login, $answer, $url, $hash) {
if(!$this->verifyGame($url, $hash)) return "no";
$date = date("Y-m-d H:i:s");
$this->insert("feedback$this->version", [
"date" => $date,
"login" => $login,
"answer" => $answer,
"url" => $url
]);
return true;
}
function setFeedback($url, $hash, $feedback, $feedbackOn) {
if(!$this->verifyGame($url, $hash)) return "no";
$this->exec("UPDATE games%d SET feedback=%s, feedbackOn=%s WHERE url=%s", $this->version, $feedback, $feedbackOn, $url);
return true;
}
function getFeedback($login) {
$feedback = $this->selectOne("SELECT * FROM feedback%s WHERE login=%s", $this->version, $login);
return json_encode($feedback);
}
function getAllFeedbacks($url) {
$feedbacks = $this->select("SELECT * FROM feedback%s WHERE url=%s", $this->version, $url);
return json_encode($feedbacks);
}
function removeFeedback($login) {
$this->delete("DELETE FROM feedback%s WHERE login=%s", $this->version, $login);
}
function removeFeedbacks($url) {
$this->delete("DELETE FROM feedback%s WHERE url=%s", $this->version, $url);
}
}
$DB = new Model(4);