## Using urlapprove.php

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

• requiring approval of Internet sites before a link to them are created in the wiki, and
• allowing you to limit the number of unapproved links that may be added to a page.

To enable urlapprove.php, add the following line to a configuration file:

include_once('scripts/urlapprove.php');

By default, unapproved links display a (approve sites) link instead of the unapproved link. A click on the link will approve all unapproved URLs on the page, but only if you are authorized to edit the Site.ApprovedUrls page. You may also pre-approve sites by by adding them to the Site.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:

$UnapprovedLinkCountMax = 5; include_once('scripts/urlapprove.php'); Note that$UnapprovedLinkCountMax must be set before including the urlapprove.php script.

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>";  If you wish to totally forbid unapproved links you can use $UnapprovedLinkFmt = "<b>external link not allowed</b>";

# SideBar caveat

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.

## Technical tips

Urls are approved by adding them to a "white list", defined in the variable $WhiteUrlPatterns, which is set in the local/config.php file. To add multiples urls, use the separator | (vertical bar). For example: $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';


If you want to change the default name of this Site.ApprovedUrls write in local/config.php (after the script inclusion line):

$ApprovedUrlPagesFmt = array('OtherGroup.OtherName'); Generally, it might be array('$DefaultGroup.ApprovedUrls');

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