#!/usr/bin/perl use strict; use warnings; use File::Temp qw( tempfile ); use File::Copy; chdir('/tmp'); my($buffer, %FORM); if ($ENV{'REQUEST_METHOD'} eq "GET") { $buffer = $ENV{'QUERY_STRING'}; } my @pairs = split(/&/, $buffer); foreach my $pair (@pairs) { my ($name, $val) = split(/=/, $pair); $val =~ tr/+/ /; $val =~ s/%(..)/pack("C", hex($1))/eg; $val =~ s/([#%_\$^&{}\\])//g; $FORM{$name} = $val; } my ($fh, $filename) = tempfile(UNLINK => 1); copy("%%DEST%%/format.tex",$fh); print $fh "\n"; if (index($ENV{'PATH_INFO'},'award') != -1){ say $fh "\\award{$FORM{'country'}}{$FORM{'award'}}{$FORM{'committee'}}{$FORM{'school'}}"; } elsif (index($ENV{'PATH_INFO'},'room') != -1){ say $fh "\\room{$FORM{'committee'}}"; } else{ print "Content-type: text/html\n"; print "Status: 404 File Not Found Error\n\n"; print '404 Error. Go back.'; die; } say $fh "\\bye"; `/usr/bin/pdftex "$filename"`; unlink "$filename.log"; open(DOC, '<', "$filename.pdf") or do { print "Content-type: text/html\n"; print "Status: 400 Bad Request Error\n\n"; print '