remote addr modification

A

Anonymous

Guest
hey ppl,

when i execute the code :

echo $_SERVER["REMOTE_ADDR"];

the ip output is

::ffff:***.**.***.**


how can i get rid of the "ffff" part....?

thanks
 
Try looking here:

http://uk.php.net/manual/en/function.ereg-replace.php
 
thanks for that, thats what i was looking for, but things are more complicated.

it seems that it wont work for a string that has no spaces

for example:
Code:
$eg="hello mark";
echo str_replace(" mark", " joe", $eg);
works fine but:

Code:
$ip=$_SERVER["REMOTE_ADDR"];
echo str_replace(" ffff", " ", $ip);
does nothing...
how do i make it to search the string for a specific character?

i tried looking at split and eregi functions but i dont unrestdand them enough to make my script work..

ta
 
having thought a bit more...

if ALL IP's come out with the ffff bit, you could use the following code to retrieve the actual IP:
Code:
<?php
$txt = "::ffff:***.**.***.**";
$tmpline=explode(":",$txt);
$ip = $data[$tmpline[0]][ip]=$tmpline[3];

echo $ip; ?>

This basically gives you the txt after the 3rd :

You can make $txt your actual $_SERVER[] information by simply changing the variable.

As it is, this code just echo's "***.**.***.**"

Andrew
 
That worked perfectly, it is a great help.
thank you. :-D

////


almost forgot, i didn't ask what was the meaning of the ffff part?
all that trouble for that piece of the address .....
 
Back
Top