|
171 | 171 | unset($_SESSION['error_msg']); |
172 | 172 | unset($_SESSION['ok_msg']); |
173 | 173 | } else { |
| 174 | + |
| 175 | + $v_username = $user; |
174 | 176 | $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 | + $v_account = escapeshellarg($_GET['account']); |
| 178 | + exec (VESTA_CMD."v_list_mail_account ".$user." ".$v_domain." ".$v_account." 'json'", $output, $return_var); |
177 | 179 | if ($return_var != 0) { |
178 | 180 | $error = implode('<br>', $output); |
179 | 181 | if (empty($error)) $error = 'Error: vesta did not return any output.'; |
|
183 | 185 | unset($output); |
184 | 186 | $v_username = $user; |
185 | 187 | $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']; |
| 188 | + $v_account = $_GET['account']; |
| 189 | + $v_password = "••••••••"; |
| 190 | + $v_aliases = str_replace(',', "\n", $data[$v_account]['ALIAS']); |
| 191 | + $valiases = explode(",", $data[$v_account]['ALIAS']); |
| 192 | + $v_fwd = str_replace(',', "\n", $data[$v_account]['FWD']); |
| 193 | + $vfwd = explode(",", $data[$v_account]['FWD']); |
| 194 | + $v_quota = $data[$v_account]['QUOTA']; |
| 195 | + $v_autoreply = $data[$v_account]['AUTOREPLY']; |
| 196 | + if ( $v_autoreply == 'yes' ) { |
| 197 | + exec (VESTA_CMD."v_list_mail_account_autoreply ".$user." '".$v_domain."' '".$v_account."' json", $output, $return_var); |
| 198 | + $autoreply_str = json_decode(implode('', $output), true); |
| 199 | + unset($output); |
| 200 | + $v_autoreply_message = $autoreply_str[$v_account]['MSG']; |
| 201 | + } |
| 202 | + $v_suspended = $data[$v_account]['SUSPENDED']; |
192 | 203 | if ( $v_suspended == 'yes' ) { |
193 | 204 | $v_status = 'suspended'; |
194 | 205 | } else { |
195 | 206 | $v_status = 'active'; |
196 | 207 | } |
197 | | - $v_date = $data[$v_record_id]['DATE']; |
198 | | - $v_time = $data[$v_record_id]['TIME']; |
| 208 | + $v_date = $data[$v_account]['DATE']; |
| 209 | + $v_time = $data[$v_account]['TIME']; |
199 | 210 | } |
200 | 211 |
|
201 | 212 | // Action |
202 | 213 | if (!empty($_POST['save'])) { |
203 | 214 | $v_domain = escapeshellarg($_POST['v_domain']); |
204 | | - $v_record_id = escapeshellarg($_POST['v_record_id']); |
| 215 | + $v_account = escapeshellarg($_POST['v_account']); |
| 216 | + |
| 217 | + // Password |
| 218 | + if (($v_password != $_POST['v_password']) && (empty($_SESSION['error_msg']))) { |
| 219 | + $v_password = escapeshellarg($_POST['v_password']); |
| 220 | + exec (VESTA_CMD."v_change_mail_account_password ".$v_username." ".$v_domain." ".$v_account." ".$v_password, $output, $return_var); |
| 221 | + if ($return_var != 0) { |
| 222 | + $error = implode('<br>', $output); |
| 223 | + if (empty($error)) $error = 'Error: vesta did not return any output.'; |
| 224 | + $_SESSION['error_msg'] = $error; |
| 225 | + } |
| 226 | + $v_password = "••••••••"; |
| 227 | + unset($output); |
| 228 | + } |
205 | 229 |
|
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); |
| 230 | + // Quota |
| 231 | + if (($v_quota != $_POST['v_quota']) && (empty($_SESSION['error_msg']))) { |
| 232 | + if (empty($_POST['v_quota'])) { |
| 233 | + $v_quota = 0; |
| 234 | + } else { |
| 235 | + $v_quota = escapeshellarg($_POST['v_quota']); |
| 236 | + } |
| 237 | + exec (VESTA_CMD."v_change_mail_account_quota ".$v_username." ".$v_domain." ".$v_account." ".$v_quota, $output, $return_var); |
210 | 238 | if ($return_var != 0) { |
211 | 239 | $error = implode('<br>', $output); |
212 | 240 | if (empty($error)) $error = 'Error: vesta did not return any output.'; |
213 | 241 | $_SESSION['error_msg'] = $error; |
214 | 242 | } |
215 | | - $restart_dns = 'yes'; |
216 | 243 | unset($output); |
217 | 244 | } |
218 | | - |
| 245 | + |
| 246 | + |
| 247 | + // Aliases |
| 248 | + if (empty($_SESSION['error_msg'])) { |
| 249 | + $waliases = preg_replace("/\n/", " ", $_POST['v_aliases']); |
| 250 | + $waliases = preg_replace("/,/", " ", $waliases); |
| 251 | + $waliases = preg_replace('/\s+/', ' ',$waliases); |
| 252 | + $waliases = trim($waliases); |
| 253 | + $aliases = explode(" ", $waliases); |
| 254 | + $v_aliases = str_replace(' ', "\n", $waliases); |
| 255 | + $result = array_diff($valiases, $aliases); |
| 256 | + foreach ($result as $alias) { |
| 257 | + if (empty($_SESSION['error_msg'])) { |
| 258 | + exec (VESTA_CMD."v_delete_mail_account_alias ".$v_username." ".$v_domain." ".$v_account." '".$alias, $output, $return_var); |
| 259 | + if ($return_var != 0) { |
| 260 | + $error = implode('<br>', $output); |
| 261 | + if (empty($error)) $error = 'Error: vesta did not return any output.'; |
| 262 | + $_SESSION['error_msg'] = $error; |
| 263 | + } |
| 264 | + unset($output); |
| 265 | + } |
| 266 | + } |
| 267 | + $result = array_diff($aliases, $valiases); |
| 268 | + foreach ($result as $alias) { |
| 269 | + if (empty($_SESSION['error_msg'])) { |
| 270 | + exec (VESTA_CMD."v_add_mail_account_alias ".$v_username." ".$v_domain." ".$v_account." '".$alias, $output, $return_var); |
| 271 | + if ($return_var != 0) { |
| 272 | + $error = implode('<br>', $output); |
| 273 | + if (empty($error)) $error = 'Error: vesta did not return any output.'; |
| 274 | + $_SESSION['error_msg'] = $error; |
| 275 | + } |
| 276 | + unset($output); |
| 277 | + } |
| 278 | + } |
| 279 | + } |
| 280 | + |
| 281 | + // Forwarders |
| 282 | + if (empty($_SESSION['error_msg'])) { |
| 283 | + $wfwd = preg_replace("/\n/", " ", $_POST['v_fwd']); |
| 284 | + $wfwd = preg_replace("/,/", " ", $wfwd); |
| 285 | + $wfwd = preg_replace('/\s+/', ' ',$wfwd); |
| 286 | + $wfwd = trim($wfwd); |
| 287 | + $fwd = explode(" ", $wfwd); |
| 288 | + $v_fwd = str_replace(' ', "\n", $wfwd); |
| 289 | + $result = array_diff($vfwd, $fwd); |
| 290 | + foreach ($result as $forward) { |
| 291 | + if (empty($_SESSION['error_msg'])) { |
| 292 | + exec (VESTA_CMD."v_delete_mail_account_forward ".$v_username." ".$v_domain." ".$v_account." '".$forward."'", $output, $return_var); |
| 293 | + if ($return_var != 0) { |
| 294 | + $error = implode('<br>', $output); |
| 295 | + if (empty($error)) $error = 'Error: vesta did not return any output.'; |
| 296 | + $_SESSION['error_msg'] = $error; |
| 297 | + } |
| 298 | + unset($output); |
| 299 | + } |
| 300 | + } |
| 301 | + $result = array_diff($fwd, $vfwd); |
| 302 | + foreach ($result as $forward) { |
| 303 | + if (empty($_SESSION['error_msg'])) { |
| 304 | + exec (VESTA_CMD."v_add_mail_account_forward ".$v_username." ".$v_domain." ".$v_account." '".$forward."'", $output, $return_var); |
| 305 | + if ($return_var != 0) { |
| 306 | + $error = implode('<br>', $output); |
| 307 | + if (empty($error)) $error = 'Error: vesta did not return any output.'; |
| 308 | + $_SESSION['error_msg'] = $error; |
| 309 | + } |
| 310 | + unset($output); |
| 311 | + } |
| 312 | + } |
| 313 | + } |
| 314 | + |
| 315 | + // Autoreply |
| 316 | + if (($v_autoreply == 'yes') && (empty($_POST['v_autoreply'])) && (empty($_SESSION['error_msg']))) { |
| 317 | + exec (VESTA_CMD."v_delete_mail_account_autoreply ".$v_username." ".$v_domain." ".$v_account, $output, $return_var); |
| 318 | + if ($return_var != 0) { |
| 319 | + $error = implode('<br>', $output); |
| 320 | + if (empty($error)) $error = 'Error: vesta did not return any output.'; |
| 321 | + $_SESSION['error_msg'] = $error; |
| 322 | + } |
| 323 | + unset($output); |
| 324 | + $v_autoreply = 'no'; |
| 325 | + $v_autoreply_message = ''; |
| 326 | + } |
| 327 | + if (($v_autoreply == 'yes') && (!empty($_POST['v_autoreply'])) && (empty($_SESSION['error_msg']))) { |
| 328 | + if ( $v_autoreply_message != str_replace("\r\n", "\n", $_POST['v_autoreply_message'])) { |
| 329 | + $v_autoreply_message = str_replace("\r\n", "\n", $_POST['v_autoreply_message']); |
| 330 | + $v_autoreply_message = escapeshellarg($v_autoreply_message); |
| 331 | + exec (VESTA_CMD."v_add_mail_account_autoreply ".$v_username." ".$v_domain." ".$v_account." ".$v_autoreply_message, $output, $return_var); |
| 332 | + if ($return_var != 0) { |
| 333 | + $error = implode('<br>', $output); |
| 334 | + if (empty($error)) $error = 'Error: vesta did not return any output.'; |
| 335 | + $_SESSION['error_msg'] = $error; |
| 336 | + } |
| 337 | + unset($output); |
| 338 | + $v_autoreply_message = $_POST['v_autoreply_message']; |
| 339 | + } |
| 340 | + } |
| 341 | + |
| 342 | + if (($v_autoreply == 'no') && (!empty($_POST['v_autoreply'])) && (empty($_SESSION['error_msg']))) { |
| 343 | + if (empty($_POST['v_autoreply_message'])) $_SESSION['error_msg'] = "Error: field atoreply message can not be blank."; |
| 344 | + if (empty($_SESSION['error_msg'])) { |
| 345 | + $v_autoreply_message = str_replace("\r\n", "\n", $_POST['v_autoreply_message']); |
| 346 | + $v_autoreply_message = escapeshellarg($v_autoreply_message); |
| 347 | + exec (VESTA_CMD."v_add_mail_account_autoreply ".$v_username." ".$v_domain." ".$v_account." ".$v_autoreply_message, $output, $return_var); |
| 348 | + if ($return_var != 0) { |
| 349 | + $error = implode('<br>', $output); |
| 350 | + if (empty($error)) $error = 'Error: vesta did not return any output.'; |
| 351 | + $_SESSION['error_msg'] = $error; |
| 352 | + } |
| 353 | + unset($output); |
| 354 | + $v_autoreply = 'yes'; |
| 355 | + $v_autoreply_message = $_POST['v_autoreply_message']; |
| 356 | + } |
| 357 | + } |
| 358 | + |
| 359 | + |
219 | 360 | if (empty($_SESSION['error_msg'])) { |
220 | 361 | $_SESSION['ok_msg'] = "OK: changes has been saved."; |
221 | 362 | } |
222 | 363 |
|
223 | 364 | } |
224 | | - include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/menu_edit_dns_rec.html'); |
225 | | - include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_dns_rec.html'); |
| 365 | + include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/menu_edit_mail_acc.html'); |
| 366 | + include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_mail_acc.html'); |
226 | 367 | unset($_SESSION['error_msg']); |
227 | 368 | unset($_SESSION['ok_msg']); |
228 | 369 | } |
|
0 commit comments