| verzia 1.22, 2002/03/14 23:15:35 |
verzia 1.23, 2002/03/18 23:24:37 |
|
|
| * 19/02/2002 - getActiveSessions() added |
* 19/02/2002 - getActiveSessions() added |
| * 27/02/2002 - active session query caching added |
* 27/02/2002 - active session query caching added |
| * - PHP support utils |
* - PHP support utils |
| |
* 18/03/2002 - PEAR compliant expected error catching and handling |
| |
* - removed all errors and warnings in code (undefined keys |
| |
* in arrays, bad eval() processing, etc) |
| */ |
*/ |
| |
|
| /* |
/* |
| Riadok 64 class Web_Log { |
|
| Riadok 67 class Web_Log { |
|
| */ |
*/ |
| |
|
| var $_session_timeout; |
var $_session_timeout; |
| var $_session_keys = array('remote_addr', 'http_user_agent', 'ident_username'); |
//var $_session_keys = array('remote_addr', 'http_user_agent', 'ident_username'); |
| |
var $_session_keys = array('remote_addr', 'http_user_agent'); |
| |
|
| /* Raw log variable |
/* Raw log variable |
| |
|
| Riadok 97 class Web_Log { |
|
| Riadok 101 class Web_Log { |
|
| |
|
| /* $_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 |
| special action (ingnore property or add property to list |
special action (ingnore property or add property to list |
| of session definers), it is provided via this identifiers) |
of session definers), it is provided via this identifiers) |
| |
|
| values: arrays; keys of each array are described below |
values: arrays; keys of each array are described below |
| |
|
| key description |
key description |
| ------ ----------- |
------ ----------- |
| column column name in main accesses table |
column column name in main accesses table |
| table table name for values storing (in accesses table will be only |
table table name for values storing (in accesses table will be only |
| ID to this table stored) |
ID to this table stored) |
| var how to get property value; if starts with '$' character, than |
var how to get property value; if starts with '$' character, than |
| it is eval()-ed, if not, than is string passed to getenv() |
it is eval()-ed, if not, than is string passed to getenv() |
| function to obtain value |
function to obtain value |
| value value of property |
value value of property |
| id id of property; defined only if value is stored in its own |
id id of property; defined only if value is stored in its own |
| separate table |
separate table |
| disable if non zero, property is disabled; no action with that property |
disabled if non zero, property is disabled; no action with that property |
| is done; by default, all properties are enabled (not disabled) |
is done; by default, all properties are enabled (not disabled) |
| */ |
*/ |
| |
|
| var $_props = array( |
var $_props = array( |
| Riadok 134 class Web_Log { |
|
| Riadok 138 class Web_Log { |
|
| 'request_method' => array( |
'request_method' => array( |
| 'column' => 'request_method_id', |
'column' => 'request_method_id', |
| 'table' => 'weblog_request_methods', |
'table' => 'weblog_request_methods', |
| 'var' => '$HTTP_SERVER_VARS["REQUEST_METHOD"]' ), |
/*'var' => '$HTTP_SERVER_VARS["REQUEST_METHOD"]' ),*/ |
| |
'var' => 'REQUEST_METHOD' ), |
| 'query_string' => array( |
'query_string' => array( |
| 'column' => 'query_string_id', |
'column' => 'query_string_id', |
| 'table' => 'weblog_query_strings', |
'table' => 'weblog_query_strings', |
| 'var' => '$HTTP_SERVER_VARS["QUERY_STRING"]' ), |
/*'var' => '$HTTP_SERVER_VARS["QUERY_STRING"]' ),*/ |
| |
'var' => 'QUERY_STRING' ), |
| 'path_info' => array( |
'path_info' => array( |
| 'column' => 'path_info_id', |
'column' => 'path_info_id', |
| 'table' => 'weblog_path_infos', |
'table' => 'weblog_path_infos', |
| 'var' => 'PATH_INFO' ), |
'var' => 'PATH_INFO' ), |
| 'path_translated' => array( |
'path_translated' => array( /* must be retrieved from SERVER_VARS */ |
| 'column' => 'path_translated_id', |
'column' => 'path_translated_id', |
| 'table' => 'weblog_paths_translated', |
'table' => 'weblog_paths_translated', |
| 'var' => '$HTTP_SERVER_VARS["PATH_TRANSLATED"]' ), |
'var' => '$HTTP_SERVER_VARS["PATH_TRANSLATED"]' ), |
| Riadok 158 class Web_Log { |
|
| Riadok 164 class Web_Log { |
|
| 'script_name' => array( |
'script_name' => array( |
| 'column' => 'script_name_id', |
'column' => 'script_name_id', |
| 'table' => 'weblog_script_names', |
'table' => 'weblog_script_names', |
| 'var' => '$HTTP_SERVER_VARS["SCRIPT_NAME"]' ), |
/*'var' => '$HTTP_SERVER_VARS["SCRIPT_NAME"]' ),*/ |
| |
'var' => 'SCRIPT_NAME' ), |
| 'server_name' => array( |
'server_name' => array( |
| 'column' => 'server_name_id', |
'column' => 'server_name_id', |
| 'table' => 'weblog_server_names', |
'table' => 'weblog_server_names', |
| Riadok 303 class Web_Log { |
|
| Riadok 310 class Web_Log { |
|
| if (! empty($dsn)) { |
if (! empty($dsn)) { |
| $this->setDSN($dsn); |
$this->setDSN($dsn); |
| } |
} |
| |
|
| |
foreach (array_keys($this->_props) as $prop) { |
| |
$this->_props[$prop]['disabled'] = false; |
| |
} |
| } |
} |
| |
|
| /* |
/* |
| Riadok 506 class Web_Log { |
|
| Riadok 517 class Web_Log { |
|
| if (! empty($this->_props[$prop_name]['var'])) { |
if (! empty($this->_props[$prop_name]['var'])) { |
| $this->_props[$prop_name]['value'] = |
$this->_props[$prop_name]['value'] = |
| $this->_props[$prop_name]['var'][0] == '$' |
$this->_props[$prop_name]['var'][0] == '$' |
| ? eval('return '.$this->_props[$prop_name]['var'].';') |
? eval('return' |
| |
. ' (isset('.$this->_props[$prop_name]['var'].')' |
| |
. ' ? '.$this->_props[$prop_name]['var'].' : false);') |
| : getenv($this->_props[$prop_name]['var']); |
: getenv($this->_props[$prop_name]['var']); |
| } |
} |
| } |
} |
| Riadok 644 class Web_Log { |
|
| Riadok 657 class Web_Log { |
|
| $val = ''; |
$val = ''; |
| |
|
| if ($this->_raw_log) { |
if ($this->_raw_log) { |
| if ($this->_props[$prop_name]['value']) |
if (isset($this->_props[$prop_name]['value'])) { |
| $val = addslashes($this->_props[$prop_name]['value']); |
$val = addslashes($this->_props[$prop_name]['value']); |
| if (! empty($this->_props[$prop_name]['table'])) |
if (! empty($this->_props[$prop_name]['table'])) |
| $val = "'$val'"; |
$val = "'$val'"; |
| |
} |
| |
else { |
| |
$val = 0; |
| |
} |
| } |
} |
| else { |
else { |
| if ($this->_props[$prop_name]['id']) |
if (isset($this->_props[$prop_name]['id'])) { |
| $val = $this->_props[$prop_name]['id']; |
$val = $this->_props[$prop_name]['id']; |
| |
} |
| |
else { |
| |
$val = 0; |
| |
} |
| } |
} |
| |
|
| if ($val) { |
if ($val) { |
| Riadok 689 class Web_Log { |
|
| Riadok 710 class Web_Log { |
|
| |
|
| function _getID($table, $value) |
function _getID($table, $value) |
| { |
{ |
| |
|
| /* |
|
| * 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, |
|
| * uncomment this and comment the next line. Otherwise 0 and "" values |
|
| * will be counted as NULL. |
|
| */ |
|
| |
|
| // if (!isset($value) || !isset($table)) return 0; |
|
| if (! $value || ! $table) |
|
| return 0; |
|
| |
|
| $this->_checkDB(); |
$this->_checkDB(); |
| |
|
| for ($i = 0; $i < 2; $i++) { |
for ($i = 0; $i < 2; $i++) { |
| Riadok 726 class Web_Log { |
|
| Riadok 734 class Web_Log { |
|
| |
|
| $query = "insert into $table (id, value)" |
$query = "insert into $table (id, value)" |
| ." values (0, '" . addslashes($value) . "')"; |
." values (0, '" . addslashes($value) . "')"; |
| $result = $this->_db->query($query); |
|
| |
if ($i == 0) { |
| |
$this->_db->expectError(DB_ERROR_ALREADY_EXISTS); |
| |
$result = $this->_db->query($query); |
| |
$this->_db->popExpect(); |
| |
} |
| |
else { |
| |
$result = $this->_db->query($query); |
| |
} |
| |
|
| /* |
/* |
| * There is a possibility of insert failure. Paraller connection |
* There is a possibility of insert failure. Paraller connection |
| Riadok 736 class Web_Log { |
|
| Riadok 752 class Web_Log { |
|
| */ |
*/ |
| |
|
| if (DB::isError($result)) { |
if (DB::isError($result)) { |
| if ($i > 0) |
if ($i == 0 && $result->getCode() == DB_ERROR_ALREADY_EXISTS) { |
| |
/* This is an expected error. If it will be returned |
| |
again we will count it seriously. */ |
| |
} |
| |
else |
| $this->_error($result->getMessage()); |
$this->_error($result->getMessage()); |
| } |
} |
| else { |
else { |
| |
/* No errors, insert succeed. */ |
| break; |
break; |
| } |
} |
| } |
} |
| Riadok 799 class Web_Log { |
|
| Riadok 820 class Web_Log { |
|
| $this->_error($row->getMessage()); |
$this->_error($row->getMessage()); |
| |
|
| if (is_array($row) |
if (is_array($row) |
| && ($row[diff_sec] < $this->_session_timeout) |
&& ($row['diff_sec'] < $this->_session_timeout) |
| && ($row[session_id])) { |
&& ($row['session_id'])) { |
| |
|
| return $row[session_id]; |
return $row['session_id']; |
| } |
} |
| |
|
| /* |
/* |