#!/bin/sh #file=ftp_index #ftp_index for root interactive ftp, #ftp_index [[/]name/rep1/../repn/[file] [download|display]]. #1-A directory specification (../repn/) should end with one "/", # a file specification (..file) should not. #2-If present, the directory/file argument should start with a name # which is to be found as the first word of one line in the "ftp.conf" file : #3-The directory found on this line is then substituted to the first name # part of the argument to form the real directory to be accessed on the # host for the user. # conf=/usr/local/etc/httpd/adm/conf/ftpgeisa.conf HTTP_REFERER=1 export HTTP_REFERER if [ -n "$1" ];then #ftp?dir|file if [ `expr "$1" : ".*/$"` -ne 0 ];then isdir=1; set `expr "$1" : "/*\(.*\)/"`; fi name=`expr "$1" : "/*\([^/]*\)"` line=`grep "^[ | ]*$name/*[ | ]*" $conf` name=`expr "$line" : "[ | ]*\([^ |^ ]*\)"` host=`expr "$line" : "[ | ]*[^ |^ ]*[ | ]*\([^ |^ ]*\)"` user=`expr "$line" : "[ | ]*[^ |^ ]*[ | ]*[^ |^ ]*[ | ]*\([^ |^ ]*\)"` root=`expr "$line" : "[ | ]*[^ |^ ]*[ | ]*[^ |^ ]*[ | ]*[^ |^ ]*[ | ]*\([^ |^ ]*\)"` dir=$root/`expr "$1" : "/*[^/]*/*\(.*\)"` if [ -z "$isdir" ];then #file ftp_file $host $user `dirname $dir` `basename $dir` 0 $2 else ftp_dir $host $user $dir $1 $root fi exit 0 fi echo content-type: text/html echo echo "Index of /



Index  of  /

" echo "
    Name
" { while read n h u d e; do [ -z "$n" -o `expr "$n" : "#"` -ne 0 ]&&continue if [ "$e" = "+" ];then #expand now ftp_dir $h $u $d $n $d STRIP else #link now #root=$r=$5 is required only if $d doesn't start with `/' if [ `expr "$d" : '\/'` -ne 0 ];then r=+$d; else r=; fi echo "[DIR] $n" fi #expand/link_now done } < $conf echo "
"