Skip to content

Commit e326996

Browse files
committed
Added autoresponder function and custom maildrop rules.
1 parent 20e6426 commit e326996

File tree

10 files changed

+346
-56
lines changed

10 files changed

+346
-56
lines changed

install/install.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@
121121
exec("/etc/init.d/courier-imap-ssl restart");
122122
exec("/etc/init.d/courier-pop restart");
123123
exec("/etc/init.d/courier-pop-ssl restart");
124-
124+
exec("/etc/init.d/apache2 restart");
125125

126126
echo "Installation finished.\n";
127127

install/lib/installer_base.lib.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ function configure_saslauthd() {
318318
// Edit the file /etc/default/saslauthd
319319
$configfile = '/etc/default/saslauthd';
320320
if(is_file($configfile)) copy($configfile,$configfile.'~');
321-
if(is_file($configfile.'~')) exec('chmod 400 '.$configfile.'/~');
321+
if(is_file($configfile.'~')) exec('chmod 400 '.$configfile.'~');
322322
$content = rf($configfile);
323323
$content = str_replace('START=no','START=yes',$content);
324324
$content = str_replace('OPTIONS="-c"','OPTIONS="-m /var/spool/postfix/var/run/saslauthd -r"',$content);
@@ -371,7 +371,7 @@ function configure_courier() {
371371
//authdaemonrc
372372
$configfile = $conf["dist_courier_config_dir"].'/authdaemonrc';
373373
if(is_file($configfile)) copy($configfile,$configfile.'~');
374-
if(is_file($configfile.'~')) exec('chmod 400 '.$configfile.'/~');
374+
if(is_file($configfile.'~')) exec('chmod 400 '.$configfile.'~');
375375
$content = rf($configfile);
376376
$content = str_replace('authmodulelist="authpam"','authmodulelist="authmysql"',$content);
377377
wf($configfile,$content);

install/tpl/mailfilter.master

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,26 @@ if ( $RETURNCODE != 0 )
3737
`chmod -R 0700 {dist_postfix_vmail_mailbox_base}/$HOST`
3838
}
3939

40+
# Check if the user has a autoresponder enabled
41+
42+
`test -f {dist_postfix_vmail_mailbox_base}/mailfilters/$HOST/$USER/.autoresponder`
43+
if ( $RETURNCODE == 0 )
44+
{
45+
include "{dist_postfix_vmail_mailbox_base}/mailfilters/$HOST/$USER/.autoresponder"
46+
}
47+
48+
4049
#
4150
# Check that user has his own maildrop include,
4251
# if not available, check if $DEFAULT is set
4352
# (newer maildrop get's that from the DB and updates
4453
# it) and deliver or fail temporarily if not available
4554
#
4655

47-
`test -f {dist_postfix_vmail_mailbox_base}/mailfilters/$LOGNAME`
56+
`test -f {dist_postfix_vmail_mailbox_base}/mailfilters/$HOST/$USER/.mailfilter`
4857
if ( $RETURNCODE == 0 )
4958
{
50-
include "{dist_postfix_vmail_mailbox_base}/mailfilters/$LOGNAME"
59+
include "{dist_postfix_vmail_mailbox_base}/mailfilters/$HOST/$USER/.mailfilter"
5160
}
5261
else
5362
{

interface/lib/classes/tform.inc.php

Lines changed: 56 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -673,15 +673,23 @@ function getSQL($record, $tab, $action = 'INSERT', $primary_id = 0, $sql_ext_whe
673673
if($field['formtype'] == 'PASSWORD') {
674674
$sql_insert_key .= "`$key`, ";
675675
if($field['encryption'] == 'CRYPT') {
676-
// $sql_insert_val .= "encrypt('".$record[$key]."'), ";
677-
$sql_insert_val .= "'".crypt($record[$key],substr(md5(time()),0,2))."', ";
676+
$salt="$1$";
677+
for ($n=0;$n<8;$n++) {
678+
$salt.=chr(mt_rand(64,126));
679+
}
680+
$salt.="$";
681+
// $salt = substr(md5(time()),0,2);
682+
$record[$key] = crypt($record[$key],$salt);
678683
} else {
679-
$sql_insert_val .= "md5('".$record[$key]."'), ";
684+
$record[$key] = md5($record[$key]);
680685
}
686+
$sql_insert_val .= "'".$record[$key]."', ";
681687
} elseif ($field['formtype'] == 'CHECKBOX') {
682688
$sql_insert_key .= "`$key`, ";
683689
if($record[$key] == '') {
690+
// if a checkbox is not set, we set it to the unchecked value
684691
$sql_insert_val .= "'".$field['value'][0]."', ";
692+
$record[$key] = $field['value'][0];
685693
} else {
686694
$sql_insert_val .= "'".$record[$key]."', ";
687695
}
@@ -691,23 +699,35 @@ function getSQL($record, $tab, $action = 'INSERT', $primary_id = 0, $sql_ext_whe
691699
}
692700
} else {
693701
if($field['formtype'] == 'PASSWORD') {
694-
if($field['encryption'] == 'CRYPT') {
695-
// $sql_update .= "`$key` = encrypt('".$record[$key]."'), ";
696-
$sql_update .= "`$key` = '".crypt($record[$key],substr(md5(time()),0,2))."', ";
702+
if($field['encryption'] == 'CRYPT') {
703+
$salt="$1$";
704+
for ($n=0;$n<8;$n++) {
705+
$salt.=chr(mt_rand(64,126));
706+
}
707+
$salt.="$";
708+
// $salt = substr(md5(time()),0,2);
709+
$record[$key] = crypt($record[$key],$salt);
697710
} else {
698-
$sql_update .= "`$key` = md5('".$record[$key]."'), ";
711+
$record[$key] = md5($record[$key]);
699712
}
713+
$sql_update .= "`$key` = '".$record[$key]."', ";
700714
} elseif ($field['formtype'] == 'CHECKBOX') {
701715
if($record[$key] == '') {
716+
// if a checkbox is not set, we set it to the unchecked value
702717
$sql_update .= "`$key` = '".$field['value'][0]."', ";
718+
$record[$key] = $field['value'][0];
703719
} else {
704720
$sql_update .= "`$key` = '".$record[$key]."', ";
705721
}
706722
} else {
707723
$sql_update .= "`$key` = '".$record[$key]."', ";
708724
}
709725
}
710-
}
726+
} else {
727+
// we unset the password filed, if empty to tell the datalog function
728+
// that the password has not been changed
729+
unset($record[$key]);
730+
}
711731
}
712732
}
713733

