mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
Added main site, code formatting
This commit is contained in:
parent
814abae86b
commit
77427399db
4 changed files with 61 additions and 29 deletions
|
@ -18,6 +18,8 @@
|
||||||
|
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
const siteUrl = 'https://qmining.frylabs.net' // http(s)//asd.basd
|
||||||
|
|
||||||
const express = require('express')
|
const express = require('express')
|
||||||
const bodyParser = require('body-parser')
|
const bodyParser = require('body-parser')
|
||||||
const busboy = require('connect-busboy')
|
const busboy = require('connect-busboy')
|
||||||
|
@ -55,8 +57,9 @@ app.use(bodyParser.json({
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
|
|
||||||
app.get('/', function (req, res) {
|
app.get('/', function (req, res) {
|
||||||
// res.render()
|
res.render('main/main', {
|
||||||
res.end('henlo')
|
siteurl: siteUrl
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
app.get('*', function (req, res) {
|
app.get('*', function (req, res) {
|
||||||
|
|
|
@ -27,48 +27,44 @@ module.exports = {
|
||||||
|
|
||||||
const DELIM = '|'
|
const DELIM = '|'
|
||||||
|
|
||||||
var utils = require('../utils/utils.js')
|
const utils = require('../utils/utils.js')
|
||||||
const nlogFile = './stats/nlogs'
|
|
||||||
const locLogFile = './stats/logs'
|
const locLogFile = './stats/logs'
|
||||||
const logFile = '/nlogs/nlogs'
|
const logFile = '/nlogs/nlogs'
|
||||||
const allLogFile = '/nlogs/log'
|
const allLogFile = '/nlogs/log'
|
||||||
|
|
||||||
function GetDateString () {
|
function GetDateString () {
|
||||||
var m = new Date()
|
const m = new Date()
|
||||||
return m.getFullYear() + '/' +
|
return m.getFullYear() + '/' +
|
||||||
('0' + (m.getMonth() + 1)).slice(-2) + '/' +
|
('0' + (m.getMonth() + 1)).slice(-2) + '/' +
|
||||||
('0' + m.getDate()).slice(-2) + ' ' +
|
('0' + m.getDate()).slice(-2) + ' ' +
|
||||||
('0' + m.getHours()).slice(-2) + ':' +
|
('0' + m.getHours()).slice(-2) + ':' +
|
||||||
('0' + m.getMinutes()).slice(-2) + ':' +
|
('0' + m.getMinutes()).slice(-2) + ':' +
|
||||||
('0' + m.getSeconds()).slice(-2)
|
('0' + m.getSeconds()).slice(-2)
|
||||||
}
|
}
|
||||||
|
|
||||||
function Log (s, c, b) {
|
function Log (s, c, b) {
|
||||||
if (c != undefined) { console.log(c, GetDateString() + DELIM + s) } else { console.log(GetDateString() + DELIM + s) }
|
if (c !== undefined) { console.log(c, GetDateString() + DELIM + s) } else { console.log(GetDateString() + DELIM + s) }
|
||||||
|
|
||||||
if (b) { utils.Beep() }
|
if (b) { utils.Beep() }
|
||||||
|
|
||||||
utils.AppendToFile(GetDateString() + DELIM + s, nlogFile)
|
|
||||||
utils.AppendToFile(GetDateString() + DELIM + s, logFile)
|
utils.AppendToFile(GetDateString() + DELIM + s, logFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
function LogReq (req, toFile, sc) {
|
function LogReq (req, toFile, sc) {
|
||||||
try {
|
try {
|
||||||
var ip = req.headers['cf-connecting-ip'] || req.connection.remoteAddress
|
let ip = req.headers['cf-connecting-ip'] || req.connection.remoteAddress
|
||||||
var logEntry = ip + DELIM + req.hostname + DELIM + req.headers['user-agent'] +
|
let logEntry = ip + DELIM + req.hostname + DELIM + req.headers['user-agent'] + DELIM + req.method + DELIM
|
||||||
DELIM + req.method + DELIM
|
|
||||||
|
|
||||||
logEntry += req.url
|
logEntry += req.url
|
||||||
|
|
||||||
if (sc != undefined && sc == 404) { logEntry += DELIM + sc }
|
if (sc !== undefined && sc === 404) { logEntry += DELIM + sc }
|
||||||
var color = GetColor('green')
|
let color = GetColor('green')
|
||||||
|
|
||||||
if (req.url.toLowerCase().includes('isadding')) { color = GetColor('yellow') }
|
if (req.url.toLowerCase().includes('isadding')) { color = GetColor('yellow') }
|
||||||
if (!toFile) {
|
if (!toFile) {
|
||||||
Log(logEntry, color)
|
Log(logEntry, color)
|
||||||
} else {
|
} else {
|
||||||
var defLogs = GetDateString() + DELIM + logEntry
|
let defLogs = GetDateString() + DELIM + logEntry
|
||||||
var extraLogs = '\n\t' + JSON.stringify(req.headers) + '\n\t' + JSON.stringify(req.body) + '\n'
|
|
||||||
|
|
||||||
utils.AppendToFile(defLogs, locLogFile)
|
utils.AppendToFile(defLogs, locLogFile)
|
||||||
utils.AppendToFile(defLogs, allLogFile)
|
utils.AppendToFile(defLogs, allLogFile)
|
||||||
|
@ -80,11 +76,11 @@ function LogReq (req, toFile, sc) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function GetColor (c) {
|
function GetColor (c) {
|
||||||
if (c == 'redbg') { return '\x1b[41m%s\x1b[0m' }
|
if (c === 'redbg') { return '\x1b[41m%s\x1b[0m' }
|
||||||
if (c == 'bluebg') { return '\x1b[44m%s\x1b[0m' }
|
if (c === 'bluebg') { return '\x1b[44m%s\x1b[0m' }
|
||||||
if (c == 'red') { return '\x1b[31m%s\x1b[0m' }
|
if (c === 'red') { return '\x1b[31m%s\x1b[0m' }
|
||||||
if (c == 'green') { return '\x1b[32m%s\x1b[0m' }
|
if (c === 'green') { return '\x1b[32m%s\x1b[0m' }
|
||||||
if (c == 'yellow') { return '\x1b[33m%s\x1b[0m' }
|
if (c === 'yellow') { return '\x1b[33m%s\x1b[0m' }
|
||||||
if (c == 'blue') { return '\x1b[34m%s\x1b[0m' }
|
if (c === 'blue') { return '\x1b[34m%s\x1b[0m' }
|
||||||
if (c == 'cyan') { return '\x1b[36m%s\x1b[0m' }
|
if (c === 'cyan') { return '\x1b[36m%s\x1b[0m' }
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,9 +14,6 @@ var fs = require('fs')
|
||||||
|
|
||||||
var logger = require('../utils/logger.js')
|
var logger = require('../utils/logger.js')
|
||||||
|
|
||||||
const recievedFile = './stats/recieved'
|
|
||||||
const manFile = './public/man.html'
|
|
||||||
const logFile = './stats/logs'
|
|
||||||
const dataFile = './public/data.json'
|
const dataFile = './public/data.json'
|
||||||
|
|
||||||
function ReadFile (name) {
|
function ReadFile (name) {
|
||||||
|
|
36
views/main/main.ejs
Normal file
36
views/main/main.ejs
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<body bgcolor="#212127">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>FryLabs.net</title>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font: normal 14px Verdana;
|
||||||
|
color: #999999;
|
||||||
|
}
|
||||||
|
|
||||||
|
td {
|
||||||
|
vertical-align: top
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: #9999ff;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<h2>
|
||||||
|
<a href="qmining.frylabs.net">QMining</a>
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
</hr>
|
||||||
|
|
||||||
|
henlo
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Add table
Add a link
Reference in a new issue