Просмотр исходного кода

Merge pull request #1559 from hestiacp/feature/1281-webmail-control

#1281 Control webmail
Raphael Schneeberger 5 лет назад
Родитель
Сommit
4810eabc25

+ 5 - 2
bin/v-add-letsencrypt-domain

@@ -120,7 +120,10 @@ check_hestia_demo_mode
 if [ ! -z "$mail" ]; then
     root_domain=$domain
     domain="mail.$root_domain"
-    aliases="$WEBMAIL_ALIAS.$root_domain"
+    webmail=$(get_object_value "mail" "$domain" '$WEBMAIL');
+    if [ ! -z "$webmail" ]; then
+        aliases="$WEBMAIL_ALIAS.$root_domain"
+    fi
 fi
 
 log_file="/var/log/hestia/LE-${user}-${domain}-$(date +%Y%m%d-%H%M%S).log"
@@ -243,7 +246,7 @@ fi
 for auth in $authz; do
     payload=''
     answer=$(query_le_v2 "$auth" "$payload" "$nonce")
-    url=$(echo "$answer" |grep -A3 $proto |grep url |cut -f 4 -d \")
+    url=$(echo "$answer" |grep -A3 $proto |grep -m1 url |cut -f 4 -d \")
     token=$(echo "$answer" |grep -A3 $proto |grep token |cut -f 4 -d \")
     nonce=$(echo "$answer" |grep -i nonce |cut -f2 -d \ |tr -d '\r\n')
     status=$(echo "$answer"|grep HTTP/ |tail -n1 |cut -f 2 -d ' ')

+ 1 - 1
bin/v-add-mail-domain

@@ -169,7 +169,7 @@ fi
 # Add webmail configuration to mail domain
 if [ ! -z "$WEB_SYSTEM" ] || [ ! -z "$PROXY_SYSTEM" ]; then
     if [ ! -z "$IMAP_SYSTEM" ]; then
-        $BIN/v-add-sys-webmail $user $domain '' ''
+        $BIN/v-add-sys-webmail $user $domain '' '' ''
     fi
 fi
     

+ 18 - 8
web/add/mail/index.php

@@ -83,20 +83,30 @@ if (!empty($_POST['ok'])) {
         check_return_code($return_var,$output);
         unset($output);
     }
-
-    // Flush field values on success
-    if (empty($_SESSION['error_msg'])) {
-        $_SESSION['ok_msg'] = sprintf(_('MAIL_DOMAIN_CREATED_OK'),htmlentities($_POST['v_domain']),htmlentities($_POST['v_domain']));
-        unset($v_domain);
-    }
     
     if (!empty($_SESSION['IMAP_SYSTEM']) && !empty($_SESSION['WEBMAIL_SYSTEM'])){
-        if(!empty($_POST['v_webmail'])){
+        if (empty($_SESSION['error_msg'])) {
+        if (!empty($_POST['v_webmail'])) {
             $v_webmail = escapeshellarg($_POST['v_webmail']);
-            exec (HESTIA_CMD."v-add-sys-webmail ".$user." ".$v_domain." ".$v_webmail, $output, $return_var);
+            exec (HESTIA_CMD."v-add-sys-webmail ".$user." ".$v_domain." ".$v_webmail." yes", $output, $return_var);
             check_return_code($return_var,$output);
             unset($output);
         }
+        }
+    }
+    
+    if (empty($_POST['v_webmail'])) {
+        if (empty($_SESSION['error_msg'])) {
+        exec (HESTIA_CMD."v-delete-sys-webmail ".$user." ".$v_domain." yes", $output, $return_var);
+        check_return_code($return_var,$output);
+        unset($output);
+        }
+    }
+    
+    // Flush field values on success
+    if (empty($_SESSION['error_msg'])) {
+        $_SESSION['ok_msg'] = sprintf(_('MAIL_DOMAIN_CREATED_OK'),htmlentities($_POST['v_domain']),htmlentities($_POST['v_domain']));
+        unset($v_domain, $v_webmail);
     }
 }
 

+ 14 - 3
web/edit/mail/index.php

@@ -215,14 +215,25 @@ if ((!empty($_POST['save'])) && (!empty($_GET['domain'])) && (empty($_GET['accou
         check_return_code($return_var,$output);
         unset($output);
     }
+    
     if (!empty($_SESSION['IMAP_SYSTEM']) && !empty($_SESSION['WEBMAIL_SYSTEM'])){
-        // Update webmail
-        if ((!empty($_POST['v_webmail'])) && $_POST['v_webmail'] != $v_webmail && (empty($_SESSION['error_msg']))) {
+        if (empty($_SESSION['error_msg'])) {
+        if (!empty($_POST['v_webmail'])) {
             $v_webmail = escapeshellarg($_POST['v_webmail']);
-            exec (HESTIA_CMD."v-add-sys-webmail ".$v_username." ".escapeshellarg($v_domain)." ".$v_webmail." yes", $output, $return_var);
+            exec (HESTIA_CMD."v-add-sys-webmail ".$user." ".$v_domain." ".$v_webmail." yes", $output, $return_var);
             check_return_code($return_var,$output);
             unset($output);
         }
+        }
+    }
+    
+    if (empty($_POST['v_webmail'])) {
+        if (empty($_SESSION['error_msg'])) {
+        exec (HESTIA_CMD."v-delete-sys-webmail ".$user." ".$v_domain." yes", $output, $return_var);
+        check_return_code($return_var,$output);
+        $v_webmail = "";
+        unset($output);
+        }
     }
     
     // Change SSL certificate

+ 1 - 0
web/templates/admin/add_mail.html

@@ -78,6 +78,7 @@
                                             echo ">".htmlentities(ucfirst($client))."</option>\n";
                                             }
                                             ?>
+                                            <option value="" <?php if(empty($v_webmail)){ echo "selected";}?>><?php print _('Disabled');?></option>
                                         </select>
                                     </td>
                                 </tr>

+ 1 - 0
web/templates/admin/edit_mail.html

@@ -81,6 +81,7 @@
                                             echo ">".htmlentities(ucfirst($client))."</option>\n";
                                             }
                                             ?>
+                                            <option value="" <?php if (empty($v_webmail)){ echo "selected";}?>><?php print _('Disabled');?></option>
                                         </select>
                                     </td>
                                 </tr>