From daff5cb75bce6d6b0cbed092c3b807bb04fade9b Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Thu, 31 May 2007 15:15:12 +0000
Subject: [PATCH] diverse updates.

---
 install/dist/conf/debian40.conf.php           |  4 ++
 install/install.php                           |  4 ++
 install/lib/installer_base.lib.php            | 33 +++++++++
 interface/lib/classes/tform.inc.php           |  1 +
 .../web/mail/lib/lang/en_mail_domain.lng      |  3 +-
 interface/web/mail/lib/lang/en_mail_user.lng  |  4 ++
 interface/web/mail/lib/module.conf.php        |  4 +-
 interface/web/mail/mail_domain_edit.php       | 58 ++++++++++++++++
 interface/web/mail/mail_get_edit.php          | 10 +++
 interface/web/mail/mail_user_edit.php         | 67 ++++++++++++++++++-
 .../web/mail/spamfilter_blacklist_edit.php    |  5 ++
 .../web/mail/spamfilter_whitelist_edit.php    |  6 ++
 .../web/mail/templates/mail_domain_edit.htm   |  8 +++
 .../web/mail/templates/mail_get_edit.htm      |  6 +-
 .../mail/templates/mail_user_mailbox_edit.htm |  8 +++
 .../templates/spamfilter_blacklist_edit.htm   |  2 +
 .../templates/spamfilter_whitelist_edit.htm   |  2 +
 server/conf/getmail.conf.master               |  3 +-
 server/lib/classes/modules.inc.php            |  6 +-
 server/plugins-enabled/getmail_plugin.inc.php |  1 +
 20 files changed, 224 insertions(+), 11 deletions(-)

diff --git a/install/dist/conf/debian40.conf.php b/install/dist/conf/debian40.conf.php
index 5957e48876..6a3c410c50 100644
--- a/install/dist/conf/debian40.conf.php
+++ b/install/dist/conf/debian40.conf.php
@@ -31,6 +31,10 @@ $conf["dist_postfix_vmail_groupid"] = "5000";
 $conf["dist_postfix_vmail_groupname"] = "vmail";
 $conf["dist_postfix_vmail_mailbox_base"] = "/home/vmail";
 
+// Getmail
+$conf["dist_getmail_config_dir"] = "/etc/getmail";
+$conf["dist_getmail_program"] = "/usr/bin/getmail";
+
 // Courier
 $conf["dist_courier_config_dir"] = "/etc/courier";
 
diff --git a/install/install.php b/install/install.php
index 1805ef310a..abbe35839f 100644
--- a/install/install.php
+++ b/install/install.php
@@ -94,6 +94,10 @@ $inst->configure_getmail();
 swriteln('Installing ISPConfig');
 $inst->install_ispconfig();
 
