I've a PHP running code that ask the file size of a remote mp4 file, thanks to a fsockopen function and HEAD command.
Now, i need to move this code to other server behind a proxy, which is the best approach to go through that new proxy, and continue using fsockopen? I'm really stuck. I can't tunnel or handle two sockets.
Any ideas? thanks for your help and time.
private function filesize_remote($remotefile, $timeout=10) {
$size = false;
$url = parse_url($remotefile);
if ($fp = @fsockopen($url['host'], ($url['port'] ? $url['port'] : 80), $errno, $errstr, $timeout)) {
fwrite($fp, 'HEAD '.@$url['path'].@$url['query'].' HTTP/1.0'."\r\n".'Host: '.@$url['host']."\r\n\r\n");
while (!feof($fp)) {
$headerline = fgets($fp, 4096);
if (preg_match('/^Content-Length: (.*)/', $headerline, $matches)) {
$size = intval($matches[1]);
break;
}
}
fclose ($fp);
}
return $size;
}