rah_ip_range

Published under current TXP projects

Elegant Textpattern CMS plugin for blocking and allowing visitors based on their IP. You can define an IP range, and what to do to those whose IP is within the range; either allow, or the opposite, deny access to the page content. Powered by a single little tag.

Download rah_ip_range v0.3

Image: rah_ip_range

Image: rah_ip_range

List of features

Attributes

The tag is <txp:rah_ip_range /> attributes for it follow. Use the tag on places (pages/forms/sections) which you want to restrict from specific visitors.

message
Error message shown to blocked visitors. Message can be shown with the <txp:error_message /> tag. If the tag is used as a container, the message is shown instead of the contained content to the blocked users.
Default: message="Access denied" Example: "Sorry, we can not do that."

status
HTTP error status code returned to blocked visitors. The preferences will be ignored when the tag is used as a container.
Default: status="503" Example: "200"

fromip
IP-range’s starting IP (or partial IP). Default is unset.
Default: fromip="" Example: "127.0.0.1"

toip
IP-range’s ending IP (or partial IP). Default is unset.
Default: toip="" Example: "127.0.0.100"

method
Sets what to do to the visitor when IP is within the range. Either deny or allow. When set to deny, all visitors within the range are blocked, and others outside the range are allowed to see the content. Value allow is opposite to the deny.
Default: method="allow" Example: "deny"

Examples

Example #1: Using the self-closing single tag.

<txp:rah_ip_range fromip="127.0.0.1" toip="127.0.0.100" method="deny" />

Visitors within the range 127.0.0.1-127.0.0.100 are blocked will see an error page.

Example #2: Using the tags as a container.

Important link:
<txp:rah_ip_range fromip="127.0.0.1" toip="127.0.0.100" method="allow" message="Link is hidden.">
	<a href="http://example.com">Click here</a>.
</txp:rah_ip_range>

Visitors within the range 127.0.0.1-127.0.0.100 will see an important link, while others won’t. Instead they are treated with “Link is hidden.” message where the link should be.

Changelog

Version 0.3

Version 0.2

Version 0.1