Skip to content

Commit 361f0ec

Browse files
committed
dns add domain page
1 parent 74d0ad1 commit 361f0ec

File tree

5 files changed

+169
-2
lines changed

5 files changed

+169
-2
lines changed

web/add/dns/index.php

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
<?php
2+
// Init
3+
error_reporting(NULL);
4+
ob_start();
5+
session_start();
6+
$TAB = 'DNS';
7+
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
8+
9+
// Header
10+
include($_SERVER['DOCUMENT_ROOT'].'/templates/header.html');
11+
12+
// Panel
13+
top_panel($user,$TAB);
14+
15+
// Are you admin?
16+
if ($_SESSION['user'] == 'admin') {
17+
18+
// Cancel
19+
if (!empty($_POST['cancel'])) {
20+
header("Location: /list/dns/");
21+
}
22+
23+
// Action
24+
if (!empty($_POST['ok'])) {
25+
// Check input
26+
if (empty($_POST['v_domain'])) $errors[] = 'domain';
27+
if (empty($_POST['v_ip'])) $errors[] = 'ip';
28+
if (empty($_POST['v_template'])) $errors[] = 'template';
29+
if (empty($_POST['v_exp'])) $errors[] = 'expiriation date';
30+
if (empty($_POST['v_soa'])) $errors[] = 'SOA';
31+
if (empty($_POST['v_ttl'])) $errors[] = 'TTL';
32+
33+
// Protect input
34+
$v_domain = preg_replace("/^www./i", "", $_POST['v_domain']);
35+
$v_domain = escapeshellarg($v_domain);
36+
$v_ip = escapeshellarg($_POST['v_ip']);
37+
$v_template = escapeshellarg($_POST['v_template']);
38+
$v_exp = escapeshellarg($_POST['v_exp']);
39+
$v_soa = escapeshellarg($_POST['v_soa']);
40+
$v_ttl = escapeshellarg($_POST['v_ttl']);
41+
42+
// Check for errors
43+
if (!empty($errors[0])) {
44+
foreach ($errors as $i => $error) {
45+
if ( $i == 0 ) {
46+
$error_msg = $error;
47+
} else {
48+
$error_msg = $error_msg.", ".$error;
49+
}
50+
}
51+
$_SESSION['error_msg'] = "Error: field ".$error_msg." can not be blank.";
52+
} else {
53+
54+
// Add DNS
55+
exec (VESTA_CMD."v_add_dns_domain ".$user." ".$v_domain." ".$v_ip." ".$v_template." ".$v_exp." ".$v_soa." ".$v_ttl, $output, $return_var);
56+
if ($return_var != 0) {
57+
$error = implode('<br>', $output);
58+
if (empty($error)) $error = 'Error: vesta did not return any output.';
59+
$_SESSION['error_msg'] = $error;
60+
}
61+
unset($output);
62+
63+
if (empty($_SESSION['error_msg'])) {
64+
$_SESSION['ok_msg'] = "OK: domain <b>".$_POST[v_domain]."</b> has been created successfully.";
65+
unset($v_domain);
66+
}
67+
}
68+
}
69+
70+
exec (VESTA_CMD."v_list_dns_templates json", $output, $return_var);
71+
$templates = json_decode(implode('', $output), true);
72+
unset($output);
73+
74+
exec (VESTA_CMD."v_list_user_ns ".$user." json", $output, $return_var);
75+
$soa = json_decode(implode('', $output), true);
76+
$v_soa = $soa[0];
77+
unset($output);
78+
79+
$v_ttl = 14400;
80+
$v_exp = date('Y-m-d', strtotime('+1 year'));
81+
82+
include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/menu_add_dns.html');
83+
include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_dns.html');
84+
unset($_SESSION['error_msg']);
85+
unset($_SESSION['ok_msg']);
86+
}
87+
88+
// Footer
89+
include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html');

web/list/user/index.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
exec (VESTA_CMD."v_list_users json", $output, $return_var);
1818
check_error($return_var);
1919
$data = json_decode(implode('', $output), true);
20+
$data = array_reverse($data);
2021
unset($output);
2122

2223
include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/menu_user.html');

