Skip to content

Commit b306202

Browse files
committed
suspend dns record page
1 parent a968f9b commit b306202

19 files changed

+583
-28
lines changed

bin/v_suspend_dns_domain

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ sed -i "/\/$domain.db\"/d" /etc/named.conf
4646

4747
# Adding suspend in config
4848
update_object_value 'dns' 'DOMAIN' "$domain" '$SUSPENDED' 'yes'
49+
sed -i "s/SUSPENDED='no'/SUSPENDED='yes'/g" $USER_DATA/dns/$domain.conf
4950
increase_user_value "$user" '$SUSPENDED_DNS'
5051

5152
# Restart named

bin/v_suspend_dns_domain_record

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/bin/bash
2+
# info: suspend dns domain record
3+
# options: user domain id [restart]
4+
#
5+
# The function suspends a certain domain record.
6+
7+
8+
#----------------------------------------------------------#
9+
# Variable&Function #
10+
#----------------------------------------------------------#
11+
12+
# Argument defenition
13+
user=$1
14+
domain=$(idn -t --quiet -u "$2" )
15+
domain_idn=$(idn -t --quiet -a "$domain")
16+
id=$3
17+
restart="$4"
18+
19+
# Includes
20+
source $VESTA/conf/vesta.conf
21+
source $VESTA/func/main.sh
22+
source $VESTA/func/domain.sh
23+
24+
25+
#----------------------------------------------------------#
26+
# Verifications #
27+
#----------------------------------------------------------#
28+
29+
check_args '3' "$#" 'user domain id [restart]'
30+
validate_format 'user' 'domain' 'id'
31+
is_system_enabled "$DNS_SYSTEM"
32+
is_object_valid 'user' 'USER' "$user"
33+
is_object_valid 'dns' 'DOMAIN' "$domain"
34+
is_object_unsuspended 'dns' 'DOMAIN' "$domain"
35+
is_object_valid "dns/$domain" 'ID' "$id"
36+
is_object_unsuspended "dns/$domain" 'ID' "$id"
37+
38+
39+
#----------------------------------------------------------#
40+
# Action #
41+
#----------------------------------------------------------#
42+
43+
line=$(grep "ID='$id'" $USER_DATA/dns/$domain.conf)
44+
eval $line
45+
sed -i "/^ID='$id'/d" $USER_DATA/dns/$domain.conf
46+
47+
# Adding record
48+
dns_rec="ID='$id' RECORD='$RECORD' TYPE='$TYPE' PRIORITY='$PRIORITY'"
49+
dns_rec="$dns_rec VALUE='$VALUE' SUSPENDED='yes' TIME='$TIME' DATE='$DATE'"
50+
echo "$dns_rec" >> $USER_DATA/dns/$domain.conf
51+
52+
# Sorting records
53+
sort_dns_records
54+
55+
# Updating zone
56+
update_domain_zone
57+
58+
59+
#----------------------------------------------------------#
60+
# Vesta #
61+
#----------------------------------------------------------#
62+
63+
# Restart named
64+
if [ "$restart" != 'no' ]; then
65+
$BIN/v_restart_dns "$EVENT"
66+
fi
67+
68+
# Logging
69+
log_event "$OK" "$EVENT"
70+
71+
exit

bin/v_unsuspend_dns_domain

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ echo "zone \"$domain\" { type master; file \"/etc/namedb/$domain.db\"; };" \
4747
# Unsuspending domain in config
4848
update_object_value 'dns' 'DOMAIN' "$domain" '$SUSPENDED' 'no'
4949
decrease_user_value "$user" '$SUSPENDED_DNS'
50+
sed -i "s/SUSPENDED='yes'/SUSPENDED='no'/g" $USER_DATA/dns/$domain.conf
51+
5052

5153
# Restart named
5254
if [ "$restart" != 'no' ]; then

