--- /dev/null
+#!/usr/bin/perl
+use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
+
+print "Content-type: text/html\n\n";
+
+
+
+print <<HDOC;
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <title>Xmatter File Uploader</title>
+ <link rel="stylesheet" type="text/css" href="style.css">
+ <meta charset="UTF-8"/>
+<style>
+label {
+ width:150px;
+ text-align:right;
+ display:inline-block;
+ margin-right:20px;
+ margin-bottom:10px;
+}
+</style>
+</head>
+<body class="title">
+<h1>Xmatter Form Uploader</h1>
+<p></p>
+
+<form action="uploadFiles.pl" method="post" enctype="multipart/form-data">
+<label for="doctype">Type of document</label><select name="doctype"><option>Travel Request<option>Travel Reimbursement<option>Other<option>TEST</select><br>
+ <label for="lastname">Last name</label><input type="text" name="lastname" required><br>
+ <label for="firstname">First name</label><input type="text" name="firstname" required><br>
+ <label for="date">First day of travel</label><input type="date" name="date"><br>
+ <label for="occassion">Travel Reason</label><input list="occassion-list" type="text" name="occassion" maxlength="20"><br>
+ <label for="destination">Travel Destination</label><input type="text" required name="destination" maxlength="20"><br>
+ <label for="mainfile">Request Form</label><input type="file" name="mainfile" required><br>
+ <label for="attachments">Attachments</label><input type="file" name="attachments[]" id="attachments" accept=".pdf,.png,.jpg,.jpeg,.JPG,.PDF,.PNG,.JPEG" multiple><a href="#" onclick="document.getElementById('attachments').value = []">Remove Attachments</a><br><br>
+ <label for="upload"> </label><input type="submit" value="Upload" name="upload">
+</form>
+<datalist id="occassion-list">
+<option>Hades_Collab_Meeting
+<option>CBM_Collab_Meeting
+<option>DPG
+</datalist>
+<h2>Usage</h2>
+<ul>
+<li>The generated document will be downloaded - if you see it, everything went well and the document is sent.
+<li>Allowed file types: PDF, JPG and PNG.
+<li>You have to select all attachments at once. They have to be located in the same directory.
+<li>To select several attachments: keep CTRL pressed and selected them in the order you want to have them merged.
+<li>Please keep all fields short and concise. Use no special characters.
+<li><b>In case of problems, please save the error message, the generated file and the time when it happened.</b>
+</ul>
+
+
+<h2>Links</h2>
+<ul>
+<li><a href="https://www.uni-frankfurt.de/70926891/antrag-auf-genehmigung-reisekosten20_02_18_inland.pdf">Travel Request Germany</a>
+<li><a href="https://www.uni-frankfurt.de/178340204.pdf">Travel Request other countries</a>
+<li><a href="https://www.uni-frankfurt.de/48628954/reisekostenrechnung-pdf-mit-anlage.pdf">Travel Reimbursement Request</a>
+<li><a href="https://www.uni-frankfurt.de/45559573/Generic_45559573.docx">Generic Reimbursement Request</a>
+
+
+</body>
+</html>
+HDOC
--- /dev/null
+html {
+ height:100%;
+ margin:0;
+ padding:0;
+ font-size:9pt;
+}
+
+
+* {
+ box-sizing:border-box;
+}
+
+
+body {
+ background: #000;
+ color:#888;
+ font-family: sans-serif;
+ height: 100%;
+ overflow:hidden;
+ margin:0;
+ padding-left:20px;
+ }
+
+body.title {
+ background:#F6F9FC;
+ padding:0;
+ margin-left: 20px;
+}
+
+h1 {
+ color: #889;
+ width:100%;
+ padding-left:20px;
+ border-bottom:1px solid #aaa;
+ }
+
+#control {
+ height:100%;
+ width:220px;
+ left:-200px;
+ position:absolute;
+ top:0;
+ padding-left:10px;
+ border-right:70px solid #000;
+ background:#9AA2AA;
+ color:#000;
+ transition:left 0.6s 3s ease-out, border 0.6s 3s ease-out;
+ overflow-y:scroll !important;
+ overflow-x:hidden;
+ }
+
+#control:hover {
+ left:0;
+ border:0;
+ transition:left 0.2s 0s ease-in, border 0.2s 0s ease-in;
+ }
+
+#content {
+ height:100%;
+ width:100%;
+ position:absolute;
+ text-align:center;
+ /*padding-right:100px;*/
+ overflow:scroll !important;
+ text-align:center;
+ }
+
+#content div {
+ display:inline-block;
+ }
+
+#content img {
+ height:100%;
+ width:100%;
+ max-height:100%;
+ max-width:100%;
+ object-fit:contain;
+ margin:auto;
+ padding:0;
+ }
+
+#content.zoomed {
+ text-align:left;
+ }
+
+#content.zoomed img {
+ height:150%;
+ max-height:150%;
+ width:150%;
+ max-width:150%;
+ }
+
+#roomlist {
+ width:200px;
+}
+
+#filelist {
+ width:180px;
+}
+
+@keyframes pointerani {
+ 0% {opacity:.2;}
+ 100% {opacity:.7;}
+}
+
+
+#pointer {
+ width:20px;
+ height:20px;
+ background:transparent;
+ border:7px solid red;
+ opacity:0.7;
+ border-radius:15px;
+ position:absolute;
+ }
+
+
+#files div {
+ padding-top:2px;
+ border-bottom:1px solid #aaa;
+ clear:both;
+
+}
+
+#files img {
+ margin:auto;
+ max-height:100px;
+ max-width:150px;
+ object-fit:contain;
+ position:relative;
+}
+
+#files button {
+ font-size:80%;
+ width:35px;
+ display:block;
+ float:right;
+ margin-right:5px;
+ padding:0px;
+ }
+
+
--- /dev/null
+#!/usr/bin/perl
+use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
+#use CGI;
+use warnings;
+use Data::Dumper;
+use File::Temp qw/ tempfile tempdir /;
+use utf8;
+use CGI qw(-utf8);
+
+my $cgi = new CGI();
+
+
+
+my @files = $cgi->param('attachments[]');
+my @io_handles=$cgi->upload('attachments[]');
+
+my $mainfile = $cgi->param('mainfile');
+my $main_handle = $cgi->upload('mainfile');
+
+
+my $dir = "/local/apachetmp/labtoolspdfmerge";
+system("mkdir -p $dir");
+my $workdir = tempdir( DIR => $dir, CLEANUP => 1 );
+
+my $error = "";
+
+unshift(@files,$mainfile);
+unshift(@io_handles,$main_handle);
+
+my @sanefiles;
+foreach my $upload(@files){
+ my $upload_file = shift @io_handles;
+ $upload =~ s/"//g;
+ $upload =~ s/\\//g;
+ $upload =~ s/\.\.//g;
+ $upload =~ s/;//g;
+ $upload =~ s%/%%g;
+ next if $upload eq '';
+ next unless $upload_file;
+
+ open (UPLOADFILE,">$workdir/$upload") or $error .= "File Open Error";
+ next unless UPLOADFILE;
+
+ binmode UPLOADFILE;
+ while (<$upload_file>) {
+ print UPLOADFILE;
+ }
+ close UPLOADFILE;
+
+ if($upload =~ /\.jpe?g$/i || $upload =~ /\.png$/i) {
+ $error .= `cd $workdir; convert $upload -auto-orient $upload.pdf 2>&1`;
+ $upload .= ".pdf";
+ }
+
+ push(@sanefiles,'"'.$upload.'"');
+ }
+
+my @fnparts;
+push(@fnparts, $cgi->param('lastname'));
+push(@fnparts, $cgi->param('firstname'));
+push(@fnparts, $cgi->param('date')) unless $cgi->param('date') eq '';
+push(@fnparts, $cgi->param('occassion')) unless $cgi->param('occassion') eq '';
+push(@fnparts, $cgi->param('destination'))unless $cgi->param('destination') eq '';
+push(@fnparts, "Antrag") if $cgi->param('doctype') eq 'Travel Request';
+push(@fnparts, "Abrechnung") if $cgi->param('doctype') eq 'Travel Reimbursement';
+push(@fnparts, "TEST_IGNORE") if $cgi->param('doctype') eq 'TEST';
+
+
+for(my $i=0;$i<scalar @fnparts;$i++) {
+ $fnparts[$i] =~ s/[^A-Za-z0-9\-_öäüÜÖÄß]//g;
+ }
+
+
+my $random = sprintf("%06X", rand(0xffffff));
+my $target = join('_',@fnparts);
+ $target .= "++ID-$random.pdf";
+
+
+my $cmd = "cd $workdir; pdfunite ".join(" ",@sanefiles)." $target 2>&1";
+$error .= `$cmd`;
+system("cd $workdir; cp $target /srv/uploads/");
+
+
+$error =~ s/Syntax Warning: Output intents differs, remove them all//g;
+$error =~ s/\n/<br>/g;
+#$error .= $cgi->param('lastname')." ".$fnparts[0];
+#$error .= Dumper @io_handles;
+#$error .= "----";
+#$error .= Dumper @files;
+print "Content-Type: text/html\n\n";
+print <<HTML;
+<html>
+<body>
+<p>File uploaded. Server response (if any, may contain useless warnings...):</p>
+<code>$error</code>
+HTML
+
+if(-e "uploads/$target") {
+print <<HTML;
+<script>
+window.onload = function() {
+ window.location.href = "uploads/$target";
+};
+</script>
+HTML
+}
+
+print("</body></html>");
+
+
+
+
+