r55837 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r55836‎ | r55837 | r55838 >
Date:21:57, 4 September 2009
Author:jdpond
Status:deferred
Tags:
Comment:
Updated README, added check to make sure extension Lockdown was already loaded.
Modified paths:
  • /trunk/extensions/NSFileRepo/NSFileRepo.php (modified) (history)
  • /trunk/extensions/NSFileRepo/README (modified) (history)
  • /trunk/extensions/NSFileRepo/REL1_13_0/phase3/img_auth.i18n.php (deleted) (history)

Diff [purge]

Index: trunk/extensions/NSFileRepo/REL1_13_0/phase3/img_auth.i18n.php
@@ -1,32 +0,0 @@
2 -<?php
3 -/**
4 - * Internationalisation file for img_auth script (see see http://www.mediawiki.org/wiki/Manual:Image_Authorization).
5 -*/
6 -
7 -$messages = array();
8 -
9 -/** English
10 - * @author Jack D. Pond
11 - */
12 -$messages['en'] = array(
13 - 'image_auth-desc' => 'Image authorisation script',
14 - 'image_auth-nopathinfo' => "Missing PATH_INFO. Your server is not set up to pass this information -
15 -may be CGI-based and can't support img_auth. See `Image Authorization` on MediaWiki.",
16 - 'image_auth-notindir' => "Requested path not in upload directory.",
17 - 'image_auth-badtitle' => "Unable to construct a valid Title from `$1`.",
18 - 'image_auth-nologinnWL' => "Not logged in and `$1` not in whitelist.",
19 - 'image_auth-nofile' => "`$1` does not exist.",
20 - 'image_auth-isdir' => "`$1` is a directory.",
21 - 'image_auth-streaming' => "Streaming `$1`.",
22 - 'image_auth-public' => "The function of img_auth.php is to output files from a private wiki. This wiki
23 -is configured as a public wiki. For optimal security, img_auth.php is disabled for this case.",
24 - 'image_auth-noread' => "User does not have access to read `$1`."
25 -);
26 -
27 -/** Message documentation (Message documentation)
28 - * @author Jack D. Pond
29 - */
30 -$messages['qqq'] = array(
31 - 'image_auth-desc' => 'Image authorisation script'
32 -);
33 -
Index: trunk/extensions/NSFileRepo/NSFileRepo.php
@@ -11,10 +11,11 @@
1212 * @licence GNU General Public Licence 2.0 or later
1313 *
1414 * This extension extends and is dependent on extension Lockdown - see http://www.mediawiki.org/wiki/Extension:Lockdown
15 - * It must be included(required) after Lockdown!
 15+ * It must be included(required) after Lockdown! Also, $wgHashedUploadDirectory must be true and cannot be changed once repository has files in it
1616 */
1717
1818 if (!defined('MEDIAWIKI')) die('Not an entry point.');
 19+if (!function_exists('lockdownUserCan')) die('You MUST load Extension Lockdown before NSFileRepo (http://www.mediawiki.org/wiki/Extension:Lockdown).');
1920
2021 $wgImgAuthPublicTest = false; // Must be set to false if you want to use more restrictive than general ['*']['read']
2122 $wgIllegalFileChars = isset($wgIllegalFileChars) ? $wgIllegalFileChars : ""; // For MW Versions <1.16
@@ -215,7 +216,7 @@
216217
217218 # See if stored in a NS path
218219
219 - $subdirs = explode('/',$_SERVER['PATH_INFO']);
 220+ $subdirs = explode('/',$path);
