Hello jenny,

Monday, March 28, 2005, 9:36:07 AM, you wrote:
j> i am making a website in php and i will appreciate if anybody can
j> tell me the php code to :
j> - (1)display isp name,

One problem you're going to run into is that by using
$_SERVER['REMOTE_ADDR'] oftentimes, you'll end up with just the IP.

I wrote the below to give me the hostname, which generally gives you
the ISP information too, to fix a problem on a project I was doing.

If it won't resolve to a name (which does happen sometimes for
machines behind corporate firewalls), I just displayed "No Reverse DNS"

<?php
$pingResults = shell_exec('ping -a ' . $_SERVER['REMOTE_ADDR']);
$temp = explode("\r\n",$pingResults);
preg_match("/^Pinging\s([a-zA-Z0-9.]+)/", $temp[1], $hostname);
if ($temp[4] == "Request timed out.")
  $latency = "Unknown";
else
  $latency = $temp[4];
?>

Hostname: <?php if (!$_SERVER['REMOTE_ADDR'] == 
preg_match("/^[a-z.]+/i",$hostname[1])) echo "No Reverse DNS"; else echo 
$hostname[1]; ?>
Latency: <? echo $latency; ?>

Geez, it's amazing when you dig back through old code you realize how
much your coding skills sucked back then! <grin>




-- 
Leif (TB lists moderator and fellow end user).

Using The Bat! 3.0.9.9 Return (pre-beta) under Windows XP 5.1
Build 2600 Service Pack 2 on a Pentium 4 2GHz with 512MB

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to