mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-12 12:56:16 +00:00
smtk2ssrf Perl script: Add some error reporting
So far, if the conversion process failed, we simply returned an empty file. Now, we report that something's wrong. Signed-off-by: Robert C. Helling <helling@atdotde.de>
This commit is contained in:
parent
6a706a7000
commit
73151ca1d9
1 changed files with 14 additions and 3 deletions
|
@ -2,21 +2,32 @@
|
||||||
|
|
||||||
use CGI;
|
use CGI;
|
||||||
|
|
||||||
|
$CGI::POST_MAX = 1024 * 1024 * 10;
|
||||||
|
|
||||||
# Change this to the correct path to binary.
|
# Change this to the correct path to binary.
|
||||||
my $smtk2ssrf = "../build/smtk2ssrf";
|
my $smtk2ssrf = "../build/smtk2ssrf";
|
||||||
|
my $logfile = '/tmp/smtk2ssrf.log';
|
||||||
|
|
||||||
my $q = CGI->new;
|
my $q = CGI->new;
|
||||||
|
|
||||||
if ($q->upload("uploaded_file")) {
|
if ($q->upload("uploaded_file")) {
|
||||||
my $original_filename = $q->param("uploaded_file");
|
my $original_filename = $q->param("uploaded_file");
|
||||||
|
my $converted = `$smtk2ssrf $tmp_filename -`;
|
||||||
my $tmp_filename = $q->tmpFileName($original_filename);
|
my $tmp_filename = $q->tmpFileName($original_filename);
|
||||||
my $new_filename = $original_filename;
|
my $new_filename = $original_filename;
|
||||||
$new_filename =~ s/.*[\/\\]//;
|
$new_filename =~ s/.*[\/\\]//;
|
||||||
$new_filename =~ s/\..*$/.ssrf/;
|
$new_filename =~ s/\..*$/.ssrf/;
|
||||||
|
|
||||||
print "Content-Disposition: attachment; filename=\"$new_filename\"\n";
|
if (length($converted) > 5) {
|
||||||
print "Content-type: subsurface/xml\n\n";
|
|
||||||
system "$smtk2ssrf $tmp_filename -";
|
print "Content-Disposition: attachment; filename=\"$new_filename\"\n";
|
||||||
|
print "Content-type: subsurface/xml\n\n";
|
||||||
|
print $converted;
|
||||||
|
} else {
|
||||||
|
print "Content-type: text/html\n\n";
|
||||||
|
print "<H1>Conversion failed</H1>";
|
||||||
|
print 'Please contact <a href=mailto:helling@atdotde.de>Robert Helling (robert@thetheoreticaldiver.org)</a> if the problem persits.';
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
print "Content-type: text/html\n\n";
|
print "Content-type: text/html\n\n";
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue