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.7a2/push.pl | 112 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 0.4.7a2/push.pl (limited to '0.4.7a2/push.pl') diff --git a/0.4.7a2/push.pl b/0.4.7a2/push.pl new file mode 100644 index 0000000..f8b8a78 --- /dev/null +++ b/0.4.7a2/push.pl @@ -0,0 +1,112 @@ +#!/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; \ No newline at end of file -- cgit v1.2.3