Manual:Configuration tips and tricks

<-MediaWiki User's Guide

The Little Icon in the Address Bar
How did they assign the little "W" icon to the Wikipedia pages? Id est, the one that shows up next to the URL or on the left side of a Firefox tab. Bmunden 22:29, 26 February 2007 (UTC)


 * Here's a good demonstration: http://www.chami.com/tips/Internet/110599I.html

Splash page
If you install WikiMedia in /www/wiki, how do you get it to automatically go to the splash page when one types "www.wikipedia.org" and to the actual main page when a user types "en.wikipedia.org" Bmunden 22:29, 26 February 2007 (UTC)

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.

Questions

 * Please help! Mediawiki is stumping me on a couple of configuration issues. First, I'd like to rename "Image List" to "Upload List," as has been done here. Second, I'd like to remove completely the links to the rss/atom feeds--how do I do this? --Artemisi link 21:27, 12 August 2005 (UTC)


 * Access Restrictions

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

Configuration of Image Marker
is there a way to supply an image for the box with the red x when linking to a file like a doc file or pdf file ??

Change lock defaults
1. Set new pages to locked What to do to make newly created pages get locked by default?

2. Set uploads disabled for users What to do to restrict file upload to the e.g. sysop group?

Using external SMTP server
For using an external smtp server you need to define $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

Comment for v1.6.7
I tried this in mediawiki 1.6.7 on Windows and found that there you have to change the $path array (in LocalSettings.php) instead:

$path = array( $IP, "$IP/includes", "$IP/languages", "C:\PHP\PEAR");

where "C:\PHP\PEAR" is the location of Mail.php. Note that there are two files of that name: Mail.php in the PEAR root and mail.php in subdirectory "Mail". I set the include path to the PEAR root and it works. If this doesn't work try using forward slashes "c:/php/pear".

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\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.

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 usefull (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; }

?>

Removing Main Page Title
To remove the "Main Page" title from the main page, as configured on Wikipedia,

Add to your LocalSettings.php:

$wgUseSiteJs = true;

Edit your MediaWiki:Monobook.js(URL) and insert the below javascript:

/* Main page hacks. Remove default "Main Page" header */ var mpTitle = "Main Page"; 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[*/ h1.firstHeading { display: none !important; } /*]]>*/ '); }


 * Doesn't work with different language location.