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 @@ |
12 | 12 | * @licence GNU General Public Licence 2.0 or later |
13 | 13 | * |
14 | 14 | * 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 |
16 | 16 | */ |
17 | 17 | |
18 | 18 | 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).'); |
19 | 20 | |
20 | 21 | $wgImgAuthPublicTest = false; // Must be set to false if you want to use more restrictive than general ['*']['read'] |
21 | 22 | $wgIllegalFileChars = isset($wgIllegalFileChars) ? $wgIllegalFileChars : ""; // For MW Versions <1.16 |
— | — | @@ -215,7 +216,7 @@ |
216 | 217 | |
217 | 218 | # See if stored in a NS path |
218 | 219 | |
219 | | - $subdirs = explode('/',$_SERVER['PATH_INFO']); |
| 220 | + $subdirs = explode('/',$path); |
220 | 221 | if (strlen($subdirs[1]) == 3 && is_numeric($subdirs[1]) && $subdirs[1] >= 100) { |
221 | 222 | $title = Title::makeTitleSafe( NS_FILE, $wgContLang->getNsText($subdirs[1]).":".$name ); |
222 | 223 | if( !$title instanceof Title ) { |
Index: trunk/extensions/NSFileRepo/README |
— | — | @@ -1,8 +1,8 @@ |
2 | 2 | {{Page security extension disclaimer}} |
3 | | -{{Extension by patch warning|version=}} |
| 3 | +{{Extension by patch warning|version=1.15.1}} |
4 | 4 | {{Extension|templatemode= |
5 | 5 | |name = NSFileRepo |
6 | | -|status = beta |
| 6 | +|status = stable |
7 | 7 | |type1 = user rights |
8 | 8 | |type2 = |
9 | 9 | |hook1 = userCan |
— | — | @@ -11,9 +11,9 @@ |
12 | 12 | |author = <!-- add only if different from user name --> |
13 | 13 | |description = implements per-namespace group permissions for image and file rights protection |
14 | 14 | |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 |
18 | 18 | |license = GNU General Public Licence 2.0 |
19 | 19 | |download = {{WikimediaDownload|NSFileRepo}} |
20 | 20 | |readme = [http://svn.wikimedia.org/svnroot/mediawiki/trunk/extensions/NSFileRepo/README README] |
— | — | @@ -25,8 +25,14 @@ |
26 | 26 | |
27 | 27 | ==What can this extension do?== |
28 | 28 | |
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. |
30 | 30 | |
| 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 | + |
31 | 37 | __TOC__ |
32 | 38 | ==Usage== |
33 | 39 | |
— | — | @@ -65,19 +71,20 @@ |
66 | 72 | |
67 | 73 | == Announcements == |
68 | 74 | |
| 75 | +* Starting with version 1.16.0, this extension will require no patching. Updates were made to make more efficient and easier to use. |
69 | 76 | * 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: |
70 | 77 | ** 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 |
71 | 78 | ** Discussing ways to allow modification of wfStripIllegalFilenameChars so that future patching will not be needed. |
72 | 79 | |
73 | 80 | ==Download instructions== |
74 | 81 | |
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. |
76 | 83 | |
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] |
81 | 84 | |
| 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 | + |
82 | 89 | Copy all files and directories into directory: |
83 | 90 | |
84 | 91 | <pre> |
— | — | @@ -91,30 +98,36 @@ |
92 | 99 | * [[Manual:Image Authorization | Image Authorization]]. |
93 | 100 | * [[Extension:Lockdown | Extension Lockdown]] |
94 | 101 | |
95 | | -Please read and understand the above before executing the following instructions |
| 102 | +Please read and understand before executing the following instructions |
96 | 103 | |
97 | | -# Download and install [[Extension:Lockdown | Extension Lockdown]] |
| 104 | +# Download and install [[Extension:Lockdown | Extension Lockdown]]. If you have not installed |
98 | 105 | # Download and copy the NSFileRepo extension into directory <nowiki>$IP/extensions/NSFileRepo</nowiki> |
99 | 106 | # 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). |
101 | 112 | # <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): |
102 | 113 | ## Edit the file according to instructions [[#Patch_GlobalFunctions.php | below]] |
103 | 114 | ## 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> |
104 | 115 | ## 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 == |
105 | 118 | # To activate this extension, add the following to [[Manual:LocalSettings.php|LocalSettings.php]]: |
106 | 119 | <source lang="php"> |
107 | 120 | require_once("$IP/extensions/NSFileRepo/NSFileRepo.php"); |
108 | 121 | </source> |
109 | 122 | |
110 | | -===Configuration parameters=== |
| 123 | +==Configuration parameters== |
111 | 124 | |
112 | 125 | The user rights and configuration requiremements are are the same as described in [[Extension:Lockdown#Configuration | Extension Lockdown]]. |
113 | 126 | |
114 | 127 | ==Patch GlobalFunctions.php== |
115 | 128 | |
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: |
117 | 130 | |
118 | | -<pre> |
| 131 | +<source lang=diff> |
119 | 132 | Index: GlobalFunctions.php |
120 | 133 | =================================================================== |
121 | 134 | --- GlobalFunctions.php (revision 52849) |
— | — | @@ -127,11 +140,10 @@ |
128 | 141 | + $name = preg_replace ( "/[^".Title::legalChars()."]/", '-', $name ); |
129 | 142 | return $name; |
130 | 143 | } |
131 | | -</pre> |
| 144 | +</source> |
132 | 145 | <br> |
| 146 | +You need to remove the "or :" clause from the REGEX expression by deleting the characters <nowiki>"|:"</nowiki> |
133 | 147 | <br> |
134 | | -You need to remove the "or :" clause from the REGEX expression of wfStripIllegalFilenameChars by deleting the characters <nowiki>"|:"</nowiki> |
135 | | -<br> |
136 | 148 | |
137 | 149 | ==See also== |
138 | 150 | |
— | — | @@ -140,5 +152,5 @@ |
141 | 153 | |
142 | 154 | [[Category:View page extensions]] |
143 | 155 | [[Category:Edit extensions]] |
144 | | - |
| 156 | +[[Category:Namespace extensions]] |
145 | 157 | {{languages}} |