Skip to content

Commit 276df05

Browse files
committed
dns edit domain page
1 parent 361f0ec commit 276df05

File tree

6 files changed

+213
-4
lines changed

6 files changed

+213
-4
lines changed

bin/v_list_dns_domain

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ json_list_domain() {
4040
echo -e "\t\"$value\": {"
4141
else
4242
if [ "$fileds_count" -eq "$i" ]; then
43-
echo -e "\t\t\"${field//$/}\": \"$value\","
44-
else
4543
echo -e "\t\t\"${field//$/}\": \"$value\""
44+
else
45+
echo -e "\t\t\"${field//$/}\": \"$value\","
4646
fi
4747
fi
4848
# Updating iterator

web/edit/dns/index.php

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
<?php
2+
// Init
3+
//error_reporting(NULL);
4+
ob_start();
5+
session_start();
6+
7+
$TAB = 'DNS';
8+
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
9+
10+
// Header
11+
include($_SERVER['DOCUMENT_ROOT'].'/templates/header.html');
12+
13+
// Panel
14+
top_panel($user,$TAB);
15+
16+
// Are you admin?
17+
if ($_SESSION['user'] == 'admin') {
18+
19+
// Check user argument?
20+
if (empty($_GET['domain'])) {
21+
header("Location: /list/dns/");
22+
}
23+
24+
if (!empty($_POST['cancel'])) {
25+
header("Location: /list/dns/");
26+
}
27+
28+
// Check domain
29+
$v_domain = escapeshellarg($_GET['domain']);
30+
exec (VESTA_CMD."v_list_dns_domain ".$user." ".$v_domain." json", $output, $return_var);
31+
if ($return_var != 0) {
32+
$error = implode('<br>', $output);
33+
if (empty($error)) $error = 'Error: vesta did not return any output.';
34+
$_SESSION['error_msg'] = $error;
35+
} else {
36+
$data = json_decode(implode('', $output), true);
37+
unset($output);
38+
39+
$v_username = $user;
40+
$v_domain = $_GET['domain'];
41+
$v_ip = $data[$v_domain]['IP'];
42+
$v_template = $data[$v_domain]['TPL'];
43+
$v_ttl = $data[$v_domain]['TTL'];
44+
$v_exp = $data[$v_domain]['EXP'];
45+
$v_soa = $data[$v_domain]['SOA'];
46+
$v_date = $data[$v_domain]['DATE'];
47+
$v_time = $data[$v_domain]['TIME'];
48+
49+
exec (VESTA_CMD."v_list_dns_templates json", $output, $return_var);
50+
$templates = json_decode(implode('', $output), true);
51+
unset($output);
52+
}
53+
54+
// Action
55+
if (!empty($_POST['save'])) {
56+
$v_domain = escapeshellarg($_POST['v_domain']);
57+
58+
// IP
59+
if (($v_ip != $_POST['v_ip']) && (empty($_SESSION['error_msg']))) {
60+
$v_ip = escapeshellarg($_POST['v_ip']);
61+
exec (VESTA_CMD."v_change_dns_domain_ip ".$v_username." ".$v_domain." ".$v_ip." 'no'", $output, $return_var);
62+
if ($return_var != 0) {
63+
$error = implode('<br>', $output);
64+
if (empty($error)) $error = 'Error: vesta did not return any output.';
65+
$_SESSION['error_msg'] = $error;
66+
}
67+
$restart_dns = 'yes';
68+
unset($output);
69+
}
70+
71+
// Template
72+
if (($v_template != $_POST['v_template']) && (empty($_SESSION['error_msg']))) {
73+
$v_template = escapeshellarg($_POST['v_template']);
74+
exec (VESTA_CMD."v_change_dns_domain_tpl ".$v_username." ".$v_domain." ".$v_template." 'no'", $output, $return_var);
75+
if ($return_var != 0) {
76+
$error = implode('<br>', $output);
77+
if (empty($error)) $error = 'Error: vesta did not return any output.';
78+
$_SESSION['error_msg'] = $error;
79+
}
80+
unset($output);
81+
$restart_dns = 'yes';
82+
}
83+
84+
// SOA
85+
if (($v_soa != $_POST['v_soa']) && (empty($_SESSION['error_msg']))) {
86+
$v_soa = escapeshellarg($_POST['v_soa']);
87+
exec (VESTA_CMD."v_change_dns_domain_soa ".$v_username." ".$v_domain." ".$v_soa." 'no'", $output, $return_var);
88+
if ($return_var != 0) {
89+
$error = implode('<br>', $output);
90+
if (empty($error)) $error = 'Error: vesta did not return any output.';
91+
$_SESSION['error_msg'] = $error;
92+
}
93+
unset($output);
94+
$restart_dns = 'yes';
95+
}
96+
97+
// EXP
98+
if (($v_exp != $_POST['v_exp']) && (empty($_SESSION['error_msg']))) {
99+
$v_exp = escapeshellarg($_POST['v_exp']);
100+
exec (VESTA_CMD."v_change_dns_domain_exp ".$v_username." ".$v_domain." ".$v_exp." 'no'", $output, $return_var);
101+
if ($return_var != 0) {
102+
$error = implode('<br>', $output);
103+
if (empty($error)) $error = 'Error: vesta did not return any output.';
104+
$_SESSION['error_msg'] = $error;
105+
}
106+
unset($output);
107+
$restart_dns = 'yes';
108+
}
109+
110+
// TTL
111+
if (($v_ttl != $_POST['v_ttl']) && (empty($_SESSION['error_msg']))) {
112+
$v_ttl = escapeshellarg($_POST['v_ttl']);
113+
exec (VESTA_CMD."v_change_dns_domain_ttl ".$v_username." ".$v_domain." ".$v_ttl." 'no'", $output, $return_var);
114+
if ($return_var != 0) {
115+
$error = implode('<br>', $output);
116+
if (empty($error)) $error = 'Error: vesta did not return any output.';
117+
$_SESSION['error_msg'] = $error;
118+
}
119+
unset($output);
120+
$restart_dns = 'yes';
121+
}
122+
123+
// Restart dns
124+
if (!empty($restart_dns) && (empty($_SESSION['error_msg']))) {
125+
exec (VESTA_CMD."v_restart_dns", $output, $return_var);
126+
if ($return_var != 0) {
127+
$error = implode('<br>', $output);
128+
if (empty($error)) $error = 'Error: vesta did not return any output.';
129+
$_SESSION['error_msg'] = $error;
130+
}
131+
}
132+
133+
if (empty($_SESSION['error_msg'])) {
134+
$_SESSION['ok_msg'] = "OK: changes has been saved.";
135+
}
136+
137+
}
138+
include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/menu_edit_dns.html');
139+
include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_dns.html');
140+
unset($_SESSION['error_msg']);
141+
unset($_SESSION['ok_msg']);
142+
}
143+
144+
// Footer
145+
include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html');

web/templates/admin/edit_dns.html

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<table class='data'>
2+
<tr class="data-add">
3+
<td class="data-dotted" style="padding: 0px 10px 0px 0px" width="150">
4+
<table class="data-col1">
5+
<tr><td style="padding: 20px 0 4px 4px;"><a class="data-date" ?><?php echo date("d M Y", strtotime($v_date))?></a></td></tr>
6+
<tr><td style="padding: 0 0 6px 4px;"><a class="data-date" ?><?php echo $v_time?></a></td></tr>
7+
<tr><td style="padding: 0 0 0 24px;" class="data-<?php echo $v_status ?>"><b><?php echo $v_status ?></b></td></tr>
8+
</table>
9+
</td>
10+
<td class="data-dotted" width="830px" style="vertical-align:top;">
11+
<table width="830px"><tr>
12+
<td></td>
13+
</tr></table>
14+
<form method="post" name="v_edit_user">
15+
<table class="data-col2" width="830px">
16+
<tr><td class="add-text" style="padding: 10 0 0 2px;">Domain</td></tr>
17+
<tr><td><input type="text" size="20" class="add-input" name="v_domain" <?php if (!empty($v_domain)) echo "value=".$v_domain; ?> disabled> <input type="hidden" name="v_domain" <?php if (!empty($v_domain)) echo "value=".$v_domain; ?>></td></tr>
18+
<tr><td class="add-text" style="padding: 10px 0 0 2px;">IP address</td></tr>
19+
<tr><td><input type="text" size="20" class="add-input" name="v_ip" <?php if (!empty($v_ip)) echo "value=".$v_ip; ?>></td></tr>
20+
<tr><td class="add-text" style="padding: 10px 0 0 2px;">Template</td></tr>
21+
<tr><td><select class="add-list" name="v_template">
22+
<?php
23+
foreach ($templates as $key => $value) {
24+
echo "\t\t\t\t<option value=\"".$key."\"";
25+
$skey = "'".$key."'";
26+
if ((!empty($v_template)) && ( $key == $v_template ) || ($skey == $v_template)){
27+
echo ' selected' ;
28+
}
29+
echo ">".$key."</option>\n";
30+
}
31+
?>
32+
</select></td></tr>
33+
<tr><td class="add-text" style="padding: 10px 0 0 2px;">Domain Expiriation</td></tr>
34+
<tr><td><input type="text" size="20" class="add-input" name="v_exp" <?php if (!empty($v_exp)) echo "value=".$v_exp; ?>></tr>
35+
<tr><td class="add-text" style="padding: 10px 0 0 2px;">SOA</td></tr>
36+
<tr><td><input type="text" size="20" class="add-input" name="v_soa" <?php if (!empty($v_soa)) echo "value=".$v_soa; ?>></tr>
37+
<tr><td class="add-text" style="padding: 10px 0 0 2px;">TTL</td></tr>
38+
<tr><td><input type="text" size="20" class="add-input" name="v_ttl" <?php if (!empty($v_ttl)) echo "value=".$v_ttl; ?>></tr>
39+
40+
<tr><td style="padding: 24px 0 0 0;">
41+
<input type="submit" class="add-button" name="save" value="Save"></form>
42+
<input type="button" class="add-button" value="Cancel" onClick="location.href='/list/dns/'">
43+
<input type="button" class="add-button" value="Edit Records" onClick="location.href='/list/dns/'">
44+
</td></tr>
45+
</form>
46+
</table>
47+
</td>
48+
</tr>
49+
</table>

web/templates/admin/edit_web.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
<form method="post" name="v_edit_user">
3636
<table class="data-col2" width="830px">
3737
<tr><td class="add-text" style="padding: 10 0 0 2px;">Domain</td></tr>
38-
<tr><td><input type="text" size="20" class="add-input" name="v_domain" <?php if (!empty($v_domain)) echo "value=".$v_domain; ?> disabled> <input type="hidden" name="v_domain" <?php if (!empty($v_domain)) echo "value=".$v_domain; ?>></tr>
38+
<tr><td><input type="text" size="20" class="add-input" name="v_domain" <?php if (!empty($v_domain)) echo "value=".$v_domain; ?> disabled> <input type="hidden" name="v_domain" <?php if (!empty($v_domain)) echo "value=".$v_domain; ?>></td></tr>
3939
<tr><td class="add-text" style="padding: 10px 0 0 2px;">IP address</td></tr>
4040
<tr><td><select class="add-list" name="v_ip">
4141
<?php

web/templates/admin/list_dns.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<td></td>
2727
<td class="data-controls" width="96px"><img src="/images/more.png" width="8px" height="8px"><a href="?domain=<?php echo $key ?>"> list records</a></td>
2828
<td class="data-controls" width="92px"><img src="/images/add.png" width="8px" height="8px"><a href="?domain=<?php echo $key ?>"> add record</a></td>
29-
<td class="data-controls" width="50px"><img src="/images/edit.png" width="8px" height="8px"><a href="#"> edit</a></td>
29+
<td class="data-controls" width="50px"><img src="/images/edit.png" width="8px" height="8px"><a href="/edit/dns/?domain=<?php echo $key ?>"> edit</a></td>
3030
<td class="data-controls" width="80px"><img src="/images/suspend.png" width="7px" height="8px"><a href="#"> <?php echo $spnd_action ?></a></td>
3131
<td class="data-controls" width="70px"><img src="/images/delete.png" width="7px" height="7px"><a href="#"> delete</a></td>
3232
</tr></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>Editing 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>

0 commit comments

Comments
 (0)