SHOW:
|
|
- or go back to the newest paste.
1 | #!/bin/sh | |
2 | ||
3 | Header () | |
4 | { | |
5 | echo -en "Content-Type: text/html\r\n\r\n" | |
6 | - | echo "<html><head><title>test</title></head><body>"; |
6 | + | echo "<html><head><title>test</title></head><body>" |
7 | } | |
8 | ||
9 | - | FileExists () |
9 | + | IsDirectoryMatch () |
10 | { | |
11 | - | # In case "[ -d FILE]" (busybox?) Does not work |
11 | + | case "$1" in |
12 | */) return 0 ;; | |
13 | - | # Run any file access functions, suppored by busybox and |
13 | + | *) return 1 ;; |
14 | - | # return status to caller |
14 | + | esac |
15 | } | |
16 | - | tail -n 1 $1 > /dev/null |
16 | + | |
17 | IsDirectory () | |
18 | { | |
19 | result=$(ls -dp $1) | |
20 | IsDirectoryMatch "$result" | |
21 | } | |
22 | ||
23 | Main () | |
24 | { | |
25 | for file in "../$QUERY_STRING"/* | |
26 | - | if FileExists "$file" ; then |
26 | + | |
27 | b=${file##*/} | |
28 | #echo "<a href='../$b'>$b</a><br/>" | |
29 | ||
30 | if IsDirectory "$file" ; then | |
31 | echo "<a href='test.cgi?$QUERY_STRING/$b'>$b</a><br/>" | |
32 | else | |
33 | echo "<a href='$QUERY_STRING/$b'>$b</a><br/>" | |
34 | fi | |
35 | done | |
36 | ||
37 | echo "</body></html>"; | |
38 | } | |
39 | ||
40 | Header | |
41 | Main | |
42 | ||
43 | # End of file |