File:
1.06.2a/server/extras/events/console.php (
View as Code)
1: 2: /* -------------------------------------------------------------
3: This file is part of FreeNATS
4:
5: FreeNATS is (C) Copyright 2008-2009 PurplePixie Systems
6:
7: FreeNATS is free software: you can redistribute it and/or modify
8: it under the terms of the GNU General Public License as published by
9: the Free Software Foundation, either version 3 of the License, or
10: (at your option) any later version.
11:
12: FreeNATS is distributed in the hope that it will be useful,
13: but WITHOUT ANY WARRANTY; without even the implied warranty of
14: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: GNU General Public License for more details.
16:
17: You should have received a copy of the GNU General Public License
18: along with FreeNATS. If not, see www.gnu.org/licenses
19:
20: For more information see www.purplepixie.org/freenats
21: -------------------------------------------------------------- */
22:
23: /* Description:
24:
25: This is a custom event handler for FreeNATS v1 and relies on the following
26: event types: alert_action
27:
28: It also relies on the following FreeNATS class methods:
29: TFreeNATS::AddEventHandler
30:
31: USAGE INSTRUCTIONS:
32:
33: Place into the server/base/site/events directory being sure to keep a .php
34: extension on the end of the file. Enable the system variable site.include.events
35: (set to 1) to enable inclusion.
36:
37: Create an alert action of type message queue and the name "_console" (without
38: the quotes). Alerts to this action will be echo'd to the /dev/console device.
39:
40: Note this will almost certainly never work for the "test" option owing to
41: security limitations but will work within a test cycle.
42:
43: */
44:
45:
46:
47:
48: global $NATS;
49: if (isset($NATS))
50: {
51:
52: function alert_action_console($data)
53: {
54: if ($data['name']!="_console") return false;
55: $cmd="echo \"FreeNATS: ".$data['data']."\" > /dev/console";
56: @exec($cmd);
57: return true;
58: }
59:
60: $NATS->AddEventHandler("alert_action","alert_action_console");
61:
62:
63:
64:
65:
66: } // end of isset($NATS) block
67: ?>