bin/v_unsuspend_dns_domain_record

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#!/bin/bash
2+
# info: unsuspend dns domain record
3+
# options: user domain id [restart]
4+
#
5+
# The function unsuspends a certain domain record.
6+
7+
8+
#----------------------------------------------------------#
9+
# Variable&Function #
10+
#----------------------------------------------------------#
11+
12+
# Argument defenition
13+
user=$1
14+
domain=$(idn -t --quiet -u "$2" )
15+
domain_idn=$(idn -t --quiet -a "$domain")
16+
id=$3
17+
restart="$4"
18+
19+
# Includes
20+
source $VESTA/conf/vesta.conf
21+
source $VESTA/func/main.sh
22+
source $VESTA/func/domain.sh
23+
24+
25+
#----------------------------------------------------------#
26+
# Verifications #
27+
#----------------------------------------------------------#
28+
29+
check_args '3' "$#" 'user domain id [restart]'
30+
validate_format 'user' 'domain' 'id'
31+
is_system_enabled "$DNS_SYSTEM"
32+
is_object_valid 'user' 'USER' "$user"
33+
is_object_valid 'dns' 'DOMAIN' "$domain"
34+
is_object_unsuspended 'dns' 'DOMAIN' "$domain"
35+
is_object_valid "dns/$domain" 'ID' "$id"
36+
37+
38+
#----------------------------------------------------------#
39+
# Action #
40+
#----------------------------------------------------------#
41+
42+
line=$(grep "ID='$id'" $USER_DATA/dns/$domain.conf)
43+
eval $line
44+
sed -i "/^ID='$id'/d" $USER_DATA/dns/$domain.conf
45+
46+
# Adding record
47+
dns_rec="ID='$id' RECORD='$RECORD' TYPE='$TYPE' PRIORITY='$PRIORITY'"
48+
dns_rec="$dns_rec VALUE='$VALUE' SUSPENDED='no' TIME='$TIME' DATE='$DATE'"
49+
echo "$dns_rec" >> $USER_DATA/dns/$domain.conf
50+
51+
# Sorting records
52+
sort_dns_records
53+
54+
# Updating zone
55+
update_domain_zone
56+
57+
58+
#----------------------------------------------------------#
59+
# Vesta #
60+
#----------------------------------------------------------#
61+
62+
# Restart named
63+
if [ "$restart" != 'no' ]; then
64+
$BIN/v_restart_dns "$EVENT"
65+
fi
66+
67+
# Logging
68+
log_event "$OK" "$EVENT"
69+
70+
exit

data/templates/dns/default.tpl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
ID='1' RECORD='@' TYPE='NS' PRIORITY='' VALUE='%ns1%.' SUSPEND='no' TIME='%time%' DATE='%date%'
2-
ID='2' RECORD='@' TYPE='NS' PRIORITY='' VALUE='%ns2%.' SUSPEND='no' TIME='%time%' DATE='%date%'
3-
ID='3' RECORD='@' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPEND='no' TIME='%time%' DATE='%date%'
4-
ID='4' RECORD='mail' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPEND='no' TIME='%time%' DATE='%date%'
5-
ID='5' RECORD='www' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPEND='no' TIME='%time%' DATE='%date%'
6-
ID='6' RECORD='pop' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPEND='no' TIME='%time%' DATE='%date%'
7-
ID='7' RECORD='ftp' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPEND='no' TIME='%time%' DATE='%date%'
8-
ID='8' RECORD='@' TYPE='MX' PRIORITY='10' VALUE='mail' SUSPEND='no' TIME='%time%' DATE='%date%'
9-
ID='9' RECORD='@' TYPE='TXT' PRIORITY='' VALUE='"v=spf1 a mx ip4:%ip% ?all"' SUSPEND='no' TIME='%time%' DATE='%date%'
1+
ID='1' RECORD='@' TYPE='NS' PRIORITY='' VALUE='%ns1%.' SUSPENDED='no' TIME='%time%' DATE='%date%'
2+
ID='2' RECORD='@' TYPE='NS' PRIORITY='' VALUE='%ns2%.' SUSPENDED='no' TIME='%time%' DATE='%date%'
3+
ID='3' RECORD='@' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPENDED='no' TIME='%time%' DATE='%date%'
4+
ID='4' RECORD='mail' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPENDED='no' TIME='%time%' DATE='%date%'
5+
ID='5' RECORD='www' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPENDED='no' TIME='%time%' DATE='%date%'
6+
ID='6' RECORD='pop' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPENDED='no' TIME='%time%' DATE='%date%'
7+
ID='7' RECORD='ftp' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPENDED='no' TIME='%time%' DATE='%date%'
8+
ID='8' RECORD='@' TYPE='MX' PRIORITY='10' VALUE='mail' SUSPENDED='no' TIME='%time%' DATE='%date%'
9+
ID='9' RECORD='@' TYPE='TXT' PRIORITY='' VALUE='"v=spf1 a mx ip4:%ip% ?all"' SUSPENDED='no' TIME='%time%' DATE='%date%'

data/templates/dns/gmail.tpl

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
ID='1' RECORD='@' TYPE='NS' PRIORITY='' VALUE='%ns1%.' SUSPEND='no' TIME='%time%' DATE='%date%'
2-
ID='2' RECORD='@' TYPE='NS' PRIORITY='' VALUE='%ns2%.' SUSPEND='no' TIME='%time%' DATE='%date%'
3-
ID='3' RECORD='@' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPEND='no' TIME='%time%' DATE='%date%'
4-
ID='4' RECORD='ftp' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPEND='no' TIME='%time%' DATE='%date%'
5-
ID='5' RECORD='localhost' TYPE='A' PRIORITY='' VALUE='127.0.0.1' SUSPEND='no' TIME='%time%' DATE='%date%'
6-
ID='6' RECORD='mail' TYPE='CNAME' PRIORITY='' VALUE='ghs.google.com.' SUSPEND='no' TIME='%time%' DATE='%date%'
7-
ID='7' RECORD='pop' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPEND='no' TIME='%time%' DATE='%date%'
8-
ID='8' RECORD='www' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPEND='no' TIME='%time%' DATE='%date%'
9-
ID='9' RECORD='@' TYPE='MX' PRIORITY='1' VALUE='ASPMX.L.GOOGLE.COM.' SUSPEND='no' TIME='%time%' DATE='%date%'
10-
ID='10' RECORD='@' TYPE='MX' PRIORITY='5' VALUE='ALT1.ASPMX.L.GOOGLE.COM.' SUSPEND='no' TIME='%time%' DATE='%date%'
11-
ID='11' RECORD='@' TYPE='MX' PRIORITY='5' VALUE='ALT2.ASPMX.L.GOOGLE.COM.' SUSPEND='no' TIME='%time%' DATE='%date%'
12-
ID='12' RECORD='@' TYPE='MX' PRIORITY='10' VALUE='ASPMX2.GOOGLEMAIL.COM.' SUSPEND='no' TIME='%time%' DATE='%date%'
13-
ID='13' RECORD='@' TYPE='MX' PRIORITY='10' VALUE='ASPMX3.GOOGLEMAIL.COM.' SUSPEND='no' TIME='%time%' DATE='%date%'
14-
ID='14' RECORD='@' TYPE='TXT' PRIORITY='' VALUE='"v=spf1 a mx ip4:%ip% ?all"' SUSPEND='no' TIME='%time%' DATE='%date%'
1+
ID='1' RECORD='@' TYPE='NS' PRIORITY='' VALUE='%ns1%.' SUSPENDED='no' TIME='%time%' DATE='%date%'
2+
ID='2' RECORD='@' TYPE='NS' PRIORITY='' VALUE='%ns2%.' SUSPENDED='no' TIME='%time%' DATE='%date%'
3+
ID='3' RECORD='@' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPENDED='no' TIME='%time%' DATE='%date%'
4+
ID='4' RECORD='ftp' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPENDED='no' TIME='%time%' DATE='%date%'
5+
ID='5' RECORD='localhost' TYPE='A' PRIORITY='' VALUE='127.0.0.1' SUSPENDED='no' TIME='%time%' DATE='%date%'
6+
ID='6' RECORD='mail' TYPE='CNAME' PRIORITY='' VALUE='ghs.google.com.' SUSPENDED='no' TIME='%time%' DATE='%date%'
7+
ID='7' RECORD='pop' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPENDED='no' TIME='%time%' DATE='%date%'
8+
ID='8' RECORD='www' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPENDED='no' TIME='%time%' DATE='%date%'
9+
ID='9' RECORD='@' TYPE='MX' PRIORITY='1' VALUE='ASPMX.L.GOOGLE.COM.' SUSPENDED='no' TIME='%time%' DATE='%date%'
10+
ID='10' RECORD='@' TYPE='MX' PRIORITY='5' VALUE='ALT1.ASPMX.L.GOOGLE.COM.' SUSPENDED='no' TIME='%time%' DATE='%date%'
11+
ID='11' RECORD='@' TYPE='MX' PRIORITY='5' VALUE='ALT2.ASPMX.L.GOOGLE.COM.' SUSPENDED='no' TIME='%time%' DATE='%date%'
12+
ID='12' RECORD='@' TYPE='MX' PRIORITY='10' VALUE='ASPMX2.GOOGLEMAIL.COM.' SUSPENDED='no' TIME='%time%' DATE='%date%'
13+
ID='13' RECORD='@' TYPE='MX' PRIORITY='10' VALUE='ASPMX3.GOOGLEMAIL.COM.' SUSPENDED='no' TIME='%time%' DATE='%date%'
14+
ID='14' RECORD='@' TYPE='TXT' PRIORITY='' VALUE='"v=spf1 a mx ip4:%ip% ?all"' SUSPENDED='no' TIME='%time%' DATE='%date%'

