source: src/webapp/webservice/inc/GnuBoat/Config.php@ 9773514

0.5 debian/bullseye debian/jessie
Last change on this file since 9773514 was 008bce9, checked in by Joachim Langenbach <joachim.langenbach@…>, 9 years ago

First more or less working version of visualising logfiles on the map

  • Property mode set to 100644
File size: 2.0 KB
Line 
1<?php
2/*
3 Copyright (C) 2016 - 2017 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
19namespace GNUBoat;
20
21/**
22 * @brief Loads the configuration from webservice/config/config.php (if file exists) and provides the settings for usage
23 */
24class Config
25{
26 public function __construct()
27 {
28 $configFile = __DIR__ ."/../../config/config.php";
29 if(file_exists($configFile)){
30 include($configFile);
31 $this->_config = $config;
32 }
33 else{
34 $this->_config = array();
35 }
36 }
37
38 public function databaseFile()
39 {
40 return $this->dataDirectory() ."gnuboat.rrd";
41 }
42
43 public function shutdownRequestFile()
44 {
45 if(array_key_exists("shutdownfile", $this->_config))
46 return $this->_config["shutdownfile"];
47 return "/var/spool/gnuboat/shutdown.request";
48 }
49
50 public function dataDirectory()
51 {
52 if(array_key_exists("datadirectory", $this->_config))
53 return $this->addTrailingSlash($this->_config["datadirectory"]);
54 return "/var/lib/gnuboat/";
55 }
56
57 public function logDirectory()
58 {
59 if(array_key_exists("logdirectory", $this->_config))
60 return $this->addTrailingSlash($this->_config["logdirectory"]);
61 return "/var/log/gnuboat/";
62 }
63
64 private static function addTrailingSlash($path)
65 {
66 $length = strlen($path);
67 if(substr($path, $length - 1, 1) != "/"){
68 return $path ."/";
69 }
70 return $path;
71 }
72
73 private $_config;
74}
75
76?>
Note: See TracBrowser for help on using the repository browser.