diff --git a/.gitignore b/.gitignore index 5db9b71dc2defcb24eeb44314424ba390e114e1e..42838eb61298d85e9f5a3f9e07c3ee91f0eb29f0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /data/ /nbproject/ /cronjobs.html -/winscp.rnd \ No newline at end of file +/winscp.rnd +config/inc_cronlog.php diff --git a/classes/cronlog-renderer.class.php b/classes/cronlog-renderer.class.php index 759acda3781af077e6921cc801a42e39c26c96a0..538ca075261f089f3698ab3e1fe0633072699930 100644 --- a/classes/cronlog-renderer.class.php +++ b/classes/cronlog-renderer.class.php @@ -1,15 +1,12 @@ <?php require_once 'cronlog.class.php'; -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ - /** - * Description of cronlog-renderer + * central cronlog viewer + * + * cronlog-renderer contains visual methods to render html + * @see cronlog.class.php * * @author hahn */ diff --git a/classes/cronlog.class.php b/classes/cronlog.class.php index 571e6276f204563ac2bb98d333977f2a30167d26..ba6c4c043ba28c50752a8a8d7ab5bc11f15de441 100644 --- a/classes/cronlog.class.php +++ b/classes/cronlog.class.php @@ -1,7 +1,9 @@ <?php - /** - * Description of cronlog + * central cronlog viewer + * + * cronlog contains non visual methods + * @see cronlog-renderer.class.php * * @author hahn */ @@ -9,27 +11,26 @@ class cronlog { - protected $_sDataDir = "__DIR__/data"; + protected $_sDataDir = "__APPDIR__/data"; protected $_iTtlCache = 60; // in sec - + protected $_aSkipJoblogs = array(); protected $_aServers = false; protected $_sActiveServer = false; protected $_sFileFilter_serverjoblog = '*joblog*.done'; protected $_sFileFilter_serverlog = '*.log'; - - protected $_aSkipJoblogs = array( - // 'dok-kvm-instances', - 'sync-log-2-lithium', - ); - + public function __construct() { - if (file_exists(__DIR__.'/cronlog_cfg.php')){ - include(__DIR__.'/cronlog_cfg.php'); + + if (file_exists(__DIR__.'/../config/inc_cronlog.php')){ + $aCfgTemp=include(__DIR__.'/../config/inc_cronlog.php'); + $this->_sDataDir = isset($aCfgTemp['sDatadir']) ? $aCfgTemp['sDatadir'] : $this->_sDataDir; + $this->_iTtlCache = isset($aCfgTemp['iTtlCache']) ? (int)$aCfgTemp['iTtlCache'] : $this->_iTtlCache; + $this->_aSkipJoblogs = isset($aCfgTemp['aHidelogs']) && is_array($aCfgTemp['aHidelogs']) ? $aCfgTemp['aHidelogs'] : $this->_aSkipJoblogs; } - $this->_sDataDir = str_replace("__DIR__", dirname(dirname(__FILE__)), $this->_sDataDir); + $this->_sDataDir = str_replace("__APPDIR__", dirname(dirname(__FILE__)), $this->_sDataDir); $this->_sDataDir = str_replace('\\', '/', $this->_sDataDir); $this->getServers(); @@ -112,7 +113,7 @@ class cronlog { $this->_aServers=array(); // echo "DEBUG DATADIR: " . $this->_sDataDir."<br>"; if (!is_dir($this->_sDataDir)){ - echo "WARNING: no data. variable _sDataDir is wrong (or somehting is not mounted).<br>"; + echo "WARNING: no data. Check sDatadir in the config and set it to an existing directory.<br>"; die(); } diff --git a/classes/cronlog_cfg.php b/classes/cronlog_cfg.php deleted file mode 100644 index 38713f1cd57d73e8951652c3517294e01525925d..0000000000000000000000000000000000000000 --- a/classes/cronlog_cfg.php +++ /dev/null @@ -1,6 +0,0 @@ -<?php -$sLithiumDir='/var/www/cronlogs'; - -if(is_dir($sLithiumDir)){ - $this->_sDataDir = $sLithiumDir; -} \ No newline at end of file diff --git a/config/inc_cronlog.php.dist b/config/inc_cronlog.php.dist new file mode 100644 index 0000000000000000000000000000000000000000..d995feef6e6d40b768ab719ea4b0c4a554adab64 --- /dev/null +++ b/config/inc_cronlog.php.dist @@ -0,0 +1,13 @@ +<?php +/** + * CONFIG FILE + * + * it is included by classes/cronlog.class.php + */ +return array( + // starting directory with all servers cronwrapper logs + 'sDatadir'=>'__APPDIR__/data', + + // caching time for infos in the browser + 'iTtlCache'=>0, +);