version 1.86, 2002/08/08 13:45:21
|
version 1.87, 2002/08/09 10:05:00
|
Line 1570 sub addline {
|
Line 1570 sub addline {
|
|
|
sub getchat { |
sub getchat { |
my ($cdom,$cname)=@_; |
my ($cdom,$cname)=@_; |
my @entries; |
my %hash; |
if (open(CHATIN,&propath($cdom,$cname).'/chatroom.txt')) { |
my $proname=&propath($cdom,$cname); |
while ($line=<CHATIN>) { push(@entries,$line); } |
my @entries=(); |
close(CHATIN); |
if |
return @entries; |
(tie(%hash,'GDBM_File',"$proname/nohist_chatroom.db",&GDBM_READER(),0640)) |
|
{ |
|
@entries=map { $_.':'.$hash{$_} } sort keys %hash; |
|
untie %hash; |
} |
} |
return (); |
return @entries; |
} |
} |
|
|
sub chatadd { |
sub chatadd { |
my ($cdom,$cname,$newchat)=@_; |
my ($cdom,$cname,$newchat)=@_; |
my @entries=&getchat($cdom,$cname); |
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 $time=time; |
my ($lastid)=($entries[$#entries]=~/^(\w+)\:/); |
my ($lastid)=($entries[$#entries]=~/^(\w+)\:/); |
my ($thentime,$idnum)=split(/\_/,$lastid); |
my ($thentime,$idnum)=split(/\_/,$lastid); |
Line 1592 sub chatadd {
|
Line 1601 sub chatadd {
|
$idnum=substr('000000'.$idnum,-6,6); |
$idnum=substr('000000'.$idnum,-6,6); |
$newid=$time.'_'.$idnum; |
$newid=$time.'_'.$idnum; |
} |
} |
push (@entries,$newid.':'.$newchat."\n"); |
$hash{$newid}=$newchat; |
my $expired=$time-3600; |
my $expired=$time-3600; |
open(CHATOUT,'>'.&propath($cdom,$cname).'/chatroom.txt'); |
foreach (keys %hash) { |
foreach (@entries) { |
|
my ($thistime)=($_=~/(\d+)\_/); |
my ($thistime)=($_=~/(\d+)\_/); |
if ($thistime>$expired) { |
if ($thistime<$expired) { |
print CHATOUT $_; |
undef $hash{$_}; |
} |
} |
} |
} |
close(CHATOUT); |
untie %hash; |
|
} |
} |
} |
|
|
sub unsub { |
sub unsub { |