Difference between revisions of "Extension:EventPipe"

From Organic Design wiki
m
(move to svn)
Line 1: Line 1:
{{voodoo}}<php><?php
+
{{voodoo}}
/**
+
{{svn|extensions|EventPipe}}
* EventPipe extension - Allows selected events (hooks) to be forwarded to a local pipe
 
*
 
* @package MediaWiki
 
* @subpackage Extensions
 
* @author [http://www.mediawiki.org/wiki/User:Nad User:Nad]
 
* @copyright © 2009 [http://www.mediawiki.org/wiki/User:Nad 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'      => '[http://www.mediawiki.org/wiki/User:Nad 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;
 
}
 
</php>
 
 
[[Category:Extensions|EventPipe]]
 
[[Category:Extensions|EventPipe]]

Revision as of 06:21, 7 June 2009

Voodoo.svg This code exhibits voodoo programming techniques. The most common of these is extending an instance's class at runtime after it has been instantiated, a technique that can be used to provide additional hooks into existing code without requiring modification of code-base files. For a list of all our scripts which exhibit voodoo, see Category:Code that uses voodoo.
Info.svg This code is in our Git repository here.

Note: If there is no information in this page about this code and it's a MediaWiki extension, there may be something at mediawiki.org.