MediaWiki常见问题解答

From Meta, a Wikimedia project coordination wiki
Jump to: navigation, search

其他语种:

Contents

[edit] 基础概念

[edit] 为什么我要用MediaWiki?

其实未必。MediaWiki是一个并非万能的wiki引擎程序,某些特定的内容/文档管理系统也许更适合你的需要。因此,建议您参考MediaWiki特征列表(英文)使用MediaWiki的网站列表,以及 对Mediawiki的看法(英文)也可以了解一下。

[edit] "Wikimedia"与"MediaWiki"是一回事吗?

不是. Wikimedia是一个非盈利组织维基媒体基金会的名称,它管理着一系列wiki开源内容项目。MediaWiki则是为上述项目的需求而开发的软件。

更详细的解释请见名称(英文)

[edit] 我应该在哪里提交错误报告/特性请求?

错误报告请发布到 [1]。请检索已有的列表,检查新版本中是否已经修正该问题,并确认问题没有重复提交。

[edit] 本FAQ中没有的问题,该到哪里求助?

你可以访问中文wiki专题站点天下维客查找资料,并参与QQ群3680101的讨论。这是mediawiki在中国最大的使用、研究社群。

请加入zh.wikipedia在Google上的群组 XML - 这里聚集了很多维基人与中文维基百科管理员, 关于 Mediawiki 或任何 Wiki 相关的问题都可以在这里得到解答

另外你可以到这里进行英文求助:

或者

[edit] 安装

参见:

[edit] 如何安装MediaWiki? 系统需求是什么?

参见Mediawiki的安装以及本站的英文安装说明

[edit] 一台服务器能同时装多个wiki(MediaWiki)吗?怎么做?

Yes, MediaWiki can be installed multiple times in different directories using either the same database with a different set of table prefixes (configurable upon install) or using different databases altogether.

Additionally, you may want to make some settings common for all the installations, and have a central place where changes to these can be made. Since the configuration file (LocalSettings.php) is executed as PHP code, this can be done with PHP's inclusion mechanism - for instance, by adding the line include_once("../CommonSettings.php") in each LocalSettings.php, and placing settings which apply to all wikis in ../CommonSettings.php.

If you have a large number of wikis on one host, you may not want to keep a separate copy of the source code for every one. Instead, extract the source somewhere, and for each wiki installation, symlink the entire MediaWiki directory with the sole exception of the LocalSettings.php file. This can be accomplished with the lndir command (available on some Linux installations) or an equivalent tool.

You can then either use a separate LocalSettings.php for each wiki, or (easier to maintain) determine the settings based on the URL. See also Wiki farm.

If you want your login to be persistent across Wiki's running on the same server, simply add the following line to your LocalSettings.php after $wgSiteName = ... :

ini_set("session.name", "{$wgSitename}Session" );

(Though you can expect some trouble if $wgSiteName contains spaces. In that case replace {$wgSiteName} with an explicit space-removed version).

[edit] Can I import from other types of wiki?

There is some documentation about importing in the UPGRADE file distributed with MediaWiki.

To follow on from those, this is how at least one individual imported pages from usemod to MediaWiki:

Because MediaWiki does not automatically link to CamelCase style links, you will need to add brackets [[ ]] to all your links. You can do this with the following:

First, obtain ImportStage1.txt (or whatever you want to call it) from the importUseModWiki.php script ( use > to pipe the output to a file )

Second, do

sed '/Importing/!s/\ [A-Z]\w*[a-z]\w*[A-Z]\w*[a-zA-Z]/\ \[\[&\]\] /g' ImportStage1.txt > ImportStage2.txt

This should create proper links in place of your CamelCase links.

This doesn't work so well for SubPage links - someone care to fix?

Then,

 
sed 's/upload\:\w*\.\w*/http\:\/\/aberwiki\.org\/uploads\/& /g' ImportStage2.txt > ImportStage3.txt

This fixes your upload links. Change the replace text so it fills in your url such as http://www.yourwiki.org/uploads/filename

You are now ready to import ImportStage3.txt into your database with a command such as

mysql -u<mysqluser> -p<yourpass> <db name> < ImportStage3.txt

Note: If your importUseModWiki.php outputs an XML file instead of SQL statements, this probably means you have a rather new version of MediaWiki. In such a case, you case import the XML file -- see Importing a Wikipedia database dump into MediaWiki, towards the bottom of the page ('Import XML'). Don't forget to rebuild all the tables -- that page also explains how to do that.

[edit] 请问能否定义一个数据库的前缀?

在1.3.x 和之前的版本是不行的。

在 1.4 和以后的版本在安装过程中可以定义数据库的前缀。 最好在所加的前缀后面增加一个 _ 使得名称更好看一点。

[edit] 為何Help:(幫助:)名空間是空的?

We don't currently have a clean, generic, internationalized set of help pages. Would you like to write one? However, you will find some useful pages in the MediaWiki User's Guide. They are of course open content under the GNU FDL.

[edit] I've changed $wgLanguageCode to something else, but nothing happens - what gives?

When we display a user interface text and $wgUseDatabaseMessages is enabled, we first check if a page for that interface message exists in the MediaWiki: namespace (table CUR, field cur_namespace=8); if so, we return it and abort. If $wgUseDatabaseMessages is false, or no page exists, we call the getMessage() function of the language object (the Language??.php file for the language in question).

In other words, we try the MediaWiki: namespace first, and the local file second. When you install MediaWiki, the MediaWiki: namespace is initially filled with the data from Language??.php, where ?? is the language set in $wgLanguageCode. If you change the language code afterwards, the MediaWiki: pages are not updated, and the old language is used instead.

Setting $wgUseDatabaseMessages=false should show you the language you want (after clearing your cache (browser or mysql?)), but you will no longer be able to use the MediaWiki namespace. If you want to do that, you should run the script rebuildMessages.php from the maintenance directory instead.

See MediaWiki i18n and MediaWiki namespace for more information.

[edit] The install stops with no messages or I get a blank page!

Installation problems are sometimes weird and hard to diagnose. If possible, check PHP's error log (you may have to configure PHP to enable error logging) and report any error messages you have and the complete output from the installation script to mediawiki-l, we'll see if we can hash it out.

If you can track down the problem specifically, please report it directly to http://bugzilla.wikipedia.org/

Known issues

  • Version 1.3.3: you'll get a blank page after submitting configuration info on your config/index.php script if you don't make the config directory writeable.
  • Version 1.3.x: bugzilla:736


[edit] I want my wiki to appear in a frame as part of my site, but it keeps popping out of the frame

MediaWiki contains protection against abusive use of frame sets. Unfortunately this will trap your intentional frames as well -- to remove this, edit stylesheets/wikibits.js and remove these lines:

