#!/usr/bin/perl -w #################################### # Mirror File 2010 rwedge expandinghead.net # This script copies a remote file to the directory # that it is installed in. Option to rename file. # Confirmation includes file stats. # Requires CGI.pm and the LWP package. # The directory this script runs in must have write # permissions enabled. Chmod this 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, $fname, $browser, @ext, $res, $errmsg, $results, $nname, $file_stats, @status_list, $status_list); use CGI qw(:standard); use strict; $url = param('url') || ''; $fname = param('fname') || ''; print header,start_html(-title =>'Mirror Utility', -author =>'expandinghead.net', -bgcolor => '#ffffff', -text => '#000000'), p,h1('Mirror a File'),p,'enter the URL of the file you wish to copy',hr, start_form,table(Tr([ td(['URL ',textfield(-size=>50,-name=>'url',-default=>'http://')]), td(['New Name ',textfield(-size=>25,-name=>'fname',-default=>''),'optional']), td([submit(undef,' Submit '),reset]), ])),end_form; if (param()) { $url =~ s/[;<>`\*\|'\$!#\(\)\[\]\{\}'"\\]//g; $url =~ s/^\s+//; $url =~ s/\s+$//; use LWP::UserAgent; $browser = LWP::UserAgent->new(); if ($fname eq '') { @ext = split(/\//,$url); $fname = pop(@ext); } $res = $browser->mirror($url, $fname) or die "Error getting file: $!"; if (!$res->is_success) { $errmsg = $res->status_line; $results = "
expanding head
"; } print $results; } print end_html;