diff --git a/CHANGELOG.md b/CHANGELOG.md index f4739cb..b7b5710 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,6 @@ * Add tree view for online clients * Update deployment and release documentation and examples * Update dependencies and force PHP 7.3 -* Add fallback for values for `env` file ## 1.2.4 - 2019/01/18 * No info text diff --git a/config/EnvConstants.php b/config/EnvConstants.php index 13962be..94a1516 100644 --- a/config/EnvConstants.php +++ b/config/EnvConstants.php @@ -5,15 +5,10 @@ */ class EnvConstants { - /** - * Default env file loaded - */ - const ENV_FILE_DEFAULT = "env.default"; - /** * Custom env file */ - const ENV_FILE_CUSTOM = "env"; + const ENV_FILE = "env"; /** * Site title diff --git a/config/env.default b/config/env.default deleted file mode 100644 index 4703e66..0000000 --- a/config/env.default +++ /dev/null @@ -1,18 +0,0 @@ -# site -site_title="Teamspeak 3 Web" -site_language="en" # values: each yml you specified in data/locale/ -site_date_format="d.m.Y H:i:s" # values: all possible for Date::class - -# theme -theme="bootstrap4" # values: bootstrap4 (foldernames are used to determine theme in src/View/) -theme_cache=false # values: true|false (cache view/twig. makes it faster, disable for debug) - -# teamspeak -teamspeak_host="localhost" # 'localhost' or 'name_of_docker_container' if running locally -teamspeak_query_port=10011 -teamspeak_user="serveradmin" -teamspeak_tree_view="true" # show a tree view in the details of online clients if a server has been selected - -# log -log_name="ts3web" # values: all strings -log_level="INFO" # values: DEBUG, INFO, NOTICE, WARNING, ERROR, CRITICAL, ALERT, EMERGENCY \ No newline at end of file diff --git a/data/locale/en.yml b/data/locale/en.yml index bb3d831..c456791 100644 --- a/data/locale/en.yml +++ b/data/locale/en.yml @@ -278,8 +278,4 @@ about.header: "About %name%" about.body: | ts3web is a web interface for one TeamSpeak 3 Server. It's using serverquery to login. This web interface aims to be as simple as possible. The minimalistic approach is intentional. - Feel free to submit pull requests if you like to help. More information are here: https://hub.docker.com/r/varakh/ts3web - - Features which are currently not supported: - - modify permissions (only viewing) - - modify files (only viewing) \ No newline at end of file + Feel free to submit pull requests if you like to help. More information are here: https://hub.docker.com/r/varakh/ts3web \ No newline at end of file diff --git a/docker-compose/docker-compose.yml b/docker-compose/docker-compose.yml deleted file mode 100644 index 0d1525a..0000000 --- a/docker-compose/docker-compose.yml +++ /dev/null @@ -1,33 +0,0 @@ -version: '2' -networks: - teamspeak: - external: false -services: - app: - container_name: teamspeak_app - image: teamspeak:latest - volumes: - - ./app:/var/ts3server - - ./whitelist.txt:/whitelist.txt - ports: - - 10011:10011 - - 30033:30033 - - 9987:9987/udp - environment: - - TS3SERVER_LICENSE=accept - - TS3SERVER_IP_WHITELIST=/whitelist.txt - restart: always - network_mode: "host" - web: - container_name: teamspeak_web - image: teamspeak_web:latest - volumes: - - ./env:/var/www/html/application/config/env - - ./snapshots:/var/www/html/application/data/snapshots - ports: - - 127.0.0.1:8181:80 - depends_on: - - app - restart: always - networks: - - teamspeak \ No newline at end of file diff --git a/docker-compose/env b/docker-compose/env deleted file mode 100644 index 11a2817..0000000 --- a/docker-compose/env +++ /dev/null @@ -1,17 +0,0 @@ -# site -site_title="Teamspeak 3 Web" -site_language="en" # values: each yml you specified in data/locale/ -site_date_format="d.m.Y H:i:s" # values: all possible for Date::class - -# theme -theme="bootstrap4" # values: bootstrap4 (foldernames are used to determine theme in src/View/) -theme_cache=false # values: true|false (cache view/twig. makes it faster, disable for debug) - -# teamspeak -teamspeak_host="localhost" # 'localhost' or 'name_of_docker_container' if running locally or IP -teamspeak_query_port=10011 -teamspeak_user="serveradmin" - -# log -log_name="ts3web" # values: all strings -log_level="INFO" # values: DEBUG, INFO, NOTICE, WARNING, ERROR, CRITICAL, ALERT, EMERGENCY \ No newline at end of file diff --git a/docker-compose/whitelist.txt b/docker-compose/whitelist.txt deleted file mode 100644 index e56ea71..0000000 --- a/docker-compose/whitelist.txt +++ /dev/null @@ -1 +0,0 @@ -127.0.0.1 \ No newline at end of file diff --git a/src/Util/BootstrapHelper.php b/src/Util/BootstrapHelper.php index 208523e..f18ea24 100644 --- a/src/Util/BootstrapHelper.php +++ b/src/Util/BootstrapHelper.php @@ -20,20 +20,27 @@ class BootstrapHelper public static function bootEnvironment() { $envPath = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'config'; + $envFile = $envPath . DIRECTORY_SEPARATOR . EnvConstants::ENV_FILE; - $defaultEnv = new Dotenv($envPath, EnvConstants::ENV_FILE_DEFAULT); - $defaultEnvRes = $defaultEnv->load(); - - $envFile = $envPath . DIRECTORY_SEPARATOR . EnvConstants::ENV_FILE_CUSTOM; - $envRes = []; if (file_exists($envFile)) { - $env = new Dotenv($envPath, EnvConstants::ENV_FILE_CUSTOM); - $envRes = $env->load(); + $env = new Dotenv(realpath($envPath), EnvConstants::ENV_FILE); + $res = $env->load(); + $env->required([ + EnvConstants::SITE_TITLE, + EnvConstants::SITE_LANGUAGE, + EnvConstants::SITE_DATE_FORMAT, + EnvConstants::THEME, + EnvConstants::THEME_CACHE, + EnvConstants::TEAMSPEAK_HOST, + EnvConstants::TEAMSPEAK_QUERY_PORT, + EnvConstants::TEAMSPEAK_USER, + EnvConstants::LOG_NAME, + EnvConstants::LOG_LEVEL + ]); + return $res; + } else { + die('No environment file found in ' . realpath($envFile)); } - - $res = array_merge_recursive($defaultEnvRes, $envRes); - - return $res; } /** diff --git a/src/Util/TSInstance.php b/src/Util/TSInstance.php index 75a9e18..3f706e1 100644 --- a/src/Util/TSInstance.php +++ b/src/Util/TSInstance.php @@ -26,7 +26,10 @@ class TSInstance /** * TeamSpeakWrapper constructor. + * * @param $logger + * @throws Exception + * if no connection can be made */ public function __construct($logger) { @@ -43,6 +46,7 @@ class TSInstance $this->ts = $ts; $this->logger->debug(sprintf('Connected to %s:%s', $this->host, $this->queryPort)); } catch (TSException $e) { + $this->logger->error(sprintf('Could not connect to %s:%s', $this->host, $this->queryPort, $e->getMessage())); die($e); } }