diff --git a/bin/v-list-database-hosts b/bin/v-list-database-hosts index 4260d59b9..1355a5a48 100755 --- a/bin/v-list-database-hosts +++ b/bin/v-list-database-hosts @@ -28,12 +28,12 @@ json_list() { fi done - echo "{" + echo "[" for type in $(echo $DB_SYSTEM |sed -e 's/,/\n/'); do if [ -e "$VESTA/conf/$type.conf" ]; then for str in $(cat $VESTA/conf/$type.conf); do eval $str - echo -n ' "'$HOST'": { + echo -n ' { "HOST": "'$HOST'", "TYPE": "'$type'", "CHARSETS": "'$CHARSETS'", @@ -54,7 +54,7 @@ json_list() { done fi done - echo '}' + echo ']' } # SHELL list function diff --git a/web/add/db/index.php b/web/add/db/index.php index c64ca42e8..ae2c0809d 100644 --- a/web/add/db/index.php +++ b/web/add/db/index.php @@ -120,12 +120,13 @@ $v_db_email = $panel[$user]['CONTACT']; $db_types = split(",",$_SESSION['DB_SYSTEM']); // List available database servers -$db_hosts = array(); -exec (VESTA_CMD."v-list-database-hosts 'json'", $output, $return_var); -$db_hosts_tmp = json_decode(implode('', $output), true); -$db_hosts = array_merge($db_hosts, $db_hosts_tmp); -unset($db_hosts_tmp); +exec (VESTA_CMD."v-list-database-hosts json", $output, $return_var); +$db_hosts_tmp1 = json_decode(implode('', $output), true); +$db_hosts_tmp2 = array_map(function($host){return $host['HOST'];}, $db_hosts_tmp1); +$db_hosts = array_values(array_unique($db_hosts_tmp2)); unset($output); +unset($db_hosts_tmp1); +unset($db_hosts_tmp2); // Display body include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_db.html'); @@ -136,4 +137,3 @@ unset($_SESSION['ok_msg']); // Footer include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); -?> diff --git a/web/edit/server/index.php b/web/edit/server/index.php index 073dc97b3..602fce4a7 100644 --- a/web/edit/server/index.php +++ b/web/edit/server/index.php @@ -46,21 +46,15 @@ foreach ($dns_cluster as $key => $value) { $v_dns_cluster = 'yes'; } -// List MySQL hosts -exec (VESTA_CMD."v-list-database-hosts mysql json", $output, $return_var); -$v_mysql_hosts = json_decode(implode('', $output), true); +// List Database hosts +exec (VESTA_CMD."v-list-database-hosts json", $output, $return_var); +$db_hosts = json_decode(implode('', $output), true); unset($output); -foreach ($v_mysql_hosts as $key => $value) { - $v_mysql = 'yes'; -} - -// List PostgreSQL hosts -exec (VESTA_CMD."v-list-database-hosts pgsql json", $output, $return_var); -$v_pgsql_hosts = json_decode(implode('', $output), true); -unset($output); -foreach ($v_pgsql_hosts as $key => $value) { - $v_pgsql = 'yes'; -} +$v_mysql_hosts = array_values(array_filter($db_hosts, function($host){return $host['TYPE'] === 'mysql';})); +$v_mysql = count($v_mysql_hosts) ? 'yes' : 'no'; +$v_pgsql_hosts = array_values(array_filter($db_hosts, function($host){return $host['TYPE'] === 'pgsql';})); +$v_pgsql = count($v_pgsql_hosts) ? 'yes' : 'no'; +unset($db_hosts); // List backup settings $v_backup_dir = "/backup"; diff --git a/web/templates/admin/add_db.html b/web/templates/admin/add_db.html index a69a6c140..2caa24a7a 100644 --- a/web/templates/admin/add_db.html +++ b/web/templates/admin/add_db.html @@ -68,7 +68,7 @@ - + @@ -79,7 +79,7 @@ - + @@ -100,7 +100,7 @@ - + @@ -112,32 +112,32 @@ if ((!empty($v_type)) && ( $value == $v_type )) echo ' selected'; echo ">".htmlentities($value).""; } - ?> + ?> - + - + @@ -183,7 +183,7 @@ - + diff --git a/web/templates/admin/edit_server.html b/web/templates/admin/edit_server.html index 20e494537..1c8578599 100644 --- a/web/templates/admin/edit_server.html +++ b/web/templates/admin/edit_server.html @@ -54,7 +54,7 @@ @@ -82,7 +82,7 @@ } echo ">".$value."\n"; } - ?> + ?>

@@ -106,7 +106,7 @@ } echo ">".$value."\n"; } - ?> + ?>

@@ -121,10 +121,10 @@ @@ -187,7 +187,7 @@
- +
- + @@ -133,10 +133,10 @@

- + @@ -145,10 +145,10 @@

- + @@ -159,7 +159,7 @@ @@ -169,7 +169,7 @@ - +
- +
- +
- +
- +
@@ -215,10 +215,10 @@ $i = 0; foreach ($dns_cluster as $key => $value) { $i++; - ?> + ?> @@ -227,7 +227,7 @@

- +
- +
- +
@@ -245,7 +245,7 @@ @@ -254,10 +254,10 @@

- + @@ -266,11 +266,11 @@

- - + + @@ -279,10 +279,10 @@

- + @@ -324,7 +324,7 @@ @@ -336,23 +336,23 @@ $value) { + foreach ($v_mysql_hosts as $value) { $i++; - ?> + ?> @@ -364,7 +364,7 @@ @@ -375,7 +375,7 @@ @@ -384,7 +384,7 @@



- + @@ -404,7 +404,7 @@ @@ -416,23 +416,23 @@ $value) { + foreach ($v_pgsql_hosts as $value) { $i++; - ?> + ?> @@ -443,7 +443,7 @@ @@ -452,7 +452,7 @@



- +
- +
- +
- +
- +
- +
- +
- +

- +
- +
- +
- +
- +
- +

- +
- +
@@ -470,7 +470,7 @@ @@ -484,7 +484,7 @@ @@ -505,7 +505,7 @@ @@ -524,7 +524,7 @@
- +
- +
- +
@@ -538,7 +538,7 @@ @@ -549,7 +549,7 @@ @@ -560,7 +560,7 @@ @@ -571,7 +571,7 @@ @@ -599,7 +599,7 @@
- +
- +
- +
- +
- +
@@ -638,7 +638,7 @@ @@ -651,7 +651,7 @@ @@ -690,7 +690,7 @@ '.__('Licence Key').':
'; } else { - echo + echo __('Restrict users so that they cannot use SSH and access only their home directory.').' '.__('This is a commercial module, you would need to purchace license key to enable it.'). '
'.__('Enter License Key').':
@@ -712,7 +712,7 @@
@@ -797,4 +797,4 @@ } }); }); - \ No newline at end of file +
- +
- +
- +
- +