In other words, how can I tell if the person using my web application is on the server it resides on? If I remember correctly, PHPMyAdmin does something like this for securi
I found a easy answer.
Because all local drives have C: or D: or F: ... etc.
Just detect if the second character is a :
if ( substr_compare(getcwd(),":",1,1) == 0)
{
echo '<script type="text/javascript">alert(" The working dir is at the local computer ")</script>';
$client_or_server = 'client';
}
else
{
echo '<script type="text/javascript">alert(" The working dir is at the server ")</script>';
$client_or_server = 'server';
}
How about to compare $_SERVER['SERVER_ADDR'] === $_SERVER['REMOTE_ADDR']
to determine if client is on the same machine as server?
$_SERVER["REMOTE_ADDR"]
should tell you the user's IP. It's spoofable, though.
Check this bounty question for a very detailed discussion.
I think what you remember with PHPMyAdmin is something different: Many MySQL Servers are configured so that they can only be accessed from localhost for security reasons.