-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathirclogger_common
executable file
·66 lines (56 loc) · 1.62 KB
/
irclogger_common
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
# common file loaded by the bash irclogger_* files
# should be called from the BIN (cgi-bin) dir
conffile="${conffile:-irclogger.conf}"
if test -e "$conffile"; then
. "$conffile"
case "$conffile" in /*) :;; *) conffile="$PWD/$conffile";;
esac
fi
logsdir=${logsdir:-/var/log/irclogger}
passfile=${passfile:-/var/www/passwds/irclogger-passwds}
private_image="${private_image:-<img src='http://colaz.net/qbullets/private.gif' width=11 height=10 alt='Password-protected log'>}"
search_timeout="${search_timeout:-60}"
nl='
'
# $1=chan / return true if protected, false if free access
acces_protected () {
if protectable "$1"; then
protected_chans="`echo;cat $passfile`"
case "$protected_chans" in
*"$nl$1:"*) case "$SCRIPT_NAME" in
*_a) if [ "${REMOTE_USER#[#]}" != "$1" ]; then
wrong_user "${REMOTE_USER#[#]}" "$1"
fi ;;
*) if [ -n "$QUERY_STRING" ]; then qs="?$QUERY_STRING"
fi
echo "Location: ${SCRIPT_NAME}_a/$1$qs";echo;exit 0 ;;
esac
return 0;;
*) return 1;;
esac
else
return 1
fi
}
# $1=logged_as_user $2=chan
wrong_user () {
echo "Location: ${SCRIPT_NAME%/*}/nph-irclogger_reset_auth/$2";echo;exit 0
}
# $1=channel, returns true if can be protected
protectable () {
if [ -e "$logsdir/$1/PUBLIC" ]; then return 1; else return 0
fi
}
#------------------------------------------------------------------ style
# can be redefined by files style.sh in logs dirs
html_head () { :; }
html_header () { :; }
html_footer () { :; }
# $1=prefix $2=suffix rest=crumbs
html_breadcrumbs () {
:
}
### EMACS MODES
### Local Variables: ***
### mode:ksh ***
### End: ***