1 | #!/bin/sh |
---|
2 | #file=ftp_index |
---|
3 | #ftp_index for root interactive ftp, |
---|
4 | #ftp_index [[/]name/rep1/../repn/[file] [download|display]]. |
---|
5 | #1-A directory specification (../repn/) should end with one "/", |
---|
6 | # a file specification (..file) should not. |
---|
7 | #2-If present, the directory/file argument should start with a name |
---|
8 | # which is to be found as the first word of one line in the "ftp.conf" file : |
---|
9 | #3-The directory found on this line is then substituted to the first name |
---|
10 | # part of the argument to form the real directory to be accessed on the |
---|
11 | # host for the user. |
---|
12 | # |
---|
13 | conf=/usr/local/etc/httpd/adm/conf/ftpgeisa.conf |
---|
14 | HTTP_REFERER=1 |
---|
15 | export HTTP_REFERER |
---|
16 | if [ -n "$1" ];then #ftp?dir|file |
---|
17 | if [ `expr "$1" : ".*/$"` -ne 0 ];then isdir=1; set `expr "$1" : "/*\(.*\)/"`; fi |
---|
18 | name=`expr "$1" : "/*\([^/]*\)"` |
---|
19 | line=`grep "^[ | ]*$name/*[ | ]*" $conf` |
---|
20 | name=`expr "$line" : "[ | ]*\([^ |^ ]*\)"` |
---|
21 | host=`expr "$line" : "[ | ]*[^ |^ ]*[ | ]*\([^ |^ ]*\)"` |
---|
22 | user=`expr "$line" : "[ | ]*[^ |^ ]*[ | ]*[^ |^ ]*[ | ]*\([^ |^ ]*\)"` |
---|
23 | root=`expr "$line" : "[ | ]*[^ |^ ]*[ | ]*[^ |^ ]*[ | ]*[^ |^ ]*[ | ]*\([^ |^ ]*\)"` |
---|
24 | dir=$root/`expr "$1" : "/*[^/]*/*\(.*\)"` |
---|
25 | if [ -z "$isdir" ];then #file |
---|
26 | ftp_file $host $user `dirname $dir` `basename $dir` 0 $2 |
---|
27 | else |
---|
28 | ftp_dir $host $user $dir $1 $root |
---|
29 | fi |
---|
30 | exit 0 |
---|
31 | fi |
---|
32 | echo content-type: text/html |
---|
33 | echo |
---|
34 | echo "<html><head><title>Index of /</title></head><body><h1><img src=/icons-ftpgeisa/ftp.gif89><br><br>Index of /</h1>" |
---|
35 | echo "<pre> Name<hr>" |
---|
36 | { |
---|
37 | while read n h u d e; do [ -z "$n" -o `expr "$n" : "#"` -ne 0 ]&&continue |
---|
38 | if [ "$e" = "+" ];then #expand now |
---|
39 | ftp_dir $h $u $d $n $d STRIP |
---|
40 | else #link now |
---|
41 | #root=$r=$5 is required only if $d doesn't start with `/' |
---|
42 | if [ `expr "$d" : '\/'` -ne 0 ];then r=+$d; else r=; fi |
---|
43 | echo "<a name=$n href=/cgi-ftpgeisa/ftp_dir?$h+$u+$d+$n+$d><img src=/icons-ftpgeisa/menu.gif alt=[DIR] border=0> $n</a>" |
---|
44 | fi #expand/link_now |
---|
45 | done |
---|
46 | } < $conf |
---|
47 | echo "</pre></body></html>" |
---|