diff --git a/server/handlers/chat.js b/server/handlers/chat.js index 14106af1..1283e010 100644 --- a/server/handlers/chat.js +++ b/server/handlers/chat.js @@ -112,7 +112,7 @@ function chat(msg, guid, offline, socket) { } }); } - }); + }, "place 1"); } else { socket.emit('auth_required'); } @@ -159,7 +159,7 @@ function all_chat(msg, guid, offline, socket) { } }); } - }); + }, "place 2"); } function namechange(data, guid, socket, tried, callback) { diff --git a/server/handlers/functions.js b/server/handlers/functions.js index cc38a225..0d5edf64 100644 --- a/server/handlers/functions.js +++ b/server/handlers/functions.js @@ -120,12 +120,13 @@ function get_short_id(socket) { socket.emit("id", new_short_id); } -function check_inlist(coll, guid, socket, offline, callback) +function check_inlist(coll, guid, socket, offline, callback, double_check) { if(coll == undefined) { if(typeof(callback) == "function") callback(); return; } + console.log(coll, double_check); //coll = coll.replace(/ /g,''); if(!offline && coll != undefined){ db.collection("connected_users").update({"_id": coll}, {$addToSet:{users: guid}}, {upsert: true}, function(err, updated) { diff --git a/server/handlers/io.js b/server/handlers/io.js index 70b0b835..688edf28 100644 --- a/server/handlers/io.js +++ b/server/handlers/io.js @@ -245,7 +245,7 @@ module.exports = function() { return; } var status = msg.status; - var channel = msg.channel;//.replace(/ /g,''); + var channel = Functions.encodeChannelName(msg.channel);//.replace(/ /g,''); if(status){ in_list = false; offline = true; @@ -281,7 +281,7 @@ module.exports = function() { } else { offline = false; db.collection("connected_users").update({"_id": "offline_users"}, {$pull: {users: guid}}, function(err, docs) { - Functions.check_inlist(coll, guid, socket, offline); + Functions.check_inlist(coll, guid, socket, offline, undefined, "place 3"); }); } }); @@ -700,7 +700,7 @@ module.exports = function() { obj.pass = userpass; } if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (obj.hasOwnProperty('pass') && docs[0].userpass == crypto.createHash('sha256').update(Functions.decrypt_string(obj.pass)).digest("base64")))) { - Functions.check_inlist(coll, guid, socket, offline); + Functions.check_inlist(coll, guid, socket, offline, undefined, "place 4"); List.send_play(coll, socket); } else { socket.emit("auth_required"); diff --git a/server/handlers/list.js b/server/handlers/list.js index edb65b7e..9464004b 100644 --- a/server/handlers/list.js +++ b/server/handlers/list.js @@ -75,7 +75,7 @@ function list(msg, guid, coll, offline, socket) { } in_list = true; socket.join(coll); - Functions.check_inlist(coll, guid, socket, offline); + Functions.check_inlist(coll, guid, socket, offline, undefined, "place 10"); if(frontpage_lists.viewers != undefined){ io.to(coll).emit("viewers", frontpage_lists.viewers); @@ -98,7 +98,7 @@ function list(msg, guid, coll, offline, socket) { send_list(coll, socket, true, false, true); db.collection("frontpage_lists").insert({"_id": coll, "count" : 0, "frontpage": true, "accessed": Functions.get_time(), "viewers": 1}, function(e,d){ }); - Functions.check_inlist(coll, guid, socket, offline); + Functions.check_inlist(coll, guid, socket, offline, undefined, "place 11"); }); }); }); @@ -170,7 +170,7 @@ function skip(list, guid, coll, offline, socket) { db.collection(coll + "_settings").find(function(err, docs){ if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (list.hasOwnProperty('userpass') && docs[0].userpass == crypto.createHash('sha256').update(Functions.decrypt_string(list.userpass)).digest("base64")))) { - Functions.check_inlist(coll, guid, socket, offline); + Functions.check_inlist(coll, guid, socket, offline, undefined, "place 12"); adminpass = ""; video_id = list.id; @@ -613,7 +613,7 @@ function end(obj, coll, guid, offline, socket) { obj.pass = userpass; } if(!authentication_needed || (authentication_needed && obj.hasOwnProperty('pass') && docs[0].userpass == crypto.createHash('sha256').update(Functions.decrypt_string(obj.pass)).digest("base64"))) { - Functions.check_inlist(coll, guid, socket, offline); + Functions.check_inlist(coll, guid, socket, offline, undefined, "place 13"); db.collection(coll).find({now_playing:true}, function(err, np){ if(err !== null) console.log(err); if(np !== null && np !== undefined && np.length == 1 && np[0].id == id){ diff --git a/server/handlers/list_change.js b/server/handlers/list_change.js index d0acdfc9..68f0da59 100644 --- a/server/handlers/list_change.js +++ b/server/handlers/list_change.js @@ -393,7 +393,7 @@ function add_function(arr, coll, guid, offline, socket) { } db.collection(coll + "_settings").find(function(err, docs){ if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (arr.hasOwnProperty('pass') && docs[0].userpass == crypto.createHash('sha256').update(Functions.decrypt_string(arr.pass)).digest("base64")))) { - Functions.check_inlist(coll, guid, socket, offline); + Functions.check_inlist(coll, guid, socket, offline, undefined, "place 5"); var id = arr.id + ""; var title = arr.title; @@ -550,7 +550,7 @@ function add_function(arr, coll, guid, offline, socket) { 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 == crypto.createHash('sha256').update(Functions.decrypt_string(msg.pass)).digest("base64")))) { - Functions.check_inlist(coll, guid, socket, offline); + Functions.check_inlist(coll, guid, socket, offline, undefined, "place 6"); if(msg.type == "del") { del(msg, socket, socketid); @@ -632,7 +632,7 @@ function add_function(arr, coll, guid, offline, socket) { guid: coll, }, }, {upsert: true}, function(err, docs) { - Functions.check_inlist(coll, guid, socket, offline); + Functions.check_inlist(coll, guid, socket, offline, undefined, "place 7"); var hash; if(msg.adminpass === "") hash = msg.adminpass; else hash = Functions.hash_pass(Functions.hash_pass(Functions.decrypt_string(msg.adminpass),true)); diff --git a/server/handlers/list_settings.js b/server/handlers/list_settings.js index f994d69d..99f84f23 100644 --- a/server/handlers/list_settings.js +++ b/server/handlers/list_settings.js @@ -43,7 +43,7 @@ function password(inp, coll, guid, offline, socket) { //coll = coll.replace(/ /g,''); uncrypted = pw; pw = Functions.hash_pass(Functions.decrypt_string(pw), true); - Functions.check_inlist(coll, guid, socket, offline); + Functions.check_inlist(coll, guid, socket, offline, undefined, "place 8"); Functions.getSessionAdminUser(sessionId, coll, function(userpass, adminpass) { db.collection(coll + "_settings").find(function(err, docs){ @@ -111,7 +111,7 @@ function conf_function(params, coll, guid, offline, socket) { return; } - Functions.check_inlist(coll, guid, socket, offline); + Functions.check_inlist(coll, guid, socket, offline, undefined, "place 9"); Functions.getSessionAdminUser(Functions.getSession(socket), coll, function(userpass, adminpass, gotten) { if(gotten) {