source: src/webapp/webservice/inc/Config.php@ eb7597e

debian/bullseye debian/jessie
Last change on this file since eb7597e was c84f87e, checked in by Joachim Langenbach <joachim.langenbach@…>, 10 years ago

Merge branch 'master' of ​https://svn.falaba.de/gnuboat

  • Property mode set to 100644
File size: 1.8 KB
RevLine 
[4ab1c0a]1<?php
2/*
[c84f87e]3 Copyright (C) 2016 - 2017 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.
[4ab1c0a]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";
20if(file_exists($configFile))
21 include($configFile);
22else{
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 */
30class Config {
31 public function __construct(){
32 global $config;
33 $this->_config = $config;
34 }
35
36 public function databaseFile(){
[95db5cc]37 return $this->dataDirectory() ."gnuboat.rrd";
[4ab1c0a]38 }
[95db5cc]39
[9be4f3f]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 }
[95db5cc]45
[4ab1c0a]46 public function dataDirectory(){
47 if(array_key_exists("datadirectory", $this->_config))
48 return addTrailingSlash($this->_config["datadirectory"]);
[00a8800]49 return "/var/lib/gnuboat/";
[4ab1c0a]50 }
[95db5cc]51
[4ab1c0a]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 }
[95db5cc]59
[4ab1c0a]60 private $_config;
61}
62
[9be4f3f]63?>
Note: See TracBrowser for help on using the repository browser.