diff --git a/index.js b/index.js
index 0e60efe..bd6ba65 100644
--- a/index.js
+++ b/index.js
@@ -1,3 +1,5 @@
+require('hashcode.js')
+
const Express = require('express')
const bdb = require('bdb.js')
const posts = bdb.load('posts.json', 1)
@@ -43,7 +45,7 @@ server.all('/', function get(req, res) {
mainPage.comments.push({timestamp: posts[i].timestamp, author: posts[i].author, title: posts[i].title, content: posts[i].content, comments: []})
}
if(req.body.name && req.body.title && req.body.content) {
- let post = {timestamp: new Date().getTime(), author: req.body.name, title: req.body.title, content: req.body.content.replaceAll('\r\n', '\n'), comments: []}
+ let post = {timestamp: new Date().getTime(), author: req.body.name, title: req.body.title, content: req.body.content.replaceAll('\r\n', '\n') + (req.body.secret && req.body.secret !== '' ? ('\n\n[* Signed: [" ' + req.body.secret.sha512().sha512().sha256() + ' "] *]') : ''), comments: []}
if(fake) {
mainPage.comments.push(post)
res.render('post.ejs', {post: mainPage, postid: '-1', webname: webname, email: email, comment: '', fake: true})
@@ -76,7 +78,7 @@ server.all('/comment', function get(req, res) {
console.log(String(cid) + ' ' + comment)
if(String(cid) === comment) {
if(req.body.name && req.body.title && req.body.content) {
- post.comments.push({timestamp: new Date().getTime(), author: req.body.name, title: req.body.title, content: req.body.content.replaceAll('\r\n', '\n'), comments: []})
+ post.comments.push({timestamp: new Date().getTime(), author: req.body.name, title: req.body.title, content: req.body.content.replaceAll('\r\n', '\n') + (req.body.secret && req.body.secret !== '' ? ('\n\n[* Signed: [" ' + req.body.secret.sha512().sha512().sha256() + ' "] *]') : ''), comments: []})
if(fake) {
res.render('post.ejs', {post: posts[id], postid: id, webname: webname, email: email, comment: cid, fake: fake})
toRemove = post
@@ -103,7 +105,7 @@ server.all('/comment', function get(req, res) {
}
else {
if(req.body.name && req.body.title && req.body.content) {
- posts[id].comments.push({timestamp: new Date().getTime(), author: req.body.name, title: req.body.title, content: req.body.content.replaceAll('\r\n', '\n'), comments: []})
+ posts[id].comments.push({timestamp: new Date().getTime(), author: req.body.name, title: req.body.title, content: req.body.content.replaceAll('\r\n', '\n') + (req.body.secret && req.body.secret !== '' ? ('\n\n[* Signed: [" ' + req.body.secret.sha512().sha512().sha256() + ' "] *]') : ''), comments: []})
if(fake) {
res.render('post.ejs', {post: posts[id], postid: id, webname: webname, email: email, comment: cid, fake: fake})
toRemove = posts[id]
diff --git a/package.json b/package.json
index 30f19bf..e79e6bf 100644
--- a/package.json
+++ b/package.json
@@ -12,6 +12,7 @@
"bdb.js": "^0.3.2-c",
"body-parser": "^1.19.1",
"ejs": "^3.1.6",
- "express": "^4.17.2"
+ "express": "^4.17.2",
+ "hashcode.js": "^2.2.1"
}
}
diff --git a/views/post.ejs b/views/post.ejs
index f273614..ff6efb0 100644
--- a/views/post.ejs
+++ b/views/post.ejs
@@ -141,7 +141,8 @@
`` +
`
` +
+ `
` +
+ `Signed:
` +
` ` +
`` +
`