#!/bin/sh _EXEC=. _DATA=. SESSION_TIMEOUT=43200 . "$_EXEC/cgilite/logging.sh" . "$_EXEC/cgilite/cgilite.sh" . "$_EXEC/cgilite/session.sh" . "$_EXEC/cgilite/storage.sh" LOCATION="$(PATH "$PATH_INFO")" LOCATION="${LOCATION#/}" LOCATION="${LOCATION%%/*}" yield_page(){ page="$1" printf '%s\r\n' 'Content-Type: text/html; charset=utf-8' \ "Content-Security-Policy: script-src 'none'" \ '' { printf '[html [head [meta name="viewport" content="width=device-width"] [link rel="stylesheet" type="text/css" href="/webchat.css"] [title Webchat] ] [body class="%s" ' "$page" [ "$QUERY_STRING" = settings ] && settings_menu cat printf '] ]' } |"$_EXEC/cgilite/html-sh.sed" -u } settings_menu(){ printf ' [form #settings method="POST" action="?settings" [hidden "session_key" "%s"] [h1 Settings][a .settings href="?" Close] ' "$SESSION_KEY" if [ "$ERROR" ]; then printf '[p .error %s %s]' "${ERROR%% *}" "$(HTML "${ERROR#.* }")" unset ERROR fi printf ' [a .section href="#nick" Nickname] [div #nick [input name="nickname" value="%s"][submit "action" "nick" Set Cookie]] ' "$(HTML "${nickname#\?}")" printf ' [a .section href="#register" Register Nickname] [div #register [p Registration will set a permanent Cookie in your Browser. Registration requires neither a password, nor an email address.] [input name="regnick" value="%s"][submit "action" "register" Register] ]' "$(HTML "${nickname#\?}")" printf ']' } . "$_EXEC/usernick.sh" case ${LOCATION} in webchat.css) . "$_EXEC/cgilite/file.sh" FILE "$_EXEC/webchat.css" exit 0 ;; \&?*) chatfile="$_DATA/${LOCATION}/channel" . "$_EXEC/channel.sh" exit 0 ;; @?*) if [ -d "$_DATA/${LOCATION}" ]; then chatfile="$_DATA/${LOCATION}/?${SESSION_ID}" . "$_EXEC/channel.sh" else REDIRECT / fi exit 0 ;; ~?*) if [ -d "$_DATA/@${LOCATION#~}" ]; then pubinfo="$_DATA/@${LOCATION#~}/pubinfo" else # ToDo Edit / Display of public user information REDIRECT / fi ;; '') yield_page front <<-EOF Front EOF ;; *) REDIRECT / ;; esac