source: trunk/ftp/cgi-bin/ftp_index @ 1

Last change on this file since 1 was 1, checked in by cbipsl, 18 years ago

Geisa inital import

File size: 1.9 KB
Line 
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#
13conf=/usr/local/etc/httpd/adm/conf/ftpgeisa.conf
14HTTP_REFERER=1
15export HTTP_REFERER
16if [ -n "$1" ];then #ftp?dir|file
17if [ `expr "$1" : ".*/$"` -ne 0 ];then isdir=1; set `expr "$1" : "/*\(.*\)/"`; fi
18name=`expr "$1" : "/*\([^/]*\)"`
19line=`grep "^[ |        ]*$name/*[ |    ]*" $conf`
20name=`expr "$line" : "[ |       ]*\([^ |^       ]*\)"`
21host=`expr "$line" : "[ |       ]*[^ |^ ]*[ |   ]*\([^ |^       ]*\)"`
22user=`expr "$line" : "[ |       ]*[^ |^ ]*[ |   ]*[^ |^ ]*[ |   ]*\([^ |^       ]*\)"`
23root=`expr "$line" : "[ |       ]*[^ |^ ]*[ |   ]*[^ |^ ]*[ |   ]*[^ |^ ]*[ |   ]*\([^ |^       ]*\)"`
24dir=$root/`expr "$1" : "/*[^/]*/*\(.*\)"`
25if [ -z "$isdir" ];then #file
26ftp_file $host $user `dirname $dir` `basename $dir` 0 $2
27else
28ftp_dir $host $user $dir $1 $root
29fi
30exit 0
31fi
32echo content-type: text/html
33echo
34echo "<html><head><title>Index of /</title></head><body><h1><img src=/icons-ftpgeisa/ftp.gif89><br><br>Index &nbsp;of &nbsp;/</h1>"
35echo "<pre>    Name<hr>"
36{
37while read n h u d e; do [ -z "$n" -o `expr "$n" : "#"` -ne 0 ]&&continue
38if [ "$e" = "+" ];then #expand now
39ftp_dir $h $u $d $n $d STRIP
40else #link now
41#root=$r=$5 is required only if $d doesn't start with `/'
42if [ `expr "$d" : '\/'` -ne 0 ];then r=+$d; else r=; fi
43echo "<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>"
44fi #expand/link_now
45done
46} < $conf
47echo "</pre></body></html>"
Note: See TracBrowser for help on using the repository browser.