+// Configure ISPConfig
+swriteln('Installing Crontab');
+$inst->install_crontab();
+
 
 /*
 Restart services:
diff --git a/install/lib/installer_base.lib.php b/install/lib/installer_base.lib.php
index 8370a06980..b1c5a85874 100644
--- a/install/lib/installer_base.lib.php
+++ b/install/lib/installer_base.lib.php
@@ -521,6 +521,39 @@ postfix check
 		
 	}
 	
+	function install_crontab() {
+		global $conf;
+		
+		// Root Crontab
+		exec("crontab -u root -l > crontab.txt");
+		$existing_root_cron_jobs = file('crontab.txt');
+		
+		$root_cron_jobs = array('* * * * * /usr/bin/php -q /usr/local/ispconfig/server/server.php &> /dev/null');
+		foreach($root_cron_jobs as $cron_job) {
+			if(!in_array($cron_job."\n",$existing_root_cron_jobs)) {
+				$existing_root_cron_jobs[] = $cron_job."\n";
+			}
+		}
+		file_put_contents('crontab.txt',$existing_root_cron_jobs);
+		exec("crontab -u root crontab.txt &> /dev/null");
+		unlink('crontab.txt');
+		
+		// Getmail crontab
+		exec("crontab -u root -l > crontab.txt");
+		$existing_cron_jobs = file('crontab.txt');
+		
+		$cron_jobs = array('*/5 * * * * '.$conf["dist_getmail_program"].' -g '.$conf["dist_getmail_config_dir"].' -r '.$conf["dist_getmail_config_dir"].'/*.conf &> /dev/null');
+		foreach($cron_jobs as $cron_job) {
+			if(!in_array($cron_job."\n",$existing_cron_jobs)) {
+				$existing_cron_jobs[] = $cron_job."\n";
+			}
+		}
+		file_put_contents('crontab.txt',$existing_cron_jobs);
+		exec("crontab -u root crontab.txt &> /dev/null");
+		unlink('crontab.txt');
+		
+	}
+	
 	
 	
 }
diff --git a/interface/lib/classes/tform.inc.php b/interface/lib/classes/tform.inc.php
index a9ae437cea..bdcbaed855 100644
--- a/interface/lib/classes/tform.inc.php
+++ b/interface/lib/classes/tform.inc.php
@@ -853,6 +853,7 @@ class tform {
 				
 				// 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;
 
diff --git a/interface/web/mail/lib/lang/en_mail_domain.lng b/interface/web/mail/lib/lang/en_mail_domain.lng
index 49f823604c..efa7c81ef1 100644
--- a/interface/web/mail/lib/lang/en_mail_domain.lng
+++ b/interface/web/mail/lib/lang/en_mail_domain.lng
@@ -10,5 +10,6 @@ $wb["domain_error_unique"] = 'Duplicate Domain.';
 $wb["domain_error_regex"] = 'Invalid domain name.';
 $wb["client_txt"] = 'Client';
 $wb["limit_maildomain_txt"] = 'The max. number of email domains for your account is reached.';
-
+$wb["policy_txt"] = 'Spamfilter';
+$wb["no_policy"] = '- not enabled -';
 ?>
\ No newline at end of file
diff --git a/interface/web/mail/lib/lang/en_mail_user.lng b/interface/web/mail/lib/lang/en_mail_user.lng
index 3026274db5..6990819123 100644
--- a/interface/web/mail/lib/lang/en_mail_user.lng
+++ b/interface/web/mail/lib/lang/en_mail_user.lng
@@ -17,6 +17,10 @@ $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.";
 ?>
\ No newline at end of file
diff --git a/interface/web/mail/lib/module.conf.php b/interface/web/mail/lib/module.conf.php
index 5cf7455247..34a7afc8f3 100644
--- a/interface/web/mail/lib/module.conf.php
+++ b/interface/web/mail/lib/module.conf.php
@@ -94,11 +94,11 @@ unset($items);
 
 if($_SESSION["s"]["user"]["typ"] == 'admin') {
 
-	$items[] = array( 'title' 	=> "Whitelist",
+	$items[] = array( 'title' 	=> "Postfix Whitelist",
 				  	'target' 	=> 'content',
 				  	'link'	=> 'mail/mail_whitelist_list.php');
 
-	$items[] = array( 'title' 	=> "Blacklist",
+	$items[] = array( 'title' 	=> "Postfix Blacklist",
 				 	 'target' 	=> 'content',
 				  	 'link'	=> 'mail/mail_blacklist_list.php');
 
diff --git a/interface/web/mail/mail_domain_edit.php b/interface/web/mail/mail_domain_edit.php
index 579a052955..13333b1963 100644
--- a/interface/web/mail/mail_domain_edit.php
+++ b/interface/web/mail/mail_domain_edit.php
@@ -92,6 +92,22 @@ class page_action extends tform_actions {
 		$app->tpl->setVar("client_group_id",$client_select);
 		}
 		
+		// Get the spamfilter policys for the user
+		$tmp_user = $app->db->queryOneRecord("SELECT policy_id FROM spamfilter_users WHERE email = '@".$this->dataRecord["domain"]."'");
+		$sql = "SELECT id, policy_name FROM spamfilter_policy WHERE ".$app->tform->getAuthSQL('r');
+		$policys = $app->db->queryAllRecords($sql);
+		$policy_select = "<option value='0'>".$app->tform->wordbook["no_policy"]."</option>";
+		if(is_array($policys)) {
+			foreach( $policys as $p) {
+				$selected = ($p["id"] == $tmp_user["policy_id"])?'SELECTED':'';
+				$policy_select .= "<option value='$p[id]' $selected>$p[policy_name]</option>\r\n";
+			}
+		}
+		$app->tpl->setVar("policy",$policy_select);
+		unset($policys);
+		unset($policy_select);
+		unset($tmp_user);
+		
 		parent::onShowEnd();
 	}
 	
@@ -138,6 +154,24 @@ class page_action extends tform_actions {
 			$client_group_id = intval($this->dataRecord["client_group_id"]);
 			$app->db->query("UPDATE mail_domain SET sys_groupid = $client_group_id, sys_perm_group = 'ru' WHERE domain_id = ".$this->id);
 		}
+		
+		// Spamfilter policy
+		$policy_id = intval($this->dataRecord["policy"]);
+		if($policy_id > 0) {
+			$tmp_user = $app->db->queryOneRecord("SELECT id FROM spamfilter_users WHERE email = '@".addslashes($this->dataRecord["domain"])."'");
+			if($tmp_user["id"] > 0) {
+				// There is already a record that we will update
+				$sql = "UPDATE spamfilter_users SET policy_id = $ploicy_id WHERE id = ".$tmp_user["id"];
+				$app->db->query($sql);
+			} else {
+				$tmp_domain = $app->db->queryOneRecord("SELECT sys_groupid FROM mail_domain WHERE domain_id = ".$this->id);
+				// We create a new record
+				$sql = "INSERT INTO `spamfilter_users` (`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_id`, `priority`, `policy_id`, `email`, `fullname`, `local`) 
+				        VALUES (".$_SESSION["s"]["user"]["userid"].", ".$tmp_domain["sys_groupid"].", 'riud', 'riud', '', ".$this->dataRecord["server_id"].", 5, ".$policy_id.", '@".addslashes($this->dataRecord["domain"])."', '@".addslashes($this->dataRecord["domain"])."', 'Y')";
+				$app->db->query($sql);
+				unset($tmp_domain);
+			}
+		}  // endif spamfilter policy
 	}
 	
 	function onAfterUpdate() {
@@ -149,6 +183,30 @@ class page_action extends tform_actions {
 			$client_group_id = intval($this->dataRecord["client_group_id"]);
 			$app->db->query("UPDATE mail_domain SET sys_groupid = $client_group_id, sys_perm_group = 'ru' WHERE domain_id = ".$this->id);
 		}
+		
+		// Spamfilter policy
+		$policy_id = intval($this->dataRecord["policy"]);
+		$tmp_user = $app->db->queryOneRecord("SELECT id FROM spamfilter_users WHERE email = '@".addslashes($this->dataRecord["domain"])."'");
+		if($policy_id > 0) {
+			if($tmp_user["id"] > 0) {
+				// There is already a record that we will update
+				$sql = "UPDATE spamfilter_users SET policy_id = $policy_id WHERE id = ".$tmp_user["id"];
+				$app->db->query($sql);
+			} else {
+				$tmp_domain = $app->db->queryOneRecord("SELECT sys_groupid FROM mail_domain WHERE domain_id = ".$this->id);
+				// We create a new record
+				$sql = "INSERT INTO `spamfilter_users` (`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_id`, `priority`, `policy_id`, `email`, `fullname`, `local`) 
+				        VALUES (".$_SESSION["s"]["user"]["userid"].", ".$tmp_domain["sys_groupid"].", 'riud', 'riud', '', ".$this->dataRecord["server_id"].", 5, ".$policy_id.", '@".addslashes($this->dataRecord["domain"])."', '@".addslashes($this->dataRecord["domain"])."', 'Y')";
+				$app->db->query($sql);
+				unset($tmp_domain);
+			}
+		}else {
+			if($tmp_user["id"] > 0) {
+				// There is already a record but the user shall have no policy, so we delete it
+				$sql = "DELETE FROM spamfilter_users WHERE id = ".$tmp_user["id"];
+				$app->db->query($sql);
+			}
+		} // endif spamfilter policy
 	}
 	
 }
diff --git a/interface/web/mail/mail_get_edit.php b/interface/web/mail/mail_get_edit.php
index 1d0726665e..1da67355e1 100644
--- a/interface/web/mail/mail_get_edit.php
+++ b/interface/web/mail/mail_get_edit.php
@@ -53,6 +53,16 @@ $app->load('tform_actions');
 
 class page_action extends tform_actions {
 	
+	function onSubmit() {
+		global $app, $conf;
+		
+		// Set the server ID according to the selected destination
+		$tmp = $app->db->queryOneRecord("SELECT server_id FROM mail_user WHERE email = '".addslashes($this->dataRecord["destination"])."'");
+		$this->dataRecord["server_id"] = $tmp["server_id"];
+		unset($tmp);
+		
+		parent::onSubmit();
+	}
 	
 }
 
diff --git a/interface/web/mail/mail_user_edit.php b/interface/web/mail/mail_user_edit.php
index 4659d87581..88986e95bf 100644
--- a/interface/web/mail/mail_user_edit.php
+++ b/interface/web/mail/mail_user_edit.php
@@ -94,9 +94,27 @@ class page_action extends tform_actions {
 			}
 		}
 		$app->tpl->setVar("email_domain",$domain_select);
+		unset($domains);
+		unset($domain_select);
+		
+		// Get the spamfilter policys for the user
+		$tmp_user = $app->db->queryOneRecord("SELECT policy_id FROM spamfilter_users WHERE email = '".$this->dataRecord["email"]."'");
+		$sql = "SELECT id, policy_name FROM spamfilter_policy WHERE ".$app->tform->getAuthSQL('r');
+		$policys = $app->db->queryAllRecords($sql);
+		$policy_select = "<option value='0'>".$app->tform->wordbook["no_policy"]."</option>";
+		if(is_array($policys)) {
+			foreach( $policys as $p) {
+				$selected = ($p["id"] == $tmp_user["policy_id"])?'SELECTED':'';
+				$policy_select .= "<option value='$p[id]' $selected>$p[policy_name]</option>\r\n";
+			}
+		}
+		$app->tpl->setVar("policy",$policy_select);
+		unset($policys);
+		unset($policy_select);
+		unset($tmp_user);
 		
 		// Convert quota from Bytes to MB
-		$app->tpl->setVar("quota",$this->dataRecord["quota"] / 1024/ 1024);
+		$app->tpl->setVar("quota",$this->dataRecord["quota"] / 1024 / 1024);
 		
 		parent::onShowEnd();
 	}
@@ -176,16 +194,59 @@ class page_action extends tform_actions {
 		global $app, $conf;
 		
 		// Set the domain owner as mailbox owner
-		$domain = $app->db->queryOneRecord("SELECT sys_groupid FROM mail_domain WHERE domain = '".$app->db->quote($_POST["email_domain"])."' AND ".$app->tform->getAuthSQL('r'));
+		$domain = $app->db->queryOneRecord("SELECT sys_groupid, server_id FROM mail_domain WHERE domain = '".$app->db->quote($_POST["email_domain"])."' AND ".$app->tform->getAuthSQL('r'));
 		$app->db->query("UPDATE mail_user SET sys_groupid = ".$domain["sys_groupid"]." WHERE mailuser_id = ".$this->id);
+		
+		// send a welcome email to create the mailbox
+		mail($this->dataRecord["email"],$app->tform->wordbook["welcome_mail_subject"],$app->tform->wordbook["welcome_mail_message"]);
+		
+		// Spamfilter policy
+		$policy_id = intval($this->dataRecord["policy"]);
+		if($policy_id > 0) {
+			$tmp_user = $app->db->queryOneRecord("SELECT id FROM spamfilter_users WHERE email = '".addslashes($this->dataRecord["email"])."'");
+			if($tmp_user["id"] > 0) {
+				// There is already a record that we will update
+				$sql = "UPDATE spamfilter_users SET policy_id = $ploicy_id WHERE id = ".$tmp_user["id"];
+				$app->db->query($sql);
+			} else {
+				// We create a new record
+				$sql = "INSERT INTO `spamfilter_users` (`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_id`, `priority`, `policy_id`, `email`, `fullname`, `local`) 
+				        VALUES (".$_SESSION["s"]["user"]["userid"].", ".$domain["sys_groupid"].", 'riud', 'riud', '', ".$domain["server_id"].", 1, ".$policy_id.", '".addslashes($this->dataRecord["email"])."', '".addslashes($this->dataRecord["email"])."', 'Y')";
+				$app->db->query($sql);
+			}
+		}  // endif spamfilter policy
+		
 	}
 	
 	function onAfterUpdate() {
 		global $app, $conf;
 		
 		// Set the domain owner as mailbox owner
-		$domain = $app->db->queryOneRecord("SELECT sys_groupid FROM mail_domain WHERE domain = '".$app->db->quote($_POST["email_domain"])."' AND ".$app->tform->getAuthSQL('r'));
+		$domain = $app->db->queryOneRecord("SELECT sys_groupid, server_id FROM mail_domain WHERE domain = '".$app->db->quote($_POST["email_domain"])."' AND ".$app->tform->getAuthSQL('r'));
 		$app->db->query("UPDATE mail_user SET sys_groupid = ".$domain["sys_groupid"]." WHERE mailuser_id = ".$this->id);
+		
+		// Spamfilter policy
+		$policy_id = intval($this->dataRecord["policy"]);
+		$tmp_user = $app->db->queryOneRecord("SELECT id FROM spamfilter_users WHERE email = '".addslashes($this->dataRecord["email"])."'");
+		if($policy_id > 0) {
+			if($tmp_user["id"] > 0) {
+				// There is already a record that we will update
+				$sql = "UPDATE spamfilter_users SET policy_id = $policy_id WHERE id = ".$tmp_user["id"];
+				$app->db->query($sql);
+			} else {
+				// We create a new record
+				$sql = "INSERT INTO `spamfilter_users` (`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_id`, `priority`, `policy_id`, `email`, `fullname`, `local`) 
+				        VALUES (".$_SESSION["s"]["user"]["userid"].", ".$domain["sys_groupid"].", 'riud', 'riud', '', ".$domain["server_id"].", 1, ".$policy_id.", '".addslashes($this->dataRecord["email"])."', '".addslashes($this->dataRecord["email"])."', 'Y')";
+				$app->db->query($sql);
+			}
+		}else {
+			if($tmp_user["id"] > 0) {
+				// There is already a record but the user shall have no policy, so we delete it
+				$sql = "DELETE FROM spamfilter_users WHERE id = ".$tmp_user["id"];
+				$app->db->query($sql);
+			}
+		} // endif spamfilter policy
+		
 	}
 	
 }
diff --git a/interface/web/mail/spamfilter_blacklist_edit.php b/interface/web/mail/spamfilter_blacklist_edit.php
index 99c098fe53..e4772da21d 100644
--- a/interface/web/mail/spamfilter_blacklist_edit.php
+++ b/interface/web/mail/spamfilter_blacklist_edit.php
@@ -93,6 +93,11 @@ class page_action extends tform_actions {
 			}
 		} // end if user is not admin
 		
+		// Select and set the server_id so it matches the server_id of the spa,filter_users record
+		$tmp = $app->db->queryOneRecord("SELECT server_id FROM spamfilter_users WHERE id = ".intval($this->dataRecord["rid"]));
+		$this->dataRecord["server_id"] = $tmp["server_id"];
+		unset($tmp);
+		
 		parent::onSubmit();
 	}
 }
diff --git a/interface/web/mail/spamfilter_whitelist_edit.php b/interface/web/mail/spamfilter_whitelist_edit.php
index b1f249651f..fb2a5ef692 100644
--- a/interface/web/mail/spamfilter_whitelist_edit.php
+++ b/interface/web/mail/spamfilter_whitelist_edit.php
@@ -93,6 +93,12 @@ class page_action extends tform_actions {
 			}
 		} // end if user is not admin
 		
+		// Select and set the server_id so it matches the server_id of the spa,filter_users record
+		$tmp = $app->db->queryOneRecord("SELECT server_id FROM spamfilter_users WHERE id = ".intval($this->dataRecord["rid"]));
+		$this->dataRecord["server_id"] = $tmp["server_id"];
+		unset($tmp);
+		
+		
 		parent::onSubmit();
 	}
 }
diff --git a/interface/web/mail/templates/mail_domain_edit.htm b/interface/web/mail/templates/mail_domain_edit.htm
index 9a02d87a2c..6889b8a37d 100644
--- a/interface/web/mail/templates/mail_domain_edit.htm
+++ b/interface/web/mail/templates/mail_domain_edit.htm
@@ -21,6 +21,14 @@
     <td class="frmText11">{tmpl_var name='domain_txt'}:</td>
     <td class="frmText11"><input name="domain" type="text" class="text" value="{tmpl_var name='domain'}" size="30" maxlength="255"></td>
   </tr>
+  <tr>
+    <td class="frmText11">{tmpl_var name='policy_txt'}:</td>
+    <td class="frmText11">
+		<select name="policy" class="text">
+			{tmpl_var name='policy'}
+		</select>
+	</td>
+  </tr>
   <tr>
     <td class="frmText11">&nbsp;</td>
     <td class="frmText11">{tmpl_var name='active'} &nbsp; {tmpl_var name='active_txt'}</td>
diff --git a/interface/web/mail/templates/mail_get_edit.htm b/interface/web/mail/templates/mail_get_edit.htm
index 6b92616ab1..e89524445f 100644
--- a/interface/web/mail/templates/mail_get_edit.htm
+++ b/interface/web/mail/templates/mail_get_edit.htm
@@ -1,4 +1,5 @@
 <table width="500" border="0" cellspacing="0" cellpadding="2">
+  <!--
   <tr>
     <td class="frmText11">{tmpl_var name='server_id_txt'}:</td>
     <td class="frmText11">
@@ -7,6 +8,7 @@
 		</select>
 	</td>
   </tr>
+  -->
   <tr>
     <td class="frmText11">{tmpl_var name='type_txt'}:</td>
     <td class="frmText11">
@@ -51,6 +53,6 @@
     <td><input name="btn_save" type="button" class="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','mail/mail_get_edit.php');"><div class="buttonEnding"></div>&nbsp;
       <input name="btn_cancel" type="button" class="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('mail/mail_get_list.php');"><div class="buttonEnding"></div>
     </td>
-  </tr>
-</table>
+  </tr>
+</table>
 <input type="hidden" name="id" value="{tmpl_var name='id'}">
\ No newline at end of file
diff --git a/interface/web/mail/templates/mail_user_mailbox_edit.htm b/interface/web/mail/templates/mail_user_mailbox_edit.htm
index b7eabad92a..7f008992f8 100644
--- a/interface/web/mail/templates/mail_user_mailbox_edit.htm
+++ b/interface/web/mail/templates/mail_user_mailbox_edit.htm
@@ -11,6 +11,14 @@
     <td width="126" class="frmText11">{tmpl_var name='quota_txt'}:</td>
     <td width="366" class="frmText11"><input name="quota" type="text" class="text" value="{tmpl_var name='quota'}" size="5" maxlength="5"> MB</td>
   </tr>
+  <tr>
+    <td class="frmText11">{tmpl_var name='policy_txt'}:</td>
+    <td class="frmText11">
+		<select name="policy" class="text">
+			{tmpl_var name='policy'}
+		</select>
+	</td>
+  </tr>
   <tr>
     <td width="126" class="frmText11">{tmpl_var name='postfix_txt'}:</td>
     <td width="366" class="frmText11">{tmpl_var name='postfix'}</td>
diff --git a/interface/web/mail/templates/spamfilter_blacklist_edit.htm b/interface/web/mail/templates/spamfilter_blacklist_edit.htm
index 9b515c21ca..c658591801 100644
--- a/interface/web/mail/templates/spamfilter_blacklist_edit.htm
+++ b/interface/web/mail/templates/spamfilter_blacklist_edit.htm
@@ -1,4 +1,5 @@
 <table width="500" border="0" cellspacing="0" cellpadding="2">
+  <!--
   <tr>
     <td class="frmText11">{tmpl_var name='server_id_txt'}:</td>
     <td class="frmText11">
@@ -7,6 +8,7 @@
 		</select>
 	</td>
   </tr>
+  -->
   <tr>
     <td class="frmText11">{tmpl_var name='rid_txt'}:</td>
     <td class="frmText11">
diff --git a/interface/web/mail/templates/spamfilter_whitelist_edit.htm b/interface/web/mail/templates/spamfilter_whitelist_edit.htm
index c35e5808eb..d05796a324 100644
--- a/interface/web/mail/templates/spamfilter_whitelist_edit.htm
+++ b/interface/web/mail/templates/spamfilter_whitelist_edit.htm
@@ -1,4 +1,5 @@
 <table width="500" border="0" cellspacing="0" cellpadding="2">
+<!--
   <tr>
     <td class="frmText11">{tmpl_var name='server_id_txt'}:</td>
     <td class="frmText11">
@@ -7,6 +8,7 @@
 		</select>
 	</td>
   </tr>
+  -->
   <tr>
     <td class="frmText11">{tmpl_var name='rid_txt'}:</td>
     <td class="frmText11">
diff --git a/server/conf/getmail.conf.master b/server/conf/getmail.conf.master
index 92bb689ef7..1fb1c182cd 100644
--- a/server/conf/getmail.conf.master
+++ b/server/conf/getmail.conf.master
@@ -1,5 +1,6 @@
 [options]
-message_log = /var/log/getmail.log
+# message_log = /var/log/getmail.log
+message_log_syslog = 1
 delete = {DELETE}
 
 [retriever]
diff --git a/server/lib/classes/modules.inc.php b/server/lib/classes/modules.inc.php
index a8de65bce9..16fc2cc84a 100644
--- a/server/lib/classes/modules.inc.php
+++ b/server/lib/classes/modules.inc.php
@@ -78,15 +78,17 @@ class modules {
 	*/
 	
 	function processDatalog() {
-		global $app;
+		global $app,$conf;
 		
 		// TODO: process only new entries.
-		$sql = "SELECT * FROM sys_datalog WHERE 1";
+		$sql = "SELECT * FROM sys_datalog WHERE server_id = ".$conf["server_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);
 	}
 	
 	function raiseTableHook($table_name,$action,$data) {
diff --git a/server/plugins-enabled/getmail_plugin.inc.php b/server/plugins-enabled/getmail_plugin.inc.php
index 65569d4bf7..b65a087dbe 100644
--- a/server/plugins-enabled/getmail_plugin.inc.php
+++ b/server/plugins-enabled/getmail_plugin.inc.php
@@ -113,6 +113,7 @@ class getmail_plugin {
 				// Write the config file.
 				file_put_contents($config_file_path,$tpl);
 				$app->log("Writing Getmail config file: $config_file_path",LOGLEVEL_DEBUG);
+				exec("chmod 400 $config_file_path");
 				unset($tpl);
 				unset($config_file_path);
 				
-- 
GitLab