web/templates/admin/add_dns.html

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<script language="javascript">
2+
function elementHideShow(elementToHideOrShow)
3+
{
4+
var el = document.getElementById(elementToHideOrShow);
5+
if (el.style.display == "block") {
6+
el.style.display = "none";
7+
} else {
8+
el.style.display = "block";
9+
}
10+
}
11+
</script>
12+
13+
14+
<table class='data'>
15+
<tr class="data-add">
16+
<td class="data-dotted" style="padding: 0px 10px 0px 0px" width="150">
17+
<table class="data-col1">
18+
<tr><td style="padding: 18 0 4 18;"></td></tr>
19+
</table>
20+
</td>
21+
<td class="data-dotted" width="830px" style="vertical-align:top;">
22+
<table width="830px"><tr>
23+
<td></td>
24+
</tr></table>
25+
<table class="data-col2" width="600px">
26+
<form method="post" name="v_add_user">
27+
<tr><td class="add-text" style="padding: 10 0 0 2px;">Domain</td></tr>
28+
<tr><td><input type="text" size="20" class="add-input" name="v_domain" <?php if (!empty($v_domain)) echo "value=".$v_domain; ?> ></td></tr>
29+
<tr><td class="add-text" style="padding: 10px 0 0 2px;">IP address</td></tr>
30+
<tr><td><input type="text" size="20" class="add-input" name="v_ip" <?php if (!empty($v_ip)) echo "value=".$v_ip; ?>></tr>
31+
<tr><td class="add-text" style="padding: 10px 0 0 2px;">Template</td></tr>
32+
<tr><td><select class="add-list" name="v_template">
33+
<?php
34+
foreach ($templates as $key => $value) {
35+
echo "\t\t\t\t<option value=\"".$key."\"";
36+
if ((!empty($v_template)) && ( $key == $_POST['v_template'])){
37+
echo ' selected' ;
38+
}
39+
echo ">".$key."</option>\n";
40+
}
41+
?>
42+
</select></td></tr>
43+
44+
<tr><td class="add-text" style="padding: 10px 0 0 2px;"><a href="javascript:elementHideShow('advtable');" class="add-advanced">Advanced Options ⇢</a></td></tr>
45+
<tr><td class="add-text" style="padding: 9px 0 0 0px;">
46+
<table style="display:<?php if (empty($v_adv)) echo 'none';?> ;" id="advtable">
47+
<tr><td class="add-text" style="padding: 10px 0 0 2px;">Domain Expiriation</td></tr>
48+
<tr><td><input type="text" size="20" class="add-input" name="v_exp" <?php if (!empty($v_exp)) echo "value=".$v_exp; ?>></tr>
49+
<tr><td class="add-text" style="padding: 10px 0 0 2px;">SOA</td></tr>
50+
<tr><td><input type="text" size="20" class="add-input" name="v_soa" <?php if (!empty($v_soa)) echo "value=".$v_soa; ?>></tr>
51+
<tr><td class="add-text" style="padding: 10px 0 0 2px;">TTL</td></tr>
52+
<tr><td><input type="text" size="20" class="add-input" name="v_ttl" <?php if (!empty($v_ttl)) echo "value=".$v_ttl; ?>></tr>
53+
</table>
54+
</td></tr>
55+
<tr><td style="padding: 24px 0 0 0;">
56+
<input type="submit" name="ok" value="OK" class="add-button"></form>
57+
<input type="button" class="add-button" value="Cancel" onClick="location.href='/list/dns/'">
58+
</td></tr>
59+
</table>
60+
</td>
61+
</tr>
62+
</table>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<table class="sub-menu">
2+
<tr>
3+
<td style="padding: 10px 2px 28px 0;" ><a class="add-name"><b>Adding DNS Domain</b></a>
4+
<?php
5+
if (!empty($_SESSION['error_msg'])) {
6+
echo "<a class=\"add-error\"> → ".$_SESSION['error_msg']."</a>";
7+
} else {
8+
if (!empty($_SESSION['ok_msg'])) {
9+
echo "<a class=\"add-ok\"> → ".$_SESSION['ok_msg']."</a>";
10+
}
11+
}
12+
?>
13+
</td>
14+
</tr>
15+
</table>

web/templates/header.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@
393393
.aliases {
394394
font-family: Arial;
395395
font-size: 12pt;
396-
color: #999999;
396+
color: #99a7af;
397397
padding: 0 0 0 8px;
398398
}
399399

@@ -407,7 +407,7 @@
407407
.fullname {
408408
font-family: Arial;
409409
font-size: 14pt;
410-
color: #999999;
410+
color: #99a7af;
411411
padding: 0 0 0 8px;
412412
}
413413

0 commit comments

Comments
 (0)