From: Michael Rasmussen Date: Sat, 6 Jun 2015 12:02:22 +0000 (+0200) Subject: finish log method X-Git-Url: http://git.datanom.net/qtadmin.git/commitdiff_plain/7b56160975b8ef93b24fb6d1128d557efab2b7da finish log method --- diff --git a/config.php b/config.php index f361993..da1e02e 100644 --- a/config.php +++ b/config.php @@ -39,9 +39,15 @@ $CFG->session_timeout = 60; $CFG->log_level = 3; // Log method -// stderr = Stand Error -// file = file to log to. Requires write permission to web server +// stderr = Log to stand error +// file = Log to file. Requires write permission // syslog = syslog // Default log method is syslog $CFG->log_method = 'syslog'; + +// File to log to if log method is file +// Both relative and absolut path is accepted +// If path is relative root is $CFG->root +// Default file is $CFG->root.qtadmin.log +$CFG->log_file = 'qtadmin.log'; ?> diff --git a/lib/utils.inc.php b/lib/utils.inc.php index dcdd851..773e45f 100644 --- a/lib/utils.inc.php +++ b/lib/utils.inc.php @@ -82,7 +82,20 @@ class Utils { switch ($this->log_method) { case 'file': + if (isset($CFG->log_file)) { + if ($CFG->log_file[0] == '/') { + $file = $CFG->log_file; + } else { + $file = $CFG->root.$CFG->log_file; + } + } else { + $file = $CFG->root.'qtadmin.log'; + } + file_put_contents($file, "[$time]: $message", FILE_APPEND | LOCK_EX); + break; case 'stderr': + file_put_contents('php://stderr', "[$time]: $message"); + break; case 'syslog': syslog($priority, $message); break; @@ -125,8 +138,9 @@ class Utils { if (ini_get('session.gc_maxlifetime') != $this->timeout) ini_set('session.gc_maxlifetime', $this->timeout); - if (ini_get('session.cookie_lifetime') != $this->timeout) - ini_set('session.cookie_lifetime', $this->timeout); + //if (ini_get('session.cookie_lifetime') != $this->timeout) + // ini_set('session.cookie_lifetime', $this->timeout); + ini_set('session.cookie_lifetime', 0); session_start(); } @@ -275,9 +289,8 @@ class Utils { } if ($loggedIn == false) { - echo '$this->settings: '.var_export($this->settings, true); - echo 'R_TIME: '.date('c', $_SERVER['REQUEST_TIME']).' L_ACT: '.date('c', $_SESSION['LAST_ACTIVITY']); - //exit; + $this->log('$this->settings: '.var_export($this->settings, true), 3); + $this->log('R_TIME: '.date('c', $_SERVER['REQUEST_TIME']).' L_ACT: '.date('c', $_SESSION['LAST_ACTIVITY']), 3); } $_SESSION['settings'] = $this->settings;