small changes

This commit is contained in:
Flummi 2016-09-10 17:53:13 +02:00
parent b99f4bb53f
commit a886d46064
2 changed files with 249 additions and 231 deletions

View File

@ -30,6 +30,8 @@ function Lib(tbot, tsql) {
Lib.prototype.sql = tsql; Lib.prototype.sql = tsql;
this.cfg = cfg = require('../cfg/main.json'); this.cfg = cfg = require('../cfg/main.json');
Lib.prototype.debug = cfg.debug;
Lib.prototype.loadUser((cb) => { Lib.prototype.loadUser((cb) => {
console.log((cb)?"Admins wurden geladen":"Admins konnten nicht geladen werden"); console.log((cb)?"Admins wurden geladen":"Admins konnten nicht geladen werden");
}); });
@ -122,7 +124,7 @@ Lib.prototype.generateThumbs = () => {
}; };
Lib.prototype.log = (msg) => { Lib.prototype.log = (msg) => {
if(Lib.prototype.debug) if(Lib.prototype.debug)
bot.send("#f0ck", msg, 'n0xy'); bot.send(cfg.debugchannel, msg, 'n0xy');
}; };
Lib.prototype.loadTrigger = () => { Lib.prototype.loadTrigger = () => {

View File

@ -22,6 +22,28 @@ function Websrv(tbot, tsql, tlib) {
var url = req.url.split("/")[1]; var url = req.url.split("/")[1];
if(filePath == './') if(filePath == './')
filePath = './index.html'; filePath = './index.html';
if(req.method == 'POST') {
if(filePath == './git') {
var body = '';
req.on('data', (data) => {
body += data;
if(body.length > 1e6) {
req.connection.destroy();
}
});
req.on('end', () => {
console.log(body);
//var eventname = body.event_name;
//var autor = body.user_name;
//var commit = body.commits[body.commits[total_commits_count]-1].message;
//bot.log( eventname + ' from ' + autor + ' ('+commit+')' );
});
res.writeHead(200, { 'Content-Type': 'text/html' });
res.end('muh', 'utf-8');
}
}
else {
var extname = String(path.extname(filePath)).toLowerCase(); var extname = String(path.extname(filePath)).toLowerCase();
var contentType = 'text/html'; var contentType = 'text/html';
var mimeTypes = { var mimeTypes = {
@ -132,12 +154,6 @@ function Websrv(tbot, tsql, tlib) {
res.writeHead(200, { 'Content-Type': 'text/html' }); res.writeHead(200, { 'Content-Type': 'text/html' });
res.end(tpl(), 'utf-8'); res.end(tpl(), 'utf-8');
} }
else if(filePath == './git') {
console.log(filePath);
console.log(res);
res.writeHead(200, { 'Content-Type': 'text/html' });
res.end('muh', 'utf-8');
}
else if(filePath.match(/^\.\/(b|s|t)\/.*/)) { // file else if(filePath.match(/^\.\/(b|s|t)\/.*/)) { // file
contentType = mimeTypes[extname]; contentType = mimeTypes[extname];
switch(contentType) { switch(contentType) {
@ -272,8 +288,8 @@ function Websrv(tbot, tsql, tlib) {
res.end('404 - f0ck you', 'utf-8'); res.end('404 - f0ck you', 'utf-8');
} }
} }
}
else { else {
console.log(req);
res.writeHead(403); res.writeHead(403);
res.end('403 - forbidden'); res.end('403 - forbidden');
} }