Quick question. I have the following code and one line is bugging me. Here's the complete code:
function whois ($a_server, $a_query, $a_port=43) {
$available = "No match";
$a_query = str_replace("www.", "", $a_query);
$a_query = str_replace("http://", "", $a_query);
//connects to whois to search for username
$sock = fsockopen($a_server,$a_port);
if(!$sock) {
echo 'Could Not Connect To Server.';
}
//write the query to whois
fputs($sock,"$a_query\r\n");
//get the line of results
while(!feof($sock)) $result .= fgets($sock,128);
//close the connection
fclose($sock);
if (eregi($available,$result)) {
echo $a_query . ' is available.';
} else {
echo $a_query . ' is not available.</b></font>';
}
}
if($query != ''){
if(!eregi(".com",$query) AND !eregi(".net",$query) AND !eregi(".org",$query)) {
echo 'You must specify a .com, .net, or .org domain name.';
} else {
$server = 'whois.internic.net';
whois($server,$query);
}
} elseif(isset($query)) {
echo 'Please fill in a domain name and try again.';
}
- function whois ($a_server, $a_query, $a_port=43) {
- $available = "No match";
- $a_query = str_replace("www.", "", $a_query);
- $a_query = str_replace("http://", "", $a_query);
-
- //connects to whois to search for username
- $sock = fsockopen($a_server,$a_port);
- if(!$sock) {
- echo 'Could Not Connect To Server.';
- }
-
- //write the query to whois
- fputs($sock,"$a_query\r\n");
- //get the line of results
- while(!feof($sock)) $result .= fgets($sock,128);
- //close the connection
- fclose($sock);
-
- if (eregi($available,$result)) {
- echo $a_query . ' is available.';
- } else {
- echo $a_query . ' is not available.</b></font>';
- }
- }
- if($query != ''){
- if(!eregi(".com",$query) AND !eregi(".net",$query) AND !eregi(".org",$query)) {
- echo 'You must specify a .com, .net, or .org domain name.';
- } else {
- $server = 'whois.internic.net';
- whois($server,$query);
- }
- } elseif(isset($query)) {
- echo 'Please fill in a domain name and try again.';
- }
What the heck does this part do?
while(!feof($sock)) $result .= fgets($sock,128);
Is it writing line 128 to variable result? Because if it is, I don't understand how this shows that a domain is available since there's nothing on whois.internic.net that I can see with my eye. I downloaded this from a hotscripts type website (i broke my #1 rule!) to try and figure out whe the author has done, but I don't get it. Well, I think I get it, but I'm not sure how the heck he's getting his results.
Advice?