Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2008-10-30 23:16:20
- Nikolaos
- New Member
- Registered: 2006-11-02
- Posts: 7
Allow IP range(s)
Dear all,
I would like to ask your help and answers for the following question: how can I allow specified IP ranges to access a private section available only for these IPs?
I have a client which is a company (more than 200 employees) that wishes to access the web-site and its information. Obviously I cannot create 200 different users with the use of ign_password_protect. Therefore I believe only a php code in the header of the page allocated in a specified section (i.e name_of_company as Section allocated to a name_of_company Page) which will allow only the company’s IP ranges. Therefore I am thinking to use a variation of the following code:
<code>
//This function returns True if visitor IP within allowed range.
//Otherwise it returns False
function CheckAccess()
{
$fromip = ’127.0.0.1’;
$toip = ’127.0.0.100’;
$ip = ip2long($_SERVER[‘REMOTE_ADDR’]);
return ($ip >= ip2long($fromip) && $ip <= ip2long($toip));
}
</code>
However it seems is not working in the Page and in the section accessed by the Internet. Please do give me a hand of help!!
Thank you in advance.
Offline
Offline
#3 2008-10-31 16:41:32
- Nikolaos
- New Member
- Registered: 2006-11-02
- Posts: 7
Re: Allow IP range(s)
Thanks you Jukka!! For both your yesterday reply (which make the php code functional) and for your new plugin!!
Offline
Offline
Pages: 1