| version 1.3, 2001/11/22 15:27:03 |
version 1.4, 2001/12/10 21:09:45 |
|
|
| #!/usr/bin/perl -w |
#!/usr/bin/perl -w |
| |
|
| # Author: Ondrej Jombik <nepto@pobox.sk> |
# |
| # Filename: sessions_split_config.pm |
# phpWebLogAnalyzer - powerful weblog and analyzer |
| |
# |
| |
# utils/sessions_split.pl - Perl script used for spliting |
| |
# accesses in database into sessions according to timeout |
| |
# __________________________________________________________ |
| |
# |
| |
# Developed by Ondrej Jombik <nepto@pobox.sk> |
| |
# Copyright (c) 2001 Platon software development group |
| |
# All rights reserved. |
| |
# |
| |
# See README file for more informations about this software. |
| |
# See COPYING file for license informations. |
| |
# |
| |
# Download the latest version from |
| |
# http://www.platon.sk/projects/phpWebLogAnalyzer/ |
| |
# |
| |
|
| use strict; |
use strict; |
| use DBI; |
use DBI; |
|
|
| # |
# |
| |
|
| $dbh = DBI->connect( |
$dbh = DBI->connect( |
| "dbi:" . $sessions_split_config::db{driver} |
"dbi:" . $sessions_split_config::db{driver} |
| . ":database=" . $sessions_split_config::db{name} |
. ":database=" . $sessions_split_config::db{name} |
| . ";host=" . $sessions_split_config::db{host} |
. ";host=" . $sessions_split_config::db{host} |
| . ";port=" . $sessions_split_config::db{port}, |
. ";port=" . $sessions_split_config::db{port}, |
| $sessions_split_config::db{username}, |
$sessions_split_config::db{username}, |
| $sessions_split_config::db{password} ) |
$sessions_split_config::db{password} ) |
| || die "can't connect to database: $DBI::errstr"; |
|| die "can't connect to database: $DBI::errstr"; |
|
|
| for ( $i = 0 ; $ids[$i] = $sth->fetchrow_hashref() ; $i++ ) { } |
for ( $i = 0 ; $ids[$i] = $sth->fetchrow_hashref() ; $i++ ) { } |
| |
|
| die $sth->errstr if $sth->err; |
die $sth->errstr if $sth->err; |
| pop(@ids); |
pop (@ids); |
| |
|
| # |
# |
| # Counting max_session_id. |
# Counting max_session_id. |
| Line 118 foreach (@ids) { |
|
| Line 133 foreach (@ids) { |
|
| for ( $i = 0 ; $data[$i] = $sth->fetchrow_hashref() ; $i++ ) { } |
for ( $i = 0 ; $data[$i] = $sth->fetchrow_hashref() ; $i++ ) { } |
| |
|
| die $sth->errstr if $sth->err; |
die $sth->errstr if $sth->err; |
| pop(@data); |
pop (@data); |
| |
|
| $total_records += scalar(@data); |
$total_records += scalar(@data); |
| print scalar(@data) . " records, "; |
print scalar(@data) . " records, "; |
| |
|
| # |
# |
| Line 147 foreach (@ids) { |
|
| Line 162 foreach (@ids) { |
|
| } |
} |
| |
|
| $max_session_id++ if ( scalar(@data) > 0 ); |
$max_session_id++ if ( scalar(@data) > 0 ); |
| $total_sessions += $max_session_id - $start_session_id; |
$total_sessions += $max_session_id - $start_session_id; |
| |
|
| print $max_session_id - $start_session_id . " sessions.\n"; |
print $max_session_id - $start_session_id . " sessions.\n"; |
| } |
} |
| Line 165 $dbh->disconnect(); |
|
| Line 180 $dbh->disconnect(); |
|
| print "-" x 60 . "\n"; |
print "-" x 60 . "\n"; |
| print "Total records = $total_records\n"; |
print "Total records = $total_records\n"; |
| print "Total sessions = $total_sessions\n"; |
print "Total sessions = $total_sessions\n"; |
| |
|