| 1 | <?php |
| 2 | /** |
| 3 | * The web entry point for serving non-public images to logged-in users. |
| 4 | * |
| 5 | * To use this, see https://www.mediawiki.org/wiki/Manual:Image_authorization |
| 6 | * |
| 7 | * - Set $wgUploadDirectory to a non-public directory (not web accessible) |
| 8 | * - Set $wgUploadPath to point to this file |
| 9 | * |
| 10 | * Optional Parameters |
| 11 | * |
| 12 | * - Set $wgImgAuthDetails = true if you want the reason the access was denied messages to |
| 13 | * be displayed instead of just the 403 error (doesn't work on IE anyway), |
| 14 | * otherwise it will only appear in error logs |
| 15 | * |
| 16 | * For security reasons, you usually don't want your user to know *why* access was denied, |
| 17 | * just that it was. If you want to change this, you can set $wgImgAuthDetails to 'true' |
| 18 | * in localsettings.php and it will give the user the reason why access was denied. |
| 19 | * |
| 20 | * Your server needs to support REQUEST_URI or PATH_INFO; CGI-based |
| 21 | * configurations sometimes don't. |
| 22 | * |
| 23 | * @see MediaWiki\FileRepo\AuthenticatedFileEntryPoint The implementation. |
| 24 | * |
| 25 | * This program is free software; you can redistribute it and/or modify |
| 26 | * it under the terms of the GNU General Public License as published by |
| 27 | * the Free Software Foundation; either version 2 of the License, or |
| 28 | * (at your option) any later version. |
| 29 | * |
| 30 | * This program is distributed in the hope that it will be useful, |
| 31 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 32 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 33 | * GNU General Public License for more details. |
| 34 | * |
| 35 | * You should have received a copy of the GNU General Public License along |
| 36 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 37 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 38 | * http://www.gnu.org/copyleft/gpl.html |
| 39 | * |
| 40 | * @file |
| 41 | * @ingroup entrypoint |
| 42 | */ |
| 43 | |
| 44 | use MediaWiki\Context\RequestContext; |
| 45 | use MediaWiki\EntryPointEnvironment; |
| 46 | use MediaWiki\FileRepo\AuthenticatedFileEntryPoint; |
| 47 | use MediaWiki\MediaWikiServices; |
| 48 | |
| 49 | define( 'MW_NO_OUTPUT_COMPRESSION', 1 ); |
| 50 | define( 'MW_ENTRY_POINT', 'img_auth' ); |
| 51 | require __DIR__ . '/includes/WebStart.php'; |
| 52 | |
| 53 | ( new AuthenticatedFileEntryPoint( |
| 54 | RequestContext::getMain(), |
| 55 | new EntryPointEnvironment(), |
| 56 | MediaWikiServices::getInstance() |
| 57 | ) )->run(); |