From 546980249e9bf29aa8d542e988a0f92a9607996d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Mon, 20 Jul 2020 14:03:55 +0200 Subject: [PATCH 1/3] Add a switch to force 'assume SSL' mode behind a reverse proxy, when the RP adds SSL and the internal connection is HTTP only. --- airtime_mvc/application/common/HTTPHelper.php | 3 ++- airtime_mvc/application/configs/conf.php | 1 + airtime_mvc/build/airtime.example.conf | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/airtime_mvc/application/common/HTTPHelper.php b/airtime_mvc/application/common/HTTPHelper.php index 80e6fd16e..c3ff70858 100644 --- a/airtime_mvc/application/common/HTTPHelper.php +++ b/airtime_mvc/application/common/HTTPHelper.php @@ -31,6 +31,7 @@ class Application_Common_HTTPHelper $baseUrl = $CC_CONFIG['baseUrl']; $baseDir = $CC_CONFIG['baseDir']; $basePort = $CC_CONFIG['basePort']; + $forceSSL = $CC_CONFIG['forceSSL']; if (empty($baseDir)) { $baseDir = "/"; } @@ -42,7 +43,7 @@ class Application_Common_HTTPHelper } $scheme = "http"; - if ($secured && !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') { + if ($forceSSL || ($secured && !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off')) { $scheme = "https"; $basePort = "443"; //Airtime Pro compatibility hack } diff --git a/airtime_mvc/application/configs/conf.php b/airtime_mvc/application/configs/conf.php index 964225e8c..6295d410e 100644 --- a/airtime_mvc/application/configs/conf.php +++ b/airtime_mvc/application/configs/conf.php @@ -31,6 +31,7 @@ class Config { $CC_CONFIG['basePort'] = $values['general']['base_port']; $CC_CONFIG['stationId'] = $values['general']['station_id']; $CC_CONFIG['phpDir'] = $values['general']['airtime_dir']; + $CC_CONFIG['forceSSL'] = isset($values['general']['force_ssl']) ? $values['general']['force_ssl'] : FALSE; if (isset($values['general']['dev_env'])) { $CC_CONFIG['dev_env'] = $values['general']['dev_env']; } else { diff --git a/airtime_mvc/build/airtime.example.conf b/airtime_mvc/build/airtime.example.conf index 96487f3ce..7e3ebf479 100644 --- a/airtime_mvc/build/airtime.example.conf +++ b/airtime_mvc/build/airtime.example.conf @@ -53,6 +53,7 @@ web_server_user = www-data base_url = localhost base_port = 80 base_dir = / +force_ssl = cache_ahead_hours = 1 airtime_dir = station_id = From 83862cfb8e5c1062e1ba48bdc322d257cc1e1ce2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Mon, 20 Jul 2020 14:55:32 +0200 Subject: [PATCH 2/3] Player update from https://github.com/wifiblog/playerHtml5-Libretime --- .../controllers/EmbedController.php | 3 +- .../views/scripts/embed/player.phtml | 209 +++--------------- .../public/js/airtime/player/playerhtml5.js | 20 ++ 3 files changed, 50 insertions(+), 182 deletions(-) create mode 100644 airtime_mvc/public/js/airtime/player/playerhtml5.js diff --git a/airtime_mvc/application/controllers/EmbedController.php b/airtime_mvc/application/controllers/EmbedController.php index 0898dfc18..e411b3feb 100644 --- a/airtime_mvc/application/controllers/EmbedController.php +++ b/airtime_mvc/application/controllers/EmbedController.php @@ -25,9 +25,8 @@ class EmbedController extends Zend_Controller_Action $request = $this->getRequest(); - $this->view->mrp_js = Application_Common_HTTPHelper::getStationUrl() . "js/airtime/player/mrp.js?".$CC_CONFIG['airtime_version']; + $this->view->playerhtml5_js = Application_Common_HTTPHelper::getStationUrl() . "js/airtime/player/playerhtml5.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($this->view->escape($request->getParam('title'))); $this->view->jquery_i18n = Application_Common_HTTPHelper::getStationUrl() . "js/i18n/jquery.i18n.js?"; diff --git a/airtime_mvc/application/views/scripts/embed/player.phtml b/airtime_mvc/application/views/scripts/embed/player.phtml index 853dbddc1..6b4b2cfb4 100644 --- a/airtime_mvc/application/views/scripts/embed/player.phtml +++ b/airtime_mvc/application/views/scripts/embed/player.phtml @@ -3,7 +3,7 @@ - + @@ -12,33 +12,18 @@ diff --git a/airtime_mvc/public/js/airtime/player/playerhtml5.js b/airtime_mvc/public/js/airtime/player/playerhtml5.js new file mode 100644 index 000000000..529b89386 --- /dev/null +++ b/airtime_mvc/public/js/airtime/player/playerhtml5.js @@ -0,0 +1,20 @@ +function getRandomIdPlayer(max) { + return "playerHtml5Libretime_"+Math.floor(Math.random() * Math.floor(max)); +} + +function playerhtml5_insert(settings) + { + atp=''; + if(settings.autoplay==true) atp='autoplay'; + if(settings.forceHTTPS==true&&settings.url.indexOf('https')==-1) settings.url=settings.url.replace(/http/g, 'https'); + if(settings.replacePort!=''&&settings.replacePort!=false&&settings.replacePort!='false') + { + if(settings.replacePortTo!='') settings.replacePortTo=':'+settings.replacePortTo; + settings.url=settings.url.replace(':'+settings.replacePort, settings.replacePortTo); + } + if(settings.codec=='mp3') settings.codec='mpeg'; + document.getElementById('html5player_skin').innerHTML += '