This commit is contained in:
MrFry 2019-10-26 10:21:30 +02:00
commit 19246d6931
14 changed files with 425 additions and 239 deletions

View file

@ -18,7 +18,7 @@
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
const siteUrl = 'https://qmining.frylabs.net' // http(s)//asd.basd let url = '' // http(s)//asd.basd
const express = require('express') const express = require('express')
const bodyParser = require('body-parser') const bodyParser = require('body-parser')
@ -49,7 +49,7 @@ app.use(bodyParser.json({
app.get('/', function (req, res) { app.get('/', function (req, res) {
res.render('main/main', { res.render('main/main', {
siteurl: siteUrl siteurl: url
}) })
}) })
@ -65,5 +65,8 @@ app.post('*', function (req, res) {
}) })
exports.app = app exports.app = app
exports.setup = (x) => {
url = x.url
}
logger.Log('Main module started', logger.GetColor('yellow')) logger.Log('Main module started', logger.GetColor('yellow'))

View file

@ -18,6 +18,7 @@
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
let url = ''
const express = require('express') const express = require('express')
const app = express() const app = express()
@ -26,17 +27,20 @@ const logger = require('../utils/logger.js')
// -------------------------------------------------------------- // --------------------------------------------------------------
app.get('/', function (req, res) { app.get('/', function (req, res) {
res.redirect('https://qmining.frylabs.net' + req.url) res.redirect(url + req.url)
}) })
app.get('*', function (req, res) { app.get('*', function (req, res) {
res.redirect('https://qmining.frylabs.net' + req.url) res.redirect(url + req.url)
}) })
app.post('*', function (req, res) { app.post('*', function (req, res) {
res.redirect('https://qmining.frylabs.net' + req.url) res.redirect(url + req.url)
}) })
exports.app = app exports.app = app
exports.setup = (x) => {
url = x.url
}
logger.Log('Old module started', logger.GetColor('yellow')) logger.Log('Old module started', logger.GetColor('yellow'))

View file

@ -18,7 +18,7 @@
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
const siteUrl = 'https://qmining.frylabs.net' // http(s)//asd.basd let url = ''
const express = require('express') const express = require('express')
const bodyParser = require('body-parser') const bodyParser = require('body-parser')
@ -59,7 +59,7 @@ app.get('/', function (req, res) {
// req.hostname // req.hostname
res.render('qmining/main', { res.render('qmining/main', {
siteurl: siteUrl, siteurl: url,
qa: actions.ProcessQA() qa: actions.ProcessQA()
}) })
res.end() res.end()
@ -82,7 +82,7 @@ app.get('/legacy', function (req, res) {
data: d, data: d,
scount: scount, scount: scount,
qcount: qcount, qcount: qcount,
siteurl: siteUrl siteurl: url
}) })
logger.LogReq(req) logger.LogReq(req)
@ -135,7 +135,13 @@ app.get('/greasy', function (req, res) {
}) })
app.get('/install', function (req, res) { app.get('/install', function (req, res) {
res.redirect(siteUrl + '/moodle-test-userscript/stable.user.js?install') res.redirect(url + '/moodle-test-userscript/stable.user.js?install')
res.end()
logger.LogReq(req)
})
app.get('/install', function (req, res) {
res.redirect(url + '/moodle-test-userscript/stable.user.js')
res.end() res.end()
logger.LogReq(req) logger.LogReq(req)
}) })
@ -206,5 +212,8 @@ app.post('*', function (req, res) {
}) })
exports.app = app exports.app = app
exports.setup = (x) => {
url = x.url
}
logger.Log('Qmining module started', logger.GetColor('yellow')) logger.Log('Qmining module started', logger.GetColor('yellow'))

View file

