mirror of
https://github.com/myvesta/vesta
synced 2025-08-19 21:04:07 -07:00
Merge pull request #738 from Flatta/fix-listdbhosts-call
Fix /edit/server/ always says database unsupported
This commit is contained in:
commit
3d27ad4fe7
5 changed files with 83 additions and 89 deletions
|
@ -28,12 +28,12 @@ json_list() {
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "{"
|
echo "["
|
||||||
for type in $(echo $DB_SYSTEM |sed -e 's/,/\n/'); do
|
for type in $(echo $DB_SYSTEM |sed -e 's/,/\n/'); do
|
||||||
if [ -e "$VESTA/conf/$type.conf" ]; then
|
if [ -e "$VESTA/conf/$type.conf" ]; then
|
||||||
for str in $(cat $VESTA/conf/$type.conf); do
|
for str in $(cat $VESTA/conf/$type.conf); do
|
||||||
eval $str
|
eval $str
|
||||||
echo -n ' "'$HOST'": {
|
echo -n ' {
|
||||||
"HOST": "'$HOST'",
|
"HOST": "'$HOST'",
|
||||||
"TYPE": "'$type'",
|
"TYPE": "'$type'",
|
||||||
"CHARSETS": "'$CHARSETS'",
|
"CHARSETS": "'$CHARSETS'",
|
||||||
|
@ -54,7 +54,7 @@ json_list() {
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
echo '}'
|
echo ']'
|
||||||
}
|
}
|
||||||
|
|
||||||
# SHELL list function
|
# SHELL list function
|
||||||
|
|
|
@ -120,12 +120,13 @@ $v_db_email = $panel[$user]['CONTACT'];
|
||||||
$db_types = split(",",$_SESSION['DB_SYSTEM']);
|
$db_types = split(",",$_SESSION['DB_SYSTEM']);
|
||||||
|
|
||||||
// List available database servers
|
// List available database servers
|
||||||
$db_hosts = array();
|
exec (VESTA_CMD."v-list-database-hosts json", $output, $return_var);
|
||||||
exec (VESTA_CMD."v-list-database-hosts 'json'", $output, $return_var);
|
$db_hosts_tmp1 = json_decode(implode('', $output), true);
|
||||||
$db_hosts_tmp = json_decode(implode('', $output), true);
|
$db_hosts_tmp2 = array_map(function($host){return $host['HOST'];}, $db_hosts_tmp1);
|
||||||
$db_hosts = array_merge($db_hosts, $db_hosts_tmp);
|
$db_hosts = array_values(array_unique($db_hosts_tmp2));
|
||||||
unset($db_hosts_tmp);
|
|
||||||
unset($output);
|
unset($output);
|
||||||
|
unset($db_hosts_tmp1);
|
||||||
|
unset($db_hosts_tmp2);
|
||||||
|
|
||||||
// Display body
|
// Display body
|
||||||
include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_db.html');
|
include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_db.html');
|
||||||
|
@ -136,4 +137,3 @@ unset($_SESSION['ok_msg']);
|
||||||
|
|
||||||
// Footer
|
// Footer
|
||||||
include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html');
|
include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html');
|
||||||
?>
|
|
||||||
|
|
|
@ -46,21 +46,15 @@ foreach ($dns_cluster as $key => $value) {
|
||||||
$v_dns_cluster = 'yes';
|
$v_dns_cluster = 'yes';
|
||||||
}
|
}
|
||||||
|
|
||||||
// List MySQL hosts
|
// List Database hosts
|
||||||
exec (VESTA_CMD."v-list-database-hosts mysql json", $output, $return_var);
|
exec (VESTA_CMD."v-list-database-hosts json", $output, $return_var);
|
||||||
$v_mysql_hosts = json_decode(implode('', $output), true);
|
$db_hosts = json_decode(implode('', $output), true);
|
||||||
unset($output);
|
unset($output);
|
||||||
foreach ($v_mysql_hosts as $key => $value) {
|
$v_mysql_hosts = array_values(array_filter($db_hosts, function($host){return $host['TYPE'] === 'mysql';}));
|
||||||
$v_mysql = 'yes';
|
$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';
|
||||||
// List PostgreSQL hosts
|
unset($db_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';
|
|
||||||
}
|
|
||||||
|
|
||||||
// List backup settings
|
// List backup settings
|
||||||
$v_backup_dir = "/backup";
|
$v_backup_dir = "/backup";
|
||||||
|
|
|
@ -125,10 +125,10 @@
|
||||||
<td>
|
<td>
|
||||||
<select class="vst-list" name="v_host">
|
<select class="vst-list" name="v_host">
|
||||||
<?php
|
<?php
|
||||||
foreach ($db_hosts as $key => $value) {
|
foreach ($db_hosts as $value) {
|
||||||
echo "\n\t\t\t\t\t\t\t\t\t\t<option value=\"".htmlentities($key)."\"";
|
echo "\n\t\t\t\t\t\t\t\t\t\t<option value=\"".htmlentities($value)."\"";
|
||||||
if ((!empty($v_host)) && ( $key == $v_host )) echo ' selected';
|
if ((!empty($v_host)) && ( $value == $v_host )) echo ' selected';
|
||||||
echo ">".htmlentities($key)."</option>";
|
echo ">".htmlentities($value)."</option>";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</select>
|
</select>
|
||||||
|
|
|
@ -336,7 +336,7 @@
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<?php if ($v_mysql == 'yes') {
|
<?php if ($v_mysql == 'yes') {
|
||||||
$i = 0;
|
$i = 0;
|
||||||
foreach ($v_mysql_hosts as $key => $value) {
|
foreach ($v_mysql_hosts as $value) {
|
||||||
$i++;
|
$i++;
|
||||||
?>
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -346,7 +346,7 @@
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="step-left">
|
<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>
|
<br><br>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -416,7 +416,7 @@
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<?php if ($v_pgsql == 'yes') {
|
<?php if ($v_pgsql == 'yes') {
|
||||||
$i = 0;
|
$i = 0;
|
||||||
foreach ($v_pgsql_hosts as $key => $value) {
|
foreach ($v_pgsql_hosts as $value) {
|
||||||
$i++;
|
$i++;
|
||||||
?>
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -426,7 +426,7 @@
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="step-left">
|
<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>
|
<br><br>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue