mirror of
https://github.com/myvesta/vesta
synced 2025-08-14 18:49:21 -07:00
Improved code formating
This commit is contained in:
parent
2f300aab69
commit
2558fa550d
15 changed files with 1723 additions and 1655 deletions
|
@ -3,8 +3,8 @@
|
|||
error_reporting(NULL);
|
||||
ob_start();
|
||||
session_start();
|
||||
|
||||
$TAB = 'DB';
|
||||
|
||||
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
|
||||
|
||||
// Header
|
||||
|
@ -13,6 +13,7 @@ include($_SERVER['DOCUMENT_ROOT'].'/templates/header.html');
|
|||
// Panel
|
||||
top_panel($user,$TAB);
|
||||
|
||||
// Check database id
|
||||
if (empty($_GET['database'])) {
|
||||
header("Location: /list/db/");
|
||||
exit;
|
||||
|
@ -23,69 +24,63 @@ if (($_SESSION['user'] == 'admin') && (!empty($_GET['user']))) {
|
|||
$user=escapeshellarg($_GET['user']);
|
||||
}
|
||||
|
||||
// List datbase
|
||||
$v_database = escapeshellarg($_GET['database']);
|
||||
exec (VESTA_CMD."v-list-database ".$user." ".$v_database." 'json'", $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
$data = json_decode(implode('', $output), true);
|
||||
unset($output);
|
||||
$data = json_decode(implode('', $output), true);
|
||||
unset($output);
|
||||
|
||||
// Parse database
|
||||
$v_username = $user;
|
||||
$v_database = $_GET['database'];
|
||||
$v_dbuser = $data[$v_database]['DBUSER'];
|
||||
$v_password = "••••••••";
|
||||
$v_host = $data[$v_database]['HOST'];
|
||||
$v_type = $data[$v_database]['TYPE'];
|
||||
$v_charset = $data[$v_database]['CHARSET'];
|
||||
$v_date = $data[$v_database]['DATE'];
|
||||
$v_time = $data[$v_database]['TIME'];
|
||||
$v_suspended = $data[$v_database]['SUSPENDED'];
|
||||
if ( $v_suspended == 'yes' ) {
|
||||
$v_status = 'suspended';
|
||||
} else {
|
||||
$v_status = 'active';
|
||||
}
|
||||
|
||||
// Check POST request
|
||||
if (!empty($_POST['save'])) {
|
||||
$v_username = $user;
|
||||
$v_database = $_GET['database'];
|
||||
$v_dbuser = $data[$v_database]['DBUSER'];
|
||||
$v_password = "••••••••";
|
||||
$v_host = $data[$v_database]['HOST'];
|
||||
$v_type = $data[$v_database]['TYPE'];
|
||||
$v_charset = $data[$v_database]['CHARSET'];
|
||||
$v_date = $data[$v_database]['DATE'];
|
||||
$v_time = $data[$v_database]['TIME'];
|
||||
$v_suspended = $data[$v_database]['SUSPENDED'];
|
||||
if ( $v_suspended == 'yes' ) {
|
||||
$v_status = 'suspended';
|
||||
} else {
|
||||
$v_status = 'active';
|
||||
|
||||
// Change database user
|
||||
if (($v_dbuser != $_POST['v_dbuser']) && (empty($_SESSION['error_msg']))) {
|
||||
$v_dbuser = preg_replace("/^".$user."_/", "", $_POST['v_dbuser']);
|
||||
$v_dbuser = escapeshellarg($v_dbuser);
|
||||
exec (VESTA_CMD."v-change-database-user ".$v_username." ".$v_database." ".$v_dbuser, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
$v_dbuser = $user."_".preg_replace("/^".$user."_/", "", $_POST['v_dbuser']);
|
||||
}
|
||||
|
||||
// Action
|
||||
if (!empty($_POST['save'])) {
|
||||
$v_username = $user;
|
||||
// Change database password
|
||||
if (($v_password != $_POST['v_password']) && (empty($_SESSION['error_msg']))) {
|
||||
$v_password = escapeshellarg($_POST['v_password']);
|
||||
exec (VESTA_CMD."v-change-database-password ".$v_username." ".$v_database." ".$v_password, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
$v_password = "••••••••";
|
||||
unset($output);
|
||||
}
|
||||
|
||||
// Change database username
|
||||
if (($v_dbuser != $_POST['v_dbuser']) && (empty($_SESSION['error_msg']))) {
|
||||
$v_dbuser = preg_replace("/^".$user."_/", "", $_POST['v_dbuser']);
|
||||
$v_dbuser = escapeshellarg($v_dbuser);
|
||||
if ($v_password != $_POST['v_password']) {
|
||||
// Change username and password
|
||||
$v_password = escapeshellarg($_POST['v_password']);
|
||||
exec (VESTA_CMD."v-change-database-user ".$v_username." ".$v_database." ".$v_dbuser." ".$v_password, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
$v_dbuser = $user."_".preg_replace("/^".$user."_/", "", $_POST['v_dbuser']);
|
||||
$v_password = "••••••••";
|
||||
$v_pw_changed = 'yes';
|
||||
} else {
|
||||
// Change only username
|
||||
exec (VESTA_CMD."v-change-database-user ".$v_username." ".$v_database." ".$v_dbuser, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
$v_dbuser = $user."_".preg_replace("/^".$user."_/", "", $_POST['v_dbuser']);
|
||||
}
|
||||
}
|
||||
|
||||
// Change only database password
|
||||
if (($v_password != $_POST['v_password']) && (!isset($v_pw_changed)) && (empty($_SESSION['error_msg']))) {
|
||||
$v_password = escapeshellarg($_POST['v_password']);
|
||||
exec (VESTA_CMD."v-change-database-password ".$v_username." ".$v_database." ".$v_password, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
$v_password = "••••••••";
|
||||
unset($output);
|
||||
}
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
$_SESSION['ok_msg'] = __('Changes has been saved.');
|
||||
}
|
||||
// Set success message
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
$_SESSION['ok_msg'] = __('Changes has been saved.');
|
||||
}
|
||||
}
|
||||
|
||||
// Display body
|
||||
include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_db.html');
|
||||
|
||||
// Flush session messages
|
||||
unset($_SESSION['error_msg']);
|
||||
unset($_SESSION['ok_msg']);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue