-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathirclogger_log
executable file
·124 lines (107 loc) · 2.93 KB
/
irclogger_log
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/bin/bash
set -a
. irclogger_cgiparse
. irclogger_common
PATH="$PATH:/usr/local/bin:$PWD"
GCF=4
cachedir="${cachedir:-/tmp/.irclogger_logs_cache}"
[ -n "$cachepages" ] && do_cachepages=true || do_cachepages=false
date="$FORM_date"
raw="$FORM_raw"
tml="$FORM_tml"
text="$FORM_text"
urls="$FORM_urls"
sel="$FORM_sel"
CHAN=${PATH_INFO#/}
CHAN=${CHAN:-main}
mimetype=text/plain
if test ! -d $logsdir/$CHAN; then
echo 'Content-type: text/html; charset: ISO-8859-1';echo
echo "Cannot list channel $CHAN (no dir $logsdir/$CHAN)"
exit 0
fi
STYLE=
cd $logsdir
if [ -e style.css ]; then STYLE="`cat style.css`";fi
cd $logsdir/$CHAN
if [ -e style.css ]; then STYLE="$STYLE`cat style.css`";fi
gzip=off;case "$HTTP_ACCEPT_ENCODING" in *gzip*)gzip=on;;esac
#check perms
if acces_protected "$CHAN"
then header="$private_image Logs of this channel are protected by a password that you can <a href='${SCRIPT_NAME%/*}/irclogger_password_a/$CHAN'>change</a>.<p>"
else
if protectable "$CHAN"
then header="Logs of this channel are not protected. You can <a href='${SCRIPT_NAME%/*}/irclogger_password/$CHAN'>protect them by a password</a>.<p>"
else header=
fi
fi
error_file_not_found() {
cat << EOF
Content-type: text/html
<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">
<html><head><title>ERROR</title>
<meta http-equiv='Content-Type' content='text/html; charset=ISO-8859-1'>
<style type='text/css'> $STYLE </style>
</head><body><h1>ERROR</h1> File <tt>$date.log</tt> not found!!!
</body></html>
EOF
exit 0
}
catz() { case "$1" in *.gz) zcat "$1";; *) cat "$1";; esac; }
compress_cache() { gzip -qk9 $cache; }
emitheader() {
if [ "$gzip" = on ]; then
echo "Content-Type: $mimetype"; echo "Content-Encoding: gzip"; echo
else
echo "Content-Type: $mimetype"; echo
fi
}
emitcache() {
if [ "$gzip" = on ]; then cat $cache.gz
else cat $cache
fi
}
emitstream() { if [ "$gzip" = on ]; then gzip -$GCF; else cat; fi; }
if [ -z "$date" ]; then
echo "Location: $CHAN?date=`date -u +'%Y-%m-%d,%a'`";echo
fi
case "$date" in *,*):;;*)date="`date -d $date +'%Y-%m-%d,%a'`";;esac
log=$date.log
if [ ! -e $log ]; then
log=$date.log.gz
if [ ! -e $log ]; then error_ file_not_found
fi
fi
if [ "$raw" = on ]; then
ext=raw
gen() { cat; }
elif [ "$tml" = on ]; then
ext=tml
gen() { irclogger_totml $CHAN $date "$sel" "$conffile" "$header" "$log"; }
elif [ "$text" = on ]; then
ext=txt
gen() { irclogger_totext $CHAN $date "$sel" "$conffile" "$header" "$log"; }
else
mimetype=text/html
ext=html
gen() { irclogger_tohtml $CHAN $date "$sel" "$conffile" "$header" "$log" "$urls"; }
fi
if $do_cachepages; then
cachepagedir="$cachedir`/bin/pwd`/PAGES/$CHAN/"
mkdir -p $cachepagedir
cache=$cachepagedir$date.$ext
if ! [ $cache -nt $log ]; then
catz $log | gen >$cache
compress_cache
fi
emitheader
emitcache
else
emitheader
catz $log | gen | emitstream
fi
exit 0
### EMACS MODES
### Local Variables: ***
### mode:ksh ***
### End: ***