Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#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

#2 2008-10-31 03:12:40

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: Allow IP range(s)

Maybe plugin can help? rah_ip_range

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

#4 2008-10-31 17:57:54

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: Allow IP range(s)

Nikolaos wrote:

Thanks you Jukka!! For both your yesterday reply (which make the php code functional) and for your new plugin!!

Heh, no problem :-)

Last edited by Gocom (2008-10-31 17:58:05)

Offline

Board footer

Powered by FluxBB