| 1 | <?php
|
|---|
| 2 | /*
|
|---|
| 3 | Copyright (C) 2016 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.
|
|---|
| 4 |
|
|---|
| 5 | This program is free software: you can redistribute it and/or modify
|
|---|
| 6 | it under the terms of the GNU General Public License as published by
|
|---|
| 7 | the Free Software Foundation, either version 3 of the License, or
|
|---|
| 8 | (at your option) any later version.
|
|---|
| 9 |
|
|---|
| 10 | This program is distributed in the hope that it will be useful,
|
|---|
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 13 | GNU General Public License for more details.
|
|---|
| 14 |
|
|---|
| 15 | You should have received a copy of the GNU General Public License
|
|---|
| 16 | along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|---|
| 17 | */
|
|---|
| 18 |
|
|---|
| 19 | $configFile = __DIR__ ."../config/config.php";
|
|---|
| 20 | if(file_exists($configFile))
|
|---|
| 21 | include($configFile);
|
|---|
| 22 | else{
|
|---|
| 23 | error_log("No config file ". $configFile ." not found!");
|
|---|
| 24 | $config = array();
|
|---|
| 25 | }
|
|---|
| 26 |
|
|---|
| 27 | /**
|
|---|
| 28 | * @brief Loads the configuration from webservice/config/config.php (if file exists) and provides the settings for usage
|
|---|
| 29 | */
|
|---|
| 30 | class Config {
|
|---|
| 31 | public function __construct(){
|
|---|
| 32 | global $config;
|
|---|
| 33 | $this->_config = $config;
|
|---|
| 34 | }
|
|---|
| 35 |
|
|---|
| 36 | public function databaseFile(){
|
|---|
| 37 | return $this->dataDirectory() ."log-webservice.rrd";
|
|---|
| 38 | }
|
|---|
| 39 |
|
|---|
| 40 | public function shutdownRequestFile(){
|
|---|
| 41 | if(array_key_exists("shutdownfile", $this->_config))
|
|---|
| 42 | return $this->_config["shutdownfile"];
|
|---|
| 43 | return "/var/spool/gnuboat/shutdown.request";
|
|---|
| 44 | }
|
|---|
| 45 |
|
|---|
| 46 | public function dataDirectory(){
|
|---|
| 47 | if(array_key_exists("datadirectory", $this->_config))
|
|---|
| 48 | return addTrailingSlash($this->_config["datadirectory"]);
|
|---|
| 49 | return "/var/lib/gnuboat/";
|
|---|
| 50 | }
|
|---|
| 51 |
|
|---|
| 52 | private static function addTrailingSlash($path){
|
|---|
| 53 | $length = strlen($path);
|
|---|
| 54 | if(substr($path, $length - 1, 1) != "/"){
|
|---|
| 55 | return $path ."/";
|
|---|
| 56 | }
|
|---|
| 57 | return $path;
|
|---|
| 58 | }
|
|---|
| 59 |
|
|---|
| 60 | private $_config;
|
|---|
| 61 | }
|
|---|
| 62 |
|
|---|
| 63 | ?>
|
|---|