Moving to GitHub.
[platal.git] / classes / platallogger.php
index 447ff9e..b76daf4 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /*
- * Copyright (C) 2003-2009 Polytechnique.org
+ * Copyright (C) 2003-2014 Polytechnique.org
  * http://opensource.polytechnique.org/
  *
  * This program is free software; you can redistribute it and/or modify
@@ -46,7 +46,7 @@ class PlatalLogger extends PlLogger
 
         // retrieve available actions
         $this->actions = XDB::fetchAllAssoc('text', 'SELECT  id, text
-                                                       FROM  logger.actions');
+                                                       FROM  log_actions');
     }
 
     /** Creates a new session entry in database and return its ID.
@@ -55,7 +55,7 @@ class PlatalLogger extends PlLogger
      * @param $suid the id of the administrator who has just su'd to the user
      * @return session the session id
      */
-    private function writeSession($uid, $suid = 0)
+    private function writeSession($uid, $suid = null)
     {
         $ip      = $_SERVER['REMOTE_ADDR'];
         $host    = strtolower(gethostbyaddr($_SERVER['REMOTE_ADDR']));
@@ -71,7 +71,9 @@ class PlatalLogger extends PlLogger
             $proxy = 'proxy';
         }
 
-        XDB::execute("INSERT INTO  logger.sessions
+        $uid = ($uid == 0) ? null : $uid;
+        $suid = ($suid == 0) ? null : $suid;
+        XDB::execute("INSERT INTO  log_sessions
                               SET  uid={?}, host={?}, ip={?}, forward_ip={?}, forward_host={?}, browser={?}, suid={?}, flags={?}",
                      $uid, $host, ip_to_uint($ip), ip_to_uint($forward_ip), $forward_host, $browser, $suid, $proxy);
         if ($forward_ip) {
@@ -88,7 +90,7 @@ class PlatalLogger extends PlLogger
     }
 
     public function saveLastSession() {
-        XDB::execute('REPLACE INTO  logger.last_sessions (uid, id)
+        XDB::execute('REPLACE INTO  log_last_sessions (uid, id)
                             VALUES  ({?}, {?})',
                      $this->uid, $this->session);
     }
@@ -106,7 +108,7 @@ class PlatalLogger extends PlLogger
     public function log($action, $data = null)
     {
         if (isset($this->actions[$action])) {
-            XDB::execute("INSERT INTO  logger.events
+            XDB::execute("INSERT INTO  log_events
                                   SET  session={?}, action={?}, data={?}",
                          $this->session, $this->actions[$action], $data);
         } else {
@@ -115,5 +117,5 @@ class PlatalLogger extends PlLogger
     }
 }
 
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker fenc=utf-8:
 ?>