|
| 1 | +<?php |
| 2 | +// Init |
| 3 | +error_reporting(NULL); |
| 4 | +ob_start(); |
| 5 | +session_start(); |
| 6 | + |
| 7 | +$TAB = 'DB'; |
| 8 | +include($_SERVER['DOCUMENT_ROOT']."/inc/main.php"); |
| 9 | + |
| 10 | +// Header |
| 11 | +include($_SERVER['DOCUMENT_ROOT'].'/templates/header.html'); |
| 12 | + |
| 13 | +// Panel |
| 14 | +top_panel($user,$TAB); |
| 15 | + |
| 16 | +// Are you admin? |
| 17 | +if ($_SESSION['user'] == 'admin') { |
| 18 | + |
| 19 | + // Check user argument? |
| 20 | + if (empty($_GET['database'])) { |
| 21 | + header("Location: /list/db/"); |
| 22 | + exit; |
| 23 | + } |
| 24 | + |
| 25 | + $v_database = escapeshellarg($_GET['database']); |
| 26 | + exec (VESTA_CMD."v_list_database ".$user." ".$v_database." 'json'", $output, $return_var); |
| 27 | + if ($return_var != 0) { |
| 28 | + $error = implode('<br>', $output); |
| 29 | + if (empty($error)) $error = 'Error: vesta did not return any output.'; |
| 30 | + $_SESSION['error_msg'] = $error; |
| 31 | + } else { |
| 32 | + $data = json_decode(implode('', $output), true); |
| 33 | + unset($output); |
| 34 | + $v_username = $user; |
| 35 | + $v_database = $_GET['database']; |
| 36 | + $v_dbuser = $data[$v_database]['DBUSER']; |
| 37 | + $v_password = "••••••••"; |
| 38 | + $v_host = $data[$v_database]['HOST']; |
| 39 | + $v_type = $data[$v_database]['TYPE']; |
| 40 | + $v_charset = $data[$v_database]['CHARSET']; |
| 41 | + $v_date = $data[$v_database]['DATE']; |
| 42 | + $v_time = $data[$v_database]['TIME']; |
| 43 | + $v_suspended = $data[$v_database]['SUSPENDED']; |
| 44 | + if ( $v_suspended == 'yes' ) { |
| 45 | + $v_status = 'suspended'; |
| 46 | + } else { |
| 47 | + $v_status = 'active'; |
| 48 | + } |
| 49 | + |
| 50 | + // Action |
| 51 | + if (!empty($_POST['save'])) { |
| 52 | + $v_username = $user; |
| 53 | + // Change password |
| 54 | + if (($v_password != $_POST['v_password']) && (empty($_SESSION['error_msg']))) { |
| 55 | + $v_password = escapeshellarg($_POST['v_password']); |
| 56 | + exec (VESTA_CMD."v_change_database_password ".$v_username." ".$v_database." ".$v_password, $output, $return_var); |
| 57 | + if ($return_var != 0) { |
| 58 | + $error = implode('<br>', $output); |
| 59 | + if (empty($error)) $error = 'Error: vesta did not return any output.'; |
| 60 | + $_SESSION['error_msg'] = $error; |
| 61 | + } |
| 62 | + $v_password = "••••••••"; |
| 63 | + unset($output); |
| 64 | + } |
| 65 | + if (empty($_SESSION['error_msg'])) { |
| 66 | + $_SESSION['ok_msg'] = "OK: changes has been saved."; |
| 67 | + } |
| 68 | + } |
| 69 | + } |
| 70 | + |
| 71 | + include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/menu_edit_db.html'); |
| 72 | + include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_db.html'); |
| 73 | + unset($_SESSION['error_msg']); |
| 74 | + unset($_SESSION['ok_msg']); |
| 75 | +} |
| 76 | + |
| 77 | +// Footer |
| 78 | +include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); |
0 commit comments