version 1.19, 2005/09/20 17:49:51
|
version 1.25, 2014/11/24 02:36:34
|
Line 48
|
Line 48
|
# parameter is not set $logthis is set to ¬hing, which does what you |
# parameter is not set $logthis is set to ¬hing, which does what you |
# would expect. |
# would expect. |
# |
# |
|
|
use strict; |
use strict; |
use DBI; |
use DBI; |
use lib '/home/httpd/lib/perl/Apache'; |
|
use lib '/home/httpd/lib/perl/'; |
use lib '/home/httpd/lib/perl/'; |
use LONCAPA::Configuration(); |
use LONCAPA::Configuration(); |
use Apache::lonmysql(); |
use Apache::lonmysql(); |
use lonmysql(); |
|
use Time::HiRes(); |
use Time::HiRes(); |
use Getopt::Long(); |
use Getopt::Long(); |
use IO::File; |
use IO::File; |
Line 184 if (! defined($xmlfile)) {
|
Line 181 if (! defined($xmlfile)) {
|
if (!flock(LOCKFILE,LOCK_EX|LOCK_NB)) { |
if (!flock(LOCKFILE,LOCK_EX|LOCK_NB)) { |
warn("Unable to lock $lockfilename. Aborting".$/); |
warn("Unable to lock $lockfilename. Aborting".$/); |
# don't call clean_up_and_exit another instance is running and |
# don't call clean_up_and_exit another instance is running and |
# we don't want to 'cleanup' there files |
# we don't want to 'cleanup' their files |
exit 6; |
exit 6; |
} |
} |
|
|
Line 308 if (!&Apache::lonmysql::verify_sql_conne
|
Line 305 if (!&Apache::lonmysql::verify_sql_conne
|
} |
} |
$logthis->('SQL connection is up'); |
$logthis->('SQL connection is up'); |
|
|
|
&update_process_name($course.'@'.$domain." loading existing data"); |
my $missing_table = &check_for_missing_tables(values(%tables)); |
my $missing_table = &check_for_missing_tables(values(%tables)); |
if (-s $gz_sql_filename && ! -s $gz_xml_filename) { |
if (-s $gz_sql_filename && ! -s $gz_xml_filename) { |
my $backup_modification_time = (stat($gz_sql_filename))[9]; |
my $backup_modification_time = (stat($gz_sql_filename))[9]; |
Line 377 my $error_fh = IO::File->new(">>$error_f
|
Line 375 my $error_fh = IO::File->new(">>$error_f
|
## |
## |
## Parse the course log |
## Parse the course log |
$logthis->('processing course log'); |
$logthis->('processing course log'); |
|
&update_process_name($course.'@'.$domain." processing new data"); |
if (-s $newfilename) { |
if (-s $newfilename) { |
my $result = &process_courselog($newfilename,$error_fh,\%tables); |
my $result = &process_courselog($newfilename,$error_fh,\%tables); |
|
&update_process_name($course.'@'.$domain." backing up new data"); |
if (! defined($result)) { |
if (! defined($result)) { |
# Something went wrong along the way... |
# Something went wrong along the way... |
$logthis->('process_courselog returned undef'); |
$logthis->('process_courselog returned undef'); |
Line 481 sub process_courselog {
|
Line 481 sub process_courselog {
|
# %3aPOST%3a(name)%3d(value)%3a(name)%3d(value) |
# %3aPOST%3a(name)%3d(value)%3a(name)%3d(value) |
# or |
# or |
# %3aCSTORE%3a(name)%3d(value)%26(name)%3d(value) |
# %3aCSTORE%3a(name)%3d(value)%26(name)%3d(value) |
|
# or |
|
# %3aPUTSTORE%3a(name)%3d(value)%26(name)%3d(value) |
# |
# |
# get delimiter between timestamped entries to be &&& |
# get delimiter between timestamped entries to be &&& |
$log=~s/\%26(\d{9,10})\%3a/\&\&\&$1\%3a/g; |
$log=~s/\%26(\d{9,10})\%3a/\&\&\&$1\%3a/g; |
Line 492 sub process_courselog {
|
Line 494 sub process_courselog {
|
if (length($chunk) > 20000) { |
if (length($chunk) > 20000) { |
# avoid putting too much data into the database |
# avoid putting too much data into the database |
# (usually an uploaded file or something similar) |
# (usually an uploaded file or something similar) |
$chunk = &escape($chunk); |
if (! &savechunk(\$chunk,$timestamp,$host)) { |
if (! open(CHUNKFILE,">>$chunk_filename") || |
|
! print CHUNKFILE $timestamp.':'.$host.':'.$chunk.$/) { |
|
# abort |
|
close(CHUNKFILE); |
|
close(IN); |
close(IN); |
return undef; |
return undef; |
} |
} |
close(CHUNKFILE); |
|
next; |
next; |
} |
} |
my $warningflag = ''; |
my $warningflag = ''; |
Line 516 sub process_courselog {
|
Line 513 sub process_courselog {
|
if (! defined($action) || $action eq '') { |
if (! defined($action) || $action eq '') { |
$action = 'VIEW'; |
$action = 'VIEW'; |
} |
} |
if ($action !~ /^(LOGIN|VIEW|POST|CSTORE|STORE)$/) { |
if ($action !~ /^(LOGIN|VIEW|POST|CSTORE|STORE|PUTSTORE)$/) { |
$warningflag .= 'action'; |
$warningflag .= 'action'; |
print $error_fh 'full log entry:'.$log.$/; |
print $error_fh 'full log entry:'.$log.$/; |
print $error_fh 'error on chunk:'.$chunk.$/; |
print $error_fh 'error on chunk (saving)'.$/; |
$logthis->('(action) Unable to parse '.$/.$chunk.$/. |
if (! &savechunk(\$chunk,$timestamp,$host)) { |
|
close(IN); |
|
return undef; |
|
} |
|
$logthis->('(action) Unable to parse chunk'.$/. |
'got '. |
'got '. |
'time = '.$time.$/. |
'time = '.$time.$/. |
'res = '.$res.$/. |
'res = '.$res.$/. |
Line 557 sub process_courselog {
|
Line 558 sub process_courselog {
|
} |
} |
close IN; |
close IN; |
return $linecount; |
return $linecount; |
|
## |
|
## |
|
sub savechunk { |
|
my ($chunkref,$timestamp,$host) = @_; |
|
my $chunk = &escape(${$chunkref}); |
|
if (! open(CHUNKFILE,">>$chunk_filename") || |
|
! print CHUNKFILE $timestamp.':'.$host.':'.$chunk.$/) { |
|
# abort |
|
close(CHUNKFILE); |
|
return 0; |
|
} |
|
close(CHUNKFILE); |
|
return 1; |
|
} |
} |
} |
|
|
|
|
Line 930 sub xml_store_id_table {
|
Line 945 sub xml_store_id_table {
|
####################################################################### |
####################################################################### |
{ |
{ |
my @rows; |
my @rows; |
my $max_row_count = 100; |
|
|
|
sub store_entry { |
sub store_entry { |
|
my $max_row_count = 100; |
if (! @_) { |
if (! @_) { |
undef(@rows); |
undef(@rows); |
return ''; |
return ''; |