aboutsummaryrefslogtreecommitdiff
path: root/minimun.orig
diff options
context:
space:
mode:
authorHolden Rohrer <hr@hrhr.dev>2020-06-01 17:29:59 -0400
committerHolden Rohrer <hr@hrhr.dev>2020-06-01 17:29:59 -0400
commit564ba31acf6fa4df0c3d3c528ee0011e5631fdbc (patch)
treeb69600cc4d8552048633fa715ecd272be249421e /minimun.orig
parent992477af8ca6f91b2812b454c135bd87bfefbc2c (diff)
generalized destdir
Diffstat (limited to 'minimun.orig')
-rwxr-xr-xminimun.orig51
1 files changed, 51 insertions, 0 deletions
diff --git a/minimun.orig b/minimun.orig
new file mode 100755
index 0000000..bf07a25
--- /dev/null
+++ b/minimun.orig
@@ -0,0 +1,51 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+
+use IPC::Run qw(run);
+use Time::HiRes qw( time );
+
+chdir('%%DEST%%');
+
+my ($buffer, @pairs, $pair, $name, $val, %FORM);
+
+if ($ENV{'REQUEST_METHOD'} eq "GET") {
+ $buffer = $ENV{'QUERY_STRING'};
+}
+@pairs = split(/&/, $buffer);
+
+foreach $pair (@pairs) {
+ ($name, $val) = split(/=/, $pair);
+ $val =~ tr/+/ /;
+ $val =~ s/%(..)/pack("C", hex($1))/eg;
+ $FORM{$name} = $val;
+}
+
+my ($in, $out);
+$in = "\n";
+
+if (index($ENV{'PATH_INFO'},'award.pdf') != -1){
+ $in .= "\\award{$FORM{'committee'}}{$FORM{'country'}}{$FORM{'award'}}{$FORM{'school'}}";
+}
+elsif (index($ENV{'PATH_INFO'},'room.pdf') != -1){
+ $in .= "\\room{$FORM{'committee'}}";
+}
+else{
+ print "Content-type: text/html\n";
+ print "Status: 404 File Not Found Error\n";
+ print "\n";
+ print '<a href="/">404 Error. Go back.</a>';
+ die;
+}
+
+$in .= "\\bye\n";
+
+my $timestamp = time;
+run ['/usr/bin/pdftex', '-jobname', "$timestamp", 'format.tex'], '<', \$in, '>', \$out;
+print "Content-type: application/pdf\n\n";
+open(DOC, '<', "$timestamp.pdf");
+while (<DOC>){
+ print;
+}
+close(DOC);
+unlink "$timestamp.pdf", "$timestamp.log";