From 6b52c45e95f91622dd7ccfe10cb9da7c5e4b767a Mon Sep 17 00:00:00 2001 From: dongsheng Date: Wed, 2 Jul 2008 04:51:28 +0000 Subject: [PATCH] "MDL-15469, limit email notification" --- lib/setup.php | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/lib/setup.php b/lib/setup.php index 326b2bec2a1..6f806427f12 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -156,9 +156,23 @@ global $HTTPSPAGEREQUIRED; error_log('ADODB Error: '.$db->ErrorMsg()); // see MDL-14628 if (!empty($CFG->emailconnectionerrorsto)) { - mail($CFG->emailconnectionerrorsto, - 'WARNING: Database connection error: '.$CFG->wwwroot, - 'Connection error: '.$CFG->wwwroot); + if (file_exists($CFG->dataroot.'/emailcount')){ + $fp = fopen($CFG->dataroot.'/emailcount', 'r'); + $content = fread($fp, 24); + if((time() - (int)$content) > 600){ + mail($CFG->emailconnectionerrorsto, + 'WARNING: Database connection error: '.$CFG->wwwroot, + 'Connection error: '.$CFG->wwwroot); + $fp = fopen($CFG->dataroot.'/emailcount', 'w'); + fwrite($fp, time()); + } + } else { + mail($CFG->emailconnectionerrorsto, + 'WARNING: Database connection error: '.$CFG->wwwroot, + 'Connection error: '.$CFG->wwwroot); + $fp = fopen($CFG->dataroot.'/emailcount', 'w'); + fwrite($fp, time()); + } } die; }