Show the Visitor's IP

Dismounted

59.***.***.***
1,440 days ago

Show the Visitor's IP

Show the Visitor's IP This will display the visitor's IP Address. Insert this into a PHP Script.

PHP code:

<?php echo $_SERVER['REMOTE_ADDR']; ?>

Done! :)

phool4fool

203.***.***.***
1,417 days ago

IP Logger

Here is the code to Display the visitors information like: IP@,type of connection, provider, browser info, country and time information.

php:

PHP code:

0<?php
1
2function logip($ip='') {
3 if ($ip=='') $ip = $_SERVER['REMOTE_ADDR'];
4 $longisp = @gethostbyaddr($ip);
5 $isp = explode('.', $longisp);
6 $n=count($isp);
7 if (preg_match("/[0-9]{1,3}\.[0-9]{1,3}/", $isp[0])) return 'ISP lookup failed.';
8 $type=$isp[$n-3];
9 if(($type!="dsl") || ($type!="adsl") ) $type="adsl";
10 $provider=$isp[$n-2];
11 if(strlen($provider)==3)$provider=$isp[0];
12 $country=$isp[$n-1];
13
14 $browser=$_SERVER['HTTP_USER_AGENT'];
15
16 $timestamp=time();
17 echo 'IP: $ip <br>Type: $type<br>Provider: $provider<br>';
18 echo 'Country: $country <br>Browser: $browser<br>Timestamp: $timestamp';
19
20}
21?>


Usage Example:
php:

PHP code:

0<?php
1logip();
2
3?>

Logik

66.***.***.***
1,010 days ago

phool4fool;274:

Here is the code to Display the visitors information like: IP@,type of connection, provider, browser info, country and time information.

php:

Code:

0<?php
1
2function logip($ip='') {
3 if ($ip=='') $ip = $_SERVER['REMOTE_ADDR'];
4 $longisp = @gethostbyaddr($ip);
5 $isp = explode('.', $longisp);
6 $n=count($isp);
7 if (preg_match("/[0-9]{1,3}\.[0-9]{1,3}/", $isp[0])) return 'ISP lookup failed.';
8 $type=$isp[$n-3];
9 if(($type!="dsl") || ($type!="adsl") ) $type="adsl";
10 $provider=$isp[$n-2];
11 if(strlen($provider)==3)$provider=$isp[0];
12 $country=$isp[$n-1];
13
14 $browser=$_SERVER['HTTP_USER_AGENT'];
15
16 $timestamp=time();
17 echo 'IP: $ip <br>Type: $type<br>Provider: $provider<br>';
18 echo 'Country: $country <br>Browser: $browser<br>Timestamp: $timestamp';
19
20}
21?>


Usage Example:
php:

Code:

0<?php
1logip();
2
3?>



Was it necessary to paste the line numbers?

Your code doesn't work. The $strings are not parsed when php reads your script. Please note: the ISP type and Country do not work accurately since $longisp just contains the hostname (.net is not a country). Also, since no one can calculate UNIX epoch time in their head, i changed your variable to date() instead of time().

i have fixed your code below:

PHP code:


<?php
function logip($ip='') {
if ($ip=='') $ip = $_SERVER['REMOTE_ADDR'];
$longisp = @gethostbyaddr($ip);
$isp = explode('.', $longisp);
$n=count($isp);
if (preg_match("/[0-9]{1,3}\.[0-9]{1,3}/", $isp[0])) return 'ISP lookup failed.';
$type=$isp[$n-3];
if(($type!="dsl") || ($type!="adsl") ) $type="adsl";
$provider=$isp[$n-2];
if(strlen($provider)==3)$provider=$isp[0];
$country=$isp[$n-1];
$browser=$_SERVER['HTTP_USER_AGENT'];
$timestamp=date("g:ia");

echo 'IP: ' . $ip . ' <br>Type: ' . $type . '<br>Provider: ' . $provider . '<br>';
echo 'Country: ' . $country . ' <br>Browser: ' . $browser . '<br>Timestamp: ' . $timestamp . '<br>';
}
print(logip());
?>