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

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

Geisa inital import

File size: 1.8 KB
Line 
1#!/bin/sh
2#file=ftp_index
3#ftp_index for root interactive ftp,
4#ftp_index?[/]name/rep2/..../repn/ for subdirectory interactive ftp,
5#ftp_index?[/]name/rep2/repn/file[+[download|display]] for file direct ftp.
6#1.-IF PRESENT, THE DIRECTORY/FILE ARGUMENT SHOULD BE SEPARATED
7#FROM THE COMMAND WITH A `?'.
8#2-IF PRESENT, THE DIRECTORY/FILE ARGUMENT SHOULD START WITH A NAME
9#FOUND IN THE FTP.CONF FILE :
10#THE ROOT DIRECTORY FOR THIS NAME IS THEN SUBSITUTED
11#AND APPLIED TO THE MATCHING HOST AND USER.
12#3.-A DIRECTORY SPECIFICATION SHOULD END WITH ONE "/",
13#A FILE SPECIFICATION SHOULD NOT.
14#
15conf=/usr/local/etc/httpd/adm/conf/ftpgeisa.conf
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" : "/*[^/]*/*\(.*\)"`
25HTTP_REFERER=1
26export HTTP_REFERER
27if [  -z "$isdir" ];then #file
28ftp_file $host $user `dirname $dir` `basename $dir` 0 $2
29else
30ftp_dir $host $user $dir $1 $root
31fi
32exit 0
33fi
34echo content-type: text/html
35echo
36echo "<html><head><title>Index of /ftp</title></head><body><h1><img src=/icons-ftpgeisa/ftp.gif89><br><br>Index &nbsp;of &nbsp;/</h1>"
37echo "<pre>    Name<hr>"
38{
39while read n h u d; do [ -z "$n" -o `expr "$n" : "#"` -ne 0 ]&&continue
40#root=$r=$5 is required only if $d doesn't start with `/'
41if [ `expr "$d" : '\/'` -ne 0 ];then r=+$d; else r=; fi
42echo "<a name=$n href=/cgi-ftpgeisa/ftp_dir?$h+$u+$d+$n$r><img src=/icons-ftpgeisa/menu.gif alt=[DIR] border=0> $n</a>"
43done
44} < $conf
45echo "</pre></body></html>"
Note: See TracBrowser for help on using the repository browser.