3 # shows the directory passed as the first parameter.
4 # if there's a second parameter, it's used for a filtering pattern.
8 echo "Content-type: text/html"
16 if [ ! -z "$temp_pat" ]; then
17 # we don't allow any clever scooting up the directory hierarchy...
18 if [ -z "$(echo "$temp_pat" | grep "\.\.")" ]; then
23 # check that they've at least provided a directory.
24 if [ -z "$dir" ]; then
26 echo "$(basename $0): This needs a directory name before it can show the folder."
30 # make sure they aren't trying to go above the web root.
31 if [ ! -z "$(echo "$dir" | grep "\.\.")" ]; then
32 echo "$(basename $0): Will not go above the root web directory."
42 fulldir="/var/www/$dir"
44 for i in "$fulldir"/$pattern; do
45 dirlisting="$(ls -dsh $i | sed -e 's/ \/.*$//')"
46 echo "<a href=\"$(basename $i)\">$(basename $i) ($dirlisting)</a> <br>"