/** * @Route("/", name="index") */ public function indexAction() { $config = App::module('shoutzor')->config('liquidsoap'); $liquidsoapManager = new LiquidsoapManager(); $wrapperActive = $liquidsoapManager->isUp('wrapper'); $shoutzorActive = $liquidsoapManager->isUp('shoutzor'); $form = new FormGenerator('', 'POST', 'uk-form uk-form-horizontal'); $form->addField(new DivField("Permission Check", $config['logDirectoryPath'] . (is_writable($config['logDirectoryPath']) ? " is writable" : " is not writable! chown manually to www-data:www-data"), "", is_writable($config['logDirectoryPath']) ? "uk-alert uk-alert-success" : "uk-alert uk-alert-danger")); //Usually the log directory and the socket directory will be the same //Thus, showing twice that the same directory is (not) writable has no use if ($config['logDirectoryPath'] != $config['socketPath']) { $form->addField(new DivField("Permission Check", $config['socketPath'] . (is_writable($config['socketPath']) ? " is writable" : " is not writable! chown manually to www-data:www-data"), "", is_writable($config['socketPath']) ? "uk-alert uk-alert-success" : "uk-alert uk-alert-danger")); } $form->addField(new DivField("Permission Check", $liquidsoapManager->getPidFileDirectory() . (is_writable($liquidsoapManager->getPidFileDirectory()) ? " is writable" : " is not writable! chown manually to liquidsoap:www-data"), "", is_writable($liquidsoapManager->getPidFileDirectory()) ? "uk-alert uk-alert-success" : "uk-alert uk-alert-danger")); $form->addField(new DividerField()); $form->addField(new InputField("wrapperToggle", "wrapperToggle", $wrapperActive ? "Deactivate Wrapper" : "Activate Wrapper", "button", $wrapperActive ? "Deactivate Wrapper" : "Activate Wrapper", "(De)activates the wrapper liquidsoap script", $wrapperActive ? "uk-button uk-button-danger" : "uk-button uk-button-primary", 'data-status="' . ($wrapperActive ? 'started' : 'stopped') . '"'))->setValidationType(FormValidation::TYPE_STRING)->setValidationRequirements(array(FormValidation::REQ_NOTEMPTY)); if ($wrapperActive === false) { $form->setError("The wrapper script is not activated!"); } else { $form->setSuccess("The wrapper script is up and running!"); } $form->addField(new InputField("shoutzorToggle", "shoutzorToggle", $shoutzorActive ? "Deactivate Shoutzor" : "Activate Shoutzor", "button", $shoutzorActive ? "Deactivate Shoutzor" : "Activate Shoutzor", "(De)activates the shoutzor liquidsoap script", $shoutzorActive ? "uk-button uk-button-danger" : "uk-button uk-button-primary", 'data-status="' . ($wrapperActive ? 'started' : 'stopped') . '"'))->setValidationType(FormValidation::TYPE_STRING)->setValidationRequirements(array(FormValidation::REQ_NOTEMPTY)); if ($shoutzorActive === false) { if ($wrapperActive === false) { $form->setError("The wrapper script needs to be activated first!"); } else { $form->setError("The shoutzor script is not activated!"); } } else { $form->setSuccess("The shoutzor script is up and running!"); } $content = $form->render(); return ['$view' => ['title' => __('Shoutzor System'), 'name' => 'shoutzor:views/admin/system.php'], 'form' => $content]; }
/** * @Route("/", name="index") */ public function indexAction() { $config = App::module('shoutzor')->config('liquidsoap'); $liquidsoapManager = new LiquidsoapManager(); $wrapperActive = $liquidsoapManager->isUp('wrapper'); $shoutzorActive = $liquidsoapManager->isUp('shoutzor'); $form = new FormGenerator('', 'POST', 'uk-form uk-form-horizontal'); $form->addField(new InputField("skipTrack", "skipTrack", "Skip Track", "button", "Skip Track", "Sends the "skip track" command", "uk-button uk-button-primary")); $content = $form->render(); return ['$view' => ['title' => __('Shoutzor Controls'), 'name' => 'shoutzor:views/admin/controls.php'], 'form' => $content]; }
/** * @Route("/", name="index") */ public function indexAction() { $request = App::request(); $config = App::module('shoutzor')->config('shoutzor'); $config = array_merge($config, $_POST); $form = new FormGenerator('', 'POST', 'uk-form uk-form-horizontal'); $form->addField(new DivField("Permission Check", $config['mediaDir'] . (is_writable($config['mediaDir']) ? " is writable" : " is not writable! chown manually to www-data:www-data"), "", is_writable($config['mediaDir']) ? "uk-alert uk-alert-success" : "uk-alert uk-alert-danger")); $form->addField(new DivField("Permission Check", App::module('shoutzor')->config('root_path') . $config['imageDir'] . (is_writable(App::module('shoutzor')->config('root_path') . $config['imageDir']) ? " is writable" : " is not writable! chown manually to www-data:www-data"), "", is_writable(App::module('shoutzor')->config('root_path') . $config['imageDir']) ? "uk-alert uk-alert-success" : "uk-alert uk-alert-danger")); $form->addField(new DividerField()); $form->addField(new SelectField("upload", "upload", "Allow Uploads", "text", $config['upload'], array(['value' => 0, 'title' => 'Disabled'], ['value' => 1, 'title' => 'Enabled']), false, "Changing this setting will not delete uploaded content"))->setValidationType(FormValidation::TYPE_STRING)->setValidationRequirements(array(FormValidation::REQ_NOTEMPTY)); $form->addField(new SelectField("request", "request", "Allow Requests", "text", $config['request'], array(['value' => 0, 'title' => 'Disabled'], ['value' => 1, 'title' => 'Enabled']), false, "Changing this setting will allow / deny user requests"))->setValidationType(FormValidation::TYPE_STRING)->setValidationRequirements(array(FormValidation::REQ_NOTEMPTY)); $form->addField(new DividerField()); $form->addField(new InputField("mediaDir", "mediaDir", "Media Storage Directory", "text", $config['mediaDir'], "The directory where uploads should be stored", "uk-form-width-large"))->setValidationType(FormValidation::TYPE_STRING)->setValidationRequirements(array(FormValidation::REQ_NOTEMPTY)); $form->addField(new InputField("imageDir", "imageDir", "Image Storage Directory", "text", $config['imageDir'], "The directory where downloaded images should be stored", "uk-form-width-large"))->setValidationType(FormValidation::TYPE_STRING)->setValidationRequirements(array(FormValidation::REQ_NOTEMPTY)); $form->addField(new InputField("parserLastRun", "parserLastRun", "Parser Last Run Timestamp", "text", $config['parserLastRun'], "The timestamp of when the parser last ran - in general you will not have to make any changes to this value"))->setValidationType(FormValidation::TYPE_NUMERIC)->setValidationRequirements(array(FormValidation::REQ_NOTEMPTY)); $form->addField(new InputField("parserMaxItems", "parserMaxItems", "Parser Max Items", "text", $config['parserMaxItems'], "The maximum amount of items the parser should parse on each run"))->setValidationType(FormValidation::TYPE_NUMERIC)->setValidationRequirements(array(FormValidation::REQ_NOTEMPTY)); $form->addField(new DividerField()); $form->addField(new InputField("userRequestDelay", "userRequestDelay", "User Request Delay", "text", $config['userRequestDelay'], "The delay in minutes that a user has to wait to be able to request a media object again"))->setValidationType(FormValidation::TYPE_NUMERIC)->setValidationRequirements(array(FormValidation::REQ_NOTEMPTY)); $form->addField(new InputField("mediaRequestDelay", "mediaRequestDelay", "Media Request Delay", "text", $config['mediaRequestDelay'], "The delay in minutes before a media object can be played again"))->setValidationType(FormValidation::TYPE_NUMERIC)->setValidationRequirements(array(FormValidation::REQ_NOTEMPTY)); $form->addField(new InputField("artistRequestDelay", "artistRequestDelay", "Artist Request Delay", "text", $config['artistRequestDelay'], "The delay in minutes before a media object from the same artist can be played again"))->setValidationType(FormValidation::TYPE_NUMERIC)->setValidationRequirements(array(FormValidation::REQ_NOTEMPTY)); $form->addField(new InputField("uploadDurationLimit", "uploadDurationLimit", "Media Duration Limit (Minutes)", "text", $config['uploadDurationLimit'], "The limit of the duration from uploaded media files in minutes - changing this will have no effect on already uploaded files"))->setValidationType(FormValidation::TYPE_NUMERIC)->setValidationRequirements(array(FormValidation::REQ_NOTEMPTY)); $form->addField(new SelectField("useFilenameIfUntitled", "useFilenameIfUntitled", "Use Filename If Untitled", "text", $config['useFilenameIfUntitled'], array(['value' => 0, 'title' => 'Disabled'], ['value' => 1, 'title' => 'Enabled']), false, "Use the filename as title when no title could be detected and/or found"))->setValidationType(FormValidation::TYPE_STRING)->setValidationRequirements(array(FormValidation::REQ_NOTEMPTY)); $form->addField(new InputField("submit", "", "Save Changes", "submit", "Save Changes", "", "uk-button uk-button-primary")); $alert = array(); //Check if a POST request has been made if ($request->isMethod('POST')) { $form->validate(); //Make sure no errors have occured during validation if ($form->hasErrors() === false) { $configValues = array(); foreach ($form->getFields() as $field) { if (!empty($field->getName())) { $configValues[$field->getName()] = $field->getValue(); } } App::config('shoutzor')->set('shoutzor', $configValues); //Do stuff $alert = array('type' => 'success', 'msg' => __('Changes saved. Make sure the applicable liquidsoap scripts are restarted for the changes to take effect')); } else { $alert = array('type' => 'error', 'msg' => __('Not all fields passed validation, correct the problems and try again')); } } $content = $form->render(); return ['$view' => ['title' => __('Shoutzor Settings'), 'name' => 'shoutzor:views/admin/shoutzor.php'], 'form' => $content, 'alert' => $alert]; }
/** * @Route("/", name="index") */ public function indexAction() { $request = App::request(); $config = App::module('shoutzor')->config('lastfm'); $config = array_merge($config, $_POST); //Set the value to the new POST data $liquidsoapManager = new LiquidsoapManager(); $form = new FormGenerator('', 'POST', 'uk-form uk-form-horizontal'); $form->addField(new DivField("Notice", "Make sure to have provided a working Application API Key before enabling LastFM to prevent any issues", "", "uk-alert uk-alert-info")); $form->addField(new CheckboxField("enabled", "enabled", "Enable LastFM", array($config['enabled']), array(['value' => "1", 'title' => 'enabled'], ['value' => "0", 'title' => 'disabled']), false, "Enable the LastFM Integration"))->setValidationType(FormValidation::TYPE_STRING)->setValidationRequirements(array(FormValidation::REQ_NOTEMPTY, FormValidation::REQ_VALUE => array('1', '0'))); $form->addField(new InputField("apikey", "apikey", "Application API Key", "text", $config['apikey'], "The Application Key for LastFM, if you don't have one, get one at: <a href='hhttp://www.last.fm/api/account/create'>http://www.last.fm/api/account/create</a>"))->setValidationType(FormValidation::TYPE_STRING)->setValidationRequirements(array(FormValidation::REQ_NOTEMPTY)); $form->addField(new InputField("secret", "secret", "Application Secret", "text", $config['secret'], "The Application Secret for LastFM, if you don't have one, get one at: <a href='http://www.last.fm/api/account/create'>http://www.last.fm/api/account/create</a>"))->setValidationType(FormValidation::TYPE_STRING)->setValidationRequirements(array(FormValidation::REQ_NOTEMPTY)); $form->addField(new DividerField()); $form->addField(new InputField("submit", "", "Save Changes", "submit", "Save Changes", "", "uk-button uk-button-primary")); $alert = array(); //Check if a POST request has been made if ($request->isMethod('POST')) { $form->validate(); //Make sure no errors have occured during validation if ($form->hasErrors() === false) { $configValues = array(); foreach ($form->getFields() as $field) { if (!empty($field->getName())) { $configValues[$field->getName()] = $field->getValue(); } } //Save our config changes App::config('shoutzor')->set('lastfm', $configValues); //Show success message $alert = array('type' => 'success', 'msg' => __('Changes saved')); } else { $alert = array('type' => 'error', 'msg' => __('Not all fields passed validation, correct the problems and try again')); } } $content = $form->render(); return ['$view' => ['title' => __('Shoutzor LastFM'), 'name' => 'shoutzor:views/admin/lastfm.php'], 'form' => $content, 'alert' => $alert]; }
/** * @Route("/", name="index") */ public function indexAction() { $request = App::request(); $config = App::module('shoutzor')->config('liquidsoap'); $config = array_merge($config, $_POST); //Set the value to the new POST data $form = new FormGenerator('', 'POST', 'uk-form uk-form-horizontal'); $form->addField(new InputField("pidFileDirectory", "pidFileDirectory", "Pid File Directory", "text", $config['pidFileDirectory'], "The directory where liquidsoap stores its script PID files"))->setValidationType(FormValidation::TYPE_STRING)->setValidationRequirements(array(FormValidation::REQ_NOTEMPTY)); $form->addField(new InputField("logDirectoryPath", "logDirectoryPath", "Log Directory Path", "text", $config['logDirectoryPath'], "The directory where to store the logs (without ending slash)"))->setValidationType(FormValidation::TYPE_STRING)->setValidationRequirements(array(FormValidation::REQ_NOTEMPTY)); $form->addField(new InputField("socketPath", "socketPath", "Socket Path", "text", $config['socketPath'], "The directory where to create the socket files (without ending slash)"))->setValidationType(FormValidation::TYPE_STRING)->setValidationRequirements(array(FormValidation::REQ_NOTEMPTY)); $form->addField(new InputField("socketPermissions", "socketPermissions", "Socket Permissions", "text", $config['socketPermissions'], "The permissions to set to the created socket files"))->setValidationType(FormValidation::TYPE_NUMERIC)->setValidationRequirements(array(FormValidation::REQ_NOTEMPTY)); $form->addField(new DividerField()); $form->addField(new CheckboxField("wrapperLogStdout", "wrapperLogStdout", "Wrapper Log Stdout", array($config['wrapperLogStdout']), array(['value' => "true", 'title' => 'enable'], ['value' => "false", 'title' => 'disable']), false, "Show stdout output in the logs"))->setValidationType(FormValidation::TYPE_STRING)->setValidationRequirements(array(FormValidation::REQ_NOTEMPTY, FormValidation::REQ_VALUE => array('true', 'false'))); $form->addField(new CheckboxField("wrapperServerTelnet", "wrapperServerTelnet", "Wrapper Enable Telnet", array($config['wrapperServerTelnet']), array(['value' => "true", 'title' => 'enable'], ['value' => "false", 'title' => 'disable']), false, "Enable telnet access to the wrapper"))->setValidationType(FormValidation::TYPE_STRING)->setValidationRequirements(array(FormValidation::REQ_NOTEMPTY, FormValidation::REQ_VALUE => array('true', 'false'))); $form->addField(new CheckboxField("wrapperServerSocket", "wrapperServerSocket", "Wrapper Enable Socket", array($config['wrapperServerSocket']), array(['value' => "true", 'title' => 'enable'], ['value' => "false", 'title' => 'disable']), false, "Enable socket access to the wrapper - REQUIRED FOR CONTROLS TO WORK"))->setValidationType(FormValidation::TYPE_STRING)->setValidationRequirements(array(FormValidation::REQ_NOTEMPTY, FormValidation::REQ_VALUE => array('true', 'false'))); $form->addField(new DividerField()); $form->addField(new CheckboxField("shoutzorLogStdout", "shoutzorLogStdout", "Shoutzor Log Stdout", array($config['shoutzorLogStdout']), array(['value' => "true", 'title' => 'enable'], ['value' => "false", 'title' => 'disable']), false, "Show stdout output in the logs"))->setValidationType(FormValidation::TYPE_STRING)->setValidationRequirements(array(FormValidation::REQ_NOTEMPTY, FormValidation::REQ_VALUE => array('true', 'false'))); $form->addField(new CheckboxField("shoutzorServerTelnet", "shoutzorServerTelnet", "Shoutzor Enable Telnet", array($config['shoutzorServerTelnet']), array(['value' => "true", 'title' => 'enable'], ['value' => "false", 'title' => 'disable']), false, "Enable telnet access to shoutzor"))->setValidationType(FormValidation::TYPE_STRING)->setValidationRequirements(array(FormValidation::REQ_NOTEMPTY, FormValidation::REQ_VALUE => array('true', 'false'))); $form->addField(new CheckboxField("shoutzorServerSocket", "shoutzorServerSocket", "Shoutzor Enable Socket", array($config['shoutzorServerSocket']), array(['value' => "true", 'title' => 'enable'], ['value' => "false", 'title' => 'disable']), false, "Enable socket access to shoutzor - REQUIRED FOR CONTROLS TO WORK"))->setValidationType(FormValidation::TYPE_STRING)->setValidationRequirements(array(FormValidation::REQ_NOTEMPTY, FormValidation::REQ_VALUE => array('true', 'false'))); $form->addField(new DividerField()); $form->addField(new InputField("wrapperInputListeningMount", "wrapperInputListeningMount", "Wrapper Input Listening Mount", "text", $config['wrapperInputListeningMount'], "The mount that the wrapper and shoutzor should be using to communicate locally"))->setValidationType(FormValidation::TYPE_STRING)->setValidationRequirements(array(FormValidation::REQ_NOTEMPTY)); $form->addField(new InputField("wrapperInputListeningPort", "wrapperInputListeningPort", "Wrapper Input Listening Port", "text", $config['wrapperInputListeningPort'], "The port the wrapper and shoutzor should be using to communicate locally"))->setValidationType(FormValidation::TYPE_NUMERIC)->setValidationRequirements(array(FormValidation::REQ_NOTEMPTY)); $form->addField(new InputField("wrapperInputListeningPassword", "wrapperInputListeningPassword", "Wrapper Input Listening Password", "password", $config['wrapperInputListeningPassword'], "The password the wrapper and shoutzor should be using to communicate locally"))->setValidationType(FormValidation::TYPE_STRING)->setValidationRequirements(array(FormValidation::REQ_NOTEMPTY)); $form->addField(new DividerField()); $form->addField(new InputField("wrapperOutputHost", "wrapperOutputHost", "Wrapper Output Host", "text", $config['wrapperOutputHost'], "The IP of the icecast server to stream to"))->setValidationType(FormValidation::TYPE_STRING)->setValidationRequirements(array(FormValidation::REQ_NOTEMPTY)); $form->addField(new InputField("wrapperOutputMount", "wrapperOutputMount", "Wrapper Output Mount", "text", $config['wrapperOutputMount'], "The mount of the icecast server to stream to"))->setValidationType(FormValidation::TYPE_STRING)->setValidationRequirements(array(FormValidation::REQ_NOTEMPTY)); $form->addField(new InputField("wrapperOutputPort", "wrapperOutputPort", "Wrapper Output Port", "text", $config['wrapperOutputPort'], "The port of the icecast server to stream to"))->setValidationType(FormValidation::TYPE_NUMERIC)->setValidationRequirements(array(FormValidation::REQ_NOTEMPTY)); $form->addField(new InputField("wrapperOutputPassword", "wrapperOutputPassword", "Wrapper Output Password", "password", $config['wrapperOutputPassword'], "The password of the icecast server to stream to"))->setValidationType(FormValidation::TYPE_STRING)->setValidationRequirements(array(FormValidation::REQ_NOTEMPTY)); $form->addField(new DividerField()); $form->addField(new InputField("shoutzorUrl", "shoutzorUrl", "Shoutzor Website URL", "text", $config['shoutzorUrl'], "The hostname of the url this website is running on, example: 'https://shoutzor.com' NO ENDING SLASH"))->setValidationType(FormValidation::TYPE_STRING)->setValidationRequirements(array(FormValidation::REQ_NOTEMPTY)); $form->addField(new DividerField()); $form->addField(new InputField("encodingBitrate", "encodingBitrate", "Encoding bitrate", "text", $config['encodingBitrate'], "The bitrate of our audio stream")); $form->addField(new InputField("encodingQuality", "encodingQuality", "LAME Encoding Quality", "text", $config['encodingQuality'], "The quality to be used by the LAME encoder, 0 - 9 where 0 is the highest quality")); $form->addField(new DividerField()); $form->addField(new InputField("submit", "", "Save Changes", "submit", "Save Changes", "", "uk-button uk-button-primary")); $alert = array(); //Check if a POST request has been made if ($request->isMethod('POST')) { $form->validate(); //Make sure no errors have occured during validation if ($form->hasErrors() === false) { $replace_values = array(); $configValues = array(); foreach ($form->getFields() as $field) { if (!empty($field->getName())) { $configValues[$field->getName()] = $field->getValue(); $replace_values['%' . $field->getName() . '%'] = $field->getValue(); } } //Save our config changes App::config('shoutzor')->set('liquidsoap', $configValues); //Generate our new config file $liquidsoapManager = new liquidsoapManager(); $liquidsoapManager->generateConfigFile($replace_values); //Show success message $alert = array('type' => 'success', 'msg' => __('Changes saved. Make sure the applicable liquidsoap scripts are restarted for the changes to take effect')); } else { $alert = array('type' => 'error', 'msg' => __('Not all fields passed validation, correct the problems and try again')); } } $content = $form->render(); return ['$view' => ['title' => __('Liquidsoap Settings'), 'name' => 'shoutzor:views/admin/liquidsoap.php'], 'form' => $content, 'alert' => $alert]; }