Skip to content

Commit bdac016

Browse files
committed
dbhost selector
1 parent 18c3467 commit bdac016

File tree

2 files changed

+35
-3
lines changed

2 files changed

+35
-3
lines changed

web/add/db/index.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
if (empty($_POST['v_dbuser'])) $errors[] = __('username');
2121
if (empty($_POST['v_password'])) $errors[] = __('password');
2222
if (empty($_POST['v_type'])) $errors[] = __('type');
23+
if (empty($_POST['v_host'])) $errors[] = __('host');
2324
if (empty($_POST['v_charset'])) $errors[] = __('charset');
2425

2526
// Check for errors
@@ -47,6 +48,7 @@
4748
$v_password = escapeshellarg($_POST['v_password']);
4849
$v_type = $_POST['v_type'];
4950
$v_charset = $_POST['v_charset'];
51+
$v_host = $_POST['v_host'];
5052
$v_db_email = $_POST['v_db_email'];
5153

5254
// Check password length
@@ -59,8 +61,10 @@
5961
// Add Database
6062
$v_type = escapeshellarg($_POST['v_type']);
6163
$v_charset = escapeshellarg($_POST['v_charset']);
62-
exec (VESTA_CMD."v-add-database ".$user." ".$v_database." ".$v_dbuser." ".$v_password." ".$v_type." 'default' ".$v_charset, $output, $return_var);
64+
$v_host = escapeshellarg($_POST['v_host']);
65+
exec (VESTA_CMD."v-add-database ".$user." ".$v_database." ".$v_dbuser." ".$v_password." ".$v_type." ".$v_host." ".$v_charset, $output, $return_var);
6366
$v_type = $_POST['v_type'];
67+
$v_host = $_POST['v_host'];
6468
$v_charset = $_POST['v_charset'];
6569
check_return_code($return_var,$output);
6670
unset($output);
@@ -90,6 +94,15 @@
9094
$db_types = json_decode(implode('', $output), true);
9195
unset($output);
9296

97+
$db_hosts = array();
98+
foreach ($db_types as $db_type ) {
99+
exec (VESTA_CMD."v-list-database-hosts ".$db_type." 'json'", $output, $return_var);
100+
$db_hosts_tmp = json_decode(implode('', $output), true);
101+
$db_hosts = array_merge($db_hosts, $db_hosts_tmp);
102+
unset($db_hosts_tmp);
103+
unset($output);
104+
}
105+
93106
include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_db.html');
94107
unset($_SESSION['error_msg']);
95108
unset($_SESSION['ok_msg']);

web/templates/admin/add_db.html

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,33 @@
105105
<select class="vst-list" name="v_type">
106106
<?php
107107
foreach ($db_types as $key => $value) {
108-
echo "\t\t\t\t<option value=\"".$value."\"";
108+
echo "\n\t\t\t\t\t\t\t\t\t\t<option value=\"".$value."\"";
109109
if ((!empty($v_type)) && ( $value == $v_type )) echo ' selected';
110-
echo ">".$value."</option>\n";
110+
echo ">".$value."</option>";
111111
}
112112
?>
113113
</select>
114114
</td>
115115
</tr>
116+
<tr>
117+
<td class="vst-text" style="padding: 10px 0 0 2px;">
118+
<?php print __('Host');?>
119+
</td>
120+
</tr>
121+
<tr>
122+
<td>
123+
<select class="vst-list" name="v_host">
124+
<?php
125+
foreach ($db_hosts as $key => $value) {
126+
echo "\n\t\t\t\t\t\t\t\t\t\t<option value=\"".$key."\"";
127+
if ((!empty($v_host)) && ( $key == $v_host )) echo ' selected';
128+
echo ">".$key."</option>";
129+
}
130+
?>
131+
</select>
132+
</td>
133+
</tr>
134+
116135
<tr>
117136
<td class="vst-text" style="padding: 10px 0 0 2px;">
118137
<?php print __('Charset');?>

0 commit comments

Comments
 (0)