2015-09-29 19:04:22 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class FeedsController extends Zend_Controller_Action
|
|
|
|
{
|
|
|
|
public function stationRssAction()
|
|
|
|
{
|
2015-10-28 15:58:22 +01:00
|
|
|
$this->view->layout()->disableLayout();
|
|
|
|
$this->_helper->viewRenderer->setNoRender(true);
|
|
|
|
|
2017-11-25 07:44:01 +01:00
|
|
|
$request = $this->getRequest();
|
|
|
|
$response = $this->getResponse();
|
|
|
|
|
2015-11-04 21:57:51 +01:00
|
|
|
if ((Application_Model_Preference::getStationPodcastPrivacy()
|
2017-11-25 07:44:01 +01:00
|
|
|
&& $request->getParam("sharing_token") != Application_Model_Preference::getStationPodcastDownloadKey())
|
2015-11-26 21:25:38 +01:00
|
|
|
&& !RestAuth::verifyAuth(true, false, $this)) {
|
2017-11-25 07:44:01 +01:00
|
|
|
$response->setHttpResponseCode(401);
|
2015-10-21 23:30:24 +02:00
|
|
|
return;
|
|
|
|
}
|
2015-09-29 19:04:22 +02:00
|
|
|
|
2017-11-25 07:44:01 +01:00
|
|
|
CORSHelper::enableCrossOriginRequests($request, $response);
|
2015-09-29 19:04:22 +02:00
|
|
|
|
2015-11-18 00:34:02 +01:00
|
|
|
$rssData = Application_Service_PodcastService::createStationRssFeed();
|
|
|
|
|
|
|
|
$mimeType = "text/xml";
|
|
|
|
header("Content-Type: $mimeType; charset=UTF-8");
|
|
|
|
|
|
|
|
if (isset($_SERVER['HTTP_RANGE'])) {
|
|
|
|
header('HTTP/1.1 206 Partial Content');
|
|
|
|
} else {
|
|
|
|
header('HTTP/1.1 200 OK');
|
|
|
|
}
|
|
|
|
header("Content-Type: $mimeType");
|
|
|
|
header("Content-Transfer-Encoding: binary");
|
|
|
|
header('Cache-Control: public, must-revalidate, max-age=0');
|
|
|
|
header('Pragma: no-cache');
|
|
|
|
header('Accept-Ranges: bytes');
|
|
|
|
$size = strlen($rssData);
|
|
|
|
|
|
|
|
$begin = 0;
|
|
|
|
$end = $size - 1;
|
|
|
|
|
|
|
|
//ob_start(); //Must start a buffer here for these header() functions
|
|
|
|
|
|
|
|
if (isset($_SERVER['HTTP_RANGE'])) {
|
|
|
|
if (preg_match('/bytes=\h*(\d+)-(\d*)[\D.*]?/i', $_SERVER['HTTP_RANGE'], $matches)) {
|
|
|
|
$begin = intval($matches[1]);
|
|
|
|
if (!empty($matches[2])) {
|
|
|
|
$end = intval($matches[2]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($size > 0) {
|
|
|
|
header('Content-Length:' . (($end - $begin) + 1));
|
|
|
|
if (isset($_SERVER['HTTP_RANGE'])) {
|
|
|
|
header("Content-Range: bytes $begin-$end/$size");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
echo $rssData;
|
2015-09-29 19:04:22 +02:00
|
|
|
}
|
|
|
|
}
|