Skip to content

Commit daff5cb

Browse files
committed
diverse updates.
1 parent 3edf9d7 commit daff5cb

20 files changed

+224
-11
lines changed

install/dist/conf/debian40.conf.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@
3131
$conf["dist_postfix_vmail_groupname"] = "vmail";
3232
$conf["dist_postfix_vmail_mailbox_base"] = "/home/vmail";
3333

34+
// Getmail
35+
$conf["dist_getmail_config_dir"] = "/etc/getmail";
36+
$conf["dist_getmail_program"] = "/usr/bin/getmail";
37+
3438
// Courier
3539
$conf["dist_courier_config_dir"] = "/etc/courier";
3640

install/install.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@
9494
swriteln('Installing ISPConfig');
9595
$inst->install_ispconfig();
9696

97+
// Configure ISPConfig
98+
swriteln('Installing Crontab');
99+
$inst->install_crontab();
100+
97101

98102
/*
99103
Restart services:

install/lib/installer_base.lib.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,39 @@ function install_ispconfig() {
521521

522522
}
523523

524+
function install_crontab() {
525+
global $conf;
526+
527+
// Root Crontab
528+
exec("crontab -u root -l > crontab.txt");
529+
$existing_root_cron_jobs = file('crontab.txt');
530+
531+
$root_cron_jobs = array('* * * * * /usr/bin/php -q /usr/local/ispconfig/server/server.php &> /dev/null');
532+
foreach($root_cron_jobs as $cron_job) {
533+
if(!in_array($cron_job."\n",$existing_root_cron_jobs)) {
534+
$existing_root_cron_jobs[] = $cron_job."\n";
535+
}
536+
}
537+
file_put_contents('crontab.txt',$existing_root_cron_jobs);
538+
exec("crontab -u root crontab.txt &> /dev/null");
539+
unlink('crontab.txt');
540+
541+
// Getmail crontab
542+
exec("crontab -u root -l > crontab.txt");
543+
$existing_cron_jobs = file('crontab.txt');
544+
545+
$cron_jobs = array('*/5 * * * * '.$conf["dist_getmail_program"].' -g '.$conf["dist_getmail_config_dir"].' -r '.$conf["dist_getmail_config_dir"].'/*.conf &> /dev/null');
546+
foreach($cron_jobs as $cron_job) {
547+
if(!in_array($cron_job."\n",$existing_cron_jobs)) {
548+
$existing_cron_jobs[] = $cron_job."\n";
549+
}
550+
}
551+
file_put_contents('crontab.txt',$existing_cron_jobs);
552+
exec("crontab -u root crontab.txt &> /dev/null");
553+
unlink('crontab.txt');
554+
555+
}
556+
524557

525558

526559
}

interface/lib/classes/tform.inc.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -853,6 +853,7 @@ function datalogSave($action,$primary_id,$record_new) {
853853

854854
// Insert the server_id, if the record has a server_id
855855
$server_id = ($record_old["server_id"] > 0)?$record_old["server_id"]:0;
856+
if(isset($record_new["server_id"])) $server_id = $record_new["server_id"];
856857

857858
$this->diffrec = $diffrec;
858859

interface/web/mail/lib/lang/en_mail_domain.lng

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ $wb["domain_error_unique"] = 'Duplicate Domain.';
1010
$wb["domain_error_regex"] = 'Invalid domain name.';
1111
$wb["client_txt"] = 'Client';
1212
$wb["limit_maildomain_txt"] = 'The max. number of email domains for your account is reached.';
13-
13+
$wb["policy_txt"] = 'Spamfilter';
14+
$wb["no_policy"] = '- not enabled -';
1415
?>

interface/web/mail/lib/lang/en_mail_user.lng

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ $wb["password_txt"] = 'password';
1717
$wb["maildir_txt"] = 'maildir';
1818
$wb["postfix_txt"] = 'Enable Receiving';
1919
$wb["access_txt"] = 'Enable Access';
20+
$wb["policy_txt"] = 'Spamfilter';
21+
$wb["no_policy"] = '- not enabled -';
2022
$wb["limit_mailbox_txt"] = 'The max. number of mailboxes for your account is reached.';
2123
$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.";
2226
?>

interface/web/mail/lib/module.conf.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,11 @@
9494

9595
if($_SESSION["s"]["user"]["typ"] == 'admin') {
9696

97-
$items[] = array( 'title' => "Whitelist",
97+
$items[] = array( 'title' => "Postfix Whitelist",
9898
'target' => 'content',
9999
'link' => 'mail/mail_whitelist_list.php');
100100

101-
$items[] = array( 'title' => "Blacklist",
101+
$items[] = array( 'title' => "Postfix Blacklist",
102102
'target' => 'content',
103103
'link' => 'mail/mail_blacklist_list.php');
104104

interface/web/mail/mail_domain_edit.php

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,22 @@ function onShowEnd() {
9292
$app->tpl->setVar("client_group_id",$client_select);
9393
}
9494

95+
// Get the spamfilter policys for the user
96+
$tmp_user = $app->db->queryOneRecord("SELECT policy_id FROM spamfilter_users WHERE email = '@".$this->dataRecord["domain"]."'");
97+
$sql = "SELECT id, policy_name FROM spamfilter_policy WHERE ".$app->tform->getAuthSQL('r');
98+
$policys = $app->db->queryAllRecords($sql);
99+
$policy_select = "<option value='0'>".$app->tform->wordbook["no_policy"]."</option>";
100+
if(is_array($policys)) {
101+
foreach( $policys as $p) {
102+
$selected = ($p["id"] == $tmp_user["policy_id"])?'SELECTED':'';
103+
$policy_select .= "<option value='$p[id]' $selected>$p[policy_name]</option>\r\n";
104+
}
105+
}
106+
$app->tpl->setVar("policy",$policy_select);
107+
unset($policys);
108+
unset($policy_select);
109+
unset($tmp_user);
110+
95111
parent::onShowEnd();
96112
}
97113

@@ -138,6 +154,24 @@ function onAfterInsert() {
138154
$client_group_id = intval($this->dataRecord["client_group_id"]);
139155
$app->db->query("UPDATE mail_domain SET sys_groupid = $client_group_id, sys_perm_group = 'ru' WHERE domain_id = ".$this->id);
140156
}
157+
158+
// Spamfilter policy
159+
$policy_id = intval($this->dataRecord["policy"]);
160+
if($policy_id > 0) {
161+
$tmp_user = $app->db->queryOneRecord("SELECT id FROM spamfilter_users WHERE email = '@".addslashes($this->dataRecord["domain"])."'");
162+
if($tmp_user["id"] > 0) {
163+
// There is already a record that we will update
164+
$sql = "UPDATE spamfilter_users SET policy_id = $ploicy_id WHERE id = ".$tmp_user["id"];
165+
$app->db->query($sql);
166+
} else {
167+
$tmp_domain = $app->db->queryOneRecord("SELECT sys_groupid FROM mail_domain WHERE domain_id = ".$this->id);
168+
// We create a new record
169+
$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`)
170+
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')";
171+
$app->db->query($sql);
172+
unset($tmp_domain);
173+
}
174+
} // endif spamfilter policy
141175
}
142176

143177
function onAfterUpdate() {
@@ -149,6 +183,30 @@ function onAfterUpdate() {
149183
$client_group_id = intval($this->dataRecord["client_group_id"]);
150184
$app->db->query("UPDATE mail_domain SET sys_groupid = $client_group_id, sys_perm_group = 'ru' WHERE domain_id = ".$this->id);
151185
}
186+
187+
// Spamfilter policy
188+
$policy_id = intval($this->dataRecord["policy"]);
189+
$tmp_user = $app->db->queryOneRecord("SELECT id FROM spamfilter_users WHERE email = '@".addslashes($this->dataRecord["domain"])."'");
190+
if($policy_id > 0) {
191+
if($tmp_user["id"] > 0) {
192+
// There is already a record that we will update
193+
$sql = "UPDATE spamfilter_users SET policy_id = $policy_id WHERE id = ".$tmp_user["id"];
194+
$app->db->query($sql);
195+
} else {
196+
$tmp_domain = $app->db->queryOneRecord("SELECT sys_groupid FROM mail_domain WHERE domain_id = ".$this->id);
197+
// We create a new record
198+
$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`)
199+
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')";
200+
$app->db->query($sql);
201+
unset($tmp_domain);
202+
}
203+
}else {
204+
if($tmp_user["id"] > 0) {
205+
// There is already a record but the user shall have no policy, so we delete it
206+
$sql = "DELETE FROM spamfilter_users WHERE id = ".$tmp_user["id"];
207+
$app->db->query($sql);
208+
}
209+
} // endif spamfilter policy
152210
}
153211

154212
}

interface/web/mail/mail_get_edit.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,16 @@
5353

5454
class page_action extends tform_actions {
5555

56+
function onSubmit() {
57+
global $app, $conf;
58+
59+
// Set the server ID according to the selected destination
60+
$tmp = $app->db->queryOneRecord("SELECT server_id FROM mail_user WHERE email = '".addslashes($this->dataRecord["destination"])."'");
61+
$this->dataRecord["server_id"] = $tmp["server_id"];
62+
unset($tmp);
63+
64+
parent::onSubmit();
65+
}
5666

5767
}
5868

interface/web/mail/mail_user_edit.php

Lines changed: 64 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,27 @@ function onShowEnd() {
9494
}
9595
}
9696
$app->tpl->setVar("email_domain",$domain_select);
97+
unset($domains);
98+
unset($domain_select);
99+
100+
// Get the spamfilter policys for the user
101+
$tmp_user = $app->db->queryOneRecord("SELECT policy_id FROM spamfilter_users WHERE email = '".$this->dataRecord["email"]."'");
102+
$sql = "SELECT id, policy_name FROM spamfilter_policy WHERE ".$app->tform->getAuthSQL('r');
103+
$policys = $app->db->queryAllRecords($sql);
104+
$policy_select = "<option value='0'>".$app->tform->wordbook["no_policy"]."</option>";
105+
if(is_array($policys)) {
106+
foreach( $policys as $p) {
107+
$selected = ($p["id"] == $tmp_user["policy_id"])?'SELECTED':'';
108+
$policy_select .= "<option value='$p[id]' $selected>$p[policy_name]</option>\r\n";
109+
}
110+
}
111+
$app->tpl->setVar("policy",$policy_select);
112+
unset($policys);
113+
unset($policy_select);
114+
unset($tmp_user);
97115

98116
// Convert quota from Bytes to MB
99-
$app->tpl->setVar("quota",$this->dataRecord["quota"] / 1024/ 1024);
117+
$app->tpl->setVar("quota",$this->dataRecord["quota"] / 1024 / 1024);
100118

101119
parent::onShowEnd();
102120
}
@@ -176,16 +194,59 @@ function onAfterInsert() {
176194
global $app, $conf;
177195

178196
// Set the domain owner as mailbox owner
179-
$domain = $app->db->queryOneRecord("SELECT sys_groupid FROM mail_domain WHERE domain = '".$app->db->quote($_POST["email_domain"])."' AND ".$app->tform->getAuthSQL('r'));
197+
$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'));
180198
$app->db->query("UPDATE mail_user SET sys_groupid = ".$domain["sys_groupid"]." WHERE mailuser_id = ".$this->id);
199+
200+
// send a welcome email to create the mailbox
201+
mail($this->dataRecord["email"],$app->tform->wordbook["welcome_mail_subject"],$app->tform->wordbook["welcome_mail_message"]);
202+
203+
// Spamfilter policy
204+
$policy_id = intval($this->dataRecord["policy"]);
205+
if($policy_id > 0) {
206+
$tmp_user = $app->db->queryOneRecord("SELECT id FROM spamfilter_users WHERE email = '".addslashes($this->dataRecord["email"])."'");
207+
if($tmp_user["id"] > 0) {
208+
// There is already a record that we will update
209+
$sql = "UPDATE spamfilter_users SET policy_id = $ploicy_id WHERE id = ".$tmp_user["id"];
210+
$app->db->query($sql);
211+
} else {
212+
// We create a new record
213+
$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`)
214+
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')";
215+
$app->db->query($sql);
216+
}
217+
} // endif spamfilter policy
218+
181219
}
182220

183221
function onAfterUpdate() {
184222
global $app, $conf;
185223

186224
// Set the domain owner as mailbox owner
187-
$domain = $app->db->queryOneRecord("SELECT sys_groupid FROM mail_domain WHERE domain = '".$app->db->quote($_POST["email_domain"])."' AND ".$app->tform->getAuthSQL('r'));
225+
$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'));
188226
$app->db->query("UPDATE mail_user SET sys_groupid = ".$domain["sys_groupid"]." WHERE mailuser_id = ".$this->id);
227+
228+
// Spamfilter policy
229+
$policy_id = intval($this->dataRecord["policy"]);
230+
$tmp_user = $app->db->queryOneRecord("SELECT id FROM spamfilter_users WHERE email = '".addslashes($this->dataRecord["email"])."'");
231+
if($policy_id > 0) {
232+
if($tmp_user["id"] > 0) {
233+
// There is already a record that we will update
234+
$sql = "UPDATE spamfilter_users SET policy_id = $policy_id WHERE id = ".$tmp_user["id"];
235+
$app->db->query($sql);
236+
} else {
237+
// We create a new record
238+
$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`)
239+
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')";
240+
$app->db->query($sql);
241+
}
242+
}else {
243+
if($tmp_user["id"] > 0) {
244+
// There is already a record but the user shall have no policy, so we delete it
245+
$sql = "DELETE FROM spamfilter_users WHERE id = ".$tmp_user["id"];
246+
$app->db->query($sql);
247+
}
248+
} // endif spamfilter policy
249+
189250
}
190251

191252
}

0 commit comments

Comments
 (0)