func/domain.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,9 @@ update_domain_zone() {
114114
done
115115

116116
RECORD=$(idn --quiet -a -t "$RECORD")
117-
eval echo -e "\"$fields\""|sed -e "s/%quote%/'/g" >> $conf
117+
if [ "$SUSPENDED" != 'yes' ]; then
118+
eval echo -e "\"$fields\""|sed -e "s/%quote%/'/g" >> $conf
119+
fi
118120
done < $USER_DATA/dns/$domain.conf
119121
}
120122

web/suspend/dns/index.php

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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['back'])) {
20+
header("Location: /list/dns/");
21+
}
22+
23+
// DNS domain
24+
if ((!empty($_GET['domain'])) && (empty($_GET['record_id']))) {
25+
$v_username = escapeshellarg($user);
26+
$v_domain = escapeshellarg($_GET['domain']);
27+
exec (VESTA_CMD."v_suspend_dns_domain ".$v_username." ".$v_domain, $output, $return_var);
28+
if ($return_var != 0) {
29+
$error = implode('<br>', $output);
30+
if (empty($error)) $error = 'Error: vesta did not return any output.';
31+
$_SESSION['error_msg'] = $error;
32+
} else {
33+
$_SESSION['ok_msg'] = "OK: dns domain <b>".$_GET['domain']."</b> has been suspended.";
34+
unset($v_lname);
35+
}
36+
unset($output);
37+
38+
include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/menu_suspend_dns.html');
39+
include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/suspend_dns.html');
40+
unset($_SESSION['error_msg']);
41+
unset($_SESSION['ok_msg']);
42+
}
43+
44+
// DNS record
45+
if ((!empty($_GET['domain'])) && (!empty($_GET['record_id']))) {
46+
$v_username = escapeshellarg($user);
47+
$v_domain = escapeshellarg($_GET['domain']);
48+
$v_record_id = escapeshellarg($_GET['record_id']);
49+
exec (VESTA_CMD."v_suspend_dns_domain_record ".$v_username." ".$v_domain." ".$v_record_id, $output, $return_var);
50+
if ($return_var != 0) {
51+
$error = implode('<br>', $output);
52+
if (empty($error)) $error = 'Error: vesta did not return any output.';
53+
$_SESSION['error_msg'] = $error;
54+
} else {
55+
$_SESSION['ok_msg'] = "OK: dns record has been suspended.";
56+
unset($v_lname);
57+
}
58+
unset($output);
59+
60+
include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/menu_suspend_dns_rec.html');
61+
include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/suspend_dns_rec.html');
62+
unset($_SESSION['error_msg']);
63+
unset($_SESSION['ok_msg']);
64+
}
65+
66+
}
67+
68+
// Footer
69+
include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html');