@ -23,6 +23,7 @@ const bodyParser = require('body-parser')
const busboy = require('connect-busboy') const busboy = require('connect-busboy')
const fs = require('fs') const fs = require('fs')
const app = express() const app = express()
let url = ''
const logger = require('../utils/logger.js') const logger = require('../utils/logger.js')
// const utils = require('../utils/utils.js') // const utils = require('../utils/utils.js')
@ -49,7 +50,8 @@ app.use(bodyParser.json({
// -------------------------------------------------------------- // --------------------------------------------------------------
app.get('/*', function (req, res) { app.get('/*', function (req, res) {
let curr = listedFiles + '/' + req.url.substring('/'.length, req.url.length).split('?')[0] let parsedUrl = req.url.replace(/%20/g, ' ')
let curr = listedFiles + '/' + parsedUrl.substring('/'.length, parsedUrl.length).split('?')[0]
let relPath = curr.substring('./public/files'.length, curr.length) let relPath = curr.substring('./public/files'.length, curr.length)
if (relPath[relPath.length - 1] !== '/') { relPath += '/' } if (relPath[relPath.length - 1] !== '/') { relPath += '/' }
@ -63,6 +65,7 @@ app.get('/*', function (req, res) {
logger.LogReq(req) logger.LogReq(req)
try {
if (fs.lstatSync(curr).isDirectory()) { if (fs.lstatSync(curr).isDirectory()) {
if (curr[curr.length - 1] !== '/') { curr += '/' } if (curr[curr.length - 1] !== '/') { curr += '/' }
@ -89,12 +92,19 @@ app.get('/*', function (req, res) {
res.render('stuff/folders', { res.render('stuff/folders', {
folders: f, folders: f,
dirname: relPath, dirname: relPath,
prevDir prevDir,
url
}) })
} else { } else {
let fileStream = fs.createReadStream(curr) let fileStream = fs.createReadStream(curr)
fileStream.pipe(res) fileStream.pipe(res)
} }
} catch (e) {
res.render('stuff/nofile', {
missingFile: curr,
url
})
}
}) })
// ----------------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------------
@ -111,5 +121,8 @@ app.post('*', function (req, res) {
}) })
exports.app = app exports.app = app
exports.setup = (x) => {
url = x.url
}
logger.Log('Stuff module started', logger.GetColor('yellow')) logger.Log('Stuff module started', logger.GetColor('yellow'))

View file

@ -32,11 +32,69 @@ const https = require('https')
const stat = require('./utils/stat.js') const stat = require('./utils/stat.js')
stat.Load() stat.Load()
const qmining = require('./modules/qmining.js').app const loggableKeywords = [
const main = require('./modules/main.js').app 'user.js'
const sio = require('./modules/sio.js').app ]
const stuff = require('./modules/stuff.js').app let modules = {
const old = require('./modules/old.js').app qmining: {
path: './modules/qmining.js',
name: 'qmining',
urls: [ 'qmining.frylabs.net', 'localhost' ]
},
main: {
path: './modules/main.js',
name: 'main',
urls: [ 'frylabs.net', 'www.frylabs.net' ]
},
sio: {
path: './modules/sio.js',
name: 'sio',
urls: [ 'sio.frylabs.net' ]
},
stuff: {
path: './modules/stuff.js',
name: 'stuff',
urls: [ 'stuff.frylabs.net' ]
},
old: {
path: './modules/old.js',
name: 'old',
urls: [ 'qmining.tk', 'www.qmining.tk' ]
}
}
const app = express()
app.use(function (req, res, next) {
res.on('finish', function () {
logger.LogReq(req, true, res.statusCode)
let toLog = loggableKeywords.some((x) => {
return req.url.includes(x)
})
if (toLog) { logger.LogReq(req) }
if (res.statusCode !== 404) { stat.LogStat(req.url) }
})
next()
})
Object.keys(modules).forEach(function (k, i) {
let x = modules[k]
try {
let mod = require(x.path)
if (mod.setup) {
mod.setup({
url: 'http://' + x.urls[0] // TODO http https or neither
})
}
x.app = mod.app
x.urls.forEach((url) => {
app.use(vhost(url, x.app))
})
} catch (e) {
console.log(e)
}
})
const locLogFile = './stats/logs' const locLogFile = './stats/logs'
const allLogFile = '/nlogs/log' const allLogFile = '/nlogs/log'
@ -93,35 +151,6 @@ function setLogTimer () {
setLogTimer() setLogTimer()
const app = express()
const loggableKeywords = [
'user.js'
]
app.use(function (req, res, next) {
res.on('finish', function () {
logger.LogReq(req, true, res.statusCode)
let toLog = loggableKeywords.some((x) => {
return req.url.includes(x)
})
if (toLog) { logger.LogReq(req) }
if (res.statusCode !== 404) { stat.LogStat(req.url) }
})
next()
})
app.use(vhost('qmining.frylabs.net', qmining))
app.use(vhost('sio.frylabs.net', sio))
app.use(vhost('stuff.frylabs.net', stuff))
app.use(vhost('frylabs.net', main))
app.use(vhost('www.frylabs.net', main))
app.use(vhost('qmining.tk', old))
app.use(vhost('www.qmining.tk', old))
app.use(vhost('localhost', qmining))
logger.Log('Node version: ' + process.version) logger.Log('Node version: ' + process.version)
logger.Log('Listening on port: ' + port) logger.Log('Listening on port: ' + port)

View file

@ -33,14 +33,19 @@ const logFile = '/nlogs/nlogs'
const allLogFile = '/nlogs/log' const allLogFile = '/nlogs/log'
const colors = [ const colors = [
'red',
'green', 'green',
'red',
'yellow', 'yellow',
'blue', 'blue',
'magenta', 'magenta',
'cyan' 'cyan'
] ]
let noLogips = utils.ReadFile('./nolog').split('\n')
setInterval(() => {
noLogips = utils.ReadFile('./nolog').split('\n')
}, 1000 * 60 * 30)
function GetDateString () { function GetDateString () {
const m = new Date() const m = new Date()
const d = m.getFullYear() + '/' + const d = m.getFullYear() + '/' +
@ -64,13 +69,21 @@ function LogReq (req, toFile, sc) {
try { try {
let ip = req.headers['cf-connecting-ip'] || req.connection.remoteAddress let ip = req.headers['cf-connecting-ip'] || req.connection.remoteAddress
let nolog = noLogips.some((x) => {
return x.includes(ip)
})
if (nolog) {
return
}
let logEntry = GetRandomColor(ip) + ip + C() let logEntry = GetRandomColor(ip) + ip + C()
let dl = DELIM let dl = DELIM
if (req.url.includes('lred')) { if (req.url.includes('lred')) {
dl += C('red') dl += C('red')
} }
logEntry += dl + req.hostname + dl + req.headers['user-agent'] + dl + req.method + dl const hostname = req.hostname.replace('www.', '').split('.')[0]
logEntry += dl + hostname + dl + req.headers['user-agent'] + dl + req.method + dl
logEntry += GetRandomColor(req.url.split('?')[0]) + req.url logEntry += GetRandomColor(req.url.split('?')[0]) + req.url
@ -111,8 +124,8 @@ function C (c) {
if (c === 'redbg') { return '\x1b[41m' } if (c === 'redbg') { return '\x1b[41m' }
if (c === 'bluebg') { return '\x1b[44m' } if (c === 'bluebg') { return '\x1b[44m' }
if (c === 'red') { return '\x1b[31m' }
if (c === 'green') { return '\x1b[32m' } if (c === 'green') { return '\x1b[32m' }
if (c === 'red') { return '\x1b[31m' }
if (c === 'yellow') { return '\x1b[33m' } if (c === 'yellow') { return '\x1b[33m' }
if (c === 'blue') { return '\x1b[34m' } if (c === 'blue') { return '\x1b[34m' }
if (c === 'magenta') { return '\x1b[35m' } if (c === 'magenta') { return '\x1b[35m' }

View file

@ -5,6 +5,7 @@
<head> <head>
<title>FryLabs.net</title> <title>FryLabs.net</title>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=0.8" />
<style> <style>
body { body {
font: normal 14px Verdana; font: normal 14px Verdana;

View file

@ -5,6 +5,7 @@
<head> <head>
<title>All questions</title> <title>All questions</title>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=0.8" />
<style> <style>
body { body {
font: normal 14px Verdana; font: normal 14px Verdana;
@ -79,7 +80,12 @@
<% include aludni.ejs %> <% include aludni.ejs %>
<% for (var i = 0; i < data.Subjects.length; i++) { %> <% for (var i = 0; i < data.Subjects.length; i++) { %>
<button class="collapsible"> <button
class="collapsible"
style='<%= i % 2 === 0 ? "background-color: #2f2f37" : "" %>'
onmouseenter='mouseEnter(this, <%= i %>)'
onmouseleave='mouseLeave(this, <%= i %>)'
>
<h2> <h2>
<table id=<%=i%>> <table id=<%=i%>>
<td> <td>
@ -124,6 +130,16 @@
coll[i].style.display = "block"; 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> </script>
<% include b.ejs %> <% include b.ejs %>
</body> </body>

View file

@ -5,6 +5,7 @@
<head> <head>
<title>All questions</title> <title>All questions</title>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=0.8" />
<style> <style>
body { body {
font: normal 14px Verdana; font: normal 14px Verdana;

View file

@ -5,6 +5,7 @@
<head> <head>
<title>Question mining</title> <title>Question mining</title>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=0.8" />
<style> <style>
body { body {
font: normal 14px Verdana; font: normal 14px Verdana;

View file

@ -5,6 +5,8 @@
<head> <head>
<title>Moodle/Elearning/KMOOC manual</title> <title>Moodle/Elearning/KMOOC manual</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=0.8" />
<style> <style>
body { body {
font: normal 17px Verdana; font: normal 17px Verdana;
@ -196,12 +198,11 @@
</li> </li>
</ul> </ul>
<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_info: a
GM_getResourceText: a txt beolvasáshoz. Mást nem bír beolvasni, csak amit megadsz a @resouces scriptről információ, a verzióváltozás érzékeléséhez. GM_getValue/ GM_setValue: oldal
tagnál. GM_info: a scriptről információ, a verzióváltozás érzékeléséhez. GM_getValue/ bezárásakor megmaradó változók kezelése. Előző verzió tárolására, ugyanúgy verzióváltozás
GM_setValue: oldal bezárásakor megmaradó változók kezelése. Előző verzió tárolására, ugyanúgy érzékeléséhez, néhány beállítás, illetve hogy melyik tárgyakból keressen kérdéseket. Ezek
verzióváltozás érzékeléséhez, néhány beállítás, illetve hogy melyik tárgyakból keressen függvények, és a sciptben néhol meg vannak hívva, keresd meg.
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 </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 helyesnek vélt válaszok. Fogadott adatok: az összes eddig ismert moodle kérdés
<hr> <hr>

View file

@ -3,6 +3,8 @@
<body bgcolor="#212127"> <body bgcolor="#212127">
<head> <head>
<meta name="viewport" content="width=device-width, initial-scale=0.8" />
<meta charset="UTF-8">
<style> <style>
body { body {
font: normal 14px Verdana; font: normal 14px Verdana;

View file

@ -5,6 +5,7 @@
<head> <head>
<title><%=dirname%></title> <title><%=dirname%></title>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=0.6" />
<style> <style>
body { body {
font: normal 14px Verdana; font: normal 14px Verdana;
@ -12,7 +13,12 @@
} }
td { td {
vertical-align: top vertical-align: top;
word-wrap: break-word;
word-break: break-all;
table-layout: fixed;
padding: 0 12;
vertical-align: middle;
} }
textarea { textarea {
@ -39,7 +45,6 @@
border: none !important; border: none !important;
} }
tr { tr {
line-height: 29px;
width:32%; width:32%;
} }
.butt { .butt {
@ -53,11 +58,6 @@
font-size: 13px; font-size: 13px;
} }
.active,
.butt:hover {
background-color: #555;
}
</style> </style>
</head> </head>
<center> <center>
@ -65,27 +65,32 @@
<%=dirname%> <%=dirname%>
</h1> </h1>
</center> </center>
<a href=<%= "http://stuff.frylabs.net" + prevDir%> > Up one level </a> <a href="<%= url + prevDir%>" > Up one level </a>
</p> </p>
<table class="maintable"> <table class="maintable">
<% for (var i = 0; i < folders.length; i++) { %> <% for (var i = 0; i < folders.length; i++) { %>
<tr> <tr>
<td> <td>
<button class="butt"> <button
class="butt"
onclick='itemClick("<%= "http://stuff.frylabs.net" + folders[i].path %>")'
style='<%= i % 2 === 0 ? "background-color: #2f2f37" : "" %>'
onmouseenter='mouseEnter(this, <%= i %>)'
onmouseleave='mouseLeave(this, <%= i %>)'
>
<table class="subtable"> <table class="subtable">
<tr height="62">
<td style='width:30%;'> <td style='width:30%;'>
<a href="<%= "http://stuff.frylabs.net" + folders[i].path%>"> <%=folders[i].name %> </a> <%=folders[i].name %>
</td>
<td style='width:30%;'>
<%=folders[i].path %>
</td> </td>
<td style='width:20%;'> <td style='width:20%;'>
<%=folders[i].mtime %> <%=folders[i].mtime %>
</td> </td>
<td style='width:10%;'> <td style='width:10%;'>
<%=folders[i].size %> MB <%= folders[i].size === 0 ? "Dir" : folders[i].size + 'MB' %>
</td> </td>
</tr>
</table> </table>
</button> </button>
</td> </td>
@ -93,4 +98,20 @@
<% } %> <% } %>
</table> </table>
</body> </body>
<script>
console.log('hi')
function itemClick (e) {
location.href = e
}
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> </html>

72
views/stuff/nofile.ejs Normal file
View file

@ -0,0 +1,72 @@
<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>
</h1>
</center>
</body>
</html>