slitaz-base-files view rootfs/var/www/cgi-bin/index.cgi @ rev 318

Add Japanese translations (thanks Keiichi Shiga)
author Aleksej Bobylev <al.bobylev@gmail.com>
date Tue Jan 10 12:30:48 2017 +0200 (2017-01-10)
parents 0a476090cd09
children
line source
1 #!/bin/sh
2 #
3 # Directory lister for BusyBox HTTPd
4 # Copyright (C) 2014 SliTaz GNU/Linux - BSD License
5 #
6 . /usr/lib/slitaz/httphelper.sh
7 header
9 # Security check
10 case "$QUERY_STRING" in
11 ..*) echo "Security exit" && exit 1 ;;
12 esac
14 # HTML5 head
15 cat <<EOT
16 <!DOCTYPE html>
17 <html lang="en">
18 <head>
19 <meta charset="UTF-8">
20 <title>Index of /$QUERY_STRING</title>
21 <link rel="stylesheet" href="/style.css">
22 <style>
23 #header h1 { width: auto; }
24 ul { line-height: 1.5em; } li { color: #666; }
25 </style>
26 </head>
27 <body>
28 <div id="header">
29 <h1>Index of /$QUERY_STRING</h1>
30 </div>
31 <section id="content">
32 <div>Files: $(ls ../$QUERY_STRING | wc -l)</div>
33 <ul>
34 EOT
36 [ "$QUERY_STRING" ] && echo '<li><a href="../">../</a></li>'
38 # We need ?/path
39 for i in $(ls -p ../$QUERY_STRING)
40 do
41 if [ -f "../$QUERY_STRING/$i" ]; then
42 echo "<li><a href='/${QUERY_STRING}${i}'>$i</a></li>"
43 else
44 echo "<li><a href='/${QUERY_STRING}${i}?${QUERY_STRING}${i}'>$i</a></li>"
45 fi
46 done
48 cat << EOT
49 </ul>
50 </section>
51 <footer id="footer"></footer>
52 </body>
53 </html>
54 EOT