mirror of
https://github.com/myvesta/vesta
synced 2025-08-14 02:28:05 -07:00
Fix /edit/server/ always says database unsupported
This commit changes interface of bin/v-list-database-hosts
This commit is contained in:
parent
656d34ed0b
commit
e0f695e493
5 changed files with 83 additions and 89 deletions
|
@ -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
|
||||
|
|
|
@ -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');
|
||||
?>
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -125,10 +125,10 @@
|
|||
<td>
|
||||
<select class="vst-list" name="v_host">
|
||||
<?php
|
||||
foreach ($db_hosts as $key => $value) {
|
||||
echo "\n\t\t\t\t\t\t\t\t\t\t<option value=\"".htmlentities($key)."\"";
|
||||
if ((!empty($v_host)) && ( $key == $v_host )) echo ' selected';
|
||||
echo ">".htmlentities($key)."</option>";
|
||||
foreach ($db_hosts as $value) {
|
||||
echo "\n\t\t\t\t\t\t\t\t\t\t<option value=\"".htmlentities($value)."\"";
|
||||
if ((!empty($v_host)) && ( $value == $v_host )) echo ' selected';
|
||||
echo ">".htmlentities($value)."</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
|
|
|
@ -336,7 +336,7 @@
|
|||
<?php } ?>
|
||||
<?php if ($v_mysql == 'yes') {
|
||||
$i = 0;
|
||||
foreach ($v_mysql_hosts as $key => $value) {
|
||||
foreach ($v_mysql_hosts as $value) {
|
||||
$i++;
|
||||
?>
|
||||
<tr>
|
||||
|
@ -346,7 +346,7 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td class="step-left">
|
||||
<input type="text" size="20" class="vst-input" name="v_mysql_host" value="<?php echo $key; ?>" disabled>
|
||||
<input type="text" size="20" class="vst-input" name="v_mysql_host" value="<?=$value['HOST']?>" disabled>
|
||||
<br><br>
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -416,7 +416,7 @@
|
|||
<?php } ?>
|
||||
<?php if ($v_pgsql == 'yes') {
|
||||
$i = 0;
|
||||
foreach ($v_pgsql_hosts as $key => $value) {
|
||||
foreach ($v_pgsql_hosts as $value) {
|
||||
$i++;
|
||||
?>
|
||||
<tr>
|
||||
|
@ -426,7 +426,7 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td class="step-left">
|
||||
<input type="text" size="20" class="vst-input" name="v_pgsql_host" value="<?php echo $key; ?>" disabled>
|
||||
<input type="text" size="20" class="vst-input" name="v_pgsql_host" value="<?=$value['HOST']?>" disabled>
|
||||
<br><br>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue