#!/bin/bash

echo 'Content-Type: text/html; charset=utf-8'
echo ''

urldecode() { : "${*//+/ }"; echo -e "${_//%/\\x}"; }

clock=$(cat append.txt | awk '{print$2}')
name=$(cat append.txt | awk -F'=' '{gsub(/&comment/,"<br>")}{print$2}')
logPASSx=$(cat append.txt)
logg=$(urldecode "$logPASSx" | awk 'BEGIN{FS=OFS="="} {print$1,$3}' | sed 's/name=//g')

cat <<- _EOF_
<head>
<style>
body {
  background-color: #458799;
  margin: 0px 0px;
}

h1 {
  color: #111111;
  margin-left: 20px;
}
.container {
  height: 200px;
  overflow: auto;
  display: flex;
  flex-direction: column-reverse;
}
table {
background-color: #CBCBCB;
margin: 5vh 12vw;
border-collapse: collapse;
border-radius:0.2em;
}

table, td, tr {
  box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);}
p {text-indent:20px;
padding:0.8vw 0.5vh;
font-size:1em;}
th>p
{font-size:1.2em;}
</style>
</head>
<body>
<h1>CHAT</h1>
<p>This is a chat, I know, I know.</p>
<table>
  <tr>
    <th>Comment</th>
  </tr>
  <tr>
    <td><div class="container">$logg</div></td>
  </tr>
</table>
<form action="pipe.sh" method="post">
Name: <input type="text" name="name"><br>
Comment: <input type="text" name="comment">
<input type="submit">
</form>
</body>
</html>

_EOF_
