Difference between revisions of "Extension:EventPipe"

From Organic Design wiki
m
m (new svn path)
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{voodoo}}<php><?php
+
{{legacy}}
/**
+
{{voodoo}}
* EventPipe extension - Allows selected events (hooks) to be forwarded to a local pipe
+
{{svn|extensions|MediaWiki-Legacy/EventPipe/EventPipe.php}}
*
+
[[Category:Legacy Extensions|EventPipe]]
* @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]]
 

Latest revision as of 12:58, 30 April 2015

Legacy.svg Legacy: This article describes a concept that has been superseded in the course of ongoing development on the Organic Design wiki. Please do not develop this any further or base work on this concept, now this page is for historic record only.


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.