Manual:Configuration tips and tricks

The Little Icon in the Address Bar
=> Manual:$wgFavicon

Form Elements in Wiki Edit box

 * Please help! I would want to add form elements i.e check box, list box, radio buttons e.t.c. but the wikitext edit box do not allow me to have these elements. How can i use form elements in wiki edit box.  24/01/2007.

Set $wgRawHtml = true; in DefaultSettings.php then enclose standard html tags in.

Read about security risks for manual:$wgRawHtml = true;

Navigation Tabs
How do I change the "discussion" tab at the top of the page to "News"?
 * Check the System Messages, under Special pages.

Using external SMTP server
For using an external smtp server you need to define manual:$wgSMTP

$wgSMTP = array( "host" => 'smtp.your-server.extension',  "IDHost" => 'your-domain.extension',  "port" => "25",  "auth" => true/false,  "username" => user,  "password" => password );

This function relies on the PEAR's Mail packages. After installing you have to include the location to your include path. What is located in the beginning of LocalSettings.php:

ini_set( "include_path", ".:$IP:$IP/includes:$IP/languages:/usr/share/php" );

The last part (/usr/share/php) is pointing to the directory where Mail.php is

Note for Windows servers
PEAR must not be downloaded from php.net. Use go-pear.bat found in the PHP folder (usually C:\PHP) and then run c:\pear\go-pear.bat -install mail which will download and install Mail automatically.

Notes for PHP 5.1, 5.2 and higher
As described above, you need PEAR. The installation of PEAR is through a PHAR file (PHP Archive) go-pear.phar, since PHP 5.1, instead of the bat-file. The location at the moment of this writing is http://pear.php.net/go-pear.phar (download that file and save it somewhere locally). You can install PEAR by calling the PHAR file as follows from a Windows Command line:

php go-pear.phar

Follow the instructions on the screen. All defaults should suffice. You may receive warning of non-installed modules, you can ignore these warnings. At the end, the installer will ask to add the path to pear to the include_path. Say yes.

If you think that PEAR now includes all libs, than think again. You will have to do some more (sorry). Follow the following steps to remove errors of the kind Class Net_SMTP not found and Fatal error: require_once with Mail.php.

(PEAR comes with a handy installer. It can be called like "pear install libname", which is used for the following steps)


 * Install Mail.php, by issuing the command pear install Mail
 * Install Net::SMTP by issuing the command pear install Net_SMTP
 * Install Net::Socket by issuing the command pear install Net_Socket

Now, try the instructions above for setting $wgSMTP and you should be done.

Instead of installing each one of the PEAR packages, you can do 'pear install --alldeps mail' and it will get the other two and install them as well.

(alternatively, use "yum install php-pear-Mail" to grab it and dependencies from your repository)

Using the PHP 5.2 installer
It is not possible to install PEAR by using the PHP installer for Windows that comes with the PHP 5.2 distribution of PHP. It is simply not included.

HTTPS on Login only
For having encryption on password sending this could be useful (add to LocalSettings.php) $ServerName=$_SERVER['HTTP_HOST']; if ((substr($_GET['title'],-10,10) == ":Userlogin") && ($_SERVER['HTTPS'] != "on")) header("Location: https://$ServerName".$_SERVER['REQUEST_URI']); else if ((substr($_GET['title'],-10,10) != ":Userlogin") && ($_SERVER['HTTPS'] == "on")) header("Location: http://$ServerName".$_SERVER['REQUEST_URI']);
 * 1) take care of https login and back to http after
 * 2) (Yedidia Klein)


 * This is a nice start but too simplistic. It will fail if you're using Using_a_very_short_URL or Eliminating_index.php_from_the_url because the page title is no longer in query string. It will also serve CSS stylesheets and JavaScript files insecurely (via HTTP) on the HTTPS page, making Firefox warn you that the page is only "partially encrypted" (a padlock icon with a slash through it). You will also get PHP warnings that the 'title' array element doesn't exist, if you hit a wiki page with no 'title' query parameter.


 * The following is an "extension" that handles both these problems. Call it whatever you want and include it in LocalSettings.php. Maiden taiwan 18:11, 6 March 2007 (UTC)


 * Update - the extension kills the "Remember my login" checkbox feature -- you lose your sessions because cookies are created as secure on the https page, so the http pages can't access them. I've updated the code below. Maiden taiwan 04:45, 16 March 2007 (UTC)

<?php
 * 1) Secure the login page.

