#!/usr/local/bin/perl # The top line points to the perl location on your server. use strict; use CGI; $CGI::HEADERS_ONCE=1; use CGI::Carp qw(fatalsToBrowser); # You must have CGI.PM module on your server (most servers do.) use Net::FTP; # You must have Net::FTP, Net::Cmd and Net::Config modules # installed on your server. If you don't have enough priviledges # to install them in system path, make a directory called Net in # the directory where your ftp2.cgi script will be and put FTP.pm, # Cmd.pm and Config.pm there. These Net libraries can be got from # http://www.gbarr.demon.co.uk/ ################################################################## # WWW FTP CLIENT # by Maxim Bakin # Copyright 2000-2001 # If you use this script please make a link to Maximus Site. # http://www.maximus.f2s.com # # I will not be liable for indirect, special, or consequential # damages (or any loss of revenue, profits, or data) arising in # connection with this script. # Please feel free to modify and distribute this program as well as # send me any critic, comments and improvements. # Maxim Bakin # max@maximus.f2s.com # # VERSION 1.1 # Last modified 03-July-2001 # Changes from version 1.0: # 1) Added ability to create and edit remote text files. # 2) Fixed some minor bug with directory listings on Windows NT box. # 3) Configurable name and place of temporary directory # # I expect to rewrite this script from scratch in the near future. # Changes will be in the structure of the script as well as I think # I'll try to make FTP operations built-in instead of relying on # modules that unfortunately do not come with standard Perl distribution, # and installing them on the hosting company's server is a kind of a # headache. ################################################################### # HERE ARE CONFIGURATION VARIABLES my $upload_files=6; #The number of upload fields my $temp_dir="ajha9svft"; #Path to temporary directory with uploads/downloads #I prefer using absolute path but it can be left #with a relative path just as now. #It's recommended to make it somewhere outside your #cgi-bin directory, so please change this default. my $www_temp_dir="ajha9svft"; #Path from the web to temporary directory #say you have ftp2.cgi at http://server2047.virtualave.net/83v-9s/ftp2.cgi #and temporary dir at http://server2047.virtualave.net/83v-9s/ajha9svft #so you can write "../ajha9svft" or full "http://www.yoursite.com/ajha9svft" #Certainly it's connected with $temp_dir variable #################################################################### my $query=new CGI; my $ftp; my $site=$query->param("site"); my $user=$query->param("user"); my $pass=$query->param("pass"); my $dir=$query->param("dir")? $query->param("dir") : ""; my $action=$query->param("action"); print $query->header(); print "<body bg=\"000000\" text=\"red\" usestyle><center><blackface>Debugg YourSelf<noembed>X - Ftp Client Protocol - X
\n"; unless ($site){ choose_site(); exit; } if ($action){ action($action); } print <<"EOT";
EOT show_dir(); sub choose_site(){ print <<"EOT";
Ftp address:
User:
Password:
Directory:
</BODY></HTML> EOT } sub action(){ my $action=shift; if ($action eq "view"){ mkdir("$temp_dir", 0777) unless (-e "$temp_dir"); unlink <$temp_dir/*>; my $name=$query->param("name"); my $new_name; login_remote($site, $user, $pass, $dir); if ($name=~/\.pl|\.cgi|\.php.|\.shtml|\.css$/){ ($new_name=$name)=~s/(.*)(\..*)$/$1/; $new_name.=".txt"; } else { $new_name=$name; } $ftp->get("$name", "$temp_dir/$new_name") or do {error_here("file_not_got", $name); return;}; print "<script language=Javascript>window.open(\"$www_temp_dir/$new_name\", \"newWin\", \"scrollbars=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=600,height=400\")</script>"; } if ($action eq "edit"){ my $sure=$query->param("sure"); if ($sure eq "yes"){ my $name=$query->param("name"); my $file_content=$query->param("file_content"); open(FILE, ">$temp_dir/$name") or die "Cannot open file: $!"; print FILE $file_content; close(FILE) or die "Cannot close file: $!"; login_remote($site, $user, $pass, $dir); if ($ftp->put("$temp_dir/$name")){ print "<B>$name</B> has been modified.<BR>\n"; } else{ &error_here("bad_edit"); } unlink ("$temp_dir/$name"); } else { my $name=$query->param("name"); return unless $name; mkdir("$temp_dir", 0777) unless (-e "$temp_dir"); unlink <$temp_dir/*>; login_remote($site, $user, $pass, $dir); $ftp->get("$name", "$temp_dir/$name") or do {error_here("file_not_got", $name); return;}; open(FILE, "$temp_dir/$name") or die "Cannot open file: $!"; print <<"EOT"; <FORM name=my_form method=POST> <INPUT TYPE=hidden NAME=site VALUE=$site> <INPUT TYPE=hidden NAME=user VALUE=$user> <INPUT TYPE=hidden NAME=pass VALUE=$pass> <INPUT TYPE=hidden NAME=dir VALUE=$dir> <INPUT TYPE=hidden NAME=sure VALUE=yes> <INPUT TYPE=hidden NAME=name VALUE=$name> <TABLE WIDTH=600 BORDER=0 CELLPADDING=0 CELLSPACING=0> <TR><TD COLSPAN=2 ALIGN=center>Edit <B>$name</B></TD></TR> <TR><TD COLSPAN=2 ALIGN=center> <TEXTAREA COLS=70 ROWS=30 NAME=file_content> EOT print while (<FILE>); print <<"EOT"; <(/textarea)></TD></TR> <TR><TD WIDTH=50% ALIGN=right><INPUT TYPE=hidden NAME=action VALUE=edit text=\"0099ff\" borderimage=\"file://rom/borders/buttonborder2.bif\"><INPUT TYPE=submit VALUE=Save text=\"0099ff\" borderimage=\"file://rom/borders/buttonborder2.bif\"></TD> </FORM> <TD WIDTH=50% ALIGN=left> <FORM name=my_form method=POST> <INPUT TYPE=hidden NAME=site VALUE=$site> <INPUT TYPE=hidden NAME=user VALUE=$user> <INPUT TYPE=hidden NAME=pass VALUE=$pass> <INPUT TYPE=hidden NAME=dir VALUE=$dir> <INPUT TYPE=submit VALUE=Cancel text=\"0099ff\" borderimage=\"file://rom/borders/buttonborder2.bif\"> </TD></TR> </TABLE> EOT close(FILE) or die "Cannot close file: $!"; exit; } } if ($action eq "new_file"){ my $sure=$query->param("sure"); if ($sure eq "yes"){ my $name=$query->param("name"); my $file_content=$query->param("file_content"); open(FILE, ">$temp_dir/$name") or die "Cannot open file: $!"; print FILE $file_content; close(FILE) or die "Cannot close file: $!"; login_remote($site, $user, $pass, $dir); if ($ftp->put("$temp_dir/$name")){ print "<B>$name</B> has been created.<BR>\n"; } else{ &error_here("bad_edit"); } unlink ("$temp_dir/$name"); } else { my $name = "new_file_name.txt"; mkdir("$temp_dir", 0777) unless (-e "$temp_dir"); unlink <$temp_dir/*>; login_remote($site, $user, $pass, $dir); print <<"EOT"; <FORM name=my_form method=POST> <INPUT TYPE=hidden NAME=site VALUE=$site> <INPUT TYPE=hidden NAME=user VALUE=$user> <INPUT TYPE=hidden NAME=pass VALUE=$pass> <INPUT TYPE=hidden NAME=dir VALUE=$dir> <INPUT TYPE=hidden NAME=sure VALUE=yes> <TABLE WIDTH=600 BORDER=0 CELLPADDING=0 CELLSPACING=0> <TR><TD COLSPAN=2 ALIGN=center>Edit <INPUT TYPE=TEXT NAME=name VALUE="$name" text=\"0099ff\" borderimage=\"file://rom/borders/buttonborder2.bif\"></TD></TR> <TR><TD COLSPAN=2 ALIGN=center> <TEXTAREA COLS=70 ROWS=30 NAME=file_content text=\"0099ff\" borderimage=\"file://rom/borders/buttonborder2.bif\"> <(/textarea)></TD></TR> <TR><TD WIDTH=50% ALIGN=right><INPUT TYPE=hidden NAME=action VALUE=new_file text=\"0099ff\" borderimage=\"file://rom/borders/buttonborder2.bif\"><INPUT TYPE=submit VALUE=Save text=\"0099ff\" borderimage=\"file://rom/borders/buttonborder2.bif\"></TD> </FORM> <TD WIDTH=50% ALIGN=left> <FORM name=my_form method=POST> <INPUT TYPE=hidden NAME=site VALUE=$site> <INPUT TYPE=hidden NAME=user VALUE=$user> <INPUT TYPE=hidden NAME=pass VALUE=$pass> <INPUT TYPE=hidden NAME=dir VALUE=$dir> <INPUT TYPE=submit VALUE=Cancel text=\"0099ff\" borderimage=\"file://rom/borders/buttonborder2.bif\"> </TD></TR> </TABLE> EOT exit; } } if ($action eq "chmod"){ my @names=$query->param("name"); if (@names){ if ($query->param("new_mode_$names[0]")){ login_remote($site, $user, $pass, $dir); foreach my $name(@names){ my $mode=$query->param("new_mode_$name"); #here we check whether the user entered a valid mode unless ($mode=~/[0-7][0-7][0-7]/){ error_here("bad_mode", $name, $mode); next; } my $response=($ftp->site("CHMOD $mode $name")); #site method returns most significant digit of the response code, #so if it is not 2 the command wasn"t ok unless ($response == 2){ error_here("file_not_chmodded", $name, $mode); next; } print "<B>$name</B> has been chmoded to <B>$mode</B>.<BR>"; } } else { print <<"EOT"; <FORM name=my_form method=POST> <INPUT TYPE=hidden NAME=site VALUE=$site> <INPUT TYPE=hidden NAME=user VALUE=$user> <INPUT TYPE=hidden NAME=pass VALUE=$pass> <INPUT TYPE=hidden NAME=dir VALUE=$dir> Please make sure you are not making a mistake.<BR> Only checked files will be <B>chmodded</B>.<BR><BR> <TABLE BORDER=0> <TR><TD><TD><TD>Chmod to: EOT foreach (@names){ print <<"EOT"; <TR> <TD><INPUT TYPE=checkbox name=name value=$_ CHECKED> <TD>$_ <TD><INPUT TYPE=text SIZE=4 MAXLENGTH=3 NAME=new_mode_$_ text=\"0099ff\" borderimage=\"file://rom/borders/buttonborder2.bif\"> EOT } print <<"EOT"; <TR> <TD><TD><INPUT TYPE=hidden NAME=action VALUE=chmod text=\"0099ff\" borderimage=\"file://rom/borders/buttonborder2.bif\"> <TD><INPUT TYPE=submit VALUE=Proceed text=\"0099ff\" borderimage=\"file://rom/borders/buttonborder2.bif\"> </FORM> </TABLE> <noframes> </BODY></HTML> EOT exit; } } } if ($action eq "rename"){ my @old_names=$query->param("name"); if (@old_names){ if ($query->param("sure") eq "yes"){ login_remote($site, $user, $pass, $dir); foreach my $name(@old_names){ my $new_name=$query->param("new_name_$name"); unless ($new_name){ error_here("empty_rename", $name); next; } if ($new_name=~/[^\w\-\.\+]/){ error_here("bad_rename", $name); next; } $ftp->rename("$name", "$new_name") or do {error_here("not_renamed", $name, $new_name); next;}; print "<B>$name</B> has been renamed to <B>$new_name</B>.<BR>"; } } else { print <<"EOT"; <FORM name=my_form method=POST> <INPUT TYPE=hidden NAME=site VALUE=$site> <INPUT TYPE=hidden NAME=user VALUE=$user> <INPUT TYPE=hidden NAME=pass VALUE=$pass> <INPUT TYPE=hidden NAME=dir VALUE=$dir> <INPUT TYPE=hidden NAME=sure VALUE=yes> Please make sure you are not making a mistake.<BR> Only checked files(directories) will be <B>renamed</B>.<BR><BR> <TABLE BORDER=0> <TR><TD><TD> <TD>Rename to: EOT foreach (@old_names){ print <<"EOT"; <TR> <TD><INPUT TYPE=checkbox name=name value=$_ CHECKED text=\"0099ff\" borderimage=\"file://rom/borders/buttonborder2.bif\"> <TD>$_ <TD><INPUT TYPE=text NAME=new_name_$_ VALUE=$_ text=\"0099ff\" borderimage=\"file://rom/borders/buttonborder2.bif\"> EOT } print <<"EOT"; <TR><TD><TD> <INPUT TYPE=hidden NAME=action VALUE=rename text=\"0099ff\" borderimage=\"file://rom/borders/buttonborder2.bif\"> <TD><INPUT TYPE=submit VALUE=Proceed text=\"0099ff\" borderimage=\"file://rom/borders/buttonborder2.bif\"> </FORM> </TABLE> <noframes> </BODY></HTML> EOT exit; } } } if ($action eq "delete_dir"){ my @names=$query->param("name"); if (@names){ my $sure=$query->param("sure"); if ($sure eq "yes"){ login_remote($site, $user, $pass, $dir); foreach my $name(@names){ $ftp->rmdir("$name"); print "Directory <B>$name</B> has been deleted.<BR>"; } } else { print <<"EOT"; Please make sure you are not making a mistake.<BR> Only checked directories will be <B>deleted</B>.<BR> <TABLE> <FORM name=my_form method=POST> <INPUT TYPE=hidden NAME=site VALUE=$site> <INPUT TYPE=hidden NAME=user VALUE=$user> <INPUT TYPE=hidden NAME=pass VALUE=$pass> <INPUT TYPE=hidden NAME=dir VALUE=$dir> <input type=hidden name=sure value=yes> EOT foreach (@names){ print "<TR>\n"; print "<TD><input type=checkbox name=name value=$_ CHECKED text=\"0099ff\" borderimage=\"file://rom/borders/buttonborder2.bif\">\n"; print "<TD>$_\n"; } print <<"EOT"; <TR><TD><TD> <input type=hidden name=action value=delete_dir text=\"0099ff\" borderimage=\"file://rom/borders/buttonborder2.bif\"> <input type=submit value=Proceed text=\"0099ff\" borderimage=\"file://rom/borders/buttonborder2.bif\"> </TABLE> </FORM> EOT exit; } } } if ($action eq "delete_file"){ my @names=$query->param("name"); if (@names){ if ($query->param("sure") eq "yes"){ login_remote($site, $user, $pass, $dir); foreach my $name(@names){ $ftp->delete("$name") or do {error_here("file_not_deleted", $name); next;}; print "<B>$name</B> has been deleted.<BR>"; } } else { print <<"EOT"; Please make sure you are not making a mistake.<BR> Only checked files will be <B>deleted</B>.<BR> <TABLE> <FORM name=my_form method=POST> <INPUT TYPE=hidden NAME=site VALUE=$site> <INPUT TYPE=hidden NAME=user VALUE=$user> <INPUT TYPE=hidden NAME=pass VALUE=$pass> <INPUT TYPE=hidden NAME=dir VALUE=$dir> <input type=hidden name=sure value=yes> EOT foreach (@names){ print "<TR>\n"; print "<TD><input type=checkbox name=name value=$_ CHECKED>\n"; print "<TD>$_\n"; } print <<"EOT"; <TR> <TD> <TD> <input type=hidden name=action value=delete_file> <input type=submit value=Proceed> </TABLE> </FORM> EOT exit; } } } if ($action eq "make_new_dir"){ my $new_dir=$query->param("new_dir"); unless ($new_dir){ error_here("empty_new_dir_field"); return; } if ($new_dir=~/[^\w\-\.\+]/){ error_here("bad_new_dir"); return; } login_remote($site, $user, $pass, $dir); $ftp->mkdir("$new_dir") or do {error_here("dir_not_created", $new_dir); return;}; print "Directory <B>$new_dir</B> has been created.<BR><BR>"; } if ($action eq "home_dir"){ $dir=""; } if ($action eq "change_dir"){ $dir=$query->param("dir"); my $name=$query->param("name"); $dir.="\/$name"; } if ($action eq "one_level_up"){ $dir=$query->param("dir"); $dir=~s/(.*)(\/.*)$/$1/; } if ($action eq "upload"){ my $binary_mode="ok"; for (my $i=1; $i<=$upload_files; $i++){ my $file=$query->param("file$i"); my $short_name; next unless $file; ($short_name=$file)=~s/.*[\/\\](.*)$/$1/; my $type = $query->uploadInfo($file)->{"Content-Type"}; unless (($type=~/text/)||($short_name=~/.pl|.cgi|.pm$/)){ $binary_mode="ok"; } mkdir("$temp_dir", 0777) unless (-e "$temp_dir"); my ($bytesread, $buffer); open (OUTFILE, ">$temp_dir/$short_name") or error_here("open_file"); while ($bytesread=read($file, $buffer, 1024)){ print OUTFILE $buffer; } close (OUTFILE) or error_here("close_file"); if (-z "$temp_dir/$short_name"){ error_here("bad_file"); unlink ("$temp_dir/$short_name"); } } login_remote($site, $user, $pass, $dir); for (my $i=1; $i<=$upload_files; $i++){ my $file=$query->param("file$i"); my $short_name; next unless $file; ($short_name=$file)=~s/.*[\/\\](.*)$/$1/; next unless (-e "$temp_dir/$short_name"); $ftp->binary() if ($binary_mode eq "ok"); if ($ftp->put("$temp_dir/$short_name")){ print "<B>$short_name</B> has been uploaded.<BR>\n"; } else{ &error_here("bad_upload"); } unlink ("$temp_dir/$short_name"); } print "<BR>"; $ftp->quit(); } } sub show_dir(){ login_remote($site, $user, $pass, $dir); my @dir = read_remote(); my(@directories, @files, @file_sizes); my($up_dir, $unix); foreach (@dir){ #imho on UNIX dir() returns array of 9 elements, on Windows basicly 4 but #it can be configured to return in UNIX style. So we check here how #many options are returned. #Also for directories it writes <DIR> in place of size my @file_options=split " "; my ($perm, $dig, $own, $grp, $size, $mon, $day, $year, $file_name, $date, $time); if ($#file_options==8){ ($perm, $dig, $own, $grp, $size, $mon, $day, $year, $file_name) = @file_options; } else { ($date, $time, $size, $file_name) = @file_options; } if ( (/^d/) or ($size eq "<DIR>")){ push(@directories, $file_name) unless $file_name=~/^\./ } else { push(@files, $file_name); push(@file_sizes, $size); } } ($up_dir = $dir) =~s/(.*)(\/.*)$/$1/; print "<TABLE WIDTH=700 BORDER=0>\n<TR><TD>"; print "You logged in <B>$site</B>.<BR>" if $site; if ($dir){ print "Current directory: <B>$dir</B><BR>\n"; } else { print "You are in <B>home directory</B><BR>\n"; } print "<input type=submit name=action value=home_dir text=\"0099ff\" borderimage=\"file://rom/borders/buttonborder2.bif\">\n" if $dir; print "<input type=submit name=action value=one_level_up text=\"0099ff\" borderimage=\"file://rom/borders/buttonborder2.bif\">\n" if $dir; print <<"EOT"; <TD ALIGN=center><a href=ftp2.cgi><B>HOME</B></a> <TR><TD COLSPAN=2> Please note that <B>change_dir</B> and <B>view</B> options work only for a single selection. For other actions you are welcome to make multiple selections. </TABLE> <BR> <TABLE BORDER=0 WIDTH=700 ALIGN=center><TR> <TD WIDTH=450 VALIGN=TOP> EOT print <<"EOT" if @directories; <TABLE BORDER=0> <TR><TD COLSPAN=2>Directories: <TR><TD VALIGN=top> <TABLE BORDER=0 WIDTH=170> EOT my $count=0; my $tdcolor; foreach (@directories){ if ($count%2 == 0){$tdcolor="BGCOLOR=#1b1b21"} else {$tdcolor="BGCOLOR=#1b1b21"} $count++; print <<"EOT"; <TR> <TD $tdcolor ALIGN=center WIDTH=20><input type=checkbox name=name value=$_></TD> <TD $tdcolor WIDTH=150><B>$_</B></TD> </TR> EOT } print <<"EOT" if @directories; </TABLE> </TD> <TD VALIGN=top> <TABLE BORDER=0> <TR><TD> <INPUT TYPE=submit NAME=action VALUE=change_dir WIDTH=100 STYLE="width:100" text=\"0099ff\" borderimage=\"file://rom/borders/buttonborder2.bif\"><BR> <INPUT TYPE=submit NAME=action VALUE=rename WIDTH=100 STYLE="width:100" text=\"0099ff\" borderimage=\"file://rom/borders/buttonborder2.bif\"><BR> <INPUT TYPE=submit NAME=action VALUE=delete_dir WIDTH=100 STYLE="width:100" text=\"0099ff\" borderimage=\"file://rom/borders/buttonborder2.bif\"> </TD> </TR> </TABLE> </TD> </TR> </TABLE> EOT print <<"EOT" if @files; <TABLE BORDER=0> <TR><TD COLSPAN=2>Files: <TR><TD VALIGN=top> <TABLE BORDER=0 WIDTH=170> EOT my $count=0; my $tdcolor; foreach (@files){ if ($count%2 == 0){$tdcolor="BGCOLOR=#1b1b21"} else {$tdcolor="BGCOLOR=#1b1b21"} print <<"EOT"; <TR> <TD $tdcolor ALIGN=center VALIGN=center WIDTH=20><input type=checkbox name=name value=$_></TD> <TD $tdcolor WIDTH=150>$_</TD> <TD $tdcolor ALIGN=right WIDTH=150>$file_sizes[$count]</TD> </TR> EOT $count++; } print <<"EOT" if @files; </TABLE> </TD> <TD VALIGN=top> <TABLE BORDER=0> <TR><TD> <INPUT TYPE=submit NAME=action VALUE=rename WIDTH=100 STYLE="width:100" text=\"0099ff\" borderimage=\"file://rom/borders/buttonborder2.bif\"><BR> <INPUT TYPE=submit NAME=action VALUE=delete_file WIDTH=100 STYLE="width:100" text=\"0099ff\" borderimage=\"file://rom/borders/buttonborder2.bif\"><BR> <INPUT TYPE=submit NAME=action VALUE=chmod WIDTH=100 STYLE="width:100" text=\"0099ff\" borderimage=\"file://rom/borders/buttonborder2.bif\"><BR> <INPUT TYPE=submit NAME=action VALUE=view WIDTH=100 STYLE="width:100" text=\"0099ff\" borderimage=\"file://rom/borders/buttonborder2.bif\"><BR> <INPUT TYPE=submit NAME=action VALUE=edit WIDTH=100 STYLE="width:100" text=\"0099ff\" borderimage=\"file://rom/borders/buttonborder2.bif\"><BR> <INPUT TYPE=submit NAME=action VALUE=new_file WIDTH=100 STYLE="width:100" text=\"0099ff\" borderimage=\"file://rom/borders/buttonborder2.bif\"> </TD> </TR> </TABLE> </TD> </TR> </TABLE> EOT print <<"EOT"; <TD VALIGN=TOP> <TABLE BORDER=0> <TR><TD>Make new directory: <TR><TD> <input type=text name=new_dir text=\"0099ff\" borderimage=\"file://rom/borders/buttonborder2.bif\"><BR> <input type=submit name=action value="make_new_dir" text=\"0099ff\" borderimage=\"file://rom/borders/buttonborder2.bif\"> </TABLE> <BR> <TABLE BORDER=0> <TR><TD>Upload file(s) to this directory: EOT for (my $i=1; $i<=$upload_files; $i++){ print "<TR><TD><input type=file name=file$i size=30 maxlength=150 text=\"0099ff\" borderimage=\"file://rom/borders/buttonborder2.bif\">\n"; } print <<"EOT"; <TR><TD><INPUT TYPE=submit NAME=action VALUE="upload" text=\"0099ff\" borderimage=\"file://rom/borders/buttonborder2.bif\"> </FORM> </TABLE> </TABLE> </CENTER><noframes></BODY></HTML> EOT } sub read_remote(){ my @dir=$ftp->dir(); $ftp->quit(); return @dir; } sub login_remote(){ my $site=shift; my $user=shift; my $pass=shift; my $dir=shift; $ftp = Net::FTP->new($site) or error_here("bad_site"); $ftp->login($user,$pass) or error_here("bad_login"); $ftp->cwd($dir) or error_here("bad_dir", $dir); } sub error_here(){ my $reason = shift; print $query->header(); if ($reason eq "bad_login"){ print <<"EOT"; <TABLE BORDER=0> <TR><TD COLSPAN=2><B>Cannot login to host.</B> <TR><TD COLSPAN=2>Either the host is unreachable or you entered the wrong data. <TR><TD COLSPAN=2> <TR><TD COLSPAN=2>You supplied the following:<BR> <TR><TD><B>Host address:</B><TD>$site<BR> <TR><TD><B>Username:</B><TD>$user<BR> <TR><TD><B>Password:</B><TD>$pass<BR> <TR><TD COLSPAN=2> <TR><TD COLSPAN=2>Please go <a href="ftp2.cgi">back</a> and try again if you feel you made a mistake. </TABLE> EOT exit; } elsif ($reason eq "bad_site"){ print <<"EOT"; <TABLE BORDER=0> <TR><TD COLSPAN=2><B>The host doesn"t seem to respond.</B> <TR><TD COLSPAN=2>Either the host is unreachable or you entered the wrong address. <TR><TD COLSPAN=2> <TR><TD COLSPAN=2>You supplied the following:<BR> <TR><TD><B>Host address:</B><TD>$site<BR> <TR><TD COLSPAN=2> <TR><TD COLSPAN=2>Please go <a href="ftp2.cgi">back</a> and try again if you feel you made a mistake. </TABLE> EOT exit; } elsif ($reason eq "bad_dir"){ my $dir=shift; print "<B>Error:</B> Cannot move to the directory <B>$dir</B>.<BR>"; print "Please go <a href=\"ftp2.cgi\">back</a> and try again if you feel you made a mistake.<BR>"; exit; } elsif ($reason eq "dir_not_created"){ my $new_dir=shift; print "<B>Error:</B> Cannot create a directory named <B>$new_dir</B>.<BR>"; } elsif ($reason eq "file_not_got"){ my $name=shift; print "<B>Error:</B> Cannot view <B>$name</B>.<BR>"; } elsif ($reason eq "file_not_chmodded"){ my $name=shift; my $mode=shift; print "<P><B>Error:</B> <B>$name</B> has \Unot\E been chmoded to <B>$mode</B>.<BR>"; print "Something goes wrong or this command is not supported.</P>" } elsif ($reason eq "bad_mode"){ my $name=shift; my $mode=shift; print "<B>Error:</B> For <B>$name</B> you entered \Uillegal\E mode <B>$mode</B>.<BR>"; } elsif ($reason eq "not_renamed"){ my $name=shift; my $new_name=shift; print "<B>Error:</B> Cannot rename <B>$name</B> to <B>$new_name</B>.<BR>"; } elsif ($reason eq "bad_new_dir"){ print "<B>Error:</B> Name for a new directory contains \Uillegal\E characters. Use only alphanumerics, _, ., + and -.<BR>"; } elsif ($reason eq "empty_new_dir_field"){ print "<B>Error:</B> New directory name field was empty when you hit the button.<BR>"; } elsif ($reason eq "empty_rename"){ my $name=shift; print "<B>Error:</B> New name field for <B>$name</B> was empty when you hit the button.<BR>"; } elsif ($reason eq "bad_rename"){ my $name=shift; print "<B>Error:</B> New name for <B>$name</B> contains \Uillegal\E characters. Use only alphanumerics, _, ., + and -.<BR>"; } elsif ($reason eq "dir_not_deleted"){ my $name=shift; print "<B>Error:</B> Directory <B>$name</B> has NOT been deleted.<BR>"; } elsif ($reason eq "file_not_deleted"){ my $name=shift; print "<B>Error:</B> File <B>$name</B> has NOT been deleted.<BR>"; } elsif ($reason eq "bad_file"){ print "<B>Error:</B> There is a problem with the file you tried to upload.<BR>"; } elsif ($reason eq "bad_upload"){ print "ERROR: Cannot upload file:$!.<BR>"; } elsif ($reason eq "bad_edit"){ print "ERROR: Cannot upload file which you edited:$!.<BR>"; } elsif ($reason eq "open_file"){ print "ERROR: Cannot open file:$!.<BR>"; } elsif ($reason eq "close_file"){ print "ERROR: Cannot close file:$!.<BR>"; } else { print "Unspecified error ;-)<BR>"; } }