6 . "$_EXEC/cgilite/logging.sh"
7 . "$_EXEC/cgilite/cgilite.sh"
8 . "$_EXEC/cgilite/session.sh"
9 . "$_EXEC/cgilite/storage.sh"
11 LOCATION="$(PATH "$PATH_INFO")"
12 LOCATION="${LOCATION#/}"
13 LOCATION="${LOCATION%%/*}"
15 NICK_REGISTRATION="${NICK_REGISTRATION:-on}"
16 CHANNEL_LIST="${CHANNEL_LIST:-off}"
19 # COOKIE_NICK_EXPIRE=$((86400 * 14))
20 # REGEISTERED_NICK_EXPIRE=$((86400 * 365))
24 printf '%s\r\n' 'Content-Type: text/html; charset=utf-8' \
25 "Content-Security-Policy: script-src 'none'" \
29 [meta name="viewport" content="width=device-width"]
30 [link rel="stylesheet" type="text/css" href="/webchat.css"]
34 [ "$QUERY_STRING" = settings ] && settings_menu
37 } |"$_EXEC/cgilite/html-sh.sed" -u
41 local nick="$(HTML "${nickname#\?}")"
43 [form #settings method="POST" action="?settings"
44 [hidden "session_key" "%s"]
45 [h1 Settings][a .settings href="?" Close]
48 printf '[p .error %s %s]' "${ERROR%% *}" "$(HTML "${ERROR#.* }")"
51 if [ "$NICK_REGISTRATION" != on -o "$nickname" = '?Guest' ]; then
53 [a .section href="#nick" Nickname]
54 [div #nick .open [input name="nickname" placeholder="%s"][submit "action" "nick" Set Cookie]]
58 [a .section href="#nick" Nickname]
59 [div #nick [input name="nickname" placeholder="%s"][submit "action" "nick" Set Cookie]]
60 [a .section href="#register" Register Nickname]
62 [p Registration will set a permanent Cookie in your Browser.
63 Registration requires neither a password, nor an email address.]
64 [input name="regnick" value="%s"][submit "action" "register" Register]
70 . "$_EXEC/usernick.sh"
74 . "$_EXEC/cgilite/file.sh"
75 FILE "$_EXEC/${LOCATION}"
79 [ "$(COOKIE nick)" -o "$QUERY_STRING" = settings ] || REDIRECT "/$LOCATION?settings#nick"
80 chatfile="$_DATA/${LOCATION}/channel"
85 if [ -d "$_DATA/${LOCATION}" ]; then
86 chatfile="$_DATA/${LOCATION}/?${SESSION_ID}"
94 if [ -d "$_DATA/@${LOCATION#~}" ]; then
95 pubinfo="$_DATA/@${LOCATION#~}/pubinfo"
97 # ToDo Edit / Display of public user information
102 if [ "$(POST action)" = join ]; then
103 REDIRECT "./&$(POST channel |URL)"
105 yield_page front <<-EOF
108 [label Join Channel: [input name=channel value='' placeholder="Name of Channel"][button type=submit name=action value=join Join]]
110 $(if [ "$CHANNEL_LIST" = on ]; then
111 printf '[h2 Existing channels][div #channels'
112 for chan in "$_DATA/&"*; do
113 printf '[a href="./%s" . %s]\n' "$(HTML "${chan##*/}")" "$(HTML "${chan##*/}")"