-
Notifications
You must be signed in to change notification settings - Fork 0
/
dns_ressource_record.php
53 lines (50 loc) · 2.31 KB
/
dns_ressource_record.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
<?php
require_once('runtime.php');
require_once(ROOT_DIR.'/lib/core/DnsZone.class.php');
require_once(ROOT_DIR.'/lib/core/DnsZoneList.class.php');
require_once(ROOT_DIR.'/lib/core/DnsRessourceRecord.class.php');
if(!isset($_GET['section']) AND isset($_GET['dns_ressource_record_id'])) {
//show ressource record
} elseif($_GET['section'] == 'add') {
if(Permission::checkPermission(PERM_USER)) {
//pass system messages to the template
$smarty->assign('message', Message::getMessage());
$dns_zone_list = new DnsZoneList();
$smarty->assign('dns_zone_list', $dns_zone_list->getDnsZoneList());
//compile the template and sorround the main content by footer and header template
$smarty->display("header.tpl.html");
$smarty->display("dns_ressource_record_add.tpl.html");
$smarty->display("footer.tpl.html");
} else {
Permission::denyAccess(PERM_USER);
}
} elseif($_GET['section'] == 'insert_add') {
if(Permission::checkPermission(PERM_USER)) {
$dns_ressource_record = new DnsRessourceRecord(false, (int)$_POST['dns_zone_id'], (int)$_SESSION['user_id'],
$_POST['host'], $_POST['type'], $_POST['pri'], (int)$_POST['destination']);
if($dns_ressource_record->store()) {
$message[] = array('Der Ressource Record '.$dns_ressource_record->getHost().' wurde gespeichert.', 1);
} else {
$message[] = array('Der Ressource Record konnte nicht gespeichert werden.', 2);
}
Message::setMessage($message);
header('Location: ./dns_zone.php?dns_zone_id='.$_POST['dns_zone_id']);
} else {
Permission::denyAccess(PERM_USER);
}
} elseif($_GET['section'] == 'delete') {
$dns_ressource_record = new DnsRessourceRecord((int)$_GET['dns_ressource_record_id']);
$dns_ressource_record->fetch();
if(permission::checkIfUserIsOwnerOrPermitted(PERM_ROOT, $dns_ressource_record->getUserId())) {
if($dns_ressource_record->delete()) {
$message[] = array('Der Ressource Record '.$dns_ressource_record->getHost().' wurde gelöscht.', 1);
} else {
$message[] = array('Der Ressource Record '.$dns_ressource_record->getHost().' konnte nicht gelöscht werden.', 2);
}
Message::setMessage($message);
header('Location: ./dns_zone.php?dns_zone_id='.$dns_ressource_record->getDnsZoneId());
} else {
Permission::denyAccess(PERM_ROOT, $dns_ressource_record->getUserId());
}
}
?>