diff options
author | Yaco <franco@reevo.org> | 2019-06-07 22:47:48 -0300 |
---|---|---|
committer | Yaco <franco@reevo.org> | 2019-06-07 22:47:48 -0300 |
commit | c9793814bd7490cd54e47463461996431252abf6 (patch) | |
tree | aef9b4c05fd0befb540578e67039650919374204 /www/wiki/extensions | |
parent | 3322c435cb2a586e27d00ef4a542f881485a4a0a (diff) |
cambia funcion para no mostrar ip de usuario no logueado
Diffstat (limited to 'www/wiki/extensions')
-rw-r--r-- | www/wiki/extensions/GetUserName/GetUserName.php | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/www/wiki/extensions/GetUserName/GetUserName.php b/www/wiki/extensions/GetUserName/GetUserName.php index 3f14423c..c50b2a73 100644 --- a/www/wiki/extensions/GetUserName/GetUserName.php +++ b/www/wiki/extensions/GetUserName/GetUserName.php @@ -2,7 +2,7 @@ if ( !defined( 'MEDIAWIKI' ) ) { die( 'This file is a MediaWiki extension and not a valid entry point' ); } - + $wgExtensionCredits['parserhook'][] = array( 'path' => __FILE__, 'name' => 'GetUserName', @@ -10,7 +10,7 @@ $wgExtensionCredits['parserhook'][] = array( 'url' => 'https://www.mediawiki.org/wiki/Extension:GetUserName', 'author' => 'Ejcaputo', 'description' => "Allows the current user's name to be put in a page" -); +); $wgHooks[ 'ParserFirstCallInit' ][] = "ExtGetUserName::setup"; $wgHooks[ 'LanguageGetMagic' ][] = 'ExtGetUserName::languageGetMagic'; @@ -19,24 +19,30 @@ class ExtGetUserName { private static $parserFunctions = array( 'USERNAME' => 'getUserName', ); - + public static function setup( &$parser ) { // register each hook foreach( self::$parserFunctions as $hook => $function ) $parser->setFunctionHook( $hook, array( __CLASS__, $function ), SFH_OBJECT_ARGS ); - + return true; } - + public static function languageGetMagic( &$magicWords, $langCode ) { - $magicWords[ 'USERNAME' ] = array( 0, 'USERNAME' ); + $magicWords[ 'USERNAME' ] = array( 0, 'USERNAME' ); return true; } - + public static function getUserName( &$parser, $frame, $args ) { $parser->disableCache(); - global $wgUser; - return trim( $wgUser->getName() ); + global $wgUser; + $username = $wgUser->getName(); + $isip = ip2long($username) !== false; + if ($isip) { + return; + } else { + return trim( $username ); + } } } |