$wgCookieSecure = false;
 * 1) Secure cookies hurt us because they are set on the https page
 * 2) but inaccessible from the http page, so we lose our previous session.

if (checkQS('gen', 'js')) {return;} if (checkQS('gen', 'css') || checkQS('ctype', 'text/css')) {return;}
 * 1) Don't process JavaScript and CSS files.
 * 2) Otherwise, a secure page will be tagged as "partially secure" because these
 * 3) files are being hit via http.

$pageTitle = array_key_exists('title', $_GET) ? $_GET['title'] : "";
 * 1) Get page title from query string.

$domain = $_SERVER['HTTP_HOST']; $uri = $_SERVER['REQUEST_URI'];
 * 1) Get server variables

$onSignInPage = false; $signInPageName = 'special:userlogin'; // lowercase on purpose if ( strtolower($pageTitle) == $signInPageName ) { $onSignInPage = true; } elseif ( strstr(strtolower($uri), "/$signInPageName") ) { $onSignInPage = true; } else { $onSignInPage = false; }
 * 1) Are we on the sign-in page or not?
 * 2) Logic works for everything except Special pages which apparently don't
 * 3) even run LocalSettings.php.

if ( !checkServerVariable('HTTPS', 'on') && $onSignInPage ) { header('Location: https://' . $domain . $uri); } elseif ( checkServerVariable('HTTPS', 'on') && ! $onSignInPage ) { header('Location: http://' . $domain . $uri); } else { // nothing }
 * 1) Secure only the Special:Userlogin page.
 * 2) Un-secure all other pages.

function checkQS($key, $value) { return checkArrayValue($_GET, $key, $value); }

function checkServerVariable($var, $value) { return checkArrayValue($_SERVER, $var, $value); }

function checkArrayValue($arr, $key, $value) { return array_key_exists($key, $arr) && $arr[$key] == $value; }

?>


 * What's the point of encrypting logon if you are going to pass the cookies around in the clear? Sure, the password may be protected, but you are still letting people steal authentication information.

Removing Main Page Title
Methods to remove the "Main Page" title from the main page, as configured on Wikipedia. These examples also remove the "siteSub" and "contentSub".

Using JavaScript
Add to your LocalSettings.php:

$wgUseSiteJs = true;

Edit your MediaWiki:Common.js system message page and insert the javascript below. /* Main page hacks. Remove default "Main Page" header */ var mpTitle = ""; var isMainPage = (document.title.substr(0, document.title.lastIndexOf(" - ")) == mpTitle); var isDiff = (document.location.search && (document.location.search.indexOf("diff=") != -1 || document.location.search.indexOf("oldid=") != -1));

if (isMainPage && !isDiff) { document.write('/*<![CDATA[*/ #siteSub, #contentSub, h1.firstHeading { display: none !important; } /*]]>*/ '); } If this doesn't work, try changing to the name of your main page. On sites set to use English, this is usually, "Main Page".

Using CSS
In MediaWiki 1.9 and above you can remove the Main Page title using CSS. For example, you could add the following to the MediaWiki:Monobook.css system message page.

body.page-Main_Page #siteSub, body.page-Main_Page #contentSub, body.page-Main_Page h1.firstHeading { display: none !important; } This example works for sites that are set to use English. Change "Main_Page" to the name of your main page using underscores instead of spaces.

How to change default font?
I work on a wiki which will use a special font in Jrai (language) and I don't know how to do to make the editor understand symbols and show its. My font use several symbols from vietnamese font, but extended by a set of others symbols. Do you know where can I put this font for the wiki? thanks Benoit COULLET

How to prevent autoconfirmed users from editing the "Main Page" and "Help" pages?
All my users on my wiki have to register for an account. Once they register, they become autoconfirmed users. By using the SimpleSecurity Extension, I am able to recreate groups and assign users to specific groups. I can limit editing, moving, and reading of group created pages by members of other groups. However, I cannot protect the pages in the main navigation box, mainly "Main Page" and "Help" pages by autoconfirmed users. I just want the administrator or sysop group to be able to edit those two pages. The SimpleSecurity Extensions doesn't seem to protect the default system pages such as "Main Page", "Community Portal", "Current Events", "Recent Changes", "Random Page", and "Help". How do I configure protection on the default "Main Page" and "Help Page" so even autoconfirmed users have NO edit rights? Thanks - Satow 20:55, 15 June 2009 (UTC)