File rearrange 2

This commit is contained in:
MrFry 2020-01-23 09:49:19 +01:00
parent 5530f03fac
commit 55d7885d21
20 changed files with 1775 additions and 0 deletions

73
modules/main/main.js Normal file
View file

@ -0,0 +1,73 @@
/* ----------------------------------------------------------------------------
Question Server
GitLab: <https://gitlab.com/MrFry/mrfrys-node-server>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
------------------------------------------------------------------------- */
let url = '' // http(s)//asd.basd
const express = require('express')
const bodyParser = require('body-parser')
const busboy = require('connect-busboy')
const app = express()
const logger = require('../../utils/logger.js')
// const utils = require('../utils/utils.js')
// const actions = require('../utils/actions.js')
app.set('view engine', 'ejs')
app.set('views', [
'./modules/main/views',
'./sharedViews'
])
app.use(express.static('public'))
app.use(busboy({
limits: {
fileSize: 10000 * 1024 * 1024
}
}))
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({
limit: '5mb',
extended: true
}))
app.use(bodyParser.json({
limit: '5mb'
}))
// --------------------------------------------------------------
app.get('/', function (req, res) {
res.render('main', {
siteurl: url
})
})
app.get('*', function (req, res) {
res.status(404).render('shared/404')
})
app.post('*', function (req, res) {
res.status(404).render('shared/404')
})
exports.app = app
exports.setup = (x) => {
url = x.url
}
logger.Log('Main module started', logger.GetColor('yellow'))

41
modules/main/views/main.ejs Executable file
View file

@ -0,0 +1,41 @@
<html>
<body bgcolor="#212127">
<head>
<title>FryLabs.net</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=0.8" />
<style>
body {
font: normal 14px Verdana;
color: #999999;
}
td {
vertical-align: top
}
a {
color: #9999ff;
text-decoration: none;
}
</style>
</head>
</p>
<h2>
<a href="http://qmining.frylabs.net">
<pre>
____ __ __
/ __/_____ __ / /__ _/ / ___
/ _// __/ // / / / _ `/ _ \(_-<
/_/ /_/ \_, / /_/\_,_/_.__/___/
/___/
</pre>
</a>
</h2>
</body>
</html>

46
modules/old/old.js Executable file
View file

@ -0,0 +1,46 @@
/* ----------------------------------------------------------------------------
Question Server
GitLab: <https://gitlab.com/MrFry/mrfrys-node-server>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
------------------------------------------------------------------------- */
let url = ''
const express = require('express')
const app = express()
const logger = require('../../utils/logger.js')
// --------------------------------------------------------------
app.get('/', function (req, res) {
res.redirect(url + req.url)
})
app.get('*', function (req, res) {
res.redirect(url + req.url)
})
app.post('*', function (req, res) {
res.redirect(url + req.url)
})
exports.app = app
exports.setup = (x) => {
url = x.url
}
logger.Log('Old module started', logger.GetColor('yellow'))

242
modules/qmining/qmining.js Normal file
View file

