This page explains how to discourage "link spamming" on your wiki site using PmWiki's urlapprove.php script. This script is already included in PmWiki files, but not activated by default.
Occasionally spammers may try to add large number of (sometimes hidden) URLs to pages because they think it will improve their search engine rankings -- which it probably won't. The urlapprove.php script works against these spammers' purpose by
To enable urlapprove.php, add the following line to a configuration file:
By default, unapproved links display what ever should be displayed normally (the URL or a text), but not linked and next to it a link (approve sites). A click on the link will approve all unapproved URLs on the page, but only if you are authorized to edit the SiteAdmin.ApprovedUrls page. You may also pre-approve sites by by adding them to the SiteAdmin.ApprovedUrls? page.
Limiting unapproved urls per page
You can limit the number of unapproved links per page. If the limit is exceeded, the page cannot be saved. This is useful because spammers like to write long link lists, which is rare for normal authors.
Example: To set the limit to 5 unapproved links, add the following line to a configuration file:
Note that $UnapprovedLinkCountMax must be set before including the urlapprove.php script.
Handling of Unapproved Links
You can also change the disapproval message defined in the $UnapprovedLinkFmt variable, for example:
include_once('scripts/urlapprove.php'); $UnapprovedLinkFmt = "[$[Link requires approval]]<a class='apprlink' href='\$PageUrl?action=approvesites'>$[(approve)]</a>";
"Link requires approval" is whatever you want to see in place of the unapproved link and "(approve)" is the blue text. Using this feature may prove usefull if you want to always hide the unapproved link.
If you wish to totally forbid unapproved links you can use
Please note that in general you need to go to the sidebar page in order to approve links in the sidebar. The reason for this is that the approve mechanism only approves links on the current page.
After initial setup all existing links become unapproved. To find out which pages are affected one can use an RSS feed on AllRecentChanges. All pages with unapproved links will show up there. Please can someone explain this in more detail?
Urls can also be approved by adding them to a "white list",
defined in the variable
$WhiteUrlPatterns = "http://example.com/|http://example.net/|http://example.org/";
To add all urls from, say New Zealand and Australia, use:
$WhiteUrlPatterns = 'http://[^/] \\.nz'; $WhiteUrlPatterns = 'http://[^/] \\.au';
Change Approved URLs page name
If you want to change the default name of SiteAdmin.ApprovedUrls, set the following in local/config.php:
Previewing the unapproved URL
To see what link is to be approved without editing the page a tool tip can be displayed when the cursor hovers over the (approve Links) link that displays the URL. e.g. Example
Add the following setting in your local/config.php:
$UnapprovedLinkFmt = "\$LinkText<a class='apprlink' href='\$PageUrl?action=approvesites' title='\$LinkUrl'>$[(approve sites)]</a>";
Note that Safari insists on showing only the link on hover, not the "Title" -- I hacked this idea so that people on Safari (me!) can also see the link to be approved by creating a faked variable with my initials and adding it to the variables in the link. Now when I want to approve sites, it shows me the site I'm about to approve in the link text. You can make up your own variable, but make sure it's something PmWiki is unlikely to use. --XES?
$UnapprovedLinkFmt = "\$LinkText<a class='apprlink' href='\$PageUrl?action=approvesites&xes_url=\$LinkUrl' title='\$LinkUrl'>$[(approve sites)]</a>";
By default, PmWiki creates external links that are not followed by search engines. Here are release notes from pmwiki-2.0.beta20 (30-Jan-2005):
Is it possible to, using Per Group Customizations, use $UnapprovedLinkCountMax to apply only to a specific group or page, given the comment about it having to be set prior to including the script and the script being included in the maim ''config.php' which is processed first?