diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php
index 96f99e0ec..66309b091 100644
--- a/airtime_mvc/application/controllers/ApiController.php
+++ b/airtime_mvc/application/controllers/ApiController.php
@@ -807,8 +807,6 @@ class ApiController extends Zend_Controller_Action
}
$info = Application_Model_StreamSetting::getStreamSetting();
- $info[] = (array("keyname" =>"harbor_input_port", "value"=>Application_Model_Preference::GetLiveSteamPort(), "type"=>"integer"));
- $info[] = (array("keyname" =>"harbor_input_mount_point", "value"=>Application_Model_Preference::GetLiveSteamMountPoint(), "type"=>"string"));
$this->view->msg = $info;
}
@@ -988,6 +986,7 @@ class ApiController extends Zend_Controller_Action
$username = $request->getParam('username');
$password = $request->getParam('password');
+ $djtype = $request->getParam('djtype');
if (!in_array($api_key, $CC_CONFIG["apiKey"]))
{
@@ -995,11 +994,57 @@ class ApiController extends Zend_Controller_Action
print 'You are not allowed to access this resource.';
exit;
}
- //check against master
- if($username == Application_Model_Preference::GetLiveSteamMasterUsername() && $password == Application_Model_Preference::GetLiveSteamMasterPassword()){
- $this->view->msg = true;
- }else{
- $this->view->msg = false;
+
+ Logging::log("user:".$username." pass:".$password." type:".$djtype);
+
+ if($djtype == 'master'){
+ //check against master
+ if($username == Application_Model_Preference::GetLiveSteamMasterUsername() && $password == Application_Model_Preference::GetLiveSteamMasterPassword()){
+ Logging::log("master true");
+ $this->view->msg = true;
+ }else{
+ Logging::log("master false");
+ $this->view->msg = false;
+ }
+ }elseif($djtype == "dj"){
+ Logging::log("djtype...");
+ //check against show dj auth
+ $showInfo = Application_Model_Show::GetCurrentShow();
+ if(isset($showInfo[0]['id'])){
+ $current_show_id = $showInfo[0]['id'];
+ $CcShow = CcShowQuery::create()->findPK($current_show_id);
+
+ // get custom pass info from the show
+ $custom_user = $CcShow->getDbLiveStreamUser();
+ $custom_pass = $CcShow->getDbLiveStreamPass();
+
+ Logging::log("user:".$username." pass:".$password);
+ Logging::log("c_user:".$custom_user." c_pass:".$custom_pass);
+
+ // get hosts ids
+ $show = new Application_Model_Show($current_show_id);
+ $hosts_ids = $show->getHostsIds();
+
+ // check against hosts auth
+ foreach( $hosts_ids as $host){
+ $h = new Application_Model_User($host['subjs_id']);
+ if($username == $h->getLogin() && md5($password) == $h->getPassword()){
+ $this->view->msg = true;
+ return;
+ }
+ }
+
+ // check against custom auth
+ if($username == $custom_user && $password == $custom_pass){
+ Logging::log("custom true");
+ $this->view->msg = true;
+ }else{
+ Logging::log("custom false");
+ $this->view->msg = false;
+ }
+ }else{
+ $this->view->msg = false;
+ }
}
}
}
diff --git a/airtime_mvc/application/controllers/PreferenceController.php b/airtime_mvc/application/controllers/PreferenceController.php
index 2d64effbb..1192c3775 100644
--- a/airtime_mvc/application/controllers/PreferenceController.php
+++ b/airtime_mvc/application/controllers/PreferenceController.php
@@ -205,23 +205,29 @@ class PreferenceController extends Zend_Controller_Action
$values['streamFormat'] = $form->getValue('streamFormat');
Application_Model_StreamSetting::setStreamSetting($values);
- $data = array();
- $info = Application_Model_StreamSetting::getStreamSetting();
- $info[] = (array("keyname" =>"harbor_input_port", "value"=>$values["harbor_input_port"], "type"=>"integer"));
- $info[] = (array("keyname" =>"harbor_input_mount_point", "value"=>$values["harbor_input_mount_point"], "type"=>"string"));
- $data['setting'] = $info;
- for($i=1;$i<=$num_of_stream;$i++){
- Application_Model_StreamSetting::setLiquidsoapError($i, "waiting");
- }
+
// this goes into cc_pref table
Application_Model_Preference::SetStreamLabelFormat($values['streamFormat']);
Application_Model_Preference::SetLiveSteamAutoEnable($values["auto_enable_live_stream"]);
Application_Model_Preference::SetLiveSteamMasterUsername($values["master_username"]);
Application_Model_Preference::SetLiveSteamMasterPassword($values["master_password"]);
- Application_Model_Preference::SetLiveSteamPort($values["harbor_input_port"]);
- Application_Model_Preference::SetLiveSteamMountPoint($values["harbor_input_mount_point"]);
+
+ // extra info that goes into cc_stream_setting
+ Application_Model_StreamSetting::SetMasterLiveSteamPort($values["master_harbor_input_port"]);
+ Application_Model_StreamSetting::SetMasterLiveSteamMountPoint($values["master_harbor_input_mount_point"]);
+ Application_Model_StreamSetting::SetDJLiveSteamPort($values["dj_harbor_input_port"]);
+ Application_Model_StreamSetting::SetDJLiveSteamMountPoint($values["dj_harbor_input_mount_point"]);
+
// store stream update timestamp
Application_Model_Preference::SetStreamUpdateTimestamp();
+
+ $data = array();
+ $info = Application_Model_StreamSetting::getStreamSetting();
+ $data['setting'] = $info;
+ for($i=1;$i<=$num_of_stream;$i++){
+ Application_Model_StreamSetting::setLiquidsoapError($i, "waiting");
+ }
+
Application_Model_RabbitMq::SendMessageToPypo("update_stream_setting", $data);
$this->view->statusMsg = "
Stream Setting Updated.
";
}
diff --git a/airtime_mvc/application/forms/AddShowLiveStream.php b/airtime_mvc/application/forms/AddShowLiveStream.php
index 8c79f5274..bebd88cd4 100644
--- a/airtime_mvc/application/forms/AddShowLiveStream.php
+++ b/airtime_mvc/application/forms/AddShowLiveStream.php
@@ -37,7 +37,6 @@ class Application_Form_AddShowLiveStream extends Zend_Form_SubForm
->setFilters(array('StringTrim'))
->setValidators(array(
new ConditionalNotEmpty(array("cb_custom_auth"=>"1"))))
- ->setValue(Application_Model_Preference::GetLiveSteamMasterUsername())
->setDecorators(array('ViewHelper'));
$this->addElement($custom_username);
@@ -51,7 +50,6 @@ class Application_Form_AddShowLiveStream extends Zend_Form_SubForm
->setFilters(array('StringTrim'))
->setValidators(array(
new ConditionalNotEmpty(array("cb_custom_auth"=>"1"))))
- //fix//->setValue(Application_Model_Preference::GetLiveSteamMasterUsername())
->setDecorators(array('ViewHelper'));
$this->addElement($custom_password);
diff --git a/airtime_mvc/application/forms/LiveStreamingPreferences.php b/airtime_mvc/application/forms/LiveStreamingPreferences.php
index ce210343f..a9e4847ba 100644
--- a/airtime_mvc/application/forms/LiveStreamingPreferences.php
+++ b/airtime_mvc/application/forms/LiveStreamingPreferences.php
@@ -39,17 +39,34 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
$this->addElement($master_password);
//liquidsoap harbor.input port
- $port = new Zend_Form_Element_Text('harbor_input_port');
- $port->setLabel("Port to Connect")
- ->setValue(Application_Model_Preference::GetLiveSteamPort())
+ $port = new Zend_Form_Element_Text('master_harbor_input_port');
+ $port->setLabel("Master DJ Port")
+ ->setValue(Application_Model_StreamSetting::GetMasterLiveSteamPort())
->setValidators(array(new Zend_Validate_Between(array('min'=>0, 'max'=>99999))))
->addValidator('regex', false, array('pattern'=>'/^[0-9]+$/', 'messages'=>array('regexNotMatch'=>'Only numbers are allowed.')))
->setDecorators(array('ViewHelper'));
$this->addElement($port);
- $mount = new Zend_Form_Element_Text('harbor_input_mount_point');
- $mount->setLabel("Mount Point to Connect")
- ->setValue(Application_Model_Preference::GetLiveSteamMountPoint())
+ $mount = new Zend_Form_Element_Text('master_harbor_input_mount_point');
+ $mount->setLabel("Master DJ Mount Point")
+ ->setValue(Application_Model_StreamSetting::GetMasterLiveSteamMountPoint())
+ ->setValidators(array(
+ array('regex', false, array('/^[^ &<>]+$/', 'messages' => 'Invalid character entered'))))
+ ->setDecorators(array('ViewHelper'));
+ $this->addElement($mount);
+
+ //liquidsoap harbor.input port
+ $port = new Zend_Form_Element_Text('dj_harbor_input_port');
+ $port->setLabel("DJ Port")
+ ->setValue(Application_Model_StreamSetting::GetDJLiveSteamPort())
+ ->setValidators(array(new Zend_Validate_Between(array('min'=>0, 'max'=>99999))))
+ ->addValidator('regex', false, array('pattern'=>'/^[0-9]+$/', 'messages'=>array('regexNotMatch'=>'Only numbers are allowed.')))
+ ->setDecorators(array('ViewHelper'));
+ $this->addElement($port);
+
+ $mount = new Zend_Form_Element_Text('dj_harbor_input_mount_point');
+ $mount->setLabel("DJ Mount Point")
+ ->setValue(Application_Model_StreamSetting::GetDJLiveSteamMountPoint())
->setValidators(array(
array('regex', false, array('/^[^ &<>]+$/', 'messages' => 'Invalid character entered'))))
->setDecorators(array('ViewHelper'));
diff --git a/airtime_mvc/application/models/Preference.php b/airtime_mvc/application/models/Preference.php
index d2b82e74b..d5d708418 100644
--- a/airtime_mvc/application/models/Preference.php
+++ b/airtime_mvc/application/models/Preference.php
@@ -728,22 +728,6 @@ class Application_Model_Preference
public static function GetLiveSteamMasterPassword(){
return self::GetValue("live_stream_master_password");
}
-
- public static function SetLiveSteamPort($value){
- self::SetValue("live_stream_port", $value, false);
- }
-
- public static function GetLiveSteamPort(){
- return self::GetValue("live_stream_port");
- }
-
- public static function SetLiveSteamMountPoint($value){
- self::SetValue("live_stream_mp", $value, false);
- }
-
- public static function GetLiveSteamMountPoint(){
- return self::GetValue("live_stream_mp");
- }
/* User specific preferences end */
}
diff --git a/airtime_mvc/application/models/Show.php b/airtime_mvc/application/models/Show.php
index 47a5fcdd2..0159b4487 100644
--- a/airtime_mvc/application/models/Show.php
+++ b/airtime_mvc/application/models/Show.php
@@ -104,6 +104,19 @@ class Application_Model_Show {
return $res;
}
+
+ public function getHostsIds()
+ {
+ global $CC_DBC;
+
+ $sql = "SELECT subjs_id
+ FROM cc_show_hosts
+ WHERE show_id = {$this->_showId}";
+
+ $hosts = $CC_DBC->GetAll($sql);
+
+ return $hosts;
+ }
//remove everything about this show.
public function delete()
@@ -785,6 +798,8 @@ class Application_Model_Show {
$info['allow_live_stream_override'] = $ccShow->getDbAllowLiveStream();
$info['cb_airtime_auth'] = $ccShow->getDbLiveStreamUsingAirtimeAuth();
$info['cb_custom_auth'] = $ccShow->getDbLiveStreamUsingCustomAuth();
+ $info['custom_username'] = $ccShow->getDbLiveStreamUser();
+ $info['custom_password'] = $ccShow->getDbLiveStreamPass();
return $info;
}
}
@@ -1698,9 +1713,13 @@ class Application_Model_Show {
* @param String $timeNow - current time (in UTC)
* @return array - show being played right now
*/
- public static function GetCurrentShow($timeNow)
+ public static function GetCurrentShow($timeNow=null)
{
global $CC_CONFIG, $CC_DBC;
+ if($timeNow == null){
+ $date = new Application_Model_DateHelper;
+ $timeNow = $date->getUtcTimestamp();
+ }
//TODO, returning starts + ends twice (once with an alias). Unify this after the 2.0 release. --Martin
$sql = "SELECT si.starts as start_timestamp, si.ends as end_timestamp, s.name, s.id, si.id as instance_id, si.record, s.url, starts, ends"
." FROM $CC_CONFIG[showInstances] si, $CC_CONFIG[showTable] s"
diff --git a/airtime_mvc/application/models/StreamSetting.php b/airtime_mvc/application/models/StreamSetting.php
index 0ae84a009..e2a8d0989 100644
--- a/airtime_mvc/application/models/StreamSetting.php
+++ b/airtime_mvc/application/models/StreamSetting.php
@@ -1,5 +1,48 @@
GetOne($sql);
+
+ if($result == 1) {
+ $sql = "UPDATE cc_stream_setting"
+ ." SET value = '$value', type='$type'"
+ ." WHERE keyname = '$key'";
+ } else {
+ $sql = "INSERT INTO cc_stream_setting (keyname, value, type)"
+ ." VALUES ('$key', '$value', '$type')";
+ }
+
+ return $CC_DBC->query($sql);
+ }
+
+ public static function GetValue($key){
+ global $CC_CONFIG, $CC_DBC;
+
+ //Check if key already exists
+ $sql = "SELECT COUNT(*) FROM cc_stream_setting"
+ ." WHERE keyname = '$key'";
+ $result = $CC_DBC->GetOne($sql);
+
+ if ($result == 0)
+ return "";
+ else {
+ $sql = "SELECT value FROM cc_stream_setting"
+ ." WHERE keyname = '$key'";
+
+ $result = $CC_DBC->GetOne($sql);
+ return $result;
+ }
+ }
/* Returns the id's of all streams that are enabled in an array. An
* example of the array returned in JSON notation is ["s1", "s2", "s3"] */
@@ -63,6 +106,18 @@ class Application_Model_StreamSetting {
." WHERE keyname not like '%_error'";
$rows = $CC_DBC->getAll($sql);
+ if(isset($rows["master_harbor_input_port"])){
+ $rows[] = (array("keyname" =>"master_harbor_input_port", "value"=>self::GetMasterLiveSteamPort(), "type"=>"integer"));
+ }
+ if(isset($rows["master_harbor_input_mount_point"])){
+ $rows[] = (array("keyname" =>"master_harbor_input_mount_point", "value"=>self::GetMasterLiveSteamMountPoint(), "type"=>"string"));
+ }
+ if(isset($rows["dj_harbor_input_port"])){
+ $rows[] = (array("keyname" =>"dj_harbor_input_port", "value"=>self::GetDJLiveSteamPort(), "type"=>"integer"));
+ }
+ if(isset($rows["dj_harbor_input_mount_point"])){
+ $rows[] = (array("keyname" =>"dj_harbor_input_mount_point", "value"=>self::GetDJLiveSteamMountPoint(), "type"=>"string"));
+ }
return $rows;
}
@@ -197,4 +252,36 @@ class Application_Model_StreamSetting {
}
return $out;
}
+
+ public static function SetMasterLiveSteamPort($value){
+ self::SetValue("master_live_stream_port", $value, "integer");
+ }
+
+ public static function GetMasterLiveSteamPort(){
+ return self::GetValue("master_live_stream_port");
+ }
+
+ public static function SetMasterLiveSteamMountPoint($value){
+ self::SetValue("master_live_stream_mp", $value, "string");
+ }
+
+ public static function GetMasterLiveSteamMountPoint(){
+ return self::GetValue("master_live_stream_mp");
+ }
+
+ public static function SetDJLiveSteamPort($value){
+ self::SetValue("dj_live_stream_port", $value, "integer");
+ }
+
+ public static function GetDJLiveSteamPort(){
+ return self::GetValue("dj_live_stream_port");
+ }
+
+ public static function SetDJLiveSteamMountPoint($value){
+ self::SetValue("dj_live_stream_mp", $value, "string");
+ }
+
+ public static function GetDJLiveSteamMountPoint(){
+ return self::GetValue("dj_live_stream_mp");
+ }
}
diff --git a/airtime_mvc/application/views/scripts/form/preferences_livestream.phtml b/airtime_mvc/application/views/scripts/form/preferences_livestream.phtml
index 1dda30647..9fd67479b 100644
--- a/airtime_mvc/application/views/scripts/form/preferences_livestream.phtml
+++ b/airtime_mvc/application/views/scripts/form/preferences_livestream.phtml
@@ -43,29 +43,57 @@
-
-