-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathadminctrl.php
More file actions
74 lines (72 loc) · 2.63 KB
/
adminctrl.php
File metadata and controls
74 lines (72 loc) · 2.63 KB
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
<?php
require_once('includes.php');
if (!isAdmin()) {
echo '{"status": "error", "message": "Keine Berechtigung"}';
} else {
$action = $_GET['action'];
if ($action == 'add') {
$zoom = get_int('zoom');
$lat = get_float('lat');
$lon = get_float('lon');
$name = $_GET['name'];
if ($zoom && $lat && $lon && $name) {
$db = openDB();
if ($db->prepare("INSERT INTO ".$tbl_prefix."regions (category, lat, lon, zoom) VALUES(?, ?, ?, ?)")
->execute(array($name, $lat, $lon, $zoom))) {
$id = $db->lastInsertId();
$result = array(
'status' => 'success',
'message' => "'$name' hinzugefügt.",
'data' => array(
'id' => $id,
'name' => $name,
'lat' => $lat,
'lon' => $lon,
'zoom' => $zoom
)
);
echo json_encode($result);
} else {
echo json_encode(array(
'status' => 'error',
'message' => 'Kategorie konnte nicht hinzugefügt werden.'
));
}
$db = null;
} else {
echo json_encode(array(
'status' => 'error',
'message' => 'Fehlerhafte Eingabe.'
));
}
} else if ($action == 'drop') {
$id = get_int('id');
if ($id) {
$db = openDB();
if ($db->prepare("DELETE FROM ".$tbl_prefix."regions WHERE id = ?")
->execute(array($id))) {
echo json_encode(array(
'status' => 'success',
'message'=> 'Kategorie gelöscht.'
));
} else {
echo json_encode(array(
'status' => 'error',
'message'=> 'Kategorie konnte nicht gelöscht werden.'
));
}
$db = null;
} else {
echo json_encode(array(
'status' => 'error',
'message'=> 'Fehlerhafte Eingabe.'
));
}
} else {
echo json_encode(array(
'status' => 'error',
'message' => 'Unbekannte Aktion.'
));
}
}
?>