Added logging to accesible folder, and made all questions page more readable

This commit is contained in:
YourFriendlyNeighborhoodDealer 2019-02-27 18:58:29 +01:00
parent ccc7f31e3a
commit 59640eaddf
16 changed files with 149 additions and 15 deletions

0
README.md Executable file → Normal file
View file

1
actions.js Executable file → Normal file
View file

@ -279,7 +279,6 @@ function ProcessIncomingRequest(data) {
data.AddQuestion(d.subj, q);
}
data.version = version;
logger.Log("[PCES]:\t" + d.subj);
var msg = "All / new count: " + allQuestions.length + " / " + questions.length;
if (d.version != undefined)

0
license Executable file → Normal file
View file

4
logger.js Executable file → Normal file
View file

@ -26,6 +26,8 @@ module.exports = {
var utils = require('./utils.js');
const nlogFile = "stats/nlogs";
const varLogFile = "/var/log/qminingNLog";
const logFile = "/nlogs/nlogs";
function GetDateString() {
var m = new Date();
@ -45,7 +47,9 @@ function Log(s, c, b) {
if (b)
utils.Beep();
utils.AppendToFile(GetDateString() + "> " + s, nlogFile);
utils.AppendToFile(GetDateString() + "> " + s, logFile);
}
function GetColor(c) {

0
merger.js Executable file → Normal file
View file

0
motd.js Executable file → Normal file
View file

0
public/favicon.ico Executable file → Normal file
View file

Before

Width:  |  Height:  |  Size: 252 KiB

After

Width:  |  Height:  |  Size: 252 KiB

Before After
Before After

0
public/man.html Executable file → Normal file
View file

20
server.js Executable file → Normal file
View file

@ -45,6 +45,8 @@ const inputFile = "stats/inputs";
const msgFile = "stats/msgs";
const logFile = "stats/logs";
const allLogFile = "/nlogs/log";
// https://certbot.eff.org/
const privkeyFile = "/etc/letsencrypt/live/questionmining.tk/privkey.pem";
const fullchainFile = "/etc/letsencrypt/live/questionmining.tk/fullchain.pem";
@ -134,17 +136,14 @@ app.get('/static', function(req, res) {
});
app.get('/legacy', function(req, res) {
// TODO: make this ejs
var f = utils.ReadFile(dataFile);
var r = '<html><body bgcolor="#212127"><head><meta charset="UTF-8">';
r += '<style>body { font: normal 14px Verdana; color: #999999;}</style>';
var d = actions.LoadJSON(f).toString().split("\n");
for (var i = 0; i < d.length; i++)
r += d[i] + "</br>";
r += '</head></body></html>';
res.write(r);
res.end();
var f = utils.ReadFile(dataFile);
var d = actions.LoadJSON(f);
var raw = d.toString().split("\n");
res.render('alldata', {
data: d
});
});
app.post('/postfeedback', function(req, res) {
@ -276,6 +275,7 @@ function Log(req, toFile, sc) {
.body) + "\n";
utils.AppendToFile(defLogs, logFile);
utils.AppendToFile(defLogs, allLogFile);
}
} catch (e) {

0
stat.js Executable file → Normal file
View file

6
utils.js Executable file → Normal file
View file

@ -36,8 +36,10 @@ function CreatePath(path, onlyPath) {
var p = path.split("/");
var currDir = p[0];
for (var i = 1; i < p.length; i++) {
if (!fs.existsSync(currDir)) {
fs.mkdirSync(currDir);
if (currDir != "" && !fs.existsSync(currDir)) {
try {
fs.mkdirSync(currDir);
} catch (e) { console.log("Failed to make " + currDir + " directory... "); }
}
currDir += "/" + p[i];
}

0
views/404.ejs Executable file → Normal file
View file

107
views/alldata.ejs Normal file
View file

@ -0,0 +1,107 @@
<html>
<body bgcolor="#212127">
<head>
<title>All questions</title>
<meta charset="UTF-8">
<style>
body {
font: normal 14px Verdana;
color: #999999;
}
td {
font: normal 16px Verdana;
}
td {
font: normal 16px Verdana;
width: 100%;
}
textarea {
font: normal 14px Verdana;
color: #999999;
background-color: #212127;
width: 100%;
height: 700
}
a {
color: #9999ff;
}
.collapsible {
background-color: #212127;
color: #999999;
cursor: pointer;
width: 100%;
border: none;
text-align: left;
outline: none;
font-size: 13px;
}
.active, .collapsible:hover {
background-color: #555;
}
.content {
padding: 0 18px;
display: none;
overflow: hidden;
background-color: #212127;
}
</style>
</head>
<center><h2>
Ennek az oldalnak a tartalma dinamikusan frissül minden beküldött kérdés után
</h2></center>
<% for (var i = 0; i < data.Subjects.length; i++) { %>
<button class="collapsible">
<h2>
<table>
<td>
<%=data.Subjects[i].Name %>
</td>
<td style="vertical-align:middle;text-align:right">
<%=data.Subjects[i].length %>
</td>
</table>
</h2>
</button>
<div class="content">
<% var a = data.Subjects[i].toString().split('\n')%>
<% for (var j = 1; j < a.length; j++) { %>
<% if (a[j][0] == '?') { %>
</br>
<% } %>
<%=a[j] %>
</br>
<% } %>
</div>
<% } %>
<script>
var coll = document.getElementsByClassName("collapsible");
var i;
for (i = 0; i < coll.length; i++) {
coll[i].addEventListener("click", function() {
this.classList.toggle("active");
var content = this.nextElementSibling;
if (content.style.display === "block") {
content.style.display = "none";
} else {
content.style.display = "block";
}
});
}
</script>
</body>
</html>

4
views/main.ejs Executable file → Normal file
View file

@ -24,9 +24,9 @@ greasyforkon</a>
|
<a href="<%= siteurl %>/manual">Manual</a>
|
<a href="<%= siteurl %>/data.json">Összes kérdés (JSON)</a>
<a href="<%= siteurl %>/legacy">Összes kérdés (Olvasható formátum)</a>
|
<a href="<%= siteurl %>/legacy">Összes kérdés (Régi/Olvasható formátum)</a>
<a href="<%= siteurl %>/data.json">Összes kérdés (JSON)</a>
|
<a href="<%= siteurl %>/servergit">Szerver repó</a>
|

22
views/uload.ejs Normal file
View file

@ -0,0 +1,22 @@
<html>
<body bgcolor="#212127">
<head>
<title>Shit uploader</title>
<meta charset="UTF-8">
<style>
body { font: normal 14px Verdana; color: #999999;}
td {vertical-align: top }
textarea { font: normal 14px Verdana; color: #999999; background-color: #212127; width: 100%; height: 700;}
a {color: #9999ff;}
</style>
</head>
<form action="/fosuploader" enctype=multipart/form-data method="post">
<input type="file" name="dasfile" />
<input type="submit" value="Upload" />
</form>
</body>
</html>

0
views/uploaded.ejs Executable file → Normal file
View file