Textpattern Forum

You are not logged in. Register | Login | Help

#11 2008-11-17 15:10:34

kazcor
New Member
Registered: 2008-11-17
Posts: 2

Re: rah_ip_range

Cocom wrote:

Bots do like to make URLs/paths up. Basically the bot might request the URL, but the bot will still see the error page, not the actual article.

Of course, you’re right. I just tried this one with my IP and that’s exactly the way it works. I just was irritated by seeing the correct article URL and return code 200 in my txp log, but that’s of course not a proper indicator in this case as the plugin acts and behaves on a higher application level.

Not sure about MSNbot, but it should honor robots.txt; yes it will visit those pages (so do all other bots too, spam bots are even usually adjusted to try exspecially URLs contained in robots.txt), but it doesn’t index them.

Hmm, I was not aware of this. Thanks for explaining this so detailed :)

Offline

#12 2011-06-25 16:10:54

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

Re: rah_ip_range

Would it be possible to modify this plugin to block just a certain form on a page from a malicious ip, and return an “Access Denied” message rather than using <txp:die>? 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. Thanks for your hard work!

Offline

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

Gocom
Developer
Registered: 2006-07-14
Posts: 4,473
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


Rah-plugins | What? I’m a little confused… again :-) <txp:is_god />

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
Registered: 2006-07-14
Posts: 4,473
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


Rah-plugins | What? I’m a little confused… again :-) <txp:is_god />

Offline

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

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 4,951
Website

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.org | neme-imca.org | hblack.net | LABS

Online

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

Gocom
Developer
Registered: 2006-07-14
Posts: 4,473
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.


Rah-plugins | What? I’m a little confused… again :-) <txp:is_god />

Offline

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

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 4,951
Website

Re: rah_ip_range

Hey Jukka

That looks simple enough…

Will upload and check… Thanks once again!


Yiannis
——————————
neme.org | neme-imca.org | hblack.net | LABS

Online

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

Gocom
Developer
Registered: 2006-07-14
Posts: 4,473
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


Rah-plugins | What? I’m a little confused… again :-) <txp:is_god />

Offline

Board footer

Powered by FluxBB