Difference between revisions of "Extension:EventPipe"
(Extension for allowing wikid.pl to be notified of MW hook execution) |
(use socket to compose an illegally long GET request) |
||
Line 14: | Line 14: | ||
$wgEventPipePort = '2012'; | $wgEventPipePort = '2012'; | ||
− | $wgEventPipeList = array('PrefsPasswordAudit','ArticleSaveComplete'); | + | $wgEventPipeList = array( 'PrefsPasswordAudit','ArticleSaveComplete' ); |
$wgExtensionCredits['other'][] = array( | $wgExtensionCredits['other'][] = array( | ||
Line 35: | Line 35: | ||
function wfEventPipeSend( $hook, $args ) { | function wfEventPipeSend( $hook, $args ) { | ||
global $wgEventPipePort; | global $wgEventPipePort; | ||
− | + | $data = var_export( $args, true ); | |
+ | if ( $handle = fsockopen( '127.0.0.1', $wgEventPipePort ) ) { | ||
+ | fputs( $handle, "GET $hook?$data HTTP/1.0\n\n" ); | ||
+ | fclose( $handle ); | ||
+ | } | ||
return true; | return true; | ||
} | } |
Revision as of 08:57, 25 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.0, 2009-05-25' );
$wgEventPipePort = '2012'; $wgEventPipeList = array( 'PrefsPasswordAudit','ArticleSaveComplete' );
$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); }" ); } }
function wfEventPipeSend( $hook, $args ) { global $wgEventPipePort; $data = var_export( $args, true ); if ( $handle = fsockopen( '127.0.0.1', $wgEventPipePort ) ) { fputs( $handle, "GET $hook?$data HTTP/1.0\n\n" ); fclose( $handle ); } return true; }