]> git.datanom.net - qtadmin.git/commitdiff
finish log method
authorMichael Rasmussen <mir@datanom.net>
Sat, 6 Jun 2015 12:02:22 +0000 (14:02 +0200)
committerMichael Rasmussen <mir@datanom.net>
Sat, 6 Jun 2015 12:02:22 +0000 (14:02 +0200)
config.php
lib/utils.inc.php

index f3619930ce510094f82541b46a64b6cfa35e47b4..da1e02e90b8d58c05e9a5dda66b8f7ce29febfe7 100644 (file)
@@ -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';
 ?>
index dcdd8518eb4d7b458876edf51d49eb23f80fb6ea..773e45fceee4d66dc6335f891cfe516fb7ca13d9 100644 (file)
@@ -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;
This page took 0.035382 seconds and 5 git commands to generate.