forked from jschildgen/sql-island
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDB.class.php
413 lines (336 loc) · 18.4 KB
/
DB.class.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
<?php
require_once("Exercise.class.php");
require_once("Lang.class.php");
if(isset($_GET['del'])) {
DB::deleteOldDBs();
}
class DB {
private $dbID = null;
private $db = null;
public static $MODE_SIMULATE = "SIMULATION";
function __construct($dbID = null) {
$this->DB($dbID);
}
public function DB($dbID = null) {
if($dbID == null) {
/* create new database instance */
DB::deleteOldDBs();
$randID = DB::generateRandomString();
$this->dbID = $randID;
$this->db = new PDO("sqlite:DBs/".$randID.".sqlite");
$this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);
$this->init_db();
//DB::generateTable($this->query("SELECT * FROM DORF"));
} elseif($dbID == DB::$MODE_SIMULATE) {
$this->db = new DBSimulator();
$this->init_db();
} elseif(filesize("DBs/".$dbID.".sqlite")>1024*30) {
/* DB size too big => create new one */
unlink('DBs/'.$dbID.'.sqlite');
DB::deleteOldDBs();
$randID = DB::generateRandomString();
$this->dbID = $randID;
$this->db = new PDO("sqlite:DBs/".$randID.".sqlite");
$this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);
$this->init_db();
} else {
/* use existing database instance */
$this->dbID = $dbID;
$this->db = new PDO("sqlite:DBs/".$dbID.".sqlite");
$this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);
// $this->init_db();
}
}
public static function deleteOldDBs() {
if ($handle = opendir('DBs')) {
$deleteBefore = time() - 60*60*36; // 36 hours
while (false !== ($file = readdir($handle))) {
//if ($file != "." && $file != "..") {
if(substr($file, -7) == ".sqlite") {
$filemtime = filemtime('DBs/'.$file);
if($filemtime < $deleteBefore) {
unlink('DBs/'.$file);
}
}
}
closedir($handle);
}
}
public function getDbID() { return $this->dbID; }
/* code
* -1: error
* 1: correct
*/
public static function respondMsg($code, $msg = null, $result = null) {
$toJson["code"] = $code;
if($msg != null) { $toJson["msg"] = $msg; }
if($result != null) { $toJson["result"] = $result; }
return $toJson;
}
public function query($query, $readonly = FALSE, $exercise = null) {
$makesResult = TRUE;
$q = trim($query);
$semipos = strpos($q, ";");
if($semipos !== FALSE) {
$q = substr($q, 0, $semipos);
}
/* No SELECT query */
if(strtoupper(substr($q, 0, 7)) != "SELECT ") {
$makesResult = FALSE;
}
/* multiple queries (not possible anymore because everything after ; is cut */
if(strpos($q, ";") !== FALSE) {
return DB::respondMsg(-1, Lang::txt("Es ist nicht erlaubt, mehrere Anfragen auf einmal auszuführen."));
}
//if($query == "X") { return DB::respondMsg(1, 'Hey, Schummler!'); }
$begin = strtoupper(substr($q, 0, 7));
if($begin != "SELECT " && $begin != "INSERT " && $begin != "UPDATE " && $begin != "DELETE ") {
return DB::respondMsg(-1, Lang::txt("Erlaubt sind nur SELECT-, INSERT-, UPDATE- und DELETE-Anfragen."));
}
if(!$makesResult && $readonly) {
return DB::respondMsg(-1, Lang::txt("Es sind nur SELECT-Anfragen erlaubt."));
}
if(strlen($q) > 1500) {
return DB::respondMsg(-1, Lang::txt("Wofür brauchst du so eine lange Anfrage?"));
}
if(stripos($q, "SELECT ") !== FALSE && stripos($q, "INSERT ") !== FALSE) {
return DB::respondMsg(-1, Lang::txt("INSERT-SELECT-Kombinationen sind hier nicht erlaubt."));
}
if(!$makesResult) {
$this->db->exec("BEGIN TRANSACTION");
$this->db->exec($q);
$error = $this->db->errorInfo();
if(strlen($error[2]) < 2) {
if($exercise != null && !$exercise->getSolved() && $exercise->getSolution() != null && $exercise->getUpdates() == FALSE) {
$this->db->exec("ROLLBACK");
return DB::respondMsg(0, Lang::txt("Was machst du da eigentlich?"));
}
$validationError = $this->isCorrect($exercise, $q);
if($validationError == "") {
$this->db->exec("COMMIT");
return DB::respondMsg(1, Lang::txt("Yeah")."!");
} else {
$this->db->exec("ROLLBACK");
return DB::respondMsg(-1, $validationError);
}
} else {
$this->db->exec("ROLLBACK");
return DB::respondMsg(-1, Lang::txt("Fehler").': '.$error[2]);
}
}
$result = $this->db->query($q);
if($result) {
$validationError = $this->isCorrect($exercise, $q);
if($validationError == "") {
return DB::respondMsg(1, Lang::txt("Yeah")."!", DB::resultsetToArray($result));
} else {
return DB::respondMsg(-1, $validationError, DB::resultsetToArray($result));
}
} else {
$error = $this->db->errorInfo();
return DB::respondMsg(-1, Lang::txt("Fehler").': '.$error[2]);
}
}
/**
* @returns
* emtpy string: correct
* otherwise: error message
*/
public function isCorrect($exercise, $query) {
if($query == "CHEAT") {
return "";
}
if($exercise == null) {
return;
}
$query = trim($query);
$semipos = strpos($query, ";");
if($semipos !== FALSE) {
$query = substr($query, 0, $semipos);
}
if($exercise->getSolved()) {
return "";
}
if($exercise->getSolution() != null && $exercise->getUpdates() == FALSE) {
$orderPos = stripos($query, "ORDER BY ");
if($orderPos !== FALSE) { $query = substr($query, 0, $orderPos); }
if(!$exercise->getSolved() && strtoupper(substr($query, 0, 7)) != "SELECT ") {
return Lang::txt("Aber was machst du da eigentlich?");
}
$solution = $exercise->getSolution();
$orderPos = stripos($solution, " ORDER BY ");
if($orderPos !== FALSE) { $solution = substr($solution, 0, $orderPos); }
$resultA = $this->db->query("$query EXCEPT $solution");
$resultB = $this->db->query("$solution EXCEPT select * from($query)");
if($resultA && $resultB) {
$rowsA = $resultA->fetchAll();
$nA = count($rowsA);
$rowsB = $resultB->fetchAll();
$nB = count($rowsB);
$hint = "";
if(preg_match('/\'[a-z]*/', $query)) {
$hint = ' '.Lang::txt("Hinweis: Achte bei Werten, die in Anführungszeichen stehen, auf Groß-/Kleinschreibung.");
}
if($nA > 0 && $nB > 0) {
return Lang::txt("Es kommen falsche Zeilen raus.").$hint;
}
elseif($nB > 0) {
return Lang::txt("Da fehlen noch ein Paar Zeilen.").$hint;
}
elseif($nA > 0) {
return Lang::txt("Es kommen zu viele Zeilen raus.").$hint;
}
return "";
} else {
$error = $this->db->errorInfo();
$error_msg = $error[2];
if(strpos($error_msg, "do not have the same number of result columns") !== FALSE) {
return Lang::txt("Die Spalten sind falsch.");
}
return $error_msg;
}
}
elseif($exercise->getVerificationQuery() != "") {
$result = $this->db->query($exercise->getVerificationQuery());
if($result) {
$rows = $result->fetchAll();
$n = count($rows);
if($n == $exercise->getVerificationCount()) {
return "";
} else {
return Lang::txt("Oh oh... Entweder du hast zu viele oder zu wenige Änderungen durchgeführt.");
}
} else {
$error = $this->db->errorInfo();
$error_msg = $error[2];
return $error_msg;
}
}
return ":-(";
}
public function getPlayerName() {
if($this->db == null) { return null; }
$result = $this->db->query("SELECT ".Lang::txt("name")." AS name FROM ".Lang::txt("bewohner")." WHERE ".Lang::txt("bewohnernr")." = 20");
if($result == FALSE) { return null; }
foreach($result as $row) {
return $row['name'];
}
return null;
}
//@Deperecated
private static function generateTable($result) {
if($result == null) { return ""; }
if($result == "OK") { return "OK"; }
$html = '<table border="1">';
$html .= "<tr>";
for($i = 0; $i < $result->columnCount(); $i++) {
$col = $result->getColumnMeta($i);
$html .= "<td><b>".$col['name']."</b></td>";
}
$html .= "</tr>";
$numrows = 0;
foreach($result as $row) {
$numrows++;
if($numrows > 100) { break; }
$html .= "<tr>";
foreach($row as $col => $value) {
if(!is_numeric($col)) {
$html .= "<td>$value</td>";
}
}
$html .= "</tr>";
}
$html .= "</table>";
return $html;
}
private static function resultsetToArray($result) {
if($result == null) { return null; }
if($result == "OK") { return null; }
$table = array();
/* start with metadata (column names) */
$rowdata = array();
for($i = 0; $i < $result->columnCount(); $i++) {
$col = $result->getColumnMeta($i);
$rowdata[] = $col['name'];
}
$table[] = $rowdata;
$numrows = 0;
/* data */
foreach($result as $row) {
$numrows++;
if($numrows > 100) { break; }
$rowdata = array();
foreach($row as $col => $value) {
if(!is_numeric($col)) {
$rowdata[] = $value;
}
}
$table[] = $rowdata;
}
return $table;
}
public function log($log) {
file_put_contents("./Logs/".$this->dbID.".log.sql", $log."\n", FILE_APPEND);
}
public function sqlTable($query) {
return DB::generateTable($this->query($query));
}
private function init_db() {
$this->db->exec("PRAGMA max_page_count = 30"); // DB size max. 30 KB
$this->db->exec("CREATE TABLE ".Lang::txt("dorf")." (".Lang::txt("dorfnr")." INT PRIMARY KEY, ".Lang::txt("name")." VARCHAR(31),".Lang::txt("haeuptling")." INT);");
$this->db->exec("INSERT INTO ".Lang::txt("dorf")."(".Lang::txt("dorfnr").",".Lang::txt("name").",".Lang::txt("haeuptling").") VALUES (1, '".Lang::txt("Affenstadt")."', 1);");
$this->db->exec("INSERT INTO ".Lang::txt("dorf")."(".Lang::txt("dorfnr").",".Lang::txt("name").",".Lang::txt("haeuptling").") VALUES (2, '".Lang::txt("Gurkendorf")."', 6)");
$this->db->exec("INSERT INTO ".Lang::txt("dorf")."(".Lang::txt("dorfnr").",".Lang::txt("name").",".Lang::txt("haeuptling").") VALUES (3, '".Lang::txt("Zwiebelhausen")."', 13);");
$this->db->exec("CREATE TABLE ".Lang::txt("bewohner")." (".Lang::txt("bewohnernr")." INTEGER PRIMARY KEY AUTOINCREMENT, ".Lang::txt("name")." VARCHAR(50),".Lang::txt("dorfnr")." INT,".Lang::txt("geschlecht")." CHAR(1),".Lang::txt("beruf")." VARCHAR(31),".Lang::txt("gold")." INT,".Lang::txt("status")." VARCHAR(31));");
$this->db->exec("INSERT INTO ".Lang::txt("bewohner")." (".Lang::txt("name").",".Lang::txt("dorfnr").",".Lang::txt("geschlecht").",".Lang::txt("beruf").",".Lang::txt("gold").",".Lang::txt("status").") VALUES('".Lang::txt("Paul Backmann")."', 1, '".Lang::txt("m")."', '".Lang::txt("Baecker")."', 850, '".Lang::txt("friedlich")."');");
$this->db->exec("INSERT INTO ".Lang::txt("bewohner")." (".Lang::txt("name").",".Lang::txt("dorfnr").",".Lang::txt("geschlecht").",".Lang::txt("beruf").",".Lang::txt("gold").",".Lang::txt("status").") VALUES('".Lang::txt("Ernst Peng")."', 3, '".Lang::txt("m")."', '".Lang::txt("Waffenschmied")."', 280, '".Lang::txt("friedlich")."');");
$this->db->exec("INSERT INTO ".Lang::txt("bewohner")." (".Lang::txt("name").",".Lang::txt("dorfnr").",".Lang::txt("geschlecht").",".Lang::txt("beruf").",".Lang::txt("gold").",".Lang::txt("status").") VALUES('".Lang::txt("Rita Ochse")."', 1, '".Lang::txt("w")."', '".Lang::txt("Baecker")."', 350, '".Lang::txt("friedlich")."');");
$this->db->exec("INSERT INTO ".Lang::txt("bewohner")." (".Lang::txt("name").",".Lang::txt("dorfnr").",".Lang::txt("geschlecht").",".Lang::txt("beruf").",".Lang::txt("gold").",".Lang::txt("status").") VALUES('".Lang::txt("Carl Ochse")."', 1, '".Lang::txt("m")."', '".Lang::txt("Kaufmann")."', 250, '".Lang::txt("friedlich")."');");
$this->db->exec("INSERT INTO ".Lang::txt("bewohner")." (".Lang::txt("name").",".Lang::txt("dorfnr").",".Lang::txt("geschlecht").",".Lang::txt("beruf").",".Lang::txt("gold").",".Lang::txt("status").") VALUES('".Lang::txt("Dirty Dieter")."', 3, '".Lang::txt("m")."', '".Lang::txt("Schmied")."', 650, '".Lang::txt("boese")."');");
$this->db->exec("INSERT INTO ".Lang::txt("bewohner")." (".Lang::txt("name").",".Lang::txt("dorfnr").",".Lang::txt("geschlecht").",".Lang::txt("beruf").",".Lang::txt("gold").",".Lang::txt("status").") VALUES('".Lang::txt("Gerd Schlachter")."', 2, '".Lang::txt("m")."', '".Lang::txt("Metzger")."', 4850, '".Lang::txt("boese")."');");
$this->db->exec("INSERT INTO ".Lang::txt("bewohner")." (".Lang::txt("name").",".Lang::txt("dorfnr").",".Lang::txt("geschlecht").",".Lang::txt("beruf").",".Lang::txt("gold").",".Lang::txt("status").") VALUES('".Lang::txt("Peter Schlachter")."', 3, '".Lang::txt("m")."', '".Lang::txt("Metzger")."', 3250, '".Lang::txt("boese")."');");
$this->db->exec("INSERT INTO ".Lang::txt("bewohner")." (".Lang::txt("name").",".Lang::txt("dorfnr").",".Lang::txt("geschlecht").",".Lang::txt("beruf").",".Lang::txt("gold").",".Lang::txt("status").") VALUES('".Lang::txt("Arthur Schneiderpaule")."', 2, '".Lang::txt("m")."', '".Lang::txt("Pilot")."', 490, '".Lang::txt("gefangen")."');");
$this->db->exec("INSERT INTO ".Lang::txt("bewohner")." (".Lang::txt("name").",".Lang::txt("dorfnr").",".Lang::txt("geschlecht").",".Lang::txt("beruf").",".Lang::txt("gold").",".Lang::txt("status").") VALUES('".Lang::txt("Tanja Trommler")."', 1, '".Lang::txt("w")."', '".Lang::txt("Baecker")."', 550, '".Lang::txt("boese")."');");
$this->db->exec("INSERT INTO ".Lang::txt("bewohner")." (".Lang::txt("name").",".Lang::txt("dorfnr").",".Lang::txt("geschlecht").",".Lang::txt("beruf").",".Lang::txt("gold").",".Lang::txt("status").") VALUES('".Lang::txt("Peter Trommler")."', 1, '".Lang::txt("m")."', '".Lang::txt("Schmied")."', 600, '".Lang::txt("friedlich")."');");
$this->db->exec("INSERT INTO ".Lang::txt("bewohner")." (".Lang::txt("name").",".Lang::txt("dorfnr").",".Lang::txt("geschlecht").",".Lang::txt("beruf").",".Lang::txt("gold").",".Lang::txt("status").") VALUES('".Lang::txt("Dirty Doerthe")."', 3, '".Lang::txt("w")."', '".Lang::txt("Erntehelfer")."', 10, '".Lang::txt("boese")."');");
$this->db->exec("INSERT INTO ".Lang::txt("bewohner")." (".Lang::txt("name").",".Lang::txt("dorfnr").",".Lang::txt("geschlecht").",".Lang::txt("beruf").",".Lang::txt("gold").",".Lang::txt("status").") VALUES('".Lang::txt("Otto Armleuchter")."', 2, '".Lang::txt("m")."', '".Lang::txt("Haendler")."', 680, '".Lang::txt("friedlich")."');");
$this->db->exec("INSERT INTO ".Lang::txt("bewohner")." (".Lang::txt("name").",".Lang::txt("dorfnr").",".Lang::txt("geschlecht").",".Lang::txt("beruf").",".Lang::txt("gold").",".Lang::txt("status").") VALUES('".Lang::txt("Fritz Dichter")."', 3, '".Lang::txt("m")."', '".Lang::txt("Hoerbuchautor")."', 420, '".Lang::txt("friedlich")."');");
$this->db->exec("INSERT INTO ".Lang::txt("bewohner")." (".Lang::txt("name").",".Lang::txt("dorfnr").",".Lang::txt("geschlecht").",".Lang::txt("beruf").",".Lang::txt("gold").",".Lang::txt("status").") VALUES('".Lang::txt("Enrico Zimmermann")."', 3, '".Lang::txt("m")."', '".Lang::txt("Waffenschmied")."', 510, '".Lang::txt("boese")."');");
$this->db->exec("INSERT INTO ".Lang::txt("bewohner")." (".Lang::txt("name").",".Lang::txt("dorfnr").",".Lang::txt("geschlecht").",".Lang::txt("beruf").",".Lang::txt("gold").",".Lang::txt("status").") VALUES('".Lang::txt("Helga Rasenkopf")."', 2, '".Lang::txt("w")."', '".Lang::txt("Haendler")."', 680, '".Lang::txt("friedlich")."');");
$this->db->exec("INSERT INTO ".Lang::txt("bewohner")." (".Lang::txt("name").",".Lang::txt("dorfnr").",".Lang::txt("geschlecht").",".Lang::txt("beruf").",".Lang::txt("gold").",".Lang::txt("status").") VALUES('".Lang::txt("Irene Hutmacher")."', 1, '".Lang::txt("w")."', '".Lang::txt("Haendler")."', 770, '".Lang::txt("boese")."');");
$this->db->exec("INSERT INTO ".Lang::txt("bewohner")." (".Lang::txt("name").",".Lang::txt("dorfnr").",".Lang::txt("geschlecht").",".Lang::txt("beruf").",".Lang::txt("gold").",".Lang::txt("status").") VALUES('".Lang::txt("Erich Rasenkopf")."', 3, '".Lang::txt("m")."', '".Lang::txt("Metzger")."', 990, '".Lang::txt("friedlich")."');");
$this->db->exec("INSERT INTO ".Lang::txt("bewohner")." (".Lang::txt("name").",".Lang::txt("dorfnr").",".Lang::txt("geschlecht").",".Lang::txt("beruf").",".Lang::txt("gold").",".Lang::txt("status").") VALUES('".Lang::txt("Rudolf Gaul")."', 3, '".Lang::txt("m")."', '".Lang::txt("Hufschmied")."', 390, '".Lang::txt("friedlich")."');");
$this->db->exec("INSERT INTO ".Lang::txt("bewohner")." (".Lang::txt("name").",".Lang::txt("dorfnr").",".Lang::txt("geschlecht").",".Lang::txt("beruf").",".Lang::txt("gold").",".Lang::txt("status").") VALUES('".Lang::txt("Anna Flysh")."', 2, '".Lang::txt("w")."', '".Lang::txt("Metzger")."', 2280, '".Lang::txt("friedlich")."');");
$this->db->exec("CREATE TABLE ".Lang::txt("gegenstand")." (".Lang::txt("gegenstand")." VARCHAR(31) PRIMARY KEY, ".Lang::txt("besitzer")." INT);");
$this->db->exec("INSERT INTO ".Lang::txt("gegenstand")." (".Lang::txt("gegenstand").",".Lang::txt("besitzer").") VALUES ('".Lang::txt("Teekanne")."', NULL);");
$this->db->exec("INSERT INTO ".Lang::txt("gegenstand")." (".Lang::txt("gegenstand").",".Lang::txt("besitzer").") VALUES ('".Lang::txt("Spazierstock")."', 5);");
$this->db->exec("INSERT INTO ".Lang::txt("gegenstand")." (".Lang::txt("gegenstand").",".Lang::txt("besitzer").") VALUES ('".Lang::txt("Hammer")."', 2);");
$this->db->exec("INSERT INTO ".Lang::txt("gegenstand")." (".Lang::txt("gegenstand").",".Lang::txt("besitzer").") VALUES ('".Lang::txt("Ring")."', NULL);");
$this->db->exec("INSERT INTO ".Lang::txt("gegenstand")." (".Lang::txt("gegenstand").",".Lang::txt("besitzer").") VALUES ('".Lang::txt("Kaffeetasse")."', NULL);");
$this->db->exec("INSERT INTO ".Lang::txt("gegenstand")." (".Lang::txt("gegenstand").",".Lang::txt("besitzer").") VALUES ('".Lang::txt("Eimer")."', NULL);");
$this->db->exec("INSERT INTO ".Lang::txt("gegenstand")." (".Lang::txt("gegenstand").",".Lang::txt("besitzer").") VALUES ('".Lang::txt("Seil")."', 17);");
$this->db->exec("INSERT INTO ".Lang::txt("gegenstand")." (".Lang::txt("gegenstand").",".Lang::txt("besitzer").") VALUES ('".Lang::txt("Pappkarton")."', NULL);");
$this->db->exec("INSERT INTO ".Lang::txt("gegenstand")." (".Lang::txt("gegenstand").",".Lang::txt("besitzer").") VALUES ('".Lang::txt("Gluehbirne")."', NULL);");
}
private static function generateRandomString($length = 10) {
$characters = '123456789abcdefghkmnpqrstuvwxyzABCDEFGHKLMNPQRSTUVWXYZ';
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, strlen($characters) - 1)];
}
return $randomString;
}
}
class DBSimulator {
public function DBSimulator() {}
public function exec($query) {
echo $query."\n";
}
}
/*
$e = new Exercise();
$e->setSolution("SELECT gold FROM bewohner");
$db = new DB("PSeGRnn8l4");
//echo $db->isCorrect($e, "SELECT gold FROM bewohner WHERE gold > 100");
echo $db->query("SELECT gold FROM bewohner", FALSE, $e);
*/