Commit 7e6f0766 authored by Kristián Feldsam's avatar Kristián Feldsam

Added DKIM support

Signed-off-by: Kristián Feldsam's avatarKristián Feldsam <feldsam@gmail.com>
parent 1541575b
...@@ -76,8 +76,6 @@ CREATE TABLE `wizard_template` ( ...@@ -76,8 +76,6 @@ CREATE TABLE `wizard_template` (
`database_remote_access` enum('n','y') NOT NULL DEFAULT 'n', `database_remote_access` enum('n','y') NOT NULL DEFAULT 'n',
`database_remote_ips` text, `database_remote_ips` text,
`policy` int(11) unsigned NOT NULL DEFAULT '0', `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', `quota_files` bigint(20) NOT NULL DEFAULT '-1',
`ul_ratio` int(11) NOT NULL DEFAULT '-1', `ul_ratio` int(11) NOT NULL DEFAULT '-1',
`dl_ratio` int(11) NOT NULL DEFAULT '-1', `dl_ratio` int(11) NOT NULL DEFAULT '-1',
......
...@@ -170,6 +170,45 @@ $form["tabs"]['client'] = array( ...@@ -170,6 +170,45 @@ $form["tabs"]['client'] = array(
'value' => '', 'value' => '',
'width' => '30', '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 ( 'dns' => array (
'datatype' => 'VARCHAR', 'datatype' => 'VARCHAR',
'formtype' => 'CHECKBOX', 'formtype' => 'CHECKBOX',
......
...@@ -237,6 +237,8 @@ function load_foreing_form($type, $path) ...@@ -237,6 +237,8 @@ function load_foreing_form($type, $path)
// unset fields // unset fields
unset($new_form['domain']); unset($new_form['domain']);
unset($new_form['active']); unset($new_form['active']);
unset($new_form['dkim']);
unset($new_form['dkim_selector']);
unset($new_form['dkim_private']); unset($new_form['dkim_private']);
unset($new_form['dkim_public']); unset($new_form['dkim_public']);
......
...@@ -12,6 +12,14 @@ $wb["template_id_txt"] = 'Template'; ...@@ -12,6 +12,14 @@ $wb["template_id_txt"] = 'Template';
$wb["mail_txt"] = 'Create Mail'; $wb["mail_txt"] = 'Create Mail';
$wb["mailboxes_txt"] = 'Mailboxes'; $wb["mailboxes_txt"] = 'Mailboxes';
$wb["mailboxes_help_txt"] = 'Separated by comma, just mailbox name without @domain.tld'; $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["dns_txt"] = 'Create DNS Zone';
$wb['email_txt'] = 'Email'; $wb['email_txt'] = 'Email';
$wb['dnssec_txt'] = 'Sign zone (DNSSEC)'; $wb['dnssec_txt'] = 'Sign zone (DNSSEC)';
...@@ -36,4 +44,5 @@ $wb['error_email_empty'] = 'Email empty.'; ...@@ -36,4 +44,5 @@ $wb['error_email_empty'] = 'Email empty.';
$wb['error_domain_regex'] = 'Domain contains invalid characters.'; $wb['error_domain_regex'] = 'Domain contains invalid characters.';
$wb['error_ns1_regex'] = 'NS1 contains invalid characters.'; $wb['error_ns1_regex'] = 'NS1 contains invalid characters.';
$wb['error_ns2_regex'] = 'NS2 contains invalid characters.'; $wb['error_ns2_regex'] = 'NS2 contains invalid characters.';
$wb['error_email_regex'] = 'Email does not contain a valid email address.'; $wb['error_email_regex'] = 'Email does not contain a valid email address.';
\ No newline at end of file $wb["__"] = '';
\ No newline at end of file
...@@ -152,7 +152,7 @@ class page_action extends tform_actions { ...@@ -152,7 +152,7 @@ class page_action extends tform_actions {
return; return;
} }
$tform_def_file = "form/dns_soa.tform.php"; $tform_def_file = "../dns/form/dns_soa.tform.php";
$app->tform->loadFormDef($tform_def_file); $app->tform->loadFormDef($tform_def_file);
// replace template placeholders // replace template placeholders
...@@ -286,6 +286,26 @@ class page_action extends tform_actions { ...@@ -286,6 +286,26 @@ class page_action extends tform_actions {
); );
$dns_rr_id = $app->db->datalogInsert('dns_rr', $insert_data, 'id'); $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"; $tform_def_file = "form/new_service.tform.php";
...@@ -293,13 +313,18 @@ class page_action extends tform_actions { ...@@ -293,13 +313,18 @@ class page_action extends tform_actions {
} }
if($fields['mail']) if($fields['mail'])
{ {
// add mail domain // add mail domain
$params = array( $params = array(
'server_id' => $template['mail_server_id'], 'server_id' => $template['mail_server_id'],
'domain' => $fields['domain'], 'domain' => $fields['domain'],
'dkim' => $fields['dkim'],
'dkim_private' => $_POST['dkim_private'],
'dkim_public' => $_POST['dkim_public'],
'dkim_selector' => $fields['dkim_selector'],
'active' => 'y' 'active' => 'y'
); );
$mail_domain_id = $remote->insert_query('../mail/form/mail_domain.tform.php', $fields['client_id'], $params); $mail_domain_id = $remote->insert_query('../mail/form/mail_domain.tform.php', $fields['client_id'], $params);
if($template['policy']) if($template['policy'])
...@@ -547,6 +572,11 @@ class page_action extends tform_actions { ...@@ -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 { class remote_actions extends remoting {
......
readme_images/new_service.png

226 KB | W: | H:

readme_images/new_service.png

313 KB | W: | H:

readme_images/new_service.png
readme_images/new_service.png
readme_images/new_service.png
readme_images/new_service.png
  • 2-up
  • Swipe
  • Onion skin
...@@ -68,6 +68,46 @@ ...@@ -68,6 +68,46 @@
<div class="col-sm-3">{tmpl_var name='mailboxes_help_txt'}</div> <div class="col-sm-3">{tmpl_var name='mailboxes_help_txt'}</div>
</div> </div>
<div class="form-group mail">
<label class="col-sm-3 control-label">{tmpl_var name='dkim_txt'}</label>
<div class="col-sm-9">
{tmpl_var name='dkim'}
</div>
</div>
<div class="form-group dkim">
<label for="dkim_selector" class="col-sm-3 control-label">{tmpl_var name='dkim_selector_txt'}</label>
<div class="col-sm-9">
<input type="text" name="dkim_selector" id="dkim_selector" value="{tmpl_var name='dkim_selector'}" class="form-control" />
</div>
</div>
<div class="form-group dkim">
<label for="dkim_private" class="col-sm-3 control-label">{tmpl_var name='dkim_private_txt'}</label>
<div class="col-sm-9">
<textarea class="form-control" name="dkim_private" id="dkim_private" rows='10' cols='30'>{tmpl_var name='dkim_private'}</textarea>
</div>
</div>
<div class="form-group dkim">
<div class="col-sm-9 col-sm-push-3">
<a class="btn btn-default formbutton-default" href="javascript:setRequest('create')" value="{tmpl_var name='dkim_generate_txt'}">{tmpl_var name='dkim_generate_txt'}</a>
</div>
</div>
<div class="form-group dkim">
<div class="col-sm-9">
<textarea class="form-control" name="dkim_public" style="display:none;" id="dkim_public" rows='5' cols='30' readonly>{tmpl_var name='dkim_public'}</textarea>
</div>
</div>
<div class="form-group dkim">
<label for="dns_record" class="col-sm-3 control-label">{tmpl_var name='dkim_dns_txt'}</label>
<div class="col-sm-9">
<textarea class="form-control" name="dns_record" id="dns_record" rows='10' cols='30' readonly>{tmpl_var name='dns_record'}</textarea>
</div>
</div>
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label">{tmpl_var name='dns_txt'}</label> <label class="col-sm-3 control-label">{tmpl_var name='dns_txt'}</label>
<div class="col-sm-9"> <div class="col-sm-9">
...@@ -146,6 +186,26 @@ ...@@ -146,6 +186,26 @@
else else
{ {
$(".mail").hide(); $(".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 @@ ...@@ -157,6 +217,8 @@
else else
{ {
$(".dns").hide(); $(".dns").hide();
$(".dkim").hide();
$("input[name=dkim]").prop('checked', false);
} }
}); });
...@@ -192,4 +254,5 @@ ...@@ -192,4 +254,5 @@
searchFieldWatermark: '', searchFieldWatermark: '',
resultBoxPosition: '' resultBoxPosition: ''
}); });
</script> </script>
\ No newline at end of file <script language="JavaScript" type="text/javascript" src="js/mail_domain_dkim.js"></script>
\ No newline at end of file
...@@ -41,19 +41,6 @@ ...@@ -41,19 +41,6 @@
</div> </div>
</div> </div>
<div class="form-group">
<label class="col-sm-3 control-label">{tmpl_var name='dkim_txt'}</label>
<div class="col-sm-9">
{tmpl_var name='dkim'}
</div>
</div>
<div class="form-group dkim">
<label for="dkim_selector" class="col-sm-3 control-label">{tmpl_var name='dkim_selector_txt'}</label>
<div class="col-sm-9">
<input type="text" name="dkim_selector" id="dkim_selector" value="{tmpl_var name='dkim_selector'}" class="form-control" />
</div>
</div>
<input type="hidden" name="id" value="{tmpl_var name='id'}"> <input type="hidden" name="id" value="{tmpl_var name='id'}">
<div class="clear"> <div class="clear">
...@@ -61,23 +48,4 @@ ...@@ -61,23 +48,4 @@
<button class="btn btn-default formbutton-success" type="button" value="{tmpl_var name='btn_save_txt'}" data-submit-form="pageForm" data-form-action="wizard/template_edit.php">{tmpl_var name='btn_save_txt'}</button> <button class="btn btn-default formbutton-success" type="button" value="{tmpl_var name='btn_save_txt'}" data-submit-form="pageForm" data-form-action="wizard/template_edit.php">{tmpl_var name='btn_save_txt'}</button>
<button class="btn btn-default formbutton-default" type="button" value="{tmpl_var name='btn_cancel_txt'}" data-load-content="wizard/template_list.php">{tmpl_var name='btn_cancel_txt'}</button> <button class="btn btn-default formbutton-default" type="button" value="{tmpl_var name='btn_cancel_txt'}" data-load-content="wizard/template_list.php">{tmpl_var name='btn_cancel_txt'}</button>
</div> </div>
</div> </div>
<script type="text/javascript"> \ No newline at end of file
check();
$("input[name=dkim]").change(function(){
check();
});
function check()
{
if($("input[name=dkim]").is(':checked'))
{
$(".dkim").show();
}
else
{
$(".dkim").hide();
}
}
</script>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment