Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

rhp2424

macrumors regular
Original poster
Jul 23, 2008
122
18
Does anybody know how to work with local IP address with PHP but behind a firewall or perhaps the problem is a proxy?

More specifically, I am working on a webpage for work where I want a link to only appear on three computers based on some unique identifier. The trouble I seem to run into is the fact that we are operating from behind a firewall so I only ever get the same IP address no matter how I request it.

When I have researched local IP address and all the variations, I am always returning the same "local IP address" no matter which computer I am on. I have tried seeing if it was possible to do MAC address, or some other single computer specific information, but I have not had any luck.

Ignoring specific formatting, here is something like what I am trying to do:

$localip = $_SERVER["HTTP_CLIENT_IP"]
if ($localip == xxx.xxx.xxx.xxx) {print "<a href='link.php'>Link Title</a>";}

I have already reviewed and tried every option on this page: http://us.php.net/manual/fr/reserved.variables.server.php

Any suggestions? All possible leads and information are greatly appreciated! Thanks!
 

Jamesbot

macrumors member
Jun 19, 2009
51
1
im assuming the specific machines you want to want to provide the link to are on some other network than the LAN where you're running you PHP server.

if thats the case, likely those machines are NATed behind a firewall so all you see is the public ip address and not the private ip address of the specific machine. i don't think there is any way around this ( if I'm wrong about that please someone feel free to correct me ).

you may have to use some other method of establishing identity. do you have any authentication mechanism?

one thought off the top of my head would be to create a page that will place a cookie on the client machine. that would how you specifically identify the client. that page could be password protected using something simple like a .htaccess file.

from then on once they have the cookie, then code it so the link appears only to the users that have the cookie.
 

rhp2424

macrumors regular
Original poster
Jul 23, 2008
122
18
do you have any authentication mechanism?

one thought off the top of my head would be to create a page that will place a cookie on the client machine. that would how you specifically identify the client. that page could be password protected using something simple like a .htaccess file.

from then on once they have the cookie, then code it so the link appears only to the users that have the cookie.

Thanks for the thoughts. Well, if I understand well enough, yes, I do have an authentication mechanism. There are accounts established, and it is after they log into their account on one specific computer, that I want the link to show up. My concern with a .htaccess cookie would be the control.

Would I be able to have a cookie only be established to show this link on a single computer? They need to access this page from multiple computers, but I only want the link to be shown on the single access computer. Would the cookie method you are proposing accomplish this?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.