Fix /edit/server/ always says database unsupported

This commit changes interface of bin/v-list-database-hosts
This commit is contained in:
Flat 2016-07-03 15:09:32 +09:00
parent 656d34ed0b
commit e0f695e493
5 changed files with 83 additions and 89 deletions

View file

@ -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

View file

@ -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');
?>

View file

@ -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";

View file

@ -68,7 +68,7 @@
</tr>
<tr>
<td class="vst-text input-label">
<?php print __('Database');?>
<?php print __('Database');?>
</td>
</tr>
<tr>
@ -79,7 +79,7 @@
</tr>
<tr>
<td class="vst-text input-label">
<?php print __('User');?>
<?php print __('User');?>
</td>
</tr>
<tr>
@ -100,7 +100,7 @@
</tr>
<tr>
<td class="vst-text input-label">
<?php print __('Type');?>
<?php print __('Type');?>
</td>
</tr>
<tr>
@ -112,32 +112,32 @@
if ((!empty($v_type)) && ( $value == $v_type )) echo ' selected';
echo ">".htmlentities($value)."</option>";
}
?>
?>
</select>
</td>
</tr>
<tr>
<td class="vst-text input-label">
<?php print __('Host');?>
<?php print __('Host');?>
</td>
</tr>
<tr>
<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>
</td>
</tr>
<tr>
<td class="vst-text input-label">
<?php print __('Charset');?>
<?php print __('Charset');?>
</td>
</tr>
<tr>
@ -183,7 +183,7 @@
</td>
<tr>
<td class="vst-text input-label">
<?php print __('Send login credentials to email address') ?>
<?php print __('Send login credentials to email address') ?>
</td>
</tr>
<tr>

View file