(Please note that if the wikibits.js file isn't in stylesheets/wikibits.js it may be skins/common/wikibits.js)

 // Un-trap us from framesets
 if( window.top != window ) window.top.location = window.location;

[edit] How do I change messages of the user interface?

The user interface text is put into pages in the special MediaWiki namespace. When logged in as a sysop, you can edit those pages to immediately change the output of the wiki.

Some configuration changes (like changing $wgSitename to set the wiki's name) don't affect the pages which were generated at install time. You can edit them directly, or use the "rebuildMessages.php" script in the maintenance directory (it must be run from the command line and you must set up an AdminSettings.php file). See MediaWiki localisation.

[edit] Why doesn't my wiki work on Sourceforge?

See Running MediaWiki on Sourceforge.net.

[edit] How do I install Imagemagick for Thumbnails on Windows?

With the following installed on the server, it should work:

  • php.ini
extension=php_imagick.dll
  • Localsettings.php
$wgEnableUploads           = true;
$wgUseImageResize               = true;
$wgUseImageMagick = true;
$wgImageMagickConvertCommand = "convert"; #<-- this should point on the right path 

If its in the windows path variable, you can use "convert" only


Using ImageMagick-6.2.5-Q16-windows-dll:

  • Install ImageMagick. Make sure the installation directory does not contain any blank spaces.
  • LocalSettings.php
$wgEnableUploads           = true;
$wgUseImageResize               = true;
$wgUseImageMagick = true;
$wgImageMagickConvertCommand = "convert";  # <-- this should point on the right path
  • You don't have to add php_imagick.dll to your php.ini
  • If you are running php in safe mode, add the ImageMagick installation directory to your php.ini: e.g safe_mode_exec_dir=C:/Programs/ImageMagick.
  • Also you will have to change permissions for %systemroot%/system32/cmd.exe. Grant read and execute rights to IUSR_XXX and IWAM_XXX.

[edit] The index redirects to localhost or 127.0.0.1 or just times out

When constructing full URLs and HTTP redirects, MediaWiki uses the hostname provided by the web server. Under Apache this will usually be specified by the ServerName directive if not autodetected from the system.

If that is set wrong, you should do one of the following:

  • Set the ServerName directive in Apache to the proper hostname
  • Override $wgServer in LocalSettings.php with the URL protocol and hostname (eg 'http://example.com')

[edit] How can I active RSS-Feed for Recent Changes

I read about the RSS-Feed feature of MediaWiki but how can I activate it my own installation?


[edit] 使用

[edit] 如何寫新頁

  1. Go to the page you want the new page to be linked from.
  2. Click on the edit tab to edit the page. Add a link to the page you wish to create.
    The way to create a link is to place the new page's title in brackets. [[Page title]]
  3. Save the page. Your link will show up as a red link which, when clicked, will bring you to an edit page for your new page.
  4. Edit and save your new page.


Updated by -Sx- :: Literally, under 1.5Beta1, you simply surf to (or try to browse to) a page you want to create - like thus:
somewikisite/index.php?title=SITE:New_pages_created
When this blank page is displayed, click edit, as described above, and add your content. The page will be orphaned initially; but you can link to it from other pages, etc...
Updated by DHJ - there really needs to be a way to simply create a new page from wherever you are - endusers should not be expected to have to know how to create new pages by writing URLs!
Updated by WNE - If nothing else, a search should say "Create a new page for <the term that wasn't found.>" and, though this is discouraged, there is a way of doing this.

[edit] How do I add a table of contents?

A TOC is added automatically as soon as you have more than three headers. To add one with fewer than four headers, type __FORCETOC__ anywhere on the page or __TOC__ at the position where you want to have the TOC.

To remove a table of contents from a page, add __NOTOC__ to anywhere on the page. See Help:Section for more information.

[edit] MediaWiki is slow, how can I make it faster?

You might want to try a PHP cache engine such as eAccelerator. It will save the parsed PHP scripts and enhance performance a lot (this is something you should use anyway on any PHP installation with non-trivial traffic).

You can use TurckMMCache, but it's an old and unmaintained application. eAccelerator is the continuation of TurckMMCache.

Also look at Squid and memcached.

[edit] Can I print out my entire MediaWiki site?

The short answer to this is no, there is no single function to print the whole site. Each page (using the monobook skin) is formatted for printing, but to print the whole site you need to go to each page and print it separately.

However, if you're building, for example, a documentation and support site you can also build a monolithic page which includes (transcludes) all the pages of your document. Create the page using:

= Big Headings =
{{:Page title1}}
{{:Page title2}}

and so on...

This will automatically generate an index for your document as well!

[edit] What is the print-friendly url?

Normally the print stylesheet is attached so it is automatically used when printing -- just printing or print-previewing a wiki page will demonstrate this.

You can force a print friendly view. For example:

http://en.wikipedia.org/w/wiki.phtml?printable=yes&title=Main_Page

[edit] Can I use commons.wikimedia.org in my installed version of mediawiki ?

At present the shared image repository must be present on the server's filesystem, so unless your site is on the Wikimedia main cluster the answer is no.

[edit] 如何用機器人?

You might want to use the python wikipediabot.

[edit] How do I purge cached pages?

  1. You can use ?action=purge on individual pages to update their cache dates. Note that this may take a few minutes.
  2. There is a global $wgCacheEpoch variable which can be set in LocalSettings.php to invalidate all prior cache entries (see DefaultSettings.php)
  3. A shell script such as this may be used
#! /bin/bash
# mwpurgecache - invalidate mediawiki cache

set -e

PROG=$(basename $0)
VER=0.1

function version() {
 echo "$PROG $VER - invalidate mediawiki cache
Copyright (c) 2005 Claudio Jolowicz <claudio@jolowicz.com>

Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved. This programs comes with
ABSOLUTELY NO WARRANTEE.
"
}

function usage() {
 version
 echo "Syntax: $PROG [options] [--] [pages]

Options:

 -H, --host          host name           (default: localhost)
 -w, --wiki WIKI     server path to wiki (default: /wiki/)
 -u, --user USER     username for HTTP authentication
 -p, --passwd PASS   password for HTTP authentication
 -d, --dryrun        show commands without executing them
 -q, --quiet         quiet (no output)
 -v, --verbose       be verbose (print server response)
 -h, --help          display this message
 -V, --version       display version information

Options and arguments must be separated by whitespace.  WIKI must
match wgArticlePath, such that \$wgArticlePath = \"WIKI/\$1\". WIKI
must not contain regex special characters.

This script requests all wiki pages listed on the command line by
HTTP, prefixed by the wiki path, appending \`?action=purge' to the
URL. If no pages are specified, it retrieves the list of all pages
from Special:Allpages.

Examples:

 \$ $PROG Main_page Help:Contents
 \$ $PROG -H wiki.my.org -w /mediawiki -u joe -p banana
 \$ $PROG -H wiki.my.org --dryrun | wc -l
"
}

## The '-e#' is a noop option to avoid `Unsupported scheme' errors.
user='-e#'
passwd='-e#'
run=
verbose=-nv
quiet='-e#'

opt_host=http://localhost
opt_wiki=/wiki/
opt_user=
opt_passwd=
opt_dryrun=false
opt_quiet=false
opt_verbose=false
while [ "$1" ]
do
 case "$1" in
   -H|--host) opt_host="$2"; shift;;
   -w|--wiki) opt_wiki="$2"; shift;;
   -u|--user) opt_user="$2"; shift;;
   -p|--passwd) opt_passwd="$2"; shift;;
   -d|--dryrun) opt_dryrun=true;;
   -q|--quiet) opt_quiet=true;;
   -v|--verbose) opt_verbose=true;;
   -h|--help) usage; exit 0;;
   -V|--version) version; exit 0;;
   --) shift; break;;
   -*) usage 2>&1; exit 1;;
   *) break;;
 esac
 shift