@ -0,0 +1,242 @@
/* ----------------------------------------------------------------------------
Question Server
GitLab: <https://gitlab.com/MrFry/mrfrys-node-server>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
------------------------------------------------------------------------- */
let url = ''
const express = require('express')
const bodyParser = require('body-parser')
const busboy = require('connect-busboy')
const fs = require('fs')
const app = express()
// const http = require('http')
// const https = require('https')
const logger = require('../../utils/logger.js')
const utils = require('../../utils/utils.js')
const actions = require('../../utils/actions.js')
const recivedFiles = 'public/recivedfiles'
const uloadFiles = 'public/f'
const dataFile = 'public/data.json'
const msgFile = 'stats/msgs'
const motdFile = 'public/motd'
let donateURL = ''
try {
donateURL = utils.ReadFile('./data/donateURL')
} catch (e) {
logger.Log('Couldnt read donate URL file!', logger.GetColor('red'))
}
app.set('view engine', 'ejs')
app.set('views', [
'./modules/qmining/views',
'./sharedViews'
])
app.use(express.static('public'))
app.use(busboy({
limits: {
fileSize: 10000 * 1024 * 1024
}
}))
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({
limit: '5mb',
extended: true
}))
app.use(bodyParser.json({
limit: '5mb'
}))
// --------------------------------------------------------------
app.get('/', function (req, res) {
// req.hostname
let motd = ''
try {
motd = utils.ReadFile(motdFile)
} catch (e) {
}
res.render('main', {
siteurl: url,
qa: actions.ProcessQA(),
motd: motd
})
res.end()
})
app.get('/manual', function (req, res) {
res.render('man')
res.end()
logger.LogReq(req)
})
app.get('/legacy', function (req, res) {
var f = utils.ReadFile(dataFile)
var d = actions.LoadJSON(f)
let qcount = 0
for (let i = 0; i < d.length; i++) { qcount += d.Subjects[i].length }
let scount = d.length
res.render('alldata', {
data: d,
scount: scount,
qcount: qcount,
siteurl: url
})
logger.LogReq(req)
})
app.post('/postfeedback', function (req, res) {
res.redirect('back')
logger.Log('New feedback message', logger.GetColor('bluebg'), true)
utils.AppendToFile('\n\n' + logger.GetDateString() + ': ' + req.body.message_field, msgFile)
})
app.get('/postfeedback', function (req, res) {
res.redirect('/')
})
app.post('/isAdding', function (req, res) {
res.end('OK')
logger.LogReq(req)
actions.ProcessIncomingRequest(req.body.datatoadd)
utils.WriteBackup()
})
app.get('/lred', function (req, res) {
res.redirect('/legacy')
res.end()
logger.LogReq(req)
})
app.get('/menuClick', function (req, res) {
res.redirect('/')
res.end()
logger.LogReq(req)
})
// all questions readable
app.get('/allqr', function (req, res) {
var f = utils.ReadFile(dataFile)
var d = actions.LoadJSON(f)
res.render('allqr', {
d: d.toString().split('\n')
})
logger.LogReq(req)
})
app.get('/greasy', function (req, res) {
res.redirect('https://greasyfork.org/en/scripts/38999-moodle-elearning-kmooc-test-help')
res.end()
logger.LogReq(req)
})
app.get('/install', function (req, res) {
res.redirect(url + '/moodle-test-userscript/stable.user.js?install')
res.end()
logger.LogReq(req)
})
app.get('/donate', function (req, res) {
res.redirect(donateURL)
res.end()
logger.LogReq(req)
})
app.get('/thanks', function (req, res) {
res.render('thanks', {
siteurl: url
})
res.end()
logger.LogReq(req)
})
app.get('/classesgit', function (req, res) {
res.redirect('https://gitlab.com/MrFry/question-classes')
res.end()
logger.LogReq(req)
})
app.get('/scriptgit', function (req, res) {
res.redirect('https://gitlab.com/MrFry/moodle-test-userscript')
res.end()
logger.LogReq(req)
})
app.get('/servergit', function (req, res) {
res.redirect('https://gitlab.com/MrFry/mrfrys-node-server')
res.end()
logger.LogReq(req)
})
function UploadFile (req, res, path, next) {
var fstream
req.pipe(req.busboy)
req.busboy.on('file', function (fieldname, file, filename) {
logger.Log('Uploading: ' + filename, logger.GetColor('blue'))
utils.CreatePath(path, true)
let d = new Date()
let fn = d.getHours() + '' + d.getMinutes() + '' + d.getSeconds() + '_' + filename
fstream = fs.createWriteStream(path + '/' + fn)
file.pipe(fstream)
fstream.on('close', function () {
logger.Log('Upload Finished of ' + path + '/' + fn, logger.GetColor('blue'))
next(fn)
})
fstream.on('error', function (err) {
console.log(err)
res.end('something bad happened :s')
})
})
}
app.route('/fosuploader').post(function (req, res, next) {
UploadFile(req, res, uloadFiles, (fn) => {
res.redirect('/f/' + fn)
})
})
app.route('/badtestsender').post(function (req, res, next) {
UploadFile(req, res, recivedFiles, (fn) => {
res.render('uploaded')
})
logger.LogReq(req)
})
app.get('*', function (req, res) {
res.status(404).render('404')
})
app.post('*', function (req, res) {
res.status(404).render('404')
})
exports.app = app
exports.setup = (x) => {
url = x.url
}
logger.Log('Qmining module started', logger.GetColor('yellow'))

146
modules/qmining/views/alldata.ejs Executable file
View file

@ -0,0 +1,146 @@
<html>
<body bgcolor="#212127">
<head>
<title>All questions</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=0.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;
}
.openall {
background-color: #212127;
color: #999999;
cursor: pointer;
border: none;
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
</br>
<%=scount%> tárgy és <%=qcount%> kérdés
</h2>
</p>
<a href="<%=siteurl%>/allqr"> Letöltés </a>
<button class="openall" onclick="openall()"> Összes kinyitása </button>
</center>
<% include aludni.ejs %>
<% for (var i = 0; i < data.Subjects.length; i++) { %>
<button
class="collapsible"
style='<%= i % 2 === 0 ? "background-color: #2f2f37" : "" %>'
onmouseenter='mouseEnter(this, <%= i %>)'
onmouseleave='mouseLeave(this, <%= i %>)'
>
<h2>
<table id=<%=i%>>
<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";
}
});
}
function openall () {
var coll = document.getElementsByClassName("content");
var i;
for (i = 0; i < coll.length; i++) {
coll[i].style.display = "block";
}
}
function mouseEnter (e, i) {
e.style.backgroundColor = "#555"
}
function mouseLeave (e, i) {
if (i % 2 == 0) {
e.style.backgroundColor = "#2f2f37"
} else {
e.style.backgroundColor = "#212127"
}
}
</script>
<% include b.ejs %>
</body>
</html>

23
modules/qmining/views/allqr.ejs Executable file
View file

@ -0,0 +1,23 @@
<html>
<body bgcolor="#212127">
<head>
<title>All questions</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=0.8" />
<style>
body {
font: normal 14px Verdana;
color: #999999;
}
</style>
</head>
<% for (var i = 0; i < d.length; i++) { %>
<%= d[i] %>
</br>
<% } %>
</body>
</html>

