administrators (basic)
Unfortunately, the open-editability of many wiki systems often makes them attractive targets for “link spam” or “wikispam”, in which links are added to pages in an effort to increase search engine rankings or drive traffic to other sites. Also, many link spammers have developed automated systems to locate sites that accept visitor input and attempt to flood the site with unwanted links. Also, and harder to deal with, is just plain wiki vandalism where nonsense changes are made often replacing entire pages.
By far the best countermeasure against wikispam is to restrict editing through the use of passwords (see Passwords and Passwords Admin). Experience has shown that passwords can be effective even if the password is widely known, and even if the password is publicly available on the site itself. However, there are many cases where passwording may be an impediment, so these will generally want to use some form of blocklist.
A blocklist is a list of IP addresses, phrases, and expressions which are prevented from being added into pages on the website. PmWiki is distributed with a built-in blocklisting capability; blocklists can be enabled by adding the following line to local/config.php:
$EnableBlocklist = 1;
This tells PmWiki to scan the Site.Blocklist? page and the “Site.Blocklist-Farm” page (and possibly other pages — see below) looking for phrases and IP addresses to be excluded from posting to the site.
Blocking by word or phrase: The simplest form of block is simply a line containing “block:
” followed by a word or phrase to be excluded from postings. For example, a line like
block: spam.com
in Site.Blocklist will block any posts containing the string “spam.com” (case-insensitive) anywhere in the post.
Blocking by IP address: Sometimes we wish to restrict posts coming from particular addresses or address ranges that are known as sources of wikispam. If a blocklist page contains IP addresses of the form “a.b.c.d” or “a.b.c.*”, then any posts coming from that address or range will be blocked.
Blocking by regular expression or pattern: Blocking on simple words can sometimes pose difficulties; for example, a simple “block: cialis
” entry will also block the word “specialist”. For these cases it’s often helpful to use a regular expression, as in:
block: /\bcialis\b/
This says to block “cialis” only if it doesn’t occur in the middle of a larger word. The leading slash (/) after “block:” tells PmWiki to use a regular expression match instead of a simple string match. (Blocklist uses PCRE or “Perl Compatible Regular Expressions”; see http://www.php.net/manual/en/ref.pcre.php for more information.)
There are 2 formats for blocklists. Regular Expression type and PM Wiki? type.
Block entries coming from Moin Master? and Chongqed are all regular expressions, and the blocklist.php file knows that because it sets ‘format’=>’regex’ for those download types. Thus an entry in one of these blocklists that looks like
\.uni\.ch
is the same as if one had specified in Site.Blocklist?:
block: /\.uni\.ch/
Thus, to unblock this, one has to use “unblock: /\.uni\.ch/
”.
For PmWiki-formatted blocklists, it’s the presence or absence // of a leading slash that determines the type of blocking:
block: word or phrase block: /regex/
By default, blocklist only tells an author that a particular edit has been blocked, but doesn’t give a specific reason for the blocking (e.g., the offending phrase). Setting the following in a local customization file will also provide the reasons for the block:
$EnableWhyBlocked = 1;
PmWiki allows blocklist entries to come from multiple pages by setting the $BlocklistPages variable. By default $BlocklistPages is set to “Site.Blocklist”, as well as any automatically downloaded blocklists as described below. PM Wiki? will use all entries in all the blocklists for filtering wikispam. Setting a value of $BlocklistPages changes the default:
$BlocklistPages = array(‘Main.Blocklist’, ‘PmWiki.Blocklist’);
The order of blocklists really doesn’t matter — all of the blocklist
pages ultimately get used, and the unblock:
entries are processed
after all of the blocklist pages have been loaded.
A blocklist can be applied farm-wide (See SharedPages?). After these pages are created they can be moved into the farm shared.d/ directory:
Site.Blocklist-Chongqed (pmwiki can create & auto update) Site.Blocklist-MoinMaster (pmwiki can create & auto update) Site.Blocklist-PmWiki (pmwiki can create & auto update) Site.Blocklist-Farm (admin creates, admin/users maintain)
The local wiki admin/user maintain Site.Blocklist
.
Maintaining blocklists is relatively easy to do, but can become tedious over time. Several groups have formed and maintain “shared blocklists”, where a common blocklist is made available to all. PmWiki’s blocklist capability has built-in features for automatically downloading and updating such shared blocklists.
If you’re just in a hurry to make use of some standard blocklists, make the following setting in local/config.php:
$EnableBlocklist = 10;
This tells PmWiki to not only enable blocklists on the site, but to also configure itself to automatically retrieve and maintain local copies of well-known blocklists such as chongqed.org and MoinMaster. These local copies will be saved in Site.Blocklist-Chonged and Site.Blocklist-Moin Master? and refreshed once per day (as determined by the value of $BlocklistDownloadRefresh).
To automatically retrieve Site.Blocklist page used at pmwiki.org, add the following setting in local/config.php:
$BlocklistDownload['Site.Blocklist-PmWiki'] = array('format' => 'pmwiki');
For detailed configuration of automatically downloaded blocklists, use the $BlocklistDownload array. An entry for Moin Master? might look like:
$BlocklistDownload[‘Site.Blocklist-Moin Master?’] = array( ‘url’ => ‘http://moinmaster.wikiwikiweb.de/BadContent?action=raw’, ‘format’ => ‘regex’, ‘refresh’ => 86400);
This says to download the blocklist data from the given url into the Site.Blocklist-Moin Master? page, that the entries in the blocklist are regular expressions, and to refresh the information every 86,400 seconds (one day).
If ‘refresh’ is omitted, then the page will be refreshed at the time interval given by $BlocklistDownloadRefresh (default one day). If ‘format’ is omitted, the page is assumed to have PmWiki-formatted entries as described above. If ‘url’ is omitted, then the blocklist information is downloaded from a standard location on the pmwiki.org site.
To force a refresh of an automatically downloaded blocklist, simply delete the existing page — a new version will be installed upon the next blocklist scan. Blocklist pages are checked for download in response to any ?action=edit request.
When using a large master blocklist or blocklists automatically refreshed from external sites, it may be that some entries in the blocklists are inappropriate or overeager and block legitimate content. In this case a wikiadministrator can use “unblock” in a blocklist page to ignore an entry from the blocklist. For example, to allow “spam.com” even if another blocklist has a block entry for it:
unblock: spam.com
In order for unblocking to work the phrase or pattern following “unblock:” must be exactly the same as the original.
In general, a administrator will want to edit-protect the Site.Blocklist and any other blocklist pages to prevent arbitrary changes to the blocklist (see Passwords). Since most pages in the Site.* group are edit-protected by default anyway, this usually isn’t a problem.
Administrators may also wish to read-protect the various blocklist pages so that others do not know the exact phrases and/or IP addresses that are being blocked. (By their nature blocklists tend to contain phrases or terms that may be offensive or inappropriate to some.)
Any pages created via automatic download (see above) are automatically locked against viewing except by administrators.
« Basic Variables | Variables | Debug Variables »
The following variables help control the configuration and operation of blocklists:
$EnableBlocklist = 1; # enable blocklists $EnableBlocklist = 10; # auto-configure standard blocklists
$EnableWhyBlocked = 1; # give reasons for blocking
$BlockedMessagesFmt[‘ip’] = “IP address blocked from posting: “; $BlockedMessagesFmt[‘text’] = “Text blocked from posting: “;
# Download the MoinMaster blocklist every twelve hours $BlocklistDownload['Site.Blocklist-MoinMaster'] = array( 'url' => 'http://moinmaster.wikiwikiweb.de/BadContent?action=raw', 'format' => 'regex', 'refresh' => 43200); # Download a shared blocklist from pmwiki.org every day $BlocklistDownload['Site.Blocklist-Shared'] = array( 'format' => 'pmwiki');
# perform automatic downloads once per week by default $BlocklistDownloadRefresh = 86400 * 7;
# perform immediate checks for ?action=comment $BlocklistActions[‘comment’] = 1; # perform immediate checks for ?action=postdata $BlocklistActions[‘postdata’] = 1;