source: src/webapp/webservice/inc/Config.php@ 4ab1c0a

0.5 app-cordova debian/bullseye debian/jessie
Last change on this file since 4ab1c0a was 4ab1c0a, checked in by Joachim Langenbach <joachim.langenbach@…>, 10 years ago
  • Added gnuboat python script, which collects the data from gpsd into a rrd database for the webservice
    • Adapted the webservice
    • Adapted the webclient

Signed-off-by: Joachim Langenbach <joachim.langenbach@…>

  • Property mode set to 100644
File size: 1.6 KB
Line 
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";
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(){
37 return $this->dataDirectory() ."log-webservice.rrd";
38 }
39
40 public function dataDirectory(){
41 if(array_key_exists("datadirectory", $this->_config))
42 return addTrailingSlash($this->_config["datadirectory"]);
43 return __DIR__ ."/../data/";
44 }
45
46 private static function addTrailingSlash($path){
47 $length = strlen($path);
48 if(substr($path, $length - 1, 1) != "/"){
49 return $path ."/";
50 }
51 return $path;
52 }
53
54 private $_config;
55}
56
57?>
Note: See TracBrowser for help on using the repository browser.