fputs / fpassthru and fclose errors, please help
I am getting these 3 errors in my php, can someone assist me please?
Code:
fputs(): supplied argument is not a valid stream resource in /home/stream.php on line 37
[08-Sep-2012 14:39:53] PHP Warning: fpassthru(): supplied argument is not a valid stream resource in /home/stream.php on line 39
[08-Sep-2012 14:39:53] PHP Warning: fclose(): supplied argument is not a valid stream resource in /home/stream.php on line 41
Stream.php
Code:
<?php
$url = urldecode($_GET["url"]);
$tmp = parse_url($url);
$streamname = $tmp["host"]; // put in whatever stream you want to play
$port = (int)($tmp["port"]); // put in the port of the stream
$path = $tmp["path"]; // put in any extra path, this is usually just a /
if(empty($path)) $path = "/";
/*
$fp = fopen("log.log","w");
fwrite($fp,"$url\n");
fwrite($fp,$streamname."----------".$path."-------------".$port."\n");
fclose($fp);*/
// print $streamname."----------".$path."-------------".$port;
header("Content-type: audio/mpeg");
$sock = fsockopen($streamname,$port);
fputs($sock, "GET $path HTTP/1.0\r\n");
fputs($sock, "Host: $streamname\r\n");
fputs($sock, "User-Agent: WinampMPEG/2.8\r\n");
fputs($sock, "Accept: */*\r\n");
fputs($sock, "Icy-MetaData:0\r\n");
fputs($sock, "Connection: close\r\n\r\n");
fpassthru($sock);
fclose($sock);
?>
Thank you.