#!/usr/bin/perl $dir = "csehelp"; $template_path = "/net/cs/htdocs/groups/ebu3b/cgi-bin"; $comments_file_path = "/net/cs/htdocs/groups/ebu3b/$dir"; $url = "http://www-cse.ucsd.edu/groups/ebu3b/$dir/comm.html"; $topic = $vars{NAME}; $line = $ENV{QUERY_STRING}; if ($ENV{REQUEST_METHOD} ne "GET") { $line = ; } $line =~ s/\+/ /g; while ($line =~ /\%([A-F0-9]{2})/) { $hex = $1; $ch = chr(hex($hex)); $line =~ s/\%$hex/$ch/g; } $line =~ s/\n/
/g; $line =~ tr/\a\b\n\r/ /; @pairs = split(/&/, $line); foreach $var_val (@pairs) { if ($var_val =~ /([A-Z]+)=(.+)/) { $vars{$1} = $2; } } print "Content-type: text/html\n\n"; if ($vars{FUNC} eq "VIEW") { if (-f "$comments_file_path/comm.html") { print "\n"; print "\n"; print "\n"; } else { print "\n"; print " No Comments \n"; print "\n"; print " Sorry, No Comments have been made for $vars{NAME}\n"; print "

Back\n"; print "\n"; } } elsif ($vars{FUNC} eq "MAKE") { open (FD, "$template_path/form_csehelp.tmpl") || die "$!"; foreach $current_line () { $current_line =~ s/\%NAME%/$vars{NAME}/g; print "$current_line"; } close(FD); } elsif ($vars{FUNC} eq "SUBMIT") { chomp($time = `date`); if (-f "$comments_file_path/comm.html") { #print "1Hello\n"; open(FD, "$comments_file_path/comm.html") || die; @text = ; close(FD); } else { open(FD, "$template_path/apphtml.tmpl") || die; @text = ; close(FD); $refer = "Back to EBU3b Project Home Page\n"; $end = "\n"; foreach $line (@text) { $line =~ s/%NAME%/$vars{NAME}/g; if ($line =~ /END/){$line ="$refer$end";} } } open(FD, ">$comments_file_path/comm.html") || die; #print "1Hello\n"; #print "Hello\n"; foreach $line (@text) { #print "hallo\n"; print FD "$line"; if ($line =~ /META DATA_BEGIN/) { $vars{COMMENTS} =~ tr/[\n\r]//; print FD "

\n"; print FD "\n"; print FD "$Comment by: $vars{USER} on $time\n"; #make this more readable in html file #perhaps newline every 80 chars print FD "

$vars{COMMENTS}
\n"; } } close(FD); unlink("/tmp\/$dir.tmp"); print "\n"; print "\n"; print "\n"; }