ID: 33816 Comment by: sey at sey dot prometheus-designs dot net Reported By: sey at prometheus-designs dot net Status: Feedback Bug Type: Network related Operating System: Linux 2.4.29 PHP Version: 5.0.4 New Comment:
I'm sorry but all I can get it down to without significantly altering it is 26 lines. It can be found here: http://sey.prometheus-designs.net/meh/index3.php ( Source: http://sey.prometheus-designs.net/meh/index3.phps ) Previous Comments: ------------------------------------------------------------------------ [2005-07-22 19:41:30] [EMAIL PROTECTED] Please provide a *SHORT* but complete script the clearly shows the problem. "Short" means max. 10-20 lines long. We don't need all those arrays and functions. Just a reproduce script (comments and descriptions are welcome). Thanks. ------------------------------------------------------------------------ [2005-07-22 19:13:08] sey at sey dot prometheus-designs dot net The script is online, at http://sey.prometheus-designs.net/meh/index.phps .. The code segment I put in the 'reproduce code' box was just the function that I thought was messing up, as the rest of the script just formats user input and holds whois server information. If you need, I can provide another link with a bit shorter version. using just the get_raw_whois function. ------------------------------------------------------------------------ [2005-07-22 12:02:58] [EMAIL PROTECTED] Thank you for this bug report. To properly diagnose the problem, we need a short but complete example script to be able to reproduce this bug ourselves. A proper reproducing script starts with <?php and ends with ?>, is max. 10-20 lines long and does not require any external resources such as databases, etc. If possible, make the script source available online and provide an URL to it here. Try to avoid embedding huge scripts into the report. ------------------------------------------------------------------------ [2005-07-22 11:30:19] sey at prometheus-designs dot net Description: ------------ I seem to be having inconsistant results using gethostbyname() and fsockopen(). On one hand I can make all the gethostbyname and fsockopen calls I want, as observed in: http://sey.prometheus-designs.net/meh/index2.php ( Source: http://sey.prometheus-designs.net/meh/index2.phps ) However, in: http://sey.prometheus-designs.net/meh/index.php ( Source: http://sey.prometheus-designs.net/meh/index.phps ) When one enters a domain in the first text box and nothing in the second, for example, apple.com, my script successfully gets the ip address of whois.verisign-grs.net, but not whois.markmonitor.com. However, if whois.markmonitor.com is put in the second text box, forcing it to query whois.markmonitor.com first, it runs just fine. What I believe to be the problematic code is in the get_raw_whois function I made. Header.php and footer.php are only html with the exception of the date function used in header.php. Phpinfo is: http://sey.prometheus-designs.net/phpinfo.php Reproduce code: --------------- function get_raw_whois( $whois, $domain ) { $ip = gethostbyname( $whois ); print( 'Attempting to use ' . $whois . ' ( ' . $ip . ' ) ..<br />' ); $fp = fsockopen( $whois, 43, $errno, $errstr, 30 ); if( !$fp ) { $output = 'Could not perform whois: ' . $errno . ' ( ' . $errstr . ' )'; } else { fputs( $fp, $domain . "\r\n" ); while( !feof( $fp ) ) { $temp = trim( fgets( $fp, 1024 ), "\x00..\x1F" ); if( stristr( $temp, 'whois server:' ) ) { fclose( $fp ); return get_raw_whois( substr( $temp, strpos( $temp, ':' ) + 1 ), $domain ); } $output .= $temp . '<br />'; } } fclose( $fp ); return $output; } Expected result: ---------------- $whois is supposed to be a uri to a whois server, $domain a domain name and tld. First some text is printed about what whois server is being used. Then a connection is made to that server, if it cannot be contacted in 30 minutes, failure. Upon successful connection, the whois request is made. The while statement ensures that all incoming data from the whois request is accounted for in some manner, barring exceptions. Input is trimmed and then examined to contain 'whois server:'. If this is found, it grabs that whois server off the end of that line, closes the connection, and recursively runs get_raw_whois, if not, it saves the input in to an output container. After the whois server is done sending it's stuff, the connection is closed and output is returned to be printed on the screen. Actual result: -------------- After the recursive call is made, gethostbyname and fsockopen do not function properly. Attempting to use whois.verisign-grs.net ( 198.41.3.54 ) .. Attempting to use whois.markmonitor.com ( whois.markmonitor.com ) .. Warning: fsockopen() [function.fsockopen]: php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/.camella/sey/sey.prometheus-designs.net/meh/index.php on line 297 Warning: fsockopen() [function.fsockopen]: unable to connect to whois.markmonitor.com:43 (Unknown error) in /home/.camella/sey/sey.prometheus-designs.net/meh/index.php on line 297 Warning: fclose(): supplied argument is not a valid stream resource in /home/.camella/sey/sey.prometheus-designs.net/meh/index.php on line 325 Could not perform whois: -1073765632 ( ) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=33816&edit=1