/** * @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]; }
/** * Runs a liquidsoap command * @method liquidsoapcommand * @param type the type of the script to start * @param command the command to run * @param options extra options to provide with the command */ public function liquidsoapcommand($params) { $liquidsoapManager = new LiquidsoapManager(); if (!App::user()->hasAccess('shoutzor: manage shoutzor controls')) { return $this->formatOutput(__('You have no permission to manage shoutzor controls'), self::METHOD_NOT_AVAILABLE); } switch ($params['command']) { case "start": //Get the status of the script before we start it $status = $liquidsoapManager->isUp($params['type']); //Start our script $result = $liquidsoapManager->startScript($params['type']); //Make sure we don't import the queue if the script was already running if ($params['type'] == 'shoutzor' && $status === false) { $autoDJ = new AutoDJ(); $autoDJ->importQueue(); } break; case "stop": $result = $liquidsoapManager->stopScript($params['type']); break; case "volume": $result = $liquidsoapManager->setVolume($params['type'], $params['options']); break; case "next": $result = $liquidsoapManager->nextTrack(); break; case "remaining": $result = $liquidsoapManager->remaining(); break; case "uptime": $result = $liquidsoapManager->isUp($params['type']); break; case "help": $result = $liquidsoapManager->help($params['type']); break; default: return $this->formatOutput(__('Invalid command provided'), self::INVALID_PARAMETER_VALUE); break; } if ($result) { return $this->formatOutput($result); } return $this->formatOutput(false, self::ERROR_IN_REQUEST); }