web/templates/admin/list_dns.html

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,51 @@
55
++$i;
66
if ($data[$key]['SUSPENDED'] == 'yes') {
77
$status = 'suspended';
8-
$spnd_action = 'ususpend' ;
8+
$spnd_action = 'unsuspend' ;
99
} else {
1010
$status = 'active';
1111
$spnd_action = 'suspend' ;
1212
}
1313
?>
14+
<script type="text/javascript">
15+
$(function(){
16+
$('#<?php echo $spnd_action ?>_dialog_<?php echo "$i" ?>').dialog({
17+
modal: true,
18+
autoOpen: false,
19+
width: 360,
20+
buttons: {
21+
"Ok": function(event, ui) {
22+
location.href = '/<?php echo $spnd_action ?>/dns/?domain=<?php echo "$key" ?>';
23+
},
24+
"Cancel": function() {
25+
$(this).dialog("close");
26+
}
27+
}
28+
});
29+
$('#<?php echo $spnd_action ?>_link_<?php echo "$i" ?>').click(function(){
30+
$('#<?php echo $spnd_action ?>_dialog_<?php echo "$i" ?>').dialog('open');
31+
return false;
32+
});
33+
34+
$('#delete_dialog_<?php echo "$i" ?>').dialog({
35+
modal: true,
36+
autoOpen: false,
37+
width: 360,
38+
buttons: {
39+
"Ok": function(event, ui) {
40+
location.href = '/delete/dns/?domain=<?php echo "$key" ?>';
41+
},
42+
"Cancel": function() {
43+
$(this).dialog("close");
44+
}
45+
}
46+
});
47+
$('#delete_link_<?php echo "$i" ?>').click(function(){
48+
$('#delete_dialog_<?php echo "$i" ?>').dialog('open');
49+
return false;
50+
});
51+
});
52+
</script>
1453

1554
<tr class="data-row">
1655
<td class="data-dotted" style="padding: 0px 10px 0px 0px" width="150">
@@ -27,7 +66,13 @@
2766
<td class="data-controls" width="96px"><img src="/images/more.png" width="8px" height="8px"><a href="/list/dns/?domain=<?php echo $key ?>"> list records</a></td>
2867
<td class="data-controls" width="92px"><img src="/images/add.png" width="8px" height="8px"><a href="/add/dns/?domain=<?php echo $key ?>"> add record</a></td>
2968
<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>
30-
<td class="data-controls" width="80px"><img src="/images/suspend.png" width="7px" height="8px"><a href="#"> <?php echo $spnd_action ?></a></td>
69+
<td class="data-controls" width="80px">
70+
<img src="/images/suspend.png" width="7px" height="8px">
71+
<a href="#" id="<?php echo $spnd_action ?>_link_<?php echo "$i" ?>"> <?php echo $spnd_action ?></a>
72+
<div id="<?php echo $spnd_action ?>_dialog_<?php echo "$i" ?>" title="Confirmation">
73+
<p class="counter-value">Are you sure you want to <?php echo $spnd_action ?> <span style="color: #34536A;"><b><?php echo "$key" ?></b></span> domain?</p>
74+
</div>
75+
</td>
3176
<td class="data-controls" width="70px"><img src="/images/delete.png" width="7px" height="7px"><a href="#"> delete</a></td>
3277
</tr></table>
3378

0 commit comments

Comments
 (0)