#!/usr/bin/perl -w # yChat - Copyright by Paul C. Bütow use CGI; CGI->compile(':all'); $q = new CGI; print $q->header; require config; $alias = $q->param("alias"); $tmpid = $q->param("tmpid"); &secure_checkid($alias); $room = $q->param("room"); my $pid = $$; $| = 1; print < $title - Created & Copyright by Paul C. Bütow [PID: $pid]
END my $msgfile; if (-f "data/user/memos/$alias") { open(MEMOS,"; close MEMOS; print $memos; unlink("data/user/memos/$alias"); } my $startime,$change_room,@pids; $SIG{INT} = \&sendmsgs; OPENMSGFILE: $change_room = 0; $startime = time; if (-e "data/msgs/$room") { open(MSGFILE,">data/online/pids/$room"); print PID $pid."\n"; close PID; } else { sleep 1; goto OPENMSGFILE; } &sendmsgs; while (-e "data/online/users/$alias") { goto OPENMSGFILE if ($change_room == 1); sleep 15; print "\n"; } sub sendmsgs { for ($curpos = tell(MSGFILE); ; $curpos = tell(MSGFILE)) { my ($address, $stamp, $command, $action, $message) = split(/<;/, $_); if ($address eq "!" || $address eq $alias) { if ($stamp > $startime) { if ($command eq "cr") { &closepid; $room = $action; close MSGFILE; $change_room = 1; } print "$message
\n" if ($change_room != 1); } } } seek(MSGFILE, $curpos, 0); } sub closepid { @pids = undef; open(PID,"; close PID; my @newpids = undef; foreach(@pids) { push @newpids,$_ if ($pid ne $_."\n"); } open(PID,">data/online/pids/$room"); print PID @newpids; close PID; } &closepid;