#!/usr/bin/perl # Local configuration values # basepath - absolute path to the server's document root, ENDING WITH A SLASH. # Advertize content type to server $docroot="../"; # urlpath - relative path from the document root to the base directory # in the chat directory tree, ENDING WITH A SLASH. $urlpath="chat/"; # chexp - number of seconds of inactivity after which a channel is closed. # If you want a permanent channel, simply enter the channel name, followed # by a tab and then a 0, into the file [basedir]/data/.chlist. $chexp=300; # End of local configuration $LOCK_EX=2; $LOCK_UN=8; sub lock { flock(OUTFILE,$LOCK_EX); seek(OUTFILE,0,2); } sub unlock { flock(OUTFILE,$LOCK_UN); } $|=1; $basepath=$docroot . $urlpath; $includepath=$basepath . "include/"; $datapath=$basepath . "data/"; $lockpath=$basepath . "lock/"; print "Content-type: text/html\n\n"; read(STDIN,$buffer,$ENV{'CONTENT_LENGTH'}); if ($buffer eq "") { $buffer = $ENV{'QUERY_STRING'}; } # Parse form input into a list NAME1=VALUE1,... @elements=split(/&/,$buffer); # Now transform this into an array so that PARRAY(NAME1)=VALUE1,... foreach $element (@elements) { ($name,$value)=split(/=/,$element); $value=~tr/+/ /; $value=~s/%([a-fA-F0-9][a-fA-F0-9])/pack('C',hex($1))/eg; $value=~tr/\t\r\n\<\>/ /; if (($name eq 'CHNAME')||($name eq 'NEWCHNAME')) { $value=~tr/A-Za-z0-9_\- //cd; } $PARRAY{$name}=$value; } $nickname=$PARRAY{'NICKNAME'}; $leavingch=$PARRAY{'LEAVINGCH'}; if (($nickname ne "")&&($leavingch ne "")) { ($sec,$min,$hr)=(localtime())[0..2]; open(lockfile, ">${lockpath}${leavingch}"); flock(lockfile,2); seek(lockfile,0,2); open(OUTFILE,"<${datapath}${leavingch}"); @tempmain=; unshift(@tempmain, "(${hr}:${min}:${sec})User ${nickname} has left the room ${leavingch}.\n"); close(OUTFILE); open(OUTFILE,">${datapath}${leavingch}"); do lock(); print OUTFILE @tempmain; do unlock(); close(OUTFILE); print lockfile "1\n"; flock(lockfile,8); close(lockfile); } open(S, "<${includepath}chlisthdr"); @mi=; close(S); $header=join("\n",@mi); $header=~ s/;;NAME;;/$nickname/; print $header; $chlist=`cat ${includepath}chatrooms.txt`; $time=time(); @channels=split(/\n/,$chlist); print<${channel}
\n" } print "\n"; open(S, "<${includepath}chlistftr"); @main=; close(S); print "@main"; exit;