Skip to content

Commit 2d5fcd5

Browse files
author
Marius Cramer
committed
Merge branch 'master' into 'master'
Master See merge request !132
2 parents 7972151 + 712363b commit 2d5fcd5

File tree

5 files changed

+83
-70
lines changed

5 files changed

+83
-70
lines changed

interface/web/mail/mail_domain_dkim_create.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,14 @@ function new_selector ($old_selector, $domain) {
124124
}
125125

126126
//* get dkim-strength for server_id
127-
$mail_server_id = $app->functions->intval( $app->db->queryOneRecord("SELECT server_id from mail_domain WHERE domain = ?", $_POST['domain']) );
128-
$dkim_strength = $app->functions->intval( $app->getconf->get_server_config($mail_server_id, 'mail')['dkim_strength'] );
127+
//$mail_server_id = $app->functions->intval( $app->db->queryOneRecord("SELECT server_id from mail_domain WHERE domain = ?", $_POST['domain']) );
128+
//$dkim_strength = $app->functions->intval( $app->getconf->get_server_config($mail_server_id, 'mail')['dkim_strength'] );
129+
$rec = $app->db->queryOneRecord("SELECT server_id from mail_domain WHERE domain = ?", $_POST['domain']);
130+
$mail_server_id = $app->functions->intval($rec['server_id']);
131+
unset ($rec);
132+
$rec = $app->getconf->get_server_config($mail_server_id, 'mail');
133+
$dkim_strength = $app->functions->intval($rec['dkim_strength']);
134+
unset ($rec);
129135
if ( empty($dkim_strength) ) $dkim_strength = 1024;
130136

131137
switch ($_POST['action']) {

interface/web/tools/resync_do.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ function query_server($table, $server_id, $server_type, $where = "WHERE active =
6767
$server_name[$server['server_id']] = $server['server_name'];
6868
}
6969
} else {
70-
$server_name[$server_id] = $app->db->queryOneRecord("SELECT server_name FROM server WHERE server_id = ".$server_id)['server_name'];
70+
$temp = $app->db->queryOneRecord("SELECT server_name FROM server WHERE server_id = ".$server_id);
71+
$server_name[$server_id] = $temp['server_name'];
72+
unset($temp);
7173
}
7274

