Format code using php-cs-fixer

This commit is contained in:
jo 2021-10-11 16:10:47 +02:00
parent 43d7dc92cd
commit d52c6184b9
352 changed files with 17473 additions and 17041 deletions

View file

@ -1,8 +1,8 @@
<?php
$tempConfigPath = "/etc/airtime/airtime.conf.tmp";
$tempConfigPath = '/etc/airtime/airtime.conf.tmp';
if (file_exists($tempConfigPath)) {
$airtimeConfig = parse_ini_file($tempConfigPath, true);
$db = $airtimeConfig["database"];
$db = $airtimeConfig['database'];
}
?>
@ -16,25 +16,25 @@
<div class="form-group">
<label class="control-label" for="dbUser">Username</label>
<input required class="form-control" type="text" name="dbUser" id="dbUser" placeholder="Username"
value="<?php echo (isset($db) ? $db["dbuser"] : "airtime"); ?>" />
value="<?php echo isset($db) ? $db['dbuser'] : 'airtime'; ?>" />
<span class="glyphicon glyphicon-remove form-control-feedback"></span>
</div>
<div class="form-group">
<label class="control-label" for="dbPass">Password</label>
<input required class="form-control" type="password" name="dbPass" id="dbPass" placeholder="Password"
value="<?php echo (isset($db) ? $db["dbpass"] : "airtime"); ?>" />
value="<?php echo isset($db) ? $db['dbpass'] : 'airtime'; ?>" />
<span class="glyphicon glyphicon-remove form-control-feedback"></span>
</div>
<div class="form-group">
<label class="control-label" for="dbName">Name</label>
<input required class="form-control" type="text" name="dbName" id="dbName" placeholder="Name"
value="<?php echo (isset($db) ? $db["dbname"] : "airtime"); ?>" />
value="<?php echo isset($db) ? $db['dbname'] : 'airtime'; ?>" />
<span class="glyphicon glyphicon-remove form-control-feedback"></span>
</div>
<div class="form-group">
<label class="control-label" for="dbHost">Host</label>
<input required class="form-control" type="text" name="dbHost" id="dbHost" placeholder="Host"
value="<?php echo (isset($db) ? $db["host"] : "localhost"); ?>" />
value="<?php echo isset($db) ? $db['host'] : 'localhost'; ?>" />
<span class="glyphicon glyphicon-remove form-control-feedback"></span>
</div>
<input class="form-control" type="hidden" name="dbErr" id="dbErr" aria-describedby="helpBlock"/>

View file

@ -10,12 +10,12 @@
<div id="generalFormBody">
<div class="form-group">
<label class="control-label" for="generalHost">Webserver Host</label>
<input required class="form-control" type="text" name="generalHost" id="generalHost" placeholder="Host" value="<?=$_SERVER["SERVER_NAME"]?>"/>
<input required class="form-control" type="text" name="generalHost" id="generalHost" placeholder="Host" value="<?php echo $_SERVER['SERVER_NAME']; ?>"/>
<span class="glyphicon glyphicon-remove form-control-feedback"></span>
</div>
<div class="form-group">
<label class="control-label" for="generalPort">Webserver Port</label>
<input required class="form-control" type="text" name="generalPort" id="generalPort" placeholder="Port" value="<?=$_SERVER["SERVER_PORT"]?>"/>
<input required class="form-control" type="text" name="generalPort" id="generalPort" placeholder="Port" value="<?php echo $_SERVER['SERVER_PORT']; ?>"/>
<span class="glyphicon glyphicon-remove form-control-feedback"></span>
</div>
<input class="form-control" type="hidden" name="generalErr" id="generalErr" aria-describedby="helpBlock"/>

View file

@ -1,8 +1,8 @@
<?php
$tempConfigPath = "/etc/airtime/airtime.conf.tmp";
$tempConfigPath = '/etc/airtime/airtime.conf.tmp';
if (file_exists($tempConfigPath)) {
$airtimeConfig = parse_ini_file($tempConfigPath, true);
$rmq = $airtimeConfig["rabbitmq"];
$rmq = $airtimeConfig['rabbitmq'];
}
?>
@ -27,13 +27,13 @@
<div class="form-group">
<label class="control-label" for="rmqUser">Username</label>
<input required class="form-control" type="text" name="rmqUser" id="rmqUser" placeholder="Username"
value="<?php echo (isset($rmq) ? $rmq["user"] : "airtime"); ?>" />
value="<?php echo isset($rmq) ? $rmq['user'] : 'airtime'; ?>" />
<span class="glyphicon glyphicon-remove form-control-feedback"></span>
</div>
<div class="form-group">
<label class="control-label" for="rmqPass">Password</label>
<input class="form-control" type="password" name="rmqPass" id="rmqPass" placeholder="Password"
value="<?php echo (isset($rmq) ? $rmq["password"] : "airtime"); ?>" />
value="<?php echo isset($rmq) ? $rmq['password'] : 'airtime'; ?>" />
<span class="glyphicon glyphicon-remove form-control-feedback"></span>
<span id="rmqHelpBlock" class="help-block">
You probably want to change this!
@ -42,19 +42,19 @@
<div class="form-group">
<label class="control-label" for="rmqHost">Host</label>
<input required class="form-control" type="text" name="rmqHost" id="rmqHost" placeholder="Host"
value="<?php echo (isset($rmq) ? $rmq["host"] : "127.0.0.1"); ?>" />
value="<?php echo isset($rmq) ? $rmq['host'] : '127.0.0.1'; ?>" />
<span class="glyphicon glyphicon-remove form-control-feedback"></span>
</div>
<div class="form-group">
<label class="control-label" for="rmqPort">Port</label>
<input required class="form-control" type="text" name="rmqPort" id="rmqPort" placeholder="Port"
value="<?php echo (isset($rmq) ? $rmq["port"] : "5672"); ?>" />
value="<?php echo isset($rmq) ? $rmq['port'] : '5672'; ?>" />
<span class="glyphicon glyphicon-remove form-control-feedback"></span>
</div>
<div class="form-group">
<label class="control-label" for="rmqVHost">Virtual Host</label>
<input required class="form-control" type="text" name="rmqVHost" id="rmqVHost" placeholder="VHost"
value="<?php echo (isset($rmq) ? $rmq["vhost"] : "/airtime"); ?>" />
value="<?php echo isset($rmq) ? $rmq['vhost'] : '/airtime'; ?>" />
<span class="glyphicon glyphicon-remove form-control-feedback"></span>
</div>
<input class="form-control" type="hidden" name="rmqErr" id="rmqErr" aria-describedby="helpBlock"/>

View file

