Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2011-06-25 22:20:02

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: rah_ip_range

Bill Grimm wrote:

I’d like to be able to use a conditional to determine whether or not to display the form’s contents to a user based on their ip.

Thank you for the suggestion :) Just released v0.2 adds “container tag” feature. When the tag is used as a container, the contained content is hidden from blocked visitors.

More info and downloads

Offline

#14 2011-06-26 02:55:46

Bill Grimm
New Member
From: Colorado
Registered: 2010-01-25
Posts: 8

Re: rah_ip_range

That’s exactly what I was after! You are a genius. Thank you.

Offline

#15 2011-06-29 04:19:35

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: rah_ip_range

v0.3 released, small tweaks. Changes:

  • Changed: parsing contents of message isn’t needed. Parser’s straight quote feature can be used instead.
  • Changed: pass parameters to txp_die() as strings instead of an array.

More info and downloads

Offline

#16 2011-07-08 15:56:20

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,007
Website GitHub Mastodon Twitter

Re: rah_ip_range

I was looking for a way to serve country specific content (especially for visitors from the US) and thought that this plugin might do it

Something like your example:

<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>

The problem of course is that I checked the ip ranges for the US and it comes to 21,596 lines so I was wondering if there was a better method.

Last edited by colak (2011-07-08 15:59:32)


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#17 2011-07-08 17:25:54

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: rah_ip_range

colak wrote:

The problem of course is that I checked the ip ranges for the US and it comes to 21,596 lines so I was wondering if there was a better method.

Accurate better method? Not really. If you really want to restrict content based on the visitor’s region, your best option is to use GeoIP database.

From usability and resource use wise you probably shouldn’t do that with Textpattern tags tho. But instead by using PHP library or extension. Like the one offered by MaxMind. Yes, you could use rah_ip_range, but it wouldn’t be optimal.

If the idea is just to show just optional content, not restrict users, you could also use the information provided by the visitor’s browser. You won’t be able to restrict users, but you could show preferred content.

If you end up going with MaxMind or similar DB/library, just install the library, and look at the examples. For example in case of MaxMind, after you have installed it, you could run the detection function it comes with and return the output to a TXP’s variable. From there on if_variable conditions could be used to return country specific content. Something like:

<!--
	Store the visitors country in variable named 'county'
-->

<txp:php>
	global $variable;
	include("geoip.inc");
	$gi = geoip_open("/usr/local/share/GeoIP/GeoIP.dat",GEOIP_STANDARD);
	$variable['country'] = geoip_country_code_by_addr($gi, remote_addr());
</txp:php>

<!--
	Output visitors country
-->

<txp:variable name="country" />

Untested, and I’ve never used the tools provided by MaxMind, no idea if it even works. All based on what they say. To make the code work, you likely will need to change the paths at least.

Offline

#18 2011-07-08 19:12:54

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,007
Website GitHub Mastodon Twitter

Re: rah_ip_range

Hey Jukka

That looks simple enough…

Will upload and check… Thanks once again!


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#19 2012-07-13 04:23:47

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: rah_ip_range

Rah_ip_range v0.4 is available. Changes:

  • Added: else (<txp:else />) tag support for container mode.
  • Changed: default HTTP status to 403 Forbidden from 503 Service Unavailable.
  • Changed: default message to Forbidden., 403_forbidden l18n string.
  • Changed: message attribute doesn’t apply when tag is used as a container, instead of else can be used.

More info and downloads

Offline

#20 2015-07-29 09:23:50

Karsten
Member
From: Leiden, Netherlands
Registered: 2011-04-24
Posts: 47
Website

Re: rah_ip_range

Love the plugin, thanks for that.

Is there any convient way to allow access to a particular message to a series of different IP ranges? As I understand it correctly I now have to use the plugin to allow access to IP range 1, add the content, close the tag, and subsequently allow access to IP range 2, copy-paste the same contant, close the tag, and so forth.

It would be great if the plugin would allow for multiple IP ranges to be entered who would get access to the restricted content.

In my case I want to allow access to content to friend/member networks, all of whose users should have access to the otherwise restricted content. Hence a number of different IP ranges should have access to the same content.

If this could be possible in the future that would be great. If it is already possible, but I’m unable to figure it out, any tips would be much appreciated!

Thanks

Offline

Board footer

Powered by FluxBB