MediaWiki anonymous users black list pages

From EnneEnneWiki

Variable wgWhitelistRead allow you preventing anonymous users to read just some allowed pages, but you may wish that your MediaWiki shows all pages to the anonymous users but few ones. In this case you need variable wgBlacklistRead.

Here the patch against MediaWiki 1.5.8:

--- ./includes/Title.php.orig   2006-06-12 18:04:36.902437448 +0200
+++ ./includes/Title.php        2006-06-12 18:16:32.427661080 +0200
@@ -999,6 +999,15 @@
                global $wgUser;

                if( $wgUser->isAllowed('read') ) {
+                       global $wgBlacklistRead;
+
+                       /** some pages are explicitly disallowed for
+                           anonymous users */
+                       $name = $this->getPrefixedText();
+                       if( !$wgUser->isLoggedIn() && $wgBlacklistRead && in_arr
ay( $name, $wgBlacklistRead ) ) {
+                               return false;
+                       }
+
                        return true;
                } else {
                        global $wgWhitelistRead;
--- ./includes/DefaultSettings.php.orig 2006-06-12 17:42:23.769104520 +0200
+++ ./includes/DefaultSettings.php      2006-06-12 17:43:22.753137584 +0200
@@ -702,6 +702,7 @@
 # own risks.

 $wgWhitelistRead = false;      # Pages anonymous user may see, like: = array ( 
"Main Page", "Special:Userlogin", "Wikipedia:Help");
+$wgBlacklistRead = false;      # Pages anonymous user may not see (set as above)

 $wgAllowAnonymousMinor = false; # Allow anonymous users to mark changes as 'minor'
Personal tools