| verzia 1.29, 2002/04/15 19:47:17 |
verzia 1.30, 2002/04/19 23:56:05 |
|
|
| * 03/04/2002 - standartized SQL queries |
* 03/04/2002 - standartized SQL queries |
| * - striping slashes from HTTP headers |
* - striping slashes from HTTP headers |
| * - using appropriate PEAR DB function for slashes adding |
* - using appropriate PEAR DB function for slashes adding |
| |
* 19/04/2002 - support for query strings truncating |
| */ |
*/ |
| |
|
| define('WEB_LOG_VALUE_SUBSTR_LENGTH', 255); |
define('WEB_LOG_VALUE_SUBSTR_LENGTH', 255); |
| define('WEB_LOG_SESSION_TIMEOUT_DEFAULT', 1800); |
define('WEB_LOG_SESSION_TIMEOUT_DEFAULT', 1800); |
| define('WEB_LOG_RAW_LOG_DEFAULT', 1); |
define('WEB_LOG_RAW_LOG_DEFAULT', 1); |
| define('WEB_LOG_TRUNCATE_NAMES_DEFAULT', 0); |
define('WEB_LOG_TRUNCATE_NAMES_DEFAULT', 0); |
| |
define('WEB_LOG_TRUNCATE_QUERY_STRINGS_DEFAULT', 1); |
| |
|
| /* |
/* |
| * Ident library |
* Ident library |
| Riadok 109 class Web_Log { |
|
| Riadok 111 class Web_Log { |
|
| |
|
| var $_truncate_names; |
var $_truncate_names; |
| |
|
| |
/* Truncated query strings |
| |
|
| |
$_truncate_qstrings - flag to truncate query strings |
| |
$_truncate_qstrings_keys - keys to truncate (case unsensitive) |
| |
*/ |
| |
|
| |
var $_truncate_qstrings; |
| |
var $_truncate_qstrings_keys = array(/*'session',*/ 'PHPSESSID'); |
| |
|
| /* Database variables |
/* Database variables |
| |
|
| $_db - PEAR DB object |
$_db - PEAR DB object |
| Riadok 326 class Web_Log { |
|
| Riadok 337 class Web_Log { |
|
| if (empty($session_timeout)) |
if (empty($session_timeout)) |
| $session_timeout = WEB_LOG_SESSION_TIMEOUT_DEFAULT; |
$session_timeout = WEB_LOG_SESSION_TIMEOUT_DEFAULT; |
| |
|
| $this->_session_timeout = $session_timeout; |
$this->_session_timeout = $session_timeout; |
| $this->_raw_log = WEB_LOG_RAW_LOG_DEFAULT; |
$this->_raw_log = WEB_LOG_RAW_LOG_DEFAULT; |
| $this->_truncate_names = WEB_LOG_TRUNCATE_NAMES_DEFAULT; |
$this->_truncate_names = WEB_LOG_TRUNCATE_NAMES_DEFAULT; |
| |
$this->_truncate_qstrings = WEB_LOG_TRUNCATE_QUERY_STRINGS_DEFAULT; |
| |
|
| unset($this->_db); |
unset($this->_db); |
| unset($this->_dsn); |
unset($this->_dsn); |
| Riadok 382 class Web_Log { |
|
| Riadok 394 class Web_Log { |
|
| * setSessionKeys(), getSessionKeys() |
* setSessionKeys(), getSessionKeys() |
| * |
* |
| * Sets/gets session keys. |
* Sets/gets session keys. |
| |
* If string specified, value will be appended to array. |
| */ |
*/ |
| |
|
| function setSessionKeys($keys) |
function setSessionKeys($keys) |
| Riadok 390 class Web_Log { |
|
| Riadok 403 class Web_Log { |
|
| $this->_session_keys = $keys; |
$this->_session_keys = $keys; |
| } |
} |
| elseif (is_string($keys)) { |
elseif (is_string($keys)) { |
| $this->_session_keys = array($keys); |
// TODO: REMOVE ME! |
| |
//$this->_session_keys = array($keys); |
| |
array_push($this->_session_keys, $keys); |
| } |
} |
| } |
} |
| |
|
| Riadok 432 class Web_Log { |
|
| Riadok 447 class Web_Log { |
|
| } |
} |
| |
|
| /* |
/* |
| |
* enableTruncateQueryStrings(), disableTruncateQueryStrings() |
| |
* setTruncateQueryStringsKeys(), getTruncateQueryStringsKeys() |
| |
* |
| |
* Enable/disable trincating of query strings according to specified |
| |
* query strings keys. |
| |
* |
| |
* Sets/gets truncate query strings keys. If string specified, value |
| |
* will be appended to array. |
| |
*/ |
| |
|
| |
function enableTruncateQueryStrings() |
| |
{ |
| |
$this->_truncate_qstrings = 1; |
| |
} |
| |
|
| |
function disableTruncateQueryStrings() |
| |
{ |
| |
$this->_truncate_qstrings = 1; |
| |
} |
| |
|
| |
function setTruncateQueryStringsKeys($keys) |
| |
{ |
| |
if (is_array($keys)) { |
| |
$this->_truncate_qstrings_keys = $keys; |
| |
} |
| |
elseif (is_string($keys)) { |
| |
// TODO: REMOVE ME! |
| |
//$this->_session_keys = array($keys); |
| |
array_push($this->_truncate_qstrings_keys, $keys); |
| |
} |
| |
} |
| |
|
| |
function getTruncateQueryStringsKeys() |
| |
{ |
| |
return $this->_truncate_qstrings_keys; |
| |
} |
| |
|
| |
/* |
| * enableProperty(), disableProperty() |
* enableProperty(), disableProperty() |
| * |
* |
| * Enable/disable loging of specific property. |
* Enable/disable loging of specific property. |
| Riadok 623 class Web_Log { |
|
| Riadok 676 class Web_Log { |
|
| if (is_numeric($name_ar[0])) { |
if (is_numeric($name_ar[0])) { |
| array_pop($name_ar); |
array_pop($name_ar); |
| $name = join('.', $name_ar) . '.*'; |
$name = join('.', $name_ar) . '.*'; |
| } else { |
} |
| |
else { |
| array_shift($name_ar); |
array_shift($name_ar); |
| $name = '*.' . join('.', $name_ar); |
$name = '*.' . join('.', $name_ar); |
| } |
} |
| Riadok 632 class Web_Log { |
|
| Riadok 686 class Web_Log { |
|
| return $name; |
return $name; |
| } |
} |
| |
|
| |
function _truncateQueryString($qstring) |
| |
{ |
| |
$ar_out = array(); |
| |
$ar = explode('&', $qstring); |
| |
|
| |
foreach ($ar as $part) { |
| |
$match = 0; |
| |
|
| |
foreach ($this->_truncate_qstrings_keys as $key) { |
| |
if (! strncasecmp($part, $key, strlen($key))) { |
| |
$match = 1; |
| |
break; |
| |
} |
| |
} |
| |
|
| |
if ($match == 0) |
| |
$ar_out[] = $part; |
| |
} |
| |
|
| |
return join('&', $ar_out); |
| |
} |
| |
|
| /* |
/* |
| * _setXxxValues() |
* _setXxxValues() |
| * |
* |
| Riadok 662 class Web_Log { |
|
| Riadok 738 class Web_Log { |
|
| } |
} |
| } |
} |
| |
|
| |
if ($this->_truncate_qstrings) { |
| |
$req_uri_ar = explode('?', $this->_props['request_uri']['value'], 2); |
| |
$http_ref_ar = explode('?', $this->_props['http_referer']['value'], 2); |
| |
|
| |
if (count($this->_truncate_qstrings_keys) == 0) { |
| |
$this->_props['query_string']['value'] = ''; |
| |
$req_uri_ar[1] = ''; |
| |
|
| |
$url_ar = parse_url($http_ref_ar[0]); |
| |
if (! strcasecmp($url_ar['host'], |
| |
$HTTP_SERVER_VARS['HTTP_HOST'])) |
| |
$http_ref_ar[1] = ''; |
| |
} |
| |
else { |
| |
$this->_props['query_string']['value'] = |
| |
$this->_truncateQueryString($this->_props['query_string']['value']); |
| |
|
| |
if (isset($req_uri_ar[1])) |
| |
if (($req_uri_ar[1] = $this->_truncateQueryString( |
| |
$req_uri_ar[1])) == '') |
| |
array_pop($req_uri_ar); |
| |
|
| |
if (isset($http_ref_ar[1])) |
| |
if (($http_ref_ar[1] = $this->_truncateQueryString( |
| |
$http_ref_ar[1])) == '') |
| |
array_pop($http_ref_ar); |
| |
} |
| |
|
| |
$this->_props['request_uri']['value'] = join('?', $req_uri_ar); |
| |
$this->_props['http_referer']['value'] = join('?', $http_ref_ar); |
| |
} |
| |
|
| return true; |
return true; |
| } |
} |
| |
|
| Riadok 880 class Web_Log { |
|
| Riadok 988 class Web_Log { |
|
| |
|
| function registerAccess($value = 0) |
function registerAccess($value = 0) |
| { |
{ |
| |
/* NOTES: containing variable parts |
| |
query_string, request_uri, http_referer |
| |
*/ |
| /* |
/* |
| * Setting values |
* Setting values |
| */ |
*/ |