IP Login

Solution for IP ranges with multiple parts different

11 months 1 week ago #73333

Jen Drage's Avatar Jen Drage

Hi,

I noticed that IP ranges like this:

xxx.xx.0.0 - xxx.xx.255.255

Do not work with an IP address which falls within them (eg. xxx.xx.67.197), as the simple php > operator sees this as being higher than the max of the range.

I have fixed this simply by using the php version_compare() function which is seems to be perfect for the job....

So I've replaced the existing $max and $min checks in my version of the plugin with this:

if(version_compare(trim($min), $ip) + version_compare($ip, trim($max)) === -2) {
	return true;
} else return false;

Hope this helps,

Jen

11 months 1 week ago #73337

Peter van Westen's Avatar Peter van Westen Admin

Sorry, but I don't think I quite understand.
Can you give an example of an IP address that is seen as higher than the given max of the range?
So what range are you using and what IP address is giving an issue?

11 months 1 week ago #73338

Peter van Westen's Avatar Peter van Westen Admin

Never mind. I get what you are saying.

It is fixed in latest development release on:
www.regularlabs.com/development-releases

11 months 1 week ago #73339

Jen Drage's Avatar Jen Drage

Great - It's always nice (on the rare occasions) when there is a simple solution isn't it! ;)

11 months 1 week ago #73342

Peter van Westen's Avatar Peter van Westen Admin

Yep, sure is :)
The fix will be included in the next release.