Search
Other IP Login questions
Forum

Solution for IP ranges with multiple parts different

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
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?
Please post a rating at the Joomla! Extensions Directory
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
Please post a rating at the Joomla! Extensions Directory
Jen Drage's Avatar Jen Drage
Great - It's always nice (on the rare occasions) when there is a simple solution isn't it! 😉
Peter van Westen's Avatar Peter van Westen ADMIN
Yep, sure is 🙂
The fix will be included in the next release.
Please post a rating at the Joomla! Extensions Directory
You can only post on the extension support forum if you have an active subscription and you log in

Buy a Pro subscription