@@ -840,30 +860,46 @@ function datalogSave($action,$primary_id,$record_new) {
840860
}
841861

842862
$diffrec = array();
843-
863+
844864
if(is_array($record_new)) {
845865
foreach($record_new as $key => $val) {
846866
if($record_old[$key] != $val) {
847-
// Datensatz hat sich geändert
867+
// Record has changed
848868
$diffrec[$key] = array('old' => $record_old[$key],
849-
'new' => $val);
869+
'new' => $val);
850870
}
851871
}
852872
}
873+
$this->diffrec = $diffrec;
874+
875+
// Full diff records for ISPConfig, they have a different format then the simple diffrec
876+
$diffrec_full = array();
877+
878+
if(is_array($record_old)) {
879+
foreach($record_old as $key => $val) {
880+
if(isset($record_new[$key]) && $record_new[$key] != $val) {
881+
// Record has changed
882+
$diffrec_full['old'][$key] = $val;
883+
$diffrec_full['new'][$key] = $record_new[$key];
884+
} else {
885+
$diffrec_full['old'][$key] = $val;
886+
$diffrec_full['new'][$key] = $val;
887+
}
888+
}
889+
}
890+
891+
/*
892+
echo "<pre>";
893+
print_r($diffrec_full);
894+
echo "</pre>";
895+
*/
853896

854897
// Insert the server_id, if the record has a server_id
855898
$server_id = ($record_old["server_id"] > 0)?$record_old["server_id"]:0;
856899
if(isset($record_new["server_id"])) $server_id = $record_new["server_id"];
857-
858-
$this->diffrec = $diffrec;
859900