View file

@ -0,0 +1,6 @@
<% var d = new Date().getHours();
if (d < 6 || d > 22) { %>
<center>
<img src="img/aludni.jpeg" alt="img"/>
</center>
<% } %>

35
modules/qmining/views/b.ejs Executable file
View file

@ -0,0 +1,35 @@
<% function GetRandom(min, max) {
return Math.floor(Math.random() * (max - min + 1) + min);
} %>
<% if (GetRandom(0, 100) == 1) { %>
<div style="position:fixed;left:0;bottom:0;margin:0;padding:0;" >
<img onclick="playDeer()" width=30% src="img/tiszai.png" alt="img" style="cursor:
pointer"/>
</div>
<script>
var deer = new Audio('sound/deer.mp3');
var deer2 = new Audio('sound/deer2.mp3');
var deer3 = new Audio('sound/deer3.mp3');
var deer4 = new Audio('sound/deer4.mp3');
function GetRandom(min, max) {
return Math.floor(Math.random() * (max - min + 1) + min);
}
function playDeer() {
var r = GetRandom(0, 3);
if (r == 0) {
deer.play();
} else if (r == 1) {
deer2.play();
} else if (r == 2) {
deer3.play();
} else if (r == 3) {
deer4.play();
}
}
</script>
<% } %>

112
modules/qmining/views/main.ejs Executable file
View file