220221 if (strlen($subdirs[1]) == 3 && is_numeric($subdirs[1]) && $subdirs[1] >= 100) {
221222 $title = Title::makeTitleSafe( NS_FILE, $wgContLang->getNsText($subdirs[1]).":".$name );
222223 if( !$title instanceof Title ) {
Index: trunk/extensions/NSFileRepo/README
@@ -1,8 +1,8 @@
22 {{Page security extension disclaimer}}
3 -{{Extension by patch warning|version=}}
 3+{{Extension by patch warning|version=1.15.1}}
44 {{Extension|templatemode=
55 |name = NSFileRepo
6 -|status = beta
 6+|status = stable
77 |type1 = user rights
88 |type2 =
99 |hook1 = userCan
@@ -11,9 +11,9 @@
1212 |author = <!-- add only if different from user name -->
1313 |description = implements per-namespace group permissions for image and file rights protection
1414 |image =
15 -|version = 0.0
16 -|update = 2009-07-11
17 -|mediawiki = 1.13, 1.14, 1.15
 15+|version = 1.1
 16+|update = 2009-09-4
 17+|mediawiki = 1.13, 1.14, 1.15, 1.16
1818 |license = GNU General Public Licence 2.0
1919 |download = {{WikimediaDownload|NSFileRepo}}
2020 |readme = [http://svn.wikimedia.org/svnroot/mediawiki/trunk/extensions/NSFileRepo/README README]
@@ -25,8 +25,14 @@
2626
2727 ==What can this extension do?==
2828
29 -The '''NSFileRepo''' extension implements a way to restrict access to specific files and images to a given set of user groups. This provides a more fine grained security model and allows access restriction to users in specified groups.
 29+The '''NSFileRepo''' restricts access to upload and read files and images to a given set of user groups associated with protected namespaces. Using this extension (within the security limitations noted above), you can protect not only pages and areas of your wiki, but also any uploaded images or files within those namespaces.
3030
 31+'''Namespaces''' are mechanism for grouping/separating wiki pages.
 32+
 33+* See [[Help:Namespaces]] for more '''user help documentation''' on what they are and how they are used.
 34+* See [[Manual:Namespace]] for '''system administration''' details on Mediawiki's namespace feature
 35+* See [[Project:Namespaces]] for an explanation of how '''namespaces are used on mediawiki.org'''
 36+
3137 __TOC__
3238 ==Usage==
3339
@@ -65,19 +71,20 @@
6672
6773 == Announcements ==
6874
 75+* Starting with version 1.16.0, this extension will require no patching. Updates were made to make more efficient and easier to use.
6976 * The first version of this (Rel 0.0) was released 2009-07-11. The following activities are underway to make this extension easier to install and use, including:
7077 ** Modifying and updating the standard version of img_auth.php to include localization and a hook necessary for this extension. Will hopefully be approved for version 1.16
7178 ** Discussing ways to allow modification of wfStripIllegalFilenameChars so that future patching will not be needed.
7279
7380 ==Download instructions==
7481
75 -This Extension and the necessary patch/files may be downloaded from one of the following (SVN preferred)
 82+This Extension and the necessary patch/files may be downloaded from one of the following (SVN preferred). The distribution is the same for all versions of MW, 1.13.0 through Current.
7683
77 -* Revision 0.0 (beta)
78 -** [http://wiki.montcopa.org/PublicDownloads/NSFileRepo.tar tar] (May require eol conversion)
79 -** [http://wiki.montcopa.org/PublicDownloads/NSFileRepo.tar zip]
80 -** [http://svn.wikimedia.org/svnroot/mediawiki/trunk/extensions/NSFileRepo SVN]
8184
 85+* [http://wiki.montcopa.org/PublicDownloads/NSFileRepo_REL_1_1.tar Download tar] (May require eol conversion)
 86+* [http://wiki.montcopa.org/PublicDownloads/NSFileRepo_REL_1_1.zip Download zip]
 87+* [http://svn.wikimedia.org/svnroot/mediawiki/trunk/extensions/NSFileRepo SVN]
 88+
8289 Copy all files and directories into directory:
8390
8491 <pre>
@@ -91,30 +98,36 @@
9299 * [[Manual:Image Authorization | Image Authorization]].
93100 * [[Extension:Lockdown | Extension Lockdown]]
94101
95 -Please read and understand the above before executing the following instructions
 102+Please read and understand before executing the following instructions
96103
97 -# Download and install [[Extension:Lockdown | Extension Lockdown]]
 104+# Download and install [[Extension:Lockdown | Extension Lockdown]]. If you have not installed
98105 # Download and copy the NSFileRepo extension into directory <nowiki>$IP/extensions/NSFileRepo</nowiki>
99106 # Activate the Image Authorization according to instructions found in [[Manual:Image Authorization | Image Authorization]]
100 -# Copy the img_auth.php and img_auth.i18.php from the distribution in directory <nowiki>{release}/phase3/</nowiki> to your wiki code base directory ($IP). This will overwrite the existing img_auth.php file. Alternately you could copy img_auth.php to another name in the same directory, then use that file name instead of img_auth.php (but still must be in the $IP directory and the localization file must still be img_auth.i18.php).
 107+<br>
 108+=== Installation on versions 1.13.0 through 1.15.1 ===
 109+Up until 1.16.0, MediaWiki required a small patch to includes/GlobalFunctions.php. After that time, no patches are required, so you can skip to [[#Activating NSFileRepo | Activating NSFileRepo]] if you are using MW version 1.16.0 and higher. '''NO PATCHES ARE NEEDED FOR MW Version 1.16.0 and higher.'''
 110+
 111+# Copy the img_auth.php the distribution in directory <nowiki>{release}/phase3/</nowiki> to your wiki code base directory ($IP). This will overwrite the existing img_auth.php file. Alternately you could copy img_auth.php to another name in the same directory, then use that file name instead of img_auth.php (but still must be in the $IP directory).
101112 # <nowiki>$IP/include/GlobalFunctions.php</nowiki> Must be patched. This is a very minor patch to remove the disabling of colons (':'). You can do this one of three ways (whichever you're most comfortable with):
102113 ## Edit the file according to instructions [[#Patch_GlobalFunctions.php | below]]
103114 ## If you have not otherwise patched the file, you may want to copy it from the distribution, which will be in a directory corresponding to the release you are using under <nowiki>{release}/phase3/includes/GlobalFunctions.php</nowiki>
104115 ## Apply the patch which will be in a directory corresponding to the release you are using under <nowiki>{release}/phase3/includes/GlobalFunctions.patch</nowiki>
 116+
 117+== Activating NSFileRepo ==
105118 # To activate this extension, add the following to [[Manual:LocalSettings.php|LocalSettings.php]]:
106119 <source lang="php">
107120 require_once("$IP/extensions/NSFileRepo/NSFileRepo.php");
108121 </source>
109122
110 -===Configuration parameters===
 123+==Configuration parameters==
111124
112125 The user rights and configuration requiremements are are the same as described in [[Extension:Lockdown#Configuration | Extension Lockdown]].
113126
114127 ==Patch GlobalFunctions.php==
115128
116 -In version 1_13_0, a new function wfStripIllegalFilenameChars was added to <nowiki>includes/GlobalFunctions.php</nowiki>. This prevents the protection namespace from being detectd.
 129+In version 1_13_0, a new function wfStripIllegalFilenameChars was added to <nowiki>includes/GlobalFunctions.php</nowiki>. This prevents the extension from determining the namespace associated with the file/image. For this extension to work in versions 1_13_0 through 1_15_1, you will need to make a minor patch to includes/GlobalFunctions.php as follows:
117130
118 -<pre>
 131+<source lang=diff>
119132 Index: GlobalFunctions.php
120133 ===================================================================
121134 --- GlobalFunctions.php (revision 52849)
@@ -127,11 +140,10 @@
128141 + $name = preg_replace ( "/[^".Title::legalChars()."]/", '-', $name );
129142 return $name;
130143 }
131 -</pre>
 144+</source>
132145 <br>
 146+You need to remove the "or :" clause from the REGEX expression by deleting the characters <nowiki>"|:"</nowiki>
133147 <br>
134 -You need to remove the "or :" clause from the REGEX expression of wfStripIllegalFilenameChars by deleting the characters <nowiki>"|:"</nowiki>
135 -<br>
136148
137149 ==See also==
138150
@@ -140,5 +152,5 @@
141153
142154 [[Category:View page extensions]]
143155 [[Category:Edit extensions]]
144 -
 156+[[Category:Namespace extensions]]
145157 {{languages}}

Status & tagging log