-
Notifications
You must be signed in to change notification settings - Fork 1
/
routereditor.php
138 lines (122 loc) · 5.62 KB
/
routereditor.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
<?php
require_once('runtime.php');
require_once('./lib/core/router_old.class.php');
require_once('./lib/core/Router.class.php');
require_once('./lib/core/routereditor.class.php');
require_once('./lib/core/Chipsetlist.class.php');
require_once('./lib/core/ConfigLine.class.php');
require_once('./lib/core/ApiKey.class.php');
$smarty->assign('google_maps_api_key', $GLOBALS['google_maps_api_key']);
if ($_GET['section'] == "new") {
//Logged in users can add a new router
if(Permission::checkPermission(PERM_USER)) {
$smarty->assign('message', Message::getMessage());
$smarty->assign('google_maps_api_key', ConfigLine::configByName('google_maps_api_key'));
$smarty->assign('community_location_longitude', ConfigLine::configByName('community_location_longitude'));
$smarty->assign('community_location_latitude', ConfigLine::configByName('community_location_latitude'));
$smarty->assign('community_location_zoom', ConfigLine::configByName('community_location_zoom'));
$smarty->assign('twitter_token', ConfigLine::configByName('twitter_token'));
$chipsetlist = new Chipsetlist(false, false, 0, -1);
$smarty->assign('chipsetlist', $chipsetlist->getList());
$smarty->display("header.tpl.html");
$smarty->display("router_new.tpl.html");
$smarty->display("footer.tpl.html");
} else {
Permission::denyAccess(PERM_USER);
}
}
if ($_GET['section'] == "insert") {
//Logged in users can add a new router
if(Permission::checkPermission(PERM_USER)) {
$insert_result = RouterEditor::insertNewRouter();
if($insert_result['result']) {
header('Location: ./router.php?router_id='.$insert_result['router_id']);
} else {
header("Location: ./routereditor.php?section=new&router_auto_assign_login_string=$_POST[router_auto_assign_login_string]&hostname=$_POST[hostname]");
}
} else {
Permission::denyAccess(PERM_USER);
}
}
if ($_GET['section'] == "edit") {
$router_data = Router_old::getRouterInfo($_GET['router_id']);
$smarty->assign('router_data', $router_data);
//Moderator and owning user can edit router
if(permission::checkIfUserIsOwnerOrPermitted(PERM_ROOT, (int)$router_data['user_id'])) {
$smarty->assign('community_location_longitude', Config::getConfigValueByName('community_location_longitude'));
$smarty->assign('community_location_latitude', Config::getConfigValueByName('community_location_latitude'));
$smarty->assign('community_location_zoom', Config::getConfigValueByName('community_location_zoom'));
$smarty->assign('message', Message::getMessage());
$smarty->assign('is_root', Permission::checkPermission(PERM_ROOT));
/** Get and assign Router Informations **/
$chipsetlist = new Chipsetlist(false, false, 0, -1);
$smarty->assign('chipsetlist', $chipsetlist->getList());
$smarty->display("header.tpl.html");
$smarty->display("router_edit.tpl.html");
$smarty->display("footer.tpl.html");
} else {
Permission::denyAccess(PERM_ROOT, (int)$router_data['user_id']);
}
}
if ($_GET['section'] == "insert_edit") {
//Moderator and owning user can edit router
$router_data = Router_old::getRouterInfo($_GET['router_id']);
if(permission::checkIfUserIsOwnerOrPermitted(PERM_ROOT, (int)$router_data['user_id'])) {
$insert_result = RouterEditor::insertEditRouter();
if($insert_result) {
header('Location: ./router.php?router_id='.$_GET['router_id']);
} else {
header('Location: ./routereditor.php?section=edit&router_id='.$_GET['router_id']);
}
} else {
Permission::denyAccess(PERM_ROOT, (int)$router_data['user_id']);
}
}
if ($_GET['section'] == "insert_edit_hash") {
$router_data = Router_old::getRouterInfo($_GET['router_id']);
if(permission::checkIfUserIsOwnerOrPermitted(PERM_ROOT, (int)$router_data['user_id'])) {
$insert_result = RouterEditor::insertEditHash($_GET['router_id'], $_POST['router_auto_assign_hash']);
if($insert_result) {
header('Location: ./router.php?router_id='.$_GET['router_id']);
} else {
header('Location: ./routereditor.php?section=edit&router_id='.$_GET['router_id']);
}
header('Location: ./router.php?router_id='.$_GET['router_id']);
} else {
Permission::denyAccess(PERM_ROOT, (int)$router_data['user_id']);
}
}
if ($_GET['section'] == "insert_reset_auto_assign_hash") {
$router_data = Router_old::getRouterInfo($_GET['router_id']);
if(permission::checkIfUserIsOwnerOrPermitted(PERM_ROOT, (int)$router_data['user_id'])) {
$insert_result = RouterEditor::resetRouterAutoAssignHash($_GET['router_id']);
header('Location: ./routereditor.php?section=edit&router_id='.$_GET['router_id']);
} else {
Permission::denyAccess(PERM_ROOT, (int)$router_data['user_id']);
}
}
if ($_GET['section'] == "insert_delete") {
$router = new Router((int)$_GET['router_id']);
$router->fetch();
//Root and owning user can delete router
if(permission::checkIfUserIsOwnerOrPermitted(PERM_ROOT, $router->getUserId())) {
if($_POST['really_delete']==1) {
if($router->delete()) {
$message[] = array("Der Router ".$router->getHostname()." wurde entfernt.", 1);
Message::setMessage($message);
header('Location: ./user.php?user_id='.$_SESSION['user_id']);
} else {
$message[] = array("Der Router konnte nicht entfernt werden.", 2);
Message::setMessage($message);
header('Location: ./routereditor.php?section=edit&router_id='.$_GET['router_id']);
}
} else {
$message[] = array("Zum löschen des Routers ist eine Bestätigung erforderlich!", 2);
Message::setMessage($message);
header('Location: ./routereditor.php?section=edit&router_id='.$_GET['router_id']);
}
} else {
Permission::denyAccess(PERM_ROOT, (int)$router_data['user_id']);
}
}
?>