7375
if ( isset($tmp_id) ) $server_id = rtrim($tmp_id,',');
@@ -283,7 +285,15 @@ function query_server($table, $server_id, $server_type, $where = "WHERE active =
283285
$msg .= '<b>Resynced DNS zone</b><br>';
284286
if(is_array($zone_records) && !empty($zone_records)) {
285287
foreach($zone_records as $zone_rec) {
286-
if ($server_id == -1) $records = query_server('dns_rr', $server_id, $server_type, 'WHERE 1', false)[0]; else $records = query_server('dns_rr', $server_id, $server_type, "WHERE active = 'Y'")[0];
288+
if ($server_id == -1) {
289+
$temp = query_server('dns_rr', $server_id, $server_type, 'WHERE 1', false);
290+
$records = $temp[0];
291+
unset($temp);
292+
} else {
293+
$temp= query_server('dns_rr', $server_id, $server_type, "WHERE active = 'Y'");
294+
$records = $temp[0];
295+
unset($temp);
296+
}
287297
$rr_count = 0;
288298
if (is_array($records)) {
289299
foreach($records as $rec) {

server/lib/classes/cron.d/300-quota_notify.inc.php

Lines changed: 7 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -50,64 +50,6 @@ public function onBeforeRun() {
5050
public function onRunJob() {
5151
global $app, $conf;
5252

53-
//########
54-
// function for sending notification emails
55-
//########
56-
function send_notification_email($template, $placeholders, $recipients) {
57-
global $conf;
58-
59-
if(!is_array($recipients) || count($recipients) < 1) return false;
60-
if(!is_array($placeholders)) $placeholders = array();
61-
62-
if(file_exists($conf['rootpath'].'/conf-custom/mail/' . $template . '_'.$conf['language'].'.txt')) {
63-
$lines = file($conf['rootpath'].'/conf-custom/mail/' . $template . '_'.$conf['language'].'.txt');
64-
} elseif(file_exists($conf['rootpath'].'/conf-custom/mail/' . $template . '_en.txt')) {
65-
$lines = file($conf['rootpath'].'/conf-custom/mail/' . $template . '_en.txt');
66-
} elseif(file_exists($conf['rootpath'].'/conf/mail/' . $template . '_'.$conf['language'].'.txt')) {
67-
$lines = file($conf['rootpath'].'/conf/mail/' . $template . '_'.$conf['language'].'.txt');
68-
} else {
69-
$lines = file($conf['rootpath'].'/conf/mail/' . $template . '_en.txt');
70-
}
71-
72-
//* get mail headers, subject and body
73-
$mailHeaders = '';
74-
$mailBody = '';
75-
$mailSubject = '';
76-
$inHeader = true;
77-
for($l = 0; $l < count($lines); $l++) {
78-
if($lines[$l] == '') {
79-
$inHeader = false;
80-
continue;
81-
}
82-
if($inHeader == true) {
83-
$parts = explode(':', $lines[$l], 2);
84-
if(strtolower($parts[0]) == 'subject') $mailSubject = trim($parts[1]);
85-
unset($parts);
86-
$mailHeaders .= trim($lines[$l]) . "\n";
87-
} else {
88-
$mailBody .= trim($lines[$l]) . "\n";
89-
}
90-
}
91-
$mailBody = trim($mailBody);
92-
93-
//* Replace placeholders
94-
$mailHeaders = strtr($mailHeaders, $placeholders);
95-
$mailSubject = strtr($mailSubject, $placeholders);
96-
$mailBody = strtr($mailBody, $placeholders);
97-
98-
for($r = 0; $r < count($recipients); $r++) {
99-
mail($recipients[$r], $mailSubject, $mailBody, $mailHeaders);
100-
}
101-
102-
unset($mailSubject);
103-
unset($mailHeaders);
104-
unset($mailBody);
105-
unset($lines);
106-
107-
return true;
108-
}
109-
110-
11153
//######################################################################################################
11254
// enforce traffic quota (run only on the "master-server")
11355
//######################################################################################################
@@ -170,7 +112,7 @@ function send_notification_email($template, $placeholders, $recipients) {
170112
}
171113
}
172114

173-
send_notification_email('web_traffic_notification', $placeholders, $recipients);
115+
$this->_tools->send_notification_email('web_traffic_notification', $placeholders, $recipients);
174116
}
175117

176118
} else {
@@ -290,7 +232,7 @@ function send_notification_email($template, $placeholders, $recipients) {
290232
$recipients[] = $client['email'];
291233
}
292234
}
293-
send_notification_email('web_quota_ok_notification', $placeholders, $recipients);
235+
$this->_tools->send_notification_email('web_quota_ok_notification', $placeholders, $recipients);
294236
}
295237
} else {
296238

@@ -325,7 +267,7 @@ function send_notification_email($template, $placeholders, $recipients) {
325267
$recipients[] = $client['email'];
326268
}
327269
}
328-
send_notification_email('web_quota_notification', $placeholders, $recipients);
270+
$this->_tools->send_notification_email('web_quota_notification', $placeholders, $recipients);
329271
}
330272
}
331273
}
@@ -419,7 +361,7 @@ function send_notification_email($template, $placeholders, $recipients) {
419361
}
420362
}
421363

422-
send_notification_email('mail_quota_ok_notification', $placeholders, $recipients);
364+
$this->_tools->send_notification_email('mail_quota_ok_notification', $placeholders, $recipients);
423365
}
424366
} else {
425367

@@ -454,7 +396,7 @@ function send_notification_email($template, $placeholders, $recipients) {
454396
}
455397
}
456398

457-
send_notification_email('mail_quota_notification', $placeholders, $recipients);
399+
$this->_tools->send_notification_email('mail_quota_notification', $placeholders, $recipients);
458400
}
459401
}
460402
}
@@ -534,7 +476,7 @@ function send_notification_email($template, $placeholders, $recipients) {
534476
if($web_config['overquota_db_notify_client'] == 'y' && $client['email'] != '')
535477
$recipients[] = $client['email'];
536478

537-
send_notification_email('db_quota_ok_notification', $placeholders, $recipients);
479+
$this->_tools->send_notification_email('db_quota_ok_notification', $placeholders, $recipients);
538480

539481
}
540482

