public function startFrom() { $setting = $this->setting; if (Application_Model_Preference::GetPlanLevel() == 'disabled') { $output_sound_device = new Zend_Form_Element_Checkbox('output_sound_device'); $output_sound_device->setLabel('Hardware Audio Output')->setRequired(false)->setValue($setting['output_sound_device'] == "true" ? 1 : 0)->setDecorators(array('ViewHelper')); if (Application_Model_Preference::GetEnableStreamConf() == "false") { $output_sound_device->setAttrib("readonly", true); } $this->addElement($output_sound_device); $output_types = array("ALSA" => "ALSA", "AO" => "AO", "OSS" => "OSS", "Portaudio" => "Portaudio", "Pulseaudio" => "Pulseaudio"); $output_type = new Zend_Form_Element_Select('output_sound_device_type'); $output_type->setLabel("Output Type")->setMultiOptions($output_types)->setValue($setting['output_sound_device_type'])->setDecorators(array('ViewHelper')); if ($setting['output_sound_device'] != "true") { $output_type->setAttrib("disabled", "disabled"); } $this->addElement($output_type); } $icecast_vorbis_metadata = new Zend_Form_Element_Checkbox('icecast_vorbis_metadata'); $icecast_vorbis_metadata->setLabel('Icecast Vorbis Metadata')->setRequired(false)->setValue($setting['icecast_vorbis_metadata'] == "true" ? 1 : 0)->setDecorators(array('ViewHelper')); if (Application_Model_Preference::GetEnableStreamConf() == "false") { $icecast_vorbis_metadata->setAttrib("readonly", true); } $this->addElement($icecast_vorbis_metadata); $stream_format = new Zend_Form_Element_Radio('streamFormat'); $stream_format->setLabel('Stream Label:'); $stream_format->setMultiOptions(array("Artist - Title", "Show - Artist - Title", "Station name - Show name")); $stream_format->setValue(Application_Model_Preference::GetStreamLabelFormat()); $stream_format->setDecorators(array('ViewHelper')); $this->addElement($stream_format); }
public function startFrom() { $setting = $this->setting; if (Application_Model_Preference::GetPlanLevel() == 'disabled') { $output_sound_device = new Zend_Form_Element_Checkbox('output_sound_device'); $output_sound_device->setLabel(_('Hardware Audio Output'))->setRequired(false)->setValue($setting['output_sound_device'] == "true" ? 1 : 0)->setDecorators(array('ViewHelper')); if (Application_Model_Preference::GetEnableStreamConf() == "false") { $output_sound_device->setAttrib("readonly", true); } $this->addElement($output_sound_device); $output_types = array("ALSA" => "ALSA", "AO" => "AO", "OSS" => "OSS", "Portaudio" => "Portaudio", "Pulseaudio" => "Pulseaudio"); $output_type = new Zend_Form_Element_Select('output_sound_device_type'); $output_type->setLabel(_("Output Type"))->setMultiOptions($output_types)->setValue($setting['output_sound_device_type'])->setDecorators(array('ViewHelper')); if ($setting['output_sound_device'] != "true") { $output_type->setAttrib("disabled", "disabled"); } $this->addElement($output_type); } $icecast_vorbis_metadata = new Zend_Form_Element_Checkbox('icecast_vorbis_metadata'); $icecast_vorbis_metadata->setLabel(_('Icecast Vorbis Metadata'))->setRequired(false)->setValue($setting['icecast_vorbis_metadata'] == "true" ? 1 : 0)->setDecorators(array('ViewHelper')); if (Application_Model_Preference::GetEnableStreamConf() == "false") { $icecast_vorbis_metadata->setAttrib("readonly", true); } $this->addElement($icecast_vorbis_metadata); $stream_format = new Zend_Form_Element_Radio('streamFormat'); $stream_format->setLabel(_('Stream Label:')); $stream_format->setMultiOptions(array(_("Artist - Title"), _("Show - Artist - Title"), _("Station name - Show name"))); $stream_format->setValue(Application_Model_Preference::GetStreamLabelFormat()); $stream_format->setDecorators(array('ViewHelper')); $this->addElement($stream_format); $offAirMeta = new Zend_Form_Element_Text('offAirMeta'); $offAirMeta->setLabel(_('Off Air Metadata'))->setValue(Application_Model_StreamSetting::getOffAirMeta())->setDecorators(array('ViewHelper')); $this->addElement($offAirMeta); $enable_replay_gain = new Zend_Form_Element_Checkbox("enableReplayGain"); $enable_replay_gain->setLabel(_("Enable Replay Gain"))->setValue(Application_Model_Preference::GetEnableReplayGain())->setDecorators(array('ViewHelper')); $this->addElement($enable_replay_gain); $replay_gain = new Zend_Form_Element_Hidden("replayGainModifier"); $replay_gain->setLabel(_("Replay Gain Modifier"))->setValue(Application_Model_Preference::getReplayGainModifier())->setAttribs(array('style' => "border: 0; color: #f6931f; font-weight: bold;"))->setDecorators(array('ViewHelper')); $this->addElement($replay_gain); }
public function init() { global $CC_CONFIG; $isDemo = isset($CC_CONFIG['demo']) && $CC_CONFIG['demo'] == 1; $isStreamConfigable = Application_Model_Preference::GetEnableStreamConf() == "true"; $isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled' ? false : true; $defaultFade = Application_Model_Preference::GetDefaultTransitionFade(); if ($defaultFade == "") { $defaultFade = '00.000000'; } // automatic trasition on source disconnection $auto_transition = new Zend_Form_Element_Checkbox("auto_transition"); $auto_transition->setLabel("Auto Switch Off")->setValue(Application_Model_Preference::GetAutoTransition())->setDecorators(array('ViewHelper')); $this->addElement($auto_transition); // automatic switch on upon source connection $auto_switch = new Zend_Form_Element_Checkbox("auto_switch"); $auto_switch->setLabel("Auto Switch On")->setValue(Application_Model_Preference::GetAutoSwitch())->setDecorators(array('ViewHelper')); $this->addElement($auto_switch); // Default transition fade $transition_fade = new Zend_Form_Element_Text("transition_fade"); $transition_fade->setLabel("Switch Transition Fade (s)")->setFilters(array('StringTrim'))->addValidator('regex', false, array('/^[0-9]{1,2}(\\.\\d{1,6})?$/', 'messages' => 'enter a time in seconds 00{.000000}'))->setValue($defaultFade)->setDecorators(array('ViewHelper')); $this->addElement($transition_fade); //Master username $master_username = new Zend_Form_Element_Text('master_username'); $master_username->setAttrib('autocomplete', 'off')->setAllowEmpty(true)->setLabel('Master Username')->setFilters(array('StringTrim'))->setValue(Application_Model_Preference::GetLiveStreamMasterUsername())->setDecorators(array('ViewHelper')); $this->addElement($master_username); //Master password if ($isDemo) { $master_password = new Zend_Form_Element_Text('master_password'); } else { $master_password = new Zend_Form_Element_Password('master_password'); $master_password->setAttrib('renderPassword', 'true'); } $master_password->setAttrib('autocomplete', 'off')->setAttrib('renderPassword', 'true')->setAllowEmpty(true)->setValue(Application_Model_Preference::GetLiveStreamMasterPassword())->setLabel('Master Password')->setFilters(array('StringTrim'))->setDecorators(array('ViewHelper')); $this->addElement($master_password); //Master source connection url $master_dj_connection_url = new Zend_Form_Element_Text('master_dj_connection_url'); $master_dj_connection_url->setAttrib('readonly', true)->setLabel('Master Source Connection URL')->setValue(Application_Model_Preference::GetMasterDJSourceConnectionURL())->setDecorators(array('ViewHelper')); $this->addElement($master_dj_connection_url); //Show source connection url $live_dj_connection_url = new Zend_Form_Element_Text('live_dj_connection_url'); $live_dj_connection_url->setAttrib('readonly', true)->setLabel('Show Source Connection URL')->setValue(Application_Model_Preference::GetLiveDJSourceConnectionURL())->setDecorators(array('ViewHelper')); $this->addElement($live_dj_connection_url); //liquidsoap harbor.input port if (!$isSaas) { $m_port = Application_Model_StreamSetting::getMasterLiveStreamPort(); $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::getMasterLiveStreamMountPoint(); $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::getDjLiveStreamPort(); $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::getDjLiveStreamMountPoint(); $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); } // demo only code if (!$isStreamConfigable) { $elements = $this->getElements(); foreach ($elements as $element) { if ($element->getType() != 'Zend_Form_Element_Hidden') { $element->setAttrib("disabled", "disabled"); } } } }
public function streamSettingAction() { global $CC_CONFIG; $request = $this->getRequest(); $baseUrl = $request->getBaseUrl(); $this->view->headScript()->appendFile($baseUrl . '/js/airtime/preferences/streamsetting.js?' . $CC_CONFIG['airtime_version'], 'text/javascript'); $isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled' ? false : true; // get current settings $temp = Application_Model_StreamSetting::getStreamSetting(); $setting = array(); foreach ($temp as $t) { $setting[$t['keyname']] = $t['value']; } // get predefined type and bitrate from pref table $temp_types = Application_Model_Preference::GetStreamType(); $stream_types = array(); foreach ($temp_types as $type) { if (trim($type) == "ogg") { $temp = "OGG/VORBIS"; } else { $temp = strtoupper(trim($type)); } $stream_types[trim($type)] = $temp; } $temp_bitrate = Application_Model_Preference::GetStreamBitrate(); $max_bitrate = intval(Application_Model_Preference::GetMaxBitrate()); $stream_bitrates = array(); foreach ($temp_bitrate as $type) { if (intval($type) <= $max_bitrate) { $stream_bitrates[trim($type)] = strtoupper(trim($type)) . " Kbit/s"; } } $num_of_stream = intval(Application_Model_Preference::GetNumOfStreams()); $form = new Application_Form_StreamSetting(); $form->setSetting($setting); $form->startFrom(); $live_stream_subform = new Application_Form_LiveStreamingPreferences(); $form->addSubForm($live_stream_subform, "live_stream_subform"); for ($i = 1; $i <= $num_of_stream; $i++) { $subform = new Application_Form_StreamSettingSubForm(); $subform->setPrefix($i); $subform->setSetting($setting); $subform->setStreamTypes($stream_types); $subform->setStreamBitrates($stream_bitrates); $subform->startForm(); $form->addSubForm($subform, "s" . $i . "_subform"); } if ($request->isPost()) { $values = $request->getPost(); $error = false; if ($form->isValid($values)) { if (!$isSaas) { $values['output_sound_device'] = $form->getValue('output_sound_device'); $values['output_sound_device_type'] = $form->getValue('output_sound_device_type'); } $values['icecast_vorbis_metadata'] = $form->getValue('icecast_vorbis_metadata'); $values['streamFormat'] = $form->getValue('streamFormat'); Application_Model_StreamSetting::setStreamSetting($values); // this goes into cc_pref table Application_Model_Preference::SetStreamLabelFormat($values['streamFormat']); Application_Model_Preference::SetLiveStreamMasterUsername($values["master_username"]); Application_Model_Preference::SetLiveStreamMasterPassword($values["master_password"]); Application_Model_Preference::SetDefaultTransitionFade($values["transition_fade"]); Application_Model_Preference::SetAutoTransition($values["auto_transition"]); Application_Model_Preference::SetAutoSwitch($values["auto_switch"]); if (!$isSaas) { if (!Application_Model_Preference::GetMasterDjConnectionUrlOverride()) { $master_connection_url = "http://" . $_SERVER['SERVER_NAME'] . ":" . $values["master_harbor_input_port"] . "/" . $values["master_harbor_input_mount_point"]; if (empty($values["master_harbor_input_port"]) || empty($values["master_harbor_input_mount_point"])) { Application_Model_Preference::SetMasterDJSourceConnectionURL('N/A'); } else { Application_Model_Preference::SetMasterDJSourceConnectionURL($master_connection_url); } } else { Application_Model_Preference::SetMasterDJSourceConnectionURL($values["master_dj_connection_url"]); } if (!Application_Model_Preference::GetLiveDjConnectionUrlOverride()) { $live_connection_url = "http://" . $_SERVER['SERVER_NAME'] . ":" . $values["dj_harbor_input_port"] . "/" . $values["dj_harbor_input_mount_point"]; if (empty($values["dj_harbor_input_port"]) || empty($values["dj_harbor_input_mount_point"])) { Application_Model_Preference::SetLiveDJSourceConnectionURL('N/A'); } else { Application_Model_Preference::SetLiveDJSourceConnectionURL($live_connection_url); } } else { Application_Model_Preference::SetLiveDJSourceConnectionURL($values["live_dj_connection_url"]); } // extra info that goes into cc_stream_setting Application_Model_StreamSetting::setMasterLiveStreamPort($values["master_harbor_input_port"]); Application_Model_StreamSetting::setMasterLiveStreamMountPoint($values["master_harbor_input_mount_point"]); Application_Model_StreamSetting::setDjLiveStreamPort($values["dj_harbor_input_port"]); Application_Model_StreamSetting::setDjLiveStreamMountPoint($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 = "<div class='success'>Stream Setting Updated.</div>"; } } $live_stream_subform->updateVariables(); $this->view->confirm_pypo_restart_text = "If you change the username or password values for an enabled stream the playout engine will be rebooted and your listeners will hear silence for 5-10 seconds. Changing the following fields will NOT cause a reboot: Stream Label (Global Settings), and Switch Transition Fade(s), Master Username, and Master Password (Input Stream Settings). If Airtime is recording, and if the change causes a playout engine restart, the recording will be interrupted."; $this->view->num_stream = $num_of_stream; $this->view->enable_stream_conf = Application_Model_Preference::GetEnableStreamConf(); $this->view->form = $form; }
public function startForm() { $prefix = "s" . $this->prefix; $stream_number = $this->prefix; $setting = $this->setting; $stream_types = $this->stream_types; $stream_bitrates = $this->stream_bitrates; $this->setIsArray(true); $this->setElementsBelongTo($prefix . "_data"); $disable_all = Application_Model_Preference::GetEnableStreamConf() == "false"; $enable = new Zend_Form_Element_Checkbox('enable'); $enable->setLabel('Enabled:')->setValue($setting[$prefix . '_enable'] == 'true' ? 1 : 0)->setDecorators(array('ViewHelper')); if ($disable_all) { $enable->setAttrib("disabled", "disabled"); } $this->addElement($enable); $type = new Zend_Form_Element_Select('type'); $type->setLabel("Stream Type:")->setMultiOptions($stream_types)->setValue(isset($setting[$prefix . '_type']) ? $setting[$prefix . '_type'] : 0)->setDecorators(array('ViewHelper')); if ($disable_all) { $type->setAttrib("disabled", "disabled"); } $this->addElement($type); $bitrate = new Zend_Form_Element_Select('bitrate'); $bitrate->setLabel("Bit Rate:")->setMultiOptions($stream_bitrates)->setValue(isset($setting[$prefix . '_bitrate']) ? $setting[$prefix . '_bitrate'] : 0)->setDecorators(array('ViewHelper')); if ($disable_all) { $bitrate->setAttrib("disabled", "disabled"); } $this->addElement($bitrate); $output = new Zend_Form_Element_Select('output'); $output->setLabel("Service Type:")->setMultiOptions(array("icecast" => "Icecast", "shoutcast" => "SHOUTcast"))->setValue(isset($setting[$prefix . '_output']) ? $setting[$prefix . '_output'] : "icecast")->setDecorators(array('ViewHelper')); if ($disable_all) { $output->setAttrib("disabled", "disabled"); } $this->addElement($output); $channels = new Zend_Form_Element_Select('channels'); $channels->setLabel("Channels:")->setMultiOptions(array("mono" => "1 - Mono", "stereo" => "2 - Stereo"))->setValue(isset($setting[$prefix . '_channels']) ? $setting[$prefix . '_channels'] : "stereo")->setDecorators(array('ViewHelper')); if ($disable_all) { $channels->setAttrib("disabled", "disabled"); } $this->addElement($channels); $host = new Zend_Form_Element_Text('host'); $host->setLabel("Server")->setValue(isset($setting[$prefix . '_host']) ? $setting[$prefix . '_host'] : "")->setValidators(array(array('regex', false, array('/^[0-9a-zA-Z-_.]+$/', 'messages' => 'Invalid character entered'))))->setDecorators(array('ViewHelper')); if ($disable_all) { $host->setAttrib("disabled", "disabled"); } $host->setAttrib('alt', 'domain'); $this->addElement($host); $port = new Zend_Form_Element_Text('port'); $port->setLabel("Port")->setValue(isset($setting[$prefix . '_port']) ? $setting[$prefix . '_port'] : "")->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')); if ($disable_all) { $port->setAttrib("disabled", "disabled"); } $this->addElement($port); $pass = new Zend_Form_Element_Text('pass'); $pass->setLabel("Password")->setValue(isset($setting[$prefix . '_pass']) ? $setting[$prefix . '_pass'] : "")->setValidators(array(array('regex', false, array('/^[^ &<>]+$/', 'messages' => 'Invalid character entered'))))->setDecorators(array('ViewHelper')); if ($disable_all) { $pass->setAttrib("disabled", "disabled"); } $pass->setAttrib('alt', 'regular_text'); $this->addElement($pass); $genre = new Zend_Form_Element_Text('genre'); $genre->setLabel("Genre")->setValue(isset($setting[$prefix . '_genre']) ? $setting[$prefix . '_genre'] : "")->setDecorators(array('ViewHelper')); if ($disable_all) { $genre->setAttrib("disabled", "disabled"); } $this->addElement($genre); $url = new Zend_Form_Element_Text('url'); $url->setLabel("URL")->setValue(isset($setting[$prefix . '_url']) ? $setting[$prefix . '_url'] : "")->setValidators(array(array('regex', false, array('/^[0-9a-zA-Z\\-_.:\\/]+$/', 'messages' => 'Invalid character entered'))))->setDecorators(array('ViewHelper')); if ($disable_all) { $url->setAttrib("disabled", "disabled"); } $url->setAttrib('alt', 'url'); $this->addElement($url); $name = new Zend_Form_Element_Text('name'); $name->setLabel("Name")->setValue(isset($setting[$prefix . '_name']) ? $setting[$prefix . '_name'] : "")->setDecorators(array('ViewHelper')); if ($disable_all) { $name->setAttrib("disabled", "disabled"); } $this->addElement($name); $description = new Zend_Form_Element_Text('description'); $description->setLabel("Description")->setValue(isset($setting[$prefix . '_description']) ? $setting[$prefix . '_description'] : "")->setDecorators(array('ViewHelper')); if ($disable_all) { $description->setAttrib("disabled", "disabled"); } $this->addElement($description); $mount = new Zend_Form_Element_Text('mount'); $mount->setLabel("Mount Point")->setValue(isset($setting[$prefix . '_mount']) ? $setting[$prefix . '_mount'] : "")->setValidators(array(array('regex', false, array('/^[^ &<>]+$/', 'messages' => 'Invalid character entered'))))->setDecorators(array('ViewHelper')); if ($disable_all) { $mount->setAttrib("disabled", "disabled"); } $mount->setAttrib('alt', 'regular_text'); $this->addElement($mount); $user = new Zend_Form_Element_Text('user'); $user->setLabel("Username")->setValue(isset($setting[$prefix . '_user']) ? $setting[$prefix . '_user'] : "")->setValidators(array(array('regex', false, array('/^[^ &<>]+$/', 'messages' => 'Invalid character entered'))))->setDecorators(array('ViewHelper')); if ($disable_all) { $user->setAttrib("disabled", "disabled"); } $user->setAttrib('alt', 'regular_text'); $this->addElement($user); $liquidsopa_error_msg = '<div class="stream-status status-info"><h3>Getting information from the server...</h3></div>'; $this->setDecorators(array(array('ViewScript', array('viewScript' => 'form/stream-setting-form.phtml', "stream_number" => $stream_number, "enabled" => $enable->getValue(), "liquidsoap_error_msg" => $liquidsopa_error_msg)))); }
public function streamSettingAction() { $CC_CONFIG = Config::getConfig(); $request = $this->getRequest(); $baseUrl = Application_Common_OsPath::getBaseDir(); $this->view->headScript()->appendFile($baseUrl . 'js/airtime/preferences/streamsetting.js?' . $CC_CONFIG['airtime_version'], 'text/javascript'); // get current settings $temp = Application_Model_StreamSetting::getStreamSetting(); $setting = array(); foreach ($temp as $t) { $setting[$t['keyname']] = $t['value']; } $name_map = array('ogg' => 'Ogg Vorbis', 'fdkaac' => 'AAC+', 'aac' => 'AAC', 'opus' => 'Opus', 'mp3' => 'MP3'); // get predefined type and bitrate from pref table $temp_types = Application_Model_Preference::GetStreamType(); $stream_types = array(); foreach ($temp_types as $type) { $type = strtolower(trim($type)); if (isset($name_map[$type])) { $name = $name_map[$type]; } else { $name = $type; } $stream_types[$type] = $name; } $temp_bitrate = Application_Model_Preference::GetStreamBitrate(); $max_bitrate = intval(Application_Model_Preference::GetMaxBitrate()); $stream_bitrates = array(); foreach ($temp_bitrate as $type) { if (intval($type) <= $max_bitrate) { $stream_bitrates[trim($type)] = strtoupper(trim($type)) . " kbit/s"; } } $num_of_stream = intval(Application_Model_Preference::GetNumOfStreams()); $form = new Application_Form_StreamSetting(); $form->setSetting($setting); $form->startFrom(); $live_stream_subform = new Application_Form_LiveStreamingPreferences(); $form->addSubForm($live_stream_subform, "live_stream_subform"); for ($i = 1; $i <= $num_of_stream; $i++) { $subform = new Application_Form_StreamSettingSubForm(); $subform->setPrefix($i); $subform->setSetting($setting); $subform->setStreamTypes($stream_types); $subform->setStreamBitrates($stream_bitrates); $subform->startForm(); $form->addSubForm($subform, "s" . $i . "_subform"); } if ($request->isPost()) { $params = $request->getPost(); /* Parse through post data and put in format * $form->isValid() is expecting it in */ $postData = explode('&', $params['data']); $s1_data = array(); $s2_data = array(); $s3_data = array(); $values = array(); foreach ($postData as $k => $v) { $v = explode('=', urldecode($v)); if (strpos($v[0], "s1_data") !== false) { /* In this case $v[0] may be 's1_data[enable]' , for example. * We only want the 'enable' part */ preg_match('/\\[(.*)\\]/', $v[0], $matches); $s1_data[$matches[1]] = $v[1]; } elseif (strpos($v[0], "s2_data") !== false) { preg_match('/\\[(.*)\\]/', $v[0], $matches); $s2_data[$matches[1]] = $v[1]; } elseif (strpos($v[0], "s3_data") !== false) { preg_match('/\\[(.*)\\]/', $v[0], $matches); $s3_data[$matches[1]] = $v[1]; } else { $values[$v[0]] = $v[1]; } } $values["s1_data"] = $s1_data; $values["s2_data"] = $s2_data; $values["s3_data"] = $s3_data; $error = false; if ($form->isValid($values)) { $values['output_sound_device'] = $form->getValue('output_sound_device'); $values['output_sound_device_type'] = $form->getValue('output_sound_device_type'); $values['icecast_vorbis_metadata'] = $form->getValue('icecast_vorbis_metadata'); $values['streamFormat'] = $form->getValue('streamFormat'); Application_Model_StreamSetting::setStreamSetting($values); /* If the admin password values are empty then we should not * set the pseudo password ('xxxxxx') on the front-end */ $s1_set_admin_pass = !empty($values["s1_data"]["admin_pass"]); $s2_set_admin_pass = !empty($values["s2_data"]["admin_pass"]); $s3_set_admin_pass = !empty($values["s3_data"]["admin_pass"]); // this goes into cc_pref table Application_Model_Preference::SetStreamLabelFormat($values['streamFormat']); Application_Model_Preference::SetLiveStreamMasterUsername($values["master_username"]); Application_Model_Preference::SetLiveStreamMasterPassword($values["master_password"]); Application_Model_Preference::SetDefaultTransitionFade($values["transition_fade"]); Application_Model_Preference::SetAutoTransition($values["auto_transition"]); Application_Model_Preference::SetAutoSwitch($values["auto_switch"]); // compare new values with current value $changeRGenabled = Application_Model_Preference::GetEnableReplayGain() != $values["enableReplayGain"]; $changeRGmodifier = Application_Model_Preference::getReplayGainModifier() != $values["replayGainModifier"]; if ($changeRGenabled || $changeRGmodifier) { Application_Model_Preference::SetEnableReplayGain($values["enableReplayGain"]); Application_Model_Preference::setReplayGainModifier($values["replayGainModifier"]); $md = array('schedule' => Application_Model_Schedule::getSchedule()); Application_Model_RabbitMq::SendMessageToPypo("update_schedule", $md); //Application_Model_RabbitMq::PushSchedule(); } if (!Application_Model_Preference::GetMasterDjConnectionUrlOverride()) { $master_connection_url = "http://" . $_SERVER['SERVER_NAME'] . ":" . $values["master_harbor_input_port"] . "/" . $values["master_harbor_input_mount_point"]; if (empty($values["master_harbor_input_port"]) || empty($values["master_harbor_input_mount_point"])) { Application_Model_Preference::SetMasterDJSourceConnectionURL('N/A'); } else { Application_Model_Preference::SetMasterDJSourceConnectionURL($master_connection_url); } } else { Application_Model_Preference::SetMasterDJSourceConnectionURL($values["master_dj_connection_url"]); } if (!Application_Model_Preference::GetLiveDjConnectionUrlOverride()) { $live_connection_url = "http://" . $_SERVER['SERVER_NAME'] . ":" . $values["dj_harbor_input_port"] . "/" . $values["dj_harbor_input_mount_point"]; if (empty($values["dj_harbor_input_port"]) || empty($values["dj_harbor_input_mount_point"])) { Application_Model_Preference::SetLiveDJSourceConnectionURL('N/A'); } else { Application_Model_Preference::SetLiveDJSourceConnectionURL($live_connection_url); } } else { Application_Model_Preference::SetLiveDJSourceConnectionURL($values["live_dj_connection_url"]); } // extra info that goes into cc_stream_setting Application_Model_StreamSetting::setMasterLiveStreamPort($values["master_harbor_input_port"]); Application_Model_StreamSetting::setMasterLiveStreamMountPoint($values["master_harbor_input_mount_point"]); Application_Model_StreamSetting::setDjLiveStreamPort($values["dj_harbor_input_port"]); Application_Model_StreamSetting::setDjLiveStreamMountPoint($values["dj_harbor_input_mount_point"]); Application_Model_StreamSetting::setOffAirMeta($values['offAirMeta']); // 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); $live_stream_subform->updateVariables(); $this->view->enable_stream_conf = Application_Model_Preference::GetEnableStreamConf(); $this->view->form = $form; $this->view->num_stream = $num_of_stream; $this->view->statusMsg = "<div class='success'>" . _("Stream Setting Updated.") . "</div>"; $this->_helper->json->sendJson(array("valid" => "true", "html" => $this->view->render('preference/stream-setting.phtml'), "s1_set_admin_pass" => $s1_set_admin_pass, "s2_set_admin_pass" => $s2_set_admin_pass, "s3_set_admin_pass" => $s3_set_admin_pass)); } else { $live_stream_subform->updateVariables(); $this->view->enable_stream_conf = Application_Model_Preference::GetEnableStreamConf(); $this->view->form = $form; $this->view->num_stream = $num_of_stream; $this->_helper->json->sendJson(array("valid" => "false", "html" => $this->view->render('preference/stream-setting.phtml'))); } } $live_stream_subform->updateVariables(); $this->view->num_stream = $num_of_stream; $this->view->enable_stream_conf = Application_Model_Preference::GetEnableStreamConf(); $this->view->form = $form; }