diff --git a/bin/v_add_mail_domain_cactchall b/bin/v_add_mail_domain_catchall similarity index 100% rename from bin/v_add_mail_domain_cactchall rename to bin/v_add_mail_domain_catchall diff --git a/bin/v_change_mail_domain_cactchall b/bin/v_change_mail_domain_catchall similarity index 100% rename from bin/v_change_mail_domain_cactchall rename to bin/v_change_mail_domain_catchall diff --git a/bin/v_delete_mail_domain_cactchall b/bin/v_delete_mail_domain_catchall similarity index 100% rename from bin/v_delete_mail_domain_cactchall rename to bin/v_delete_mail_domain_catchall diff --git a/bin/v_list_mail_domain b/bin/v_list_mail_domain index 8b40e8b1..aeaf0806 100755 --- a/bin/v_list_mail_domain +++ b/bin/v_list_mail_domain @@ -31,9 +31,9 @@ json_list_domain() { echo -e "\t\"$value\": {" else if [ "$fileds_count" -eq "$i" ]; then - echo -e "\t\t\"${field//$/}\": \"$value\"," - else echo -e "\t\t\"${field//$/}\": \"$value\"" + else + echo -e "\t\t\"${field//$/}\": \"$value\"," fi fi (( ++i)) @@ -72,7 +72,7 @@ is_object_valid 'mail' 'DOMAIN' "$domain" # Defining fileds to select conf=$USER_DATA/mail.conf fields='$DOMAIN $ANTIVIRUS $ANTISPAM $DKIM $ACCOUNTS $U_DISK $CATCHALL -$SUSPENDED $DATE' +$SUSPENDED $TIME $DATE' # Listing domains case $format in diff --git a/web/add/mail/index.php b/web/add/mail/index.php index d5f24c3e..8733979f 100644 --- a/web/add/mail/index.php +++ b/web/add/mail/index.php @@ -86,7 +86,11 @@ if ($_SESSION['user'] == 'admin') { $v_account = escapeshellarg($_POST['v_account']); $v_password = escapeshellarg($_POST['v_password']); $v_quota = escapeshellarg($_POST['v_quota']); + $v_aliases = $_POST['v_aliases']; + $v_fwd = $_POST['v_fwd']; + if (empty($_POST['v_quota'])) $v_quota = 0; + if ((!empty($_POST['v_quota'])) || (!empty($_POST['v_aliases'])) || (!empty($_POST['v_fwd'])) ) $v_adv = 'yes'; // Check for errors if (!empty($errors[0])) { @@ -106,11 +110,58 @@ if ($_SESSION['user'] == 'admin') { if (empty($error)) $error = 'Error: vesta did not return any output.'; $_SESSION['error_msg'] = $error; } + + // Add Aliases + if ((!empty($_POST['v_aliases'])) && (empty($_SESSION['error_msg']))) { + $valiases = preg_replace("/\n/", " ", $_POST['v_aliases']); + $valiases = preg_replace("/,/", " ", $valiases); + $valiases = preg_replace('/\s+/', ' ',$valiases); + $valiases = trim($valiases); + $aliases = explode(" ", $valiases); + foreach ($aliases as $alias) { + $alias = escapeshellarg($alias); + if (empty($_SESSION['error_msg'])) { + exec (VESTA_CMD."v_add_mail_account_alias ".$user." ".$v_domain." ".$v_account." ".$alias, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = 'Error: vesta did not return any output.'; + $_SESSION['error_msg'] = $error; + } + } + unset($output); + } + } + + // Add Forwads + if ((!empty($_POST['v_fwd'])) && (empty($_SESSION['error_msg']))) { + $vfwd = preg_replace("/\n/", " ", $_POST['v_fwd']); + $vfwd = preg_replace("/,/", " ", $vfwd); + $vfwd = preg_replace('/\s+/', ' ',$vfwd); + $vfwd = trim($vfwd); + $fwd = explode(" ", $vfwd); + foreach ($fwd as $forward) { + $forward = escapeshellarg($forward); + if (empty($_SESSION['error_msg'])) { + exec (VESTA_CMD."v_add_mail_account_forward ".$user." ".$v_domain." ".$v_account." ".$forward, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = 'Error: vesta did not return any output.'; + $_SESSION['error_msg'] = $error; + } + } + unset($output); + } + } + unset($output); if (empty($_SESSION['error_msg'])) { $_SESSION['ok_msg'] = "OK: account ".$_POST['v_account']." has been created successfully."; unset($v_account); unset($v_password); + unset($v_password); + unset($v_aliases); + unset($v_fwd); + unset($v_quota); } } } diff --git a/web/edit/mail/index.php b/web/edit/mail/index.php new file mode 100644 index 00000000..0a1f0d5e --- /dev/null +++ b/web/edit/mail/index.php @@ -0,0 +1,232 @@ +', $output); + if (empty($error)) $error = 'Error: vesta did not return any output.'; + $_SESSION['error_msg'] = $error; + } else { + $data = json_decode(implode('', $output), true); + unset($output); + $v_username = $user; + $v_domain = $_GET['domain']; + $v_antispam = $data[$v_domain]['ANTISPAM']; + $v_antivirus = $data[$v_domain]['ANTIVIRUS']; + $v_dkim = $data[$v_domain]['DKIM']; + $v_catchall = $data[$v_domain]['CATCHALL']; + $v_date = $data[$v_domain]['DATE']; + $v_time = $data[$v_domain]['TIME']; + $v_suspended = $data[$v_domain]['SUSPENDED']; + if ( $v_suspended == 'yes' ) { + $v_status = 'suspended'; + } else { + $v_status = 'active'; + } + } + + // Action + if (!empty($_POST['save'])) { + $v_domain = escapeshellarg($_POST['v_domain']); + + // Antispam + if (($v_antispam == 'yes') && (empty($_POST['v_antispam'])) && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v_delete_mail_domain_antispam ".$v_username." ".$v_domain, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = 'Error: vesta did not return any output.'; + $_SESSION['error_msg'] = $error; + } + $v_antispam = 'no'; + unset($output); + } + if (($v_antispam == 'no') && (!empty($_POST['v_antispam'])) && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v_add_mail_domain_antispam ".$v_username." ".$v_domain, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = 'Error: vesta did not return any output.'; + $_SESSION['error_msg'] = $error; + } + $v_antispam = 'yes'; + unset($output); + } + + // Antivirus + if (($v_antivirus == 'yes') && (empty($_POST['v_antivirus'])) && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v_delete_mail_domain_antivirus ".$v_username." ".$v_domain, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = 'Error: vesta did not return any output.'; + $_SESSION['error_msg'] = $error; + } + $v_antivirus = 'no'; + unset($output); + } + if (($v_antivirus == 'no') && (!empty($_POST['v_antivirus'])) && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v_add_mail_domain_antivirus ".$v_username." ".$v_domain, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = 'Error: vesta did not return any output.'; + $_SESSION['error_msg'] = $error; + } + $v_antivirus = 'yes'; + unset($output); + } + + if (empty($_SESSION['error_msg'])) { + $_SESSION['ok_msg'] = "OK: changes has been saved."; + } + + // DKIM + if (($v_dkim == 'yes') && (empty($_POST['v_dkim'])) && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v_delete_mail_domain_dkim ".$v_username." ".$v_domain, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = 'Error: vesta did not return any output.'; + $_SESSION['error_msg'] = $error; + } + $v_dkim = 'no'; + unset($output); + } + if (($v_dkim == 'no') && (!empty($_POST['v_dkim'])) && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v_add_mail_domain_dkim ".$v_username." ".$v_domain, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = 'Error: vesta did not return any output.'; + $_SESSION['error_msg'] = $error; + } + $v_dkim = 'yes'; + unset($output); + } + + // Catchall + if ((!empty($v_catchall)) && (empty($_POST['v_catchall'])) && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v_delete_mail_domain_catchall ".$v_username." ".$v_domain, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = 'Error: vesta did not return any output.'; + $_SESSION['error_msg'] = $error; + } + $v_catchall = ''; + unset($output); + } + + if ((!empty($v_catchall)) && (!empty($_POST['v_catchall'])) && (empty($_SESSION['error_msg']))) { + if ($v_catchall != $_POST['v_catchall']) { + $v_catchall = escapeshellarg($_POST['v_catchall']); + exec (VESTA_CMD."v_change_mail_domain_catchall ".$v_username." ".$v_domain." ".$v_catchall, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = 'Error: vesta did not return any output.'; + $_SESSION['error_msg'] = $error; + } + unset($output); + } + } + + if ((empty($v_catchall)) && (!empty($_POST['v_catchall'])) && (empty($_SESSION['error_msg']))) { + $v_catchall = escapeshellarg($_POST['v_catchall']); + exec (VESTA_CMD."v_add_mail_domain_catchall ".$v_username." ".$v_domain." ".$v_catchall, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = 'Error: vesta did not return any output.'; + $_SESSION['error_msg'] = $error; + } + unset($output); + } + + if (empty($_SESSION['error_msg'])) { + $_SESSION['ok_msg'] = "OK: changes has been saved."; + } + } + include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/menu_edit_mail.html'); + include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_mail.html'); + unset($_SESSION['error_msg']); + unset($_SESSION['ok_msg']); + } else { + $v_domain = escapeshellarg($_GET['domain']); + $v_record_id = escapeshellarg($_GET['record_id']); + exec (VESTA_CMD."v_list_dns_domain_records ".$user." ".$v_domain." 'json'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = 'Error: vesta did not return any output.'; + $_SESSION['error_msg'] = $error; + } else { + $data = json_decode(implode('', $output), true); + unset($output); + $v_username = $user; + $v_domain = $_GET['domain']; + $v_d = $_GET['record_id']; + $v_rec = $data[$v_record_id]['RECORD']; + $v_type = $data[$v_record_id]['TYPE']; + $v_val = $data[$v_record_id]['VALUE']; + $v_priority = $data[$v_record_id]['PRIORITY']; + $v_suspended = $data[$v_record_id]['SUSPENDED']; + if ( $v_suspended == 'yes' ) { + $v_status = 'suspended'; + } else { + $v_status = 'active'; + } + $v_date = $data[$v_record_id]['DATE']; + $v_time = $data[$v_record_id]['TIME']; + } + + // Action + if (!empty($_POST['save'])) { + $v_domain = escapeshellarg($_POST['v_domain']); + $v_record_id = escapeshellarg($_POST['v_record_id']); + + if (($v_val != $_POST['v_val']) || ($v_priority != $_POST['v_priority']) && (empty($_SESSION['error_msg']))) { + $v_val = escapeshellarg($_POST['v_val']); + $v_priority = escapeshellarg($_POST['v_priority']); + exec (VESTA_CMD."v_change_dns_domain_record ".$v_username." ".$v_domain." ".$v_record_id." ".$v_val." ".$v_priority, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = 'Error: vesta did not return any output.'; + $_SESSION['error_msg'] = $error; + } + $restart_dns = 'yes'; + unset($output); + } + + if (empty($_SESSION['error_msg'])) { + $_SESSION['ok_msg'] = "OK: changes has been saved."; + } + + } + include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/menu_edit_dns_rec.html'); + include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_dns_rec.html'); + unset($_SESSION['error_msg']); + unset($_SESSION['ok_msg']); + } +} + +// Footer +include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); diff --git a/web/list/mail/index.php b/web/list/mail/index.php index 924a94a5..dafe3139 100644 --- a/web/list/mail/index.php +++ b/web/list/mail/index.php @@ -27,7 +27,7 @@ if ($_SESSION['user'] == 'admin') { exec (VESTA_CMD."v_list_mail_accounts '".$user."' '".$_GET['domain']."' 'json'", $output, $return_var); check_error($return_var); $data = json_decode(implode('', $output), true); - //$data = array_reverse($data); + $data = array_reverse($data); unset($output); include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/menu_mail_acc.html'); include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/list_mail_acc.html'); diff --git a/web/templates/admin/add_mail_acc.html b/web/templates/admin/add_mail_acc.html index fd523dcf..df9b7687 100644 --- a/web/templates/admin/add_mail_acc.html +++ b/web/templates/admin/add_mail_acc.html @@ -1,14 +1,23 @@ @@ -31,8 +40,17 @@ document.v_add_user.v_password.value = randomstring; Password generate - Quota (optional) - Advanced Options ⇢ + + + + + + + +
Quota (in megabytes)
Aliases (local part only)
Forward to (email address or addresses)
+ diff --git a/web/templates/admin/edit_mail.html b/web/templates/admin/edit_mail.html new file mode 100644 index 00000000..967b9456 --- /dev/null +++ b/web/templates/admin/edit_mail.html @@ -0,0 +1,35 @@ + + + + + +
+ + + + +
+
+ + +
+
+ + + + + + + + + + + +
Domain
AntiSpam Support
>
AntiVirus Support
>
DKIM Support
>
Catchall Email
+ + +
+
diff --git a/web/templates/admin/list_mail.html b/web/templates/admin/list_mail.html index e22d2805..11d51012 100644 --- a/web/templates/admin/list_mail.html +++ b/web/templates/admin/list_mail.html @@ -29,8 +29,8 @@ foreach ($data as $key => $value) { - - + +
list accounts add account edit add account edit delete
diff --git a/web/templates/admin/menu_edit_dns.html b/web/templates/admin/menu_edit_dns.html index b5b105a8..d94a4ece 100644 --- a/web/templates/admin/menu_edit_dns.html +++ b/web/templates/admin/menu_edit_dns.html @@ -1,6 +1,6 @@ -