Extension:RevealEmail
From MediaWiki.org
|
|
WARNING: the code or configuration described here poses a major security risk.
Problem: This function is not suitable for public wikis as it allows anyone to see any wiki user's registered e-mail address. Use at your own risk. |
|
RevealEmail Release status: beta |
|||
|---|---|---|---|
| Implementation | Parser function, User identity | ||
| Description | Simple parser function to reveal User E-mail address | ||
| Author(s) | Joosep-Georg Järvemaa | ||
| Last version | 0.1 | ||
| MediaWiki | Tested on 1.16 | ||
| License | GPL 2+ | ||
| Download | below | ||
| Example | {{#revealEmail:Username}} | ||
|
|||
|
Check usage (experimental) |
|||
Contents |
[edit] What can this extension do?
Will take Username as parameter and return registered E-mail address.
[edit] Usage
{{#revealEmail:Username}}
[edit] Download instructions
Please cut and paste the code found below and place it in $IP/extensions/RevealEmail/RevealEmail.php. Note: $IP stands for the root directory of your MediaWiki installation, the same directory that holds LocalSettings.php.
[edit] Installation
To install this extension, add the following to LocalSettings.php:
require_once("$IP/extensions/RevealEmail/RevealEmail.php");
[edit] See also
[edit] Source code
[edit] RevealEmail.php
<?php $wgExtensionCredits['parserhook'][] = array( 'path' => __FILE__, 'name' => "Parser function to reveal User E-mail", 'description' => "Will take Username as parameter and return registered E-mail address", 'version' => "0.1", 'author' => "Joosep-Georg Järvemaa", 'url' => "http://www.mediawiki.org/wiki/Extension:RevealEmail" ); // Specify the function that will initialize the parser function. $wgHooks['ParserFirstCallInit'][] = 'efRevealEmail_Initialize'; // Specify the function that will register the magic words for the parser function. $wgHooks['LanguageGetMagic'][] = 'efRevealEmail_RegisterMagicWords'; // Tell MediaWiki that the parser function exists. function efRevealEmail_Initialize(&$parser) { // Create a function hook associating the "revealEmail" magic word with the // efRevealEmail_Render() function. $parser->setFunctionHook('revealEmail', 'efRevealEmail_Render'); // Return true so that MediaWiki continues to load extensions. return true; } // Tell MediaWiki which magic words can invoke the parser function. function efRevealEmail_RegisterMagicWords(&$magicWords, $langCode) { // If the first element of the array is 0, the magic word is case insensitive. // If the first element of the array is 1, the magic word is case sensitive. // The remaining elements in the array are "synonyms" for the magic word. $magicWords['revealEmail'] = array(0, 'revealEmail'); // Return true so that MediaWiki continues to load extensions. return true; } // Render the output of the parser function. function efRevealEmail_Render($parser, $username = '') { $user = User::newFromName($username); if (! $user->getId()) { $output = "''revealEmail: user not found''"; } else { $output = $user->getEmail(); } return $output; } // eof
