ShellSpider/index.sh

62 lines
982 B
Bash
Raw Normal View History

#!/bin/bash
2017-11-18 22:52:03 +00:00
. $1
2017-11-18 22:52:03 +00:00
setStatusCode 200
cat <<EOF
<!DOCTYPE>
<html>
<head>
2017-11-18 22:52:03 +00:00
<title>Index of ${server[path]}</title>
</head>
<body>
2017-11-18 22:52:03 +00:00
<h1>Index of ${server[path]}</h1>
<hr />
<table>
<tr>
<th>
Name
</th>
<th>
Type
</th>
<th>
Executeable
</th>
<th>
Size
</th>
</tr>
EOF
2017-11-19 00:22:21 +00:00
for file in $(ls -a "${server[real_path]}"); do
2017-11-18 22:52:03 +00:00
if test "$file" = ".." -a "${server[path]}" = "/"; then
continue;
fi
cat <<EOF
<tr>
<td>
2017-11-18 22:52:03 +00:00
<a href="$(realpath -sm "${server[path]}/$file")">$file</a>
</td>
<td>
2017-11-19 00:22:21 +00:00
$(file -b "${server[real_path]}/$file")
</td>
<td>
2017-11-19 00:22:21 +00:00
$(if test ! -d "${server[real_path]}/$file"; then if test -x "${server[real_path]}/$file"; then echo yes; else echo no; fi; fi)
</td>
<td>
2017-11-19 00:22:21 +00:00
$(if test ! -d "${server[real_path]}/$file"; then du -kh "${server[real_path]}/$file" | cut -f1; fi)
</td>
</tr>
EOF
done
cat <<EOF
</table>
<hr />
2017-11-18 22:52:03 +00:00
${headers[Host]} (${settings[server]})
</body>
</html>
EOF