diff options
author | Scott Ullrich <sullrich@pfsense.org> | 2011-04-12 18:18:57 -0400 |
---|---|---|
committer | Scott Ullrich <sullrich@pfsense.org> | 2011-04-12 18:18:57 -0400 |
commit | a93020d544335611e6e083db67ef23fb674139ca (patch) | |
tree | cdc84c78c7ce6cb12c24cc70186aeabba0a9290f | |
parent | 2632934e5ae8b8494b68981e67f25fde306ef027 (diff) | |
download | pfsense-a93020d544335611e6e083db67ef23fb674139ca.zip pfsense-a93020d544335611e6e083db67ef23fb674139ca.tar.gz |
Do not send growl notices twice
-rw-r--r-- | etc/inc/notices.inc | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/etc/inc/notices.inc b/etc/inc/notices.inc index 0ba8cc8..9ccd373 100644 --- a/etc/inc/notices.inc +++ b/etc/inc/notices.inc @@ -345,6 +345,14 @@ function notify_via_smtp($message) { function notify_via_growl($message) { require_once("growl.class"); global $config,$g; + + /* Do NOT send the same message twice */ + if(file_exists("/var/db/growlnotices_lastmsg.txt")) { + $lastmsg = trim(file_get_contents("/var/db/growlnotices_lastmsg.txt")); + if($lastmsg == $message) + return; + } + $hostname = $config['system']['hostname'] . "." . $config['system']['domain']; $growl_ip = $config['notifications']['growl']['ipaddress']; $growl_password = $config['notifications']['growl']['password']; @@ -355,6 +363,11 @@ function notify_via_growl($message) { $growl = new Growl($growl_ip, $growl_password, $growl_name); $growl->notify("{$growl_notification}", gettext(sprintf("%s (%s) - Notification", $g['product_name'], $hostname)), "{$message}"); } + + /* Store last message sent to avoid spamming */ + $fd = fopen("/var/db/growlnotices_lastmsg.txt", "w"); + fwrite($fd, $message); + fclose($fd); } /****f* notices/register_via_growl |