File: 1.11.0a/server/extras/events/file.php (View as HTML)

  1: <?php // file.php version 0.01 17/08/2009
  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 with the name of "_fileoutput"
 38: (without the quotes).
 39: 
 40: Alerts sent to this action will be written to a file (/tmp/fndebug).
 41: 
 42: */
 43: 
 44: 
 45: 
 46: 
 47: global $NATS;
 48: if (isset($NATS))
 49: {
 50: 
 51: 
 52: function alert_action_file($data)
 53: {
 54: 	if ($data['name']=="_fileoutput") $file="/tmp/fndebug";
 55: 	else return false;
 56: 	$fp=fopen($file,"a");
 57: 	fputs($fp,"-- ".date("Y-m-d H:i:s")." --\n");
 58: 	fputs($fp,$data['data']);
 59: 	fputs($fp,"\n-- ENDS --\n");
 60: 	fclose($fp);
 61: 	return true;
 62: }
 63: 
 64: $NATS->AddEventHandler("alert_action","alert_action_file");
 65: 
 66: 
 67: 
 68: 
 69: } // end of isset($NATS) block
 70: ?>