slitaz-forge view irc/index.cgi @ rev 597
No RPI version 2 support
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sat Aug 08 18:44:40 2015 +0200 (2015-08-08) |
parents | 19d1777dff8d |
children | f56d6ce4c4c7 |
line source
1 #!/bin/sh
2 #
3 # Small CGI example to display TazIRC Log Bot logs.
4 #
5 . /usr/lib/slitaz/httphelper
7 host="irc.freenode.net"
8 chan="slitaz"
9 logdir="log/$host/$chan"
11 # HTML 5 header
12 html_header() {
13 cat lib/header.html | sed -e s!'%LOG%'!"$log"!g
14 }
16 # HTML 5 footer
17 html_footer() {
18 if [ -f "lib/footer.html" ]; then
19 cat $tiny/lib/footer.html
20 else
21 cat << EOT
23 <!-- End content -->
24 </div>
26 <div id="footer">♥</div>
28 </body>
29 </html>
30 EOT
31 fi
32 }
34 # Handle GET actions
35 case " $(GET) " in
36 *\ log\ *)
37 # Display a daily log
38 log="$(GET log)"
39 header
40 html_header
41 echo "<h2>#${chan} $log</h2>"
42 IFS="|"
43 cat ${logdir}/${log}.log | while read time user text
44 do
45 cat << EOT
46 <div class="box">
47 <span class="date">[$time]</span> <span style="color: #36C;">$user:</span> $text
48 </div>
49 EOT
50 done
51 unset IFS
52 html_footer ;;
53 *\ webirc\ *)
54 # Web IRC
55 log="#slitaz"
56 header
57 html_header
58 cat << EOT
59 <div style="text-align: center;">
60 <iframe
61 src="http://webchat.freenode.net?channels=%23slitaz&uio=OT10cnVlJjExPTI0Ng32"
62 width="647" height="400">
63 </iframe>
64 </div>
65 EOT
66 html_footer ;;
67 *)
68 # Info, log list and stats.
69 log="Logs"
70 header
71 html_header
72 cat << EOT
73 <h2>Welcome to SliTaz IRC World!</h2>
74 <p>
75 This service lets you read online the SliTaz IRC support channel on
76 Freenode and provides a <a href="?webirc">web IRC client</a>. On a
77 SliTaz system you can also use a graphical or a text mode IRC client
78 such as Xchat or TazIRC:
79 </p>
80 <pre>
81 $ tazirc irc.freenode.net [nick] slitaz
82 </pre>
84 <h2>#${chan} $log</h2>
86 <pre>
87 EOT
88 for log in $(ls $logdir/*.log | sort -r -n)
89 do
90 count="$(wc -l $log | awk '{print $1}')"
91 log="$(basename ${log%.log})"
92 echo "<a href='?log=$log'>$log</a> $count messages"
93 done
94 echo "</pre>"
95 total=$(wc -l ${logdir}/*.log | tail -n 1 | awk '{print $1}')
96 echo "<p>Total: $total messages</p>"
97 unset IFS
98 html_footer
99 esac
101 exit 0