860-
if(count($diffrec) > 0) {
861-
862-
// We need the full records in ISPConfig, not only the diffs
863-
$diffrec = array( 'old' => $record_old,
864-
'new' => $record_new);
865-
866-
$diffstr = $app->db->quote(serialize($diffrec));
901+
if(count($this->diffrec) > 0) {
902+
$diffstr = $app->db->quote(serialize($diffrec_full));
867903
$username = $app->db->quote($_SESSION["s"]["user"]["username"]);
868904
$dbidx = $this->formDef['db_table_idx'].":".$primary_id;
869905
$action = ($action == 'INSERT')?'i':'u';

interface/web/mail/form/mail_user.tform.php

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,16 +166,42 @@
166166
'rows' => '15'
167167
),
168168
'autoresponder' => array (
169-
'datatype' => 'INTEGER',
169+
'datatype' => 'VARCHAR',
170170
'formtype' => 'CHECKBOX',
171-
'default' => '1',
172-
'value' => '1'
171+
'default' => 'n',
172+
'value' => array(1 => 'y',0 => 'n')
173173
),
174174
##################################
175175
# ENDE Datatable fields
176176
##################################
177177
)
178178
);
179179

180+
if($_SESSION["s"]["user"]["typ"] == 'admin') {
181+
182+
$form["tabs"]['mailfilter'] = array (
183+
'title' => "Mailfilter",
184+
'width' => 100,
185+
'template' => "templates/mail_user_mailfilter_edit.htm",
186+
'fields' => array (
187+
##################################
188+
# Begin Datatable fields
189+
##################################
190+
'custom_mailfilter' => array (
191+
'datatype' => 'TEXT',
192+
'formtype' => 'TEXTAREA',
193+
'default' => '',
194+
'value' => '',
195+
'cols' => '30',
196+
'rows' => '15'
197+
),
198+
##################################
199+
# ENDE Datatable fields
200+
##################################
201+
)
202+
);
203+
204+
}
205+
180206

181207
?>
Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,29 @@
1-
<?php
2-
$wb["email_txt"] = 'Email';
3-
$wb["cryptpwd_txt"] = 'Password';
4-
$wb["active_txt"] = 'Active';
5-
$wb["btn_save_txt"] = 'Save';
6-
$wb["btn_cancel_txt"] = 'Cancel';
7-
$wb["email_error_isemail"] = 'Email address is invalid.';
8-
$wb["email_error_unique"] = 'Duplicate Emailaddress.';
9-
$wb["autoresponder_text_txt"] = 'Text';
10-
$wb["autoresponder_txt"] = 'Autoresponder';
11-
$wb["no_domain_perm"] = 'You have no permission for this domain.';
12-
$wb["error_no_pwd"] = 'Password is empty.';
13-
$wb["quota_error_isint"] = 'Mailbox size must be a number.';
14-
$wb["quota_txt"] = 'quota';
15-
$wb["server_id_txt"] = 'server_id';
16-
$wb["password_txt"] = 'password';
17-
$wb["maildir_txt"] = 'maildir';
18-
$wb["postfix_txt"] = 'Enable Receiving';
19-
$wb["access_txt"] = 'Enable Access';
20-
$wb["policy_txt"] = 'Spamfilter';
21-
$wb["no_policy"] = '- not enabled -';
22-
$wb["limit_mailbox_txt"] = 'The max. number of mailboxes for your account is reached.';
23-
$wb["limit_mailquota_txt"] = 'The max space for mailboxes is reached. The max. available space in MB is';
24-
$wb["welcome_mail_subject"] = "Welcome to your new email account.";
25-
$wb["welcome_mail_message"] = "Welcome to your new email account.\r\n \r\n Your webmaster.";
1+
<?php
2+
$wb["custom_mailfilter_txt"] = 'custom_mailfilter';
3+
$wb["btn_save_txt"] = 'Save';
4+
$wb["btn_cancel_txt"] = 'Cancel';
5+
$wb["email_txt"] = 'Email';
6+
$wb["cryptpwd_txt"] = 'Password';
7+
$wb["active_txt"] = 'Active';
8+
$wb["email_error_isemail"] = 'Email address is invalid.';
9+
$wb["email_error_unique"] = 'Duplicate Emailaddress.';
10+
$wb["autoresponder_text_txt"] = 'Text';
11+
$wb["autoresponder_txt"] = 'Autoresponder';
12+
$wb["no_domain_perm"] = 'You have no permission for this domain.';
13+
$wb["error_no_pwd"] = 'Password is empty.';
14+
$wb["quota_error_isint"] = 'Mailbox size must be a number.';
15+
$wb["quota_txt"] = 'quota';
16+
$wb["server_id_txt"] = 'server_id';
17+
$wb["password_txt"] = 'password';
18+
$wb["maildir_txt"] = 'maildir';
19+
$wb["postfix_txt"] = 'Enable Receiving';
20+
$wb["access_txt"] = 'Enable Access';
21+
$wb["policy_txt"] = 'Spamfilter';
22+
$wb["no_policy"] = '- not enabled -';
23+
$wb["limit_mailbox_txt"] = 'The max. number of mailboxes for your account is reached.';
24+
$wb["limit_mailquota_txt"] = 'The max space for mailboxes is reached. The max. available space in MB is';
25+
$wb["welcome_mail_subject"] = 'Welcome to your new email account.';
26+
$wb["welcome_mail_message"] = 'Welcome to your new email account.
27+
28+
Your webmaster.';
2629
?>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<table width="500" border="0" cellspacing="0" cellpadding="2">
2+
<tr>
3+
<td class="frmText11">{tmpl_var name='custom_mailfilter_txt'}:</td>
4+
<td class="frmText11"><textarea name='custom_mailfilter' cols='30' rows='15'>{tmpl_var name='custom_mailfilter'}</textarea></td>
5+
</tr> <tr>
6+
<td class="frmText11">&nbsp;</td>
7+
<td class="frmText11">&nbsp;</td>
8+
</tr>
9+
<tr>
10+
<td>&nbsp;</td>
11+
<td><input name="btn_save" type="button" class="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','mail/mail_user_edit.php');"><div class="buttonEnding"></div>&nbsp;
12+
<input name="btn_cancel" type="button" class="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('mail/mail_user_list.php');"><div class="buttonEnding"></div>
13+
</td>
14+
</tr>
15+
</table>
16+
<input type="hidden" name="id" value="{tmpl_var name='id'}">

