All pastes #223094 Raw Edit

Stuff

public text v1 · immutable
#223094 ·published 2006-10-26 19:13 UTC
rendered paste body
#!/usr/bin/perl
use strict;
use CGI qw(:all);
use constant PDF   => '/opt/lampp/var/lib/textpresso/database/pdfs/upload/';
my $file;
my @types = ('count lines','count words','count characters');

print(header('text/html'));
print(start_html());

print start_multipart_form(),
    "Enter the file to process.  Filename MUST be <PMID>.pdf, where <PMID> is an integer corresponding to the PubMed ID of the article in the file.",
    filefield('filename','',45),
    br,
    reset,submit('submit','Process File'),
    endform;

# Process the form if there is a file name entered that is <pmid>.pdf
if ($file = param('filename')) {
    my($pmid) = $file =~ m!^(\d+)\.pdf$!;
    open(F,'>'.PDF.'/'.$file);
    while (<$file>) {
        print F $_;
    }
}else{
    # If the file uploaded is anything but .pdf, then we try and unpack it using a nice little program
    # which has been edited to unpack into a certain directory for the cron job to take over ;)
    system ("perl /opt/lampp/cgi-bin/curators/unp.pl $file");
}
    close $file;
    close(F);
    print hr();
    print(h2("Processing $file..."));
    print strong("Upload successful.  Your file will be processed within 1 hour.");



print(end_html());