From 2d5fcd53c19a65b9c968a1db2e9af643537379c3 Mon Sep 17 00:00:00 2001
From: Marius Cramer <m.cramer@pixcept.de>
Date: Fri, 24 Oct 2014 09:29:47 -0400
Subject: [PATCH] Merge branch 'master' into 'master'
---
server/lib/classes/monitor_tools.inc.php | 53 +++++++++++++++++
interface/web/tools/resync_do.php | 14 ++++
server/lib/classes/cron.d/300-quota_notify.inc.php | 72 ++---------------------
server/lib/classes/cron.d/500-backup_mail.inc.php | 4 +
interface/web/mail/mail_domain_dkim_create.php | 10 ++
5 files changed, 83 insertions(+), 70 deletions(-)
diff --git a/interface/web/mail/mail_domain_dkim_create.php b/interface/web/mail/mail_domain_dkim_create.php
index fa1e298..4769735 100644
--- a/interface/web/mail/mail_domain_dkim_create.php
+++ b/interface/web/mail/mail_domain_dkim_create.php
@@ -124,8 +124,14 @@
}
//* get dkim-strength for server_id
-$mail_server_id = $app->functions->intval( $app->db->queryOneRecord("SELECT server_id from mail_domain WHERE domain = ?", $_POST['domain']) );
-$dkim_strength = $app->functions->intval( $app->getconf->get_server_config($mail_server_id, 'mail')['dkim_strength'] );
+//$mail_server_id = $app->functions->intval( $app->db->queryOneRecord("SELECT server_id from mail_domain WHERE domain = ?", $_POST['domain']) );
+//$dkim_strength = $app->functions->intval( $app->getconf->get_server_config($mail_server_id, 'mail')['dkim_strength'] );
+$rec = $app->db->queryOneRecord("SELECT server_id from mail_domain WHERE domain = ?", $_POST['domain']);
+$mail_server_id = $app->functions->intval($rec['server_id']);
+unset ($rec);
+$rec = $app->getconf->get_server_config($mail_server_id, 'mail');
+$dkim_strength = $app->functions->intval($rec['dkim_strength']);
+unset ($rec);
if ( empty($dkim_strength) ) $dkim_strength = 1024;
switch ($_POST['action']) {
diff --git a/interface/web/tools/resync_do.php b/interface/web/tools/resync_do.php
index e0c422b..62d02e0 100644
--- a/interface/web/tools/resync_do.php
+++ b/interface/web/tools/resync_do.php
@@ -67,7 +67,9 @@
$server_name[$server['server_id']] = $server['server_name'];
}
} else {
- $server_name[$server_id] = $app->db->queryOneRecord("SELECT server_name FROM server WHERE server_id = ".$server_id)['server_name'];
+ $temp = $app->db->queryOneRecord("SELECT server_name FROM server WHERE server_id = ".$server_id);
+ $server_name[$server_id] = $temp['server_name'];
+ unset($temp);
}
if ( isset($tmp_id) ) $server_id = rtrim($tmp_id,',');
@@ -283,7 +285,15 @@
$msg .= '<b>Resynced DNS zone</b><br>';
if(is_array($zone_records) && !empty($zone_records)) {
foreach($zone_records as $zone_rec) {
- 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];
+ if ($server_id == -1) {
+ $temp = query_server('dns_rr', $server_id, $server_type, 'WHERE 1', false);
+ $records = $temp[0];
+ unset($temp);
+ } else {
+ $temp= query_server('dns_rr', $server_id, $server_type, "WHERE active = 'Y'");
+ $records = $temp[0];
+ unset($temp);
+ }
$rr_count = 0;
if (is_array($records)) {
foreach($records as $rec) {
diff --git a/server/lib/classes/cron.d/300-quota_notify.inc.php b/server/lib/classes/cron.d/300-quota_notify.inc.php
index a60f774..f18394c 100644
--- a/server/lib/classes/cron.d/300-quota_notify.inc.php
+++ b/server/lib/classes/cron.d/300-quota_notify.inc.php
@@ -50,64 +50,6 @@
public function onRunJob() {
global $app, $conf;
- //########
- // function for sending notification emails
- //########
- function send_notification_email($template, $placeholders, $recipients) {
- global $conf;
-
- if(!is_array($recipients) || count($recipients) < 1) return false;
- if(!is_array($placeholders)) $placeholders = array();
-
- if(file_exists($conf['rootpath'].'/conf-custom/mail/' . $template . '_'.$conf['language'].'.txt')) {
- $lines = file($conf['rootpath'].'/conf-custom/mail/' . $template . '_'.$conf['language'].'.txt');
- } elseif(file_exists($conf['rootpath'].'/conf-custom/mail/' . $template . '_en.txt')) {
- $lines = file($conf['rootpath'].'/conf-custom/mail/' . $template . '_en.txt');
- } elseif(file_exists($conf['rootpath'].'/conf/mail/' . $template . '_'.$conf['language'].'.txt')) {
- $lines = file($conf['rootpath'].'/conf/mail/' . $template . '_'.$conf['language'].'.txt');
- } else {
- $lines = file($conf['rootpath'].'/conf/mail/' . $template . '_en.txt');
- }
-
- //* get mail headers, subject and body
- $mailHeaders = '';
- $mailBody = '';
- $mailSubject = '';
- $inHeader = true;
- for($l = 0; $l < count($lines); $l++) {
- if($lines[$l] == '') {
- $inHeader = false;
- continue;
- }
- if($inHeader == true) {
- $parts = explode(':', $lines[$l], 2);
- if(strtolower($parts[0]) == 'subject') $mailSubject = trim($parts[1]);
- unset($parts);
- $mailHeaders .= trim($lines[$l]) . "\n";
- } else {
- $mailBody .= trim($lines[$l]) . "\n";
- }
- }
- $mailBody = trim($mailBody);
-
- //* Replace placeholders
- $mailHeaders = strtr($mailHeaders, $placeholders);
- $mailSubject = strtr($mailSubject, $placeholders);
- $mailBody = strtr($mailBody, $placeholders);
-
- for($r = 0; $r < count($recipients); $r++) {
- mail($recipients[$r], $mailSubject, $mailBody, $mailHeaders);
- }
-
- unset($mailSubject);
- unset($mailHeaders);
- unset($mailBody);
- unset($lines);
-
- return true;
- }
-
-
//######################################################################################################
// enforce traffic quota (run only on the "master-server")
//######################################################################################################
@@ -170,7 +112,7 @@
}
}
- send_notification_email('web_traffic_notification', $placeholders, $recipients);
+ $this->_tools->send_notification_email('web_traffic_notification', $placeholders, $recipients);
}
} else {
@@ -290,7 +232,7 @@
$recipients[] = $client['email'];
}
}
- send_notification_email('web_quota_ok_notification', $placeholders, $recipients);
+ $this->_tools->send_notification_email('web_quota_ok_notification', $placeholders, $recipients);
}
} else {
@@ -325,7 +267,7 @@
$recipients[] = $client['email'];
}
}
- send_notification_email('web_quota_notification', $placeholders, $recipients);
+ $this->_tools->send_notification_email('web_quota_notification', $placeholders, $recipients);
}
}
}
@@ -419,7 +361,7 @@
}
}
- send_notification_email('mail_quota_ok_notification', $placeholders, $recipients);
+ $this->_tools->send_notification_email('mail_quota_ok_notification', $placeholders, $recipients);
}
} else {
@@ -454,7 +396,7 @@
}
}
- send_notification_email('mail_quota_notification', $placeholders, $recipients);
+ $this->_tools->send_notification_email('mail_quota_notification', $placeholders, $recipients);
}
}
}
@@ -534,7 +476,7 @@
if($web_config['overquota_db_notify_client'] == 'y' && $client['email'] != '')
$recipients[] = $client['email'];
- send_notification_email('db_quota_ok_notification', $placeholders, $recipients);
+ $this->_tools->send_notification_email('db_quota_ok_notification', $placeholders, $recipients);
}
@@ -566,7 +508,7 @@
if($web_config['overquota_db_notify_client'] == 'y' && $client['email'] != '')
$recipients[] = $client['email'];
- send_notification_email('db_quota_notification', $placeholders, $recipients);
+ $this->_tools->send_notification_email('db_quota_notification', $placeholders, $recipients);
}
diff --git a/server/lib/classes/cron.d/500-backup_mail.inc.php b/server/lib/classes/cron.d/500-backup_mail.inc.php
index 6c2cb31..8740c55 100644
--- a/server/lib/classes/cron.d/500-backup_mail.inc.php
+++ b/server/lib/classes/cron.d/500-backup_mail.inc.php
@@ -83,7 +83,9 @@
foreach($records as $rec) {
//* Do the mailbox backup
if($rec['backup_interval'] == 'daily' or ($rec['backup_interval'] == 'weekly' && date('w') == 0) or ($rec['backup_interval'] == 'monthly' && date('d') == '01')) {
- $sql = "SELECT * FROM mail_domain WHERE domain = '".$app->db->quote(explode("@",$rec['email'])[1])."'";
+ $email = $rec['email'][1];
+ $sql="SELECT * FROM mail_domain WHERE domain = ?" . $app->db->quote(explode("@",$email))."'";
+ unset($email);
$domain_rec=$app->db->queryOneRecord($sql);
$mail_backup_dir = $backup_dir.'/mail'.$domain_rec['domain_id'];
diff --git a/server/lib/classes/monitor_tools.inc.php b/server/lib/classes/monitor_tools.inc.php
index ce1debb..c1ac461 100644
--- a/server/lib/classes/monitor_tools.inc.php
+++ b/server/lib/classes/monitor_tools.inc.php
@@ -675,6 +675,59 @@
$app->dbmaster->query($sql);
}
+ public function send_notification_email($template, $placeholders, $recipients) {
+ global $conf;
+
+ if(!is_array($recipients) || count($recipients) < 1) return false;
+ if(!is_array($placeholders)) $placeholders = array();
+
+ if(file_exists($conf['rootpath'].'/conf-custom/mail/' . $template . '_'.$conf['language'].'.txt')) {
+ $lines = file($conf['rootpath'].'/conf-custom/mail/' . $template . '_'.$conf['language'].'.txt');
+ } elseif(file_exists($conf['rootpath'].'/conf-custom/mail/' . $template . '_en.txt')) {
+ $lines = file($conf['rootpath'].'/conf-custom/mail/' . $template . '_en.txt');
+ } elseif(file_exists($conf['rootpath'].'/conf/mail/' . $template . '_'.$conf['language'].'.txt')) {
+ $lines = file($conf['rootpath'].'/conf/mail/' . $template . '_'.$conf['language'].'.txt');
+ } else {
+ $lines = file($conf['rootpath'].'/conf/mail/' . $template . '_en.txt');
+ }
+
+ //* get mail headers, subject and body
+ $mailHeaders = '';
+ $mailBody = '';
+ $mailSubject = '';
+ $inHeader = true;
+ for($l = 0; $l < count($lines); $l++) {
+ if($lines[$l] == '') {
+ $inHeader = false;
+ continue;
+ }
+ if($inHeader == true) {
+ $parts = explode(':', $lines[$l], 2);
+ if(strtolower($parts[0]) == 'subject') $mailSubject = trim($parts[1]);
+ unset($parts);
+ $mailHeaders .= trim($lines[$l]) . "\n";
+ } else {
+ $mailBody .= trim($lines[$l]) . "\n";
+ }
+ }
+ $mailBody = trim($mailBody);
+
+ //* Replace placeholders
+ $mailHeaders = strtr($mailHeaders, $placeholders);
+ $mailSubject = strtr($mailSubject, $placeholders);
+ $mailBody = strtr($mailBody, $placeholders);
+
+ for($r = 0; $r < count($recipients); $r++) {
+ mail($recipients[$r], $mailSubject, $mailBody, $mailHeaders);
+ }
+
+ unset($mailSubject);
+ unset($mailHeaders);
+ unset($mailBody);
+ unset($lines);
+
+ return true;
+ }
}
--
Gitblit v1.9.1