@@ -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
0 commit comments