/* AwebFTP - FTP plug-in for Aweb
*/ vers="Version 1.3a (AmiTrix 2.1)"
/*
By Josef Faulkner (panther@gate.net) IRC: Josef
Modified by AmiTrix Development for inclusion with AWeb-II
Added config program and file
Fixed a couple bugs
Description:
ŻŻŻŻŻŻŻŻŻŻŻŻ
This plugin will allow you to do inline FTPing of files on the net,
without the need to call an external FTP program (except FTPMount, which
is transparent). It will distinguish between a directory and a file, and
act accordingly.
Features:
ŻŻŻŻŻŻŻŻŻ
o Fast reaction, since FTPMount does a lot of cacheing of dirs
o Asyncronous download (thanks to Aweb), you can continue browsing
while it downloads, and Aweb will inform you when the transfer
has completed!
o Brings up a requestor to ask what you want to save as
New for 1.1:
o You can now upload to the directory if you type the name of a file
in a form at the bottom of the list (or leave blank, and it will
give you a requester asking for a file)
o Make directories
o Delete a file (only one at a time, currently)
New for 1.2:
o WBCopy command used to copy files w/ progress meter
Thanks to Bastian H. Frank for developing this handy program!
New for 1.3:
o Much faster:
o No longer parses list output, uses lformat to create listing
o AmiFTP is now loadable from the inside!
o Will detect if amiftp is already loaded, and go to the directory
o Doesn't disconnect and reconnect if amiftp already has the host open
New for 1.3a:
o Plaincopy used by default for Aweb II Distribution.
o Fixed some minor bugs
Requirements:
ŻŻŻŻŻŻŻŻŻŻŻŻŻ
FTPMount version 8 (or newer) must be installed and running
available on Aminet:
FTPMount-1.0.lha comm/tcp 109K Mounts FTP sites
Copy command, choose one (set below, must be in your path):
plaincopy (included in this archive)
WBCopy (aminet/util/cli/WBCopy.lha) - Does progress meters
copy (comes with workbench) - has problems with softlinked files
AmiFTP (from http://www.lysator.liu.se/~lilja/AmiFTP.html)
To be launched by a button if a separate GUI is preferred!
(optional)
Installation:
ŻŻŻŻŻŻŻŻŻŻŻŻŻ
1) Put this script in the same directory that the Aweb executable is in.
2) Set Aweb to the following settings:
----------------------------------------------
Network 3: External Programs
ftp:
Command: sys:rexxc/rx
Arguments: awebftp.rexx %s %s %s <--- *** NOTE *THREE* %s's ***
----------------------------------------------
3) Put plainCopy in your path (ie C:)
4) Set your preferences for this script below:
Known Bugs:
ŻŻŻŻŻŻŻŻŻŻŻ
Linked files are sometimes thought to be directories in AmigaDOS, and
may wind up returning an empty directory listing instead of the actual
file.
I've attempted to correct this by checking if the link clicked on has a
period in the name, if so, it assumes it's a file instead.
Hopefully this bug is obsolete with the new copy program. Let me know if
you find any URL's that this still happens on.
Many people are getting "out of memory" errors. This should only be
occuring on old versions of AwebFTP, and usually only when they forget
to pass all three %s arguments in aweb's preferences.
*/
/****AwebFTP Preferences***********************************************/
savedir='RAM:' /* Default directory to download to */
copycommand='AWeb-II:plugins/AwebFTP/plaincopy' /* Set to program used to copy (use plaincopy for best compatibility) */
amiftpexe='' /* Path and name of your amiftp executable */
/* Change by Amitrix to get configuration from file and find the current */
/* AWeb Window */
options results
ports = show('P')
parse var ports dummy 'AWEB.' portnr .
address value 'AWEB.' || portnr
'GET ACTIVEPORT'
awebhost = result
if Open(config_fp,"AWebFtp.config",r) then
do
savedir = readln(config_fp)
amiftpexe = readln(config_fp)
call close(config_fp)
end
parse source prog_type result_flag called resolved ext host .
last_slash = lastpos('/',called)
last_colon = lastpos(':',called)
dir_pos = max(last_slash,last_colon)
if dir_pos > 0 then
current_dir = left(called,dir_pos)
else
current_dir = ''
Address value awebhost
if Open(config_fp,current_dir||"AWebFTP.config",r) then
do
save_dir = readln(config_fp)
AmiFTPexe = readln(config_fp)
call close(config_fp)
end
/* End AmiTrix Changes */
/**********************************************************************/
if ~show('L','rexxsupport.library') then
if ~addlib('rexxsupport.library',0,-30,0) then
exit 20
tmpfile='t:awebftp'time(S)'.html'
address command 'delete t:awebftp#? >NIL:'
parse arg cmds
/* Added by AmiTrix to Check for screen not being passed and FTP: not */
/* being mounted */
parse var cmds '"'server'"' '"'file'"' screen
if screen = '' then
do
'GET SCREEN'
screen = result
end
address command 'assign FTP: >NIL: exists'
if rc > 0 then
if exists('sys:storage/dosdrivers/ftp') then
address command 'mount ftp:'
/* End AmiTrix changes */
if left(upper(cmds),3)='URL' then do
do until cmds=''
parse var cmds name'="'value'"'cmds
if left(cmds,1)='&' then cmds=right(cmds,length(cmds)-1)
interpret name'=value'
end
select
when function='upload' then do
call open(1,tmpfile,w)
call writeln(1,'
About AwebFTP')
if (exists(file))&(file~='FILE') then do
address command 'copy 'text' 'url
if rc<20 then call writeln(1,'
Transfer Successful
'text' uploaded.
')
else call writeln(1,'
Error
Could not transfer 'text' to 'url'
')
end
else do
address command 'requestfile RAM: >t:awebftp.tmp'
call open(2,'t:awebftp.tmp',r)
text=readln(2)
call close(2)
if word(text,1)~='no' then do
parse var text .'"'text'"'.
if exists(text) then do
call putawebmsg('
Now uploading 'text' to 'url'.
You may continue using Aweb asyncronously (especially if file is long).')
address command 'copy 'text' 'url
if rc<10 then call writeln(1,'
')
end
call writeln(1,'')
call close(1)
'OPEN file://localhost/'tmpfile
exit
end
when function='makedir' then do
if file~='FILE' then do
if exists(url||file) then call putawebmsg("Directory already exists!")
else do
call putawebmsg("Making directory. Please wait.
(Ignore this if [Back]ing up)
")
address command 'makedir 'url||file
if rc<10 then call putawebmsg('Directory 'file' created successfully. Go Back')
else call putawebmsg("
Error
Directory was NOT created.")
end
end
else call putawebmsg("No directory specified.")
exit
end
when function='delete' then do
if file~='FILE' then do
if exists(url||file) then do
address command 'requestchoice "Delete File" "Delete 'file' ?" "Delete|Cancel" >t:awebftpchoice.tmp'
if open(1,'t:awebftpchoice.tmp',r) then do
text=readln(1)
if strip(text)='1' then do
address command 'delete 'url||file' >t:awebftp.tmp'
if rc<10 then call putawebmsg('File 'file' deleted. Go Back')
else call putawebmsg("
Error
Error with deletion")
end
else call putawebmsg("Delete Cancelled.")
end
end
else call putawebmsg('
Error
'file' does not exist!')
end
else call putawebmsg("No directory specified.")
exit
end
when function='amiftp' then do
parse var url 'ftp://'hostname'/'dirs
dirs='/'dirs
if showlist(P,'AMIFTP') then do
address 'AMIFTP' 'GETATTR STEM ainfo'
if (ainfo.HOST ~= hostname) then do
address 'AMIFTP' 'DISCONNECT'
address 'AMIFTP' 'SETATTR HOST' hostname
address 'AMIFTP' 'CONNECT NOSCAN'
end
address 'AMIFTP' 'CD' dirs
end
else do
address command amiftpexe
timeout=0
address command 'waitforport AMIFTP'
if (showlist(P,'AMIFTP')) then do
address 'AMIFTP' 'GETATTR STEM ainfo'
if (ainfo.HOST ~= hostname) then do
address 'AMIFTP' 'DISCONNECT'
address 'AMIFTP' 'SETATTR HOST' hostname
address 'AMIFTP' 'CONNECT NOSCAN'
end
address 'AMIFTP' 'CD' dirs
end
else do
putawebmsg('Error: Couldn''t run AmiFTP')
exit
end
end
end
otherwise do
call putawebmsg('Program Error: please mail author w/ errorcode: F-'function' and conditions under which it failed.')
end
end
exit
end
if server='about' then do
call open(1,tmpfile,w)
call writeln(1,'About AwebFTP')
call writeln(1,'
About AwebFTP 'word(vers,2)'
')
call writeln(1,'AwebFTP is an FTP plug-in arexx script for Aweb, which does FTP inside Aweb''s GUI, provided you have FTPMount installed')
call writeln(1,'
Features of AwebFTP
')
call writeln(1,'
Fast reaction, since FTPMount does caches dirs.')
call writeln(1,'
Inline - Stays within the Aweb GUI.')
call writeln(1,'
Asyncronous download (thanks to Aweb), you can continue browsing while it downloads, and Aweb will inform you when the transfer has completed!')
call writeln(1,'
Brings up a requestor to ask what you want to save as.')
call writeln(1,'
New for 1.1:
')
call writeln(1,'
You can now upload to the directory if you type the name of a file in a form at the bottom of the list (or leave blank, and it will give you a requester asking for a file)')
call writeln(1,'
Make directories')
call writeln(1,'
Delete a file (currently only one file at a time)')
call writeln(1,'
Title is now a link: click to refresh the list after send/makedir/delete, etc')
call writeln(1,'
New for 1.2:
')
call writeln(1,'
WBCopy command used to copy files with progress meter')
call writeln(1,' Thanks to Bastian H. Frank for developing this handy program!')
call writeln(1,'
New for 1.3:
')
call writeln(1,'
Much faster:
')
call writeln(1,'
No longer parses list output, uses lformat to create listing')
call writeln(1,'
AmiFTP can now be automatically loaded and set to the current dir!
');
call writeln(1,'
Will detect if amiftp is already loaded, and go to the directory');
call writeln(1,'
Doesn''t disconnect and reconnect if amiftp already has the host open');
call writeln(1,'
')
call writeln(1,'
Known Bugs
')
call writeln(1,'
Linked files are sometimes thought to be directories in AmigaDOS, and may wind up returning an empty directory listing instead of the actual file.')
call writeln(1,'
I''ve attempted to correct this by checking if the link clicked on has a period in the name, if so, it assumes it''s a file instead. Hopefully this bug is obsolete with the new copy program. Let me know if you find any URL''s that this still happens on.
')
call writeln(1,'
Many people are getting "out of memory" errors. This should only be occuring on old versions of AwebFTP, and usually only when they forget to pass all three %s arguments in aweb''s preferences. If this is still occuring in this version for you, PLEASE let me know the URL.')
call writeln(1,'
AwebFTP Author
')
call writeln(1,'
AwebFTP is written by me (panther@gate.net), Josef on IRC. I have also written a few other arexx scripts for Aweb, and over a hundred arexx scripts for Grapevine IRC client (mostly available on my home page.')
call writeln(1,'
Latest FTPMount from Aminet | Other Aweb Scripts | Other Net Applications')
call writeln(1,'')
call close(1)
'OPEN file://localhost/'tmpfile
exit
end
if server='upload' then do
end
do
if right(server,1)~='/' then server=server'/'
if length(file)>0 then do
filebk=file
dir=''
do until index(filebk,'/')=0
parse var filebk dirbk'/'filebk
dir=dir||dirbk'/'
end
file=filebk
url='ftp://'server||dir||file
end
else url='ftp://'server
call putawebmsg('Opening 'url' - Please wait.
(Ignore this if [Back]ing up)
')
if exists(url) then do
info=statef(url)
type=word(info,1)
if type='DIR' then do
if index(file,'.')>0 then type='FILE'
end
size=word(info,2)
select
when type='DIR' then do
if right(url,1)~='/' then url=url'/'
call open(2,tmpfile,w)
call writeln(2,''url'')
call writeln(2,'')
end
else do
call writeln(2,'')
end
call writeln(2,'
')
call writeln(2,'')
call writeln(2,'')
call writeln(2,'')
call writeln(2,'AwebFTP 'vers' by Josef Faulkner.')
call writeln(2,'')
call close(1)
call close(2)
'open file://localhost/'tmpfile
'ALLOWCMD'
end
when type='FILE' then do
if open(11,url,r) then do
call close(11)
address command 'requestchoice "AWebFTP" "View or Save 'file'?" "View|Save|Cancel" pubscreen="'screen'" >t:awebftpchoice.tmp'
call open(1,'t:awebftpchoice.tmp',r)
text=readln(1)
call close(1)
select
when text=0 then do
call putawebmsg('Transfer aborted.')
end
when text=1 then do
call putawebmsg('Downloading 'url' to view in Aweb.')
address command copycommand' 'url' 'tmpfile' >nil:'
'open file://localhost/'tmpfile
end
when text=2 then do
address command 'requestfile drawer='savedir' file='file' pubscreen='screen' >'tmpfile
call open(1,tmpfile,r)
text=readln(1)
call close(1)
if left(text,7)~='no more' then do
call putawebmsg('Downloading 'file' ('size' bytes). You may resume using Aweb, and a message will appear when transfer is complete.')
address command copycommand' 'url' 'text' >nil:'
call putawebmsg('Download of 'file' to 'text' complete.')
end
else do
call putawebmsg('Transfer aborted.')
end
end
otherwise do
call putawebmsg('Strange Arexx bug. Inform author of AwebFTP bug #2-'text)
exit
end
end
end
else do
call putawebmsg('Sorry, could not open 'url' for read access.')
end
end
otherwise do
call putawebmsg('Strange Arexx bug. Inform author of AwebFTP bug #1-'type)
exit
end
end
end
else do
call putawebmsg('Sorry, 'url' doesn''t exist.')
end
end
exit
PUTAWEBMSG: procedure
parse arg text
address command 'delete t:awebmsg#?.html >NIL:'
fname='t:awebmsg'time(S)'.html'
call open(4,fname,w)
call writeln(4,'AwebFTP Message')
call writeln(4,'