Extension:IPexception

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manual - list
Crystal Clear action run.png
IPexception

Release status: beta

Implementation User rights
Description give read right to users with the correct IP address
Author(s) user:Rinkel
Last version 100415
MediaWiki Is tested on 1.14 , 1.15 and 1.16
License No license specified
Download see below
Added rights

GNU

Check usage (experimental)

Contents

[edit] Goal

For a closed cooperated wiki a part of the company needs to have right access. This simple extension checks if the IP address is in the array.

[edit] Installation

Copy the code to file in extensions/IPexception/IPexception.php and include it in LocalSettings.php with

#      this extension give a range of IP adresses read access to the wiki.
#      link:   http://www.mediawiki.org/wiki/Extension:IPexception
       $IPexception = array("127.0.0.1","192.168.10.10"); 
        require_once( "$IP/extensions/IPexception/IPexception.php");

[edit] changelog

[edit] 091023

  • first release

[edit] 100415

  • compatible with mediawiki 1.16
  • Console errors fixed

[edit] Configuration

$IPexception is the range of ip-addresses you want to give the read-rights

[edit] $fileDownloadPermission

This variable I use for a modified img_auth.php to give the users also read rights in the /image/ folder

[edit] CODE - IPexception.php

<?php
/**
 * IPexception extension - Give a IP read exception on a closed Wiki 
 *
 * 
 * For more info see 
 * http://mediawiki.org/wiki/Extension:IPexception
 *
 * @package MediaWiki
 * @subpackage Extensions
 * @author Rienk Jan Schurer, www.rienkjanschurer.nl, rjs@gmx.li
 * @copyright © 2009 Rienk Jan Schurer
 * @license GNU General Public License 2.0 or later
 */
 
if( !defined( 'MEDIAWIKI' ) ) {
        echo( "This file is an extension to the MediaWiki software and cannot be used standalone.\n" );
        // die( 1 );
}
 
$wgExtensionCredits['other'][] = array( 
        'name' => 'IPexception', 
        'author' => 'Rienk Jan Schurer', 
        'version' => '100415',
        'url' => 'http://mediawiki.org/wiki/Extension:IPexception',
        'description' => 'IP exception extension',
);
 
function IPexception($IPexception, $IPexceptiontrue, $IPexceptionPermission){     
 
        # if the ip number is found in the array then return true
 if (in_array($_SERVER['REMOTE_ADDR'], $IPexception)) {
            $IPexceptionPermission = $IPexceptiontrue;
        }
 
        return $IPexceptionPermission;
}
 
if(isset($IPexception)){
 
        # if the IP nummber is in the array then the function will return a true. this means that the user can see all the pages.
 $wgGroupPermissions['*']['read']               =      IPexception($IPexception, "1", "0");        
 
 
        # mediawiki =< 1.15
 # if the IP number is in the array then the variable get a true. In cgi_img_auth.php this means that the user can download files
 # note: You have to edit the img_auth.php file. put on line 30:
 #
 #             if ($fileDownloadPermission == true)
 #                     write_file($filename); 
 #     

        $fileDownloadPermission                                =      IPexception($IPexception, "1", "0");        
 
 
        # mediawiki == 1.16
 # mediawiki img-auth.php 1.16 download
 $wgImgAuthPublicTest                                   =      IPexception($IPexception, "0", "1");        
}
 
?>
Personal tools
Namespaces
Variants
Actions
Site
Support
Download
Development
Communication
Print/export
Toolbox