<html> <head> <title>Retrieving a Web page using fsockopen()</title> </head> <body> <?php $host = "www.navioo.com"; $page = "/index.htm"; $fp = fsockopen( "$host", 80, &$errno, &$errdesc); if ( ! $fp ) die ( "Couldn't connect to $host:nError: $errnonDesc: $errdescn" ); $request = "GET $page HTTP/1.0rn"; $request .= "Host: $hostrn"; $request .= "Referer: http://www.navioo.com/index.htmrn"; $request .= "User-Agent: PHP test clientrnrn"; $page = array(); fputs ( $fp, $request ); while ( ! feof( $fp ) ) $page[] = fgets( $fp, 1024 ); fclose( $fp );print "the server returned ".(count($page))." lines!"; ?> </body> </html>
|