done
opt_host=${opt_host%/}
opt_wiki=/${opt_wiki#/}
opt_wiki=${opt_wiki%/}/
[ x"$opt_user" = x"" ] || user="--http-user=${opt_user}"
[ x"$opt_passwd" = x"" ] || passwd="--http-passwd=${opt_passwd}"
$opt_dryrun && run=echo
$opt_verbose && verbose="--server-response"
$opt_quiet && quiet="-q"
(
 if [ $# -eq 0 ]; then
   wget -qO- "$user" "$passwd" "${opt_host}${opt_wiki}Special:Allpages" |
   sed -re '/start content/,/end content/p' -e 's/href="([^"]+)"/\nGREPME:\1\n/g' |
   sed -nre 's/^GREPME:(.*)$/\1/p' |
   grep "^${opt_wiki}"
 else
   for page; do echo "${opt_wiki}${page}"; done
 fi
) |
while read page
do
 $run wget -O/dev/null "$user" "$passwd" "$quiet" "$verbose" "${opt_host}${page}?action=purge"
done

exit 0

[edit] How do I organize pages into subdirectories like /wiki/subdir/PageName ?

See Help:Link#Subpage_feature.

[edit] 設定

[edit] I access the wiki pages on my system by writing http://localhost/directorypath. But, if I try writing http://systemname/directorypath, it throws an error that page not found.

Maybe there is something wrong with your Apache virtual hosts? See the Apache documentation for details.

[edit] How do I change the look and feel of MediaWiki for my own site?

See MediaWiki look and feel for a detailed explanation..

[edit] How can I disable/enable tabs at top (monobook), add history navigation to article pages, or otherwise move around functional components from page to page?

   Under 1.5Beta1, set $wgDefaultSkin = 'disabled';
   in your LocalSettings.php (contributed by -Sx-)...

Under 1.5, to disable all view top tabs, create a new skin according to these instructions and name this MonoBookNoViews. Set this as the default theme. Logged in users will need to change their default theme to see the tabs to edit pages, however.

You will need to remove the section of code in the MonoBookNoViews.php file which generates the views (top tabs).

Search for this code:

      <div id="column-one">
        <div id="p-cactions" class="portlet">
          <h5><?php $this->msg('views') ?></h5>
          <ul>
            <?php foreach($this->data['content_actions'] as $key => $action) {
               ?><li id="ca-<?php echo htmlspecialchars($key) ?>"
               <?php if($action['class']) { ?>class="<?php echo htmlspecialchars($action['class']) ?>"<?php } ?>
               ><a href="<?php echo htmlspecialchars($action['href']) ?>"><?php
               echo htmlspecialchars($action['text']) ?></a></li><?php
             } ?>
          </ul>
        </div>
        <div class="portlet" id="p-personal">

Replace it with this:

      <div id="column-one">
        <div class="portlet" id="p-personal">

To remove the "Edit" links in the content sections, modify monobooknoviews/main.css.

Replace this line:

* html div.editsection { font-size: smaller; }

With this line:

* html div.editsection { display: none !important; }

[edit] How do I change the default skin for users that are not logged in?

Set $wgDefaultSkin = 'monobook'; in LocalSettings.php (see example). Make sure that the quoted skin is in lowercase in the LocalSettings.php file (ie: 'monobook', not 'MonoBook') regardless of how the skin name is actually capitalized.

[edit] I've changed settings in LocalSettings.php, such as $wgSitename, but they don't show up in my browser. Why not?

(Note: As always, first ensure that you're not viewing a cached page - perform a "hard refresh", clear the browser cache, or view a page that didn't exist before the change.)

There was a bug in versions of MediaWiki prior to 1.3.6 where variables, such as $wgSitename, were interpolated into user interface messages at install, rather than when the message was requested (Bugzilla:296). The result was that any later changes to these variables would have no effect on these messages, since the software simply saw them as plain text; all UI messages can be reset to their defaults (with the new variable values) by running the maintenance/rebuildMessages.php script. If you upgrade to the latest version of MediaWiki first, these will include dynamic references to the variables (e.g. {{SITENAME}}) and should therefore reflect future configuration changes.

[edit] Does MediaWiki automatically capitalize the first letter of $wgSitename?

It does appear to do so.

[edit] How can I change what the <title> of each page is? Where do I make changes?

Most of the text that you want to change, can be found in the namespace of MediaWiki.

In order to change titles, texts, announcements and the such, go to Special:Allmessages, where you will see the text associated with the pages you wish to change. (As far as I can tell, you need to log in as an administrator (like the one you made when you installed) to edit the protected entries in the MediaWiki namespace.)

If you want to change the title in your browser, you need to edit MediaWiki:sitetitle. Go there and edit it just like you would any other page in your Wiki.

What I found in my Wiki is that even after you change things in your languageXX.php file, it's "too late", because Special:Allmessages was already constructed using what it found there. So you need to change all the instances of Wikipedia, manually. (I could be wrong, and if I do, someone please correct me)

Edit MediaWiki:Pagetitle.

I do not understand these directions. How do you edit this?

I don't understand them either, could you please explain why even if my pagetitle is correct at the top of each browser page the name displayed is always Pagename- Wikipedia? (the field you told to edit is correctly displaying UniWiki as sitename... puzzled)

I've been having the same problems; I use hebrew in my site, but my SITENAME is Navi Commission. When I edit MediaWiki:Pagetitle I see {{SITENAME}} - 1$ , but at the top of my browser is still "Wikipedia" written in Hebrew. How do I change that?

Under 1.5Beta3, simply click the "move" tab link and rename your page as you move it. (contributed by -Sx-)

Editing MediaWiki:Wikititlesuffix did the trick for me. (version 1.4.9)

[edit] How do I enable uploads?

If you get the following message:

Sorry, uploading is disabled.

See Documentation:Administration#Toggle_uploads_on/off. For more information and trouble shooting, see Uploading files.

[edit] When I try to upload files in Mediawiki 1.5 I always get a "The file is corrupt or has an incorrect extension. Please check the file and upload again." error.

You should be able to solve this by adding

$wgVerifyMimeType = false;

to your LocalSettings.php file

It's a longshot, but adding

$wgMimeDetectorCommand= "file -bi"; #use external mime detector (linux)

to your LocalSettings.php file solves this problem in some cases.

With 1.5, check whether the mediawiki temp dir exists and has the right permissions. In general, check your php-logs for any obvious errors.

After, try in the maintenance directory to rebuildImages and then, display the pages with a trailing ?action=purge.

[edit] How do I use templates?

See Help:Templates.

[edit] How do I set the timezone for my MediaWiki?

In LocalSettings.php add:

$wgLocalTZoffset    = "-1";

etc.


See provisionally also:

[edit] How do I make my base URLs shorter?

See eliminating index.php from the url for details. You may need access to server files like httpd.conf.

[edit] Search returns no results for some words!

MySQL's fulltext search engine has a default set of stop words which it ignores, and a minimum word length set to 4 characters by default.

To change this you must reconfigure MySQL, see: http://dev.mysql.com/doc/mysql/en/fulltext-fine-tuning.html



[edit] How do I activate HTML-Tags, e.g. "<input>" or "<form>" ?

It seems to be possible to activate HTML-Tags like "<input>" or "<form>" (Have a look at [2], and note the PayPal Buttons working). How does it work ?

  1. if you need those HTML-tags for one action only (e.g. this PayPal-Button), but don't want HTML to be activated generally, write your own MediaWiki_Extension which outputs your HTML-needs.
  2. the more "dirty"-way is to add $wgRawHtml = true; to your LocalSettings.php. If you do so, HTML-tags are activated on every page.

[edit] How do i make $wgRawHtml = true; work only with sysop user and not with other users?

[edit] How do I make it so only admins can add full html codes to articles?

Answer:

How could the database determine, who have added the tags (to make it work)? Look in diffs? But these tags can be changed after by another user, what can change its meaning. So there are several "half-ways":

  • if last change of page was made by sysop, then HTML tags are enabled, otherwise not (if anyone make any change after, this will be disabled)
  • if sysop added HTML tags, the page is automaticly blocked for editing by other users

I don't know, how to do that in mediawiki, it is only theory. But both ways would require some hacks in php scripts.


A quick and really dirty way is to just copy the following line to includes\Setup.php line 211

   if ($wgUser->isAllowed('protect')) $wgRawHtml=true;

This will check whether the current user can change page properties (normally only a sysop can do that) and will set the $wgRawHtml variable accordingly. Of course (if you know what you're doing) you can replace protect by a special HTML permission you define yourself -- Ms


[edit] How do I make external links pop up in new browser windows?

http://meta.wikimedia.org/wiki/Opening_external_links_in_a_new_window

Please do not do this.

[edit] How do I make image pages display the image?

I installed Mediawiki and image pages display only one line of text pointing to the image itself. I want the actual image to be displayed on the image page like on Wikipedia. How do I do it?

Are you sure the image is not already on the page? Maybe the uploaded images are not getting the right permissions. You could check this in your webserver error log. I'm sorry but wouldn't know how to fix this if it were the case. --Bjørn

[edit] 更多复杂的定制

[edit] How do I add the sandbox functionality to my installation of the wiki?

Just add a page named 'Sandbox' and refer to it from within another page using the link [[Sandbox]].

[edit] 怎样更换站点标志?

In your LocalSettings.php add:

$wgLogo = '/path/to/your/logo.png';

Default is {$wgUploadPath}/wiki.png. Default for version 1.5 is $wgStylePath/common/images/wiki.png

Default logo size is 135px by 135px

See also Customization#How_do_I_customize_the_logo_in_the_top_left_corner.3F.

[edit] 怎样在搜索失败后显示一个新建页面的链接?

This is not a recommended practice as it promotes the creation of orphan pages not reachable through link crawling.

If you insist on doing so, edit your MediaWiki:Nogomatch message to add such a link, such as at the English Wikipedia version.

NOTE: it should use wiki syntax and not HTML and only applies to 1.5 and above.

[edit] 怎样更换在浏览器地址栏中的图标?

The wiki will output a <link> which references the traditional /favicon.ico, at the root URL path of your site. (Some browsers will look there even without the <link>, others require it.)

If you want to use some other icon specifically for those browsers supporting it, you can change a bit in /includes/Skin.php. Change the line from 'href' => '/favicon.ico' to 'href' => '/path/to/your/favicon.ico'.

[edit] Is it somehow possible to use a "file" URI-qualifier for local intranets e.g. [file://localhost/C: C-Drive]?

Maybe. You can make MediaWiki support it by adding the "file" protocol to the list of URL handlers. Right now you have to directly edit includes/Parser.php:

   /* private */ function replaceExternalLinks( $text ) {
                $fname = 'Parser::replaceExternalLinks';
                wfProfileIn( $fname );
                $text = $this->subReplaceExternalLinks( $text, 'http', true );
                $text = $this->subReplaceExternalLinks( $text, 'https', true );
                $text = $this->subReplaceExternalLinks( $text, 'ftp', false );
                $text = $this->subReplaceExternalLinks( $text, 'irc', false );
                $text = $this->subReplaceExternalLinks( $text, 'gopher', false );
                $text = $this->subReplaceExternalLinks( $text, 'news', false );
                $text = $this->subReplaceExternalLinks( $text, 'mailto', false );
                $text = $this->subReplaceExternalLinks( $text, 'file', false );
                wfProfileOut( $fname );
                return $text;
        }

From version 1.4 on, in Parser.php change the line

define( 'URL_PROTOCOLS', 'http|https|ftp|irc|gopher|news|mailto' );

to

define( 'URL_PROTOCOLS', 'http|https|ftp|irc|gopher|news|mailto|file' );

From version 1.5rc4 you need to add the following line to LocalSettings.php

$wgUrlProtocols = 'file:\/\/|http:\/\/|https:\/\/|ftp:\/\/|irc:\/\/|gopher:\/\/|news:|mailto:';
Doesn't seem to work 217.91.16.195 14:29, 14 September 2005 (UTC)

However, many browsers will ignore these URLs, so that even though you can create the link, clicking on it will have no effect. This is because URLs of this type pose an inherent security risk [3].

List of browsers supporting or not supporting the file:/// link from pages delivered from a remote server, which is common to wiki pages:
Browser Supports file: links?
Internet Explorer 6.0 (Windows XP SP1 or SP2) no
Internet Explorer 6.0 (Windows XP Professional Version 2002 SP1) yes
Internet Explorer 6.0 (Windows 2000 SP 4) yes
Internet Explorer 5.5 (Windows 2000 SP 4) yes
Netscape 7.0 (Windows XP SP1 or SP2) no
Opera Version 7.54 Final (Linux) no
Opera Version 8 (Windows) no (2)
Mozilla 1.7 (Linux) no /yes (1)
Firefox 1.04 (Windows) no / yes (1)
Konqueror (Linux) yes (3)

Was listed as bugzilla:614 (RESOLVED WONTFIX).

(1) Enable user_pref("security.checkloaduri", false);, see below. Drag of link and drop into location bar does not work, in difference to Copy link / Paste link.

(2) Drag of link and drop into location bar works fine.

(3) Konqueror displays a warning if a remote (eg. http) URL points to a local (file, telnet, irc, whatever), and allows the user to cancel. ((Wikipedia User JensBenecke))

A note: According to the Instiki FAQ loading of local file links from http links can be enabled on Mozilla and Firefox by putting user_pref("security.checkloaduri", false); into the file usr.js.
It should also be possible to set this with the "about:config" interface (just type about:config in the address bar, typing security.ch into the filter input line then narrows down the displayed options to this one). I'm not sure which version of Mozilla introduced this (I just learned about this interface today).
However note that this setting is global, i.e. it will affect all sites you browse; while I don't know exactly what the security risk of this is, the fact that the setting is in the security section (and the note "If you don’t give a wit about the security of your local files" on the Instiki FAQ) strongly implies this is a security risk. --132.199.100.181 08:08, 29 Oct 2004 (UTC)
Perhaps if this is set, a malicious website could load a file:/// url into a frame, and read the contents with javascript? Could be a security risk if the right file was opened. --134.148.20.33 08:43, 10 May 2005 (UTC)

--194.95.179.181 13:32, 22 September 2005 (UTC) :

in addition to version 1.5:
may help using links with this format:
[[file:///%5C%5NAME-OF-COMP-OR-IP-ADR%5SUBDIR%5C20M%F6LLER%5Cfilename.html filename.html]]
instead of
  [[file:///\\NAME-OF-COMP-OR-IP-ADR\SUBDIR\20 MöLLER\filename.html filename]]
replace Backslash with %5c, space with %20, ö with %F6 etc.
This works with MediaWiki 1.5, Explorer 6.0.2800 and Firefox 1.0.6


Also in version 1.5 I found I could change the code to accept links like:
[file:\\machine\directory\my.file text]
..by adding file:\\\\ to the define( 'HTTP_PROTOCOLS', line in parser.php and the $wgUrlProtocols variable in DefaultSettings.php, instead of file:\/\/. I am not sure if I could get away with changing just one file. This is for MediaWiki running on Windows with Apache. -Sprintstar 12:40, 1 November 2005 (UTC)

[edit] 怎样增加我自己的动态内容到 MediaWiki 软件中?

Write an extension that implements a special page. See write your own MediaWiki extension.

[edit] How can I insert one of my PHP functions underneath the "Search" box?

Dan Kohn has a neat tutorial

[edit] 怎样完全锁定数据库?

Set $wgReadOnlyFile in LocalSettings.php to the name of a file, then put the reason for the lock inside the file. The contents of the file will be displayed to anyone trying to edit the wiki.

Note that readonlyfile is not guaranteed to be absolutely safe; if you need to guarantee that MediaWiki will never write to the data, you need to do this on the database itself (e.g. revoke UPDATE,INSERT,DELETE from the wiki user, or put MySQL into read-only mode).

[edit] How do I put an alphabetical list of links on the top of the category page?

First, you'll need to edit /wiki/includes/CategoryPage.php and find the instance method shortList of class CategoryPage. The first line of the function looks like :

$r = "<h3>{$articles_start_char[0]}</h3>\n";

Replace it, adding an id attribute. The method becomes :

        function shortList( $articles, $articles_start_char ) 
        {
                // !PATCH-ALPHA-CATEGORIES : CategoryPage::shortList
                $r = "<h3
                id=\"{$articles_start_char[0]}\"              
                >".$articles_start_char[0]."</h3>\n";

A more professional design could produce :

        function shortList( $articles, $articles_start_char ) 
        {
                // !PATCH-ALPHA-CATEGORIES : CategoryPage::shortList
                // !PATCH-ALPHA-CATEGORIES : // !SEE-ALSO $wgAlphaCategoriesPrefix in DefaultSettings.php
                global $wgAlphaCategoriesPrefix ;
                $wgAlphaCategoriesPrefix = isSet($wgAlphaCategoriesPrefix) ? $wgAlphaCategoriesPrefix : '' ;
                $szId = ($wgAlphaCategoriesPrefix === false) ? '' 
                   : ($wgAlphaCategoriesPrefix." id=\"{$articles_start_char[0]}\" ") ;
                $r = "<h3 $szId >".$articles_start_char[0]."</h3>\n";

A few lines after, replace, in the same way, the following line:

$r .= "</ul><h3>{$articles_start_char[$index]}</h3>\n<ul>";

With :

     // !PATCH-ALPHA-CATEGORIES : CategoryPage::shortList
     $r .= "</ul><h3 
            id=\"{$articles_start_char[$index]}\"
            >{$articles_start_char[$index]}</h3>\n<ul>";

Or, in a more professional design :

     // !PATCH-ALPHA-CATEGORIES : CategoryPage::shortList
     $szId = ($wgAlphaCategoriesPrefix === false) ? '' 
        : ($wgAlphaCategoriesPrefix." id=\"{$articles_start_char[$index]}\" ") ;
     $r .= "</ul><h3 $szId >{$articles_start_char[$index]}</h3>\n<ul>";

Then, edit a Category page. Insert a line that looks like

 {{A-Z-title|Ma belle liste alphabétique}}

Of course, A-Z-title is just an example. You may use another template name.

Then, because A-Z-title is not yet defined, click on the link, edit, and enter a content such as :

=={{{1}}}==
<center>[[#A|A]] [[#B|B]] [[#C|C]] [[#D|D]] [[#E|E]] [[#F|F]] [[#G|G]] 
[[#H|H]] [[#I|I]] [[#J|J]] [[#K|K]] [[#L|L]] [[#M|M]] [[#N|N]] 
[[#O|O]] [[#P|P]] [[#Q|Q]] [[#R|R]] [[#S|S]] [[#T|T]] [[#U|U]] 
[[#V|V]] [[#W|W]] [[#X|X]] [[#Y|Y]] [[#Z|Z]]</center>

After reloading the Category page, your page will include something like :

Ma belle liste alphabétique

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Later on, each time you want to add an alphabetic index to a Category page, simply reuse your A-Z-title :

 {{A-Z-title|Ma très belle liste alphabétique}}

Four related templates are available in this discussion page.

 {{A-Z}}
 {{A-Z-title|Ma belle liste}}
 {{A-Z-prefix|cp_}}
 {{A-Z-title-prefix|Ma belle liste|cp_}}

In a professionnal design, you should add in the /wiki/includes/DefaultSettings.php something like :

 // !PATCH-ALPHA-CATEGORIES : // !SEE-ALSO CategoryPage::shortList in CategoryPage.php
 /*
  * $wgAlphaCategoriesPrefix = false ; // disable feature
  * $wgAlphaCategoriesPrefix = '' ; // default
  * $wgAlphaCategoriesPrefix = 'myprefix_' ; // customized prefix
  */  
  $wgAlphaCategoriesPrefix = '' ;

In this case, you may eventually add, in your /wiki/LocalSettings.php something like

 $wgAlphaCategoriesPrefix = 'cp_' ;

In this case, you'll use one of these templates :

 {{A-Z-prefix|cp_}}
 {{A-Z-title-prefix|Ma belle liste|cp_}}
in this note, non-english (french, spanish, german, etc) expressions are voluntary used to denote examples,
PHP variable names such as $szId use hungarian prefixes,
patterns such as // !PATCH... are so-called haDoc comments, not to be confused with appropriate phpDoc comments.

[edit] How can I add a variable {{CURRENTWEEK}} for a "Featured article of the week" or similar?

NOTE: this is not needed in 1.4

Variables such as {{CURRENTMONTH}} and {{CURRENTDAY}} are called Magic Words, and you will want to add a new one to your system. For MediaWiki 1.4beta3, you'll need to edit three files, adding just a small bit of text. Be Bold. At the same time, don't work on your live version, but on a working back up.

In /wiki/includes/MagicWords.php near the top of the file you'll find a list of define statements, like this:

define('MAG_REDIRECT', 0);

Notice that the number in the parenthesis is incrementing. Go to the bottom of this list and add a new definition, with XX being the next number for your set up:

define('MAG_CURRENTWEEK', XX);

Just below definition list you'll find an array which probably looks rather like

$wgVariableIDs = array(
   MAG_CURRENTMONTH,
   MAG_CURRENTMONTHNAME,
   MAG_CURRENTDAY,
   MAG_CURRENTDAYNAME,
   MAG_CURRENTYEAR,
   MAG_CURRENTTIME,
   MAG_NUMBEROFARTICLES,
   MAG_CURRENTMONTHNAMEGEN,
   MAG_SITENAME,
   MAG_SERVER,
   MAG_PAGENAME,
   MAG_PAGENAMEE,
   MAG_NAMESPACE
);

Add a comma after the last MAG_word, a line return, and the new magic word:

   MAG_CURRENTWEEK

Save and close /wiki/includes/MagicWords.php.

Now you will need to edit /wiki/includes/Parser.php. You will need to find the getVariableValue function. In this function you want to add a new case to the select list. Choose a position in the select and insert:

case MAG_CURRENTWEEK:
   return $varCache[$index] = $wgContLang->formatNum( date('W') );

A short explanation of what this does is in order. This will put the week of the year into the variable. This value will be from 1 to 54. Yes, there are only 52 weeks, plus one or two days, in a year. However, according to the ISO 8601 standard for week numbering, yearly weeks begin on Monday, so if the first day of the year is Sunday, that will be week number 1, and the next day will be week 2, and you will have 53 weeks by the end, and if it just happens to be a Leap Year the year will end on a Monday - making week 54.

Side notes:

  • An ISO week effectively always starts on Monday.
  • However the comment above is wrong about ISO week numbering. In the ISO week numbering system, the first week of the ISO year must contain at least 4 days in the civil year. So whenever a civil year starts on Sunday January 1st, this is the last day of the last week of the previous ISO year. And if a civil year ends on Monday December 31, this is the first day of the first week of the next ISO year.
  • A ISO year contains only complete ISO weeks (from Monday to Sunday): the first ISO week of a ISO year starts on Monday, between December 29 of the previous civil year and January 4 of the current civil year. The last ISO week of the ISO year terminates on Sunday, between December 28 in the current civil year and January 3 of the next civil year.
  • A ISO year can then count a total of either 364 or 371 days (both cases can then occur in leap or non-leap years). So in the ISO week numbering system, weeks can then effectively be numbered from 1 to 53 only (there's no week 54 in ISO years).
  • This all means that January 1st is part of ISO week number 1 only if it falls on a Monday, Tuesday, Wednesday or Thursday, otherwise January 1st is counted as part of the last week of the previous civil and ISO year. December 31 is part of the last week of the current year only if it falls on Thursday, Friday, Saturday or Sunday, otherwise December 31 will be counted as part of the next civil and ISO year.
  • To define a week precisely within the same civil year, it is then necessary to specify the ISO year number which may differ (between December 28 and January 3) from the civil year by 1. Then, any date can be fully specified by this ISO year, the ISO week number (from 1 to 52 or 53, depending on year), and the day of week (from Monday to Sunday).
  • Alternatively, any date can be fully specified by the ISO year and the ISO day of year (between 1 and 364 or 371, depending on the year), where the ISO day of year 1 is always a Monday (the conversion from a ISO day of year to the ISO week number and day of week is independant of the year; the same is true for the reverse conversion).

Save and close /wiki/includes/Parser.php.

The final file you will need to edit is /wiki/languages/Language.php. Note the different directory. You will need to locate the $wgMagicWordsEn array, and insert a new line:

   MAG_CURRENTWEEK          => array( 1,    'CURRENTWEEK'            ),

If you are adding the new line to the end of the list, remember to make sure there is a comma at the end of the line above your new line, and that there is not a comma at the end of your new line.

Save and close /wiki/languages/Language.php.

Be sure to test your changes before adding them to the live version.

[edit] How do I change the contents of the navigation toolbar?

The solution is different between MediaWiki versions.

If the page doesn't change in the desired way after applying the changes, just point your browser to http://yoursite.tld/index.php/MainPage?action=purge. Notice the "action=purge"-Part which clears the webpage cache.

[edit] Changing the files (php-installation-files)

[edit] General notes

Every link in the navigation box is specified in two parts - the text, and the target. Each of these is stored in an interface message; that is, a page in the MediaWiki namespace (in most situations, editting the LanguageXX.php files will have no effect on a running wiki).

  • if the content of the "target" message is a full URL (i.e. begins http://, etc), the result will be an external link equivalent to [<target> <text>]
  • otherwise, the target will be interpreted as the name of a wiki page, and the link will be the equivalent of an internal link like [[<target>|<text>]]

You do not need to edit any PHP files to change the text or target of existing links, you need only find and edit the appropriate MediaWiki:<whatever> pages. (Note: This way you can only edit preconfigured variables. You are not totally enabled to edit the navigation-bar)

[edit] In version 1.5

Follow instructions as per 1.4, except that instead of working with the files LocalSettings.php and DefaultSettings.php, the list is held in the [[MediaWiki:Sidebar]] page. You have to be logged into the Wiki with an adminstrator account change these pages.

The default should be:

* navigation
** mainpage|mainpage
** portal-url|portal
** currentevents-url|currentevents
** recentchanges-url|recentchanges
** randompage-url|randompage
** helppage|help
** sitesupport-url|sitesupport
[edit] In version 1.4
[edit] How the navigation bar is rendered

Wiki2.png

The rendering of one of the stock items, the Community portal of the english wiki, in the 4array:

  1. (In blue) The key for the visible text is fetched from the MediaWiki namespace
  2. (In blue) The text under that key is placed in the navigation bar.
  3. (In red) The target page or URL for the link is also fetched from the Mediawiki namespace.
  4. (In red) The text from the "href" key is the link for the entry in the navigation bar.
[edit] How to customize your own navigation bar

The list of pages is defined in an array called $wgNavigationLinks; copy the entire array from includes/DefaultSettings.php to /LocalSettings.php if you wish to edit it (never edit DefaultSettings.php itself). The default array looks like this:

$wgNavigationLinks = array (
        array( 'text'=>'mainpage',   'href'=>'mainpage' ),
        array( 'text'=>'portal',     'href'=>'portal-url' ),
        array( 'text'=>'currentevents', 'href'=>'currentevents-url' ),
        array( 'text'=>'recentchanges', 'href'=>'recentchanges-url' ),
        array( 'text'=>'randompage', 'href'=>'randompage-url' ),
        array( 'text'=>'help',               'href'=>'helppage' ),
        array( 'text'=>'sitesupport',        'href'=>'sitesupport-url' ),
);

Each line of this array represents a link in the navigation box; remember that these are pointers into the database, not the actual text used.

  • To edit a link: you do not need to copy and edit the $wgNavigationLinks array; simply find the appropriate pages, such as MediaWiki:portal and MediaWiki:portal-url, and edit them while logged in with "sysop" privileges. The page Special:Allmessages can be useful for finding these and other editable interface elements.
  • To remove a link: copy the array as described above, and simply delete the appropriate line.
  • To add a new link:
    1. add a line of the form array( 'text'=>'something', 'href'=>'something-url' ),; "something" (Blue in the illustration above) and "something-url" (Red in the illustration above) can be whatever you like, and should be something you will remember and recognise later.
    2. edit (create) the pages MediaWiki:something (Blue above) and MediaWiki:something-url (Red above) in your wiki, substituting the names you chose at step 1 (the "MediaWiki:" part refers to the MediaWiki namespace; whatever names you chose at step 1, the pages to edit will be of the form "[[MediaWiki:<your name here>]]"). The first should contain whatever you want the link's text to be (e.g. "Donate") (Blue above), and the second either the name of a wiki page (e.g. "Project:Get in touch") or the full URL of an external document (e.g. "http://example.com/feedbackform.php"). Make sure that if you are linking to a wiki page that you put the name of the page, not a link to that page (no double brackets) or you will end up with a link to an error message (error: link target missing) when the Quickbar is rendered, rather than a link to the intended page.

Edited robbr 8/11/05 - colour references were incorrect

Remember: if your changes don't show up, remember to clear/by-pass your browser cache. Also you must not have $wgUseMemCached set to true, having this set will cause these links to not work.

[edit] In version 1.3 or earlier

In versions earlier than 1.4, there is no simple way to add a new link to the navigation bar. However, the existing links in version 1.3 behave in the same way as described - they are composed from two pages in the MediaWiki namespace.

  • To edit a link: find the appropriate "message" (page in your wiki), for instance by looking at your Special:Allmessages page, and make your changes. For instance, the "Community Portal" link has the text of MediaWiki:Portal, and the target found in MediaWiki:Portal-url; similarly, MediaWiki:Sitesupport and MediaWiki:Sitesupport-url, and others. The target can be either internal (just the name of a wiki page) or external (a full URL, beginning http:// etc).
  • To remove (hide) a link: set the text of the link to "-" (a single hyphen, without the quotes); e.g. if MediaWiki:portal contained only "-", no "Community portal" link would appear.

Remember: if your changes don't show up, remember to clear/by-pass your browser cache.

[edit] Using a wikipage as a source for a navigation bar

Sometimes even the navigation-bars should be available for editing by a normal user, who has no access to the PHP-scripts working in the background. A solution for this approach is to include a defined pagename. The advice below uses the namespace "MediaWiki" and the "function msgWiki( $str )", located in "include/SkinTemplate.php". That function renders a pagename within the MediaWiki-namespace to HTML. Within other skins, not using "SkinTemplate.php" this is not working.

[edit] MonoBook (MediaWiki 1.44)

You have to modify the file skin/MonoBook.php This advice works only with the Skin MonoBook

  • Fill this article/wikipage with content (MediaWiki-Markup-Style) like:
  * [[an internal link]]
  * [[another internal link]]
  * [http://www.Link.de a external http-link]
  • open the file skins/Monobook.php
  • look for:
  <h5><?php $this->msg('navigation') ?></h5>
    <div class="pBody">
      <ul>
        <?php foreach($this->data['navigation_urls'] as $navlink) { ?>
        <li id="<?php echo htmlspecialchars($navlink['id'])
        ?>"><a href="<?php echo htmlspecialchars($navlink['href']) ?>"><?php 
        echo htmlspecialchars($navlink['text']) ?></a></li><?php } ?>
      </ul>
    </div>
  • replace the lines:
      <ul>
        <?php foreach($this->data['navigation_urls'] as $navlink) { ?>
        <li id="<?php echo htmlspecialchars($navlink['id'])
        ?>"><a href="<?php echo htmlspecialchars($navlink['href']) ?>"><?php 
        echo htmlspecialchars($navlink['text']) ?></a></li><?php } ?>
      </ul>

with:

      <?php $this->msgWiki( 'MenuNavigation' ) ?>
  • The result should look like this:
  <h5><?php $this->msg('navigation') ?></h5>
    <div class="pBody">
      <?php $this->msgWiki( 'MenuNavigation' ) ?>
    </div>
  • You can add further navigations-blocks the same way.

HeinzJo 20:39, 12 Jun 2005 (UTC)

[edit] How do I create a small wiki farm?

After copying the mediawiki source tree in /opt/mediawiki/ you need to run something like:

 mkdir .../wiki
 cd .../wiki
 mkdir images
 ln -s /opt/mediawiki/languages /opt/mediawiki/maintenance \
   /opt/mediawiki/skins /opt/mediawiki/redirect.php .
 cp -a /opt/mediawiki/config/ .
 chown www-data: config/
 cp /opt/mediawiki/index.php index.php

Then add /opt/mediawiki to the commands which set the include_path in config/index.php and add something like this to the main index.php:

 ini_set( "include_path", "/opt/mediawiki:." ); # line added
 require_once( 'includes/Defines.php' ); # this line used to include './includes/Defines.php'
  • make sure your webserver can read from /opt/mediawiki

You may also want to visit this link for further information about standarising the log in for users across multiple wikis.

You can also look at the (rather complex) setup wikimedia is using

[edit] How do I add w:Metatags

The page includes\OutputPage.php defines within the function addMetaTags () the output of metatags. This function can be used to define further metatags.

The existing command $wgOut->addMeta ( 'KEYWORDS' , $a.) ; can be added by further keywords just by adding a dot and a comma sperated list. The change would look something like

$wgOut->addMeta ( 'KEYWORDS' , $a.', your Keywords, Comma seperated') ;

Additional Metatags can be added too.

Just add further lines as last lines of the function addMetaTags() like:

$wgOut->addMeta ( 'LANGUAGE' , 'de') ;

HeinzJo 18:53, 14 Jun 2005 (UTC)

This solution can be used to add the same keywords to each page. How can we add specific keywords to specific pages?

Should not we define a MediaWiki tag, in the page, to define the keywords?

We currently have the opportunity to add comments, which are not displayed: Maybe a special comment could be detected by the engine and used to fill the string this->Keywords.

Any idea?

Jean-Dom 20:01, 9 Aug 2005 (UTC)

I am also interested in the ability to allow users to insert metatags into a page when they edit it. Has any thought been given to the above question?

Pekadad 15:55, 30 November 2005 (UTC)

[edit] How do I add search-engines to the Search-Results for further investigations

  • Fill that page with content e.g.:
    * [http://groups.google.de/groups?q=$1&hl=de alle '''Google Newsgroups''' nach "$1" durchsuchen] 
    

    Important is the variable $1. It is the content of searched words.
  • Open the PHP-file "SpecialSearch.php" within the subdirectory "includes" of the MediaWiki-installationsdirectory.
  • Find the function "function goResult( $term )"
  • Insert at the end before the last line:
    $wgOut->addWikiText( '<p>' . wfMsg('SearchInSearchEngines', $term ) . "</p>\n" );
    
  • Do the same with function: "function showResults( $term )"
  • Enhancements: Handling empty spaces.

[edit] How do I reset the popular page counters

In <= 1.4:
 UPDATE cur SET cur_counter=0;
In >= 1.5:
 UPDATE page SET page_counter=0;

[edit] How do I create a custom namespace?

See Help:Custom namespaces

[edit] How do I see a list of users watching a page?

You can't, mainly because watchlists are considered to be more or less "private" information. Obviously, the information's in the database if you wanted to hack up an extension to do it, but there's no in-built facility for it.

Remark: EnotifWiki indicates the number of watching users in Recent Changes views.

[edit] How do I modify the search-engine to search also all 'sister' projects?

[edit] 用戶管理

[edit] Basic User Account Management?

As a sysop, how do I see basic information about users like username, realname, email? How do I find the ip of a user for previous edits? What is the best way to roll back a users edits globally?

[edit] How do I change a user's password?

Assuming that $wgPasswordSalt is set to true (the default), you can use the following SQL query:

UPDATE user SET user_password = MD5(CONCAT(user_id, '-', 
  MD5('somepass'))) WHERE user_name = 'someuser';

Where obviously "somepass" is changed to the password you want to set and "someuser" is changed to the user name as it is listed in the table "user".

[edit] User forgot his/her password, has no e-mail address

Let the user step through a "mail me a temporary password" cycle with a working e-mail address of her discretion, which you temporarily enter into her user account record.

You need to have

(a) access to the Wiki database (table user) and
(b) a working e-mail system

Check requirement (b) by mailing yourself a temporary password via the login screen button. Make sure, that you have set up correctly your own e-mail address.

  1. As WikiSysop you enter temporarily user's e-mail address into user account in db table user.
  2. Tell the user to click "Mail me a temporary password" on the wiki login screen
  3. S/he will receive a temporary password soon
  4. S/he can now login with the password and
  5. S/he now must set up a new password for her/his account

The trick also overcomes any problem with salted or unsalted passwords.

[edit] How do I allow only logged-in users to edit?

See Setting user rights in MediaWiki for questions relating to user rights.

For 1.5.1 or later: To stop people from creating accounts and/or anonymously editing pages, in the LocalSettings.php, add either of these 2 lines:

   // Only SysOp (Admin) can create accounts -
   $wgGroupPermissions['*']['createaccount'] = false;

or

   // No anonymous editing allowed -
   $wgGroupPermissions['*']['edit'] = false;

Pre 1.5.1: Add this in LocalSettings.php:

$wgWhitelistEdit = true;

[edit] How do I require an email address be specified at registration?

[edit] 如何只让授权用户访问页面?

有两个扩展(hack)可以达到目的,参见页面权限控制(MediaWiki扩展)以及隐藏页面(MediaWiki扩展)

另外,可以使用本地wiki的mediawiki访问权限设置

[edit] How do I reassign edits from one user to another?

cd <path to mediawiki>/maintenance
php ./attribute.php OldUserNameOrIP NewUserName
mysql <./attribute.sql

[edit] 如何把一个用户设定为管理员?

前往: Special:Userrights页面 输入用户名. 点击"sysop" 从"Available groups" 列表里. 只有具有"Bureaucrat" 权的用户才能设定管理员.

[edit] 如何解除一个用户的管理员权限?

see Setting_user_rights_in_MediaWiki

[edit] How do I manage user rights and groups?

see Setting_user_rights_in_MediaWiki (version 1.4 and older) or Help:User rights (version 1.5 and newer).

[edit] How do I allow any user to edit but the edited pages only updated on wiki after being approved by moderators?

Add the appropriate functionality to the code. ;p There is no way of doing this with the current software, although if written well it could prove a useful alternative for page protection.

[edit] How do I edit the Log in page to add a question so that only people with the correct answer are allowed to create a new account?

Add the functionality to the code, as shown above. There is no other way with the current software.

See FxParlant CAPTCHA to learn how to add a CAPTCHA capability, requiring that users correctly interpret a visual image.

[edit] How do I delete a user from my list of users?

MediaWiki does not support the deletion of user accounts. To prevent an account from being used, either scramble the password or set up an indefinite block on the account.

Do not remove users from the user table in the mySQL database; this causes problems with other parts of the wiki due to the relational structure of the database.

[edit] But can I rename the user, then?

Deleting the user is not strictly necessary, but it would help to be able to rename it to something neutral. Is it possible to change the username to something else?

In MediaWiki 1.5, bureaucrats can rename users directly in the wiki with the Renameuser extension installed. In previous versions, it required direct manipulation of the database:

update low_priority user set user_name='NewUsername' where user_name='OldUsername';
update low_priority user_newtalk set user_ip='NewUsername' where user_ip='OldUsername';
update low_priority cur set cur_user_text='NewUsername' where cur_user_text='OldUsername';
update low_priority old set old_user_text='NewUsername' where old_user_text='OldUsername';
update low_priority archive set ar_user_text='NewUsername' where ar_user_text='OldUsername';
update low_priority ipblocks set ipb_address='NewUsername' where ipb_address='OldUsername';
update low_priority image set img_user_text='NewUsername' where img_user_text='OldUsername';
update low_priority oldimage set oi_user_text='NewUsername' where oi_user_text='OldUsername';
update low_priority recentchanges set rc_user_text='NewUsername' where rc_user_text='OldUsername';

[edit] How do I change the name of the default administrator?

Instead of changing the name of the administrator, create a new user with the desired name, and assign sysop privileges to that user with Special:Userrights (1.5 and later), or Special:Makesysop (pre-1.5).

If this is to be your primary account on the wiki, you may want to consider assigning the bureaucrat privilege as well.

[edit] How do I assign a username to an IP address?

(Question asked by Blueeyor on 20:06, 25 Apr 2005 (UTC))

You can't have a specific IP become a specific user. You can check the "remember me" box.

If you want all the edits of one IP to be attributed to an user, see How do I reassign edits from one user to another? above.

[edit] How do I change an edit history from an IP address to a userID?

(Question asked by Blueeyor on 20:06, 25 Apr 2005 (UTC))

See How do I reassign edits from one user to another? above.

[edit] How do I make a page only viewable by a WikiSysop or Bureaucrat or a particular user?

(Question asked by Wiseleyb 26 Apr 2005)

There are three hacks (patches) for this. See Page access restriction with MediaWiki, Hidden pages and Regular expressions for wgWhitelistRead.

[edit] How to add a new user when anonymous wiki access is not allowed?

Login as a sysop then use the special page: Special:Userlogin to add the new user account.

[edit] How do I restrict User:<username> page to be edited by only <username> and Sysop?

[edit] How do I add multiple user accounts?

Login as a sysop then use the special page: Special:Userlogin to add the new user account.

[edit] How do I edit error messages?

[edit] 我想幫助開發更多MediaWiki, 我如何入手?

參見:怎樣成為MediaWiki黑客(英文) ?

[edit] How can I recover the SearchIndex Table?

When I try to repair it with phpmyadmin utilities it seems to be in use and nothing can be do with it.

Thanks for your attention and help

................

The SearchIndex table appears to break occassionally when any page in the wiki is edited and saved. Using the repair option in PhpMyAdmin seems to fix the table.

[edit] 我可以把其他wiki的資料/模板以實時更新插入在我的wiki頁面內顯示嗎?

If I want to put info in my wiki from Wikipedia (eg a template such as below) without copying all the data, eg. templates, variables, images etc. etc. to my wiki can I just 'link' to the other wiki (eg. Wikipedia) in real time as my page loads?

比喻我想把維基百科姊姊計劃題示在我的首頁上, 效果如維基百科上首頁一樣, 我如何做呢...

Personal tools

Variants
Actions
Navigation
Community
Beyond the Web
Print/export
Toolbox