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

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