As for why your script is not producing any output, try instead:
print STDERR "my \$valid_dir is: $valid_dir \n"; print STDERR "my \$valid_zip is: $valid_zip \n";
And inspecting your logs at: /var/log/apache2/error.log for your output. Its likely because you did not create your html headers, but that may be off. If you are going to `use CGI;`, you could at least replace the printing of the Content-type: line with:

print $query->header; print $query->start_html('My Application');
Since that module is built to handle that sort of thing.

Not sure of the true scope and purpose of your application, but I would go pc88mxer at least one more step down the path toward securing this app. I would urge that you not permit someone to simply name any old directory on your server where they are permitted to upload an arbitrary and potentially hostile zip file. I would choose a directory which I controlled and over which I could exercise some supervision. In fact, if you are running a web server, it makes alot of sense to create a disk partition from which an executable can not be executed. (See `man mount` for further details, and set your configuration for that partition in /etc/fstab). Then you can mount it to /tmp/uploads and use it as an additional layer of protection between your server and potentially hostile operators at a browser.

I would start by trying (the untested):

my $safe_uploads_directory = '/tmp/uploads'; use Archive::Zip qw( :ERROR_CODES :CONSTANTS ); my $zip = Archive::Zip->new( $valid_zip ); chdir( $safe_uploads_directory ) && $zip->extractTree();
This follows one of the first rules of programming: laziness, by reusing other people's code. Adam Kennedy already figured out all this manipulating a zip file stuff for you. If you take a few minutes to read his documentation, with `perldoc Archive::Zip`, you might find it could save you hours of working this all out for yourself, as well as teach you more about the structure of a zip archive than you ever wanted to know. You might find that this works better for you.

-- Hugh

UPDATE:

I corrected a typo to provide a complete and absolute path in my definition of the $safe_uploads_directory.

if( $lal && $lol ) { $life++; }

In reply to Re: HTML Form and Perl by hesco
in thread HTML Form and Perl by workman_m

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.