getenv('LW_DB_HOST') ?: '127.0.0.1', 'database' => getenv('LW_DB_NAME') ?: 'legacyworlds', 'user' => getenv('LW_DB_USER_NAME') ?: 'legacyworlds', 'password' => readSecret('LW_DB_USER_PASS'), 'adminUser' => getenv('LW_DB_ADMIN_NAME') ?: 'legacyworlds_admin', 'adminPassword' => readSecret('LW_DB_ADMIN_PASS'), 'ctrlFifo' =>'/tmp/.lwFifo', 'ctrlPath' =>'/tmp/.lwControl' ); function __dbConnect(bool $admin = false): \PgSql\Connection|bool { global $aConfig; $h = $aConfig['host']; $d = $aConfig['database']; $u = $aConfig[$admin ? 'adminUser' : 'user']; $p = $aConfig[$admin ? 'adminPassword' : 'password']; $cString = "dbname='$d' host='$h' sslmode='prefer' user='$u' password='$p'"; return pg_connect($cString); } function __sendControl($command) { global $aConfig; $fName = $aConfig['ctrlFifo']; if (!file_exists($fName)) { return false; } $fifo = @fopen($fName, "w"); if ($fifo === false) { return false; } fwrite($fifo, "$command\n"); fclose($fifo); return true; } ?>