@ -0,0 +1,112 @@
<html>
<body bgcolor="#212127">
<head>
<title>Question mining</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=0.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;
}
.rainbow {
background: linear-gradient( 92deg, #ff0000, #00ffff);
background: -webkit-linear-gradient( 92deg, #ff0000, #00ffff);
background-size:600vw 600vw;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
animation: textAnimate 5s linear infinite alternate;
}
@keyframes textAnimate {
from {
filter: hue-rotate(0deg);
background-position-x: 0%;
}
to {
filter: hue-rotate(360deg);
background-position-x: 600vw;
}
}
</style>
</head>
</p>
<h2>
<a href="<%= siteurl %>/install">Script install</a> |
<a href="<%= siteurl %>/manual">Manual</a> |
<a href="<%= siteurl %>/legacy">Összes kérdés (Olvasható formátum)</a> |
<a href="<%= siteurl %>/data.json">Összes kérdés (JSON)</a> |
<a href="<%= siteurl %>/servergit">Szerver repó</a> |
<a href="<%= siteurl %>/scriptgit">Userscript repó</a> |
<a href="<%= siteurl %>/classesgit">Classes repó</a> |
<a href="<%= siteurl %>/donate">Donate</a>
</h2>
<hr>
<h3>
<b>MOTD:</b>
<%- motd %>
</h2>
<hr>
<form action="/postfeedback" , method="post">
<div>Észrevételek: (közeledő teszt miatti kérdés-karbantartás, bug, feature vagy egyéb dolog, ami nyomja a lelked)</div>
<textarea type="text" name="message_field" style="width: 100%;box-sizing:border-box;height: 100;"></textarea>
<div>Rengeteg spam-et kapok, nyugodtan küldd el ezerszer, akkor hátha észreveszem a spam
között :)</div>
<button>Küldés</button>
</form>
<hr>
Hibát kiváltó teszt feltöltése
</br>
<form action="/badtestsender" enctype=multipart/form-data method="post">
<input type="file" name="dasfile" />
<input type="submit" value="Upload" />
</form>
</p>
Ha egy kérdésre mindig helytelenül talál választ a userscript (vagy egyéb hibát észlelsz), akkor azon az oldalon nyomj egy ctrl-s -t. Ez lementi a weboldalt úgy ahogy van egy mappába, és egy html fájlba. Ezt a kettőt ha berakod egy .zip-be, és ide feltöltöd, akkor ránézek mi lehet a hiba, és kijavítom. <b> Max 10 MB!
</b> Ha több, elég a .html. Bónusz ha mellékelsz egy readme-t, hogy mit csináljak.
<% include aludni.ejs %>
<table>
<td>
<!-- Kommentek / válaszok -->
<% include qa.ejs %>
</td>
</table>
<center> ... </center>
<% include b.ejs %>
</body>
</html>

232
modules/qmining/views/man.ejs Executable file
View file

@ -0,0 +1,232 @@
<html>
<meta charset="UTF-8">
<body bgcolor="#212127">
<head>
<title>Moodle/Elearning/KMOOC manual</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=0.8" />
<style>
body {
font: normal 17px Verdana;
color: #999999;
}
a {
color: #9999ff;
}
textarea {
font: normal 17px Verdana;
color: white;
background-color: #212127;
width: 90%;
height: 250px;
}
</style>
</head>
<center>
<h1>Moodle/Elearnig/KMOOC manual</h1>
</center>
<center>
Ez a userscript Moodle/Elearnig/KMOOC tesztek megoldása során segítséget jelenít meg.
</center>
</p>
<b>A válasz ablakban jobb felül lévő százalék jelzi, hogy mekkora eséllyel jó a megoldás. Ez
sokszor jó viszonyítás, de semmi sem biztos! Bármikor előfordulhat, hogy nem jó a
megjelenített válasz! Ezért csak saját felelősségedre használd!</b> Sok kikerülhetetlen
hibalehetőség van, amit egyszerű nem lehet scriptben lekezelni (Pl rosszul megadott kérdés
tanár részéről). Kézzel is lehet keresni a elmentett kérdések között. Ezért mindig
legyen egy letöltött verziód a kérdésekről, mert nem 100% hogy mindég elérhető a szerver!
Továbbá ha a moodle oldalán a layout megváltozik, a script nem fog működni! Ez nem annyira
gyakori, de bármikor megtörténhet! Érdemes nem kikapcsolni a tampermonkey-ban a userscript
frissítést. Ez nem windows update, itt tényleg hibajavítások jönnek ki. Hiba, észrevétel
esetén : <a target="_blank" href="https://qmining.frylabs.net">Script Feedback</a> (ezt
gyakran még aznap megnézem.)
</p>
</p>
<b>Továbbá ez a userscript HTTP requestekket küldhet egy szerver felé, ahova az összes megoldott
tesztjeid kérdéseit és (helyes)válaszait feltölti! Ezzel garantálja, hogy neked, és mindenki
másnak a legfrissebb adatok állnak rendelkezésre.</b>
<center>
<% include aludni.ejs %>
<h3>Tartalomjegyzék</h3>
</center>
<hr>
<ul>
<li>
<b>Használat</b> - Ez szuper fontos, elsőnek olvasd el
</li>
<li>
<b>Eddigi teszt kérdések</b> - Itt elérhető az eddigi összes ismert teszt
kérdés-válaszai
</li>
<li>
<b>Gyakran előforduló kérdések</b> - Ha itt nincs kérdésed, akkor <a
href="http://qmining.frylabs.net">itt</a> tedd fel!
</li>
<li>
<b>Adat egyszerűsítés</b> - Ha túl sok egyforma kérdésed van ;)
</li>
<li>
<b>Other stuff</b>
</li>
</ul>
<center>
<h3>Használat</h3>
</center>
<hr>
<table style="table-layout:fixed;vertical-align:top;width:100%">
<td>
</p> Először is tölts le egy userscript futtató kiegészítőt a böngésződhöz. Én <a
href="https://www.tampermonkey.net/">Tampermonkeyt</a> használok, és ezzel van tesztelve a
userscript is, ezért ez ajánlott. Más is működhet (violentmonkey, etc), de az nem garantált.
Majd a <a href="http://qmining.frylabs.net/install">weboldalról</a> egy kattintással elvileg
le tudod tölteni a scriptet, és elvileg kész is.
</p> Ha tesztet akarsz megoldani, akkor először nézd meg a menüben, hogy aktív-e a
tárgyad. Teszt közben a script a megadott tárgy már lementett kérdéseiből próbál segíteni.
</p>
</p> Teszt közben még több dolog történhet:
</p>
<ul>
<li><b>Nem jó kérdésre ad választ a script:</b> Ilyenkor az van, hogy nincs meg a
kérdés, vagy több hasonló kérdés/válasz van. Ilyenkor a jobbra/balra gombbal
váltogathatsz azok a kérdés/válasz combók közül, amit talált a script</li>
<li><b>Több teszt kérdés van egy oldalon:</b> Fel le gombbal váltogathatsz a kérdések között.
Ilyenkor is működik az előbb említett funkció. Az indexek, amit kiír a bal felső sarokban:
aktuális kérdés száma / aktuális találat száma.</li>
<li><b>Nem jelenik meg semmi, vagy nem működik a script:</b> Megesik az ilyesmi. Ha
a webszerver még elérhető akkor ott meg bírod nézni a kérdéseket, és ott lehet
keresgélni Ctrl + F -el Ha az sincs, akkor lehet hogy jól jön ha van egy
lementett kérdés gyűjteményed.</li>
</ul>
</p> Fontos hogy kijelöld a tárgyat amit szeretnél "tanulni" mielőtt nekikezdesz. Ha egy
olyan tárgynak kezdesz neki, ami még nincs benne az adatbázisban, akkor az új tárgyként
fog bekerülni (obviously). <b>De azt neked kell utána aktívnak jelölnöd!</b> Ha nem
használsz egy tárgyat, akkor kapcsold ki, mert picit belassulhat!
</p> Egyéb funkciók:
<ul>
<li>
Ha esetleg videókat nézel, akkor spaceval lehet play/pausolni, és jobbra/balra
gombbal ugrani a videóban.
</li>
<li>
Menüben el lehet rejteni a kérdéseket a felugró ablakról, így az
kisebb helyet foglal, de így nem bírod ellenőrizni, hogy tényleg jó kérdés/választ talált-e.
</li>
<li>
Ugyanitt az üdvözlő üzenetet is el lehet rejteni. Ez frissítésnél vagy hibánál így is
úgyis megjelenik, mert azok nagyjából fontosak.
</li>
<li>
Ha bármikor nem kell a script, akkor a menü gomb alatt bekapcsolhatod a passzív
módot, ami nem olvassa be a kérdéseket. Vagy kikapcsolhatod magát a scriptet
tampermonkey-ban. Ha bármiért is el akarod tüntetni a következő oldalig az éppen
megjelenő script ablakot, akkor középső egér gombbal kattintva rajta ezt
megteheted.
</li>
</ul>
<h3>TL; DR:</h3>
Olvasd csak el. Az összes bonyodalom abból adódik, hogy a tampermonkey API-je
korlátozott, és néhány dolgot neked kell megcsinálni, megérteni. Nagy eséllyel semmi
teendőd, de azért jó ha tudod hogy működik, ha esetleg valami elromlik teszt közben,
tudd hogy lehet megcsinálni gyorsan. <b> Legyen mindég nálad egy másolat az online
kérdésekről, mert bármikor eltűnhet!</b>
</td>
<td width=20%>
<img style="max-width:100%;max-height:100%;" src="img/rtfm.jpg" alt="img"/>
</td>
</table>
<center>
<h3>Eddigi teszt kérdések:</h3>
</center>
<hr>
<a target="_blank" href="http://qmining.frylabs.net/legacy"><b>Eddigi összes kérdés</b></a>
Továbbá ez még arra jó, hogy ha valamiért bugos a script, akkor itt tudsz ctrl-f el nézegetni,
vagy ha lemented az összes kérdést, akkor még akkor is biztonságban vagy, ha netán leáll a
szerver, vagy elmegy a neted. Bár úgy nehezen moodlezel, de mind1
<center>
<h3>Gyakran előforduló kérdések</h3>
</center>
<hr>
<ul>
<li>
<b>1. Olyan helyeken fut le a script, ahol nem kellene, vagy zavar</b>
</br> Tampermonkey bővitmény ikon -> click -> scriptet kapcsold ki. Csak ne felejtsd
visszakapcsolni ;) Meg passzív módot is bekapcsolhatod a menü gomb alatt.
</li>
</p>
<li>
<b>2. Túl nagy a kérdést és a választ megjelenítő ablak, nem tudok a válaszra kattintani</b>
</br> Zommolj ki egy kicsit, vagy kapcsold ki addig a scriptet. Továbbá középső
egérgombra kattintva rá el bírod tüntetni az ablakot, amíg újra nem töltöd az oldalt,
vagy másikra ugrasz.
</li>
</p>
<li>
<b>3. Online adatokat használok, de a script hibát jelez</b>
</br> Ennek több oka is lehet:
<ul>
<li>Nem engedélyezted az http requestek küldését a usercript menedzselő
programodnál. Ez nélkül nem működik.</li>
<li>Nem elérhető a szerver. Ezt ellenőrizheted: <a
href="http://qmining.frylabs.net/">link</a></li>
<li>Nincs kiválasztva a megoldani kívánt tárgy a menüben.</li>
</ul>
</li>
<li>
<b>4. Mi ez a ... ?</b>
</br>
<img height=40% src="img/imgq.jpg" alt="img"/>
</li>
<li>
<b>5.</b>
</br>
<img src="img/6.png" alt="img"/>
</li>
</p>
<li>
Egyéb:<br>
<a target="_blank" href="http://qmining.frylabs.net/">észrevétel</a>
</li>
</ul>
<hr> Jogosultságok:
</br>GM_openInTab: help megnyitása új lapon, GM_xmlhttpRequest: online adatbázishoz. GM_info: a
scriptről információ, a verzióváltozás érzékeléséhez. GM_getValue/ GM_setValue: oldal
bezárásakor megmaradó változók kezelése. Előző verzió tárolására, ugyanúgy verzióváltozás
érzékeléséhez, néhány beállítás, illetve hogy melyik tárgyakból keressen kérdéseket. Ezek
függvények, és a sciptben néhol meg vannak hívva, keresd meg.
</p> Elküldött adatok online módban: Minden teszt végén az összes kérdés, és rá a moodle szerint
helyesnek vélt válaszok. Fogadott adatok: az összes eddig ismert moodle kérdés
<hr>
<center>
<h1>
<a target="_blank" href="http://qmining.frylabs.net/">Weboldal</a>
</h1>
</center>
<script>
function conv() {
var a = document.getElementById("tex").value;
a = a.replace(/ /g, "%20");
a = a.replace(/\\/g, "");
if (!a.includes(".txt")) {
a += ".txt";
}
document.getElementById("tex").value = "// @resource data file:///" + a;
}
</script>
<% include b.ejs %>
</html>
</body>

