|
Posted by gosha bine on 08/31/07 22:07
Christian Aastorp wrote:
> I'm a newbie with php, but experienced with other languages. I'm
> maintaining a small site written in php. To ease debugging and updates
> I've used an onscreen reference to indicate identity of included files
> etc.
>
> I don't really want this reference to be visible to anyone but myself.
> So I searched the manual and found some promising predefined variables
> that I used in this code snippet:
>
> <?php
> if ($_SERVER['REMOTE_ADDR'] = "127.0.0.1") {
> echo $level1, '_', $level2, '_', $imageNO, ' ', $display;
> }
> ?>
>
> This worked spllendidly when I tested running our site locally using
> the XAMPP-bundle. But when I copied the code out to the real server it
> seems that all clients are found at 127.0.0.1!
>
> I'm sure there are lots of better ways both to fix my code, and
> especially totally different ways to do what I'm trying to achive, any
> suggestions very welcome!
>
127.0.0.1 is "localhost", i.e. it is the machine the script is running
on, not the user machine. You have to put your real "internet" IP there
(and, of course, you want "==" not "=").
If you don't have a permanent IP, you need other means to
authentication, for example HTTP auth:
if(@$_SERVER['PHP_AUTH_USER'] != 'me' || @$_SERVER['PHP_AUTH_PW'] !=
'secret') {
header('WWW-Authenticate: Basic');
header('HTTP/1.0 401 Unauthorized');
die();
}
--
gosha bine
extended php parser ~ http://code.google.com/p/pihipi
blok ~ http://www.tagarga.com/blok
[Back to original message]
|