From 0e5f4f4861aef34b911ef394225f7d2ae0cb4dce Mon Sep 17 00:00:00 2001 From: gcoeugnet Date: Tue, 29 Mar 2016 15:34:39 +0200 Subject: [PATCH] Update alerts.php Update to make canopsis transport works. Canopsis transport use AMQP PHP libraries which needs to be installed and included at the begining of the transport but PHP doesn't allow this include to occured in an anonyous function. --- alerts.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/alerts.php b/alerts.php index b3bb308a35..13a83d28c0 100755 --- a/alerts.php +++ b/alerts.php @@ -340,8 +340,13 @@ function ExtTransports($obj) { $msg = FormatAlertTpl($obj); $obj['msg'] = $msg; echo $transport.' => '; - eval('$tmp = function($obj,$opts) { global $config; '.file_get_contents($config['install_dir'].'/includes/alerts/transport.'.$transport.'.php').' return false; };'); - $tmp = $tmp($obj,$opts); + if ($transport == "canopsis") { + $tmp = eval ('global $config; '.file_get_contents($config['install_dir'].'/includes/alerts/transport.'.$transport.'.php').' return false;'); + } + else { + eval('$tmp = function($obj,$opts) { global $config; '.file_get_contents($config['install_dir'].'/includes/alerts/transport.'.$transport.'.php').' return false; };'); + $tmp = $tmp($obj,$opts); + } $prefix = array( 0=>"recovery", 1=>$obj['severity']." alert", 2=>"acknowledgment" ); $prefix[3] = &$prefix[0]; $prefix[4] = &$prefix[0];