35
modules/qmining/views/qa.ejs Executable file
View file

@ -0,0 +1,35 @@
<center><h2> Q & A: </h3></center>
<% for (var i = qa.length - 1; i >= 0 ; i--) { %>
<hr>
<table style="width:100%">
<td style="vertical-align:middle;text-align:center;width:5%">
<h2 >
<%= i %>
</h2>
</td>
<td >
<b>
<%= qa[i].q %>
</b>
<p/>
<% if (qa[i].a) { %>
<% for (var j = 0; j < qa[i].a.length; j++) { %>
<% if (j != 0) { %>
<p/>
<% } %>
<%= qa[i].a[j] %>
<% } %>
<% } else { %>
<i> Válasz folyamatban... </i>
<% } %>
</td>
</table>
<% } %>

View file

@ -0,0 +1,114 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://fonts.googleapis.com/css?family=Quicksand&display=swap" rel="stylesheet">
<title>Thank you!</title>
<style>
:root{
--size: 100px;
--bgcolor: #212127;
--color: #fcff4f;
--shadow: rgba(30,2,5,.2);
}
.surface {
position:absolute;
top: 50%;
left: 50%;
transform-style: preserve-3d;
transform: translate(-50%,-50%) rotateX(70deg) rotateZ(300deg);
width: 300px;
height: 300px;
animation: rotatingCoin 1s linear infinite;
}
.coin,
.shadow {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%) rotateX(30deg);
width: 100px;
height: 100px;
background-image: url('https://i.ya-webdesign.com/images/mario-coin-png-19.png');
background-position: center;
background-size: cover;
background-color: var(--color);
border-radius: 50%;
}
.shadow {
width: 90px;
height: 90px;
transform: translate(-50%,-50%) translateZ(-25px);
background: linear-gradient(to bottom, rgba(255,255,255,.2) 0%,var(--bgcolor) 35%);
}
@keyframes rotatingCoin {
from {transform: translate(-50%,-50%) rotateX(70deg) rotateZ(0);}
to {transform: translate(-50%,-50%) rotateX(70deg) rotateZ(360deg);}
}
html,body{
height:100vh;
overflow: hidden;
}
body {
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
background-color: var(--bgcolor);
}
#text{
font-family: 'Quicksand', sans-serif;
color: white;
font-size: 24px;
text-shadow: 1px 1px 2px rgba(0,0,0,0.6);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding-top: 30px;
}
#backbutton{
text-decoration: none;
color: white;
cursor: pointer;
margin: 10px;
background-color: #4bb9bd;
box-shadow: 0px 1px 3px rgba(0,0,0,0.6);
border-radius: 3px;
padding: 3px 10px;
}
#backbutton:hover{
box-shadow: 0px 1px 2px rgba(0,0,0,0.6);
}
.coincontainer {
position: relative;
width: 200px;
height: 200px;
}
@media only screen and (max-width: 600px) {
body {
flex-direction: column;
}
}
</style>
</head>
<body>
<div class="coincontainer"><div class="surface">
<div class="coin"></div>
<div class="shadow"></div>
</div></div>
<center>
<div id="text"><span>Thanks for the gold, kind question miner!</span><a id="backbutton" href="<%= siteurl %>">Return</a></div>
</center>
<div class="coincontainer"><div class="surface">
<div class="coin"></div>
<div class="shadow"></div>
</div></div>
</body>
</html>

