#!/usr/bin/perl -w ############################################ # Remote unZip Utility 2009 by rwedge # expandinghead.net. Use to retrieve a .zip or # .gzip file and unzip and add the file(s) # to a directory it is installed in. Be careful, # as it will over-write any existing file(s) # which share the same name. # Requires CGI.pm and LWP. # The directory this script runs in must have # write permissions enable. # Chmod script as required ( usually 755 ) ############################################ # This software is provided "as is" and any express or # implied warranties, including, but not limited to, the implied warranties # of merchantability and fitness for a particular purpose are disclaimed. # In no event shall the author be liable for any direct, indirect, # incidental, special, exemplary, or consequential damages ############################################ my ($url, $effect, $fname, $browser, $res, $Results, $js); use CGI qw(:cgi :standard); use strict; use warnings; $url = param('url') || ''; $effect = 'nohighlight autoactivate'; $js =<'UnZip Utility', -script => $js, -author =>'expandinghead.net', -bgcolor => '#ffffff', -text => '#000000'), p,h1('UnZip Utility'),p,'enter the URL of the zipped file',hr, start_form,table(Tr([ td(['URL ',textfield(-size=>50,-name=>'url',-default=>'http://',-onChange=>"spud(this)",$effect)]), td(['File Name ',textfield(-size=>25,-name=>'fname',-default=>'',$effect)]), td([submit(undef,' Submit '),reset]), ])),end_form; if ($url ne '' ) { $Results = ''; $fname = param('fname') || ''; if ($url !~ /(\.zip|\.gz)$/ig) { $Results = 'The URL to the file must end in .zip or .gz'; } elsif ($fname !~ /(\.zip|\.gz)$/ig) { $Results = 'The local file Name you assign must end in the same type as the remote file .zip or .gz'; } else { use LWP::UserAgent; $browser = LWP::UserAgent->new(); $res = $browser->mirror($url, $fname); if (!$res->is_success) { $Results = $res->status_line; } else { $Results = "

File Status


"; if ( -e $fname ) { if ($fname =~ /\.zip$/i) { $Results .= `unzip $fname; ls $fname 2>&1`; $Results .= "

Zip file = $fname
End of Action

"; } elsif ($fname =~ /\.gz$/i) { $Results .= `gzip -l $fname; gzip -d $fname`; $Results .= "

End of Action

"; } } else { $Results .= "

$fname could not be found

"; } } } print $Results; } print p,h5('expanding head'),end_html;