diff --git a/db.sql b/db.sql index 9c9fd12eef19c663f501d73f309157d3c77fbfe1..ba368f5051fc8fce3ca90e78c6b59cbc3e53e333 100644 --- a/db.sql +++ b/db.sql @@ -76,8 +76,6 @@ CREATE TABLE `wizard_template` ( `database_remote_access` enum('n','y') NOT NULL DEFAULT 'n', `database_remote_ips` text, `policy` int(11) unsigned NOT NULL DEFAULT '0', - `dkim` enum('n','y') NOT NULL DEFAULT 'n', - `dkim_selector` varchar(63) NOT NULL DEFAULT 'default', `quota_files` bigint(20) NOT NULL DEFAULT '-1', `ul_ratio` int(11) NOT NULL DEFAULT '-1', `dl_ratio` int(11) NOT NULL DEFAULT '-1', diff --git a/form/new_service.tform.php b/form/new_service.tform.php index b47f061db0291607b08376455d75e34c98453434..ce59ee8a771a5bfdf51669381697ce29682b5c9a 100644 --- a/form/new_service.tform.php +++ b/form/new_service.tform.php @@ -170,6 +170,45 @@ $form["tabs"]['client'] = array( 'value' => '', 'width' => '30', ), + 'dkim' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') + ), + 'dkim_private' => array ( + 'datatype' => 'TEXT', + 'formtype' => 'TEXTAREA', + 'default' => '', + 'value' => '', + 'cols' => '30', + 'rows' => '10', + 'validators' => array ( 0 => array ('type' => 'CUSTOM', + 'class' => 'validate_dkim', + 'function' => 'check_private_key', + 'errmsg'=> 'dkim_private_key_error'), + ), + ), + 'dkim_public' => array ( + 'datatype' => 'TEXT', + 'formtype' => 'TEXTAREA', + 'default' => '', + 'value' => '', + 'cols' => '30', + 'rows' => '10' + ), + 'dkim_selector' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => 'default', + 'value' => 'default', + 'width' => '20', + 'maxlength' => '63', + 'validators' => array ( 0 => array ( 'type' => 'REGEX', + 'regex' => '/^[a-z0-9]{0,63}$/', + 'errmsg'=> 'dkim_selector_error'), + ), + ), 'dns' => array ( 'datatype' => 'VARCHAR', 'formtype' => 'CHECKBOX', diff --git a/form/template.tform.php b/form/template.tform.php index f9ef0c1e7bef56c170ef21427bf280ce83427dfd..71cdfc22f4ac971aac2b82a8500a9d9cf3dab82c 100644 --- a/form/template.tform.php +++ b/form/template.tform.php @@ -237,6 +237,8 @@ function load_foreing_form($type, $path) // unset fields unset($new_form['domain']); unset($new_form['active']); + unset($new_form['dkim']); + unset($new_form['dkim_selector']); unset($new_form['dkim_private']); unset($new_form['dkim_public']); diff --git a/lib/lang/en_new_service.lng b/lib/lang/en_new_service.lng index 8c27db79cf9cf3ffe7b2998fc3816a382c923598..d1f683317e7e3545450b1fd3b737b76f30696252 100644 --- a/lib/lang/en_new_service.lng +++ b/lib/lang/en_new_service.lng @@ -12,6 +12,14 @@ $wb["template_id_txt"] = 'Template'; $wb["mail_txt"] = 'Create Mail'; $wb["mailboxes_txt"] = 'Mailboxes'; $wb["mailboxes_help_txt"] = 'Separated by comma, just mailbox name without @domain.tld'; +$wb["dkim_txt"] = 'Enable DKIM'; +$wb["dkim_private_txt"] = 'DKIM Private-key'; +$wb["dkim_public_txt"] = 'DKIM Public-key\nfor information only'; +$wb["dkim_generate_txt"] = 'Generate DKIM Private-key'; +$wb["dkim_dns_txt"] = 'DNS-Record'; +$wb["dkim_settings_txt"] = 'DomainKeys Identified Mail (DKIM)'; +$wb['dkim_selector_txt'] = 'DKIM-Selector'; +$wb["dkim_private_key_error"] = 'Invalid DKIM-Private key'; $wb["dns_txt"] = 'Create DNS Zone'; $wb['email_txt'] = 'Email'; $wb['dnssec_txt'] = 'Sign zone (DNSSEC)'; @@ -36,4 +44,5 @@ $wb['error_email_empty'] = 'Email empty.'; $wb['error_domain_regex'] = 'Domain contains invalid characters.'; $wb['error_ns1_regex'] = 'NS1 contains invalid characters.'; $wb['error_ns2_regex'] = 'NS2 contains invalid characters.'; -$wb['error_email_regex'] = 'Email does not contain a valid email address.'; \ No newline at end of file +$wb['error_email_regex'] = 'Email does not contain a valid email address.'; +$wb["__"] = ''; \ No newline at end of file diff --git a/new_service.php b/new_service.php index f3c78c9e9e5d683909ca4c1a16989edf2976cddb..993038c4a6d862f9a002679428e0d44c453f2d1f 100644 --- a/new_service.php +++ b/new_service.php @@ -152,7 +152,7 @@ class page_action extends tform_actions { return; } - $tform_def_file = "form/dns_soa.tform.php"; + $tform_def_file = "../dns/form/dns_soa.tform.php"; $app->tform->loadFormDef($tform_def_file); // replace template placeholders @@ -286,6 +286,26 @@ class page_action extends tform_actions { ); $dns_rr_id = $app->db->datalogInsert('dns_rr', $insert_data, 'id'); } + + if($fields['dkim']) + { + $insert_data = array( + "sys_userid" => $sys_userid, + "sys_groupid" => $client_group_id, + "sys_perm_user" => 'riud', + "sys_perm_group" => 'riud', + "sys_perm_other" => '', + "server_id" => $template['dns_server_id'], + "zone" => $dns_soa_id, + "name" => $fields['dkim_selector'].'._domainkey.'.$fields['domain'].'.', + "type" => 'TXT', + "data" => 'v=DKIM1; t=s; p='.str_replace(array('-----BEGIN PUBLIC KEY-----','-----END PUBLIC KEY-----',"\r","\n"), '', $_POST['dkim_public']), + "aux" => 0, + "ttl" => 86400, + "active" => 'Y' + ); + $dns_rr_id = $app->db->datalogInsert('dns_rr', $insert_data, 'id'); + } } $tform_def_file = "form/new_service.tform.php"; @@ -293,13 +313,18 @@ class page_action extends tform_actions { } if($fields['mail']) - { + { // add mail domain $params = array( 'server_id' => $template['mail_server_id'], 'domain' => $fields['domain'], + 'dkim' => $fields['dkim'], + 'dkim_private' => $_POST['dkim_private'], + 'dkim_public' => $_POST['dkim_public'], + 'dkim_selector' => $fields['dkim_selector'], 'active' => 'y' ); + $mail_domain_id = $remote->insert_query('../mail/form/mail_domain.tform.php', $fields['client_id'], $params); if($template['policy']) @@ -547,6 +572,11 @@ class page_action extends tform_actions { '; } + private function clean_private_key($key) + { + return str_replace('\r\n', '', $key); + } + } class remote_actions extends remoting { diff --git a/readme_images/new_service.png b/readme_images/new_service.png index e01ecd4ede6fc99271f3993f0b4e07611ee4d766..995327bbff6ed8b343a9f7a9f048c8cd853df738 100644 Binary files a/readme_images/new_service.png and b/readme_images/new_service.png differ diff --git a/templates/new_service.htm b/templates/new_service.htm index 28c30c4a56b42df4091c02e8cb84eda06ab1c514..443461fa4ddcce18f71d7fddc0c679acdb1e002c 100644 --- a/templates/new_service.htm +++ b/templates/new_service.htm @@ -68,6 +68,46 @@
{tmpl_var name='mailboxes_help_txt'}
+
+ +
+ {tmpl_var name='dkim'} +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+
+ {tmpl_var name='dkim_generate_txt'} +
+
+ +
+
+ +
+
+ +
+ +
+ +
+
+
@@ -146,6 +186,26 @@ else { $(".mail").hide(); + $(".dkim").hide(); + $("input[name=dkim]").prop('checked', false); + } + }); + + if( ! $("input[name=dkim]").is(':checked')) + { + $(".dkim").hide(); + } + + $("input[name=dkim]").change(function(){ + if($(this).is(':checked')) + { + $(".dkim").show(); + $(".dns").show(); + $("input[name=dns]").prop('checked', true); + } + else + { + $(".dkim").hide(); } }); @@ -157,6 +217,8 @@ else { $(".dns").hide(); + $(".dkim").hide(); + $("input[name=dkim]").prop('checked', false); } }); @@ -192,4 +254,5 @@ searchFieldWatermark: '', resultBoxPosition: '' }); - \ No newline at end of file + + \ No newline at end of file diff --git a/templates/template_mail.htm b/templates/template_mail.htm index ee92d87123df6d29e8bec93ec1bd98a59c313c40..5555aa7e0e7b7b83144653677aa45884948867b7 100644 --- a/templates/template_mail.htm +++ b/templates/template_mail.htm @@ -41,19 +41,6 @@
-
- -
- {tmpl_var name='dkim'} -
-
-
- -
- -
-
-
@@ -61,23 +48,4 @@
- - \ No newline at end of file + \ No newline at end of file