Jump to content

Remote Addr Local Testing


Lockit

Recommended Posts

Hello I was wondering how would I get $_SERVER['REMOTE_ADDR'] to work with local testing?

Whenever I run the script at the host computer it always returned the address of the router, but if done remotely it will display the correct ip address.

Thanks, Lockit.

Link to comment
Share on other sites

sorry, than i'm not sure about what you mean, because the solution i gave does not need any changes in code

 

esp. if you define the variable $TEST using an include statement..

 

include 'test.inc.php';

$ip=$_SERVER['REMOTE_ADDR']

if ($TEST)  {
    $ip="another ip-address";
}

 

and in this 'test.inc.php':

<?php
$TEST=True;
?>

 

after testing you only need to change the 'test.inc.php' file.....

Link to comment
Share on other sites

Hmm, I never was good with explanations.

I am not 100% sure something like this would work but what I am attempting falls along the lines of:

if($_SERVER['REMOTE_ADDR'] == "192.168.2.1") {
  $ip = (Some method to retrieve the real IP.);
} else {
  $ip = $_SERVER['REMOTE_ADDR'];
}

Link to comment
Share on other sites

seems this works every 5 attempts, however it uses the domain name instead of the numerical IP for the socket export.

 

if($_SERVER['REMOTE_ADDR'] == "192.168.2.1") {
  $address = $_SERVER['SERVER_NAME'];
} else {
  $address = $_SERVER['REMOTE_ADDR'];
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.