From 630af0ed6c0af69c7df2e45aef7a87722a3c00c0 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 6 Apr 2013 13:14:47 +0200 Subject: tagging ychat-perl-legacy --- 0.4.8a2/push.pl | 117 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 0.4.8a2/push.pl (limited to '0.4.8a2/push.pl') diff --git a/0.4.8a2/push.pl b/0.4.8a2/push.pl new file mode 100644 index 0000000..da19357 --- /dev/null +++ b/0.4.8a2/push.pl @@ -0,0 +1,117 @@ +#!/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: ($error_msg)" ), + $q->end_html; + open(ERROR,">>data/error"); + print ERROR "$alias $tmpid $$ ".time." $error_msg \n"; + close ERROR; + exit 0; + } +} + +$room = $q->param("room"); +my $pid = $$; +$| = 1; + +print < + + + + +Willkommen im yChat [PID: $pid]
+END + +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 (-e "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"); \ No newline at end of file -- cgit v1.2.3