Difference between revisions of "Extension:EventPipe"
(remove ugly hack and make $_REQUEST available) |
(add RevisionInsertComplete event for changes notification) |
||
Line 14: | Line 14: | ||
$wgEventPipePort = '2012'; | $wgEventPipePort = '2012'; | ||
− | $wgEventPipeList = array( 'PrefsPasswordAudit','AddNewAccount' ); | + | $wgEventPipeList = array( 'PrefsPasswordAudit','AddNewAccount', 'RevisionInsertComplete' ); |
$wgExtensionCredits['other'][] = array( | $wgExtensionCredits['other'][] = array( | ||
Line 40: | Line 40: | ||
if ( $handle = fsockopen( '127.0.0.1', $wgEventPipePort ) ) { | if ( $handle = fsockopen( '127.0.0.1', $wgEventPipePort ) ) { | ||
$data = var_export( array( $args, $_REQUEST ), true ); | $data = var_export( array( $args, $_REQUEST ), true ); | ||
− | fputs( $handle, "GET $hook?$data HTTP/1.0\n\n" ); | + | fputs( $handle, "GET $hook?$data HTTP/1.0\n\n\x00" ); |
fclose( $handle ); | fclose( $handle ); | ||
} | } | ||
return true; | return true; | ||
} | } |
Revision as of 10:22, 27 May 2009
<?php /**Template:Php
* EventPipe extension - Allows selected events (hooks) to be forwarded to a local pipe * * @package MediaWiki * @subpackage Extensions * @author User:Nad * @copyright © 2009 User:Nad * @licence GNU General Public Licence 2.0 or later */
if ( !defined( 'MEDIAWIKI' ) ) die( 'Not an entry point.' );
define( 'EVENTPIPE_VERSION', '1.0.1, 2009-05-26' );
$wgEventPipePort = '2012'; $wgEventPipeList = array( 'PrefsPasswordAudit','AddNewAccount', 'RevisionInsertComplete' );
$wgExtensionCredits['other'][] = array( 'name' => 'EventPipe', 'author' => 'User:Nad', 'description' => 'Allows selected events (hooks) to be forwarded to a local pipe', 'url' => 'http://www.organicdesign.co.nz/Extension:EventPipe', 'version' => EVENTPIPE_VERSION );
$wgExtensionFunctions[] = 'wfSetupEventPipe'; function wfSetupEventPipe() { global $wgHooks, $wgEventPipeList; foreach ( $wgEventPipeList as $hook ) { $callback = $wgHooks[$hook][] = "wfEventPipeOn$hook"; eval( "function $callback() { \$args=func_get_args();return wfEventPipeSend('$hook',\$args); }" ); } }
/**
* Forward the hooks name, args and the request global to the pipe */
function wfEventPipeSend( $hook, $args ) { global $wgEventPipePort; if ( $handle = fsockopen( '127.0.0.1', $wgEventPipePort ) ) { $data = var_export( array( $args, $_REQUEST ), true ); fputs( $handle, "GET $hook?$data HTTP/1.0\n\n\x00" ); fclose( $handle ); } return true; }