| verzia 1.20, 2002/02/19 23:07:15 |
verzia 1.21, 2002/02/28 20:35:47 |
|
|
| * 16/02/2002 - property manipulation methods (get/set value, get array) |
* 16/02/2002 - property manipulation methods (get/set value, get array) |
| * - fixed geting max session ID when raw logging enabled |
* - fixed geting max session ID when raw logging enabled |
| * 19/02/2002 - getActiveSessions() added |
* 19/02/2002 - getActiveSessions() added |
| |
* 27/02/2002 - active session query caching added |
| |
* - PHP support utils |
| */ |
*/ |
| |
|
| /* |
/* |
| Riadok 82 class Web_Log { |
|
| Riadok 84 class Web_Log { |
|
| var $_db; |
var $_db; |
| var $_dsn; |
var $_dsn; |
| |
|
| |
/* Cache variables |
| |
|
| |
$_cache_active_sessions - cached result of active sessions query |
| |
*/ |
| |
|
| |
//var $_cache_sessions_count; |
| |
//var $_cache_raw_log_sessions_count; |
| |
|
| |
var $_cache_active_sessions; |
| |
var $_cache_raw_log_active_sessions; |
| |
|
| /* $_props - properties array |
/* $_props - properties array |
| |
|
| keys: identifiers (when user is specifing some property for some |
keys: identifiers (when user is specifing some property for some |
| Riadok 270 class Web_Log { |
|
| Riadok 283 class Web_Log { |
|
| * Object constructor. |
* Object constructor. |
| */ |
*/ |
| |
|
| function Web_Log($dsn = '', $session_timeout = 1800 /* 30 mins. */) |
function Web_Log($dsn = '', $session_timeout = 0) |
| { |
{ |
| |
|
| |
if (empty($session_timeout)) |
| |
$session_timeout = 1800; /* 30 mins. */ |
| |
|
| $this->_session_timeout = $session_timeout; |
$this->_session_timeout = $session_timeout; |
| |
|
| unset($this->_db); |
unset($this->_db); |
| unset($this->_dsn); |
unset($this->_dsn); |
| |
//unset($this->_cache_sessions_count); |
| |
//unset($this->_cache_raw_log_sessions_count); |
| |
unset($this->_cache_active_sessions); |
| |
unset($this->_cache_raw_log_active_sessions); |
| |
|
| $this->_raw_log = 0; |
$this->_raw_log = 0; |
| |
|
| Riadok 429 class Web_Log { |
|
| Riadok 449 class Web_Log { |
|
| /* |
/* |
| * _error() |
* _error() |
| * |
* |
| * Error handling function. |
* Error handling function. TODO: improve! |
| */ |
*/ |
| |
|
| function _error($message = "Unknown error") { |
function _error($message = "Unknown error") { |
| Riadok 671 class Web_Log { |
|
| Riadok 691 class Web_Log { |
|
| { |
{ |
| |
|
| /* |
/* |
| * OBSOLETE: $table and $value are now always set on _getID() call |
* OBSOLETE COMMENT: $table and $value are now always set on _getID() call |
| * |
* |
| * If you want to have 0 or "" in you database as valid values, |
* If you want to have 0 or "" in you database as valid values, |
| * uncomment this and comment the next line. Otherwise 0 and "" values |
* uncomment this and comment the next line. Otherwise 0 and "" values |
| Riadok 820 class Web_Log { |
|
| Riadok 840 class Web_Log { |
|
| { |
{ |
| $this->_checkDB(); |
$this->_checkDB(); |
| |
|
| |
$accesses_table = $this->_raw_log |
| |
? "weblog_accesses_raw" |
| |
: "weblog_accesses"; |
| |
|
| $list_tables = ''; |
$list_tables = ''; |
| $list_where = ''; |
$list_where = ''; |
| |
|
| Riadok 827 class Web_Log { |
|
| Riadok 851 class Web_Log { |
|
| |
|
| foreach ($array as $key => $val) { |
foreach ($array as $key => $val) { |
| |
|
| if (isset($this->_props[$key]['table'])) { |
if (! $this->_raw_log && isset($this->_props[$key]['table'])) { |
| $list_where .= ($list_where == '' ? '' : ' and '); |
$list_where .= ($list_where == '' ? '' : ' and '); |
| $list_where .= "weblog_accesses." |
$list_where .= "$accesses_table." |
| . $this->_props[$key]['column'] . " = " |
. $this->_props[$key]['column'] . " = " |
| . $this->_props[$key]['table'] . ".id and " |
. $this->_props[$key]['table'] . ".id and " |
| . $this->_props[$key]['table'] . ".value like '$val'"; |
. $this->_props[$key]['table'] . ".value like '$val'"; |
| Riadok 846 class Web_Log { |
|
| Riadok 870 class Web_Log { |
|
| |
|
| $query = "select" |
$query = "select" |
| ." count(distinct session_id) as sessions_count" |
." count(distinct session_id) as sessions_count" |
| ." from weblog_accesses"; |
." from $accesses_table"; |
| |
|
| if (strlen($list_tables) > 0) |
if (strlen($list_tables) > 0) |
| $query .= ", $list_tables"; |
$query .= ", $list_tables"; |
| Riadok 873 class Web_Log { |
|
| Riadok 897 class Web_Log { |
|
| |
|
| function getActiveSessions() |
function getActiveSessions() |
| { |
{ |
| |
if ($this->_raw_log) { |
| |
if (isset($this->_cache_raw_log_active_sessions)) |
| |
return $this->_cache_active_sessions; |
| |
} |
| |
else { |
| |
if (isset($this->_cache_active_sessions)) |
| |
return $this->_cache_active_sessions; |
| |
} |
| |
|
| $this->_checkDB(); |
$this->_checkDB(); |
| |
|
| $accesses_table = $this->_raw_log |
$accesses_table = $this->_raw_log |
| Riadok 891 class Web_Log { |
|
| Riadok 924 class Web_Log { |
|
| if (DB::isError($active_sessions)) |
if (DB::isError($active_sessions)) |
| $this->_error($active_sessions->getMessage()); |
$this->_error($active_sessions->getMessage()); |
| |
|
| |
if ($this->_raw_log) |
| |
$this->_cache_raw_log_active_sessions = $active_sessions; |
| |
else |
| |
$this->_cache_active_sessions = $active_sessions; |
| |
|
| return $active_sessions; |
return $active_sessions; |
| } |
} |
| } |
} |