-
Notifications
You must be signed in to change notification settings - Fork 0
/
sqlhandler.php
52 lines (34 loc) · 844 Bytes
/
sqlhandler.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
<?php
include "config/common.php";
if (isset($_POST['page'])) {
$page = $_POST['page'];
if (strpos($page, '..') !== false) {
$errorMessage = "Invalid request given.";
} else {
$path = 'script/' . $page . '.php';
if (!file_exists($path)) {
$errorMessage = "Invalid request given.";
} else {
include "config/sqlopen.php";
if (!$errorMessage) {
include $path;
}
include "config/sqlclose.php";
}
}
} else {
$errorMessage = "Missing request.";
}
if ($errorMessage) {
switch ($errorMessage) {
case $ERROR_NOT_LOGGED_IN:
$errno = 402;
break;
default:
$errno = 401;
}
print(json_encode(array("code" => $errno, "response" => $errorMessage)));
} else {
print(json_encode(array("code" => 200, "response" => $successMessage)));
}
?>