version 1.203, 2002/02/25 14:33:58
|
version 1.204, 2002/03/29 18:23:50
|
Line 715 sub flushcourselogs {
|
Line 715 sub flushcourselogs {
|
&logthis('Flushing course log buffers'); |
&logthis('Flushing course log buffers'); |
foreach (keys %courselogs) { |
foreach (keys %courselogs) { |
my $crsid=$_; |
my $crsid=$_; |
|
&logthis(":$crsid:$coursehombuf{$crsid}"); |
if (&reply('log:'.$coursedombuf{$crsid}.':'. |
if (&reply('log:'.$coursedombuf{$crsid}.':'. |
&escape($courselogs{$crsid}), |
&escape($courselogs{$crsid}), |
$coursehombuf{$crsid}) eq 'ok') { |
$coursehombuf{$crsid}) eq 'ok') { |
Line 912 sub devalidate {
|
Line 913 sub devalidate {
|
} |
} |
} |
} |
|
|
|
sub arrayref2str { |
|
my ($arrayref) = @_; |
|
my $result='_ARRAY_REF__'; |
|
foreach my $elem (@$arrayref) { |
|
if (ref($elem) eq 'ARRAY') { |
|
$result.=&escape(&arrayref2str($elem)).'&'; |
|
} elsif (ref($elem) eq 'HASH') { |
|
$result.=&escape(&hashref2str($elem)).'&'; |
|
} elsif (ref($elem)) { |
|
&logthis("Got a ref of ".(ref($elem))." skipping."); |
|
} else { |
|
$result.=&escape($elem).'&'; |
|
} |
|
} |
|
$result=~s/\&$//; |
|
return $result; |
|
} |
|
|
sub hash2str { |
sub hash2str { |
my (%hash)=@_; |
my (%hash) = @_; |
my $result=''; |
my $result=&hashref2str(\%hash); |
foreach (keys %hash) { $result.=escape($_).'='.escape($hash{$_}).'&'; } |
$result=~s/^_HASH_REF__//; |
|
return $result; |
|
} |
|
|
|
sub hashref2str { |
|
my ($hashref)=@_; |
|
my $result='_HASH_REF__'; |
|
foreach (keys(%$hashref)) { |
|
if (ref($_) eq 'ARRAY') { |
|
$result.=&escape(&arrayref2str($_)).'='; |
|
} elsif (ref($_) eq 'HASH') { |
|
$result.=&escape(&hashref2str($_)).'='; |
|
} elsif (ref($_)) { |
|
&logthis("Got a ref of ".(ref($_))." skipping."); |
|
} else { |
|
$result.=&escape($_).'='; |
|
} |
|
|
|
if (ref($$hashref{$_}) eq 'ARRAY') { |
|
$result.=&escape(&arrayref2str($$hashref{$_})).'&'; |
|
} elsif (ref($$hashref{$_}) eq 'HASH') { |
|
$result.=&escape(&hashref2str($$hashref{$_})).'&'; |
|
} elsif (ref($$hashref{$_})) { |
|
&logthis("Got a ref of ".(ref($$hashref{$_}))." skipping."); |
|
} else { |
|
$result.=&escape($$hashref{$_}).'&'; |
|
} |
|
} |
$result=~s/\&$//; |
$result=~s/\&$//; |
return $result; |
return $result; |
} |
} |
Line 925 sub str2hash {
|
Line 971 sub str2hash {
|
my %returnhash; |
my %returnhash; |
foreach (split(/\&/,$string)) { |
foreach (split(/\&/,$string)) { |
my ($name,$value)=split(/\=/,$_); |
my ($name,$value)=split(/\=/,$_); |
$returnhash{&unescape($name)}=&unescape($value); |
$name=&unescape($name); |
|
$value=&unescape($value); |
|
if ($value =~ /^_HASH_REF__/) { |
|
$value =~ s/^_HASH_REF__//; |
|
my %hash=&str2hash($value); |
|
$value=\%hash; |
|
} elsif ($value =~ /^_ARRAY_REF__/) { |
|
$value =~ s/^_ARRAY_REF__//; |
|
my @array=&str2array($value); |
|
$value=\@array; |
|
} |
|
$returnhash{$name}=$value; |
} |
} |
return %returnhash; |
return (%returnhash); |
|
} |
|
|
|
sub str2array { |
|
my ($string) = @_; |
|
my @returnarray; |
|
foreach my $value (split(/\&/,$string)) { |
|
$value=&unescape($value); |
|
if ($value =~ /^_HASH_REF__/) { |
|
$value =~ s/^_HASH_REF__//; |
|
my %hash=&str2hash($value); |
|
$value=\%hash; |
|
} elsif ($value =~ /^_ARRAY_REF__/) { |
|
$value =~ s/^_ARRAY_REF__//; |
|
my @array=&str2array($value); |
|
$value=\@array; |
|
} |
|
push(@returnarray,$value); |
|
} |
|
return (@returnarray); |
} |
} |
|
|
# -------------------------------------------------------------------Temp Store |
# -------------------------------------------------------------------Temp Store |
Line 2635 sub unescape {
|
Line 2711 sub unescape {
|
# ================================================================ Main Program |
# ================================================================ Main Program |
|
|
sub goodbye { |
sub goodbye { |
|
&logthis("Starting Shut down"); |
&flushcourselogs(); |
&flushcourselogs(); |
&logthis("Shutting down"); |
&logthis("Shutting down"); |
} |
} |
Line 2897 devalidate($symb) : devalidate spreadshe
|
Line 2974 devalidate($symb) : devalidate spreadshe
|
=item * |
=item * |
|
|
hash2str(%hash) : convert a hash into a string complete with escaping and '=' |
hash2str(%hash) : convert a hash into a string complete with escaping and '=' |
and '&' separators |
and '&' separators, supports elements that are arrayrefs and hashrefs |
|
|
|
=item * |
|
|
|
hashref2str($hashref) : convert a hashref into a string complete with |
|
escaping and '=' and '&' separators, supports elements that are |
|
arrayrefs and hashrefs |
|
|
|
=item * |
|
|
|
arrayref2str($arrayref) : convert an arrayref into a string complete |
|
with escaping and '&' separators, supports elements that are arrayrefs |
|
and hashrefs |
|
|
|
=item * |
|
|
|
str2hash($string) : convert string to hash using unescaping and |
|
splitting on '=' and '&', supports elements that are arrayrefs and |
|
hashrefs |
|
|
=item * |
=item * |
|
|
str2hash($string) : convert string to hash using unescaping and splitting on |
str2array($string) : convert string to hash using unescaping and |
'=' and '&' |
splitting on '&', supports elements that are arrayrefs and hashrefs |
|
|
=item * |
=item * |
|
|