Difference between revisions of "Extension:EventPipe"
(1.0.3 - UserLoginComplete) |
(1.0.4 UsrLoginComplete) |
||
Line 1: | Line 1: | ||
− | + | <?php | |
/** | /** | ||
* EventPipe extension - Allows selected events (hooks) to be forwarded to a local pipe | * EventPipe extension - Allows selected events (hooks) to be forwarded to a local pipe | ||
Line 11: | Line 11: | ||
if ( !defined( 'MEDIAWIKI' ) ) die( 'Not an entry point.' ); | if ( !defined( 'MEDIAWIKI' ) ) die( 'Not an entry point.' ); | ||
− | define( 'EVENTPIPE_VERSION', '1.0. | + | define( 'EVENTPIPE_VERSION', '1.0.4, 2009-05-30' ); |
$wgEventPipePort = '1729'; | $wgEventPipePort = '1729'; | ||
Line 37: | Line 37: | ||
*/ | */ | ||
function wfEventPipeSend( $hook, $args ) { | function wfEventPipeSend( $hook, $args ) { | ||
− | global $wgEventPipePort, $wgSerevr, $wgScript; | + | global $wgEventPipePort, $wgSitename, $wgSerevr, $wgScript; |
if ( $handle = fsockopen( '127.0.0.1', $wgEventPipePort ) ) { | if ( $handle = fsockopen( '127.0.0.1', $wgEventPipePort ) ) { | ||
− | $data = var_export( array( 'wgScript' => $wgServer.$wgScript, $args, $_REQUEST ), true ); | + | $data = var_export( array( |
+ | 'wgSitename' => $wgSitename, | ||
+ | 'wgScript' => $wgServer.$wgScript, | ||
+ | $args, | ||
+ | $_REQUEST | ||
+ | ), true ); | ||
fputs( $handle, "GET $hook?$data HTTP/1.0\n\n\x00" ); | fputs( $handle, "GET $hook?$data HTTP/1.0\n\n\x00" ); | ||
fclose( $handle ); | fclose( $handle ); | ||
Line 45: | Line 50: | ||
return true; | return true; | ||
} | } | ||
− | |||
− | |||
− |
Revision as of 12:05, 30 May 2009
<?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.4, 2009-05-30' );
$wgEventPipePort = '1729'; $wgEventPipeList = array( 'RevisionInsertComplete', 'UserLoginComplete', 'PrefsPasswordAudit', 'AddNewAccount' );
$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, $wgSitename, $wgSerevr, $wgScript; if ( $handle = fsockopen( '127.0.0.1', $wgEventPipePort ) ) { $data = var_export( array( 'wgSitename' => $wgSitename, 'wgScript' => $wgServer.$wgScript, $args, $_REQUEST ), true ); fputs( $handle, "GET $hook?$data HTTP/1.0\n\n\x00" ); fclose( $handle ); } return true; }