@@ -447,6 +447,8 @@ function setConfigVar( $filename, $varName, $varValue ) {
447447
448448if ($ app ->dbmaster == $ app ->db ) {
449449
450+ $ global_config = $ app ->getconf ->get_global_config ('mail ' );
451+
450452 $ current_month = date ('Y-m ' );
451453
452454 //* Check website traffic quota
@@ -478,12 +480,63 @@ function setConfigVar( $filename, $varName, $varValue ) {
478480 ($reseller_traffic_quota > 0 && $web_traffic > $reseller_traffic_quota)) {*/
479481 if ($ web_traffic_quota > 0 && $ web_traffic > $ web_traffic_quota ) {
480482 $ app ->dbmaster ->datalogUpdate ('web_domain ' , "traffic_quota_lock = 'y',active = 'n' " , 'domain_id ' , $ rec ['domain_id ' ]);
481- $ app ->log ('Traffic quota for ' .$ rec ['domain_id ' ].' exceeded. Disabling website. ' ,LOGLEVEL_DEBUG );
483+ $ app ->log ('Traffic quota for ' .$ rec ['domain ' ].' exceeded. Disabling website. ' ,LOGLEVEL_DEBUG );
484+
485+ //* Send traffic notifications
486+ if ($ web_config ['overtraffic_notify_admin ' ] == 'y ' || $ web_config ['overtraffic_notify_client ' ] == 'y ' ) {
487+
488+ if (file_exists ($ conf ['rootpath ' ].'/conf-custom/mail/web_traffic_notification_ ' .$ conf ['language ' ].'.txt ' )) {
489+ $ lines = file ($ conf ['rootpath ' ].'/conf-custom/mail/web_traffic_notification_ ' .$ conf ['language ' ].'.txt ' );
490+ } elseif (file_exists ($ conf ['rootpath ' ].'/conf-custom/mail/web_traffic_notification_en.txt ' )) {
491+ $ lines = file ($ conf ['rootpath ' ].'/conf-custom/mail/web_traffic_notification_en.txt ' );
492+ } elseif (file_exists ($ conf ['rootpath ' ].'/conf/mail/web_traffic_notification_ ' .$ conf ['language ' ].'.txt ' )) {
493+ $ lines = file ($ conf ['rootpath ' ].'/conf/mail/web_traffic_notification_ ' .$ conf ['language ' ].'.txt ' );
494+ } else {
495+ $ lines = file ($ conf ['rootpath ' ].'/conf/mail/web_traffic_notification_en.txt ' );
496+ }
497+
498+ //* Get subject
499+ $ parts = explode (': ' ,trim ($ lines [0 ]));
500+ unset($ parts [0 ]);
501+ $ traffic_mail_subject = implode (': ' ,$ parts );
502+ unset($ lines [0 ]);
503+
504+ //* Get message
505+ $ traffic_mail_message = trim (implode ($ lines ));
506+ unset($ tmp );
507+
508+ //* Replace placeholders
509+ $ traffic_mail_message = str_replace ('{domain} ' ,$ rec ['domain ' ],$ traffic_mail_message );
510+
511+ $ mailHeaders = "MIME-Version: 1.0 " . "\n" ;
512+ $ mailHeaders .= "Content-type: text/plain; charset=utf-8 " . "\n" ;
513+ $ mailHeaders .= "Content-Transfer-Encoding: 8bit " . "\n" ;
514+ $ mailHeaders .= "From: " . $ global_config ['admin_mail ' ] . "\n" ;
515+ $ mailHeaders .= "Reply-To: " . $ global_config ['admin_mail ' ] . "\n" ;
516+ $ mailSubject = "=?utf-8?B? " .base64_encode ($ traffic_mail_subject )."?= " ;
517+
518+ //* send email to admin
519+ if ($ global_config ['admin_mail ' ] != '' && $ web_config ['overtraffic_notify_admin ' ] == 'y ' ) {
520+ mail ($ global_config ['admin_mail ' ], $ mailSubject , $ traffic_mail_message , $ mailHeaders );
521+ }
522+
523+ //* Send email to client
524+ if ($ web_config ['overtraffic_notify_admin ' ] == 'y ' ) {
525+ $ client_group_id = $ rec ["sys_groupid " ];
526+ $ client = $ app ->db ->queryOneRecord ("SELECT client.email FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $ client_group_id " );
527+ if ($ client ['email ' ] != '' ) {
528+ mail ($ client ['email ' ], $ mailSubject , $ traffic_mail_message , $ mailHeaders );
529+ }
530+ }
531+
532+ }
533+
534+
482535 } else {
483536 //* unlock the website, if traffic is lower then quota
484537 if ($ rec ['traffic_quota_lock ' ] == 'y ' ) {
485538 $ app ->dbmaster ->datalogUpdate ('web_domain ' , "traffic_quota_lock = 'n',active = 'y' " , 'domain_id ' , $ rec ['domain_id ' ]);
486- $ app ->log ('Traffic quota for ' .$ rec ['domain_id ' ].' ok again. Re-enabling website. ' ,LOGLEVEL_DEBUG );
539+ $ app ->log ('Traffic quota for ' .$ rec ['domain ' ].' ok again. Re-enabling website. ' ,LOGLEVEL_DEBUG );
487540 }
488541 }
489542 }
0 commit comments