i want to allow users to filter their login based on their ip address (a new settings in the user preferences i will implement).
so if a user with a specific ip login and there is not restriction, the login is successful.
in any other case i was thinking this
if the user choose his full IP like 67.31.85.47 and he has this IP then the login is good
if a user choose 67.31.85.* and has this IP then the login is good
if a user choose 67.31.. and has this IP then the login is good
if a user choose 67...* and has this IP then the login is good
any other case it’s invalid
the user can choose up to 5 IP restrictions. eg:
67.31.*.*
167.77.47.*
62.11.28.28
25.57.*.*
169.*.*.*
i was tinking to strip the IP using explode and then compared to all restrictions he setup.
this can be slow since i have to check 5 times * 4 (4 = IP exploded on the dot)
is there a faster way to do it?
thanks
will output:
If you are looking for specific ip (no wild card) checking, you can use:
var_dump(is_private_ip(‘82.237.3.3’));
var_dump(is_private_ip(‘748.1234.5.4’));