Extension talk:NoAnonymous
Should there be a closing tag to match the <?php at the beginning of the code listed here?
Variation for more recent MediaWiki
editIt seems the path of (at least my install) has changed to /wiki/index.php/Special:UserLogin
Thus, the following slight variation worked for me.
MediaWiki | 1.18.1 |
PHP | 5.3.10 (apache2handler) |
PostgreSQL | 9.0.7 |
<?php /* NoAnonymous - MediaWiki extension * Add extension information to Special:Version */ $wgExtensionCredits['other'][] = array( 'name' => 'NoAnonymous', 'version' => '', 'author' => 'Charles de Beauchesne', 'description' => 'Restrict acces to logged user', 'url' => 'http://www.mediawiki.org/wiki/Extension:NoAnonymous' ); $wgGroupPermissions['*' ]['createaccount'] = false; $wgGroupPermissions['*' ]['read'] = false; $wgGroupPermissions['*' ]['edit'] = false; $wgGroupPermissions['*' ]['createpage'] = false; $wgGroupPermissions['*' ]['createtalk'] = false; $wgExtensionFunctions[] = "wfNoAnonymous"; function wfNoAnonymous() { global $wgHooks; $wgHooks[ 'userCan' ][] = 'noAnonymousFoo'; } function noAnonymousFoo( $title, $user, $action, $result ) { if(!$user->isAnon()) { if($title->isSpecial( 'Userlogin' ) && !in_array("sysop", $user->getGroups())) header("Location:http://".$_SERVER["SERVER_NAME"]."/wiki/index.php/"); } else { global $wgWhitelistRead; if( $title->isSpecial( 'Userlogin' ) || $title->isSpecial( 'Resetpass' ) ) return true; if(is_array($wgWhitelistRead) ) { $name = $title->getPrefixedText(); $dbName = $title->getPrefixedDBKey(); if( in_array($name,$wgWhitelistRead,true) || in_array($dbName,$wgWhitelistRead,true) ) return true; } header("Location:http://".$_SERVER["SERVER_NAME"]."/wiki/index.php/special:Userlogin"); } return true; }