Extension:ViewFiles

The ViewFiles extension allows users to view the contents of a limited set of text files. A possible use for this extension would be to enable your users to see the current contents of your configuration files (e.g. LocalSettings.php and InitialiseSettings.php) or customized skin files so that they could better assist with troubleshooting and make recommendations for configuration changes.

If you plan on displaying PHP files with this, you may want to install Extension:SyntaxHighlight GeSHi as well. Don't forget, if you're going to use this to display files such as LocalSettings.php that contain sensitive data, you'll want to get that data out of webroot before exposing those files to the world.

Installation

 * Download the latest version and save it to your computer
 * Create a folder in the extensions folder named ViewFiles
 * Move the files to the extensions/ViewFiles/ folder
 * Edit LocalSettings.php in the root of your MediaWiki installation, and add the following line near the bottom:

Configuration
The only required configuration setting is $wgViewFilesList.

$wgViewFilesIntro
What to begin the page with; e.g.

$wgViewFilesBegin
What to begin each file listing with; defaults to: $wgViewFilesBegin = array (       'default' => ' ' . "\n";

$wgViewFilesList
Create a list of files and their paths, e.g.:

ViewFiles.php
<?php /** * ViewFiles MediaWiki extension. * * This extension allows users to view the contents of a limited set of text files. * * Written by Leucosticte * http://www.mediawiki.org/wiki/User:Leucosticte * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * http://www.gnu.org/copyleft/gpl.html * * @file * @ingroup Extensions */

if (!defined('MEDIAWIKI')) { echo << __FILE__,        'name' => 'ViewFiles',        'author' => 'Leucosticte',        'url' => 'https://www.mediawiki.org/wiki/Extension:ViewFiles',        'descriptionmsg' => 'viewfiles-desc',        'version' => '1.0.1', ); $dir = dirname(__FILE__). '/'; $wgAutoloadClasses['SpecialViewFiles'] = $dir. 'SpecialViewFiles.php'; $wgExtensionMessagesFiles['ViewFiles'] = $dir. 'ViewFiles.i18n.php'; $wgExtensionMessagesFiles['ViewFilesAlias'] = $dir. 'ViewFiles.alias.php'; $wgSpecialPages['ViewFiles'] = 'SpecialViewFiles'; $wgSpecialPageGroups['ViewFiles'] = 'other'; $wgViewFilesIntro = ''; $wgViewFilesBegin = array (       'default' => ' ' . "\n"; $wgViewFilesList = array;
 * 1) Alert the user that this is not a valid entry point to MediaWiki if they try to access the
 * 2) special pages file directly.