Modified rest, and added client-version

This commit is contained in:
Kasper Rynning-Tønnesen
2018-03-12 17:06:47 +01:00
parent 79fa8805b2
commit c21eee838a
17 changed files with 329 additions and 153 deletions

View File

@@ -142,7 +142,7 @@ router.route('/api/list/:channel_name/:video_id').delete(function(req, res) {
var ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
var guid = Functions.hash_pass(req.get('User-Agent') + ip + req.headers["accept-language"]);
var adminpass = req.body.adminpass == "" ? "" : Functions.hash_pass(crypto.createHash('sha256').update(req.body.adminpass, 'utf8').digest("hex"));
req.body.userpass = req.body.userpass == "" ? "" : crypto.createHash('sha256').update(req.body.userpass, 'utf8').digest("hex");
req.body.userpass = req.body.userpass == "" ? "" : req.body.userpass;
var userpass = req.body.userpass;
var channel_name = cleanChannelName(req.params.channel_name);
var video_id = req.params.video_id;
@@ -243,7 +243,7 @@ router.route('/api/conf/:channel_name').put(function(req, res) {
var ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
var guid = Functions.hash_pass(req.get('User-Agent') + ip + req.headers["accept-language"]);
var adminpass = req.body.adminpass == "" ? "" : Functions.hash_pass(crypto.createHash('sha256').update(req.body.adminpass, 'utf8').digest("hex"));
req.body.userpass = req.body.userpass == "" ? "" : crypto.createHash('sha256').update(req.body.userpass, 'utf8').digest("hex");
req.body.userpass = req.body.userpass == "" ? "" : req.body.userpass;
var userpass = req.body.userpass;
var voting = req.body.vote;
var addsongs = req.body.addsongs;
@@ -398,7 +398,7 @@ router.route('/api/list/:channel_name/:video_id').put(function(req,res) {
var ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
var guid = Functions.hash_pass(req.get('User-Agent') + ip + req.headers["accept-language"]);
var adminpass = req.body.adminpass == "" ? "" : Functions.hash_pass(crypto.createHash('sha256').update(req.body.adminpass, 'utf8').digest("hex"));
req.body.userpass = req.body.userpass == "" ? "" : crypto.createHash('sha256').update(req.body.userpass, 'utf8').digest("hex");
req.body.userpass = req.body.userpass == "" ? "" : req.body.userpass;
var userpass = req.body.userpass;
var channel_name = cleanChannelName(req.params.channel_name);
var video_id = req.params.video_id;
@@ -485,7 +485,7 @@ router.route('/api/list/:channel_name/__np__').post(function(req, res) {
var ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
var guid = Functions.hash_pass(req.get('User-Agent') + ip + req.headers["accept-language"]);
var channel_name = req.params.channel_name;
req.body.userpass = req.body.userpass == "" ? "" : crypto.createHash('sha256').update(req.body.userpass, 'utf8').digest("hex");
req.body.userpass = req.body.userpass == "" ? "" : req.body.userpass;
var userpass = req.body.userpass;
var token = "";
if(req.body.hasOwnProperty("token")) {
@@ -569,7 +569,7 @@ router.route('/api/list/:channel_name/:video_id').post(function(req,res) {
var ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
var guid = Functions.hash_pass(req.get('User-Agent') + ip + req.headers["accept-language"]);
req.body.userpass = req.body.userpass == "" ? "" : crypto.createHash('sha256').update(req.body.userpass, 'utf8').digest("hex");
req.body.userpass = req.body.userpass == "" ? "" : req.body.userpass;
var userpass = req.body.userpass;
var channel_name = cleanChannelName(req.params.channel_name);
var video_id = req.params.video_id;
@@ -817,7 +817,7 @@ router.route('/api/conf/:channel_name').post(function(req, res) {
var ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
var guid = Functions.hash_pass(req.get('User-Agent') + ip + req.headers["accept-language"]);
var channel_name = req.params.channel_name;
req.body.userpass = req.body.userpass == "" ? "" : crypto.createHash('sha256').update(req.body.userpass, 'utf8').digest("hex");
req.body.userpass = req.body.userpass == "" ? "" : req.body.userpass;
var userpass = req.body.userpass;
if(typeof(userpass) != "string") {
@@ -916,7 +916,6 @@ router.route('/api/list/:channel_name').post(function(req, res) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
res.header({"Content-Type": "application/json"});
try {
if(!req.body.hasOwnProperty('userpass')) {
throw "Wrong format";
@@ -929,7 +928,7 @@ router.route('/api/list/:channel_name').post(function(req, res) {
var ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
var guid = Functions.hash_pass(req.get('User-Agent') + ip + req.headers["accept-language"]);
var channel_name = req.params.channel_name;
req.body.userpass = req.body.userpass == "" ? "" : crypto.createHash('sha256').update(req.body.userpass, 'utf8').digest("hex");
req.body.userpass = req.body.userpass == "" ? "" : req.body.userpass;
var userpass = req.body.userpass;
if(typeof(userpass) != "string") {

View File

@@ -103,10 +103,10 @@ function root(req, res, next) {
try{
var url = req.headers['x-forwarded-host'] ? req.headers['x-forwarded-host'] : req.headers.host.split(":")[0];
var subdomain = req.headers['x-forwarded-host'] ? req.headers['x-forwarded-host'].split(".") : req.headers.host.split(":")[0].split(".");
if(url != "zoff.me" && url != "admin.localhost" && url != "admin.zoff.me" && url != "remote.zoff.me" && url != "fb.zoff.me" && url != "remote.localhost" && url != "localhost") {
/*if(url != "zoff.me" && url != "admin.localhost" && url != "admin.zoff.me" && url != "remote.zoff.me" && url != "fb.zoff.me" && url != "remote.localhost" && url != "localhost") {
res.redirect("https://zoff.me");
return;
}
}*/
if(subdomain[0] == "remote") {
var data = {
year: year,
@@ -115,11 +115,13 @@ function root(req, res, next) {
analytics: analytics,
stylesheet: "style.css",
embed: false,
client: false
}
res.render('layouts/client/remote', data);
} else if(subdomain[0] == "www") {
res.redirect("https://zoff.me");
} else {
var data = {
year: year,
javascript_file: "main.min.js",
@@ -127,6 +129,10 @@ function root(req, res, next) {
analytics: analytics,
stylesheet: "style.css",
embed: false,
client: false
}
if(subdomain == "client") {
data.client = true;
}
res.render('layouts/client/frontpage', data);
}
@@ -140,10 +146,10 @@ function channel(req, res, next) {
try{
var url = req.headers['x-forwarded-host'] ? req.headers['x-forwarded-host'] : req.headers.host.split(":")[0];
var subdomain = req.headers['x-forwarded-host'] ? req.headers['x-forwarded-host'].split(".") : req.headers.host.split(":")[0].split(".");
if(url != "zoff.me" && url != "admin.localhost" && url != "admin.zoff.me" && url != "remote.zoff.me" && url != "fb.zoff.me" && url != "remote.localhost" && url != "localhost") {
/*if(url != "zoff.me" && url != "admin.localhost" && url != "admin.zoff.me" && url != "remote.zoff.me" && url != "fb.zoff.me" && url != "remote.localhost" && url != "localhost") {
res.redirect("https://zoff.me");
return;
}
}*/
if(subdomain[0] == "remote") {
var data = {
year: year,
@@ -152,6 +158,7 @@ function channel(req, res, next) {
analytics: analytics,
stylesheet: "style.css",
embed: false,
client: false
}
res.render('layouts/client/remote', data);
} else if(subdomain.length >= 2 && subdomain[0] == "www") {
@@ -180,8 +187,11 @@ function channel(req, res, next) {
analytics: analytics,
stylesheet: "style.css",
embed: false,
client:false
}
if(subdomain == "client") {
data.client = true;
}
if(req.params.channel_name == "404") {
res.status(404);