server/conf/autoresponder.master

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
cc $DEFAULT
2+
xfilter "reformail -r -t -I 'From: $LOGNAME'"
3+
/^To:.*/
4+
getaddr{$MATCH}=~ /^.*/;
5+
MATH=tolower${MATCH}
6+
flock "{vmail_mailbox_base}/mailfilters/$HOST/$USER/.vacation.lock" {
7+
`fgrep -iqx "$MATCH" {vmail_mailbox_base}/mailfilters/$HOST/$USER/.vacation.lst 2>/dev/null || { \
8+
echo "$MATCH" >> {vmail_mailbox_base}/mailfilters/$HOST/$USER/.vacation.lst ; \
9+
exit 1 ; \
10+
} `
11+
}
12+
if ( $RETURNCODE == 0 )
13+
exit
14+
to "| (cat - ; echo ''; cat {vmail_mailbox_base}/mailfilters/$HOST/$USER/.vacation.msg) | $SENDMAIL -t"

server/lib/classes/modules.inc.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,14 @@ function processDatalog() {
8181
global $app,$conf;
8282

8383
// TODO: process only new entries.
84-
$sql = "SELECT * FROM sys_datalog WHERE server_id = ".$conf["server_id"];
84+
$sql = "SELECT * FROM sys_datalog WHERE server_id = ".$conf["server_id"]." ORDER BY datalog_id";
8585
$records = $app->db->queryAllRecords($sql);
8686
foreach($records as $rec) {
8787
$data = unserialize(stripslashes($rec["data"]));
8888
$this->raiseTableHook($rec["dbtable"],$rec["action"],$data);
89+
$app->db->query("DELETE FROM sys_datalog WHERE datalog_id = ".$rec["datalog_id"]);
90+
$app->log("Deleting sys_datalog ID ".$rec["datalog_id"],LOGLEVEL_DEBUG);
8991
}
90-
$app->db->query("DELETE FROM sys_datalog WHERE datalog_id = ".$rec["datalog_id"]);
91-
$app->log("Deleting sys_datalog ID ".$rec["datalog_id"],LOGLEVEL_DEBUG);
9292
}
9393

9494
function raiseTableHook($table_name,$action,$data) {

0 commit comments

Comments
 (0)