[LON-CAPA-cvs] cvs: loncom / lond
www
lon-capa-cvs@mail.lon-capa.org
Fri, 09 Aug 2002 10:05:00 -0000
www Fri Aug 9 06:05:00 2002 EDT
Modified files:
/loncom lond
Log:
Using "traditional" nohist_.db file for chatroom, not .txt.
Index: loncom/lond
diff -u loncom/lond:1.86 loncom/lond:1.87
--- loncom/lond:1.86 Thu Aug 8 09:45:21 2002
+++ loncom/lond Fri Aug 9 06:05:00 2002
@@ -2,7 +2,7 @@
# The LearningOnline Network
# lond "LON Daemon" Server (port "LOND" 5663)
#
-# $Id: lond,v 1.86 2002/08/08 13:45:21 www Exp $
+# $Id: lond,v 1.87 2002/08/09 10:05:00 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1570,18 +1570,27 @@
sub getchat {
my ($cdom,$cname)=@_;
- my @entries;
- if (open(CHATIN,&propath($cdom,$cname).'/chatroom.txt')) {
- while ($line=<CHATIN>) { push(@entries,$line); }
- close(CHATIN);
- return @entries;
+ my %hash;
+ my $proname=&propath($cdom,$cname);
+ my @entries=();
+ if
+ (tie(%hash,'GDBM_File',"$proname/nohist_chatroom.db",&GDBM_READER(),0640))
+ {
+ @entries=map { $_.':'.$hash{$_} } sort keys %hash;
+ untie %hash;
}
- return ();
+ return @entries;
}
sub chatadd {
- my ($cdom,$cname,$newchat)=@_;
- my @entries=&getchat($cdom,$cname);
+ my ($cdom,$cname,$newchat)=@_;
+ my %hash;
+ my $proname=&propath($cdom,$cname);
+ my @entries=();
+ if
+ (tie(%hash,'GDBM_File',"$proname/nohist_chatroom.db",&GDBM_WRCREAT(),0640))
+ {
+ @entries=map { $_.':'.$hash{$_} } sort keys %hash;
my $time=time;
my ($lastid)=($entries[$#entries]=~/^(\w+)\:/);
my ($thentime,$idnum)=split(/\_/,$lastid);
@@ -1592,16 +1601,16 @@
$idnum=substr('000000'.$idnum,-6,6);
$newid=$time.'_'.$idnum;
}
- push (@entries,$newid.':'.$newchat."\n");
+ $hash{$newid}=$newchat;
my $expired=$time-3600;
- open(CHATOUT,'>'.&propath($cdom,$cname).'/chatroom.txt');
- foreach (@entries) {
+ foreach (keys %hash) {
my ($thistime)=($_=~/(\d+)\_/);
- if ($thistime>$expired) {
- print CHATOUT $_;
+ if ($thistime<$expired) {
+ undef $hash{$_};
}
}
- close(CHATOUT);
+ untie %hash;
+ }
}
sub unsub {