Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Monday, November 23, 2026

Diff for phpWebLogAnalyzer/phpWebLogAnalyzer.inc.php between version 1.16 and 1.17

version 1.16, 2002/02/03 19:53:07 version 1.17, 2002/02/12 23:18:54
Line 58  class Web_Log {
Line 58  class Web_Log {
         var $_session_timeout;          var $_session_timeout;
         var $_session_keys = array('remote_addr', 'http_user_agent');          var $_session_keys = array('remote_addr', 'http_user_agent');
   
           /* Raw log variable
   
              $_raw_log - use raw log table for logging (it is faster than normal
                      logging, but it needs some job to transform data from
                      raw log table to normal table, for example via cron)
            */
   
           var $_raw_log;
   
         /* Database variables          /* Database variables
   
        $_db - PEAR DB object         $_db - PEAR DB object
Line 263  class Web_Log {
Line 272  class Web_Log {
                 unset($this->_db);                  unset($this->_db);
                 unset($this->_dsn);                  unset($this->_dsn);
   
                   $this->_raw_log = 0;
   
                 if (! empty($dsn)) {                  if (! empty($dsn)) {
                         $this->setDSN($dsn);                          $this->setDSN($dsn);
                 }                  }
Line 308  class Web_Log {
Line 319  class Web_Log {
         }          }
   
         /*          /*
            * enableRawLog(), disableRawLog()
            *
            * Enable/disable of logging to raw acesses table.
            */
   
           function enableRawLog()
           {
                   $this->_raw_log = 1;
           }
   
           function disableRawLog()
           {
                   $this->_raw_log = 0;
           }
   
           /*
          * enableProperty(), disableProperty()           * enableProperty(), disableProperty()
          *           *
          * Enable/disable loging of specific property.           * Enable/disable loging of specific property.
Line 501  class Web_Log {
Line 528  class Web_Log {
                  * Counting IDs according to values.                   * Counting IDs according to values.
                  */                   */
   
                 foreach (array_keys($this->_props) as $prop_name) {                  if (! $this->_raw_log) {
                         if (isset($this->_props[$prop_name]['value'])) {                          foreach (array_keys($this->_props) as $prop_name) {
                                   if (isset($this->_props[$prop_name]['value'])) {
                                 if (! empty($this->_props[$prop_name]['table'])) {  
                                         $id = $this->_getID(                                          if (! empty($this->_props[$prop_name]['table'])) {
                                                         $this->_props[$prop_name]['table'],                                                  $id = $this->_getID(
                                                         $this->_props[$prop_name]['value']);                                                                  $this->_props[$prop_name]['table'],
                                                                   $this->_props[$prop_name]['value']);
                                         if (intval($id))  
                                                 $this->_props[$prop_name]['id'] = $id;                                                  if (intval($id))
                                 }                                                          $this->_props[$prop_name]['id'] = $id;
                                 else {                                          }
                                         $this->_props[$prop_name]['id'] =                                          else {
                                                 $this->_props[$prop_name]['value'];                                                  $this->_props[$prop_name]['id'] =
                                                           $this->_props[$prop_name]['value'];
                                           }
                                 }                                  }
                         }                          }
                 }                  }
   
                 /*                  /*
                  * Session property. It is counted according to other IDs,                   * Session property. It is counted according to other IDs,
                  * so it must be after loop above.                   * so it must be after others IDs counting loop above.
                  */                   */
   
                 if (! $this->_props['session']['disabled']) {                  if (! $this->_props['session']['disabled']) {
Line 537  class Web_Log {
Line 566  class Web_Log {
                  * Datetime property. It doesn't contain real value,                   * Datetime property. It doesn't contain real value,
                  * but SQL clausule for getting datetime.                   * but SQL clausule for getting datetime.
                  *                   *
                  * TODO: make it database independent                   * TODO: make it database independent (or sysdate() is?)
                  */                   */
   
                 if (! $this->_props['datetime']['disabled'])                  if (! $this->_props['datetime']['disabled'])
Line 550  class Web_Log {
Line 579  class Web_Log {
   
                 foreach (array_keys($this->_props) as $prop_name) {                  foreach (array_keys($this->_props) as $prop_name) {
                         $sep = ($keys == '' ? '' : ', ');                          $sep = ($keys == '' ? '' : ', ');
                           $val = '';
   
                         if ($this->_props[$prop_name]['id']) {                          if ($this->_raw_log) {
                                   if ($this->_props[$prop_name]['value'])
                                           $val = addslashes($this->_props[$prop_name]['value']);
                                           if (! empty($this->_props[$prop_name]['table']))
                                                   $val = "'$val'";
                           }
                           else {
                                   if ($this->_props[$prop_name]['id'])
                                           $val = $this->_props[$prop_name]['id'];
                           }
   
                           if ($val) {
                                 $keys .= $sep . $this->_props[$prop_name]['column'];                                  $keys .= $sep . $this->_props[$prop_name]['column'];
                                 $vals .= $sep .  $this->_props[$prop_name]['id'];                                  $vals .= $sep . $val;
                         }                          }
                 }                  }
   
                 $query = "insert into weblog_accesses ($keys) values ($vals)";                  $accesses_table = $this->_raw_log
                           ? "weblog_accesses_raw"
                           : "weblog_accesses";
   
                   $query = "insert into $accesses_table ($keys) values ($vals)";
   
                 //print "<hr>$query<br>\n";                  //print "<hr>$query<br>\n";
   
Line 653  class Web_Log {
Line 698  class Web_Log {
   
                                 $where .= $this->_props[$session_key]['column'];                                  $where .= $this->_props[$session_key]['column'];
                                 $where .= " = ";                                  $where .= " = ";
                                 $where .= "'" . $this->_props[$session_key]['id'] . "'";                                  $where .= $this->_raw_log
                                           ? "substring('"
                                           . addslashes($this->_props[$session_key]['value'])
                                           . "', 1, 255)"
                                           : "'" . $this->_props[$session_key]['id'] . "'";
                         }                          }
                 }                  }
   
                   $accesses_table = $this->_raw_log
                           ? "weblog_accesses_raw"
                           : "weblog_accesses";
   
                 $query = "select"                  $query = "select"
                         ." id, session_id,"                          ." id, session_id,"
                         ." unix_timestamp(now()) - unix_timestamp(datetime) as diff_sec"                          ." unix_timestamp(sysdate()) - unix_timestamp(datetime) as diff_sec"
                         ." from weblog_accesses"                          ." from $accesses_table"
                         ." $where"                          ." $where"
                         ." order by datetime desc"                          ." order by datetime desc"
                         ." limit 1";                          ." limit 1";
Line 677  class Web_Log {
Line 730  class Web_Log {
                 }                  }
   
                 $query = "select max(session_id) + 1 as new_session_id"                  $query = "select max(session_id) + 1 as new_session_id"
                         ." from weblog_accesses";                          ." from $accesses_table";
                 $id = $this->_db->getOne($query);                  $id = $this->_db->getOne($query);
   
                 if (DB::isError($id))                  if (DB::isError($id))

Legend:
Removed from v.1.16  
changed lines
  Added in v.1.17

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top