Merge pull request #738 from Flatta/fix-listdbhosts-call

Fix /edit/server/ always says database unsupported
This commit is contained in:
Serghey Rodin 2016-07-05 12:00:08 +03:00 committed by GitHub
commit 3d27ad4fe7
5 changed files with 83 additions and 89 deletions

View file

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

View file

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

View file

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

View file

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

View file

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