From b533b414a075013307447a3fb895b1625504d477 Mon Sep 17 00:00:00 2001 From: Marius Cramer <m.cramer@pixcept.de> Date: Mon, 21 Oct 2013 07:15:00 -0400 Subject: [PATCH] Merge remote-tracking branch 'florian030/master' --- interface/web/dns/dns_dkim_edit.php | 284 +++++----- server/plugins-available/mail_plugin_dkim.inc.php | 106 ++- install/dist/lib/opensuse.lib.php | 2 interface/web/dns/lib/lang/en_dns_dkim.lng | 16 interface/web/mail/mail_domain_dkim_create.php | 122 ++-- interface/web/admin/form/server_config.tform.php | 8 interface/web/dns/templates/dns_dkim_edit.htm | 76 +- interface/web/admin/lib/lang/de_server_config.lng | 4 interface/web/mail/templates/mail_domain_edit.htm | 4 interface/web/dns/lib/lang/en_dns_wizard.lng | 2 interface/web/js/mail_domain_dkim.js | 143 ++-- interface/web/dns/dns_dkim_get.php | 190 +++--- interface/web/dns/dns_wizard.php | 15 interface/web/js/dns_dkim.js | 144 ++-- interface/lib/classes/validate_dkim.inc.php | 84 +- interface/web/dns/form/dns_dkim.tform.php | 308 +++++----- 16 files changed, 782 insertions(+), 726 deletions(-) diff --git a/install/dist/lib/opensuse.lib.php b/install/dist/lib/opensuse.lib.php index ff71aea..1e536ab 100644 --- a/install/dist/lib/opensuse.lib.php +++ b/install/dist/lib/opensuse.lib.php @@ -265,7 +265,7 @@ $command = 'chmod 755 /var/run/authdaemon.courier-imap'; caselog($command.' &> /dev/null', __FILE__, __LINE__, 'EXECUTED: '.$command, 'Failed to execute the command '.$command); - //* Changing maildrop lines in posfix master.cf + //* Changing maildrop lines in posfix master.cf if(is_file($config_dir.'/master.cf')){ copy($config_dir.'/master.cf', $config_dir.'/master.cf~'); } diff --git a/interface/lib/classes/validate_dkim.inc.php b/interface/lib/classes/validate_dkim.inc.php index 12c0945..e633430 100644 --- a/interface/lib/classes/validate_dkim.inc.php +++ b/interface/lib/classes/validate_dkim.inc.php @@ -1,6 +1,6 @@ <?php -/* +/** Copyright (c) 2007 - 2013, Till Brehm, projektfarm Gmbh Copyright (c) 2013, Florian Schaal, info@schaal-24.de All rights reserved. @@ -27,6 +27,9 @@ OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +@author Florian Schaal, info@schaal-24.de +@copyrighth Florian Schaal, info@schaal-24.de */ class validate_dkim { @@ -39,41 +42,52 @@ return $errmsg."<br>\r\n"; } } - - /* Validator function for private DKIM-Key */ - function check_private_key($field_name, $field_value, $validator) { - $dkim_enabled=$_POST['dkim']; - if ($dkim_enabled == 'y') { - if (empty($field_value)) return $this->get_error($validator['errmsg']); - exec('echo '.escapeshellarg($field_value).'|openssl rsa -check',$output,$result); - if($result != 0) return $this->get_error($validator['errmsg']); - } - } - /* Validator function for DKIM Path */ + /** + * Validator function for private DKIM-Key + */ + function check_private_key($field_name, $field_value, $validator) { + $dkim_enabled=$_POST['dkim']; + if ($dkim_enabled == 'y') { + if (empty($field_value)) return $this->get_error($validator['errmsg']); + exec('echo '.escapeshellarg($field_value).'|openssl rsa -check',$output,$result); + if($result != 0) return $this->get_error($validator['errmsg']); + } + } + + /** + * Validator function for DKIM Path + * @return boolean - true when the dkim-path exists and is writeable + */ function check_dkim_path($field_name, $field_value, $validator) { if(empty($field_value)) return $this->get_error($validator['errmsg']); if (substr(sprintf('%o', fileperms($field_value)),-3) <= 600) - return $this->get_error($validator['errmsg']); - } - - /* Check function for DNS-Template */ - function check_template($field_name, $field_value, $validator) { - $dkim=false; - foreach($field_value as $field ) { if($field == 'DKIM') $dkim=true; } - if ($dkim && $field_value[0]!='DOMAIN') return $this->get_error($validator['errmsg']); - } - - /* Validator function for $_POST */ - function validate_post($key,$value) { - switch ($key) { - case 'public': - if (preg_match("/(^-----BEGIN PUBLIC KEY-----)[a-zA-Z0-9\r\n\/\+=]{1,221}(-----END PUBLIC KEY-----(\n|\r)$)/",$value) === 1) { return true; } else { return false; } - break; - case 'private': - if (preg_match("/(^-----BEGIN RSA PRIVATE KEY-----)[a-zA-Z0-9\r\n\/\+=]{1,850}(-----END RSA PRIVATE KEY-----(\n|\r)$)/",$value) === 1) { return true; } else { return false; } - break; - } - } -} - + return $this->get_error($validator['errmsg']); + } + + /** + * Check function for DNS-Template + */ + function check_template($field_name, $field_value, $validator) { + $dkim=false; + foreach($field_value as $field ) { if($field == 'DKIM') $dkim=true; } + if ($dkim && $field_value[0]!='DOMAIN') return $this->get_error($validator['errmsg']); + } + + /** + * Validator function for $_POST + * + * @return boolean - true if $POST contains a real key-file + */ + function validate_post($key,$value) { + switch ($key) { + case 'public': + if (preg_match("/(^-----BEGIN PUBLIC KEY-----)[a-zA-Z0-9\r\n\/\+=]{1,221}(-----END PUBLIC KEY-----(\n|\r)$)/",$value) === 1) { return true; } else { return false; } + break; + case 'private': + if (preg_match("/(^-----BEGIN RSA PRIVATE KEY-----)[a-zA-Z0-9\r\n\/\+=]{1,850}(-----END RSA PRIVATE KEY-----(\n|\r)$)/",$value) === 1) { return true; } else { return false; } + break; + } + } +} + diff --git a/interface/web/admin/form/server_config.tform.php b/interface/web/admin/form/server_config.tform.php index 05764fc..2f4b9e2 100644 --- a/interface/web/admin/form/server_config.tform.php +++ b/interface/web/admin/form/server_config.tform.php @@ -280,10 +280,10 @@ 'formtype' => 'TEXT', 'default' => '/var/lib/amavis/dkim', 'validators' => array ( 0 => array ('type' => 'CUSTOM', - 'class' => 'validate_dkim', - 'function' => 'check_dkim_path', - 'errmsg'=> 'dkim_path_error'), - ), + 'class' => 'validate_dkim', + 'function' => 'check_dkim_path', + 'errmsg'=> 'dkim_path_error'), + ), 'value' => '', 'width' => '40', 'maxlength' => '255' diff --git a/interface/web/admin/lib/lang/de_server_config.lng b/interface/web/admin/lib/lang/de_server_config.lng index 14ba6fe..e919ce4 100644 --- a/interface/web/admin/lib/lang/de_server_config.lng +++ b/interface/web/admin/lib/lang/de_server_config.lng @@ -19,8 +19,8 @@ $wb['module_txt'] = 'Modul'; $wb['maildir_path_txt'] = 'Maildir Pfad'; $wb['homedir_path_txt'] = 'Homedir Pfad'; -$wb["dkim_path_txt"] = 'DKIM Pfad'; -$wb["dkim_path_error"] = 'DKIM Pfad nicht gefunden oder nicht beschreibbar.'; +$wb['dkim_path_txt'] = 'DKIM Pfad'; +$wb['dkim_path_error'] = 'DKIM Pfad nicht gefunden oder nicht beschreibbar.'; $wb['mailuser_uid_txt'] = 'Mailbenutzer UID'; $wb['mailuser_gid_txt'] = 'Mailbenutzer GID'; $wb['mailuser_name_txt'] = 'Mailbenutzer Name'; diff --git a/interface/web/dns/dns_dkim_edit.php b/interface/web/dns/dns_dkim_edit.php index 61b0bd7..2395bb0 100644 --- a/interface/web/dns/dns_dkim_edit.php +++ b/interface/web/dns/dns_dkim_edit.php @@ -1,142 +1,142 @@ -<?php - -/* -Copyright (c) 2007, Till Brehm, projektfarm Gmbh -Copyright (c) 2013, Florian Schaal, info@schaal-24.de -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of ISPConfig nor the names of its contributors - may be used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/****************************************** -* Begin Form configuration -******************************************/ - -$tform_def_file = "form/dns_dkim.tform.php"; - -/****************************************** -* End Form configuration -******************************************/ - -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); - -//* Check permissions for module -$app->auth->check_module_permissions('dns'); - -// Loading classes -$app->uses('tpl,tform,tform_actions,validate_dns'); -$app->load('tform_actions'); - -class page_action extends tform_actions { - - function onShowNew() { - global $app, $conf; - // we will check only users, not admins - if($_SESSION["s"]["user"]["typ"] == 'user') { - - // Get the limits of the client - $client_group_id = $_SESSION["s"]["user"]["default_group"]; - $client = $app->db->queryOneRecord("SELECT limit_dns_record FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); - - // Check if the user may add another record. - if($client["limit_dns_record"] >= 0) { - $tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id"); - if($tmp["number"] >= $client["limit_dns_record"]) { - $app->error($app->tform->wordbook["limit_dns_record_txt"]); - } - } - } - - parent::onShowNew(); - } - - function onSubmit() { - global $app, $conf; - // Get the parent soa record of the domain - $soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = '".$app->functions->intval($_POST["zone"])."' AND ".$app->tform->getAuthSQL('r')); - // Check if Domain belongs to user - if($soa["id"] != $_POST["zone"]) $app->tform->errorMessage .= $app->tform->wordbook["no_zone_perm"]; - - // Check the client limits, if user is not the admin - if($_SESSION["s"]["user"]["typ"] != 'admin') { // if user is not admin - // Get the limits of the client - $client_group_id = $_SESSION["s"]["user"]["default_group"]; - $client = $app->db->queryOneRecord("SELECT limit_dns_record FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); - // Check if the user may add another record. - if($this->id == 0 && $client["limit_dns_record"] >= 0) { - $tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id"); - if($tmp["number"] >= $client["limit_dns_record"]) { - $app->error($app->tform->wordbook["limit_dns_record_txt"]); - } - } - } // end if user is not admin - - // Set the server ID of the rr record to the same server ID as the parent record. - $this->dataRecord["server_id"] = $soa["server_id"]; - - // add dkim-settings to the public-key in the txt-record - $this->dataRecord['data']='v=DKIM1; t=s; p='.$this->dataRecord['data']; - $this->dataRecord['name']='default._domainkey.'.$this->dataRecord['name']; - - // Update the serial number and timestamp of the RR record - $soa = $app->db->queryOneRecord("SELECT serial FROM dns_rr WHERE id = ".$this->id); - $this->dataRecord["serial"] = $app->validate_dns->increase_serial($soa["serial"]); - $this->dataRecord["stamp"] = date('Y-m-d H:i:s'); - - // check for duplicate entry - $check=$app->db->queryOneRecord("SELECT * FROM dns_rr WHERE zone = ".$this->dataRecord["zone"]." AND type = '".$this->dataRecord["type"]."' AND data ='".$this->dataRecord["data"]."' AND name = '".$this->dataRecord['name']."'"); - if ($check!='') $app->tform->errorMessage .= $app->tform->wordbook["record_exists_txt"]; - - parent::onSubmit(); - } - - function onAfterInsert() { - global $app, $conf; - - //* Set the sys_groupid of the rr record to be the same then the sys_groupid of the soa record - $soa = $app->db->queryOneRecord("SELECT sys_groupid,serial FROM dns_soa WHERE id = '".$app->functions->intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r')); - $app->db->datalogUpdate('dns_rr', "sys_groupid = ".$soa['sys_groupid'], 'id', $this->id); - - //* Update the serial number of the SOA record - $soa_id = $app->functions->intval($_POST["zone"]); - $serial = $app->validate_dns->increase_serial($soa["serial"]); - $app->db->datalogUpdate('dns_soa', "serial = $serial", 'id', $soa_id); - } - - function onAfterUpdate() { - global $app, $conf; - - //* Update the serial number of the SOA record - $soa = $app->db->queryOneRecord("SELECT serial FROM dns_soa WHERE id = '".$app->functions->intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r')); - $soa_id = $app->functions->intval($_POST["zone"]); - $serial = $app->validate_dns->increase_serial($soa["serial"]); - $app->db->datalogUpdate('dns_soa', "serial = $serial", 'id', $soa_id); - } -} - -$page = new page_action; -$page->onLoad(); - -?> +<?php + +/* +Copyright (c) 2007, Till Brehm, projektfarm Gmbh +Copyright (c) 2013, Florian Schaal, info@schaal-24.de +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of ISPConfig nor the names of its contributors + may be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/****************************************** +* Begin Form configuration +******************************************/ + +$tform_def_file = "form/dns_dkim.tform.php"; + +/****************************************** +* End Form configuration +******************************************/ + +require_once('../../lib/config.inc.php'); +require_once('../../lib/app.inc.php'); + +//* Check permissions for module +$app->auth->check_module_permissions('dns'); + +// Loading classes +$app->uses('tpl,tform,tform_actions,validate_dns'); +$app->load('tform_actions'); + +class page_action extends tform_actions { + + function onShowNew() { + global $app, $conf; + // we will check only users, not admins + if($_SESSION["s"]["user"]["typ"] == 'user') { + + // Get the limits of the client + $client_group_id = $_SESSION["s"]["user"]["default_group"]; + $client = $app->db->queryOneRecord("SELECT limit_dns_record FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); + + // Check if the user may add another record. + if($client["limit_dns_record"] >= 0) { + $tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id"); + if($tmp["number"] >= $client["limit_dns_record"]) { + $app->error($app->tform->wordbook["limit_dns_record_txt"]); + } + } + } + + parent::onShowNew(); + } + + function onSubmit() { + global $app, $conf; + // Get the parent soa record of the domain + $soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = '".$app->functions->intval($_POST["zone"])."' AND ".$app->tform->getAuthSQL('r')); + // Check if Domain belongs to user + if($soa["id"] != $_POST["zone"]) $app->tform->errorMessage .= $app->tform->wordbook["no_zone_perm"]; + + // Check the client limits, if user is not the admin + if($_SESSION["s"]["user"]["typ"] != 'admin') { // if user is not admin + // Get the limits of the client + $client_group_id = $_SESSION["s"]["user"]["default_group"]; + $client = $app->db->queryOneRecord("SELECT limit_dns_record FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); + // Check if the user may add another record. + if($this->id == 0 && $client["limit_dns_record"] >= 0) { + $tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id"); + if($tmp["number"] >= $client["limit_dns_record"]) { + $app->error($app->tform->wordbook["limit_dns_record_txt"]); + } + } + } // end if user is not admin + + // Set the server ID of the rr record to the same server ID as the parent record. + $this->dataRecord["server_id"] = $soa["server_id"]; + + // add dkim-settings to the public-key in the txt-record + $this->dataRecord['data']='v=DKIM1; t=s; p='.$this->dataRecord['data']; + $this->dataRecord['name']='default._domainkey.'.$this->dataRecord['name']; + + // Update the serial number and timestamp of the RR record + $soa = $app->db->queryOneRecord("SELECT serial FROM dns_rr WHERE id = ".$this->id); + $this->dataRecord["serial"] = $app->validate_dns->increase_serial($soa["serial"]); + $this->dataRecord["stamp"] = date('Y-m-d H:i:s'); + + // check for duplicate entry + $check=$app->db->queryOneRecord("SELECT * FROM dns_rr WHERE zone = ".$this->dataRecord["zone"]." AND type = '".$this->dataRecord["type"]."' AND data ='".$this->dataRecord["data"]."' AND name = '".$this->dataRecord['name']."'"); + if ($check!='') $app->tform->errorMessage .= $app->tform->wordbook["record_exists_txt"]; + + parent::onSubmit(); + } + + function onAfterInsert() { + global $app, $conf; + + //* Set the sys_groupid of the rr record to be the same then the sys_groupid of the soa record + $soa = $app->db->queryOneRecord("SELECT sys_groupid,serial FROM dns_soa WHERE id = '".$app->functions->intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r')); + $app->db->datalogUpdate('dns_rr', "sys_groupid = ".$soa['sys_groupid'], 'id', $this->id); + + //* Update the serial number of the SOA record + $soa_id = $app->functions->intval($_POST["zone"]); + $serial = $app->validate_dns->increase_serial($soa["serial"]); + $app->db->datalogUpdate('dns_soa', "serial = $serial", 'id', $soa_id); + } + + function onAfterUpdate() { + global $app, $conf; + + //* Update the serial number of the SOA record + $soa = $app->db->queryOneRecord("SELECT serial FROM dns_soa WHERE id = '".$app->functions->intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r')); + $soa_id = $app->functions->intval($_POST["zone"]); + $serial = $app->validate_dns->increase_serial($soa["serial"]); + $app->db->datalogUpdate('dns_soa', "serial = $serial", 'id', $soa_id); + } +} + +$page = new page_action; +$page->onLoad(); + +?> diff --git a/interface/web/dns/dns_dkim_get.php b/interface/web/dns/dns_dkim_get.php index 6b8b90b..da917b9 100644 --- a/interface/web/dns/dns_dkim_get.php +++ b/interface/web/dns/dns_dkim_get.php @@ -1,91 +1,99 @@ -<?php -/* -Copyright (c) 2007 - 2013, Till Brehm, projektfarm Gmbh -Copyright (c) 2013, Florian Schaal, info@schaal-24.de -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of ISPConfig nor the names of its contributors - may be used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - This script is invoked by interface/web/dns/templates/dns_dkim_edit.htm - when generating the DKIM Private-key. - - return DKIM Public-Key for the DNS-record -*/ - -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); - -//* Check permissions for module -$app->auth->check_module_permissions('dns'); - -global $app, $conf; - -// Loading classes -$app->uses('tform,tform_actions'); - -header('Content-Type: text/xml; charset=utf-8'); -header('Cache-Control: must-revalidate, pre-check=0, no-store, no-cache, max-age=0, post-check=0'); - -/* - This function fix PHP's messing up POST input containing characters space, dot, - open square bracket and others to be compatible with with the deprecated register_globals -*/ -function getRealPOST() { - $pairs = explode("&", file_get_contents("php://input")); - $vars = array(); - foreach ($pairs as $pair) { - $nv = explode("=", $pair, 2); - $name = urldecode($nv[0]); - $value = $nv[1]; - $vars[$name] = $value; - } - return $vars; -} -function pub_key($pubkey) { - $public_key=''; - foreach($pubkey as $values) $public_key=$public_key.$values; - return $public_key; -} - -$_POST=getRealPost(); - -if (ctype_digit($_POST['zone'])) { - // Get the parent soa record of the domain - $soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = '".$app->db->quote($_POST['zone'])."' AND ".$app->tform->getAuthSQL('r')); - - $public_key=$app->db->queryOneRecord("SELECT dkim_public FROM mail_domain WHERE domain = '".substr_replace($soa['origin'],'',-1)."' AND ".$app->tform->getAuthSQL('r')); - - $public_key=pub_key($public_key); - - $public_key=str_replace(array('-----BEGIN PUBLIC KEY-----','-----END PUBLIC KEY-----',"\r","\n"),'',$public_key); - - echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; - echo "<formatname>\n"; - echo "<data>".$public_key."</data>\n"; - echo "<name>".$soa['origin']."</name>\n"; - echo "</formatname>\n"; -} -?> +<?php +/** +Copyright (c) 2007 - 2013, Till Brehm, projektfarm Gmbh +Copyright (c) 2013, Florian Schaal, info@schaal-24.de +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of ISPConfig nor the names of its contributors + may be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/** +* This script is invoked by interface/web/dns/templates/dns_dkim_edit.htm +* when generating the DKIM Private-key. +* +* return DKIM Public-Key for the DNS-record +*/ + +require_once('../../lib/config.inc.php'); +require_once('../../lib/app.inc.php'); + +//* Check permissions for module +$app->auth->check_module_permissions('dns'); + +global $app, $conf; + +// Loading classes +$app->uses('tform,tform_actions'); + +header('Content-Type: text/xml; charset=utf-8'); +header('Cache-Control: must-revalidate, pre-check=0, no-store, no-cache, max-age=0, post-check=0'); + +/** +* This function fix PHP's messing up POST input containing characters space, dot, +* open square bracket and others to be compatible with with the deprecated register_globals +* @return array POST +*/ + +function getRealPOST() { + $pairs = explode("&", file_get_contents("php://input")); + $vars = array(); + foreach ($pairs as $pair) { + $nv = explode("=", $pair, 2); + $name = urldecode($nv[0]); + $value = $nv[1]; + $vars[$name] = $value; + } + return $vars; +} + +/** +* This function formats the public-key +* @param array $pubkey +* @return string public-key +*/ +function pub_key($pubkey) { + $public_key=''; + foreach($pubkey as $values) $public_key=$public_key.$values; + return $public_key; +} + +$_POST=getRealPost(); + +if (ctype_digit($_POST['zone'])) { + // Get the parent soa record of the domain + $soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = '".$app->db->quote($_POST['zone'])."' AND ".$app->tform->getAuthSQL('r')); + + $public_key=$app->db->queryOneRecord("SELECT dkim_public FROM mail_domain WHERE domain = '".substr_replace($soa['origin'],'',-1)."' AND ".$app->tform->getAuthSQL('r')); + + $public_key=pub_key($public_key); + + $public_key=str_replace(array('-----BEGIN PUBLIC KEY-----','-----END PUBLIC KEY-----',"\r","\n"),'',$public_key); + + echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; + echo "<formatname>\n"; + echo "<data>".$public_key."</data>\n"; + echo "<name>".$soa['origin']."</name>\n"; + echo "</formatname>\n"; +} +?> diff --git a/interface/web/dns/dns_wizard.php b/interface/web/dns/dns_wizard.php index 8ce27ea..10cfd9a 100644 --- a/interface/web/dns/dns_wizard.php +++ b/interface/web/dns/dns_wizard.php @@ -195,14 +195,13 @@ if($_POST['ns1'] != '') $tpl_content = str_replace('{NS1}',$_POST['ns1'],$tpl_content); if($_POST['ns2'] != '') $tpl_content = str_replace('{NS2}',$_POST['ns2'],$tpl_content); if($_POST['email'] != '') $tpl_content = str_replace('{EMAIL}',$_POST['email'],$tpl_content); - if(isset($_POST['dkim']) && preg_match('/^[\w\.\-\/]{2,255}\.[a-zA-Z0-9\-]{2,30}[\.]{0,1}$/',$_POST['domain'])) { - $public_key=$app->db->queryOneRecord("SELECT dkim_public FROM mail_domain WHERE domain = '".$app->db->quote($_POST['domain'])."' AND dkim = 'y' AND ".$app->tform->getAuthSQL('r')); - if ($public_key!='') { - $dns_record=str_replace(array("\r\n", "\n", "\r","-----BEGIN PUBLIC KEY-----","-----END PUBLIC KEY-----"),'',$public_key['dkim_public']); - $tpl_content = str_replace('{DKIM}','TXT|default._domainkey.'.$_POST['domain'].'.|v=DKIM1; t=s; p='.$dns_record,$tpl_content); - } - } - + if(isset($_POST['dkim']) && preg_match('/^[\w\.\-\/]{2,255}\.[a-zA-Z0-9\-]{2,30}[\.]{0,1}$/',$_POST['domain'])) { + $public_key=$app->db->queryOneRecord("SELECT dkim_public FROM mail_domain WHERE domain = '".$app->db->quote($_POST['domain'])."' AND dkim = 'y' AND ".$app->tform->getAuthSQL('r')); + if ($public_key!='') { + $dns_record=str_replace(array("\r\n", "\n", "\r","-----BEGIN PUBLIC KEY-----","-----END PUBLIC KEY-----"),'',$public_key['dkim_public']); + $tpl_content = str_replace('{DKIM}','TXT|default._domainkey.'.$_POST['domain'].'.|v=DKIM1; t=s; p='.$dns_record,$tpl_content); + } + } // Parse the template $tpl_rows = explode("\n",$tpl_content); diff --git a/interface/web/dns/form/dns_dkim.tform.php b/interface/web/dns/form/dns_dkim.tform.php index ffeee58..71607c7 100644 --- a/interface/web/dns/form/dns_dkim.tform.php +++ b/interface/web/dns/form/dns_dkim.tform.php @@ -1,154 +1,154 @@ -<?php - -/* - Form Definition - - Tabledefinition - - Datatypes: - - INTEGER (Forces the input to Int) - - DOUBLE - - CURRENCY (Formats the values to currency notation) - - VARCHAR (no format check, maxlength: 255) - - TEXT (no format check) - - DATE (Dateformat, automatic conversion to timestamps) - - Formtype: - - TEXT (Textfield) - - TEXTAREA (Textarea) - - PASSWORD (Password textfield, input is not shown when edited) - - SELECT (Select option field) - - RADIO - - CHECKBOX - - CHECKBOXARRAY - - FILE - - VALUE: - - Wert oder Array - - Hint: - The ID field of the database table is not part of the datafield definition. - The ID field must be always auto incement (int or bigint). - - -*/ -global $app; - -$form["title"] = "DNS DKIM Record"; -$form["description"] = ""; -$form["name"] = "dns_dkim"; -$form["action"] = "dns_dkim_edit.php"; -$form["db_table"] = "dns_rr"; -$form["db_table_idx"] = "id"; -$form["db_history"] = "yes"; -$form["tab_default"] = "dns"; -$form["list_default"] = "dns_a_list.php"; -$form["auth"] = 'yes'; // yes / no - -$form["auth_preset"]["userid"] = 0; // 0 = id of the user, > 0 id must match with id of current user -$form["auth_preset"]["groupid"] = 0; // 0 = default groupid of the user, > 0 id must match with groupid of current user -$form["auth_preset"]["perm_user"] = 'riud'; //r = read, i = insert, u = update, d = delete -$form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, d = delete -$form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete - -$form["tabs"]['dns'] = array ( - 'title' => "DNS DKIM", - 'width' => 100, - 'template' => "templates/dns_dkim_edit.htm", - 'fields' => array ( - ################################## - # Begin Datatable fields - ################################## - 'server_id' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'SELECT', - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' - ), - 'zone' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'default' => @$app->functions->intval($_REQUEST["zone"]), - 'value' => '', - 'width' => '30', - 'maxlength' => '255' - ), - 'name' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'filters' => array( 0 => array( 'event' => 'SAVE', - 'type' => 'IDNTOASCII'), - 1 => array( 'event' => 'SHOW', - 'type' => 'IDNTOUTF8'), - 2 => array( 'event' => 'SAVE', - 'type' => 'TOLOWER') - ), - 'validators' => array ( 0 => array ( 'type' => 'REGEX', - 'regex' => '/^[\w\.\-]{0,255}$/', - 'errmsg'=> 'name_error_regex'), - ), - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' - ), - 'type' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => 'TXT', - 'value' => '', - 'width' => '5', - 'maxlength' => '5' - ), - 'data' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', - 'errmsg'=> 'data_error_empty'), - ), - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' - ), - 'ttl' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'default' => '86400', - 'value' => '', - 'width' => '10', - 'maxlength' => '10' - ), - 'active' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'Y', - 'value' => array(0 => 'N',1 => 'Y') - ), - 'stamp' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' - ), - 'serial' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'width' => '10', - 'maxlength' => '10' - ), - ################################## - # ENDE Datatable fields - ################################## - ) -); - - - -?> +<?php + +/* + Form Definition + + Tabledefinition + + Datatypes: + - INTEGER (Forces the input to Int) + - DOUBLE + - CURRENCY (Formats the values to currency notation) + - VARCHAR (no format check, maxlength: 255) + - TEXT (no format check) + - DATE (Dateformat, automatic conversion to timestamps) + + Formtype: + - TEXT (Textfield) + - TEXTAREA (Textarea) + - PASSWORD (Password textfield, input is not shown when edited) + - SELECT (Select option field) + - RADIO + - CHECKBOX + - CHECKBOXARRAY + - FILE + + VALUE: + - Wert oder Array + + Hint: + The ID field of the database table is not part of the datafield definition. + The ID field must be always auto incement (int or bigint). + + +*/ +global $app; + +$form["title"] = "DNS DKIM Record"; +$form["description"] = ""; +$form["name"] = "dns_dkim"; +$form["action"] = "dns_dkim_edit.php"; +$form["db_table"] = "dns_rr"; +$form["db_table_idx"] = "id"; +$form["db_history"] = "yes"; +$form["tab_default"] = "dns"; +$form["list_default"] = "dns_a_list.php"; +$form["auth"] = 'yes'; // yes / no + +$form["auth_preset"]["userid"] = 0; // 0 = id of the user, > 0 id must match with id of current user +$form["auth_preset"]["groupid"] = 0; // 0 = default groupid of the user, > 0 id must match with groupid of current user +$form["auth_preset"]["perm_user"] = 'riud'; //r = read, i = insert, u = update, d = delete +$form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, d = delete +$form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete + +$form["tabs"]['dns'] = array ( + 'title' => "DNS DKIM", + 'width' => 100, + 'template' => "templates/dns_dkim_edit.htm", + 'fields' => array ( + ################################## + # Begin Datatable fields + ################################## + 'server_id' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'SELECT', + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'zone' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'default' => @$app->functions->intval($_REQUEST["zone"]), + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'name' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'filters' => array( 0 => array( 'event' => 'SAVE', + 'type' => 'IDNTOASCII'), + 1 => array( 'event' => 'SHOW', + 'type' => 'IDNTOUTF8'), + 2 => array( 'event' => 'SAVE', + 'type' => 'TOLOWER') + ), + 'validators' => array ( 0 => array ( 'type' => 'REGEX', + 'regex' => '/^[\w\.\-]{0,255}$/', + 'errmsg'=> 'name_error_regex'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'type' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => 'TXT', + 'value' => '', + 'width' => '5', + 'maxlength' => '5' + ), + 'data' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'data_error_empty'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'ttl' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'default' => '86400', + 'value' => '', + 'width' => '10', + 'maxlength' => '10' + ), + 'active' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'Y', + 'value' => array(0 => 'N',1 => 'Y') + ), + 'stamp' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'serial' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'width' => '10', + 'maxlength' => '10' + ), + ################################## + # ENDE Datatable fields + ################################## + ) +); + + + +?> diff --git a/interface/web/dns/lib/lang/en_dns_dkim.lng b/interface/web/dns/lib/lang/en_dns_dkim.lng index 526257e..dabee2b 100644 --- a/interface/web/dns/lib/lang/en_dns_dkim.lng +++ b/interface/web/dns/lib/lang/en_dns_dkim.lng @@ -1,8 +1,8 @@ -<?php -$wb["public_key_txt"] = 'Public-Key'; -$wb["ttl_txt"] = 'TTL'; -$wb["active_txt"] = 'Active'; -$wb["record_exists_txt"] = 'DNS-Record already exists'; -$wb["limit_dns_record_txt"] = 'The max. number of DNS records for your account is reached.'; -$wb["no_zone_perm"] = 'You do not have the permission to add a record to this DNS zone.'; -?> +<?php +$wb["public_key_txt"] = 'Public-Key'; +$wb["ttl_txt"] = 'TTL'; +$wb["active_txt"] = 'Active'; +$wb["record_exists_txt"] = 'DNS-Record already exists'; +$wb["limit_dns_record_txt"] = 'The max. number of DNS records for your account is reached.'; +$wb["no_zone_perm"] = 'You do not have the permission to add a record to this DNS zone.'; +?> diff --git a/interface/web/dns/lib/lang/en_dns_wizard.lng b/interface/web/dns/lib/lang/en_dns_wizard.lng index 860464c..99f1f2a 100644 --- a/interface/web/dns/lib/lang/en_dns_wizard.lng +++ b/interface/web/dns/lib/lang/en_dns_wizard.lng @@ -36,4 +36,4 @@ $wb['globalsearch_noresults_limit_txt'] = "0 results"; $wb['globalsearch_searchfield_watermark_txt'] = "Search"; $wb['globalsearch_suggestions_text_txt'] = "Suggestions"; -?> \ No newline at end of file +?> diff --git a/interface/web/dns/templates/dns_dkim_edit.htm b/interface/web/dns/templates/dns_dkim_edit.htm index cbf8db9..3f89320 100644 --- a/interface/web/dns/templates/dns_dkim_edit.htm +++ b/interface/web/dns/templates/dns_dkim_edit.htm @@ -1,38 +1,38 @@ -<h2><tmpl_var name="list_head_txt"></h2> -<p><tmpl_var name="list_desc_txt"></p> - -<div class="panel panel_dns_txt"> - <div class="pnl_formsarea"> - <fieldset class="inlineLabels"> - <div class="ctrlHolder"> - <label for="data">{tmpl_var name='public_key_txt'}</label> - <textarea name="data" id="data" readonly>{tmpl_var name='public_key'}</textarea> - </div> - <div class="ctrlHolder"> - <label for="ttl">{tmpl_var name='ttl_txt'}</label> - <input name="ttl" id="ttl" value="{tmpl_var name='ttl'}" size="10" maxlength="10" type="text" class="textInput" /> - </div> - - <div class="ctrlHolder"> - <p class="label">{tmpl_var name='active_txt'}</p> - <div class="multiField"> - {tmpl_var name='active'} - </div> - </div> - </fieldset> - - <input type="hidden" name="id" value="{tmpl_var name='id'}"> - <input type="hidden" name="zone" value="{tmpl_var name='zone'}" id="zone"> - <input type="hidden" name="type" value="{tmpl_var name='type'}"> - <input type="hidden" name="name" value="{tmpl_var name='name'}"> - </div> - - <div class="buttonHolder buttons"> - <button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onclick="submitForm('pageForm','dns/dns_dkim_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('dns/dns_soa_edit.php?id={tmpl_var name='zone'}');"><span>{tmpl_var name='btn_cancel_txt'}</span></button> - </div> - </div> - -</div> -<script language="JavaScript" type="text/javascript" src="js/dns_dkim.js"></script> - +<h2><tmpl_var name="list_head_txt"></h2> +<p><tmpl_var name="list_desc_txt"></p> + +<div class="panel panel_dns_txt"> + <div class="pnl_formsarea"> + <fieldset class="inlineLabels"> + <div class="ctrlHolder"> + <label for="data">{tmpl_var name='public_key_txt'}</label> + <textarea name="data" id="data" readonly>{tmpl_var name='public_key'}</textarea> + </div> + <div class="ctrlHolder"> + <label for="ttl">{tmpl_var name='ttl_txt'}</label> + <input name="ttl" id="ttl" value="{tmpl_var name='ttl'}" size="10" maxlength="10" type="text" class="textInput" /> + </div> + + <div class="ctrlHolder"> + <p class="label">{tmpl_var name='active_txt'}</p> + <div class="multiField"> + {tmpl_var name='active'} + </div> + </div> + </fieldset> + + <input type="hidden" name="id" value="{tmpl_var name='id'}"> + <input type="hidden" name="zone" value="{tmpl_var name='zone'}" id="zone"> + <input type="hidden" name="type" value="{tmpl_var name='type'}"> + <input type="hidden" name="name" value="{tmpl_var name='name'}"> + </div> + + <div class="buttonHolder buttons"> + <button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onclick="submitForm('pageForm','dns/dns_dkim_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('dns/dns_soa_edit.php?id={tmpl_var name='zone'}');"><span>{tmpl_var name='btn_cancel_txt'}</span></button> + </div> + </div> + +</div> +<script language="JavaScript" type="text/javascript" src="js/dns_dkim.js"></script> + diff --git a/interface/web/js/dns_dkim.js b/interface/web/js/dns_dkim.js index 1294fd0..2811dbc 100644 --- a/interface/web/js/dns_dkim.js +++ b/interface/web/js/dns_dkim.js @@ -1,73 +1,71 @@ -/* -Copyright (c) 2007 - 2013, Till Brehm, projektfarm Gmbh -Copyright (c) 2013, Florian Schaal, info@schaal-24.de -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of ISPConfig nor the names of its contributors - may be used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - - -This Javascript is invoked by - * dns/templates/dns_dkim_edit.htm to get the public key -*/ - var request = false; - - function setRequest(zone) { - 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', 'dns/dns_dkim_get.php', true); - request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); - request.send('&zone='+zone); - 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('data')[0].value = request.responseXML.getElementsByTagName('data')[0].firstChild.nodeValue; - document.getElementsByName('name')[0].value = request.responseXML.getElementsByTagName('name')[0].firstChild.nodeValue; - } - break; - default: - break; - } - } - -var serverType = jQuery('#zone').val(); -setRequest(serverType); - - +/* +Copyright (c) 2007 - 2013, Till Brehm, projektfarm Gmbh +Copyright (c) 2013, Florian Schaal, info@schaal-24.de +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of ISPConfig nor the names of its contributors + may be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + + +This Javascript is invoked by + * dns/templates/dns_dkim_edit.htm to get the public key +*/ + var request = false; + + function setRequest(zone) { + 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', 'dns/dns_dkim_get.php', true); + request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); + request.send('&zone='+zone); + 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('data')[0].value = request.responseXML.getElementsByTagName('data')[0].firstChild.nodeValue; + document.getElementsByName('name')[0].value = request.responseXML.getElementsByTagName('name')[0].firstChild.nodeValue; + } + break; + default: + break; + } + } + +var serverType = jQuery('#zone').val(); +setRequest(serverType); diff --git a/interface/web/js/mail_domain_dkim.js b/interface/web/js/mail_domain_dkim.js index b07abc4..f1f14f6 100644 --- a/interface/web/js/mail_domain_dkim.js +++ b/interface/web/js/mail_domain_dkim.js @@ -1,72 +1,71 @@ -/* -Copyright (c) 2007 - 2013, Till Brehm, projektfarm Gmbh -Copyright (c) 2013, Florian Schaal, info@schaal-24.de -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of ISPConfig nor the names of its contributors - may be used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - - -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,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; - } - break; - default: - break; - } - } - -var serverType = jQuery('#dkim_private').val(); -setRequest('show','{tmpl_var name="domain"}',serverType); - +/* +Copyright (c) 2007 - 2013, Till Brehm, projektfarm Gmbh +Copyright (c) 2013, Florian Schaal, info@schaal-24.de +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of ISPConfig nor the names of its contributors + may be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + + +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,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; + } + break; + default: + break; + } + } + +var serverType = jQuery('#dkim_private').val(); +setRequest('show','{tmpl_var name="domain"}',serverType); diff --git a/interface/web/mail/mail_domain_dkim_create.php b/interface/web/mail/mail_domain_dkim_create.php index aab83a6..495c8df 100644 --- a/interface/web/mail/mail_domain_dkim_create.php +++ b/interface/web/mail/mail_domain_dkim_create.php @@ -1,5 +1,6 @@ <?php -/* + +/** Copyright (c) 2007 - 2013, Till Brehm, projektfarm Gmbh Copyright (c) 2013, Florian Schaal, info@schaal-24.de All rights reserved. @@ -26,30 +27,28 @@ OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - This script is invoked by interface/web/mail/templates/mail_domain_edit.htm - to generate or show the DKIM Private-key. - - returns DKIM Private-Key and DKIM Public-Key -*/ - -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); -require_once('../../lib/classes/validate_dkim.inc.php'); - -$validate_dkim=new validate_dkim (); - -//* Check permissions for module -$app->auth->check_module_permissions('mail'); - + +This script is invoked by interface/js/mail_domain_dkim.js +to generate or show the DKIM Private-key and to show the Private-key. +returns DKIM Private-Key and DKIM Public-Key +*/ + +require_once('../../lib/config.inc.php'); +require_once('../../lib/app.inc.php'); +require_once('../../lib/classes/validate_dkim.inc.php'); + +$validate_dkim=new validate_dkim (); + +//* Check permissions for module +$app->auth->check_module_permissions('mail'); + header('Content-Type: text/xml; charset=utf-8'); header('Cache-Control: must-revalidate, pre-check=0, no-store, no-cache, max-age=0, post-check=0'); -/* - This function fix PHP's messing up POST input containing characters space, dot, - open square bracket and others to be compatible with with the deprecated register_globals +/** +* This function fix PHP's messing up POST input containing characters space, dot, +* open square bracket and others to be compatible with with the deprecated register_globals +* @return array POST */ function getRealPOST() { $pairs = explode("&", file_get_contents("php://input")); @@ -60,40 +59,45 @@ $value = $nv[1]; $vars[$name] = $value; } - return $vars; -} - -function pub_key($pubkey) { - $public_key=''; - foreach($pubkey as $values) $public_key=$public_key.$values."\n"; - return $public_key; -} -$_POST=getRealPOST(); - -switch ($_POST['action']) { - case 'create': /* create DKIM Private-key */ - exec('openssl rand -out /usr/local/ispconfig/server/temp/random-data.bin 4096',$output,$result); - exec('openssl genrsa -rand /usr/local/ispconfig/server/temp/random-data.bin 1024',$privkey,$result); - unlink("/usr/local/ispconfig/server/temp/random-data.bin"); - $private_key=''; - foreach($privkey as $values) $private_key=$private_key.$values."\n"; - if($validate_dkim->validate_post('private',$private_key)) { /* validate the $_POST-value */ - exec('echo '.escapeshellarg($private_key).'|openssl rsa -pubout -outform PEM',$pubkey,$result); - $public_key=pub_key($pubkey); - } else { $public_key='invalid key'; } - break; - case 'show': /* show the DNS-Record onLoad */ - $private_key=$_POST['pkey']; - if($validate_dkim->validate_post('private',$private_key)) { /* validate the $_POST-value */ - /* get the public-key */ - exec('echo '.escapeshellarg($private_key).'|openssl rsa -pubout -outform PEM',$pubkey,$result); - $public_key=pub_key($pubkey); - } else { $public_key='invalid key'; } - break; -} -echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; -echo "<formatname>\n"; -echo "<privatekey>".$private_key."</privatekey>\n"; -echo "<publickey>".$public_key."</publickey>\n"; -echo "</formatname>\n"; -?> + return $vars; +} + +/** +* This function formats the public-key +* @param array $pubkey +* @return string public-key +*/ +function pub_key($pubkey) { + $public_key=''; + foreach($pubkey as $values) $public_key=$public_key.$values."\n"; + return $public_key; +} +$_POST=getRealPOST(); + +switch ($_POST['action']) { + case 'create': /* create DKIM Private-key */ + exec('openssl rand -out /usr/local/ispconfig/server/temp/random-data.bin 4096',$output,$result); + exec('openssl genrsa -rand /usr/local/ispconfig/server/temp/random-data.bin 1024',$privkey,$result); + unlink("/usr/local/ispconfig/server/temp/random-data.bin"); + $private_key=''; + foreach($privkey as $values) $private_key=$private_key.$values."\n"; + if($validate_dkim->validate_post('private',$private_key)) { /* validate the $_POST-value */ + exec('echo '.escapeshellarg($private_key).'|openssl rsa -pubout -outform PEM',$pubkey,$result); + $public_key=pub_key($pubkey); + } else { $public_key='invalid key'; } + break; + case 'show': /* show the DNS-Record onLoad */ + $private_key=$_POST['pkey']; + if($validate_dkim->validate_post('private',$private_key)) { /* validate the $_POST-value */ + /* get the public-key */ + exec('echo '.escapeshellarg($private_key).'|openssl rsa -pubout -outform PEM',$pubkey,$result); + $public_key=pub_key($pubkey); + } else { $public_key='invalid key'; } + break; +} +echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; +echo "<formatname>\n"; +echo "<privatekey>".$private_key."</privatekey>\n"; +echo "<publickey>".$public_key."</publickey>\n"; +echo "</formatname>\n"; +?> diff --git a/interface/web/mail/templates/mail_domain_edit.htm b/interface/web/mail/templates/mail_domain_edit.htm index 703515b..ed9d5ea 100644 --- a/interface/web/mail/templates/mail_domain_edit.htm +++ b/interface/web/mail/templates/mail_domain_edit.htm @@ -74,6 +74,10 @@ </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> +<!-- + <label for="dkim_public">{tmpl_var name='dkim_dns_txt'}</label> + <textarea name="dkim_public" id="dkim_public" rows='5' cols='30' readonly>{tmpl_var name='dkim_public'}</textarea> +--> </div> </div> diff --git a/server/plugins-available/mail_plugin_dkim.inc.php b/server/plugins-available/mail_plugin_dkim.inc.php index 8d81339..72a1d03 100644 --- a/server/plugins-available/mail_plugin_dkim.inc.php +++ b/server/plugins-available/mail_plugin_dkim.inc.php @@ -1,6 +1,6 @@ <?php -/* +/** Copyright (c) 2007 - 2013, Till Brehm, projektfarm Gmbh Copyright (c) 2013, Florian Schaal, info@schaal-24.de All rights reserved. @@ -27,6 +27,9 @@ OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +@author Florian Schaal, info@schaal-24.de +@copyrighth Florian Schaal, info@schaal-24.de */ class mail_plugin_dkim { @@ -37,9 +40,9 @@ // private variables var $action = ''; - /* - This function is called during ispconfig installation to determine - if a symlink shall be created for this plugin. + /** + * This function is called during ispconfig installation to determine + * if a symlink shall be created for this plugin. */ function onInstall() { global $conf; @@ -52,8 +55,8 @@ } - /* - This function is called when the plugin is loaded + /** + * This function is called when the plugin is loaded */ function onLoad() { global $app,$conf; @@ -65,8 +68,9 @@ $app->plugins->registerEvent('mail_domain_update',$this->plugin_name,'domain_dkim_update'); } - /* - This function gets the amavisd-config file + /** + * This function gets the amavisd-config file + * @return string path to the amavisd-config for dkim-keys */ function get_amavis_config() { $pos_config=array( @@ -84,9 +88,11 @@ return $amavis_configfile; } - /* - This function checks the relevant configs and disables dkim for the domain - if the directory for dkim is not writeable or does not exist + /** + * This function checks the relevant configs and disables dkim for the domain + * if the directory for dkim is not writeable or does not exist + * @param array $data mail-settings + * @return boolean - true when the amavis-config and the dkim-dir are writeable */ function check_system($data) { global $app,$mail_config; @@ -105,25 +111,29 @@ $check=false; } } else { - $app->log('Unable to write DKIM settings. Check your config!',LOGLEVEL_ERROR); + $app->log('Unable to write DKIM settings; Check your config!',LOGLEVEL_ERROR); $check=false; } return $check; } - /* - This function restarts amavis + /** + * This function restarts amavis */ function restart_amavis() { global $app,$conf; $initfile=$conf['init_scripts'].'/amavis'; - $app->log('Reloading amavis.',LOGLEVEL_DEBUG); - exec(escapeshellarg($conf['init_scripts']).escapeshellarg('/amavis').' reload',$output); + $app->log('Restarting amavis.',LOGLEVEL_DEBUG); + exec(escapeshellarg($conf['init_scripts']).escapeshellarg('/amavis').' restart',$output); foreach($output as $logline) $app->log($logline,LOGLEVEL_DEBUG); } - /* - This function writes the keyfiles (public and private) + /** + * This function writes the keyfiles (public and private) + * @param string $key_file full path to the key-file + * @param string $key_value private-key + * @param string $key_domain mail-domain + * @return bool - true when the key is written to disk */ function write_dkim_key($key_file,$key_value,$key_domain) { global $app,$mailconfig; @@ -143,8 +153,10 @@ return $success; } - /* - This function removes the keyfiles + /** + * This function removes the keyfiles + * @param string $key_file full path to the key-file + * @param string $key_domain mail-domain */ function remove_dkim_key($key_file,$key_domain) { global $app; @@ -158,8 +170,9 @@ } else $app->log('Unable to delete the DKIM Public-key for '.$key_domain.' (not found).',LOGLEVEL_DEBUG); } - /* - This function adds the entry to the amavisd-config + /** + * This function adds the entry to the amavisd-config + * @param string $key_domain mail-domain */ function add_to_amavis($key_domain) { global $app,$mail_config; @@ -172,8 +185,9 @@ } } - /* - This function removes the entry from the amavisd-config + /** + * This function removes the entry from the amavisd-config + * @param string $key_domain mail-domain */ function remove_from_amavis($key_domain) { global $app; @@ -193,24 +207,31 @@ } else $app->log('Unable to delete the DKIM settings from amavis-config for '.$key_domain.'.',LOGLEVEL_ERROR); } - /* - This function controlls new key-files and amavisd-entries + /** + * This function controlls new key-files and amavisd-entries + * @param array $data mail-settings */ function add_dkim($data) { global $app; - $mail_config = $app->getconf->get_server_config($conf['server_id'], 'mail'); - if ( substr($mail_config['dkim_path'],strlen($mail_config['dkim_path'])-1) == '/' ) - $mail_config['dkim_path'] = substr($mail_config['dkim_path'],0,strlen($mail_config['dkim_path'])-1); - if ($this->write_dkim_key($mail_config['dkim_path']."/".$data['new']['domain'],$data['new']['dkim_private'],$data['new']['domain'])) { - $this->add_to_amavis($data['new']['domain']); - } else { - $app->log('Error saving the DKIM Private-key for '.$data['new']['domain'].' - DKIM is not enabled for the domain.',LOGLEVEL_ERROR); + if ($data['new']['active'] == 'y') { + $mail_config = $app->getconf->get_server_config($conf['server_id'], 'mail'); + if ( substr($mail_config['dkim_path'],strlen($mail_config['dkim_path'])-1) == '/' ) + $mail_config['dkim_path'] = substr($mail_config['dkim_path'],0,strlen($mail_config['dkim_path'])-1); + if ($this->write_dkim_key($mail_config['dkim_path']."/".$data['new']['domain'],$data['new']['dkim_private'],$data['new']['domain'])) { + $this->add_to_amavis($data['new']['domain']); + } else { + $app->log('Error saving the DKIM Private-key for '.$data['new']['domain'].' - DKIM is not enabled for the domain.',LOGLEVEL_ERROR); + } + } + else { + $app->log('DKIM for '.$data['new']['domain'].' not written to disk - domain is inactive',LOGLEVEL_DEBUG); } } - /* - This function controlls the removement of keyfiles (public and private) - and the entry in the amavisd-config + /** + * This function controlls the removement of keyfiles (public and private) + * and the entry in the amavisd-config + * @param array $data mail-settings */ function remove_dkim($_data) { global $app; @@ -221,19 +242,28 @@ $this->remove_from_amavis($_data['domain']); } - /* - Functions called by onLoad + /** + * Function called by onLoad + * deletes dkim-keys */ function domain_dkim_delete($event_name,$data) { if (isset($data['old']['dkim']) && $data['old']['dkim'] == 'y') $this->remove_dkim($data['old']); } + /** + * Function called by onLoad + * insert dkim-keys + */ function domain_dkim_insert($event_name,$data) { if (isset($data['new']['dkim']) && $data['new']['dkim']=='y' && $this->check_system($data)) { $this->add_dkim($data); } } + /** + * Function called by onLoad + * chang dkim-settings + */ function domain_dkim_update($event_name,$data) { global $app; /* get the config */ -- Gitblit v1.9.1