@ -54,7 +54,7 @@
<table class="data-col2" width="600px">
<tr>
<td class="vst-text step-top">
<?php print __('Hostname') ?>
<?php print __('Hostname') ?>
</td>
</tr>
<tr>
@ -82,7 +82,7 @@
}
echo ">".$value."</option>\n";
}
?>
?>
</select>
<br><br>
</td>
@ -106,7 +106,7 @@
}
echo ">".$value."</option>\n";
}
?>
?>
</select>
<br><br>
</td>
@ -121,10 +121,10 @@
<tr>
<td class="vst-text input-label step-left">
<table style="display:<?php if (empty($v_adv)) echo 'none';?> ;" id="web">
<?php if (!empty($_SESSION['PROXY_SYSTEM'])) { ?>
<?php if (!empty($_SESSION['PROXY_SYSTEM'])) { ?>
<tr>
<td class="vst-text">
<?php print __('Proxy Server') ?>
<?php print __('Proxy Server') ?>
</td>
</tr>
<tr>
@ -133,10 +133,10 @@
<br><br>
</td>
</tr>
<?php } ?>
<?php } ?>
<tr>
<td class="vst-text">
<?php print __('Web Server') ?>
<?php print __('Web Server') ?>
</td>
</tr>
<tr>
@ -145,10 +145,10 @@
<br><br>
</td>
</tr>
<?php if (!empty($_SESSION['WEB_BACKEND'])) { ?>
<?php if (!empty($_SESSION['WEB_BACKEND'])) { ?>
<tr>
<td class="vst-text">
<?php print __('Backend Server') ?>
<?php print __('Backend Server') ?>
</td>
</tr>
<tr>
@ -159,7 +159,7 @@
</tr>
<tr>
<td class="vst-text">
<?php print __('Backend Pool Mode') ?>
<?php print __('Backend Pool Mode') ?>
</td>
</tr>
<tr>
@ -169,7 +169,7 @@
</td>
</tr>
<?php } ?>
<?php } ?>
</table>
</td>
</tr>
@ -187,7 +187,7 @@
<table style="display:<?php if (empty($v_adv)) echo 'none';?> ;" id="dns">
<tr>
<td class="vst-text">
<?php print __('DNS Server') ?>
<?php print __('DNS Server') ?>
</td>
</tr>
<tr>
@ -215,10 +215,10 @@
$i = 0;
foreach ($dns_cluster as $key => $value) {
$i++;
?>
?>
<tr>
<td class="vst-text step-left">
<?php print __('Host'). ' #'.$i ?>
<?php print __('Host'). ' #'.$i ?>
</td>
</tr>
<tr>
@ -227,7 +227,7 @@
<br><br>
</td>
</tr>
<?php }} ?>
<?php }} ?>
</table>
</td>
</tr>
@ -245,7 +245,7 @@
<table style="display:<?php if (empty($v_mail_adv)) echo 'none';?> ;" id="mail">
<tr>
<td class="vst-text">
<?php print __('MAIL Server') ?>
<?php print __('MAIL Server') ?>
</td>
</tr>
<tr>
@ -254,10 +254,10 @@
<br><br>
</td>
</tr>
<?php if (!empty($_SESSION['ANTIVIRUS_SYSTEM'])) { ?>
<?php if (!empty($_SESSION['ANTIVIRUS_SYSTEM'])) { ?>
<tr>
<td class="vst-text">
<?php print __('Antivirus') ?>
<?php print __('Antivirus') ?>
</td>
</tr>
<tr>
@ -266,11 +266,11 @@
<br><br>
</td>
</tr>
<?php } ?>
<?php if (!empty($_SESSION['ANTISPAM_SYSTEM'])) { ?>
<?php } ?>
<?php if (!empty($_SESSION['ANTISPAM_SYSTEM'])) { ?>
<tr>
<td class="vst-text">
<?php print __('AntiSpam') ?>
<?php print __('AntiSpam') ?>
</td>
</tr>
<tr>
@ -279,10 +279,10 @@
<br><br>
</td>
</tr>
<?php } ?>
<?php } ?>
<tr>
<td class="vst-text">
<?php print __('Webmail URL') ?>
<?php print __('Webmail URL') ?>
</td>
</tr>
<tr>
@ -324,7 +324,7 @@
<?php if ($v_mysql == 'yes') { ?>
<tr>
<td class="vst-text">
<?php print __('phpMyAdmin URL') ?>
<?php print __('phpMyAdmin URL') ?>
</td>
</tr>
<tr>
@ -336,23 +336,23 @@
<?php } ?>
<?php if ($v_mysql == 'yes') {
$i = 0;
foreach ($v_mysql_hosts as $key => $value) {
foreach ($v_mysql_hosts as $value) {
$i++;
?>
?>
<tr>
<td class="vst-text step-left">
<?php print __('Host'). ' #'.$i ?>
<?php print __('Host'). ' #'.$i ?>
</td>
</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>
<tr>
<td class="vst-text step-left">
<?php print __('Password') ?>
<?php print __('Password') ?>
</td>
</tr>
<tr>
@ -364,7 +364,7 @@
<tr>
<td class="vst-text step-left">
<?php print __('Maximum Number Of Databases') ?>
<?php print __('Maximum Number Of Databases') ?>
</td>
</tr>
<tr>
@ -375,7 +375,7 @@
</tr>
<tr>
<td class="vst-text step-left">
<?php print __('Current Number Of Databases') ?>
<?php print __('Current Number Of Databases') ?>
</td>
</tr>
<tr>
@ -384,7 +384,7 @@
<br><br><br><br>
</td>
</tr>
<?php }} ?>
<?php }} ?>
<tr>
@ -404,7 +404,7 @@
<?php if ($v_pgsql == 'yes') { ?>
<tr>
<td class="vst-text">
<?php print __('phpPgAdmin URL') ?>
<?php print __('phpPgAdmin URL') ?>
</td>
</tr>
<tr>
@ -416,23 +416,23 @@
<?php } ?>
<?php if ($v_pgsql == 'yes') {
$i = 0;
foreach ($v_pgsql_hosts as $key => $value) {
foreach ($v_pgsql_hosts as $value) {
$i++;
?>
?>
<tr>
<td class="vst-text step-left">
<?php print __('Host'). ' #'.$i ?>
<?php print __('Host'). ' #'.$i ?>
</td>
</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>
<tr>
<td class="vst-text step-left">
<?php print __('Maximum Number Of Databases') ?>
<?php print __('Maximum Number Of Databases') ?>
</td>
</tr>
<tr>
@ -443,7 +443,7 @@
</tr>
<tr>
<td class="vst-text step-left">
<?php print __('Current Number Of Databases') ?>
<?php print __('Current Number Of Databases') ?>
</td>
</tr>
<tr>
@ -452,7 +452,7 @@
<br><br><br><br>
</td>
</tr>
<?php }} ?>
<?php }} ?>
</table>
</td>
</tr>
@ -470,7 +470,7 @@
<table style="display:<?php if (empty($v_backup_adv)) echo 'none';?> ;" id="backup">
<tr>
<td class="vst-text">
<?php print __('Local backup') ?>
<?php print __('Local backup') ?>
</td>
</tr>
<tr>
@ -484,7 +484,7 @@
</tr>
<tr>
<td class="vst-text">
<?php print __('Compression level') ?>
<?php print __('Compression level') ?>
</td>
</tr>
<tr>
@ -505,7 +505,7 @@
</tr>
<tr>
<td class="vst-text">
<?php print __('Directory') ?>
<?php print __('Directory') ?>
</td>
</tr>
<tr>
@ -524,7 +524,7 @@
<td class="vst-text input-label step-left">
<table style="display:<?php if (empty($v_backup_remote_adv)) echo 'none';?> ;" id="remote_backup">
<td class="vst-text">
<?php print __('Protocol') ?>
<?php print __('Protocol') ?>
</td>
</tr>
<tr>
@ -538,7 +538,7 @@
</tr>
<tr>
<td class="vst-text">
<?php print __('Host') ?>
<?php print __('Host') ?>
</td>
</tr>
<tr>
@ -549,7 +549,7 @@
</tr>
<tr>
<td class="vst-text">
<?php print __('Username') ?>
<?php print __('Username') ?>
</td>
</tr>
<tr>
@ -560,7 +560,7 @@
</tr>
<tr>
<td class="vst-text">
<?php print __('Password') ?>
<?php print __('Password') ?>
</td>
</tr>
<tr>
@ -571,7 +571,7 @@
</tr>
<tr>
<td class="vst-text">
<?php print __('Directory') ?>
<?php print __('Directory') ?>
</td>
</tr>
<tr>
@ -599,7 +599,7 @@
<table style="display:<?php if (empty($v_adv) && $_GET['lead'] != 'filemanager' && $_GET['lead'] != 'sftp') echo 'none';?> ;" id="vesta">
<tr>
<td class="vst-text">
<?php print __('Version') ?>
<?php print __('Version') ?>
</td>
</tr>
<tr>
@ -638,7 +638,7 @@
</tr>
<tr>
<td class="vst-text">
<?php print __('Reseller Role') ?>
<?php print __('Reseller Role') ?>
</td>
</tr>
<tr>
@ -651,7 +651,7 @@
</tr>
<tr>
<td class="vst-text">
<?php print __('Backup Migration Manager') ?>
<?php print __('Backup Migration Manager') ?>
</td>
</tr>
<tr>
@ -690,7 +690,7 @@
'.__('Licence Key').': <input type="text" class="vst-input" name="v_sftp_licence" value="'.$licence_key.'" /><br>
</div>';
} 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.').
'<div class="licence">
'.__('Enter License Key').': <input type="text" class="vst-input" name="v_sftp_licence" /><br>
@ -712,7 +712,7 @@
<tr>
<td class="vst-text" id="module-filemanager">
<?php print __('File Manager') ?>
<?php print __('File Manager') ?>
</td>
</tr>
<tr>
@ -797,4 +797,4 @@
}
});
});
</script>
</script>