Hi, Tony... Here's a script I pilfered from online a coupla years back and have modified (over and over). The code would be online, except my ISP is having heartburns lately... Bill
<?php $MetaTitle = "WhoAmI"; $MetaDescription = "Utility to demonstrate PHP"; include( "style/htmlhead.php" ); $OnLoad = ""; include( "style/bodytemplate_top.php" ); // seed with microseconds function make_seed() { list($usec,$sec) = explode(" ", microtime()); return ((float)$sec+(float)$usec) * 100000; } $Agent = getenv( "HTTP_USER_AGENT" ); $Authorities = array( 'whois.arin.net', 'whois.ripe.net', 'whois.apnic.net' ); $date = date(r); if ( $HTTP_X_FORWARDED_FOR ) { $ip = $HTTP_X_FORWARDED_FOR; } elseif( $HTTP_VIA ) { $ip = $HTTP_VIA; } elseif( $REMOTE_ADDR ) { $ip = $REMOTE_ADDR; } else { die(); } $TheDate = rtrim( `date +%Y%m%d-%H%M` ); srand(make_seed()); $randval = rand(); $LogID = $ThisWebServer.":".$TheDate.":".microtime(); $host = gethostbyaddr($ip); if ( $host == $ip ) { $host = "possibly spoofed"; } $headers = getallheaders(); $HeaderLog = array(); while (list ($header, $value) = each ($headers)) { array_push( $HeaderLog, "$header=$value" ); } $GotResponse = false; // ARIN makes a messy output. To get what we want we have to requery using the NIC // handle to get the email address for the contact. First, replace this skimpy output // with the output that has the required data in it foreach ( $Authorities as $Authority ) { if ( $GotResponse ) { break; } $RespondingAuthority = $Authority; @exec("/usr/bin/whois $ip@$Authority", $WholeResponse, $status ); $UWholeResponse = strtoupper( join( " ", $WholeResponse) ); if ( ( strpos( $UWholeResponse, "NO ENTRIES" ) === false ) && ( strpos( $UWholeResponse, "NO MATCH" ) === false ) ) { $GotResponse = true; $Keepgoing = true; foreach ( $WholeResponse as $Line ) { if ( ( $Authority == "whois.arin.net" ) && ( $Keepgoing ) ) { $StartPos = strpos( $Line, chr(40) ); if ( !( $StartPos === false ) ) { $StartPos++; $RightSide = strpos( $Line, chr(41) ); $RightSide = $RightSide - $StartPos; $Query = substr( $Line, $StartPos, $RightSide ); $Query .= "@whois.arin.net"; unset( $WholeResponse ); @exec( "/usr/bin/whois !$Query", $WholeResponse, $status ); $Keepgoing = false; break; } } } } } // APNIC and RIPE produce similar reports. ARIN on the other hand makes // you work twice as hard to find an email address. With ARIN, one must // perform a double-query (as above) to get the information associated // with a network's NIC handle. APNIC and RIPE just hand it to you // straightaway. unset( $SendTo ); // just for effect if ( $RespondingAuthority != "whois.arin.net" ) { foreach ( $WholeResponse as $Line ) { list( $Key, $Value ) = explode( ":", $Line ); if ( strtoupper( $Key ) == "E-MAIL" ) { if ( eregi( "@dsl.net", $Value ) ) { $SendTo = "[EMAIL PROTECTED]"; } elseif ( eregi( "ripe.net", $Value ) ) { $SendTo = "[EMAIL PROTECTED]"; } elseif ( eregi( "bellsouth.net", $Value ) ) { $SendTo = "[EMAIL PROTECTED]"; } else { $SendTo = trim( $Value ); } break; } } } else { foreach ( $WholeResponse as $Line ) { $Words = explode( " ", trim( $Line ) ); foreach ( $Words as $Word ) { if (eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*$",$Word)) { if ( eregi( "@dsl.net", $Word ) ) { $SendTo = "[EMAIL PROTECTED]"; } elseif ( eregi( "ripe.net", $Value ) ) { $SendTo = "[EMAIL PROTECTED]"; } elseif ( eregi( "bellsouth.net", $Value ) ) { $SendTo = "[EMAIL PROTECTED]"; } else { $SendTo = $Word; } break; } } if ( isset( $SendTo ) ) { break; } } } ?> <h2>WhoAmI Utility</h2> <p> This utility can help you identify your browser and your Internet provider. It uses all of the worldwide NIC authorities to obtain only public information. <em>No</em> information obtained by this page is ever retained...it is simply a diagnostic to help web programmers understand how web servers respond to information provided by their browsers. It is provided in an effort to help web programmers isolate browser differences so that their programming will be more sure to work on more platforms. </p> <h3>The Basics</h3> <ul> <?php if ( $host != $ip ) { print "<li>Your host name is $host</li>\n"; } print "<li>Your IP Address is $ip</li>\n"; print "<li>Your web service provider was found in $RespondingAuthority</li>\n"; print "<li>Your browser is reported as $Agent</li>\n"; if ( isset( $SendTo ) ) { list( $EmailAddress, $Provider ) = explode( "@", $SendTo ); print "<li>Your service provider is $Provider</li>\n"; } print "</ul>\n"; print "<h3>The Entire Response from $RespondingAuthority</h3>\n"; print "<pre>\n"; foreach ( $WholeResponse as $Line ) { print "$Line\n"; } print "</pre>\n"; print "<h3>Your browser sent the following headers</h3>\n"; print "<ul>\n"; foreach( $HeaderLog as $Line ) { print "<li>$Line</li>\n"; } ?> </ul> <hr> <a href="/sourcesafe/" title="Show me the code for this page">Show me the code</a> for this page. <?php include( "style/bodytemplate_bottom.php" ); ?> ===== Bill Farrell Multivalue and *nix Support Specialist Phone: (828) 667-2245 Fax: (928) 563-5189 Web: http://www.jwfarrell.com __________________________________________________ Do you Yahoo!? New DSL Internet Access from SBC & Yahoo! http://sbc.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php