-
Notifications
You must be signed in to change notification settings - Fork 1
/
interface.php
58 lines (52 loc) · 2.4 KB
/
interface.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
<?php
require_once('runtime.php');
require_once('lib/core/Router.class.php');
require_once('lib/core/Networkinterface.class.php');
require_once('lib/core/NetworkinterfaceStatus.class.php');
if($_GET['section']=='add') {
$router = new Router((int)$_GET['router_id']);
$router->fetch();
if(permission::checkIfUserIsOwnerOrPermitted(PERM_ROOT, $router->getUserId())) {
$smarty->assign('router', $router);
$smarty->display("header.tpl.html");
$smarty->display("interface_add.tpl.html");
$smarty->display("footer.tpl.html");
} else {
Permission::denyAccess(PERM_ROOT, $router->getUserId());
}
} elseif($_GET['section']=='insert_add') {
$router = new Router((int)$_GET['router_id']);
$router->fetch();
if(permission::checkIfUserIsOwnerOrPermitted(PERM_ROOT, $router->getUserId())) {
$networkinterface = new Networkinterface(false, (int)$_GET['router_id'], $_POST['name']);
if($networkinterface->fetch()==false) {
$networkinterface_id = $networkinterface->store();
$networkinterface_status = new NetworkinterfaceStatus(false, (int)Crawling::getLastEndedCrawlCycle()['id'],
(int)$networkinterface_id, (int)$_GET['router_id']);
$networkinterface_status->store();
$message[] = array("Das Netzwerkinterface ".$_POST['name']." wurde hinzugefügt.", 1);
Message::setMessage($message);
header('Location: ./router.php?router_id='.$_GET['router_id']);
} else {
$message[] = array("Das Netzwerkinterface ".$_POST['name']." existiert bereits.", 2);
Message::setMessage($message);
header('Location: ./router.php?router_id='.$_GET['router_id']);
}
} else {
Permission::denyAccess(PERM_ROOT, $router->getUserId());
}
} elseif($_GET['section']=='delete') {
$networkinterface = new Networkinterface((int)$_GET['interface_id']);
$networkinterface->fetch();
if(permission::checkIfUserIsOwnerOrPermitted(PERM_ROOT, $networkinterface->getRouter()->getUserId())) {
if($networkinterface->delete())
$message[] = array("Das Netzwerkinterface ".$networkinterface->getName()." wurde entfernt.", 1);
else
$message[] = array("Das Netzwerkinterface ".$networkinterface->getName()." konnte nicht entfernt werden.", 1);
Message::setMessage($message);
header('Location: ./router.php?router_id='.$networkinterface->getRouterId());
} else {
Permission::denyAccess(PERM_ROOT, $networkinterface->getRouter()->getUserId());
}
}
?>