mirror of
				https://gitlab.com/MrFry/mrfrys-node-server
				synced 2025-04-01 20:24:18 +02:00 
			
		
		
		
	Motd/version fixes, some logging improvements, manual update
This commit is contained in:
		
							
								
								
									
										11
									
								
								actions.js
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								actions.js
									
									
									
									
									
								
							@@ -26,10 +26,11 @@ module.exports = {
 | 
				
			|||||||
	ProcessQA: ProcessQA
 | 
						ProcessQA: ProcessQA
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var recievedFile = "stats/recieved";
 | 
					 | 
				
			||||||
var staticFile = "public/data/static";
 | 
					var staticFile = "public/data/static";
 | 
				
			||||||
var manFile = "public/man.html";
 | 
					var manFile = "public/man.html";
 | 
				
			||||||
var dataFile = "public/data.json";
 | 
					var dataFile = "public/data.json";
 | 
				
			||||||
 | 
					const versionFile = "public/version";
 | 
				
			||||||
 | 
					const motdFile = "public/motd";
 | 
				
			||||||
const qaFile = "public/qa";
 | 
					const qaFile = "public/qa";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var logger = require('./logger.js');
 | 
					var logger = require('./logger.js');
 | 
				
			||||||
@@ -285,6 +286,13 @@ function ProcessIncomingRequest(data) {
 | 
				
			|||||||
			msg += ". Version: " + d.version;
 | 
								msg += ". Version: " + d.version;
 | 
				
			||||||
		var color = logger.GetColor("green");
 | 
							var color = logger.GetColor("green");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							try {
 | 
				
			||||||
 | 
								data.version = utils.ReadFile(versionFile);
 | 
				
			||||||
 | 
								data.motd = utils.ReadFile(motdFile);
 | 
				
			||||||
 | 
							} catch (e) {
 | 
				
			||||||
 | 
								Log("MOTD/Version writing/reading error!");
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (data != undefined && d.data.length > 0){
 | 
							if (data != undefined && d.data.length > 0){
 | 
				
			||||||
			utils.WriteBackup();
 | 
								utils.WriteBackup();
 | 
				
			||||||
			utils.WriteFile(JSON.stringify(data), dataFile);
 | 
								utils.WriteFile(JSON.stringify(data), dataFile);
 | 
				
			||||||
@@ -317,7 +325,6 @@ function ProcessIncomingRequest(data) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		var newStatItems = Process(d, staticFile);
 | 
							var newStatItems = Process(d, staticFile);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		utils.AppendToFile(logger.GetDateString() + "\n" + d.data, recievedFile);
 | 
					 | 
				
			||||||
		PrintNewCount(d, newStatItems, staticFile);
 | 
							PrintNewCount(d, newStatItems, staticFile);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,6 @@
 | 
				
			|||||||
const utils = require('./utils.js');
 | 
					const utils = require('./utils.js');
 | 
				
			||||||
const dataFile = "public/data.json";
 | 
					const dataFile = "public/data.json";
 | 
				
			||||||
 | 
					const versionFile = "public/version";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var p = GetParams();
 | 
					var p = GetParams();
 | 
				
			||||||
if (p.length <= 0) {
 | 
					if (p.length <= 0) {
 | 
				
			||||||
@@ -24,6 +25,7 @@ console.log("New version:");
 | 
				
			|||||||
console.log(parsed.version);
 | 
					console.log(parsed.version);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
utils.WriteFile(JSON.stringify(parsed), dataFile);
 | 
					utils.WriteFile(JSON.stringify(parsed), dataFile);
 | 
				
			||||||
 | 
					utils.WriteFile(parsed.version, versionFile);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function GetParams() {
 | 
					function GetParams() {
 | 
				
			||||||
	return process.argv.splice(2);
 | 
						return process.argv.splice(2);
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								motd.js
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								motd.js
									
									
									
									
									
								
							@@ -1,5 +1,7 @@
 | 
				
			|||||||
const utils = require('./utils.js');
 | 
					const utils = require('./utils.js');
 | 
				
			||||||
const dataFile = "public/data.json";
 | 
					const dataFile = "public/data.json";
 | 
				
			||||||
 | 
					const versionFile = "public/version";
 | 
				
			||||||
 | 
					const motdFile = "public/motd";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var p = GetParams();
 | 
					var p = GetParams();
 | 
				
			||||||
if (p.length <= 0) {
 | 
					if (p.length <= 0) {
 | 
				
			||||||
@@ -15,6 +17,8 @@ var parsed = JSON.parse(d);
 | 
				
			|||||||
parsed.motd = param;
 | 
					parsed.motd = param;
 | 
				
			||||||
utils.WriteFile(JSON.stringify(parsed), dataFile);
 | 
					utils.WriteFile(JSON.stringify(parsed), dataFile);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					utils.WriteFile(parsed.motd, motdFile);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function GetParams() {
 | 
					function GetParams() {
 | 
				
			||||||
	return process.argv.splice(2);
 | 
						return process.argv.splice(2);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -360,6 +360,12 @@ változtatni akarsz, akkor illik tudni
 | 
				
			|||||||
				<li>Nincs kiválasztva a megoldani kívánt tárgy a menüben.</li>
 | 
									<li>Nincs kiválasztva a megoldani kívánt tárgy a menüben.</li>
 | 
				
			||||||
			</ul>
 | 
								</ul>
 | 
				
			||||||
		</li>
 | 
							</li>
 | 
				
			||||||
 | 
							<li>
 | 
				
			||||||
 | 
								<b>7. Mi ez a ... ?</b>
 | 
				
			||||||
 | 
								</br>
 | 
				
			||||||
 | 
								<img height=40% src="img/imgq.jpg" alt="img"/>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							</li>
 | 
				
			||||||
		</p>
 | 
							</p>
 | 
				
			||||||
		<li>
 | 
							<li>
 | 
				
			||||||
			Egyéb:<br><a target="_blank"
 | 
								Egyéb:<br><a target="_blank"
 | 
				
			||||||
@@ -370,14 +376,6 @@ változtatni akarsz, akkor illik tudni
 | 
				
			|||||||
mindég használhatod a txt-t, amiben az addig lementett kérdések vannak. (CTRL + F) A kritikus hibák
 | 
					mindég használhatod a txt-t, amiben az addig lementett kérdések vannak. (CTRL + F) A kritikus hibák
 | 
				
			||||||
consolra ki vannak írva, amit f12 megnyitásával tudsz előhozni (chrome/firefox (dev console))
 | 
					consolra ki vannak írva, amit f12 megnyitásával tudsz előhozni (chrome/firefox (dev console))
 | 
				
			||||||
	</ul>
 | 
						</ul>
 | 
				
			||||||
	<center>
 | 
					 | 
				
			||||||
		<h3>Adat egyszerűsítés</h3>
 | 
					 | 
				
			||||||
	</center>
 | 
					 | 
				
			||||||
	<hr> Másold be ide az egész txt-d, és ez kiszedi belőle az ugyanolyan kérdéseket, illetve ha
 | 
					 | 
				
			||||||
	hibás részeket talál, akkor kikommenteli. Érdemes megnézni, hogy történt-e ilyen, keress rá a
 | 
					 | 
				
			||||||
	kész szövegben a "#"-karakterre. Ezzel azért óvatosan, ez kipusztithatja a szobanövényed.
 | 
					 | 
				
			||||||
	<textarea id="converter"></textarea>
 | 
					 | 
				
			||||||
	<button onclick="simplify()">Egyszerűsítés</button>
 | 
					 | 
				
			||||||
	<hr> Jogosultságok:
 | 
						<hr> Jogosultságok:
 | 
				
			||||||
	</br>GM_openInTab: help megnyitása új lapon, GM_xmlhttpRequest: online adatbázishoz.
 | 
						</br>GM_openInTab: help megnyitása új lapon, GM_xmlhttpRequest: online adatbázishoz.
 | 
				
			||||||
	GM_getResourceText: a txt beolvasáshoz. Mást nem bír beolvasni, csak amit megadsz a @resouces
 | 
						GM_getResourceText: a txt beolvasáshoz. Mást nem bír beolvasni, csak amit megadsz a @resouces
 | 
				
			||||||
@@ -411,85 +409,6 @@ consolra ki vannak írva, amit f12 megnyitásával tudsz előhozni (chrome/firef
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
			document.getElementById("tex").value = "// @resource     data file:///" + a;
 | 
								document.getElementById("tex").value = "// @resource     data file:///" + a;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					 | 
				
			||||||
		function simplify() {
 | 
					 | 
				
			||||||
			var splitData = document.getElementById("converter").value.split("\n");
 | 
					 | 
				
			||||||
			var result = [];
 | 
					 | 
				
			||||||
			var jumped = 0;
 | 
					 | 
				
			||||||
			var doubles = 0;
 | 
					 | 
				
			||||||
			for (var i = 0; i < splitData.length; i += jumped) {
 | 
					 | 
				
			||||||
				splitData[i] = splitData[i].trim();
 | 
					 | 
				
			||||||
				jumped = 0;
 | 
					 | 
				
			||||||
				var currQuestion = {
 | 
					 | 
				
			||||||
					q: splitData[i],
 | 
					 | 
				
			||||||
					a: splitData[i + 1],
 | 
					 | 
				
			||||||
					i: splitData[i + 2]
 | 
					 | 
				
			||||||
				};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				if (currQuestion.q != undefined && currQuestion.q[0] == "?" && currQuestion.a != undefined &&
 | 
					 | 
				
			||||||
					currQuestion.a[0] == "!") {
 | 
					 | 
				
			||||||
					jumped += 2;
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
				if (currQuestion.i != undefined && currQuestion.i[0] == ">" && jumped == 2) {
 | 
					 | 
				
			||||||
					jumped++;
 | 
					 | 
				
			||||||
				} else {
 | 
					 | 
				
			||||||
					delete currQuestion.i;
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
				if (jumped > 1) {
 | 
					 | 
				
			||||||
					for (var j = 0; j < result.length; j++) {
 | 
					 | 
				
			||||||
						if (result[j].q) {
 | 
					 | 
				
			||||||
							if (result[j].q == currQuestion.q && result[j].a == currQuestion.a) {
 | 
					 | 
				
			||||||
								if (result[j].i && currQuestion.i) {
 | 
					 | 
				
			||||||
									if (result[j].i == currQuestion.i) {
 | 
					 | 
				
			||||||
										break;
 | 
					 | 
				
			||||||
									}
 | 
					 | 
				
			||||||
								} else {
 | 
					 | 
				
			||||||
									break;
 | 
					 | 
				
			||||||
								}
 | 
					 | 
				
			||||||
							}
 | 
					 | 
				
			||||||
						}
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
					if (j >= result.length) {
 | 
					 | 
				
			||||||
						result.push(currQuestion);
 | 
					 | 
				
			||||||
					} else {
 | 
					 | 
				
			||||||
						doubles++;
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
				if (currQuestion.q[0] == "+") {
 | 
					 | 
				
			||||||
					result.push({
 | 
					 | 
				
			||||||
						n: currQuestion.q
 | 
					 | 
				
			||||||
					});
 | 
					 | 
				
			||||||
					jumped++;
 | 
					 | 
				
			||||||
				} else if (jumped < 1) {
 | 
					 | 
				
			||||||
					var comment = currQuestion.q;
 | 
					 | 
				
			||||||
					if (comment[0] != "#") {
 | 
					 | 
				
			||||||
						comment = "#" + comment;
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
					result.push({
 | 
					 | 
				
			||||||
						c: comment
 | 
					 | 
				
			||||||
					});
 | 
					 | 
				
			||||||
					jumped++;
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			var textResult = "";
 | 
					 | 
				
			||||||
			for (var i = 0; i < result.length; i++) {
 | 
					 | 
				
			||||||
				if (result[i].q != undefined && result[i].a != undefined) {
 | 
					 | 
				
			||||||
					textResult += result[i].q + "\n";
 | 
					 | 
				
			||||||
					textResult += result[i].a + "\n";
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
				if (result[i].i != undefined) {
 | 
					 | 
				
			||||||
					textResult += result[i].i + "\n";
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
				if (result[i].c != undefined) {
 | 
					 | 
				
			||||||
					textResult += result[i].c + "\n";
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
				if (result[i].n != undefined) {
 | 
					 | 
				
			||||||
					textResult += result[i].n + "\n";
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			alert(doubles + " duplikáció eltávolítva, és hibás kérdések kikommentelve.");
 | 
					 | 
				
			||||||
			document.getElementById("converter").value = textResult;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	</script>
 | 
						</script>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
</html>
 | 
					</html>
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										10
									
								
								server.js
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								server.js
									
									
									
									
									
								
							@@ -73,10 +73,6 @@ if (startHTTPS && utils.FileExists(privkeyFile) && utils.FileExists(fullchainFil
 | 
				
			|||||||
const port = 8080;
 | 
					const port = 8080;
 | 
				
			||||||
const httpsPort = 8443;
 | 
					const httpsPort = 8443;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var highlights = ["public", "static", "manual", "isgetting", "postfeedback",
 | 
					 | 
				
			||||||
	"postquestions"
 | 
					 | 
				
			||||||
];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
app.set('view engine', 'ejs');
 | 
					app.set('view engine', 'ejs');
 | 
				
			||||||
app.use(function(req, res, next) {
 | 
					app.use(function(req, res, next) {
 | 
				
			||||||
	res.on('finish', function() {
 | 
						res.on('finish', function() {
 | 
				
			||||||
@@ -277,11 +273,7 @@ function Log(req, toFile, sc) {
 | 
				
			|||||||
			logEntry += sc + " ";
 | 
								logEntry += sc + " ";
 | 
				
			||||||
		logEntry += req.url;
 | 
							logEntry += req.url;
 | 
				
			||||||
		var color = logger.GetColor("green");
 | 
							var color = logger.GetColor("green");
 | 
				
			||||||
		for (var i = 0; i < highlights.length; i++)
 | 
					
 | 
				
			||||||
			if (req.url.toLowerCase().includes(highlights[i])) {
 | 
					 | 
				
			||||||
				color = logger.GetColor("blue");
 | 
					 | 
				
			||||||
				break;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		if (req.url.toLowerCase().includes("isadding"))
 | 
							if (req.url.toLowerCase().includes("isadding"))
 | 
				
			||||||
			color = logger.GetColor("yellow");
 | 
								color = logger.GetColor("yellow");
 | 
				
			||||||
		if (!toFile) {
 | 
							if (!toFile) {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user