Podczyt strony ze wskazanego adresu URL, fsockopen聽

function fsopen($url) {
聽if (substr($url, 0, 7) == ‘http://’)
聽聽$url = substr($url, 7);

聽$host = substr($url, 0, strpos($url, ‘/’));
聽$filepath = substr($url, strpos($url, ‘/’));

聽$fp = @fsockopen ($host, 80, $errno, $errstr, 10);

聽if (!$fp) {
聽聽$ret_value = „$errstr ($errno)”;
聽} else {
聽聽$header .= ‘GET ‘.$filepath.’ HTTP/1.1′.”\r\n”;
聽聽$header .= ‘Host: ‘.$host.”\r\n”;
聽聽$header .= ‘Connection: close’.”\r\n”;
聽聽$header .= „\r\n”;

聽聽fputs ($fp, $header);

聽聽while(!feof($fp)) {
聽聽聽$line = fgets($fp, 8192);
聽聽聽if(!$start_data && preg_match(„/^\r\n$/”, $line)) {
聽聽聽聽$start_data = 1;
聽聽聽聽continue;
聽聽聽}
聽聽聽if ($start_data) {
聽聽聽聽$ret_value .= $line;
聽聽聽}
聽聽}

聽聽fclose ($fp);
聽}
聽return $ret_value;
}

Dodaj komentarz

* pole obowi膮zkowe