mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-12-08 20:48:48 +00:00
Added more info on faulty input
- Sent in the results on REST - Sent in the update_required msg on socket.io connection
This commit is contained in:
@@ -29,10 +29,24 @@ function chat(msg, guid, offline, socket) {
|
||||
!msg.hasOwnProperty('channel') || !msg.hasOwnProperty('pass') ||
|
||||
typeof(msg.data) != "string" || typeof(msg.channel) != "string" ||
|
||||
typeof(msg.pass) != "string") {
|
||||
socket.emit('update_required');
|
||||
var result = {
|
||||
data: {
|
||||
expected: "string",
|
||||
got: msg.hasOwnProperty("data") ? typeof(msg.data) : undefined,
|
||||
},
|
||||
channel: {
|
||||
expected: "string",
|
||||
got: msg.hasOwnProperty("channel") ? typeof(msg.channel) : undefined
|
||||
},
|
||||
pass: {
|
||||
expected: "string",
|
||||
got: msg.hasOwnProperty("pass") ? typeof(msg.pass) : undefined
|
||||
}
|
||||
};
|
||||
socket.emit('update_required', result);
|
||||
return;
|
||||
}
|
||||
var coll = msg.channel;
|
||||
var coll = msg.channel.toLowerCase();
|
||||
db.collection(coll + "_settings").find(function(err, docs){
|
||||
if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (msg.hasOwnProperty('pass') && docs[0].userpass == Functions.decrypt_string(socket.zoff_id, msg.pass)))) {
|
||||
var data = msg.data;
|
||||
@@ -64,10 +78,20 @@ function all_chat(msg, guid, offline, socket) {
|
||||
if(typeof(msg) !== 'object' || !msg.hasOwnProperty("channel") ||
|
||||
!msg.hasOwnProperty("data") || typeof(msg.data) != "string" ||
|
||||
typeof(msg.channel) != "string") {
|
||||
socket.emit('update_required');
|
||||
var result = {
|
||||
data: {
|
||||
expected: "string",
|
||||
got: msg.hasOwnProperty("data") ? typeof(msg.data) : undefined,
|
||||
},
|
||||
channel: {
|
||||
expected: "string",
|
||||
got: msg.hasOwnProperty("channel") ? typeof(msg.channel) : undefined
|
||||
}
|
||||
};
|
||||
socket.emit('update_required', result);
|
||||
return;
|
||||
}
|
||||
var coll = msg.channel;
|
||||
var coll = msg.channel.toLowerCase();
|
||||
var data = msg.data;
|
||||
|
||||
Functions.check_inlist(coll, guid, socket, offline);
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
function frontpage_lists(msg, socket) {
|
||||
if(msg == undefined || !msg.hasOwnProperty('version') || msg.version != VERSION || msg.version == undefined) {
|
||||
socket.emit("update_required");
|
||||
var result = {
|
||||
version: {
|
||||
expected: VERSION,
|
||||
got: msg.hasOwnProperty("version") ? msg.version : undefined,
|
||||
}
|
||||
};
|
||||
socket.emit('update_required', result);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ module.exports = function() {
|
||||
guid = msg.guid;
|
||||
socketid = msg.socket_id;
|
||||
socket.zoff_id = socketid;
|
||||
coll = msg.channel;
|
||||
coll = msg.channel.toLowerCase();
|
||||
in_list = true;
|
||||
chromecast_object = true;
|
||||
socket.join(coll);
|
||||
@@ -108,7 +108,13 @@ module.exports = function() {
|
||||
|
||||
socket.on("removename", function(msg) {
|
||||
if(typeof(msg) != "object" || !msg.hasOwnProperty("channel")) {
|
||||
socket.emit("update_required");
|
||||
var result = {
|
||||
channel: {
|
||||
expected: "string",
|
||||
got: msg.hasOwnProperty("channel") ? typeof(msg.channel) : undefined,
|
||||
}
|
||||
};
|
||||
socket.emit('update_required', result);
|
||||
return;
|
||||
}
|
||||
Chat.removename(guid, msg.channel);
|
||||
@@ -117,7 +123,17 @@ module.exports = function() {
|
||||
socket.on("offline", function(msg){
|
||||
if(!msg.hasOwnProperty('status') || !msg.hasOwnProperty('channel') ||
|
||||
typeof(msg.status) != "boolean" || typeof(msg.channel) != "string") {
|
||||
socket.emit("update_required");
|
||||
var result = {
|
||||
status: {
|
||||
expected: "boolean",
|
||||
got: msg.hasOwnProperty("status") ? typeof(msg.status) : undefined,
|
||||
},
|
||||
channel: {
|
||||
expected: "string",
|
||||
got: msg.hasOwnProperty("channel") ? typeof(msg.channel) : undefined
|
||||
}
|
||||
};
|
||||
socket.emit('update_required', result);
|
||||
return;
|
||||
}
|
||||
var status = msg.status;
|
||||
@@ -164,7 +180,21 @@ module.exports = function() {
|
||||
socket.on('get_history', function(msg) {
|
||||
if(!msg.hasOwnProperty("channel") || !msg.hasOwnProperty("all") ||
|
||||
typeof(msg.channel) != "string" || typeof(msg.all) != "boolean") {
|
||||
socket.emit("update_required");
|
||||
var result = {
|
||||
all: {
|
||||
expected: "boolean",
|
||||
got: msg.hasOwnProperty("all") ? typeof(msg.all) : undefined,
|
||||
},
|
||||
channel: {
|
||||
expected: "string",
|
||||
got: msg.hasOwnProperty("channel") ? typeof(msg.channel) : undefined,
|
||||
},
|
||||
pass: {
|
||||
expected: "string",
|
||||
got: msg.hasOwnProperty("pass") ? typeof(msg.pass) : undefined,
|
||||
}
|
||||
};
|
||||
socket.emit('update_required', result);
|
||||
return;
|
||||
}
|
||||
Chat.get_history(msg.channel, msg.all, socket);
|
||||
@@ -219,7 +249,7 @@ module.exports = function() {
|
||||
{
|
||||
if(coll === undefined) {
|
||||
try {
|
||||
coll = obj.channel;
|
||||
coll = obj.channel.toLowerCase();
|
||||
if(coll.length == 0) return;
|
||||
coll = emojiStrip(coll).toLowerCase();
|
||||
coll = coll.replace("_", "");
|
||||
@@ -252,7 +282,7 @@ module.exports = function() {
|
||||
socket.on('delete_all', function(msg) {
|
||||
if(coll !== undefined) {
|
||||
try {
|
||||
coll = msg.channel;
|
||||
coll = msg.channel.toLowerCase();
|
||||
if(coll.length == 0) return;
|
||||
coll = emojiStrip(coll).toLowerCase();
|
||||
coll = coll.replace("_", "");
|
||||
@@ -270,7 +300,7 @@ module.exports = function() {
|
||||
{
|
||||
if(coll !== undefined) {
|
||||
try {
|
||||
coll = msg.channel;
|
||||
coll = msg.channel.toLowerCase();
|
||||
if(coll.length == 0) return;
|
||||
coll = emojiStrip(coll).toLowerCase();
|
||||
coll = coll.replace("_", "");
|
||||
@@ -302,7 +332,7 @@ module.exports = function() {
|
||||
{
|
||||
if(coll !== undefined) {
|
||||
try {
|
||||
coll = msg.channel;
|
||||
coll = msg.channel.toLowerCase();
|
||||
if(coll.length == 0) return;
|
||||
coll = emojiStrip(coll).toLowerCase();
|
||||
coll = coll.replace("_", "");
|
||||
@@ -319,7 +349,7 @@ module.exports = function() {
|
||||
{
|
||||
if(coll === undefined && obj !== undefined && obj.channel !== undefined){
|
||||
try {
|
||||
coll = obj.channel;
|
||||
coll = obj.channel.toLowerCase();
|
||||
if(coll.length == 0) return;
|
||||
coll = emojiStrip(coll).toLowerCase();
|
||||
coll = coll.replace("_", "");
|
||||
@@ -364,7 +394,7 @@ module.exports = function() {
|
||||
(obj.hasOwnProperty("pass") && typeof(obj.pass) != "string"))
|
||||
if(coll !== undefined) {
|
||||
try {
|
||||
coll = obj.channel;
|
||||
coll = obj.channel.toLowerCase();
|
||||
if(coll.length == 0) return;
|
||||
coll = emojiStrip(coll).toLowerCase();
|
||||
coll = coll.replace("_", "");
|
||||
@@ -375,8 +405,20 @@ module.exports = function() {
|
||||
}
|
||||
}
|
||||
|
||||
if(coll == "" || coll == undefined || coll == null) {
|
||||
socket.emit("update_required");
|
||||
if(coll == "" || coll == undefined || coll == null ||
|
||||
!obj.hasOwnProperty("channel") || typeof(obj.channel) != "string" ||
|
||||
obj.hasOwnProperty("pass") || typeof(obj.pass) != "string") {
|
||||
var result = {
|
||||
channel: {
|
||||
expected: "string",
|
||||
got: obj.hasOwnProperty("channel") ? typeof(obj.channel) : undefined
|
||||
},
|
||||
pass: {
|
||||
expected: "string",
|
||||
got: obj.hasOwnProperty("pass") ? typeof(obj.pass) : undefined
|
||||
}
|
||||
};
|
||||
socket.emit('update_required', result);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,18 +20,29 @@ function now_playing(list, fn, socket) {
|
||||
function list(msg, guid, coll, offline, socket) {
|
||||
var socketid = socket.zoff_id;
|
||||
|
||||
if(typeof(msg) === 'object' && msg !== undefined && msg !== null && msg.hasOwnProperty("channel") && msg.hasOwnProperty('pass'))
|
||||
if(typeof(msg) === 'object' && msg !== undefined && msg !== null)
|
||||
{
|
||||
if(!msg.hasOwnProperty('version') || msg.version != VERSION || msg.version == undefined ||
|
||||
if(!msg.hasOwnProperty('version') || !msg.hasOwnProperty("channel") || !msg.hasOwnProperty("pass") ||
|
||||
msg.version != VERSION || msg.version == undefined ||
|
||||
typeof(msg.channel) != "string" || typeof(msg.pass) != "string") {
|
||||
socket.emit("update_required");
|
||||
return;
|
||||
}
|
||||
|
||||
if(coll == "" || coll == undefined || coll == null) {
|
||||
socket.emit("update_required");
|
||||
var result = {
|
||||
channel: {
|
||||
expected: "string",
|
||||
got: msg.hasOwnProperty("channel") ? typeof(msg.channel) : undefined,
|
||||
},
|
||||
version: {
|
||||
expected: VERSION,
|
||||
got: msg.version,
|
||||
},
|
||||
pass: {
|
||||
expected: "string",
|
||||
got: msg.hasOwnProperty("pass") ? typeof(msg.pass) : undefined,
|
||||
},
|
||||
};
|
||||
socket.emit('update_required', result);
|
||||
return;
|
||||
}
|
||||
coll = msg.channel.toLowerCase();
|
||||
var pass = Functions.decrypt_string(socketid, msg.pass);
|
||||
db.collection('frontpage_lists').find({"_id": coll}, function(err, frontpage_lists){
|
||||
if(frontpage_lists.length == 1)
|
||||
@@ -70,7 +81,13 @@ function list(msg, guid, coll, offline, socket) {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
socket.emit('update_required');
|
||||
var result = {
|
||||
msg: {
|
||||
expected: "object",
|
||||
got: typeof(msg)
|
||||
},
|
||||
};
|
||||
socket.emit('update_required', result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,10 +96,10 @@ function skip(list, guid, coll, offline, socket) {
|
||||
|
||||
if(list !== undefined && list !== null && list !== "")
|
||||
{
|
||||
if(coll == undefined && list.hasOwnProperty('channel')) coll = list.channel;
|
||||
if(coll == undefined && list.hasOwnProperty('channel')) coll = list.channel.toLowerCase();
|
||||
if(coll !== undefined) {
|
||||
try {
|
||||
coll = list.channel;
|
||||
coll = list.channel.toLowerCase();
|
||||
if(coll.length == 0) return;
|
||||
coll = emojiStrip(coll).toLowerCase();
|
||||
coll = coll.replace("_", "");
|
||||
@@ -92,9 +109,29 @@ function skip(list, guid, coll, offline, socket) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(typeof(list.pass) != "string" || typeof(list.id) != "string" ||
|
||||
if(!list.hasOwnProperty("pass") || !list.hasOwnProperty("userpass") ||
|
||||
!list.hasOwnProperty("id") || !list.hasOwnProperty("channel") ||
|
||||
typeof(list.pass) != "string" || typeof(list.id) != "string" ||
|
||||
typeof(list.channel) != "string" || typeof(list.userpass) != "string") {
|
||||
socket.emit("update_required");
|
||||
var result = {
|
||||
channel: {
|
||||
expected: "string",
|
||||
got: list.hasOwnProperty("channel") ? typeof(list.channel) : undefined,
|
||||
},
|
||||
pass: {
|
||||
expected: "string",
|
||||
got: list.hasOwnProperty("pass") ? typeof(list.pass) : undefined,
|
||||
},
|
||||
userpass: {
|
||||
expected: "string",
|
||||
got: list.hasOwnProperty("userpass") ? typeof(list.userpass) : undefined,
|
||||
},
|
||||
id: {
|
||||
expected: "string",
|
||||
got: list.hasOwnProperty("id") ? typeof(list.id) : undefined,
|
||||
},
|
||||
};
|
||||
socket.emit('update_required', result);
|
||||
return;
|
||||
}
|
||||
db.collection(coll + "_settings").find(function(err, docs){
|
||||
@@ -165,7 +202,13 @@ function skip(list, guid, coll, offline, socket) {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
socket.emit('update_required');
|
||||
var result = {
|
||||
msg: {
|
||||
expected: "object",
|
||||
got: typeof(list),
|
||||
},
|
||||
};
|
||||
socket.emit("update_required", result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -435,9 +478,24 @@ function end(obj, coll, guid, offline, socket) {
|
||||
|
||||
if(id !== undefined && id !== null && id !== "") {
|
||||
|
||||
if(coll == "" || coll == undefined || coll == null || typeof(obj.id) != "string" || typeof(obj.channel) != "string" ||
|
||||
if(!obj.hasOwnProperty("id") || !obj.hasOwnProperty("channel") || !obj.hasOwnProperty("pass") ||
|
||||
typeof(obj.id) != "string" || typeof(obj.channel) != "string" ||
|
||||
typeof(obj.pass) != "string") {
|
||||
socket.emit("update_required");
|
||||
var result = {
|
||||
channel: {
|
||||
expected: "string",
|
||||
got: obj.hasOwnProperty("channel") ? typeof(obj.channel) : undefined,
|
||||
},
|
||||
pass: {
|
||||
expected: "string",
|
||||
got: obj.hasOwnProperty("pass") ? typeof(obj.pass) : undefined,
|
||||
},
|
||||
id: {
|
||||
expected: "string",
|
||||
got: obj.hasOwnProperty("id") ? typeof(obj.id) : undefined,
|
||||
},
|
||||
};
|
||||
socket.emit("update_required", result);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -470,7 +528,13 @@ function end(obj, coll, guid, offline, socket) {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
socket.emit('update_required');
|
||||
var result = {
|
||||
msg: {
|
||||
expected: "object",
|
||||
got: typeof(obj)
|
||||
},
|
||||
};
|
||||
socket.emit("update_required", result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,8 +3,19 @@ function add_function(arr, coll, guid, offline, socket) {
|
||||
if(typeof(arr) === 'object' && arr !== undefined && arr !== null && arr !== "" && !isNaN(parseInt(arr.duration)))
|
||||
{
|
||||
|
||||
if(coll == "" || coll == undefined || coll == null || !arr.hasOwnProperty("start") || !arr.hasOwnProperty("end")) {
|
||||
socket.emit("update_required");
|
||||
if(coll == "" || coll == undefined || coll == null ||
|
||||
!arr.hasOwnProperty("start") || !arr.hasOwnProperty("end")) {
|
||||
var result = {
|
||||
start: {
|
||||
expected: "number or string that can be cast to int",
|
||||
got: arr.hasOwnProperty("start") ? typeof(arr.start) : undefined
|
||||
},
|
||||
end: {
|
||||
expected: "number or string that can be cast to int",
|
||||
got: arr.hasOwnProperty("end") ? typeof(arr.end) : undefined
|
||||
}
|
||||
};
|
||||
socket.emit('update_required', result);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -34,7 +45,49 @@ function add_function(arr, coll, guid, offline, socket) {
|
||||
typeof(arr.playlist) != "boolean" || typeof(arr.num) != "number" ||
|
||||
typeof(arr.total) != "number" || typeof(arr.pass) != "string" ||
|
||||
typeof(arr.adminpass) != "string") {
|
||||
socket.emit("update_required");
|
||||
var result = {
|
||||
start: {
|
||||
expected: "number or string that can be cast to int",
|
||||
got: arr.hasOwnProperty("start") ? typeof(arr.start) : undefined
|
||||
},
|
||||
end: {
|
||||
expected: "number or string that can be cast to int",
|
||||
got: arr.hasOwnProperty("end") ? typeof(arr.end) : undefined
|
||||
},
|
||||
title: {
|
||||
expected: "string",
|
||||
got: arr.hasOwnProperty("title") ? typeof(arr.title) : undefined
|
||||
},
|
||||
list: {
|
||||
expected: "string",
|
||||
got: arr.hasOwnProperty("list") ? typeof(arr.list) : undefined
|
||||
},
|
||||
duration: {
|
||||
expected: "number or string that can be cast to int",
|
||||
got: arr.hasOwnProperty("duration") ? typeof(arr.duration) : undefined
|
||||
},
|
||||
playlist: {
|
||||
expected: "boolean",
|
||||
got: arr.hasOwnProperty("playlist") ? typeof(arr.playlist) : undefined
|
||||
},
|
||||
num: {
|
||||
expected: "number or string that can be cast to int",
|
||||
got: arr.hasOwnProperty("num") ? typeof(arr.num) : undefined
|
||||
},
|
||||
total: {
|
||||
expected: "number or string that can be cast to int",
|
||||
got: arr.hasOwnProperty("total") ? typeof(arr.total) : undefined
|
||||
},
|
||||
pass: {
|
||||
expected: "string",
|
||||
got: arr.hasOwnProperty("pass") ? typeof(arr.pass) : undefined
|
||||
},
|
||||
adminpass: {
|
||||
expected: "string",
|
||||
got: arr.hasOwnProperty("adminpass") ? typeof(arr.adminpass) : undefined
|
||||
}
|
||||
};
|
||||
socket.emit('update_required', result);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -176,7 +229,17 @@ function add_function(arr, coll, guid, offline, socket) {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
socket.emit('update_required');
|
||||
var result = {
|
||||
arr: {
|
||||
expected: "object",
|
||||
got: typeof(arr)
|
||||
},
|
||||
duration: {
|
||||
expected: "number or string that can be cast to int",
|
||||
got: arr.hasOwnProperty("duration") ? typeof(arr.duration) : undefined,
|
||||
}
|
||||
};
|
||||
socket.emit('update_required', result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,19 +247,39 @@ function voteUndecided(msg, coll, guid, offline, socket) {
|
||||
var socketid = socket.zoff_id;
|
||||
if(typeof(msg) === 'object' && msg !== undefined && msg !== null){
|
||||
|
||||
if(coll == "" || coll == undefined || coll == null || !msg.hasOwnProperty("adminpass") || !msg.hasOwnProperty("pass") || !msg.hasOwnProperty("id")) {
|
||||
socket.emit("update_required");
|
||||
return;
|
||||
}
|
||||
|
||||
if(typeof(msg.channel) != "string" || typeof(msg.id) != "string" ||
|
||||
typeof(msg.type) != "string" || typeof(msg.adminpass) != "string" ||
|
||||
typeof(msg.pass) != "string") {
|
||||
socket.emit("update_required");
|
||||
if(!msg.hasOwnProperty("channel") || !msg.hasOwnProperty("id") ||
|
||||
!msg.hasOwnProperty("type") || !msg.hasOwnProperty("adminpass") ||
|
||||
!msg.hasOwnProperty("pass") || typeof(msg.pass) != "string" ||
|
||||
typeof(msg.channel) != "string" || typeof(msg.id) != "string" ||
|
||||
typeof(msg.type) != "string" || typeof(msg.adminpass) != "string") {
|
||||
var result = {
|
||||
channel: {
|
||||
expected: "string",
|
||||
got: msg.hasOwnProperty("channel") ? typeof(msg.channel) : undefined,
|
||||
},
|
||||
id: {
|
||||
expected: "string",
|
||||
got: msg.hasOwnProperty("id") ? typeof(msg.id) : undefined,
|
||||
},
|
||||
type: {
|
||||
expected: "string",
|
||||
got: msg.hasOwnProperty("type") ? typeof(msg.type) : undefined,
|
||||
},
|
||||
adminpass: {
|
||||
expected: "adminpass",
|
||||
got: msg.hasOwnProperty("adminpass") ? typeof(msg.adminpass) : undefined,
|
||||
},
|
||||
pass: {
|
||||
expected: "string",
|
||||
got: msg.hasOwnProperty("pass") ? typeof(msg.pass) : undefined,
|
||||
},
|
||||
};
|
||||
socket.emit('update_required', result);
|
||||
return;
|
||||
}
|
||||
coll = msg.channel.toLowerCase();;
|
||||
|
||||
db.collection(coll + "_settings").find(function(err, docs){
|
||||
db.collection(coll + "_settings").find({id: "config"}, function(err, docs){
|
||||
if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (msg.hasOwnProperty('pass') && docs[0].userpass == Functions.decrypt_string(socketid, msg.pass)))) {
|
||||
|
||||
Functions.check_inlist(coll, guid, socket, offline);
|
||||
@@ -218,84 +301,99 @@ function voteUndecided(msg, coll, guid, offline, socket) {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
socket.emit('update_required');
|
||||
var result = {
|
||||
msg: {
|
||||
expected: "object",
|
||||
got: typeof(msg)
|
||||
}
|
||||
};
|
||||
socket.emit('update_required', result);
|
||||
}
|
||||
}
|
||||
|
||||
function shuffle(msg, coll, guid, offline, socket) {
|
||||
var socketid = socket.zoff_id;
|
||||
if(msg.hasOwnProperty('adminpass') && msg.adminpass !== undefined && msg.adminpass !== null)
|
||||
{
|
||||
if(coll == "" || coll == undefined || coll == null) {
|
||||
socket.emit("update_required");
|
||||
|
||||
|
||||
if(!msg.hasOwnProperty("adminpass") || !msg.hasOwnProperty("channel") ||
|
||||
!msg.hasOwnProperty("pass") || typeof(msg.adminpass) != "string" ||
|
||||
typeof(msg.channel) != "string" || typeof(msg.pass) != "string") {
|
||||
var result = {
|
||||
channel: {
|
||||
expected: "string",
|
||||
got: msg.hasOwnProperty("channel") ? typeof(msg.channel) : undefined,
|
||||
},
|
||||
adminpass: {
|
||||
expected: "adminpass",
|
||||
got: msg.hasOwnProperty("adminpass") ? typeof(msg.adminpass) : undefined,
|
||||
},
|
||||
pass: {
|
||||
expected: "string",
|
||||
got: msg.hasOwnProperty("pass") ? typeof(msg.pass) : undefined,
|
||||
},
|
||||
};
|
||||
socket.emit('update_required', result);
|
||||
return;
|
||||
}
|
||||
coll = msg.channel.toLowerCase();
|
||||
|
||||
if(typeof(msg.adminpass) != "string" || typeof(msg.channel) != "string" ||
|
||||
typeof(msg.pass) != "string") {
|
||||
socket.emit("update_required");
|
||||
db.collection("timeout_api").find({
|
||||
type: "shuffle",
|
||||
guid: coll,
|
||||
}, function(err, docs) {
|
||||
if(docs.length > 0) {
|
||||
var date = new Date(docs[0].createdAt);
|
||||
date.setSeconds(date.getSeconds() + 5);
|
||||
var now = new Date();
|
||||
var retry_in = (date.getTime() - now.getTime()) / 1000;
|
||||
if(retry_in > 0) {
|
||||
socket.emit("toast", "wait_longer");
|
||||
return;
|
||||
}
|
||||
|
||||
db.collection("timeout_api").find({
|
||||
type: "shuffle",
|
||||
guid: coll,
|
||||
}, function(err, docs) {
|
||||
if(docs.length > 0) {
|
||||
var date = new Date(docs[0].createdAt);
|
||||
date.setSeconds(date.getSeconds() + 5);
|
||||
var now = new Date();
|
||||
var retry_in = (date.getTime() - now.getTime()) / 1000;
|
||||
if(retry_in > 0) {
|
||||
socket.emit("toast", "wait_longer");
|
||||
return;
|
||||
}
|
||||
}
|
||||
var now_date = new Date();
|
||||
db.collection("timeout_api").update({type: "shuffle", guid: coll}, {
|
||||
$set: {
|
||||
"createdAt": now_date,
|
||||
type: "shuffle",
|
||||
guid: coll,
|
||||
},
|
||||
}, {upsert: true}, function(err, docs) {
|
||||
Functions.check_inlist(coll, guid, socket, offline);
|
||||
var hash;
|
||||
if(msg.adminpass === "") hash = msg.adminpass;
|
||||
else hash = Functions.hash_pass(Functions.decrypt_string(socketid, msg.adminpass));
|
||||
db.collection(coll + "_settings").find(function(err, docs){
|
||||
if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (msg.hasOwnProperty('pass') && docs[0].userpass == Functions.decrypt_string(socketid, msg.pass)))) {
|
||||
if(docs !== null && docs.length !== 0 && ((docs[0].adminpass == hash || docs[0].adminpass === "") || docs[0].shuffle === false))
|
||||
{
|
||||
db.collection(coll).find({now_playing:false}).forEach(function(err, docs){
|
||||
if(!docs){
|
||||
List.send_list(coll, undefined, false, true, false, true);
|
||||
socket.emit("toast", "shuffled");
|
||||
|
||||
return;
|
||||
}else{
|
||||
num = Math.floor(Math.random()*1000000);
|
||||
db.collection(coll).update({id:docs.id}, {$set:{added:num}});
|
||||
}
|
||||
});
|
||||
}else
|
||||
socket.emit("toast", "wrongpass");
|
||||
} else {
|
||||
socket.emit("auth_required");
|
||||
}
|
||||
});
|
||||
|
||||
var complete = function(tot, curr){
|
||||
if(tot == curr)
|
||||
}
|
||||
var now_date = new Date();
|
||||
db.collection("timeout_api").update({type: "shuffle", guid: coll}, {
|
||||
$set: {
|
||||
"createdAt": now_date,
|
||||
type: "shuffle",
|
||||
guid: coll,
|
||||
},
|
||||
}, {upsert: true}, function(err, docs) {
|
||||
Functions.check_inlist(coll, guid, socket, offline);
|
||||
var hash;
|
||||
if(msg.adminpass === "") hash = msg.adminpass;
|
||||
else hash = Functions.hash_pass(Functions.decrypt_string(socketid, msg.adminpass));
|
||||
db.collection(coll + "_settings").find(function(err, docs){
|
||||
if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (msg.hasOwnProperty('pass') && docs[0].userpass == Functions.decrypt_string(socketid, msg.pass)))) {
|
||||
if(docs !== null && docs.length !== 0 && ((docs[0].adminpass == hash || docs[0].adminpass === "") || docs[0].shuffle === false))
|
||||
{
|
||||
List.send_list(coll, undefined, false, true, false);
|
||||
List.getNextSong(coll);
|
||||
}
|
||||
};
|
||||
db.collection(coll).find({now_playing:false}).forEach(function(err, docs){
|
||||
if(!docs){
|
||||
List.send_list(coll, undefined, false, true, false, true);
|
||||
socket.emit("toast", "shuffled");
|
||||
|
||||
return;
|
||||
}else{
|
||||
num = Math.floor(Math.random()*1000000);
|
||||
db.collection(coll).update({id:docs.id}, {$set:{added:num}});
|
||||
}
|
||||
});
|
||||
}else
|
||||
socket.emit("toast", "wrongpass");
|
||||
} else {
|
||||
socket.emit("auth_required");
|
||||
}
|
||||
});
|
||||
|
||||
var complete = function(tot, curr){
|
||||
if(tot == curr)
|
||||
{
|
||||
List.send_list(coll, undefined, false, true, false);
|
||||
List.getNextSong(coll);
|
||||
}
|
||||
};
|
||||
});
|
||||
}else
|
||||
socket.emit("toast", "wrongpass");
|
||||
});
|
||||
}
|
||||
|
||||
function del(params, socket, socketid) {
|
||||
@@ -328,15 +426,30 @@ function del(params, socket, socketid) {
|
||||
|
||||
function delete_all(msg, coll, guid, offline, socket) {
|
||||
var socketid = socket.zoff_id;
|
||||
if(typeof(msg) == 'object' && msg.hasOwnProperty('channel') && msg.hasOwnProperty('adminpass') && msg.hasOwnProperty('pass')) {
|
||||
var hash = Functions.hash_pass(Functions.decrypt_string(socketid, msg.adminpass));
|
||||
var hash_userpass = Functions.decrypt_string(socketid, msg.pass);
|
||||
|
||||
if(typeof(msg.channel) != "string" || typeof(msg.adminpass) != "string" ||
|
||||
typeof(msg.pass) != "string") {
|
||||
socket.emit("update_required");
|
||||
if(typeof(msg) == 'object' ) {
|
||||
if(!msg.hasOwnProperty('channel') || !msg.hasOwnProperty('adminpass') ||
|
||||
!msg.hasOwnProperty('pass') || typeof(msg.channel) != "string" ||
|
||||
typeof(msg.adminpass) != "string" || typeof(msg.pass) != "string") {
|
||||
var result = {
|
||||
channel: {
|
||||
expected: "string",
|
||||
got: msg.hasOwnProperty("channel") ? typeof(msg.channel) : undefined,
|
||||
},
|
||||
adminpass: {
|
||||
expected: "adminpass",
|
||||
got: msg.hasOwnProperty("adminpass") ? typeof(msg.adminpass) : undefined,
|
||||
},
|
||||
pass: {
|
||||
expected: "string",
|
||||
got: msg.hasOwnProperty("pass") ? typeof(msg.pass) : undefined,
|
||||
},
|
||||
};
|
||||
socket.emit('update_required', result);
|
||||
return;
|
||||
}
|
||||
|
||||
var hash = Functions.hash_pass(Functions.decrypt_string(socketid, msg.adminpass));
|
||||
var hash_userpass = Functions.decrypt_string(socketid, msg.pass);
|
||||
db.collection(coll + "_settings").find(function(err, conf) {
|
||||
if(conf.length == 1 && conf) {
|
||||
conf = conf[0];
|
||||
@@ -352,7 +465,13 @@ function delete_all(msg, coll, guid, offline, socket) {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
socket.emit("update_required");
|
||||
var result = {
|
||||
msg: {
|
||||
expected: "object",
|
||||
got: typeof(msg)
|
||||
},
|
||||
};
|
||||
socket.emit('update_required', result);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,17 @@ function password(inp, coll, guid, offline, socket) {
|
||||
{
|
||||
if(!inp.hasOwnProperty("password") || !inp.hasOwnProperty("channel") ||
|
||||
typeof(inp.password) != "string" || typeof(inp.channel) != "string") {
|
||||
socket.emit("update_required");
|
||||
var result = {
|
||||
channel: {
|
||||
expected: "string",
|
||||
got: inp.hasOwnProperty("channel") ? typeof(iinp.channel) : undefined,
|
||||
},
|
||||
password: {
|
||||
expected: "password",
|
||||
got: inp.hasOwnProperty("password") ? typeof(inp.password) : undefined,
|
||||
},
|
||||
};
|
||||
socket.emit('update_required', result);
|
||||
return;
|
||||
}
|
||||
pw = inp.password;
|
||||
@@ -19,11 +29,6 @@ function password(inp, coll, guid, offline, socket) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(coll == "" || coll == undefined || coll == null) {
|
||||
socket.emit("update_required");
|
||||
return;
|
||||
}
|
||||
|
||||
uncrypted = pw;
|
||||
pw = Functions.decrypt_string(socket.zoff_id, pw);
|
||||
Functions.check_inlist(coll, guid, socket, offline);
|
||||
@@ -51,22 +56,18 @@ function password(inp, coll, guid, offline, socket) {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
socket.emit('update_required');
|
||||
var result = {
|
||||
inp: {
|
||||
expected: "string",
|
||||
got: typeof(inpt)
|
||||
},
|
||||
};
|
||||
socket.emit('update_required', result);
|
||||
}
|
||||
}
|
||||
|
||||
function conf_function(params, coll, guid, offline, socket) {
|
||||
if(params !== undefined && params !== null && params !== "" &&
|
||||
params.hasOwnProperty('voting') &&
|
||||
params.hasOwnProperty('addsongs') &&
|
||||
params.hasOwnProperty('longsongs') &&
|
||||
params.hasOwnProperty('frontpage') &&
|
||||
params.hasOwnProperty('allvideos') &&
|
||||
params.hasOwnProperty('removeplay') &&
|
||||
params.hasOwnProperty('adminpass') &&
|
||||
params.hasOwnProperty('skipping') &&
|
||||
params.hasOwnProperty('shuffling') &&
|
||||
params.hasOwnProperty('channel'))
|
||||
if(params !== undefined && params !== null && params !== "")
|
||||
{
|
||||
if(coll !== undefined) {
|
||||
try {
|
||||
@@ -88,6 +89,59 @@ function conf_function(params, coll, guid, offline, socket) {
|
||||
|
||||
Functions.check_inlist(coll, guid, socket, offline);
|
||||
|
||||
|
||||
if(!params.hasOwnProperty('voting') || !params.hasOwnProperty('addsongs') ||
|
||||
!params.hasOwnProperty('longsongs') || !params.hasOwnProperty('frontpage') ||
|
||||
!params.hasOwnProperty('allvideos') || !params.hasOwnProperty('removeplay') ||
|
||||
!params.hasOwnProperty('adminpass') || !params.hasOwnProperty('skipping') ||
|
||||
!params.hasOwnProperty('shuffling') || !params.hasOwnProperty('channel') ||
|
||||
typeof(params.userpass) != "string" || typeof(params.adminpass) != "string" ||
|
||||
typeof(params.voting) != "boolean" || typeof(params.addsongs) != "boolean" ||
|
||||
typeof(params.longsongs) != "boolean" || typeof(params.frontpage) != "boolean" ||
|
||||
typeof(params.allvideos) != "boolean" || typeof(params.removeplay) != "boolean" ||
|
||||
typeof(params.skipping) != "boolean" || typeof(params.shuffling) != "boolean" ||
|
||||
typeof(params.userpass_changed) != "boolean") {
|
||||
var result = {
|
||||
adminpass: {
|
||||
expected: "string",
|
||||
got: params.hasOwnProperty("adminpass") ? typeof(params.adminpass) : undefined,
|
||||
},
|
||||
userpass: {
|
||||
expected: "string",
|
||||
got: params.hasOwnProperty("userpass") ? typeof(params.userpass) : undefined,
|
||||
},
|
||||
vote: {
|
||||
expected: "boolean",
|
||||
got: params.hasOwnProperty("vote") ? typeof(params.vote) : undefined,
|
||||
},
|
||||
addsongs: {
|
||||
expected: "boolean",
|
||||
got: params.hasOwnProperty("addsongs") ? typeof(params.addsongs) : undefined,
|
||||
},
|
||||
longsongs: {
|
||||
expected: "boolean",
|
||||
got: params.hasOwnProperty("longsongs") ? typeof(params.longsongs) : undefined,
|
||||
},
|
||||
frontpage: {
|
||||
expected: "boolean",
|
||||
got: params.hasOwnProperty("frontpage") ? typeof(params.frontpage) : undefined,
|
||||
},
|
||||
skipping: {
|
||||
expected: "boolean",
|
||||
got: params.hasOwnProperty("skipping") ? typeof(params.skipping) : undefined,
|
||||
},
|
||||
shuffling: {
|
||||
expected: "boolean",
|
||||
got: params.hasOwnProperty("shuffling") ? typeof(params.shuffling) : undefined,
|
||||
},
|
||||
userpass_changed: {
|
||||
expected: "boolean",
|
||||
got: params.hasOwnProperty("userpass_changed") ? typeof(params.userpass_changed) : undefined,
|
||||
}
|
||||
};
|
||||
socket.emit("update_required", result);
|
||||
return;
|
||||
}
|
||||
var voting = params.voting;
|
||||
var addsongs = params.addsongs;
|
||||
var longsongs = params.longsongs;
|
||||
@@ -98,15 +152,6 @@ function conf_function(params, coll, guid, offline, socket) {
|
||||
var skipping = params.skipping;
|
||||
var shuffling = params.shuffling;
|
||||
var userpass = Functions.decrypt_string(socket.zoff_id, params.userpass);
|
||||
if(typeof(userpass) != "string" || typeof(adminpass) != "string" ||
|
||||
typeof(voting) != "boolean" || typeof(addsongs) != "boolean" ||
|
||||
typeof(longsongs) != "boolean" || typeof(frontpage) != "boolean" ||
|
||||
typeof(allvideos) != "boolean" || typeof(removeplay) != "boolean" ||
|
||||
typeof(skipping) != "boolean" || typeof(shuffling) != "boolean" ||
|
||||
typeof(params.userpass_changed) != "boolean") {
|
||||
socket.emit("toast", "wrongpass");
|
||||
return;
|
||||
}
|
||||
|
||||
if((!params.userpass_changed && frontpage) || (params.userpass_changed && userpass == "")) {
|
||||
userpass = "";
|
||||
@@ -162,7 +207,13 @@ function conf_function(params, coll, guid, offline, socket) {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
socket.emit('update_required');
|
||||
var result = {
|
||||
params: {
|
||||
expected: "object",
|
||||
got: typeof(params),
|
||||
}
|
||||
}
|
||||
socket.emit('update_required', result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,17 @@ function get_correct_info(song_generated, channel, broadcast, callback) {
|
||||
function check_error_video(msg, channel) {
|
||||
if(!msg.hasOwnProperty("id") || !msg.hasOwnProperty("title") ||
|
||||
typeof(msg.id) != "string" || typeof(msg.title) != "string") {
|
||||
socket.emit("update_required");
|
||||
var result = {
|
||||
id: {
|
||||
expected: "string",
|
||||
got: msg.hasOwnProperty("id") ? typeof(msg.id) : undefined,
|
||||
},
|
||||
title: {
|
||||
expected: "string",
|
||||
got: msg.hasOwnProperty("title") ? typeof(msg.title) : undefined,
|
||||
},
|
||||
};
|
||||
socket.emit("update_required", result);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,25 @@ function thumbnail(msg, coll, guid, offline, socket) {
|
||||
if(msg.thumbnail && msg.channel && msg.adminpass && msg.thumbnail.indexOf("i.imgur.com") > -1){
|
||||
if(typeof(msg.channel) != "string" || typeof(msg.thumbnail) != "string" ||
|
||||
typeof(msg.adminpass) != "string" || typeof(msg.pass) != "string") {
|
||||
socket.emit("update_required");
|
||||
var result = {
|
||||
channel: {
|
||||
expected: "string",
|
||||
got: msg.hasOwnProperty("channel") ? typeof(msg.channel) : undefined,
|
||||
},
|
||||
pass: {
|
||||
expected: "string",
|
||||
got: msg.hasOwnProperty("pass") ? typeof(msg.pass) : undefined,
|
||||
},
|
||||
thumbnail: {
|
||||
expected: "string",
|
||||
got: msg.hasOwnProperty("thumbnail") ? typeof(msg.thumbnail) : undefined,
|
||||
},
|
||||
adminpass: {
|
||||
expected: "string",
|
||||
got: msg.hasOwnProperty("adminpass") ? typeof(msg.adminpass) : undefined,
|
||||
},
|
||||
};
|
||||
socket.emit("update_required", result);
|
||||
return;
|
||||
}
|
||||
msg.thumbnail = msg.thumbnail.replace(/^https?\:\/\//i, "");
|
||||
@@ -30,7 +48,25 @@ function description(msg, coll, guid, offline, socket) {
|
||||
if(msg.description && msg.channel && msg.adminpass && msg.description.length < 100){
|
||||
if(typeof(msg.channel) != "string" || typeof(msg.description) != "string" ||
|
||||
typeof(msg.adminpass) != "string" || typeof(msg.pass) != "string") {
|
||||
socket.emit("update_required");
|
||||
var result = {
|
||||
channel: {
|
||||
expected: "string",
|
||||
got: msg.hasOwnProperty("channel") ? typeof(msg.channel) : undefined,
|
||||
},
|
||||
pass: {
|
||||
expected: "string",
|
||||
got: msg.hasOwnProperty("pass") ? typeof(msg.pass) : undefined,
|
||||
},
|
||||
description: {
|
||||
expected: "string",
|
||||
got: msg.hasOwnProperty("description") ? typeof(msg.description) : undefined,
|
||||
},
|
||||
adminpass: {
|
||||
expected: "string",
|
||||
got: msg.hasOwnProperty("adminpass") ? typeof(msg.adminpass) : undefined,
|
||||
},
|
||||
};
|
||||
socket.emit("update_required", result);
|
||||
return;
|
||||
}
|
||||
var channel = msg.channel.toLowerCase();
|
||||
|
||||
Reference in New Issue
Block a user