Php
Articles on Php
Tagged:

The code below gets the real IP of the user and it also gets the proxy address of the user if he is using one.


if (isset($_SERVER['HTTP_X_FORWARDED_FOR']))
{
$proxy = isset($_SERVER['HTTP_CLIENT_IP']) ? $_SERVER['HTTP_CLIENT_IP'] : $_SERVER['REMOTE_ADDR'];
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
else {
$ip = isset($_SERVER['HTTP_CLIENT_IP']) ? $_SERVER['HTTP_CLIENT_IP'] : $_SERVER['REMOTE_ADDR'];
}

echo "Host IP: ". $ip ."
";
echo "Hostname: ". gethostbyaddr($ip) ."

";

//If the variable proxy is set, then the user is using Proxy so display proxy information
if(isset($proxy)){
echo "Proxy IP: ". $proxy ."
";
echo "Proxyname: ". gethostbyaddr($proxy)."
";
}

Tagged:

We have often used the function explode() to split a string by a certain string delimeter(eg: ":","~","-","," e.t.c). However,you may seldom come across a situation where you need to split a word letter by letter without any delimeter separating it. There's a simple function "str_split" for this purpose. This function splits a string to an array.

Tagged:

If we are using an iframe in a page and we want to use the existing session variables of this page inside an iframe too, we must first register the session inside iframe with the same session id as the page including it.

Syndicate content