All pastes #42371 Raw Edit

Anonymous

public php v1 · immutable
#42371 ·published 2006-02-20 22:24 UTC
rendered paste body
function fetchURL($host, $path, $port, $timeout) {   echo $host, $path, $port;   $out = "GET $path HTTP/1.0\r\nHost: $host\r\n\r\n";	return FALSE;   $fp = fsockopen($host, $port, $errno, $errstr, $timeout);      //socket_set_blocking($fp, 0);   //socket_set_timeout($fp, $timeout);      fwrite($fp, $out);   $body = false;   while (!feof($fp)) {       $s = fgets($fp, 8192);	   echo $s;       if ( $body )           $in .= $s;       if ( $s == "\r\n" )           $body = true;   }     fclose($fp);     return $in;}function getimagesize_remote($image_url) {   // break image url open for further processing   $parsed = parse_url($image_url);   $host = empty($parsed["host"])?NULL:$parsed["host"];   $path = $parsed["path"];   if (@$parsed["query"] != "") $path .= "?".$parsed["query"];   if (@$parsed["port"] == 0) $port = 80;   else $port = $parsed["port"];   $timeout = 2;      if (empty($host)) return FALSE;   //var_dump($parsed);   //$handle = fopen ($image_url, "rb");      $contents = fetchURL($host, $path, $port, $timeout);   echo $contents;   $im = ImageCreateFromString($contents);   if (!$im) { return false; }   $gis[0] = ImageSX($im);   $gis[1] = ImageSY($im);// array member 3 is used below to keep with current getimagesize standards   $gis[3] = "width={$gis[0]} height={$gis[1]}";   ImageDestroy($im);   return $gis;}