View file

@ -0,0 +1,23 @@
<html>
<body bgcolor="#212127">
<head>
<meta name="viewport" content="width=device-width, initial-scale=0.8" />
<meta charset="UTF-8">
<style>
body {
font: normal 14px Verdana;
color: #999999;
}
a {
color: #9999ff;
}
</style>
</head>
fájl feltöltve!
<a href="/"> Vissza</a>
</body>
</html>

99
modules/sio/sio.js Normal file
View file

@ -0,0 +1,99 @@
/* ----------------------------------------------------------------------------
Question Server
GitLab: <https://gitlab.com/MrFry/mrfrys-node-server>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
------------------------------------------------------------------------- */
const express = require('express')
const bodyParser = require('body-parser')
const busboy = require('connect-busboy')
const fs = require('fs')
const app = express()
// const http = require('http')
// const https = require('https')
const logger = require('../../utils/logger.js')
const utils = require('../../utils/utils.js')
const uloadFiles = './public/f'
app.set('view engine', 'ejs')
app.set('views', [
'./modules/sio/views',
'./sharedViews'
])
app.use(express.static('public'))
app.use(busboy({
limits: {
fileSize: 10000 * 1024 * 1024
}
}))
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({
limit: '5mb',
extended: true
}))
app.use(bodyParser.json({
limit: '5mb'
}))
// --------------------------------------------------------------
app.get('/', function (req, res) {
res.render('uload')
res.end()
})
function UploadFile (req, res, path, next) {
var fstream
req.pipe(req.busboy)
req.busboy.on('file', function (fieldname, file, filename) {
logger.Log('Uploading: ' + filename, logger.GetColor('blue'))
utils.CreatePath(path, true)
let d = new Date()
let fn = d.getHours() + '' + d.getMinutes() + '' + d.getSeconds() + '_' + filename
fstream = fs.createWriteStream(path + '/' + fn)
file.pipe(fstream)
fstream.on('close', function () {
logger.Log('Upload Finished of ' + path + '/' + fn, logger.GetColor('blue'))
next(fn)
})
fstream.on('error', function (err) {
console.log(err)
res.end('something bad happened :s')
})
})
}
app.route('/fosuploader').post(function (req, res, next) {
UploadFile(req, res, uloadFiles, (fn) => {
res.redirect('/f/' + fn)
})
})
app.get('*', function (req, res) {
res.status(404).render('shared/404')
})
app.post('*', function (req, res) {
res.status(404).render('shared/404')
})
exports.app = app
logger.Log('Sio module started', logger.GetColor('yellow'))

39
modules/sio/views/uload.ejs Executable file
View file

