General: * Moved pypo author info into one file * Added two database columns in schedule table: "schedule_group_played" and "media_item_played". API clients: * Created get_liquidsoap_data() function which allows you to give arbitrary data to liquidsoap. * Added documentation * Renamed functions to make it more obvious what is happening pypo_cli: * Got rid of more constants that were not needed * Created function set_export_source() to reduce code repetition * Separated the downloading of the schedule from tracking what has been played. The tracking info is now kept in a separate file. This fixes the major bug that the playlist keeps restarting for the first minute of playback. * converted more print statements to debug statements pypoTester: * Now uses samples from the audio_samples directory, and schedules two audio clips back-to-back.
47 lines
No EOL
1.1 KiB
PHP
47 lines
No EOL
1.1 KiB
PHP
<?php
|
|
require_once('../conf.php');
|
|
require_once('../backend/StoredFile.php');
|
|
|
|
$api_key = $_GET['api_key'];
|
|
if(!in_array($api_key, $CC_CONFIG["apiKey"]))
|
|
{
|
|
header('HTTP/1.0 401 Unauthorized');
|
|
print 'You are not allowed to access this resource.';
|
|
exit;
|
|
}
|
|
|
|
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
|
|
|
|
$filename = $_GET["file"];
|
|
$file_id = substr($filename, 0, strpos($filename, "."));
|
|
if (ctype_alnum($file_id) && strlen($file_id) == 32) {
|
|
$media = StoredFile::RecallByGunid($file_id);
|
|
if ($media != null && !PEAR::isError($media)) {
|
|
//var_dump($media);
|
|
$filepath = $media->getRealFilePath();
|
|
if(!is_file($filepath))
|
|
{
|
|
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
|
|
//print 'Ressource in database, but not in storage. Sorry.';
|
|
exit;
|
|
}
|
|
|
|
// !! binary mode !!
|
|
$fp = fopen($filepath, 'rb');
|
|
|
|
header("Content-Type: audio/mpeg");
|
|
header("Content-Length: " . filesize($filepath));
|
|
|
|
fpassthru($fp);
|
|
}
|
|
else {
|
|
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
|
|
exit;
|
|
}
|
|
} else {
|
|
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
|
|
exit;
|
|
}
|
|
exit;
|
|
|
|
?>
|