Florian Schaal
2014-10-29 b3a7a341047dd7549046b540b3b1a04373153c61
dkim: fixed issue with the domain-module
4 files modified
107 ■■■■■ changed files
interface/web/js/mail_domain_dkim.js 94 ●●●●● patch | view | raw | blame | history
interface/web/mail/mail_domain_dkim_create.php 1 ●●●● patch | view | raw | blame | history
interface/web/mail/mail_domain_edit.php 3 ●●●●● patch | view | raw | blame | history
interface/web/mail/templates/mail_domain_edit.htm 9 ●●●● patch | view | raw | blame | history
interface/web/js/mail_domain_dkim.js
@@ -31,49 +31,61 @@
This Javascript is invoked by
    * mail/templates/mail_domain_edit.htm to show and/or create the key-pair
*/
var request = false;
function setRequest(action) {
    if (window.XMLHttpRequest) {
        request = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
        try {
            request = new ActiveXObject('Msxml2.XMLHTTP');
        }
        catch (e) {
            try {
                request = new ActiveXObject('Microsoft.XMLHTTP');
            }
            catch (e) {}
        }
    }
$('.subsectiontoggle').on('click', function(){
    $(this).children().toggleClass('showing').end().next().slideToggle();
});
    if (!request) {
        alert("Error creating XMLHTTP-instance");
        return false;
    } else {
        // jQuery depends on domain-module active / inactive
        var check = jQuery('#domain_module').val();
        if ( check == "1" ) {
            var skillsSelect = document.getElementById("domain");
            var domain = skillsSelect.options[skillsSelect.selectedIndex].text;
        } else {
            var domain = jQuery('#domain').val();
        }
        var selector=jQuery('#dkim_selector').val();
        var publickey=jQuery('#dkim_public').val();
        var privatekey=jQuery('#dkim_private').val();
        request.open('POST', 'mail/mail_domain_dkim_create.php', true);
        request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        request.send('domain='+domain+'&action='+action+'&dkim_selector='+selector+'&dkim_public='+publickey+'&dkim_private='+privatekey);
        request.onreadystatechange = interpretRequest;
    }
}
function interpretRequest() {
    switch (request.readyState) {
        case 4:
            if ( request.status != 200 ) {
                alert("Request done but NOK\nError:"+request.status);
            } else {
                document.getElementsByName('dkim_selector')[0].value = request.responseXML.getElementsByTagName('selector')[0].firstChild.nodeValue;
                document.getElementsByName('dkim_private')[0].value = request.responseXML.getElementsByTagName('privatekey')[0].firstChild.nodeValue;
                document.getElementsByName('dkim_public')[0].value = request.responseXML.getElementsByTagName('publickey')[0].firstChild.nodeValue;
                document.getElementsByName('dns_record')[0].value = request.responseXML.getElementsByTagName('dns_record')[0].firstChild.nodeValue;
            }
        break;
        var request = false;
        default:
        break;
    }
}
        function setRequest(action,value,privatekey) {
                if (window.XMLHttpRequest) {request = new XMLHttpRequest();}
                else if (window.ActiveXObject) {
                        try {request = new ActiveXObject('Msxml2.XMLHTTP');}
                        catch (e) {
                                try {request = new ActiveXObject('Microsoft.XMLHTTP');}
                                catch (e) {}
                        }
                }
                if (!request) {
                        alert("Error creating XMLHTTP-instance");
                        return false;
                } else {
                        request.open('POST', 'mail/mail_domain_dkim_create.php', true);
                        request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
                        request.send('domain='+value+'&action='+action+'&pkey='+privatekey);
                        request.onreadystatechange = interpretRequest;
                }
        }
        function interpretRequest() {
                switch (request.readyState) {
                        case 4:
                                if (request.status != 200) {alert("Request done but NOK\nError:"+request.status);}
                                else {
                                        document.getElementsByName('dkim_private')[0].value = request.responseXML.getElementsByTagName('privatekey')[0].firstChild.nodeValue;
                                        document.getElementsByName('dkim_public')[0].value = request.responseXML.getElementsByTagName('publickey')[0].firstChild.nodeValue;
                    document.getElementsByName('dns_record')[0].value = request.responseXML.getElementsByTagName('dns_record')[0].firstChild.nodeValue;
                                }
                                break;
                        default:
                                break;
                }
        }
var serverType = jQuery('#dkim_private').val();
setRequest('show','{tmpl_var name="domain"}',serverType);
setRequest('show');
interface/web/mail/mail_domain_dkim_create.php
@@ -147,7 +147,6 @@
    break;
    case 'show': /* show the DNS-Record onLoad */
        $_POST=getRealPOST();
        $private_key=$_POST['dkim_private'];
    break;
}
interface/web/mail/mail_domain_edit.php
@@ -176,6 +176,9 @@
                $domain_select .= "<option value=''></option>\r\n";
            }
            $app->tpl->setVar("domain_option", $domain_select);
            $app->tpl->setVar("domain_module", 1);
        } else {
            $app->tpl->setVar("domain_module", 0);
        }
interface/web/mail/templates/mail_domain_edit.htm
@@ -83,6 +83,11 @@
                </div>
            </div>
            <div class="subsectiontoggle"><span></span>{tmpl_var name='dkim_settings_txt'}<em></em></div>
            <tmpl_if name="domain_module">
                <input type="hidden" name="domain_module" value="1" id="domain_module" />
            <tmpl_else>
                <input type="hidden" name="domain_module" value="0" id="domain_module" />
            </tmpl_if>
            <div style="display:none;">
              <div class="ctrlHolder">
                <p class="label">{tmpl_var name='dkim_txt'}</p>
@@ -97,11 +102,12 @@
              <div class="ctrlHolder">
                <label for="dkim_private">{tmpl_var name='dkim_private_txt'}</label>
                <textarea name="dkim_private" id="dkim_private" rows='10' cols='30'>{tmpl_var name='dkim_private'}</textarea>
<a href="javascript:setRequest('create','{tmpl_var name='domain'}','{tmpl_var name='dkim_selector'}')">{tmpl_var name='dkim_generate_txt'}</a>
<a href="javascript:setRequest('create')">{tmpl_var name='dkim_generate_txt'}</a>
              </div>
        <div class="ctrlHolder">
                <textarea name="dkim_public" style="display:none;" id="dkim_public" rows='5' cols='30' readonly>{tmpl_var name='dkim_public'}</textarea>
              </div>
              <div class="ctrlHolder">
                <label for="dns_record">{tmpl_var name='dkim_dns_txt'}</label>
                <textarea name="dns_record" id="dns_record" rows='10' cols='30' readonly>{tmpl_var name='dns_record'}</textarea>
@@ -113,7 +119,6 @@
        <input type="hidden" name="id" value="{tmpl_var name='id'}">
        <input type="hidden" name="type" value="local">
        <div class="buttonHolder buttons">
            <button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onclick="submitForm('pageForm','mail/mail_domain_edit.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
            <button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onclick="loadContent('mail/mail_domain_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>