printf "HTTP/1.0 200 OK
${cfg[extra_headers]}\r\n\r\n"
source templates/head.sh
printf "
Index of $([[ ${r[url]} == '' ]] && echo '/' || echo ${r[url]})
"
if [[ ${cookies[username]} != '' ]]; then
echo "Logged in as ${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 "$i | <DIR> | ${stats[5]} ${stats[6]} ${stats[7]} |
"
else
printf "$i | ${stats[4]}B | ${stats[5]} ${stats[6]} ${stats[7]} |
"
fi
done
printf "
HTTP.sh server on ${r[host]}
laura is cute
"