Skip to content

Commit 2899b69

Browse files
committed
UI: DNS(add/edit) Change inputbox with a editable dropdown select
1 parent 602766b commit 2899b69

File tree

8 files changed

+85
-7
lines changed

8 files changed

+85
-7
lines changed

web/add/dns/index.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
// Main include
77
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
88

9+
// List ip addresses
10+
exec (HESTIA_CMD."v-list-user-ips ".$user." json", $output, $return_var);
11+
$v_ips = json_decode(implode('', $output), true);
12+
unset($output);
13+
914
// Check POST request for dns domain
1015
if (!empty($_POST['ok'])) {
1116

@@ -33,7 +38,7 @@
3338
$v_domain = preg_replace("/^www./i", "", $_POST['v_domain']);
3439
$v_domain = escapeshellarg($v_domain);
3540
$v_domain = strtolower($v_domain);
36-
$v_ip = escapeshellarg($_POST['v_ip']);
41+
$v_ip = $_POST['v_ip'];
3742
$v_ns1 = escapeshellarg($_POST['v_ns1']);
3843
$v_ns2 = escapeshellarg($_POST['v_ns2']);
3944
$v_ns3 = escapeshellarg($_POST['v_ns3']);
@@ -45,7 +50,7 @@
4550

4651
// Add dns domain
4752
if (empty($_SESSION['error_msg'])) {
48-
exec (HESTIA_CMD."v-add-dns-domain ".$user." ".$v_domain." ".$v_ip." ".$v_ns1." ".$v_ns2." ".$v_ns3." ".$v_ns4." ".$v_ns5." ".$v_ns6." ".$v_ns7." ".$v_ns8." no", $output, $return_var);
53+
exec (HESTIA_CMD."v-add-dns-domain ".$user." ".$v_domain." ".escapeshellarg($v_ip)." ".$v_ns1." ".$v_ns2." ".$v_ns3." ".$v_ns4." ".$v_ns5." ".$v_ns6." ".$v_ns7." ".$v_ns8." no", $output, $return_var);
4954
check_return_code($return_var,$output);
5055
unset($output);
5156
}
@@ -146,6 +151,10 @@
146151
$v_ns7 = str_replace("'", "", $v_ns7);
147152
$v_ns8 = str_replace("'", "", $v_ns8);
148153

154+
if(empty($v_ip) && count($v_ips) > 0) {
155+
$ip = array_key_first($v_ips);
156+
$v_ip = (empty($v_ips[$ip]['NAT'])?$ip:$v_ips[$ip]['NAT']);
157+
}
149158

150159
if (empty($_GET['domain'])) {
151160
// Display body for dns domain

web/css/styles.min.css

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2399,6 +2399,19 @@ label:hover {
23992399
.vst-input.short {
24002400
width: 200px;
24012401
}
2402+
.vst-input.vst-list-editor {
2403+
border: none;
2404+
box-shadow: none;
2405+
position: absolute;
2406+
margin-top:-34px;
2407+
margin-left: 1px;
2408+
display: block;
2409+
width: 340px;
2410+
height: 1rem;
2411+
}
2412+
.vst-input.vst-list-editor:focus {
2413+
background-color: white;
2414+
}
24022415

24032416
.vst-list {
24042417
background-color: #fff;
@@ -2424,6 +2437,10 @@ label:hover {
24242437
box-shadow: 0px 1px 4px rgba(0,0,0,0.15);
24252438
}
24262439

2440+
select.vst-list:-moz-focusring {
2441+
color:transparent;
2442+
}
2443+
24272444
.vst-list.long-2 {
24282445
width: 486px;
24292446
background-position: 465px;

web/edit/dns/index.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
$user=escapeshellarg($_GET['user']);
1818
}
1919

20+
// List ip addresses
21+
exec (HESTIA_CMD."v-list-user-ips ".$user." json", $output, $return_var);
22+
$v_ips = json_decode(implode('', $output), true);
23+
unset($output);
24+
2025
// List dns domain
2126
if ((!empty($_GET['domain'])) && (empty($_GET['record_id']))) {
2227
$v_domain = escapeshellarg($_GET['domain']);

web/templates/admin/add_dns.html

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,16 @@
6565
</tr>
6666
<tr>
6767
<td>
68-
<input type="text" size="20" class="vst-input" name="v_ip" value="<?=htmlentities(trim($v_ip, "'"))?>">
68+
<select class="vst-list" onchange="this.nextElementSibling.value=this.value">
69+
<option value="">clear</option>
70+
<?php
71+
foreach ($v_ips as $ip => $value) {
72+
$display_ip = empty($value['NAT']) ? $ip : "{$value['NAT']}";
73+
echo "<option value='{$display_ip}'>" . htmlentities($display_ip) . "</option>\n";
74+
}
75+
?>
76+
</select>
77+
<input type="text" size="20" class="vst-input vst-list-editor" name="v_ip" value="<?=htmlentities(trim($v_ip, "'"))?>">
6978
</td>
7079
</tr>
7180
<tr>

web/templates/admin/add_dns_rec.html

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,16 @@
9494
</tr>
9595
<tr>
9696
<td>
97-
<input type="text" size="20" class="vst-input" name="v_val" value="<?=htmlentities(trim($v_val, "'"))?>">
97+
<select class="vst-list" onchange="this.nextElementSibling.value=this.value">
98+
<option value="">clear</option>
99+
<?php
100+
foreach ($v_ips as $ip => $value) {
101+
$display_ip = empty($value['NAT']) ? $ip : "{$value['NAT']}";
102+
echo "<option value='{$display_ip}'>" . htmlentities($display_ip) . "</option>\n";
103+
}
104+
?>
105+
</select>
106+
<input type="text" size="20" class="vst-input vst-list-editor" name="v_val" value="<?=htmlentities(trim($v_val, "'"))?>">
98107
</td>
99108
</tr>
100109
<tr>

web/templates/admin/edit_dns.html

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,17 @@
6868
</tr>
6969
<tr>
7070
<td>
71-
<input type="text" size="20" class="vst-input" name="v_ip" value="<?=htmlentities(trim($v_ip, "'"))?>">
71+
<select class="vst-list" onchange="this.nextElementSibling.value=this.value">
72+
<option value="">clear</option>
73+
<?php
74+
foreach ($v_ips as $ip => $value) {
75+
$display_ip = empty($value['NAT']) ? $ip : "{$value['NAT']}";
76+
$ip_selected = ((!empty($v_ip) && ($v_ip==$ip||$v_ip==$display_ip) ))? 'selected' : '';
77+
echo "<option value='{$display_ip}' {$ip_selected}>" . htmlentities($display_ip) . "</option>\n";
78+
}
79+
?>
80+
</select>
81+
<input type="text" size="20" class="vst-input vst-list-editor" name="v_ip" value="<?=htmlentities(trim($v_ip, "'"))?>">
7282
</td>
7383
</tr>
7484
<tr>

web/templates/admin/edit_dns_rec.html

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,16 @@
104104
</tr>
105105
<tr>
106106
<td>
107-
<input type="text" size="20" class="vst-input" name="v_val" value="<?=htmlentities(trim($v_val, "'"))?>">
107+
<select class="vst-list" onchange="this.nextElementSibling.value=this.value">
108+
<option value="">clear</option>
109+
<?php
110+
foreach ($v_ips as $ip => $value) {
111+
$display_ip = empty($value['NAT']) ? $ip : "{$value['NAT']}";
112+
echo "<option value='{$display_ip}'>" . htmlentities($display_ip) . "</option>\n";
113+
}
114+
?>
115+
</select>
116+
<input type="text" size="20" class="vst-input vst-list-editor" name="v_val" value="<?=htmlentities(trim($v_val, "'"))?>">
108117
</td>
109118
</tr>
110119
<tr>

web/templates/user/edit_dns.html

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,17 @@
6868
</tr>
6969
<tr>
7070
<td>
71-
<input type="text" size="20" class="vst-input" name="v_ip" value="<?=htmlentities(trim($v_ip, "'"))?>">
71+
<select class="vst-list" onchange="this.nextElementSibling.value=this.value">
72+
<option value="">clear</option>
73+
<?php
74+
foreach ($v_ips as $ip => $value) {
75+
$display_ip = empty($value['NAT']) ? $ip : "{$value['NAT']}";
76+
$ip_selected = ((!empty($v_ip) && ($v_ip==$ip||$v_ip==$display_ip) ))? 'selected' : '';
77+
echo "<option value='{$display_ip}' {$ip_selected}>" . htmlentities($display_ip) . "</option>\n";
78+
}
79+
?>
80+
</select>
81+
<input type="text" size="20" class="vst-input vst-list-editor" name="v_ip" value="<?=htmlentities(trim($v_ip, "'"))?>">
7282
</td>
7383
</tr>
7484
<tr>

0 commit comments

Comments
 (0)