WikiDebug/show source

From TestWiki
Jump to: navigation, search

The WikiDebug extension adds a new tag that allows you to display the contents of a php file within the page. For security reasons it only allows the display of files that are added to an array of allowed files.

If an extension that adds a hook for the <php> tag has been installed (e.g. the GeSHi Syntax Highlighter) then this will be used to wrap the output, otherwise <pre> tags will be used. Note that more recent versions of the syntax-highlighter use tags formatted as follows: <syntaxhighlight lang="php">. This tag style is not currently supported.

Syntax[edit]

<show_source file="{FileName}" />
  • {FileName} is the name of a file residing on the server.

As a security measure this extension will only allow display of tables added to the $wgWikiDebug_ViewableFiles array. Any other files are blocked.

For example, to view the file containing this extension, you would need to add the following to LocalSettings.php:

$wgWikiDebug_ViewableFiles[] = "WikiDebug.php";

Note that paths are relative to the current include path, which includes the extensions directory on this wiki, but which may not on yours.

Example 1: WikiDebug.php[edit]

Here is the current (live) contents of WikiDebug.php - the file that contains this extension.

<show_source file="WikiDebug.php" />

Live sourcecode viewer: WikiDebug.php
Last modified: 2021-04-08 10:18:49

 


Example 2: Non-viewable file[edit]

Here is an attempt to view LocalSettings.php. Because this file is not in the array of allowed files, you are unable to see it's contents:

<show_source file="LocalSettings.php" />

Live sourcecode viewer: LocalSettings.php

File cannot be viewed. It either does not exist, or is protected against viewing.