printf "HTTP/1.0 200 OK
${cfg[extra_headers]}\r\n\r\n"
source templates/head.sh
printf "
Index of $([[ ${r[url]} == '' ]] && echo '/' || echo $(html_encode ${r[url]}))
"
if [[ ${cookies[username]} != '' ]]; then
echo "Logged in as $(html_encode ${cookies[username]})"
fi
printf "
File |
Size |
Date |
.. | | |
"
IFS=$'\n'
for i in $(ls ${r[uri]}); do
unset IFS
stats=($(ls -hld "${r[uri]}/$i")) # -hld stands for Half-Life Dedicated
if [[ -d "${r[uri]}"'/'"$i" ]]; then
printf "$(html_encode "$i") | <DIR> | ${stats[5]} ${stats[6]} ${stats[7]} |
"
else
printf "$(html_encode "$i") | ${stats[4]}B | ${stats[5]} ${stats[6]} ${stats[7]} |
"
fi
done
printf "
HTTP.sh server on $(html_encode ${r[host]})
laura is cute
"