|
| 1 | +<?php |
| 2 | +// Init |
| 3 | +//error_reporting(NULL); |
| 4 | +ob_start(); |
| 5 | +session_start(); |
| 6 | + |
| 7 | +$TAB = 'MAIL'; |
| 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['domain'])) { |
| 21 | + header("Location: /list/mail/"); |
| 22 | + } |
| 23 | + |
| 24 | + if (!empty($_POST['cancel'])) { |
| 25 | + header("Location: /list/mail/"); |
| 26 | + } |
| 27 | + |
| 28 | + // Check domain |
| 29 | + if ((!empty($_GET['domain'])) && (empty($_GET['account']))) { |
| 30 | + $v_domain = escapeshellarg($_GET['domain']); |
| 31 | + exec (VESTA_CMD."v_list_mail_domain ".$user." ".$v_domain." json", $output, $return_var); |
| 32 | + if ($return_var != 0) { |
| 33 | + $error = implode('<br>', $output); |
| 34 | + if (empty($error)) $error = 'Error: vesta did not return any output.'; |
| 35 | + $_SESSION['error_msg'] = $error; |
| 36 | + } else { |
| 37 | + $data = json_decode(implode('', $output), true); |
| 38 | + unset($output); |
| 39 | + $v_username = $user; |
| 40 | + $v_domain = $_GET['domain']; |
| 41 | + $v_antispam = $data[$v_domain]['ANTISPAM']; |
| 42 | + $v_antivirus = $data[$v_domain]['ANTIVIRUS']; |
| 43 | + $v_dkim = $data[$v_domain]['DKIM']; |
| 44 | + $v_catchall = $data[$v_domain]['CATCHALL']; |
| 45 | + $v_date = $data[$v_domain]['DATE']; |
| 46 | + $v_time = $data[$v_domain]['TIME']; |
| 47 | + $v_suspended = $data[$v_domain]['SUSPENDED']; |
| 48 | + if ( $v_suspended == 'yes' ) { |
| 49 | + $v_status = 'suspended'; |
| 50 | + } else { |
| 51 | + $v_status = 'active'; |
| 52 | + } |
| 53 | + } |
| 54 | + |
| 55 | + // Action |
| 56 | + if (!empty($_POST['save'])) { |
| 57 | + $v_domain = escapeshellarg($_POST['v_domain']); |
| 58 | + |
| 59 | + // Antispam |
| 60 | + if (($v_antispam == 'yes') && (empty($_POST['v_antispam'])) && (empty($_SESSION['error_msg']))) { |
| 61 | + exec (VESTA_CMD."v_delete_mail_domain_antispam ".$v_username." ".$v_domain, $output, $return_var); |
| 62 | + if ($return_var != 0) { |
| 63 | + $error = implode('<br>', $output); |
| 64 | + if (empty($error)) $error = 'Error: vesta did not return any output.'; |
| 65 | + $_SESSION['error_msg'] = $error; |
| 66 | + } |
| 67 | + $v_antispam = 'no'; |
| 68 | + unset($output); |
| 69 | + } |
| 70 | + if (($v_antispam == 'no') && (!empty($_POST['v_antispam'])) && (empty($_SESSION['error_msg']))) { |
| 71 | + exec (VESTA_CMD."v_add_mail_domain_antispam ".$v_username." ".$v_domain, $output, $return_var); |
| 72 | + if ($return_var != 0) { |
| 73 | + $error = implode('<br>', $output); |
| 74 | + if (empty($error)) $error = 'Error: vesta did not return any output.'; |
| 75 | + $_SESSION['error_msg'] = $error; |
| 76 | + } |
| 77 | + $v_antispam = 'yes'; |
| 78 | + unset($output); |
| 79 | + } |
| 80 | + |
| 81 | + // Antivirus |
| 82 | + if (($v_antivirus == 'yes') && (empty($_POST['v_antivirus'])) && (empty($_SESSION['error_msg']))) { |
| 83 | + exec (VESTA_CMD."v_delete_mail_domain_antivirus ".$v_username." ".$v_domain, $output, $return_var); |
| 84 | + if ($return_var != 0) { |
| 85 | + $error = implode('<br>', $output); |
| 86 | + if (empty($error)) $error = 'Error: vesta did not return any output.'; |
| 87 | + $_SESSION['error_msg'] = $error; |
| 88 | + } |
| 89 | + $v_antivirus = 'no'; |
| 90 | + unset($output); |
| 91 | + } |
| 92 | + if (($v_antivirus == 'no') && (!empty($_POST['v_antivirus'])) && (empty($_SESSION['error_msg']))) { |
| 93 | + exec (VESTA_CMD."v_add_mail_domain_antivirus ".$v_username." ".$v_domain, $output, $return_var); |
| 94 | + if ($return_var != 0) { |
| 95 | + $error = implode('<br>', $output); |
| 96 | + if (empty($error)) $error = 'Error: vesta did not return any output.'; |
| 97 | + $_SESSION['error_msg'] = $error; |
| 98 | + } |
| 99 | + $v_antivirus = 'yes'; |
| 100 | + unset($output); |
| 101 | + } |
| 102 | + |
| 103 | + if (empty($_SESSION['error_msg'])) { |
| 104 | + $_SESSION['ok_msg'] = "OK: changes has been saved."; |
| 105 | + } |
| 106 | + |
| 107 | + // DKIM |
| 108 | + if (($v_dkim == 'yes') && (empty($_POST['v_dkim'])) && (empty($_SESSION['error_msg']))) { |
| 109 | + exec (VESTA_CMD."v_delete_mail_domain_dkim ".$v_username." ".$v_domain, $output, $return_var); |
| 110 | + if ($return_var != 0) { |
| 111 | + $error = implode('<br>', $output); |
| 112 | + if (empty($error)) $error = 'Error: vesta did not return any output.'; |
| 113 | + $_SESSION['error_msg'] = $error; |
| 114 | + } |
| 115 | + $v_dkim = 'no'; |
| 116 | + unset($output); |
| 117 | + } |
| 118 | + if (($v_dkim == 'no') && (!empty($_POST['v_dkim'])) && (empty($_SESSION['error_msg']))) { |
| 119 | + exec (VESTA_CMD."v_add_mail_domain_dkim ".$v_username." ".$v_domain, $output, $return_var); |
| 120 | + if ($return_var != 0) { |
| 121 | + $error = implode('<br>', $output); |
| 122 | + if (empty($error)) $error = 'Error: vesta did not return any output.'; |
| 123 | + $_SESSION['error_msg'] = $error; |
| 124 | + } |
| 125 | + $v_dkim = 'yes'; |
| 126 | + unset($output); |
| 127 | + } |
| 128 | + |
| 129 | + // Catchall |
| 130 | + if ((!empty($v_catchall)) && (empty($_POST['v_catchall'])) && (empty($_SESSION['error_msg']))) { |
| 131 | + exec (VESTA_CMD."v_delete_mail_domain_catchall ".$v_username." ".$v_domain, $output, $return_var); |
| 132 | + if ($return_var != 0) { |
| 133 | + $error = implode('<br>', $output); |
| 134 | + if (empty($error)) $error = 'Error: vesta did not return any output.'; |
| 135 | + $_SESSION['error_msg'] = $error; |
| 136 | + } |
| 137 | + $v_catchall = ''; |
| 138 | + unset($output); |
| 139 | + } |
| 140 | + |
| 141 | + if ((!empty($v_catchall)) && (!empty($_POST['v_catchall'])) && (empty($_SESSION['error_msg']))) { |
| 142 | + if ($v_catchall != $_POST['v_catchall']) { |
| 143 | + $v_catchall = escapeshellarg($_POST['v_catchall']); |
| 144 | + exec (VESTA_CMD."v_change_mail_domain_catchall ".$v_username." ".$v_domain." ".$v_catchall, $output, $return_var); |
| 145 | + if ($return_var != 0) { |
| 146 | + $error = implode('<br>', $output); |
| 147 | + if (empty($error)) $error = 'Error: vesta did not return any output.'; |
| 148 | + $_SESSION['error_msg'] = $error; |
| 149 | + } |
| 150 | + unset($output); |
| 151 | + } |
| 152 | + } |
| 153 | + |
| 154 | + if ((empty($v_catchall)) && (!empty($_POST['v_catchall'])) && (empty($_SESSION['error_msg']))) { |
| 155 | + $v_catchall = escapeshellarg($_POST['v_catchall']); |
| 156 | + exec (VESTA_CMD."v_add_mail_domain_catchall ".$v_username." ".$v_domain." ".$v_catchall, $output, $return_var); |
| 157 | + if ($return_var != 0) { |
| 158 | + $error = implode('<br>', $output); |
| 159 | + if (empty($error)) $error = 'Error: vesta did not return any output.'; |
| 160 | + $_SESSION['error_msg'] = $error; |
| 161 | + } |
| 162 | + unset($output); |
| 163 | + } |
| 164 | + |
| 165 | + if (empty($_SESSION['error_msg'])) { |
| 166 | + $_SESSION['ok_msg'] = "OK: changes has been saved."; |
| 167 | + } |
| 168 | + } |
| 169 | + include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/menu_edit_mail.html'); |
| 170 | + include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_mail.html'); |
| 171 | + unset($_SESSION['error_msg']); |
| 172 | + unset($_SESSION['ok_msg']); |
| 173 | + } else { |
| 174 | + $v_domain = escapeshellarg($_GET['domain']); |
| 175 | + $v_record_id = escapeshellarg($_GET['record_id']); |
| 176 | + exec (VESTA_CMD."v_list_dns_domain_records ".$user." ".$v_domain." 'json'", $output, $return_var); |
| 177 | + if ($return_var != 0) { |
| 178 | + $error = implode('<br>', $output); |
| 179 | + if (empty($error)) $error = 'Error: vesta did not return any output.'; |
| 180 | + $_SESSION['error_msg'] = $error; |
| 181 | + } else { |
| 182 | + $data = json_decode(implode('', $output), true); |
| 183 | + unset($output); |
| 184 | + $v_username = $user; |
| 185 | + $v_domain = $_GET['domain']; |
| 186 | + $v_d = $_GET['record_id']; |
| 187 | + $v_rec = $data[$v_record_id]['RECORD']; |
| 188 | + $v_type = $data[$v_record_id]['TYPE']; |
| 189 | + $v_val = $data[$v_record_id]['VALUE']; |
| 190 | + $v_priority = $data[$v_record_id]['PRIORITY']; |
| 191 | + $v_suspended = $data[$v_record_id]['SUSPENDED']; |
| 192 | + if ( $v_suspended == 'yes' ) { |
| 193 | + $v_status = 'suspended'; |
| 194 | + } else { |
| 195 | + $v_status = 'active'; |
| 196 | + } |
| 197 | + $v_date = $data[$v_record_id]['DATE']; |
| 198 | + $v_time = $data[$v_record_id]['TIME']; |
| 199 | + } |
| 200 | + |
| 201 | + // Action |
| 202 | + if (!empty($_POST['save'])) { |
| 203 | + $v_domain = escapeshellarg($_POST['v_domain']); |
| 204 | + $v_record_id = escapeshellarg($_POST['v_record_id']); |
| 205 | + |
| 206 | + if (($v_val != $_POST['v_val']) || ($v_priority != $_POST['v_priority']) && (empty($_SESSION['error_msg']))) { |
| 207 | + $v_val = escapeshellarg($_POST['v_val']); |
| 208 | + $v_priority = escapeshellarg($_POST['v_priority']); |
| 209 | + exec (VESTA_CMD."v_change_dns_domain_record ".$v_username." ".$v_domain." ".$v_record_id." ".$v_val." ".$v_priority, $output, $return_var); |
| 210 | + if ($return_var != 0) { |
| 211 | + $error = implode('<br>', $output); |
| 212 | + if (empty($error)) $error = 'Error: vesta did not return any output.'; |
| 213 | + $_SESSION['error_msg'] = $error; |
| 214 | + } |
| 215 | + $restart_dns = 'yes'; |
| 216 | + unset($output); |
| 217 | + } |
| 218 | + |
| 219 | + if (empty($_SESSION['error_msg'])) { |
| 220 | + $_SESSION['ok_msg'] = "OK: changes has been saved."; |
| 221 | + } |
| 222 | + |
| 223 | + } |
| 224 | + include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/menu_edit_dns_rec.html'); |
| 225 | + include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_dns_rec.html'); |
| 226 | + unset($_SESSION['error_msg']); |
| 227 | + unset($_SESSION['ok_msg']); |
| 228 | + } |
| 229 | +} |
| 230 | + |
| 231 | +// Footer |
| 232 | +include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); |
0 commit comments