3 if [ -f "$chatfile" ]; then
4 read -r channelkey x <"$chatfile"
5 channelkey="$( printf '%s-%s' "$channelkey" "$SESSION_ID" |sha256sum)"
10 if mkdir "${_DATA}/${LOCATION}"; then
11 { randomid; printf ' '; STRING "$nickname"; echo; } >"$chatfile"
13 REDIRECT "$(URL "/$LOCATION")"
16 read lasttime x <<-EOFread
17 $(tail -n 50 "$chatfile" |grep -F " $(STRING "$nickname"): " |tail -n1)
19 if [ "$lasttime" ]; then
20 lasttime="$(date -d "${lasttime%_*} ${lasttime#*_}" +%s)"
24 if [ -f "$chatfile" -a "$channelkey" = "$(POST channelkey)" -a "$(POST timenonce)" -ge "$lasttime" ]; then
25 printf "%s %s: %s\n" "$(date +%F_%T)" "$(STRING "$nickname")" "$(POST message |STRING)" >>"$chatfile"
27 REDIRECT "$(URL "/$LOCATION")"
31 if [ ! -f "$chatfile" ]; then
32 yield_page create <<-EOF
33 [form #nonexist method="POST"
34 There is no channel named $(HTML "$LOCATION")
35 [submit "action" "create" Create]
39 printf '%s: %s\r\n' Refresh 1
41 [form #channel method="POST"
42 [submit "action" "submit" style="display: none;"]
43 [input type=hidden name=channelkey value="%s"][input type=hidden name=timenonce value="%s"]
44 [a .settings href="?settings#nick" Settings][input autocomplete="off" name="message" autofocus=true][submit "action" "submit" Send!]
46 ' "$channelkey" "$_DATE"
47 SHESCAPE='s;[]&<>#."[];\\&;g;'
49 while sleep 10; do printf '\n'; done &
51 tail --pid $$ -n50 -f "$chatfile" \
53 /^[^ ]+ [^ ]+ [^ ]+$/{
54 h; s;^([^ ]+) ([^ ]+) ([^ ]+)$;\1;; s;.*_;;; s;.+;[p .message [span .date &];p;
55 g; s;^([^ ]+) ([^ ]+) ([^ ]+)$;a\2;; bESC; :A s;.;;; s;(.)(.+);[span .nick [span .indicator \1]\2];p;
56 g; s;^([^ ]+) ([^ ]+) ([^ ]+)$;b\3;; bESC; :B s;.;;; s;.+;[span .message &]];p;
59 '"$UNSTRING"' '"$SHESCAPE"'