|
| 1 | +<?php |
| 2 | +// Init |
| 3 | +error_reporting(NULL); |
| 4 | +ob_start(); |
| 5 | +session_start(); |
| 6 | + |
| 7 | +$TAB = 'IP'; |
| 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['ip'])) { |
| 21 | + header("Location: /list/ip/"); |
| 22 | + exit; |
| 23 | + } |
| 24 | + |
| 25 | + $v_ip = escapeshellarg($_GET['ip']); |
| 26 | + exec (VESTA_CMD."v_list_sys_ip ".$v_ip." '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_ip = $_GET['ip']; |
| 36 | + $v_netmask = $data[$v_ip]['NETMASK']; |
| 37 | + $v_interace = $data[$v_ip]['INTERFACE']; |
| 38 | + $v_name = $data[$v_ip]['NAME']; |
| 39 | + $v_ipstatus = $data[$v_ip]['STATUS']; |
| 40 | + if ($v_ipstatus == 'dedicated') $v_dedicated = 'yes'; |
| 41 | + $v_owner = $data[$v_ip]['OWNER']; |
| 42 | + $v_date = $data[$v_ip]['DATE']; |
| 43 | + $v_time = $data[$v_ip]['TIME']; |
| 44 | + $v_suspended = $data[$v_ip]['SUSPENDED']; |
| 45 | + if ( $v_suspended == 'yes' ) { |
| 46 | + $v_status = 'suspended'; |
| 47 | + } else { |
| 48 | + $v_status = 'active'; |
| 49 | + } |
| 50 | + |
| 51 | + exec (VESTA_CMD."v_list_sys_users 'json'", $output, $return_var); |
| 52 | + $users = json_decode(implode('', $output), true); |
| 53 | + unset($output); |
| 54 | + |
| 55 | + // Action |
| 56 | + if (!empty($_POST['save'])) { |
| 57 | + $v_username = $user; |
| 58 | + $v_ip = escapeshellarg($_POST['v_ip']); |
| 59 | + |
| 60 | + // Change Status |
| 61 | + if (($v_ipstatus == 'shared') && (empty($_POST['v_shared'])) && (empty($_SESSION['error_msg']))) { |
| 62 | + exec (VESTA_CMD."v_change_sys_ip_status ".$v_ip." 'dedicated'", $output, $return_var); |
| 63 | + if ($return_var != 0) { |
| 64 | + $error = implode('<br>', $output); |
| 65 | + if (empty($error)) $error = 'Error: vesta did not return any output.'; |
| 66 | + $_SESSION['error_msg'] = $error; |
| 67 | + } |
| 68 | + unset($output); |
| 69 | + $v_dedicated = 'yes'; |
| 70 | + } |
| 71 | + if (($v_ipstatus == 'dedicated') && (!empty($_POST['v_shared'])) && (empty($_SESSION['error_msg']))) { |
| 72 | + exec (VESTA_CMD."v_change_sys_ip_status ".$v_ip." 'shared'", $output, $return_var); |
| 73 | + if ($return_var != 0) { |
| 74 | + $error = implode('<br>', $output); |
| 75 | + if (empty($error)) $error = 'Error: vesta did not return any output.'; |
| 76 | + $_SESSION['error_msg'] = $error; |
| 77 | + } |
| 78 | + unset($output); |
| 79 | + unset($v_dedicated); |
| 80 | + } |
| 81 | + |
| 82 | + // Change owner |
| 83 | + if (($v_owner != $_POST['v_owner']) && (empty($_SESSION['error_msg']))) { |
| 84 | + $v_owner = escapeshellarg($_POST['v_owner']); |
| 85 | + exec (VESTA_CMD."v_change_sys_ip_owner ".$v_ip." ".$v_owner, $output, $return_var); |
| 86 | + if ($return_var != 0) { |
| 87 | + $error = implode('<br>', $output); |
| 88 | + if (empty($error)) $error = 'Error: vesta did not return any output.'; |
| 89 | + $_SESSION['error_msg'] = $error; |
| 90 | + } |
| 91 | + $v_owner = $_POST['v_owner']; |
| 92 | + unset($output); |
| 93 | + } |
| 94 | + |
| 95 | + // Change Name |
| 96 | + if (($v_name != $_POST['v_name']) && (empty($_SESSION['error_msg']))) { |
| 97 | + $v_name = escapeshellarg($_POST['v_name']); |
| 98 | + exec (VESTA_CMD."v_change_sys_ip_name ".$v_ip." ".$v_name, $output, $return_var); |
| 99 | + if ($return_var != 0) { |
| 100 | + $error = implode('<br>', $output); |
| 101 | + if (empty($error)) $error = 'Error: vesta did not return any output.'; |
| 102 | + $_SESSION['error_msg'] = $error; |
| 103 | + } |
| 104 | + unset($output); |
| 105 | + } |
| 106 | + |
| 107 | + if (empty($_SESSION['error_msg'])) { |
| 108 | + $_SESSION['ok_msg'] = "OK: changes has been saved."; |
| 109 | + } |
| 110 | + } |
| 111 | + } |
| 112 | + |
| 113 | + include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/menu_edit_ip.html'); |
| 114 | + include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_ip.html'); |
| 115 | + unset($_SESSION['error_msg']); |
| 116 | + unset($_SESSION['ok_msg']); |
| 117 | +} |
| 118 | + |
| 119 | +// Footer |
| 120 | +include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); |
0 commit comments