@ -1,71 +1,78 @@
<?php
define("RMQ_INI_SECTION", "rabbitmq");
define('RMQ_INI_SECTION', 'rabbitmq');
function booleanReduce($a, $b) {
function booleanReduce($a, $b)
{
return $a && $b;
}
/**
* Check to see if Airtime is properly configured.
*
* @return boolean true if all Airtime dependencies and services are
* properly configured and running
* @return bool true if all Airtime dependencies and services are
* properly configured and running
*/
function checkConfiguration() {
$r1 = array_reduce(checkPhpDependencies(), "booleanReduce", true);
$r2 = array_reduce(checkExternalServices(), "booleanReduce", true);
function checkConfiguration()
{
$r1 = array_reduce(checkPhpDependencies(), 'booleanReduce', true);
$r2 = array_reduce(checkExternalServices(), 'booleanReduce', true);
return $r1 && $r2;
}
/**
* Check for Airtime's PHP dependencies and return an associative
* array with the results
* array with the results.
*
* @return array associative array of dependency check results
*/
function checkPhpDependencies() {
return array(
"postgres" => checkDatabaseDependencies()
);
function checkPhpDependencies()
{
return [
'postgres' => checkDatabaseDependencies(),
];
}
/**
* Check that the PHP dependencies for the database exist
* Check that the PHP dependencies for the database exist.
*
* @return boolean true if the database dependencies exist
* @return bool true if the database dependencies exist
*/
function checkDatabaseDependencies() {
function checkDatabaseDependencies()
{
global $extensions;
// Check the PHP extension list for the Postgres db extensions
return (in_array('pdo_pgsql', $extensions)
&& in_array('pgsql', $extensions));
return in_array('pdo_pgsql', $extensions)
&& in_array('pgsql', $extensions);
}
/**
* Check that all external services are configured correctly and return an associative
* array with the results
* array with the results.
*
* @return array associative array of external service check results
*/
function checkExternalServices() {
return array(
"database" => checkDatabaseConfiguration(),
"analyzer" => checkAnalyzerService(),
"pypo" => checkPlayoutService(),
"liquidsoap" => checkLiquidsoapService(),
"rabbitmq" => checkRMQConnection(),
"celery" => checkCeleryService(),
"api" => checkApiService(),
);
function checkExternalServices()
{
return [
'database' => checkDatabaseConfiguration(),
'analyzer' => checkAnalyzerService(),
'pypo' => checkPlayoutService(),
'liquidsoap' => checkLiquidsoapService(),
'rabbitmq' => checkRMQConnection(),
'celery' => checkCeleryService(),
'api' => checkApiService(),
];
}
/**
* Check the database configuration by fetching a connection from Propel
* Check the database configuration by fetching a connection from Propel.
*
* @return boolean true if a connection is made to the database
* @return bool true if a connection is made to the database
*/
function checkDatabaseConfiguration() {
function checkDatabaseConfiguration()
{
configureDatabase();
try {
@ -81,94 +88,109 @@ function checkDatabaseConfiguration() {
}
/**
* Initialize Propel to configure the Airtime database
* Initialize Propel to configure the Airtime database.
*/
function configureDatabase() {
function configureDatabase()
{
Propel::init(CONFIG_PATH . 'airtime-conf-production.php');
}
/**
* Check that we can connect to RabbitMQ
* Check that we can connect to RabbitMQ.
*
* @return true if the RabbitMQ connection can be established
*/
function checkRMQConnection() {
function checkRMQConnection()
{
// Check for airtime.conf in /etc/airtime/ first, then check in the build directory,
if (file_exists(AIRTIME_CONFIG_STOR . AIRTIME_CONFIG)) {
$ini = parse_ini_file(AIRTIME_CONFIG_STOR . AIRTIME_CONFIG, true);
} else {
$ini = parse_ini_file(BUILD_PATH . "airtime.example.conf", true);
$ini = parse_ini_file(BUILD_PATH . 'airtime.example.conf', true);
}
$conn = new \PhpAmqpLib\Connection\AMQPConnection($ini[RMQ_INI_SECTION]["host"],
$ini[RMQ_INI_SECTION]["port"],
$ini[RMQ_INI_SECTION]["user"],
$ini[RMQ_INI_SECTION]["password"],
$ini[RMQ_INI_SECTION]["vhost"]);
$conn = new \PhpAmqpLib\Connection\AMQPConnection(
$ini[RMQ_INI_SECTION]['host'],
$ini[RMQ_INI_SECTION]['port'],
$ini[RMQ_INI_SECTION]['user'],
$ini[RMQ_INI_SECTION]['password'],
$ini[RMQ_INI_SECTION]['vhost']
);
return isset($conn);
}
/**
* Check if airtime-analyzer is currently running
* Check if airtime-analyzer is currently running.
*
* @return boolean true if airtime-analyzer is running
* @return bool true if airtime-analyzer is running
*/
function checkAnalyzerService() {
exec("pgrep -f libretime-analyzer", $out, $status);
function checkAnalyzerService()
{
exec('pgrep -f libretime-analyzer', $out, $status);
if (($out > 0) && $status == 0) {
return posix_kill(rtrim($out[0]), 0);
}
return $status == 0;
}
/**
* Check if airtime-playout is currently running
* Check if airtime-playout is currently running.
*
* @return boolean true if airtime-playout is running
* @return bool true if airtime-playout is running
*/
function checkPlayoutService() {
exec("pgrep -f airtime-playout", $out, $status);
function checkPlayoutService()
{
exec('pgrep -f airtime-playout', $out, $status);
if ($out > 0) {
return posix_kill(rtrim($out[0]), 0);
}
return $status == 0;
}
/**
* Check if airtime-liquidsoap is currently running
* Check if airtime-liquidsoap is currently running.
*
* @return boolean true if airtime-liquidsoap is running
* @return bool true if airtime-liquidsoap is running
*/
function checkLiquidsoapService() {
exec("pgrep -f airtime-liquidsoap", $out, $status);
function checkLiquidsoapService()
{
exec('pgrep -f airtime-liquidsoap', $out, $status);
if ($out > 0) {
return posix_kill(rtrim($out[0]), 0);
}
return $status == 0;
}
/**
* Check if airtime-celery is currently running
* Check if airtime-celery is currently running.
*
* @return boolean true if airtime-celery is running
* @return bool true if airtime-celery is running
*/
function checkCeleryService() {
exec("pgrep -f -u celery airtime-celery", $out, $status);
function checkCeleryService()
{
exec('pgrep -f -u celery airtime-celery', $out, $status);
if (array_key_exists(0, $out) && $status == 0) {
return 1;
}
return $status == 0;
}
/**
* Check if libretime-api is currently running
* Check if libretime-api is currently running.
*
* @return boolean true if libretime-api is running
* @return bool true if libretime-api is running
*/
function checkApiService() {
exec("pgrep -f -u www-data uwsgi", $out, $status);
function checkApiService()
{
exec('pgrep -f -u www-data uwsgi', $out, $status);
if (array_key_exists(0, $out) && $status == 0) {
return 1;
}
return $status == 0;
}

View file

@ -23,27 +23,27 @@
<div class="form-slider">
<div id="databaseSettings" class="form-wrapper">
<?php
require_once SETUP_PATH . "forms/database-settings.php";
require_once SETUP_PATH . 'forms/database-settings.php';
?>
</div>
<div id="rabbitmqSettings" class="form-wrapper">
<?php
require_once SETUP_PATH . "forms/rabbitmq-settings.php";
require_once SETUP_PATH . 'forms/rabbitmq-settings.php';
?>
</div>
<div id="generalSettings" class="form-wrapper">
<?php
require_once SETUP_PATH . "forms/general-settings.php";
require_once SETUP_PATH . 'forms/general-settings.php';
?>
</div>
<div id="mediaSettings" class="form-wrapper">
<?php
require_once SETUP_PATH . "forms/media-settings.php";
require_once SETUP_PATH . 'forms/media-settings.php';
?>
</div>
<div id="finishSettings" class="form-wrapper">
<?php
require_once SETUP_PATH . "forms/finish-settings.php";
require_once SETUP_PATH . 'forms/finish-settings.php';
?>
</div>
</div>