Skip to content
Snippets Groups Projects
Commit daff5cb7 authored by tbrehm's avatar tbrehm
Browse files

diverse updates.

parent 3edf9d79
No related branches found
No related tags found
No related merge requests found
Showing
with 224 additions and 11 deletions
......@@ -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";
......
......@@ -94,6 +94,10 @@ $inst->configure_getmail();
swriteln('Installing ISPConfig');
$inst->install_ispconfig();
// Configure ISPConfig
swriteln('Installing Crontab');
$inst->install_crontab();
/*
Restart services:
......
......@@ -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');
}
}
......
......@@ -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;
......
......@@ -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
......@@ -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
......@@ -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');
......
......@@ -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
}
}
......
......@@ -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();
}
}
......
......@@ -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
}
}
......
......@@ -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();
}
}
......
......@@ -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();
}
}
......
......@@ -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>
......
<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
......@@ -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>
......
<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">
......
<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">
......
[options]
message_log = /var/log/getmail.log
# message_log = /var/log/getmail.log
message_log_syslog = 1
delete = {DELETE}
[retriever]
......
......@@ -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) {
......
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment