From 575a42f58c4ce54c8774b875187fd63f4173f673 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ermal=20Lu=E7i?= Date: Tue, 9 Mar 2010 12:45:27 +0000 Subject: Add some more error checking to not have issues as reported on http://forum.pfsense.org/index.php/topic,23435.0.html --- etc/inc/growl.class | 22 ++++++++++++++-------- etc/inc/notices.inc | 2 +- 2 files changed, 15 insertions(+), 9 deletions(-) (limited to 'etc') diff --git a/etc/inc/growl.class b/etc/inc/growl.class index aa35533..883ec8b 100644 --- a/etc/inc/growl.class +++ b/etc/inc/growl.class @@ -77,20 +77,26 @@ { if(function_exists('socket_create') && function_exists('socket_sendto')) { - $sck = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); - socket_sendto($sck, $data, strlen($data), 0x100, $this->address, $this->port); - return true; + $sck = @socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); + if ($sck) { + socket_sendto($sck, $data, strlen($data), 0x100, $this->address, $this->port); + return true; + } } elseif(function_exists('fsockopen')) { - $fp = fsockopen('udp://' . $this->address, $this->port); - fwrite($fp, $data); - fclose($fp); - return true; + if ($this->address) { + $fp = @fsockopen('udp://' . $this->address, $this->port); + if ($fp) { + fwrite($fp, $data); + fclose($fp); + return true; + } + } } return false; } } -?> \ No newline at end of file +?> diff --git a/etc/inc/notices.inc b/etc/inc/notices.inc index 278d4f4..d2cf505 100644 --- a/etc/inc/notices.inc +++ b/etc/inc/notices.inc @@ -345,7 +345,7 @@ function notify_via_growl($message) { global $config; $growl_ip = $config['notifications']['growl']['ipaddress']; $growl_password = $config['notifications']['growl']['password']; - if($growl_ip) { + if(!empty($growl_ip)) { $growl = new Growl($growl_ip, $growl_password); $growl->notify("pfSense growl alert", "pfSense", "{$message}"); } -- cgit v1.1