|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[1999-07-29 16:21 UTC] pete dot nelson at ci dot stpaul dot mn dot us
[1999-11-11 19:38 UTC] joey at cvs dot php dot net
[2002-06-16 08:35 UTC] sander@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 17:00:01 2025 UTC |
I wanted to make a hostname lookup page, and realized that it couldn't be done on either of my SGI indys. It works fine under RedHat linux, Win98 & WinNT (all running apache 1.3.6). My guess is a bug in the SGI system libraries - it does get a little nutty. Here's my script: <html><head><title>Host Checker</title></head> <body bgcolor=white> <h1>Test a Host</h1> <?php if(! isset($host)) { $host = "friday"; } // The Input: echo "<form action=\"http-check.php3\" method=post>"; echo "<input type=text name=host size=30 value=\"$host\">"; echo "<input type=submit value=\"Check Host\">"; echo "</form>"; // Check DNS $ip = gethostbyname($host); echo "<h2>DNS Entry for <font size=+3 color=blue>$host</font></h2>\n"; echo "<b>$host:</b> $ip\n"; // The HTTP Request: echo "<p><hr align=center width=85%>"; echo "<h2>HTTP Response from <font size=+3 color=blue>$host</font></h2>\n"; $fp = fsockopen("$ip", 80, &$errnr, &$errstr); if(! $fp) { echo "<h1><font color=red>Error!</font></h1>"; echo "<p>$errstr ($errnr)"; exit; } fputs($fp, "HEAD / HTTP/1.0\n\n"); // The HTTP Response: while(!$end) { $line = fgets($fp, 2048); if(trim($line) == "") { $end = true; } else { echo "<BR>$line"; } } fclose($fp); ?> </body></html>