@ -0,0 +1,39 @@
<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>

212
modules/stuff/stuff.js Normal file
View file

@ -0,0 +1,212 @@
/* ----------------------------------------------------------------------------
Question Server
GitLab: <https://gitlab.com/MrFry/mrfrys-node-server>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
------------------------------------------------------------------------- */
const express = require('express')
const bodyParser = require('body-parser')
const busboy = require('connect-busboy')
const fs = require('fs')
const app = express()
let url = ''
const logger = require('../../utils/logger.js')
// const utils = require('../utils/utils.js')
// const actions = require('../utils/actions.js')
const listedFiles = './public/files'
app.set('view engine', 'ejs')
app.set('views', [
'./modules/stuff/views',
'./sharedViews'
])
app.use(express.static('public'))
app.use(busboy({
limits: {
fileSize: 10000 * 1024 * 1024
}
}))
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({
limit: '5mb',
extended: true
}))
app.use(bodyParser.json({
limit: '5mb'
}))
// --------------------------------------------------------------
// app, '/*.mp4', 'video/mp4', 'stuff/video'
function appGetFileType (app, wildcard, contentType, pageToRender) {
app.get(wildcard, function (req, res) {
let p = decodeURI(req.url)
let fp = p
if (p.includes('?')) {
fp = p.split('?')
fp.pop()
fp = fp.join('/')
}
const fpath = './public/files' + fp
if (!fs.existsSync(fpath)) {
res.render('nofile', {
missingFile: fpath,
url
})
return
}
if (req.query.stream || !pageToRender) {
const stat = fs.statSync(fpath)
const fileSize = stat.size
const range = req.headers.range
if (range) {
const parts = range.replace(/bytes=/, '').split('-')
const start = parseInt(parts[0], 10)
const end = parts[1]
? parseInt(parts[1], 10)
: fileSize - 1
const chunksize = (end - start) + 1
const file = fs.createReadStream(fpath, { start, end })
const head = {
'Content-Range': `bytes ${start}-${end}/${fileSize}`,
'Accept-Ranges': 'bytes',
'Content-Length': chunksize,
'Content-Type': contentType
}
res.writeHead(206, head)
file.pipe(res)
} else {
const head = {
'Content-Length': fileSize,
'Content-Type': contentType
}
res.writeHead(200, head)
fs.createReadStream(fpath).pipe(res)
}
} else {
logger.LogReq(req)
let fname = fpath.split('/')
fname = fname.pop()
res.render(pageToRender, {
path: fp,
fname,
url,
contentType,
albumArt: GetAlbumArt(p)
})
}
})
}
const fileTypes = [
['/*.mp4', 'video/mp4', 'video'],
['/*.mkv', 'audio/x-matroska', 'video'],
['/*.mp3', 'audio/mpeg', 'audio'],
['/*.pdf', 'application/pdf'],
['/*.zip', 'application/zip']
]
function GetAlbumArt (path) {
let tmp = path.split('.')
tmp.pop()
tmp = tmp.join('.').split('/')
let last = tmp.pop()
return tmp.join('/') + '/.' + last + '.png'
}
fileTypes.forEach((t) => {
appGetFileType(app, t[0], t[1], t[2])
})
app.get('/*', function (req, res) {
let parsedUrl = decodeURI(req.url)
let curr = listedFiles + '/' + parsedUrl.substring('/'.length, parsedUrl.length).split('?')[0]
let relPath = curr.substring('./public/files'.length, curr.length)
if (relPath[relPath.length - 1] !== '/') { relPath += '/' }
let t = relPath.split('/')
let prevDir = ''
for (let i = 0; i < t.length - 2; i++) { prevDir += t[i] + '/' }
// curr = curr.replace(/\//g, "/");
// relPath = relPath.replace(/\//g, "/");
logger.LogReq(req)
try {
if (fs.lstatSync(curr).isDirectory()) {
if (curr[curr.length - 1] !== '/') { curr += '/' }
let f = []
fs.readdirSync(curr).forEach((item) => {
if (item[0] !== '.') {
let res = { name: item }
let stat = fs.statSync(curr + '/' + item)
let fileSizeInBytes = stat['size']
res.size = Math.round(fileSizeInBytes / 1000000)
res.path = relPath
if (res.path[res.path.length - 1] !== '/') { res.path += '/' }
res.path += item
res.mtime = stat['mtime'].toLocaleString()
res.isDir = stat.isDirectory()
f.push(res)
}
})
res.render('folders', {
folders: f,
dirname: relPath,
prevDir,
url
})
} else {
let fileStream = fs.createReadStream(curr)
fileStream.pipe(res)
}
} catch (e) {
res.render('nofile', {
missingFile: curr,
url
})
}
})
// -----------------------------------------------------------------------------------------------
app.get('*', function (req, res) {
res.status(404).render('shared/404')
})
app.post('*', function (req, res) {
res.status(404).render('shared/404')
})
exports.app = app
exports.setup = (x) => {
url = x.url
}
logger.Log('Stuff module started', logger.GetColor('yellow'))

39
modules/stuff/views/audio.ejs Executable file
View file

