#!/usr/bin/perl -w # yChat - Copyright by Paul C. Bütow use CGI; #CGI->compile(':all'); $q = new CGI; print $q->header; $alias = $q->param("alias"); $tmpid = $q->param("tmpid"); { open(IDENT,"; close IDENT; if ($ident[1] ne $tmpid) { print $q->div( "Error: (Falsche TmpID in push.pl!)" ), $q->end_html; open(ERROR,">>data/error"); print ERROR "$alias $tmpid $$ ".time." (Falsche TmpID in push.pl!) \n"; close ERROR; exit 0; } } $room = $q->param("room"); my $pid = $$; $| = 1; print < loading chat-engine @ PID: $pid...
END sleep 1; print "loading in progress ...
"; sleep 1; print "$alias, welcome to yChat! :-)
"; if (-f "data/user/memos/$alias") { open(MEMOS,"; close MEMOS; print $memos; unlink("data/user/memos/$alias"); } my $startime,$change_room,@flood; OPENMSGFILE: $change_room = 0; $startime = time; if (-e "data/msgs/$room") { open(MSGFILE,"data/online/pids/$room/$pid"); print PID time; close PID; } else { sleep 1; goto OPENMSGFILE; } &sendmsgs; while (-f "data/online/users/$alias") { local $SIG{USR1} = \&sendmsgs; 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") { unlink("data/online/pids/$room/$pid"); $room = $action; close MSGFILE; $change_room = 1; } print "$message
\n" if ($change_room != 1); push(@flood,$message); if ($flood[0] eq $flood[1] && $flood[0] eq $flood[2] && $flood[0] eq $flood[3]) { print " Jemand floodet den Chat !
\n"; } shift(@flood) if ($#flood > 2); } } } seek(MSGFILE, $curpos, 0); } unlink("data/online/pids/$room/$pid");