@@ -566,7 +508,7 @@ function send_notification_email($template, $placeholders, $recipients) {
566508
if($web_config['overquota_db_notify_client'] == 'y' && $client['email'] != '')
567509
$recipients[] = $client['email'];
568510

569-
send_notification_email('db_quota_notification', $placeholders, $recipients);
511+
$this->_tools->send_notification_email('db_quota_notification', $placeholders, $recipients);
570512

571513
}
572514

server/lib/classes/cron.d/500-backup_mail.inc.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ public function onRunJob() {
8383
foreach($records as $rec) {
8484
//* Do the mailbox backup
8585
if($rec['backup_interval'] == 'daily' or ($rec['backup_interval'] == 'weekly' && date('w') == 0) or ($rec['backup_interval'] == 'monthly' && date('d') == '01')) {
86-
$sql = "SELECT * FROM mail_domain WHERE domain = '".$app->db->quote(explode("@",$rec['email'])[1])."'";
86+
$email = $rec['email'][1];
87+
$sql="SELECT * FROM mail_domain WHERE domain = ?" . $app->db->quote(explode("@",$email))."'";
88+
unset($email);
8789
$domain_rec=$app->db->queryOneRecord($sql);
8890

8991
$mail_backup_dir = $backup_dir.'/mail'.$domain_rec['domain_id'];

server/lib/classes/monitor_tools.inc.php

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,59 @@ public function delOldRecords($type, $serverId) {
675675
$app->dbmaster->query($sql);
676676
}
677677

678+
public function send_notification_email($template, $placeholders, $recipients) {
679+
global $conf;
680+
681+
if(!is_array($recipients) || count($recipients) < 1) return false;
682+
if(!is_array($placeholders)) $placeholders = array();
683+
684+
if(file_exists($conf['rootpath'].'/conf-custom/mail/' . $template . '_'.$conf['language'].'.txt')) {
685+
$lines = file($conf['rootpath'].'/conf-custom/mail/' . $template . '_'.$conf['language'].'.txt');
686+
} elseif(file_exists($conf['rootpath'].'/conf-custom/mail/' . $template . '_en.txt')) {
687+
$lines = file($conf['rootpath'].'/conf-custom/mail/' . $template . '_en.txt');
688+
} elseif(file_exists($conf['rootpath'].'/conf/mail/' . $template . '_'.$conf['language'].'.txt')) {
689+
$lines = file($conf['rootpath'].'/conf/mail/' . $template . '_'.$conf['language'].'.txt');
690+
} else {
691+
$lines = file($conf['rootpath'].'/conf/mail/' . $template . '_en.txt');
692+
}
693+
694+
//* get mail headers, subject and body
695+
$mailHeaders = '';
696+
$mailBody = '';
697+
$mailSubject = '';
698+
$inHeader = true;
699+
for($l = 0; $l < count($lines); $l++) {
700+
if($lines[$l] == '') {
701+
$inHeader = false;
702+
continue;
703+
}
704+
if($inHeader == true) {
705+
$parts = explode(':', $lines[$l], 2);
706+
if(strtolower($parts[0]) == 'subject') $mailSubject = trim($parts[1]);
707+
unset($parts);
708+
$mailHeaders .= trim($lines[$l]) . "\n";
709+
} else {
710+
$mailBody .= trim($lines[$l]) . "\n";
711+
}
712+
}
713+
$mailBody = trim($mailBody);
714+
715+
//* Replace placeholders
716+
$mailHeaders = strtr($mailHeaders, $placeholders);
717+
$mailSubject = strtr($mailSubject, $placeholders);
718+
$mailBody = strtr($mailBody, $placeholders);
719+
720+
for($r = 0; $r < count($recipients); $r++) {
721+
mail($recipients[$r], $mailSubject, $mailBody, $mailHeaders);
722+
}
723+
724+
unset($mailSubject);
725+
unset($mailHeaders);
726+
unset($mailBody);
727+
unset($lines);
728+
729+
return true;
730+
}
678731

679732
}
680733

0 commit comments

Comments
 (0)