@ -0,0 +1,39 @@
<html>
<body bgcolor="#212127">
<head>
<title><%= fname %></title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=0.6" />
<style>
body {
font: normal 14px Verdana;
color: #999999;
}
video {
width: 100%
}
</style>
</head>
<center>
<h2>
<%= fname %>
</h2>
<img
id="coverArt"
style="width:auto; max-height: 100%;"
src="<%= url + albumArt %>"
alt=' '
/>
<audio id="audioPlayer" controls style="width:100%">
<source src="<%= url %><%= path %>?stream=true" type=<%= contentType %>>
</audio>
</center>
</body>
<script>
console.log('a')
document.getElementById('coverArt').style.height = window.innerHeight - 140
</script>
</html>

130
modules/stuff/views/folders.ejs Executable file
View file

@ -0,0 +1,130 @@
<html>
<body bgcolor="#212127">
<head>
<title><%=dirname%></title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=0.6" />
<style>
body {
font: normal 14px Verdana;
color: #999999;
}
td {
vertical-align: top;
word-wrap: break-word;
word-break: break-all;
table-layout: fixed;
padding: 0 12;
vertical-align: middle;
}
textarea {
font: normal 14px Verdana;
color: #999999;
background-color: #212127;
width: 100%;
height: 700;
}
a {
color: #9999ff;
}
.subtable {
border-collapse: collapse;
table-layout:fixed;
width:100%
}
.maintable {
border-collapse: collapse;
table-layout:fixed;
width:100%
padding:0; margin:0;
border: none !important;
}
tr {
width:32%;
}
.butt {
background-color: #212127;
color: #999999;
cursor: pointer;
width: 100%;
border: none;
text-align: left;
outline: none;
font-size: 13px;
}
</style>
</head>
<center>
<h1>
<%=dirname%>
</h1>
</center>
<h2>
<a href="<%= url + prevDir%>" > Up one level </a>
</h2>
</p>
<table class="maintable">
<% for (var i = 0; i < folders.length; i++) { %>
<tr>
<td>
<a
href="<%= url + folders[i].path %>"
style="font-size: 0px"
>
<button
class="butt"
style='<%= i % 2 === 0 ? "background-color: #2f2f37" : "" %>'
onmouseenter='mouseEnter(this, <%= i %>)'
onmouseleave='mouseLeave(this, <%= i %>)'
>
<table class="subtable">
<tr height="62">
<td style='width:30%;'>
<%=folders[i].name %>
</td>
<td style='width:20%;'>
<%=folders[i].mtime %>
</td>
<td style='width:10%;'>
<%
if (folders[i].isDir) {
%> <%= "DIR" %> <%
} else {
if (folders[i].size === 0) {
%> <%= "~0 MB" %> <%
} else {
%> <%= folders[i].size + ' MB' %> <%
}
}
%>
</td>
</tr>
</table>
</button>
</a>
</td>
</tr>
<% } %>
</table>
</body>
<script>
console.log('hi')
function mouseEnter (e, i) {
e.style.backgroundColor = "#555"
}
function mouseLeave (e, i) {
if (i % 2 == 0) {
e.style.backgroundColor = "#2f2f37"
} else {
e.style.backgroundColor = "#212127"
}
}
</script>
</html>

94
modules/stuff/views/nofile.ejs Executable file
View file

@ -0,0 +1,94 @@
<html>
<body bgcolor="#212127">
<head>
<title>No such file/folder</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;
}
.subtable {
border-collapse: collapse;
table-layout:fixed;
width:100%
}
.maintable {
border-collapse: collapse;
table-layout:fixed;
width:100%
padding:0; margin:0;
border: none !important;
}
tr {
line-height: 29px;
width:32%;
}
.butt {
background-color: #212127;
color: #999999;
cursor: pointer;
width: 100%;
border: none;
text-align: left;
outline: none;
font-size: 13px;
}
.active,
.butt:hover {
background-color: #555;
}
</style>
</head>
<center>
<h1>
No such file / folder:
</br>
<%= missingFile %>
</br>
<a href="<%= url %>" > Back to root </a>
</br>
<a
onclick='goBack("<%=missingFile%>")'
href="#"
>
Go back
</a>
</h1>
</center>
</body>
<script>
function goBack(path) {
path = path.replace('./public/files', '')
if (path[path.length - 1] == '/') {
path = path.substring(0, path.length -2)
}
let p = path.split('/')
p.pop()
if (p.length > 1) {
location.href = p.join('/')
} else {
location.href = '/'
}
}
</script>
</html>

34
modules/stuff/views/video.ejs Executable file
View file

@ -0,0 +1,34 @@
<html>
<body bgcolor="#212127">
<head>
<title><%= fname %></title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=0.6" />
<style>
body {
font: normal 14px Verdana;
color: #999999;
}
video {
width: 100%
}
</style>
</head>
<center>
<h2>
<%= fname %>
</h2>
</center>
<video id="videoPlayer" controls>
<source src="<%= url %><%= path %>?stream=true" type="video/mp4">
</video>
</body>
<script>
var v = document.getElementsByTagName('video')[0]
v.style.maxHeight = window.innerHeight - 100
v.maxWidth = window.innerWidth
console.log('a')
</script>
</html>