| verzia 1.35, 2002/05/10 00:56:25 |
verzia 1.36, 2002/07/25 17:28:10 |
|
|
| * methods added |
* methods added |
| * - with usage of methods above convert() method for conversion |
* - with usage of methods above convert() method for conversion |
| * from raw log into normal implemented |
* from raw log into normal implemented |
| |
* 25/07/2002 - getAccessesCount() implemeneted on basis of method |
| |
* getSesssionsCount(); redunand code was moved to _getCounts() |
| */ |
*/ |
| |
|
| define('WEB_LOG_VALUE_SUBSTR_LENGTH', 255); |
define('WEB_LOG_VALUE_SUBSTR_LENGTH', 255); |
| Riadok 69 define('WEB_LOG_RAW_LOG_DEFAULT', |
|
| Riadok 71 define('WEB_LOG_RAW_LOG_DEFAULT', |
|
| define('WEB_LOG_TRUNCATE_NAMES_DEFAULT', 0); |
define('WEB_LOG_TRUNCATE_NAMES_DEFAULT', 0); |
| define('WEB_LOG_TRUNCATE_QUERY_STRINGS_DEFAULT', 1); |
define('WEB_LOG_TRUNCATE_QUERY_STRINGS_DEFAULT', 1); |
| |
|
| |
/* Internally used for _getCount() */ |
| |
define('WEB_LOG_SESSIONS_COUNT_TYPE', 1); |
| |
define('WEB_LOG_ACCESSES_COUNT_TYPE', 2); |
| |
|
| /* |
/* |
| * Ident library |
* Ident library |
| */ |
*/ |
| Riadok 1314 class Web_Log { |
|
| Riadok 1320 class Web_Log { |
|
| |
|
| /* |
/* |
| * getSessionsCount() |
* getSessionsCount() |
| |
* getAccessesCount() |
| * |
* |
| * Returns total count of all sessions in database. |
* Returns counts of sessions/accesses in database |
| |
* for defined conditions in $array. |
| */ |
*/ |
| |
|
| function getSessionsCount($array = '') |
function getSessionsCount($array = '') |
| { |
{ |
| |
return $this->_getCount($array, WEB_LOG_SESSIONS_COUNT_TYPE); |
| |
} |
| |
|
| |
function getAccessesCount($array = '') |
| |
{ |
| |
return $this->_getCount($array, WEB_LOG_ACCESSES_COUNT_TYPE); |
| |
} |
| |
|
| |
function _getCount($array = '', $type) |
| |
{ |
| if ($this->_checkDB() == false) |
if ($this->_checkDB() == false) |
| return $this->_db; |
return $this->_db; |
| |
|
| Riadok 1328 class Web_Log { |
|
| Riadok 1346 class Web_Log { |
|
| : 'weblog_accesses'; |
: 'weblog_accesses'; |
| |
|
| $list_tables = ''; |
$list_tables = ''; |
| $list_where = ''; |
$list_where = ''; |
| |
|
| if (is_array($array)) { |
if (is_array($array)) { |
| |
|
| Riadok 1337 class Web_Log { |
|
| Riadok 1355 class Web_Log { |
|
| if (! $this->_raw_log && 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 .= "$accesses_table." |
$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.'"'; |
| |
|
| $list_tables .= ($list_tables == '' ? '' : ', '); |
$list_tables .= ($list_tables == '' ? '' : ', '); |
| $list_tables .= $this->_props[$key]['table']; |
$list_tables .= $this->_props[$key]['table']; |
| Riadok 1351 class Web_Log { |
|
| Riadok 1369 class Web_Log { |
|
| } |
} |
| } |
} |
| |
|
| $query = 'SELECT COUNT(DISTINCT session_id) AS sessions_count' |
switch ($type) { |
| .' FROM ' . $accesses_table; |
case WEB_LOG_SESSIONS_COUNT_TYPE: |
| |
$select_field = "COUNT(DISTINCT $accesses_table.session_id)"; |
| |
break; |
| |
case WEB_LOG_ACCESSES_COUNT_TYPE: |
| |
$select_field = "COUNT($accesses_table.id)"; |
| |
break; |
| |
default: |
| |
return false; // error |
| |
} |
| |
|
| |
$query = "SELECT $select_field FROM $accesses_table"; |
| |
|
| if (strlen($list_tables) > 0) |
if (strlen($list_tables) > 0) |
| $query .= ", $list_tables"; |
$query .= ", $list_tables"; |
| Riadok 1360 class Web_Log { |
|
| Riadok 1388 class Web_Log { |
|
| if (strlen($list_where) > 0) |
if (strlen($list_where) > 0) |
| $query .= " WHERE $list_where"; |
$query .= " WHERE $list_where"; |
| |
|
| |
echo $query . '<hr>'; |
| if (DB::isError($count = $this->_db->getOne($query))) |
if (DB::isError($count = $this->_db->getOne($query))) |
| return $count; |
return $count; |
| |
|