install/install.php | ●●●●● patch | view | raw | blame | history | |
install/lib/installer_base.lib.php | ●●●●● patch | view | raw | blame | history | |
install/tpl/mailfilter.master | ●●●●● patch | view | raw | blame | history | |
interface/lib/classes/tform.inc.php | ●●●●● patch | view | raw | blame | history | |
interface/web/mail/form/mail_user.tform.php | ●●●●● patch | view | raw | blame | history | |
interface/web/mail/lib/lang/en_mail_user.lng | ●●●●● patch | view | raw | blame | history | |
interface/web/mail/templates/mail_user_mailfilter_edit.htm | ●●●●● patch | view | raw | blame | history | |
server/conf/autoresponder.master | ●●●●● patch | view | raw | blame | history | |
server/lib/classes/modules.inc.php | ●●●●● patch | view | raw | blame | history | |
server/plugins-enabled/maildrop_plugin.inc.php | ●●●●● patch | view | raw | blame | history |
install/install.php
@@ -121,7 +121,7 @@ exec("/etc/init.d/courier-imap-ssl restart"); exec("/etc/init.d/courier-pop restart"); exec("/etc/init.d/courier-pop-ssl restart"); exec("/etc/init.d/apache2 restart"); echo "Installation finished.\n"; install/lib/installer_base.lib.php
@@ -318,7 +318,7 @@ // Edit the file /etc/default/saslauthd $configfile = '/etc/default/saslauthd'; if(is_file($configfile)) copy($configfile,$configfile.'~'); if(is_file($configfile.'~')) exec('chmod 400 '.$configfile.'/~'); if(is_file($configfile.'~')) exec('chmod 400 '.$configfile.'~'); $content = rf($configfile); $content = str_replace('START=no','START=yes',$content); $content = str_replace('OPTIONS="-c"','OPTIONS="-m /var/spool/postfix/var/run/saslauthd -r"',$content); @@ -371,7 +371,7 @@ //authdaemonrc $configfile = $conf["dist_courier_config_dir"].'/authdaemonrc'; if(is_file($configfile)) copy($configfile,$configfile.'~'); if(is_file($configfile.'~')) exec('chmod 400 '.$configfile.'/~'); if(is_file($configfile.'~')) exec('chmod 400 '.$configfile.'~'); $content = rf($configfile); $content = str_replace('authmodulelist="authpam"','authmodulelist="authmysql"',$content); wf($configfile,$content); install/tpl/mailfilter.master
@@ -37,6 +37,15 @@ `chmod -R 0700 {dist_postfix_vmail_mailbox_base}/$HOST` } # Check if the user has a autoresponder enabled `test -f {dist_postfix_vmail_mailbox_base}/mailfilters/$HOST/$USER/.autoresponder` if ( $RETURNCODE == 0 ) { include "{dist_postfix_vmail_mailbox_base}/mailfilters/$HOST/$USER/.autoresponder" } # # Check that user has his own maildrop include, # if not available, check if $DEFAULT is set @@ -44,10 +53,10 @@ # it) and deliver or fail temporarily if not available # `test -f {dist_postfix_vmail_mailbox_base}/mailfilters/$LOGNAME` `test -f {dist_postfix_vmail_mailbox_base}/mailfilters/$HOST/$USER/.mailfilter` if ( $RETURNCODE == 0 ) { include "{dist_postfix_vmail_mailbox_base}/mailfilters/$LOGNAME" include "{dist_postfix_vmail_mailbox_base}/mailfilters/$HOST/$USER/.mailfilter" } else { interface/lib/classes/tform.inc.php
@@ -673,15 +673,23 @@ if($field['formtype'] == 'PASSWORD') { $sql_insert_key .= "`$key`, "; if($field['encryption'] == 'CRYPT') { // $sql_insert_val .= "encrypt('".$record[$key]."'), "; $sql_insert_val .= "'".crypt($record[$key],substr(md5(time()),0,2))."', "; $salt="$1$"; for ($n=0;$n<8;$n++) { $salt.=chr(mt_rand(64,126)); } $salt.="$"; // $salt = substr(md5(time()),0,2); $record[$key] = crypt($record[$key],$salt); } else { $sql_insert_val .= "md5('".$record[$key]."'), "; $record[$key] = md5($record[$key]); } $sql_insert_val .= "'".$record[$key]."', "; } elseif ($field['formtype'] == 'CHECKBOX') { $sql_insert_key .= "`$key`, "; if($record[$key] == '') { // if a checkbox is not set, we set it to the unchecked value $sql_insert_val .= "'".$field['value'][0]."', "; $record[$key] = $field['value'][0]; } else { $sql_insert_val .= "'".$record[$key]."', "; } @@ -691,15 +699,23 @@ } } else { if($field['formtype'] == 'PASSWORD') { if($field['encryption'] == 'CRYPT') { // $sql_update .= "`$key` = encrypt('".$record[$key]."'), "; $sql_update .= "`$key` = '".crypt($record[$key],substr(md5(time()),0,2))."', "; if($field['encryption'] == 'CRYPT') { $salt="$1$"; for ($n=0;$n<8;$n++) { $salt.=chr(mt_rand(64,126)); } $salt.="$"; // $salt = substr(md5(time()),0,2); $record[$key] = crypt($record[$key],$salt); } else { $sql_update .= "`$key` = md5('".$record[$key]."'), "; $record[$key] = md5($record[$key]); } $sql_update .= "`$key` = '".$record[$key]."', "; } elseif ($field['formtype'] == 'CHECKBOX') { if($record[$key] == '') { // if a checkbox is not set, we set it to the unchecked value $sql_update .= "`$key` = '".$field['value'][0]."', "; $record[$key] = $field['value'][0]; } else { $sql_update .= "`$key` = '".$record[$key]."', "; } @@ -707,7 +723,11 @@ $sql_update .= "`$key` = '".$record[$key]."', "; } } } } else { // we unset the password filed, if empty to tell the datalog function // that the password has not been changed unset($record[$key]); } } } @@ -840,30 +860,46 @@ } $diffrec = array(); if(is_array($record_new)) { foreach($record_new as $key => $val) { if($record_old[$key] != $val) { // Datensatz hat sich geändert // Record has changed $diffrec[$key] = array('old' => $record_old[$key], 'new' => $val); 'new' => $val); } } } $this->diffrec = $diffrec; // Full diff records for ISPConfig, they have a different format then the simple diffrec $diffrec_full = array(); if(is_array($record_old)) { foreach($record_old as $key => $val) { if(isset($record_new[$key]) && $record_new[$key] != $val) { // Record has changed $diffrec_full['old'][$key] = $val; $diffrec_full['new'][$key] = $record_new[$key]; } else { $diffrec_full['old'][$key] = $val; $diffrec_full['new'][$key] = $val; } } } /* echo "<pre>"; print_r($diffrec_full); echo "</pre>"; */ // Insert the server_id, if the record has a server_id $server_id = ($record_old["server_id"] > 0)?$record_old["server_id"]:0; if(isset($record_new["server_id"])) $server_id = $record_new["server_id"]; $this->diffrec = $diffrec; if(count($diffrec) > 0) { // We need the full records in ISPConfig, not only the diffs $diffrec = array( 'old' => $record_old, 'new' => $record_new); $diffstr = $app->db->quote(serialize($diffrec)); if(count($this->diffrec) > 0) { $diffstr = $app->db->quote(serialize($diffrec_full)); $username = $app->db->quote($_SESSION["s"]["user"]["username"]); $dbidx = $this->formDef['db_table_idx'].":".$primary_id; $action = ($action == 'INSERT')?'i':'u'; interface/web/mail/form/mail_user.tform.php
@@ -166,10 +166,10 @@ 'rows' => '15' ), 'autoresponder' => array ( 'datatype' => 'INTEGER', 'datatype' => 'VARCHAR', 'formtype' => 'CHECKBOX', 'default' => '1', 'value' => '1' 'default' => 'n', 'value' => array(1 => 'y',0 => 'n') ), ################################## # ENDE Datatable fields @@ -177,5 +177,31 @@ ) ); if($_SESSION["s"]["user"]["typ"] == 'admin') { $form["tabs"]['mailfilter'] = array ( 'title' => "Mailfilter", 'width' => 100, 'template' => "templates/mail_user_mailfilter_edit.htm", 'fields' => array ( ################################## # Begin Datatable fields ################################## 'custom_mailfilter' => array ( 'datatype' => 'TEXT', 'formtype' => 'TEXTAREA', 'default' => '', 'value' => '', 'cols' => '30', 'rows' => '15' ), ################################## # ENDE Datatable fields ################################## ) ); } ?> interface/web/mail/lib/lang/en_mail_user.lng
@@ -1,26 +1,29 @@ <?php $wb["email_txt"] = 'Email'; $wb["cryptpwd_txt"] = 'Password'; $wb["active_txt"] = 'Active'; $wb["btn_save_txt"] = 'Save'; $wb["btn_cancel_txt"] = 'Cancel'; $wb["email_error_isemail"] = 'Email address is invalid.'; $wb["email_error_unique"] = 'Duplicate Emailaddress.'; $wb["autoresponder_text_txt"] = 'Text'; $wb["autoresponder_txt"] = 'Autoresponder'; $wb["no_domain_perm"] = 'You have no permission for this domain.'; $wb["error_no_pwd"] = 'Password is empty.'; $wb["quota_error_isint"] = 'Mailbox size must be a number.'; $wb["quota_txt"] = 'quota'; $wb["server_id_txt"] = 'server_id'; $wb["password_txt"] = 'password'; $wb["maildir_txt"] = 'maildir'; $wb["postfix_txt"] = 'Enable Receiving'; $wb["access_txt"] = 'Enable Access'; $wb["policy_txt"] = 'Spamfilter'; $wb["no_policy"] = '- not enabled -'; $wb["limit_mailbox_txt"] = 'The max. number of mailboxes for your account is reached.'; $wb["limit_mailquota_txt"] = 'The max space for mailboxes is reached. The max. available space in MB is'; $wb["welcome_mail_subject"] = "Welcome to your new email account."; $wb["welcome_mail_message"] = "Welcome to your new email account.\r\n \r\n Your webmaster."; <?php $wb["custom_mailfilter_txt"] = 'custom_mailfilter'; $wb["btn_save_txt"] = 'Save'; $wb["btn_cancel_txt"] = 'Cancel'; $wb["email_txt"] = 'Email'; $wb["cryptpwd_txt"] = 'Password'; $wb["active_txt"] = 'Active'; $wb["email_error_isemail"] = 'Email address is invalid.'; $wb["email_error_unique"] = 'Duplicate Emailaddress.'; $wb["autoresponder_text_txt"] = 'Text'; $wb["autoresponder_txt"] = 'Autoresponder'; $wb["no_domain_perm"] = 'You have no permission for this domain.'; $wb["error_no_pwd"] = 'Password is empty.'; $wb["quota_error_isint"] = 'Mailbox size must be a number.'; $wb["quota_txt"] = 'quota'; $wb["server_id_txt"] = 'server_id'; $wb["password_txt"] = 'password'; $wb["maildir_txt"] = 'maildir'; $wb["postfix_txt"] = 'Enable Receiving'; $wb["access_txt"] = 'Enable Access'; $wb["policy_txt"] = 'Spamfilter'; $wb["no_policy"] = '- not enabled -'; $wb["limit_mailbox_txt"] = 'The max. number of mailboxes for your account is reached.'; $wb["limit_mailquota_txt"] = 'The max space for mailboxes is reached. The max. available space in MB is'; $wb["welcome_mail_subject"] = 'Welcome to your new email account.'; $wb["welcome_mail_message"] = 'Welcome to your new email account. Your webmaster.'; ?> interface/web/mail/templates/mail_user_mailfilter_edit.htm
New file @@ -0,0 +1,16 @@ <table width="500" border="0" cellspacing="0" cellpadding="2"> <tr> <td class="frmText11">{tmpl_var name='custom_mailfilter_txt'}:</td> <td class="frmText11"><textarea name='custom_mailfilter' cols='30' rows='15'>{tmpl_var name='custom_mailfilter'}</textarea></td> </tr> <tr> <td class="frmText11"> </td> <td class="frmText11"> </td> </tr> <tr> <td> </td> <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> <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> </td> </tr> </table> <input type="hidden" name="id" value="{tmpl_var name='id'}"> server/conf/autoresponder.master
New file @@ -0,0 +1,14 @@ cc $DEFAULT xfilter "reformail -r -t -I 'From: $LOGNAME'" /^To:.*/ getaddr{$MATCH}=~ /^.*/; MATH=tolower${MATCH} flock "{vmail_mailbox_base}/mailfilters/$HOST/$USER/.vacation.lock" { `fgrep -iqx "$MATCH" {vmail_mailbox_base}/mailfilters/$HOST/$USER/.vacation.lst 2>/dev/null || { \ echo "$MATCH" >> {vmail_mailbox_base}/mailfilters/$HOST/$USER/.vacation.lst ; \ exit 1 ; \ } ` } if ( $RETURNCODE == 0 ) exit to "| (cat - ; echo ''; cat {vmail_mailbox_base}/mailfilters/$HOST/$USER/.vacation.msg) | $SENDMAIL -t" server/lib/classes/modules.inc.php
@@ -81,14 +81,14 @@ global $app,$conf; // TODO: process only new entries. $sql = "SELECT * FROM sys_datalog WHERE server_id = ".$conf["server_id"]; $sql = "SELECT * FROM sys_datalog WHERE server_id = ".$conf["server_id"]." ORDER BY datalog_id"; $records = $app->db->queryAllRecords($sql); foreach($records as $rec) { $data = unserialize(stripslashes($rec["data"])); $this->raiseTableHook($rec["dbtable"],$rec["action"],$data); $app->db->query("DELETE FROM sys_datalog WHERE datalog_id = ".$rec["datalog_id"]); $app->log("Deleting sys_datalog ID ".$rec["datalog_id"],LOGLEVEL_DEBUG); } $app->db->query("DELETE FROM sys_datalog WHERE datalog_id = ".$rec["datalog_id"]); $app->log("Deleting sys_datalog ID ".$rec["datalog_id"],LOGLEVEL_DEBUG); } function raiseTableHook($table_name,$action,$data) { server/plugins-enabled/maildrop_plugin.inc.php
New file @@ -0,0 +1,186 @@ <?php /* Copyright (c) 2007, Till Brehm, projektfarm Gmbh 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. */ class maildrop_plugin { var $plugin_name = 'maildrop_plugin'; var $class_name = 'maildrop_plugin'; var $mailfilter_config_dir = ''; /* This function is called when the plugin is loaded */ function onLoad() { global $app; /* Register for the events */ $app->plugins->registerEvent('mail_user_update','maildrop_plugin','update'); $app->plugins->registerEvent('mail_user_delete','maildrop_plugin','delete'); } function update($event_name,$data) { global $app, $conf; // load the server configuration options $app->uses("getconf"); $mail_config = $app->getconf->get_server_config($conf["server_id"], 'mail'); if(substr($mail_config["homedir_path"],-1) == '/') { $mail_config["homedir_path"] = substr($mail_config["homedir_path"],0,-1); } $this->mailfilter_config_dir = $mail_config["homedir_path"].'/mailfilters'; // Check if the config directory exists. if(!is_dir($this->mailfilter_config_dir)) { $app->log("Mailfilter config directory '".$this->mailfilter_config_dir."' does not exist.",LOGLEVEL_ERROR); } else { // Check if something has been changed regarding the autoresponders if($data["old"]["autoresponder_text"] != $data["new"]["autoresponder_text"] or $data["old"]["autoresponder"] != $data["new"]["autoresponder"] or (isset($data["new"]["email"]) and $data["old"]["email"] != $data["new"]["email"])) { // We delete the old autoresponder, if it exists $email_parts = explode("@",$data["old"]["email"]); $file = $this->mailfilter_config_dir.'/'.$email_parts[1].'/'.$email_parts[0].'/.vacation.lock'; if(is_file($file)) unlink($file) or $app->log("Unable to delete file: $file",LOGLEVEL_WARN); $file = $this->mailfilter_config_dir.'/'.$email_parts[1].'/'.$email_parts[0].'/.vacation.lst'; if(is_file($file)) unlink($file) or $app->log("Unable to delete file: $file",LOGLEVEL_WARN); $file = $this->mailfilter_config_dir.'/'.$email_parts[1].'/'.$email_parts[0].'/.vacation.msg'; if(is_file($file)) unlink($file) or $app->log("Unable to delete file: $file",LOGLEVEL_WARN); $file = $this->mailfilter_config_dir.'/'.$email_parts[1].'/'.$email_parts[0].'/.autoresponder'; if(is_file($file)) unlink($file) or $app->log("Unable to delete file: $file",LOGLEVEL_WARN); //Now we create the new autoresponder, if it is enabled if($data["new"]["autoresponder"] == 'y') { if(isset($data["new"]["email"])) { $email_parts = explode("@",$data["new"]["email"]); } else { $email_parts = explode("@",$data["old"]["email"]); } // make sure that the config directories exist if(!is_dir($this->mailfilter_config_dir.'/'.$email_parts[1])) { mkdir($this->mailfilter_config_dir.'/'.$email_parts[1]); exec("chown vmail ".$this->mailfilter_config_dir.'/'.$email_parts[1]); exec("chmod 400 ".$this->mailfilter_config_dir.'/'.$email_parts[1]); } if(!is_dir($this->mailfilter_config_dir.'/'.$email_parts[1].'/'.$email_parts[0])) { mkdir($this->mailfilter_config_dir.'/'.$email_parts[1].'/'.$email_parts[0]); exec("chown vmail ".$this->mailfilter_config_dir.'/'.$email_parts[1].'/'.$email_parts[0]); exec("chmod 400 ".$this->mailfilter_config_dir.'/'.$email_parts[1].'/'.$email_parts[0]); } // Load the master template $tpl = file_get_contents($conf["rootpath"].'/conf/autoresponder.master'); $tpl = str_replace('{vmail_mailbox_base}',$mail_config["homedir_path"],$tpl); // Write the config file. $config_file_path = $this->mailfilter_config_dir.'/'.$email_parts[1].'/'.$email_parts[0].'/.autoresponder'; file_put_contents($config_file_path,$tpl); $app->log("Writing Autoresponder mailfilter file: $config_file_path",LOGLEVEL_DEBUG); exec("chmod 400 $config_file_path"); exec("chown vmail $config_file_path"); unset($tpl); unset($config_file_path); // Write the autoresponder message file $config_file_path = $this->mailfilter_config_dir.'/'.$email_parts[1].'/'.$email_parts[0].'/.vacation.msg'; file_put_contents($config_file_path,$data["new"]["autoresponder_text"]); exec("chmod 400 $config_file_path"); exec("chown vmail $config_file_path"); $app->log("Writing Autoresponder message file: $config_file_path",LOGLEVEL_DEBUG); } } // Write the custom mailfilter script, if mailfilter recipe has changed if($data["old"]["custom_mailfilter"] != $data["new"]["custom_mailfilter"]) { if(trim($data["new"]["custom_mailfilter"]) != '') { // Delete the old filter recipe $email_parts = explode("@",$data["old"]["email"]); $file = $this->mailfilter_config_dir.'/'.$email_parts[1].'/'.$email_parts[0].'/.mailfilter'; if(is_file($file)) unlink($file) or $app->log("Unable to delete file: $file",LOGLEVEL_WARN); // write the new recipe if(isset($data["new"]["email"])) { $email_parts = explode("@",$data["new"]["email"]); } else { $email_parts = explode("@",$data["old"]["email"]); } $config_file_path = $this->mailfilter_config_dir.'/'.$email_parts[1].'/'.$email_parts[0].'/.mailfilter'; file_put_contents($config_file_path,$data["new"]["custom_mailfilter"]); exec("chmod 400 $config_file_path"); exec("chown vmail $config_file_path"); unset($config_file_path); } else { // Delete the mailfilter recipe $email_parts = explode("@",$data["old"]["email"]); $file = $this->mailfilter_config_dir.'/'.$email_parts[1].'/'.$email_parts[0].'/.mailfilter'; if(is_file($file)) unlink($file) or $app->log("Unable to delete file: $file",LOGLEVEL_WARN); } } } } function delete($event_name,$data) { global $app, $conf; // load the server configuration options $app->uses("getconf"); $mail_config = $app->getconf->get_server_config($conf["server_id"], 'mail'); $this->mailfilter_config_dir = $mail_config["homedir_path"].'/mailfilters'; $email_parts = explode("@",$data["old"]["email"]); $dir = $this->mailfilter_config_dir.'/'.$email_parts[1].'/'.$email_parts[0]; if(is_dir($dir)) { $file = $this->mailfilter_config_dir.'/'.$email_parts[1].'/'.$email_parts[0].'/.vacation.lock'; if(is_file($file)) unlink($file) or $app->log("Unable to delete file: $file",LOGLEVEL_WARN); $file = $this->mailfilter_config_dir.'/'.$email_parts[1].'/'.$email_parts[0].'/.vacation.lst'; if(is_file($file)) unlink($file) or $app->log("Unable to delete file: $file",LOGLEVEL_WARN); $file = $this->mailfilter_config_dir.'/'.$email_parts[1].'/'.$email_parts[0].'/.vacation.msg'; if(is_file($file)) unlink($file) or $app->log("Unable to delete file: $file",LOGLEVEL_WARN); $file = $this->mailfilter_config_dir.'/'.$email_parts[1].'/'.$email_parts[0].'/.autoresponder'; if(is_file($file)) unlink($file) or $app->log("Unable to delete file: $file",LOGLEVEL_WARN); $file = $this->mailfilter_config_dir.'/'.$email_parts[1].'/'.$email_parts[0].'/.mailfilter'; if(is_file($file)) unlink($file) or $app->log("Unable to delete file: $file",LOGLEVEL_WARN); rmdir($dir) or $app->log("Unable to delete directory: $dir",LOGLEVEL_WARN); } } } // end class ?>