zoneadd.php
2.54 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
75
76
<?php
require_once "include.php";
if($user->isAdmin()) {
$arr = array(
'name' => $_POST['name'],
'pri_dns' => $_POST['pri_dns'],
'sec_dns' => $_POST['sec_dns'],
'refresh' => $_POST['refresh'],
'retry' => $_POST['retry'],
'expire' => $_POST['expire'],
'ttl' => $_POST['ttl'],
'owner' => $_POST['owner'],
);
$nz = new masterZone($arr);
if (!$nz->loadZoneHead()) {
$nz->setZoneHead($arr);
$nz->saveZoneHead();
$www = ((isset($_POST['www'])) && ($_POST['www'] >'')) ? $_POST['www'] : NULL;
if ($www){
$type = (filter_var($www, FILTER_VALIDATE_IP)) ? 'A' : 'CNAME';
if ($type == 'A') {
$nz->addRecord(array(
'host' => '@',
'type' => 'A',
'destination' => $www,
));
$nz->addRecord(array(
'host' => 'www',
'type' => 'CNAME',
'destination' => '@',
));
} else {
$nz->addRecord(array(
'host' => 'www',
'type' => 'CNAME',
'destination' => $www,
));
}
}
$ftp = ((isset($_POST['ftp'])) && ($_POST['ftp'] >'')) ? $_POST['ftp'] : NULL;
if ($ftp) {
$type = (filter_var($ftp, FILTER_VALIDATE_IP)) ? 'A' : 'CNAME';
$nz->addRecord(array(
'host' => 'ftp',
'type' => $type,
'destination' => $ftp,
));
}
$mail = ((isset($_POST['mail'])) && ($_POST['mail'] >'')) ? $_POST['mail'] : NULL;
if ($mail) {
$type = (filter_var($mail, FILTER_VALIDATE_IP)) ? 'A' : 'MX';
$destination = ($type == 'A') ? 'mail' : $mail;
if ($type == 'A') {
$nz->addRecord(array(
'host' => 'mail',
'type' => $type,
'destination' => $mail,
));
$type = 'MX';
}
$nz->addRecord(array(
'host' => '@',
'type' => $type,
'destination' => $destination,
'pri' => 10,
));
}
$nz->saveZone();
$user->loadUserZones();
} else {
problem("existzone");
}
}
?>