Project

General

Profile

« Previous | Next » 

Revision 0e9cb2ab

Added by Phil Davis about 9 years ago

Fix #6187 Handle Growl IP Address problems

(cherry picked from commit 642c6023fea2957bb646b1290371ead508f5cc67)

View differences:

src/etc/inc/notices.inc
71 71
 * NAME
72 72
 *   file_notice
73 73
 * INPUTS
74
 *	 $id, $notice, $category, $url, $priority
74
 *	 $id, $notice, $category, $url, $priority, $local_only
75 75
 * RESULT
76 76
 *   Files a notice and kicks off the various alerts, smtp, growl, system log, LED's, etc.
77
 *   If $local_only is true then the notice is not sent to external places (smtp, growl)
77 78
 ******/
78
function file_notice($id, $notice, $category = "General", $url = "", $priority = 1) {
79
function file_notice($id, $notice, $category = "General", $url = "", $priority = 1, $local_only = false) {
79 80
	/*
80 81
	 * $category - Category that this notice should be displayed under. This can be arbitrary,
81 82
	 * 	       but a page must be set to receive this messages for it to be displayed.
......
114 115
	/* wrap & alix */
115 116
	led_normalize();
116 117
	led_morse(1, 'sos');
117
	notify_via_growl($notice);
118
	notify_via_smtp($notice);
118
	if (!$local_only) {
119
		notify_via_growl($notice);
120
		notify_via_smtp($notice);
121
	}
119 122
	return $queuekey;
120 123
}
121 124

  
......
428 431
	$growl_name = $config['notifications']['growl']['name'];
429 432
	$growl_notification = $config['notifications']['growl']['notification_name'];
430 433

  
431
	if (!empty($growl_ip) && (is_ipaddr($growl_ip) || dns_get_record($growl_ip, DNS_A) || dns_get_record($growl_ip, DNS_AAAA))) {
432
		$growl = new Growl($growl_ip, $growl_password, $growl_name);
433
		$growl->notify("{$growl_notification}", gettext(sprintf("%s (%s) - Notification", $g['product_name'], $hostname)), "{$message}");
434
	if (!empty($growl_ip)) {
435
		if (is_ipaddr($growl_ip) || dns_check_record($growl_ip, A) || dns_check_record($growl_ip, AAAA)) {
436
			$growl = new Growl($growl_ip, $growl_password, $growl_name);
437
			$growl->notify("{$growl_notification}", gettext(sprintf("%s (%s) - Notification", $g['product_name'], $hostname)), "{$message}");
438
		} else {
439
			// file_notice to local only to prevent file_notice from calling back to growl in a loop
440
			file_notice("growl", gettext("Growl IP Address is invalid. Check the setting in System Advanced Notifications."), "General", "", 1, true);
441
		}
434 442
	}
435 443

  
436 444
	/* Store last message sent to avoid spamming */
......
455 463
	$growl_name = $config['notifications']['growl']['name'];
456 464
	$growl_notification = $config['notifications']['growl']['notification_name'];
457 465

  
458
	if ($growl_ip) {
459
		$growl = new Growl($growl_ip, $growl_password, $growl_name);
460
		$growl->addNotification($growl_notification);
461
		$growl->register();
466
	if (!empty($growl_ip)) {
467
		if (is_ipaddr($growl_ip) || dns_check_record($growl_ip, A) || dns_check_record($growl_ip, AAAA)) {
468
			$growl = new Growl($growl_ip, $growl_password, $growl_name);
469
			$growl->addNotification($growl_notification);
470
			$growl->register();
471
		} else {
472
			// file_notice to local only to prevent file_notice from calling back to growl in a loop
473
			file_notice("growl", gettext("Growl IP Address is invalid. Check the setting in System Advanced Notifications."), "General", "", 1, true);
474
		}
462 475
	}
463 476
}
464 477

  

Also available in: Unified diff