#!/usr/bin/perl # Enter page variables. $bg = '000000'; $text = 'ffffff'; $link ='bda73a'; $menutxt = '191970'; $tabc = '6699ff'; $grdc = '000000'; $angl = '90'; $txtbxtag = 'bgcolor=171726 text=bda73a cursor=bda73a'; $btntag = 'text=ffffff borderimage=file://ROM/tvimages/TVButtonBorder.bif'; # Environment variables. $root = $ENV{'DOCUMENT_ROOT'} . '/'; $server = $ENV{'SERVER_NAME'}; $server =~ s/www\.//; $script = $ENV{'SCRIPT_NAME'}; # Enter FM url. $fmUrl = "fm2.pl"; # Enter chmod values. $dir_perms = '711'; $cgi_perms = '755'; $file_perms = '644'; # Use these modules. use LWP::Simple; use CGI qw(param); # Read in the variables. $file = param('file'); $dir = param('dir'); $get = param('get'); $rename = param('rename'); # Begin subroutine selection. if ($get) { &beam_file; } else { &main_page; } # Begin the beamer page. sub main_page { $title = "Beamer"; &html_header; print qq~
 File URL
 Directory
 Rename

~; &html_footer; } # Begin html header. sub html_header { print "Content-type: text/html\n\n"; &list_dirs; print qq~ $title


$title
~; } # Begin directory list. sub list_dirs { $ls = `ls -R $root`; @pairs = split(/\n/,$ls); shift(@pairs); foreach (@pairs) { if (/$root/) { s/$root//; chop; push(@Dirs, $_); }} } # Begin file beam routine. sub beam_file { $file =~ s/`|;|\s//g; $File = get($file); $fpath = $root.$dir; &error_report; `mkdir $fpath; chmod $dir_perms $fpath` if (!-e $fpath); open NEW,">$fpath/$rename"; print NEW $File; close NEW; unlink('wget.log'); if ($rename =~ /(pl)|(cgi)$/i) { $perms = $cgi_perms; } else { $perms = $file_perms; } `chmod $perms $fpath/$rename`; if (!$dir) { $dirName = 'Root'; $Dir = ''; } else { $dirName = $dir; $Dir = $dir.'/'; } $title = 'File Was Beamed'; &html_header; print qq~

$file
Was beamed in to directory:
$dirName
And was renamed to:

$rename

\n~; &html_footer; } # Begin error messages. sub error_report { $dots = 1 if $rename =~ /\.\./g; @Chars = split(//,$rename); foreach (@Chars) { $char = $_ if !m/[A-Za-z\/\-_0-9\.]/g; } if (!$File && $rename || !$rename || $dots || $char) { $title = 'ERROR!'; &html_header; print "

\n"; if (!$File && $rename) { print "Unable to beam in the file!

Possible reasons:
Error 400 Bad URL Syntax
Error 403 Forbidden
Error 404 File Not Found
Error 500 Internal Server Error
Error 503 Gateway Timeout
"; } else { print "
"; if (!$rename) { print "New name for file is missing!"; } if ($dots) { print "
  • New name can't have 2 or more dots in a row!
    "; } if ($char) { print "
  • New name can't contain: '$char' Use only letters,
    numbers, underlines, hyphens and dots without spaces!
    "; } } print qq~
  • \n~; &html_footer; } } # Begin html footer. sub html_footer { print qq~

    Operated by $server
    ~; exit; }