Ignore:
Timestamp:
Aug 10, 2017, 6:05:33 PM (9 years ago)
Author:
Joachim Langenbach <joachim.langenbach@…>
Branches:
0.5, app-cordova, debian/bullseye, debian/jessie, master
Children:
6fec060
Parents:
82b4b49
Message:
  • Webservice now leverages PHP classes and autoloader functionality. All webservice tasks are combined in index.php and served by Webservice.php
  • Webclient lists available log files and webservice provides them to download
Location:
src/webapp/webservice/inc
Files:
7 added
1 moved

Legend:

Unmodified
Added
Removed
  • src/webapp/webservice/inc/GnuBoat/Config.php

    r82b4b49 rc455d7b  
    1717*/
    1818
    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 }
     19namespace GNUBoat;
    2620
    2721/**
    2822 * @brief Loads the configuration from webservice/config/config.php (if file exists) and provides the settings for usage
    2923 */
    30 class Config {
    31         public function __construct(){
    32                 global $config;
    33                 $this->_config = $config;
     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                }
    3436        }
    3537
    36         public function databaseFile(){
     38        public function databaseFile()
     39        {
    3740                return $this->dataDirectory() ."gnuboat.rrd";
    3841        }
    3942
    40         public function shutdownRequestFile(){
     43        public function shutdownRequestFile()
     44        {
    4145                if(array_key_exists("shutdownfile", $this->_config))
    4246                        return $this->_config["shutdownfile"];
    … …  
    4448        }
    4549
    46         public function dataDirectory(){
     50        public function dataDirectory()
     51        {
    4752                if(array_key_exists("datadirectory", $this->_config))
    4853                        return addTrailingSlash($this->_config["datadirectory"]);
    … …  
    5055        }
    5156
    52         private static function addTrailingSlash($path){
     57        public function logDirectory()
     58        {
     59                if(array_key_exists("logdirectory", $this->_config))
     60                        return addTrailingSlash($this->_config["logdirectory"]);
     61                return "/var/log/gnuboat/";
     62        }
     63
     64        private static function addTrailingSlash($path)
     65        {
    5366                $length = strlen($path);
    5467                if(substr($path, $length - 1, 1) != "/"){
Note: See TracChangeset for help on using the changeset viewer.