From 8651e6a1571fd99c4adedf3a0310e8a4fca957e3 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Thu, 26 Oct 2017 06:45:53 +0400 Subject: The event handler for sending --- classes/events.php | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'classes/events.php') diff --git a/classes/events.php b/classes/events.php index 5dfb0cf..5b93a9c 100644 --- a/classes/events.php +++ b/classes/events.php @@ -59,7 +59,7 @@ class events { if ($callbacks->valid()) { foreach ($callbacks as $callback) { - self::send($data, $callback); + self::handlerCallback($data, $callback); } } @@ -67,19 +67,33 @@ class events { } /** - * Sending data to the node. + * Processes each callback. * * @param array $data * @param object $callback */ - private static function send($data, $callback) { + private static function handlerCallback($data, $callback) { if ($callback->enable) { - $curl = new curl(); - $package = self::packup($data); - $curl::request($callback->url, $package); + $events = unserialize(gzuncompress(base64_decode($callback->events))); + + if (boolval($events[$data["eventname"]])) { + self::send($data, $callback); + } } } + /** + * Sending data to the node. + * + * @param array $data + * @param object $callback + */ + private static function send($data, $callback) { + $curl = new curl(); + $package = self::packup($data); + $curl::request($callback->url, $package); + } + /** * Packs the data for transmission. * -- cgit v1.2.3 From 54d1d030ec3e604cb2dd63819664d05677befe16 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Thu, 26 Oct 2017 06:49:33 +0400 Subject: Correcting the style of the code --- classes/events.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'classes/events.php') diff --git a/classes/events.php b/classes/events.php index 5b93a9c..33e278b 100644 --- a/classes/events.php +++ b/classes/events.php @@ -59,7 +59,7 @@ class events { if ($callbacks->valid()) { foreach ($callbacks as $callback) { - self::handlerCallback($data, $callback); + self::handler_callback($data, $callback); } } @@ -72,7 +72,7 @@ class events { * @param array $data * @param object $callback */ - private static function handlerCallback($data, $callback) { + private static function handler_callback($data, $callback) { if ($callback->enable) { $events = unserialize(gzuncompress(base64_decode($callback->events))); -- cgit v1.2.3