Merge saas-dev into soundcloud
This commit is contained in:
commit
459f9494c3
373 changed files with 6577 additions and 10376 deletions
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
require_once('WidgetHelper.php');
|
||||
require_once('TuneIn.php');
|
||||
|
||||
class ApiController extends Zend_Controller_Action
|
||||
|
@ -200,7 +201,7 @@ class ApiController extends Zend_Controller_Action
|
|||
}
|
||||
|
||||
// XSS exploit prevention
|
||||
$this->convertSpecialChars($result, array("name", "url"));
|
||||
WidgetHelper::convertSpecialChars($result, array("name", "url"));
|
||||
// apply user-defined timezone, or default to station
|
||||
Application_Common_DateHelper::convertTimestampsToTimezone(
|
||||
$result['currentShow'],
|
||||
|
@ -218,7 +219,7 @@ class ApiController extends Zend_Controller_Action
|
|||
$result["timezone"] = $upcase ? strtoupper($timezone) : $timezone;
|
||||
$result["timezoneOffset"] = Application_Common_DateHelper::getTimezoneOffset($timezone);
|
||||
// convert image paths to point to api endpoints
|
||||
$this->findAndConvertPaths($result);
|
||||
WidgetHelper::findAndConvertPaths($result);
|
||||
|
||||
// used by caller to determine if the airtime they are running or widgets in use is out of date.
|
||||
$result['AIRTIME_API_VERSION'] = AIRTIME_API_VERSION;
|
||||
|
@ -288,11 +289,11 @@ class ApiController extends Zend_Controller_Action
|
|||
$result = Application_Model_Schedule::GetPlayOrderRange($utcTimeEnd, $showsToRetrieve);
|
||||
|
||||
// XSS exploit prevention
|
||||
$this->convertSpecialChars($result, array("name", "url"));
|
||||
WidgetHelper::convertSpecialChars($result, array("name", "url"));
|
||||
// apply user-defined timezone, or default to station
|
||||
$this->applyLiveTimezoneAdjustments($result, $timezone, $upcase);
|
||||
// convert image paths to point to api endpoints
|
||||
$this->findAndConvertPaths($result);
|
||||
WidgetHelper::findAndConvertPaths($result);
|
||||
|
||||
// used by caller to determine if the airtime they are running or widgets in use is out of date.
|
||||
$result["station"]["AIRTIME_API_VERSION"] = AIRTIME_API_VERSION;
|
||||
|
@ -343,7 +344,7 @@ class ApiController extends Zend_Controller_Action
|
|||
* variables in the result to reflect the given timezone.
|
||||
*
|
||||
* @param object $result reference to the object to send back to the user
|
||||
* @param string $timezone the user's timezone parameter value
|
||||
* @param string $timezone the user's timezone parameter value
|
||||
* @param boolean $upcase whether the timezone output should be upcased
|
||||
*/
|
||||
private function applyLiveTimezoneAdjustments(&$result, $timezone, $upcase)
|
||||
|
@ -366,55 +367,11 @@ class ApiController extends Zend_Controller_Action
|
|||
$this->view->layout()->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender(true);
|
||||
|
||||
//weekStart is in station time.
|
||||
$weekStartDateTime = Application_Common_DateHelper::getWeekStartDateTime();
|
||||
|
||||
$dow = array("monday", "tuesday", "wednesday", "thursday", "friday",
|
||||
"saturday", "sunday", "nextmonday", "nexttuesday", "nextwednesday",
|
||||
"nextthursday", "nextfriday", "nextsaturday", "nextsunday");
|
||||
$result = WidgetHelper::getWeekInfo($this->getRequest()->getParam("timezone"));
|
||||
|
||||
$result = array();
|
||||
|
||||
// default to the station timezone
|
||||
$timezone = Application_Model_Preference::GetDefaultTimezone();
|
||||
$userDefinedTimezone = strtolower($this->getRequest()->getParam("timezone"));
|
||||
// if the timezone defined by the user exists, use that
|
||||
if (array_key_exists($userDefinedTimezone, timezone_abbreviations_list())) {
|
||||
$timezone = $userDefinedTimezone;
|
||||
}
|
||||
$utcTimezone = new DateTimeZone("UTC");
|
||||
|
||||
$weekStartDateTime->setTimezone($utcTimezone);
|
||||
$utcDayStart = $weekStartDateTime->format("Y-m-d H:i:s");
|
||||
for ($i = 0; $i < 14; $i++) {
|
||||
//have to be in station timezone when adding 1 day for daylight savings.
|
||||
$weekStartDateTime->setTimezone(new DateTimeZone($timezone));
|
||||
$weekStartDateTime->add(new DateInterval('P1D'));
|
||||
|
||||
//convert back to UTC to get the actual timestamp used for search.
|
||||
$weekStartDateTime->setTimezone($utcTimezone);
|
||||
|
||||
$utcDayEnd = $weekStartDateTime->format("Y-m-d H:i:s");
|
||||
$shows = Application_Model_Show::getNextShows($utcDayStart, "ALL", $utcDayEnd);
|
||||
$utcDayStart = $utcDayEnd;
|
||||
|
||||
// convert to user-defined timezone, or default to station
|
||||
Application_Common_DateHelper::convertTimestampsToTimezone(
|
||||
$shows,
|
||||
array("starts", "ends", "start_timestamp","end_timestamp"),
|
||||
$timezone
|
||||
);
|
||||
|
||||
$result[$dow[$i]] = $shows;
|
||||
}
|
||||
|
||||
// XSS exploit prevention
|
||||
$this->convertSpecialChars($result, array("name", "url"));
|
||||
// convert image paths to point to api endpoints
|
||||
$this->findAndConvertPaths($result);
|
||||
|
||||
//used by caller to determine if the airtime they are running or widgets in use is out of date.
|
||||
$result['AIRTIME_API_VERSION'] = AIRTIME_API_VERSION;
|
||||
|
||||
header("Content-type: text/javascript");
|
||||
|
||||
if (version_compare(phpversion(), '5.4.0', '<')) {
|
||||
|
@ -431,50 +388,6 @@ class ApiController extends Zend_Controller_Action
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Go through a given array and sanitize any potentially exploitable fields
|
||||
* by passing them through htmlspecialchars
|
||||
*
|
||||
* @param array $arr the array to sanitize
|
||||
* @param array $keys indexes of values to be sanitized
|
||||
*/
|
||||
private function convertSpecialChars(&$arr, $keys)
|
||||
{
|
||||
foreach ($arr as &$a) {
|
||||
if (is_array($a)) {
|
||||
foreach ($keys as &$key) {
|
||||
if (array_key_exists($key, $a)) {
|
||||
$a[$key] = htmlspecialchars($a[$key]);
|
||||
}
|
||||
}
|
||||
$this->convertSpecialChars($a, $keys);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively find image_path keys in the various $result subarrays,
|
||||
* and convert them to point to the show-logo endpoint
|
||||
*
|
||||
* @param array $arr the array to search
|
||||
*/
|
||||
private function findAndConvertPaths(&$arr)
|
||||
{
|
||||
$CC_CONFIG = Config::getConfig();
|
||||
$baseDir = Application_Common_OsPath::formatDirectoryWithDirectorySeparators($CC_CONFIG['baseDir']);
|
||||
|
||||
foreach ($arr as &$a) {
|
||||
if (is_array($a)) {
|
||||
if (array_key_exists("image_path", $a)) {
|
||||
$a["image_path"] = $a["image_path"] && $a["image_path"] !== '' ?
|
||||
"http://".$_SERVER['HTTP_HOST'].$baseDir."api/show-logo?id=".$a["id"] : '';
|
||||
} else {
|
||||
$this->findAndConvertPaths($a);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* API endpoint to display the show logo
|
||||
*/
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
require_once('WidgetHelper.php');
|
||||
|
||||
class EmbedController extends Zend_Controller_Action
|
||||
{
|
||||
|
@ -23,13 +24,21 @@ class EmbedController extends Zend_Controller_Action
|
|||
|
||||
$request = $this->getRequest();
|
||||
|
||||
$this->view->css = Application_Common_HTTPHelper::getStationUrl() . "css/player.css?".$CC_CONFIG['airtime_version'];
|
||||
$this->view->mrp_js = Application_Common_HTTPHelper::getStationUrl() . "js/airtime/player/mrp.js?".$CC_CONFIG['airtime_version'];
|
||||
$this->view->jquery = Application_Common_HTTPHelper::getStationUrl() . "js/libs/jquery-1.10.2.js";
|
||||
$this->view->muses_swf = Application_Common_HTTPHelper::getStationUrl() . "js/airtime/player/muses.swf";
|
||||
$this->view->metadata_api_url = Application_Common_HTTPHelper::getStationUrl() . "api/live-info";
|
||||
$this->view->player_title = json_encode($request->getParam('title'));
|
||||
|
||||
$styleParam = $request->getParam('style');
|
||||
$player_style = isset($styleParam) ? $styleParam : "basic";
|
||||
if ($player_style == "premium") {
|
||||
$this->view->css = Application_Common_HTTPHelper::getStationUrl() . "css/radio-page/premium_player.css?".$CC_CONFIG['airtime_version'];
|
||||
} else {
|
||||
$this->view->css = Application_Common_HTTPHelper::getStationUrl() . "css/player.css?".$CC_CONFIG['airtime_version'];
|
||||
}
|
||||
$this->view->player_style = $player_style;
|
||||
|
||||
$stream = $request->getParam('stream');
|
||||
$streamData = Application_Model_StreamSetting::getEnabledStreamData();
|
||||
$availableMobileStreams = array();
|
||||
|
@ -54,4 +63,44 @@ class EmbedController extends Zend_Controller_Action
|
|||
$this->view->availableMobileStreams = json_encode($availableMobileStreams);
|
||||
$this->view->availableDesktopStreams = json_encode($availableDesktopStreams);
|
||||
}
|
||||
|
||||
public function currentDayProgramAction()
|
||||
{
|
||||
$this->view->layout()->disableLayout();
|
||||
|
||||
$CC_CONFIG = Config::getConfig();
|
||||
|
||||
$this->view->css = Application_Common_HTTPHelper::getStationUrl() . "widgets/css/airtime-widgets.css?".$CC_CONFIG['airtime_version'];
|
||||
$this->view->jquery = Application_Common_HTTPHelper::getStationUrl() . "widgets/js/jquery-1.6.1.min.js?".$CC_CONFIG['airtime_version'];
|
||||
$this->view->jquery_custom = Application_Common_HTTPHelper::getStationUrl() . "widgets/js/jquery-ui-1.8.10.custom.min.js?".$CC_CONFIG['airtime_version'];
|
||||
$this->view->widget_js = Application_Common_HTTPHelper::getStationUrl() . "widgets/js/jquery.showinfo.js?".$CC_CONFIG['airtime_version'];
|
||||
}
|
||||
|
||||
public function weeklyProgramAction()
|
||||
{
|
||||
$this->view->layout()->disableLayout();
|
||||
|
||||
$CC_CONFIG = Config::getConfig();
|
||||
|
||||
$request = $this->getRequest();
|
||||
|
||||
$widgetStyle = $request->getParam('style');
|
||||
if ($widgetStyle == "premium") {
|
||||
$this->view->widgetStyle = "premium";
|
||||
$this->view->css = Application_Common_HTTPHelper::getStationUrl() . "/css/embed/weekly-schedule-widget.css?" . $CC_CONFIG['airtime_version'];
|
||||
} else {
|
||||
$this->view->widgetStyle = "basic";
|
||||
$this->view->css = Application_Common_HTTPHelper::getStationUrl() . "/css/embed/weekly-schedule-widget-basic.css?" . $CC_CONFIG['airtime_version'];
|
||||
}
|
||||
$this->view->jquery = Application_Common_HTTPHelper::getStationUrl() . "widgets/js/jquery-1.6.1.min.js?".$CC_CONFIG['airtime_version'];
|
||||
|
||||
$weeklyScheduleData = WidgetHelper::getWeekInfoV2($this->getRequest()->getParam("timezone"));
|
||||
|
||||
// Return only the current week's schedule data. In the future we may use the next week's data.
|
||||
$this->view->weeklyScheduleData = $weeklyScheduleData[0];
|
||||
|
||||
$currentDay = new DateTime("now", new DateTimeZone(Application_Model_Preference::GetTimezone()));
|
||||
//day of the month without leading zeros (1 to 31)
|
||||
$this->view->currentDayOfMonth = $currentDay->format("j");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
<?php
|
||||
|
||||
class PlayerController extends Zend_Controller_Action
|
||||
class EmbeddableWidgetsController extends Zend_Controller_Action
|
||||
{
|
||||
|
||||
public function init()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function customizeAction()
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
$CC_CONFIG = Config::getConfig();
|
||||
$baseUrl = Application_Common_OsPath::getBaseDir();
|
||||
|
@ -20,12 +21,17 @@ class PlayerController extends Zend_Controller_Action
|
|||
$numEnabledStreams = $form->getElement('player_stream_url')->getAttrib('numberOfEnabledStreams');
|
||||
|
||||
if ($numEnabledStreams > 0 && $apiEnabled) {
|
||||
$this->view->form = $form;
|
||||
$this->view->player_form = $form;
|
||||
} else {
|
||||
$this->view->errorMsg = "To configure and use the embeddable player you must:<br><br>
|
||||
$this->view->player_error_msg = _("To configure and use the embeddable player you must:<br><br>
|
||||
1. Enable at least one MP3, AAC, or OGG stream under System -> Streams<br>
|
||||
2. Enable the Public Airtime API under System -> Preferences";
|
||||
2. Enable the Public Airtime API under System -> Preferences");
|
||||
}
|
||||
|
||||
if (!$apiEnabled) {
|
||||
$this->view->weekly_schedule_error_msg = _("To use the embeddable weekly schedule you must:<br><br>
|
||||
1. Enable the Public Airtime API under System -> Preferences");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -38,9 +38,12 @@ class ErrorController extends Zend_Controller_Action {
|
|||
}
|
||||
|
||||
// Log exception, if logger available
|
||||
/* No idea why this doesn't work or why it was implemented like this. Disabling it -- Albert
|
||||
if (($log = $this->getLog())) {
|
||||
$log->crit($this->view->message, $errors->exception);
|
||||
}
|
||||
}*/
|
||||
//Logging that actually works: -- Albert
|
||||
Logging::error($this->view->message . ": " . $errors->exception);
|
||||
|
||||
// conditionally display exceptions
|
||||
if ($this->getInvokeArg('displayExceptions') == true) {
|
||||
|
|
|
@ -10,7 +10,24 @@ class IndexController extends Zend_Controller_Action
|
|||
|
||||
public function indexAction()
|
||||
{
|
||||
$this->_redirect('Showbuilder');
|
||||
$CC_CONFIG = Config::getConfig();
|
||||
$baseUrl = Application_Common_OsPath::getBaseDir();
|
||||
$this->view->headLink()->setStylesheet($baseUrl.'css/radio-page/radio-page.css?'.$CC_CONFIG['airtime_version']);
|
||||
$this->view->headLink()->appendStylesheet($baseUrl.'css/embed/weekly-schedule-widget.css?'.$CC_CONFIG['airtime_version']);
|
||||
|
||||
$this->_helper->layout->setLayout('radio-page');
|
||||
|
||||
$this->view->stationLogo = Application_Model_Preference::GetStationLogo();
|
||||
|
||||
$stationName = Application_Model_Preference::GetStationName();
|
||||
$this->view->stationName = $stationName;
|
||||
|
||||
$stationDescription = Application_Model_Preference::GetStationDescription();
|
||||
$this->view->stationDescription = $stationDescription;
|
||||
|
||||
$this->view->stationUrl = Application_Common_HTTPHelper::getStationUrl();
|
||||
|
||||
$this->view->baseUrl = Application_Common_OsPath::getBaseDir();
|
||||
}
|
||||
|
||||
public function mainAction()
|
||||
|
|
|
@ -13,18 +13,9 @@ class SystemstatusController extends Zend_Controller_Action
|
|||
|
||||
public function indexAction()
|
||||
{
|
||||
/*
|
||||
$services = array(
|
||||
"pypo"=>Application_Model_Systemstatus::GetPypoStatus(),
|
||||
"liquidsoap"=>Application_Model_Systemstatus::GetLiquidsoapStatus(),
|
||||
//"media-monitor"=>Application_Model_Systemstatus::GetMediaMonitorStatus(),
|
||||
);
|
||||
*/
|
||||
|
||||
$partitions = Application_Model_Systemstatus::GetDiskInfo();
|
||||
|
||||
$this->view->status = new StdClass;
|
||||
//$this->view->status->services = $services;
|
||||
$this->view->status->partitions = $partitions;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,40 +13,25 @@ class UpgradeController extends Zend_Controller_Action
|
|||
return;
|
||||
}
|
||||
|
||||
// Get all upgrades dynamically (in declaration order!) so we don't have to add them explicitly each time
|
||||
// TODO: explicitly sort classnames by ascending version suffix for safety
|
||||
$upgraders = getUpgrades();
|
||||
try {
|
||||
$upgradeManager = new UpgradeManager();
|
||||
$didWePerformAnUpgrade = $upgradeManager->doUpgrade();
|
||||
|
||||
$didWePerformAnUpgrade = false;
|
||||
try
|
||||
{
|
||||
foreach ($upgraders as $upgrader)
|
||||
{
|
||||
/** @var $upgrader AirtimeUpgrader */
|
||||
$upgrader = new $upgrader();
|
||||
if ($upgrader->checkIfUpgradeSupported())
|
||||
{
|
||||
// pass __DIR__ to the upgrades, since __DIR__ returns parent dir of file, not executor
|
||||
$upgrader->upgrade(__DIR__); //This will throw an exception if the upgrade fails.
|
||||
$didWePerformAnUpgrade = true;
|
||||
$this->getResponse()
|
||||
->setHttpResponseCode(200)
|
||||
->appendBody("Upgrade to Airtime " . $upgrader->getNewVersion() . " OK<br>");
|
||||
}
|
||||
}
|
||||
|
||||
if (!$didWePerformAnUpgrade)
|
||||
{
|
||||
if (!$didWePerformAnUpgrade) {
|
||||
$this->getResponse()
|
||||
->setHttpResponseCode(200)
|
||||
->appendBody("No upgrade was performed. The current Airtime version is " . AirtimeUpgrader::getCurrentVersion() . ".<br>");
|
||||
->setHttpResponseCode(200)
|
||||
->appendBody("No upgrade was performed. The current schema version is " . Application_Model_Preference::GetSchemaVersion() . ".<br>");
|
||||
} else {
|
||||
$this->getResponse()
|
||||
->setHttpResponseCode(200)
|
||||
->appendBody("Upgrade to Airtime schema version " . Application_Model_Preference::GetSchemaVersion() . " OK<br>");
|
||||
}
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
$this->getResponse()
|
||||
->setHttpResponseCode(400)
|
||||
->appendBody($e->getMessage());
|
||||
->setHttpResponseCode(400)
|
||||
->appendBody($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -102,7 +102,6 @@ class UserController extends Zend_Controller_Action
|
|||
public function getHostsAction()
|
||||
{
|
||||
$search = $this->_getParam('term');
|
||||
$res = Application_Model_User::getHosts($search);
|
||||
$this->view->hosts = Application_Model_User::getHosts($search);
|
||||
}
|
||||
|
||||
|
|
|
@ -139,12 +139,15 @@ class Zend_Controller_Plugin_Acl extends Zend_Controller_Plugin_Abstract
|
|||
}
|
||||
else //Non-REST, regular Airtime web app requests
|
||||
{
|
||||
//Redirect you to the login screen since you have no session.
|
||||
if ($controller !== 'login') {
|
||||
// Redirect user to the landing page if they are trying to
|
||||
// access a resource that requires a valid session.
|
||||
// Skip the redirection if they are already on the landing page
|
||||
// or the login page.
|
||||
if ($controller !== 'index' && $controller !== 'login') {
|
||||
|
||||
if ($request->isXmlHttpRequest()) {
|
||||
|
||||
$url = 'http://'.$request->getHttpHost().'/login';
|
||||
$url = 'http://'.$request->getHttpHost().'/';
|
||||
$json = Zend_Json::encode(array('auth' => false, 'url' => $url));
|
||||
|
||||
// Prepare response
|
||||
|
@ -157,7 +160,7 @@ class Zend_Controller_Plugin_Acl extends Zend_Controller_Plugin_Abstract
|
|||
Zend_Controller_Action_HelperBroker::getStaticHelper('redirector')->redirectAndExit();
|
||||
} else {
|
||||
$r = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
|
||||
$r->gotoSimpleAndExit('index', 'login', $request->getModuleName());
|
||||
$r->gotoSimpleAndExit('index', 'index', $request->getModuleName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
-- Replacing system_version with schema_version
|
||||
DELETE FROM cc_pref WHERE keystr = 'system_version';
|
||||
INSERT INTO cc_pref (keystr, valstr) VALUES ('schema_version', '2.5.2');
|
||||
|
||||
ALTER TABLE cc_show ADD COLUMN image_path varchar(255) DEFAULT '';
|
||||
ALTER TABLE cc_show_instances ADD COLUMN description varchar(255) DEFAULT '';
|
Loading…
Add table
Add a link
Reference in a new issue