Hi,

Ik heb dit script maar krijg deze error: Fatal error: Call to undefined function apache_request_headers()

Iemand een Idee?

<?php

set_time_limit(10 * 60); //this could take a while, allowing 10 minutehs. just added recently see UPDATE at the top of post

$bytes_to_send = 480000 * 130; //stream about about 2 hours of music

$headers = apache_request_headers(); //get the HTTP request headers safari has sent

//if safari is only asking for a portion of the "mp3"
if (isset($headers['Range'])) {
$exploded_range = explode('=', $headers['Range']);
$limits = explode('-', $exploded_range[1]);
$length = ($limits[1] - $limits[0]) + 1; //the content length
$content_range = 'bytes ' . $limits[0] . '-' . $limits[1]; //the content range

//send fake HTTP headers to safari, telling it that we're sending only the portion of the "mp3" it asked for
header('HTTP/1.1 206 Partial Content');
header('Accept-Ranges: bytes');
header('Content-Length: ' . $length);
header('Content-Range: ' . $content_range . '/' . $bytes_to_send);
header('Content-type: audio/mpeg');

//open the stream to the shoutcast server, set as resource $fp
$fp = fsockopen("209.51.162.173", "9904", $errno, $errstr, 30) or die("Error Connection");

//HTTP commands that will initiate the shoutcast server sending stream data
$buf = "GET / HTTP/1.0\r\nIcy-MetaData:0\r\n\r\n";

//send HTTP commands in string $buf to stream $fp
fwrite($fp, $buf);
//get next line from stream
$buf = fgets($fp, 1024);

//get next few lines and discard them, this is only
//shoutcast data that would sound like noise if iphone played them
$buf = fgets($fp, 1024);
$buf = fgets($fp, 1024);
$buf = fgets($fp, 1024);
$buf = fgets($fp, 1024);
$buf = fgets($fp, 1024);
$buf = fgets($fp, 1024);
$buf = fgets($fp, 1024);
$buf = fgets($fp, 1024);

//break if EOF
if ($buf == "\r\n") {
break;
}

$bytes_sent = 0;

//while pointer is not at EOF, and not too many bytes are sent...
while (!feof($fp) AND ($bytes_sent < $length)) {
//read 1 byte of stream
$buf = fread($fp, 1);

//output byte to iphone;
echo $buf;
$bytes_sent++;
}
fclose($fp);
exit();
}

//else, it is the initial request. safari is asking for the whole "mp3", and seeing how big it is ($bytes_to_send)
else {
header('Accept-Ranges: bytes');
header('Content-Length: ' . $bytes_to_send);
header('Content-type: audio/mpeg');

echo 'blah';
exit();
}
exit();

?>
Welke PHP-versie heb je volgens phpinfo()? En draait je site ook op Apache?
Ik heb mijn host bij ''mijndomein'' Apache draait die en de php versie is volgens mij 5.2 Sorry voor de dubbel post.
Blijkbaar staat die functie uit? Informeer eens bij Mijndomein?
Ik ga even informeren, alvast bedankt!
Ik heb het even gevraagd en de functie van Apache staat gewoon aan.
Heb jij eventueel nog een idee ? :-)
instelling in PHP.ini ?
jessyg schreef op 07.10.2009 15:45
Ik heb het even gevraagd en de functie van Apache staat gewoon aan.
Heb jij eventueel nog een idee ? :-)

Het is volgens mij meer van: Heeft je hosting nog een idee?
Prior to PHP 4.3.0, apache_request_headers() was called getallheaders(). After PHP 4.3.0, getallheaders() is an alias for apache_request_headers().
Thanx Jaron, maar eergezecht snap ik het nog niet, haha!

Reageren