homepage Welcome to WebmasterWorld Guest from 54.237.184.242
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Showing login page based on location
geoffb




msg:4134967
 10:27 pm on May 18, 2010 (gmt 0)

Hi all,

A client of our wants a logon page on their website to only appear if a user is using a computer out of the company's network.

Any ideas how this can be done, and if anyone has done it.

cheers
geoffb

[edited by: eelixduppy at 10:31 pm (utc) on May 18, 2010]
[edit reason] no solicitations, please [/edit]

 

LifeinAsia




msg:4134975
 10:39 pm on May 18, 2010 (gmt 0)

By "out of the company's network" do you mean outside the company's IP address range? Or do you mean something else? If the former, then just do a check on the user's IP address. If the later, then hwo is "out of the company's network" defined?

geoffb




msg:4135000
 11:38 pm on May 18, 2010 (gmt 0)

Hi lifeinasia,

Yes outside of the companies network. They don't want internal users to see the login page or even the link to it.

Geoffb

LifeinAsia




msg:4135006
 12:02 am on May 19, 2010 (gmt 0)

You can use $_SERVER["REMOTE_ADDR"] and check against the range of IP addresses the company uses.

And even nicer implementation (just in case the user is using a proxy) would be:
if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
$TheIp=$_SERVER['HTTP_X_FORWARDED_FOR'];
else $TheIp=$_SERVER['REMOTE_ADDR'];

geoffb




msg:4135164
 7:41 am on May 19, 2010 (gmt 0)

Thanks. How is that converted into hiding a logon div panel if the user is within the companies ip range?
Geoffb

LifeinAsia




msg:4135361
 3:18 pm on May 19, 2010 (gmt 0)

You check the user's IP against the company's range. If it's in the range, you don't show the logon panel.

londrum




msg:4135369
 3:26 pm on May 19, 2010 (gmt 0)

if you cant do IPs, then you can give all the browsers in the building their own user_agent, and check that instead... assuming that the company has control over the browsers.

its a five-second job with firefox. never tried with IE.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved