Extension:ViewFiles

From MediaWiki.org
Jump to: navigation, search


<translate> MediaWiki extensions manual</translate>Manual:Extensions
Crystal Clear action run.png
ViewFiles

<translate> Release status:</translate>Extension status <translate> stable</translate>

ViewFiles.png
<translate> Implementation</translate>Template:Extension#type Special page
<translate> Description</translate>Template:Extension#description Allows users to view the contents of a limited set of files made available by the system administrator.
<translate> Author(s)</translate>Template:Extension#username Nathan Larson (Leucostictetalk)
<translate> Latest version</translate>Template:Extension#version 1.1.0 (2014-04-05)
MediaWikiTemplate:Extension#mediawiki 1.19+
PHPTemplate:Extension#php 5.3+
<abbr title="<translate> <tvarTemplate:Extension#needs-updatephp <translate> No</translate>
<translate> License</translate>Template:Extension#license GNU General Public License 2.0 or later
<translate> Download</translate>
<translate> Example</translate>Template:Extension#example meta.inclumedia.org
<translate> Parameters</translate>Template:Extension#parameters
  • $wgViewFilesIntro
  • $wgViewFilesBegin
  • $wgViewFilesEnd
  • $wgViewFilesFileLangList
  • $wgViewFilesFilePathList
  • $wgViewFilesRobotPolicy

<translate> [[<tvar|1>translatewiki:Special:Translate/ext-viewfiles</>|Translate the <tvar|2>ViewFiles</> extension]] 3></></translate>

<translate>

[[<tvar|1>wikiapiary:Extension:ViewFiles</>|Check usage and version matrix.]] </translate>

The ViewFiles extension allows users to view the contents of a limited set of files made available by the system administrator. 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. 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[edit]

In current versions of MediaWiki, the SyntaxHighlight extension already is coming with the tarball of the MediaWiki Core. The files are located in folder extensions/SyntaxHighlight/.

Download ViewFiles[edit]

  • Download the latest version of ViewFiles
  • Create a folder in the extensions folder named ViewFiles
  • Move the files to the extensions/ViewFiles/ folder

Install SyntaxHighlight and ViewFiles[edit]

  • Edit LocalSettings.php in the root of your MediaWiki installation, and add the following line near the bottom:
require_once("$IP/extensions/ViewFiles/ViewFiles.php");
require_once("$IP/extensions/SyntaxHighlight/SyntaxHighlight_GeSHi.php");
require_once("$IP/extensions/SyntaxHighlight/geshi/geshi.php");

See Extension:SyntaxHighlight#Default_Source_Language for information on how to set a default source language (optional; will not affect how files are displayed by ViewFiles).

Configuration[edit]

The only required configuration setting is $wgViewFilesFilePathList.

$wgViewFilesIntro[edit]

What to begin the page with; e.g.

$wgViewFilesIntro = "__FORCETOC__\n";

$wgViewFilesBegin[edit]

What to begin each file listing with; defaults to:

$wgViewFilesBegin = '<source lang="$1">' . "\n";

$wgViewFilesEnd[edit]

What to end each file listing with; defaults to:

$wgViewFilesEnd = '</source>' . "\n";

$wgViewFilesFileLangList[edit]

This list of filenames and associated languages overrides the extension lookup of the SyntaxHighlight extension. Defaults to:

$wgViewFilesFileLangList = array (
	'.htaccess' => 'apache',
	'robots.txt' => 'robots',
);

$wgViewFilesFilePathList[edit]

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

$wgViewFilesPathList = array(
	'LocalSettings.php' => "$IP/LocalSettings.php",
	'robots.txt' => "$IP/../robots.txt"
);