3 for n in "$@"; do case ${n%%=*} in
4 data) _DATA="${n#data=}";;
5 exec) _exec="${n#exec=}";;
9 [ -z "${_EXEC%/}" ] && _EXEC="$(realpath "${0%/*}")" || _EXEC="${_EXEC%/}"
10 [ -z "${_DATA%/}" ] && _DATA=. || _DATA="${_DATA%/}"
12 file_pattern='^.*\.(mov|ts|mpg|mpeg|mp4|m4v|avi|mkv|flv|sfv|wmv|ogm|ogv|webm|iso|rmvb)$'
14 . "$_EXEC/cgilite/cgilite.sh"
18 ORDER="$(GET o |grep -m1 -axE 'Date|Name|Length' || printf Name)"
19 LISTSIZE="$(COOKIE pagesize |grep -m1 -axE '[1-9][0-9]*' || printf 50)"
20 ITEM="$(PATH "${PATH_INFO#/}")"
25 SET_COOKIE +$((86400 * 90)) pagesize="$(POST pagesize |grep -m1 -axE '[1-9][0-9]*' || printf 50)"
26 SET_COOKIE +$((86400 * 90)) mode="$(POST mode |grep -m1 -axE 'browse|index' || printf browse)"
27 SET_COOKIE +$((86400 * 90)) fakemp4="$(POST fakemp4 |grep -m1 -axE 'yes' || printf no)"
28 REDIRECT "$(POST ref)"
31 bm="$_DATA/.index/bookmarks"
32 . "$_EXEC/cgilite/storage.sh"
34 s="$(POST search |STRING)"; f="$(POST filter |STRING)"
36 grep -avF " search=$s filter=$f${CR}" "$bm" >"$bm.tmp"
37 [ ! "$(POST delete)" ] \
38 && printf '%s search=%s filter=%s\r\n' \
39 "$(POST name |STRING)" "$s" "$f" >>"$bm.tmp"
43 REDIRECT "$(POST ref)"
47 if [ "$ITEM" = "/style.css" ]; then
48 . "$_EXEC/cgilite/file.sh"
49 [ -r "$_DATA/$ITEM" ] && FILE "$_DATA/$ITEM" \
50 || FILE "$_EXEC/style.css"
51 elif [ -f "$_DATA/$ITEM" ]; then
56 . "$_EXEC/cgilite/file.sh"
57 index="$_DATA/${ITEM%/*}/.index"
58 thumb="$index/${ITEM##*/}"; thumb="${thumb%.*}.jpg"
59 [ -d "$index" -a \! -f "$thumb" ] \
60 && file="$_DATA/$ITEM" . "$_EXEC/thumbnail.sh"
65 *) . "$_EXEC/cgilite/file.sh"
66 fakemp4="$(COOKIE fakemp4)"
67 FILE "$_DATA/$ITEM" "$([ "$fakemp4" = yes ] && printf 'video/mp4')"
70 elif [ -d "$_DATA/$ITEM" ]; then
73 . "$_EXEC/advsearch.sh"
76 if [ "$(POST spawn)" = spawn ]; then
77 case "$(POST recursive)" in
78 yes) find "$_DATA/$ITEM" \
79 -depth -type d \! -name .index \
80 -exec mkdir -p '{}'/.index \;
82 *) mkdir -p "$_DATA/$ITEM/.index";;
85 . "$_EXEC/multitag.sh"
87 REDIRECT "$(POST ref)"
93 printf 'Status: 404 Not Found\r\nContent-Length 0:\r\n\r\n'