diff options
| author | Paul Buetow <paul@buetow.org> | 2013-04-06 13:14:47 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2013-04-06 13:14:47 +0200 |
| commit | 630af0ed6c0af69c7df2e45aef7a87722a3c00c0 (patch) | |
| tree | ad76f850278b090f7e5c26561035d19c320400cc /0.6.2/push.pl | |
| parent | 2860b03f00e48264ed15c132ad90b240ebe6070b (diff) | |
tagging ychat-perl-legacyychat-perl-legacy
Diffstat (limited to '0.6.2/push.pl')
| -rw-r--r-- | 0.6.2/push.pl | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/0.6.2/push.pl b/0.6.2/push.pl new file mode 100644 index 0000000..cc5a2aa --- /dev/null +++ b/0.6.2/push.pl @@ -0,0 +1,116 @@ +#!/usr/bin/perl + +# yChat - Copyright by Paul C. Bütow + +use CGI; +$q = new CGI; +print $q->header; + +$alias = $q->param("alias"); +$tmpid = $q->param("tmpid"); + +{ + unless (-f "data/online/tmpid/$alias.$tmpid") { + require config; + &error("Falsche TempID !"); + } +} + +$room = $q->param("room"); + +my $pid = $$; +$| = 1; + +print <<END; +<html> + <head> +<script language="JavaScript"> +<!-- +// Scroll-Routine von Anklepper (http://www.anklepper.de) +// speziell für yChat (http://www.yChat.de), Copyright 2000 +scrolling = true; +moves_steps = 4; +moves_interval = 4; +function moves() +{ + if( scrolling != false ) + window.scrollBy( 0, moves_steps ); + window.setTimeout( "moves()", moves_interval ); +} +moves(); +//--> +</script> +</head> +<body bgcolor=000000 link=FFFFFF alink=FFFFEF vlink=FFFFEF> +<font size=1 color=ffffff face=arial>loading chat-engine ...</font><br> +END +sleep 1; +print "<font size=1 color=ffffff face=arial>loading in progress ...</font><br>"; +sleep 1; +print "<font size=1 color=ffffff face=arial><b>$alias</b>, welcome to <b>yChat</b>! :-)</font><br>"; + + +if (-f "data/user/memos/$alias") { + open(MEMOS,"<data/user/memos/$alias"); + my @memos = <MEMOS>; + close MEMOS; + my $memos; + foreach (@memos) { + $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/msgs/$room"); + unless (-d "data/online/pids") { + mkdir "data/online/pids", 0777; + } unless (-d "data/online/pids/$room") { + mkdir "data/online/pids/$room", 0777; + } + open(PID,">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); <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<br>\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 "<i><font color=red> Jemand floodet den Chat !</font></i><br>\n"; + } + shift(@flood) if ($#flood > 2); + } + } + } + seek(MSGFILE, $curpos, 0); +} + +unlink("data/online/pids/$room/$pid");
\ No newline at end of file |
