2012-02-06 23:51:02 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
|
|
|
|
{
|
2012-05-28 21:37:45 +02:00
|
|
|
|
2012-02-06 23:51:02 +01:00
|
|
|
public function init()
|
|
|
|
{
|
2012-05-28 21:37:45 +02:00
|
|
|
$isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true;
|
2012-03-21 03:16:17 +01:00
|
|
|
$defaultFade = Application_Model_Preference::GetDefaultTransitionFade();
|
|
|
|
if($defaultFade == ""){
|
|
|
|
$defaultFade = '00.000000';
|
|
|
|
}
|
|
|
|
|
|
|
|
//Default transition fade
|
|
|
|
$transition_fade = new Zend_Form_Element_Text("transition_fade");
|
|
|
|
$transition_fade->setLabel("Switch Transition Fade (s)")
|
|
|
|
->setFilters(array('StringTrim'))
|
2012-04-13 18:05:59 +02:00
|
|
|
->addValidator('regex', false, array('/^[0-9]{1,2}(\.\d{1,6})?$/',
|
2012-03-21 03:16:17 +01:00
|
|
|
'messages' => 'enter a time in seconds 00{.000000}'))
|
|
|
|
->setValue($defaultFade)
|
|
|
|
->setDecorators(array('ViewHelper'));
|
|
|
|
$this->addElement($transition_fade);
|
|
|
|
|
2012-02-06 23:51:02 +01:00
|
|
|
//Master username
|
|
|
|
$master_username = new Zend_Form_Element_Text('master_username');
|
2012-02-21 23:58:05 +01:00
|
|
|
$master_username->setAttrib('autocomplete', 'off')
|
2012-02-08 06:04:19 +01:00
|
|
|
->setAllowEmpty(true)
|
2012-02-06 23:51:02 +01:00
|
|
|
->setLabel('Master Username')
|
|
|
|
->setFilters(array('StringTrim'))
|
|
|
|
->setValue(Application_Model_Preference::GetLiveSteamMasterUsername())
|
|
|
|
->setDecorators(array('ViewHelper'));
|
|
|
|
$this->addElement($master_username);
|
|
|
|
|
|
|
|
//Master password
|
2012-02-08 06:04:19 +01:00
|
|
|
$master_password = new Zend_Form_Element_Password('master_password');
|
2012-02-21 23:58:05 +01:00
|
|
|
$master_password->setAttrib('autocomplete', 'off')
|
2012-02-08 06:04:19 +01:00
|
|
|
->setAttrib('renderPassword','true')
|
|
|
|
->setAllowEmpty(true)
|
2012-02-23 17:51:20 +01:00
|
|
|
->setValue(Application_Model_Preference::GetLiveSteamMasterPassword())
|
2012-02-06 23:51:02 +01:00
|
|
|
->setLabel('Master Password')
|
|
|
|
->setFilters(array('StringTrim'))
|
|
|
|
->setDecorators(array('ViewHelper'));
|
|
|
|
$this->addElement($master_password);
|
2012-02-23 17:11:02 +01:00
|
|
|
|
|
|
|
//liquidsoap harbor.input port
|
2012-05-28 21:37:45 +02:00
|
|
|
if (!$isSaas) {
|
|
|
|
$m_port = Application_Model_StreamSetting::GetMasterLiveSteamPort();
|
|
|
|
$master_dj_port = new Zend_Form_Element_Text('master_harbor_input_port');
|
|
|
|
$master_dj_port->setLabel("Master Source Port")
|
|
|
|
->setValue($m_port)
|
|
|
|
->setValidators(array(new Zend_Validate_Between(array('min'=>1024, 'max'=>49151))))
|
|
|
|
->addValidator('regex', false, array('pattern'=>'/^[0-9]+$/', 'messages'=>array('regexNotMatch'=>'Only numbers are allowed.')))
|
|
|
|
->setDecorators(array('ViewHelper'));
|
|
|
|
$this->addElement($master_dj_port);
|
|
|
|
|
|
|
|
$m_mount = Application_Model_StreamSetting::GetMasterLiveSteamMountPoint();
|
|
|
|
$master_dj_mount = new Zend_Form_Element_Text('master_harbor_input_mount_point');
|
|
|
|
$master_dj_mount->setLabel("Master Source Mount Point")
|
|
|
|
->setValue($m_mount)
|
|
|
|
->setValidators(array(
|
|
|
|
array('regex', false, array('/^[^ &<>]+$/', 'messages' => 'Invalid character entered'))))
|
|
|
|
->setDecorators(array('ViewHelper'));
|
|
|
|
$this->addElement($master_dj_mount);
|
|
|
|
|
|
|
|
//liquidsoap harbor.input port
|
|
|
|
$l_port = Application_Model_StreamSetting::GetDJLiveSteamPort();
|
|
|
|
$live_dj_port = new Zend_Form_Element_Text('dj_harbor_input_port');
|
|
|
|
$live_dj_port->setLabel("Show Source Port")
|
|
|
|
->setValue($l_port)
|
|
|
|
->setValidators(array(new Zend_Validate_Between(array('min'=>1024, 'max'=>49151))))
|
|
|
|
->addValidator('regex', false, array('pattern'=>'/^[0-9]+$/', 'messages'=>array('regexNotMatch'=>'Only numbers are allowed.')))
|
|
|
|
->setDecorators(array('ViewHelper'));
|
|
|
|
$this->addElement($live_dj_port);
|
|
|
|
|
|
|
|
$l_mount = Application_Model_StreamSetting::GetDJLiveSteamMountPoint();
|
|
|
|
$live_dj_mount = new Zend_Form_Element_Text('dj_harbor_input_mount_point');
|
|
|
|
$live_dj_mount->setLabel("Show Source Mount Point")
|
|
|
|
->setValue($l_mount)
|
|
|
|
->setValidators(array(
|
|
|
|
array('regex', false, array('/^[^ &<>]+$/', 'messages' => 'Invalid character entered'))))
|
|
|
|
->setDecorators(array('ViewHelper'));
|
|
|
|
$this->addElement($live_dj_mount);
|
|
|
|
}
|
2012-02-06 23:51:02 +01:00
|
|
|
}
|
2012-03-19 21:08:23 +01:00
|
|
|
|
2012-04-17 00:21:28 +02:00
|
|
|
public function updateVariables(){
|
2012-03-19 21:08:23 +01:00
|
|
|
$m_port = Application_Model_StreamSetting::GetMasterLiveSteamPort();
|
|
|
|
$m_mount = Application_Model_StreamSetting::GetMasterLiveSteamMountPoint();
|
|
|
|
$l_port = Application_Model_StreamSetting::GetDJLiveSteamPort();
|
|
|
|
$l_mount = Application_Model_StreamSetting::GetDJLiveSteamMountPoint();
|
2012-05-19 01:08:50 +02:00
|
|
|
$isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true;
|
2012-03-19 21:08:23 +01:00
|
|
|
|
|
|
|
$master_dj_connection_url = Application_Model_Preference::GetMasterDJSourceConnectionURL();
|
|
|
|
$live_dj_connection_url = Application_Model_Preference::GetLiveDJSourceConnectionURL();
|
|
|
|
|
|
|
|
$master_dj_connection_url = ($master_dj_connection_url == "")?("http://".$_SERVER['SERVER_NAME'].":".$m_port."/".$m_mount):$master_dj_connection_url;
|
|
|
|
$live_dj_connection_url = ($live_dj_connection_url == "")?"http://".$_SERVER['SERVER_NAME'].":".$l_port."/".$l_mount:$live_dj_connection_url;
|
|
|
|
|
|
|
|
if($m_port=="" || $m_mount==""){
|
|
|
|
$master_dj_connection_url = "N/A";
|
|
|
|
}
|
|
|
|
if($l_port=="" || $l_mount==""){
|
|
|
|
$live_dj_connection_url = "N/A";
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->setDecorators(array(
|
2012-05-19 01:08:50 +02:00
|
|
|
array('ViewScript', array('viewScript' => 'form/preferences_livestream.phtml', 'master_dj_connection_url'=>$master_dj_connection_url, 'live_dj_connection_url'=>$live_dj_connection_url, 'isSaas' => $isSaas))
|
2012-03-19 21:08:23 +01:00
|
|
|
));
|
|
|
|
}
|
2012-03-22 21:21:23 +01:00
|
|
|
|
|
|
|
public function isValid($data){
|
2012-05-28 21:37:45 +02:00
|
|
|
$isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true;
|
2012-03-22 21:21:23 +01:00
|
|
|
$isValid = parent::isValid($data);
|
2012-05-28 21:37:45 +02:00
|
|
|
if (!$isSaas) {
|
|
|
|
$master_harbor_input_port = $data['master_harbor_input_port'];
|
|
|
|
$dj_harbor_input_port = $data['dj_harbor_input_port'];
|
|
|
|
|
|
|
|
if($master_harbor_input_port == $dj_harbor_input_port && $master_harbor_input_port != ""){
|
|
|
|
$element = $this->getElement("dj_harbor_input_port");
|
|
|
|
$element->addError("You cannot use same port as Master DJ port.");
|
|
|
|
}
|
|
|
|
if($master_harbor_input_port != ""){
|
|
|
|
if(is_numeric($master_harbor_input_port)){
|
|
|
|
if($master_harbor_input_port != Application_Model_StreamSetting::GetMasterLiveSteamPort()){
|
|
|
|
$sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
|
|
|
|
$res = socket_bind($sock, 0, $master_harbor_input_port);
|
|
|
|
if(!$res){
|
|
|
|
$element = $this->getElement("master_harbor_input_port");
|
|
|
|
$element->addError("Port '$master_harbor_input_port' is not available.");
|
|
|
|
$isValid = false;
|
|
|
|
}
|
|
|
|
socket_close($sock);
|
2012-04-19 21:18:53 +02:00
|
|
|
}
|
2012-05-28 21:37:45 +02:00
|
|
|
}else{
|
|
|
|
$isValid = false;
|
2012-03-27 23:14:34 +02:00
|
|
|
}
|
2012-03-22 21:21:23 +01:00
|
|
|
}
|
2012-05-28 21:37:45 +02:00
|
|
|
if($dj_harbor_input_port != ""){
|
|
|
|
if(is_numeric($dj_harbor_input_port)){
|
|
|
|
if($dj_harbor_input_port != Application_Model_StreamSetting::GetDJLiveSteamPort()){
|
|
|
|
$sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
|
|
|
|
$res = socket_bind($sock, 0, $dj_harbor_input_port);
|
|
|
|
if(!$res){
|
|
|
|
$element = $this->getElement("dj_harbor_input_port");
|
|
|
|
$element->addError("Port '$dj_harbor_input_port' is not available.");
|
|
|
|
$isValid = false;
|
|
|
|
}
|
|
|
|
socket_close($sock);
|
2012-04-19 21:18:53 +02:00
|
|
|
}
|
2012-05-28 21:37:45 +02:00
|
|
|
}else{
|
|
|
|
$isValid = false;
|
2012-03-27 23:14:34 +02:00
|
|
|
}
|
2012-03-22 21:21:23 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return $isValid;
|
|
|
|
}
|
|
|
|
|
2012-05-19 01:08:50 +02:00
|
|
|
}
|