Multi-word channel-names and API-fixes

- Spaces and signs allowed in channel-name
- Added missing functioncalls in RESTApi
This commit is contained in:
Kasper Rynning-Tønnesen
2018-05-31 14:45:21 +02:00
parent e3c15431c5
commit 82ac25c5d2
19 changed files with 275 additions and 137 deletions

View File

@@ -1,7 +1,12 @@
var Functions = require(pathThumbnails + '/handlers/functions.js');
var crypto = require('crypto');
var Filter = require('bad-words');
var filter = new Filter({ placeHolder: 'x'});
//var filter = new Filter({ placeHolder: 'x'});
var filter = {
clean: function(str) {
return str;
}
}
var db = require(pathThumbnails + '/handlers/db.js');
function get_history(channel, all, socket) {
@@ -16,7 +21,7 @@ function get_history(channel, all, socket) {
channel: channel,
};
}
channel = channel.replace(/ /g,'');
//channel = channel.replace(/ /g,'');
var pass = "";
if(!query.all) {
Functions.getSessionAdminUser(Functions.getSession(socket), channel, function(userpass) {
@@ -37,7 +42,7 @@ function get_history(channel, all, socket) {
}
function getAndSendLogs(channel, all, socket, pass, query) {
channel = channel.replace(/ /g,'');
//channel = channel.replace(/ /g,'');
db.collection("chat_logs").find(query, {
from: 1,
createdAt: 1,
@@ -72,7 +77,7 @@ function chat(msg, guid, offline, socket) {
socket.emit('update_required', result);
return;
}
var coll = msg.channel.toLowerCase().replace(/ /g,'');
var coll = msg.channel.toLowerCase();//.replace(/ /g,'');
coll = Functions.removeEmojis(coll).toLowerCase();
coll = filter.clean(coll);
Functions.getSessionAdminUser(Functions.getSession(socket), coll, function(userpass) {
@@ -124,7 +129,7 @@ function all_chat(msg, guid, offline, socket) {
socket.emit('update_required', result);
return;
}
var coll = msg.channel.toLowerCase().replace(/ /g,'');
var coll = msg.channel.toLowerCase();//.replace(/ /g,'');
var data = msg.data;
coll = Functions.removeEmojis(coll).toLowerCase();
coll = filter.clean(coll);
@@ -216,7 +221,7 @@ function namechange(data, guid, socket, tried) {
//socket.emit('name', {type: "name", accepted: true});
if(old_name != name && !first) {
if(data.hasOwnProperty("channel") && typeof(data.channel) == "string") {
io.to(data.channel.replace(/ /g,'')).emit('chat', {from: old_name, msg: " changed name to " + name});
io.to(data.channel).emit('chat', {from: old_name, msg: " changed name to " + name});
io.sockets.emit('chat.all', {from: old_name , msg: " changed name to " + name, channel: data.channel});
}
}
@@ -241,7 +246,7 @@ function namechange(data, guid, socket, tried) {
}
function removename(guid, coll, socket) {
coll = coll.replace(/ /g,'');
//coll = coll.replace(/ /g,'');
db.collection("user_names").find({"guid": guid}, function(err, docs) {
if(docs.length == 1) {
var old_name = docs[0].name;

View File

@@ -20,7 +20,7 @@ function frontpage_lists(msg, socket) {
}
function update_frontpage(coll, id, title, thumbnail, source, callback) {
coll = coll.replace(/ /g,'');
//coll = coll.replace(/ /g,'');
db.collection("frontpage_lists").find({_id: coll}, function(e, doc) {
var updateObject = {
id: id,

View File

@@ -12,6 +12,22 @@ var crypto = require('crypto');
var db = require(pathThumbnails + '/handlers/db.js');
var uniqid = require('uniqid');
function encodeChannelName(str) {
var _fn = encodeURIComponent;
var toReturn = _fn(str);
toReturn = toReturn.replace(/_/g, "%5F");
toReturn = toReturn.replace(/%26amp%3B/g, "%26").replace(/%26amp%3b/g, "%26");
toReturn = toReturn.toLowerCase();
return toReturn;
}
function decodeChannelName(str) {
var _fn = decodeURIComponent;
str = str.toUpperCase();
var toReturn = _fn(str.replace(/%5F/g, "_"));
return toReturn.toLowerCase();
}
function remove_unique_id(short_id) {
db.collection("unique_ids").update({"_id": "unique_ids"}, {$pull: {unique_ids: short_id}}, function(err, docs) {});
}
@@ -82,7 +98,7 @@ function check_inlist(coll, guid, socket, offline)
{
if(coll == undefined) return;
coll = coll.replace(/ /g,'');
//coll = coll.replace(/ /g,'');
if(!offline && coll != undefined){
db.collection("connected_users").update({"_id": coll}, {$addToSet:{users: guid}}, {upsert: true}, function(err, updated) {
if(updated.nModified > 0 || updated.upserted != undefined) {
@@ -294,6 +310,8 @@ function removeSessionAdminPass(id, channel, callback) {
});
}
module.exports.decodeChannelName = decodeChannelName;
module.exports.encodeChannelName = encodeChannelName;
module.exports.isUrl = isUrl;
module.exports.removeEmojis = removeEmojis;
module.exports.getSessionChatPass = getSessionChatPass;

View File

@@ -11,7 +11,12 @@ var Frontpage = require(pathThumbnails + '/handlers/frontpage.js');
var Search = require(pathThumbnails + '/handlers/search.js');
var crypto = require('crypto');
var Filter = require('bad-words');
var filter = new Filter({ placeHolder: 'x'});
//var filter = new Filter({ placeHolder: 'x'});
var filter = {
clean: function(str) {
return str;
}
}
var db = require(pathThumbnails + '/handlers/db.js');
module.exports = function() {
@@ -53,7 +58,10 @@ module.exports = function() {
if(channel.indexOf("?") > -1){
channel = channel.substring(0, channel.indexOf("?"));
}
channel = channel.replace(/ /g,'');
if(msg.hasOwnProperty("channel")) {
msg.channel = Functions.encodeChannelName(msg.channel);
}
//channel = channel.replace(/ /g,'');
if(offline) {
db.collection("connected_users").update({"_id": "offline_users"}, {$addToSet: {users: guid}}, {upsert: true}, function(err, docs){});
} else {
@@ -81,7 +89,10 @@ module.exports = function() {
guid = msg.guid;
socketid = msg.socket_id;
socket.zoff_id = socketid;
coll = msg.channel.toLowerCase().replace(/ /g,'');
if(msg.hasOwnProperty("channel")) {
msg.channel = Functions.encodeChannelName(msg.channel);
}
coll = msg.channel.toLowerCase();//.replace(/ /g,'');
coll = Functions.removeEmojis(coll).toLowerCase();
coll = filter.clean(coll);
if(coll.indexOf("?") > -1){
@@ -104,19 +115,22 @@ module.exports = function() {
socket.on("error_video", function(msg) {
try {
var _list = msg.channel.replace(/ /g,'');
var _list = msg.channel;//.replace(/ /g,'');
if(_list.length == 0) return;
if(_list.indexOf("?") > -1){
_list = _list.substring(0, _list.indexOf("?"));
msg.channel = _list;
}
coll = Functions.removeEmojis(_list).toLowerCase();
coll = coll.replace(/_/g, "");
//coll = coll.replace(/_/g, "");
coll = filter.clean(coll);
} catch(e) {
return;
}
if(msg.hasOwnProperty("channel")) {
msg.channel = Functions.encodeChannelName(msg.channel);
}
Search.check_error_video(msg, coll);
});
@@ -139,7 +153,10 @@ module.exports = function() {
var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
msg.channel = _list;
}
Suggestions.thumbnail(msg, coll.replace(/ /g,''), guid, offline, socket);
if(msg.hasOwnProperty("channel")) {
msg.channel = Functions.encodeChannelName(msg.channel);
}
Suggestions.thumbnail(msg, coll, guid, offline, socket);
});
socket.on('suggest_description', function(msg){
@@ -147,7 +164,10 @@ module.exports = function() {
var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
msg.channel = _list;
}
Suggestions.description(msg, coll.replace(/ /g,''), guid, offline, socket);
if(msg.hasOwnProperty("channel")) {
msg.channel = Functions.encodeChannelName(msg.channel);
}
Suggestions.description(msg, coll, guid, offline, socket);
});
socket.on("namechange", function(msg) {
@@ -155,6 +175,9 @@ module.exports = function() {
var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
msg.channel = _list;
}
if(msg.hasOwnProperty("channel")) {
msg.channel = Functions.encodeChannelName(msg.channel);
}
Chat.namechange(msg, guid, socket);
});
@@ -163,6 +186,9 @@ module.exports = function() {
var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
msg.channel = _list;
}
if(msg.hasOwnProperty("channel")) {
msg.channel = Functions.encodeChannelName(msg.channel);
}
if(typeof(msg) != "object" || !msg.hasOwnProperty("channel")) {
var result = {
channel: {
@@ -181,6 +207,9 @@ module.exports = function() {
var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
msg.channel = _list;
}
if(msg.hasOwnProperty("channel")) {
msg.channel = Functions.encodeChannelName(msg.channel);
}
if(!msg.hasOwnProperty('status') || !msg.hasOwnProperty('channel') ||
typeof(msg.status) != "boolean" || typeof(msg.channel) != "string") {
var result = {
@@ -197,7 +226,7 @@ module.exports = function() {
return;
}
var status = msg.status;
var channel = msg.channel.replace(/ /g,'');
var channel = msg.channel;//.replace(/ /g,'');
if(status){
in_list = false;
offline = true;
@@ -205,7 +234,6 @@ module.exports = function() {
if(coll !== undefined) {
coll = Functions.removeEmojis(coll).toLowerCase();
coll = filter.clean(coll);
db.collection("connected_users").findAndModify({
query: {"_id": coll},
update: {$pull: {users: guid}},
@@ -219,7 +247,7 @@ module.exports = function() {
io.to(coll).emit("viewers", num);
db.collection("frontpage_lists").update({"_id": coll, "viewers": {$gt: 0}}, {$inc: {viewers: -1}}, function(err, docs) { });
db.collection("connected_users").update({"_id": "total_users"}, {$pull: {total_users: guid + coll}}, function(err, docs){
db.collection("connected_users").update({"_id": "offline_users"}, {$addToSet: {users: guid}}, function(err, docs) {
db.collection("connected_users").update({"_id": "offline_users"}, {$addToSet: {users: guid}}, {upsert: true}, function(err, docs) {
if(docs.nModified == 1 && (coll != undefined && coll != "")) {
db.collection("connected_users").update({"_id": "total_users"}, {$addToSet: {total_users: guid + coll}}, function(err, docs) {});
}
@@ -244,6 +272,9 @@ module.exports = function() {
var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
msg.channel = _list;
}
if(msg.hasOwnProperty("channel")) {
msg.channel = Functions.encodeChannelName(msg.channel);
}
if(!msg.hasOwnProperty("channel") || !msg.hasOwnProperty("all") ||
typeof(msg.channel) != "string" || typeof(msg.all) != "boolean") {
var result = {
@@ -263,7 +294,7 @@ module.exports = function() {
socket.emit('update_required', result);
return;
}
Chat.get_history(msg.channel.replace(/ /g,''), msg.all, socket);
Chat.get_history(msg.channel, msg.all, socket);
});
socket.on('chat', function (msg) {
@@ -271,6 +302,9 @@ module.exports = function() {
var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
msg.channel = _list;
}
if(msg.hasOwnProperty("channel")) {
msg.channel = Functions.encodeChannelName(msg.channel);
}
Chat.chat(msg, guid, offline, socket);
});
@@ -280,6 +314,9 @@ module.exports = function() {
var _list = data.channel.substring(0, data.channel.indexOf("?"));
data.channel = _list;
}
if(data.hasOwnProperty("channel")) {
data.channel = Functions.encodeChannelName(data.channel);
}
Chat.all_chat(data, guid, offline, socket);
});
@@ -289,6 +326,9 @@ module.exports = function() {
var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
msg.channel = _list;
}
if(msg.hasOwnProperty("channel")) {
msg.channel = Functions.encodeChannelName(msg.channel);
}
Frontpage.frontpage_lists(msg, socket);
});
@@ -297,6 +337,9 @@ module.exports = function() {
var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
msg.channel = _list;
}
if(msg.hasOwnProperty("channel")) {
msg.channel = Functions.encodeChannelName(msg.channel);
}
ListChange.addFromOtherList(msg, guid, offline, socket);
})
@@ -311,6 +354,9 @@ module.exports = function() {
var _list = arr.channel.substring(0, arr.channel.indexOf("?"));
arr.channel = _list;
}
if(arr.hasOwnProperty("channel")) {
arr.channel = Functions.encodeChannelName(arr.channel);
}
if(typeof(arr) == 'object')
io.to(arr.id).emit(arr.id.toLowerCase(), {type: arr.type, value: arr.value});
});
@@ -321,15 +367,19 @@ module.exports = function() {
var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
msg.channel = _list;
}
if(msg.hasOwnProperty("channel")) {
msg.channel = Functions.encodeChannelName(msg.channel);
}
try {
var _list = msg.channel.replace(/ /g,'');
//var _list = msg.channel.replace(/ /g,'');
var _list = msg.channel;
if(_list.length == 0) return;
if(_list.indexOf("?") > -1){
_list = _list.substring(0, _list.indexOf("?"));
msg.channel = _list;
}
coll = Functions.removeEmojis(_list).toLowerCase();
coll = coll.replace(/_/g, "");
//coll = coll.replace(/_/g, "");
//
coll = filter.clean(coll);
} catch(e) {
@@ -349,12 +399,15 @@ module.exports = function() {
var _list = obj.channel.substring(0, obj.channel.indexOf("?"));
obj.channel = _list;
}
if(obj.hasOwnProperty("channel")) {
obj.channel = Functions.encodeChannelName(obj.channel);
}
if(coll === undefined) {
try {
coll = obj.channel.toLowerCase().replace(/ /g,'');
coll = obj.channel.toLowerCase();//.replace(/ /g,'');
if(coll.length == 0) return;
coll = Functions.removeEmojis(coll).toLowerCase();
coll = coll.replace(/_/g, "");
//coll = coll.replace(/_/g, "");
coll = filter.clean(coll);
} catch(e) {
@@ -369,21 +422,27 @@ module.exports = function() {
var _list = arr.channel.substring(0, arr.channel.indexOf("?"));
arr.channel = _list;
}
if(arr.hasOwnProperty("channel")) {
arr.channel = Functions.encodeChannelName(arr.channel);
}
ListChange.addPlaylist(arr, guid, offline, socket);
})
socket.on('add', function(arr)
{
if(arr.hasOwnProperty("channel") && arr.channel.indexOf("?") > -1){
var _list = arr.channel.substring(0, arr.channel.indexOf("?"));
arr.channel = _list;
if(arr.hasOwnProperty("list") && arr.list.indexOf("?") > -1){
var _list = arr.list.substring(0, arr.list.indexOf("?"));
arr.list = _list;
}
if(arr.hasOwnProperty("list")) {
arr.list = Functions.encodeChannelName(arr.list);
}
if(coll !== undefined) {
try {
coll = arr.list.replace(/ /g,'');
coll = arr.list;//.replace(/ /g,'');
if(coll.length == 0) return;
coll = Functions.removeEmojis(coll).toLowerCase();
coll = coll.replace(/_/g, "");
//coll = coll.replace(/_/g, "");
coll = filter.clean(coll);
} catch(e) {
@@ -399,10 +458,13 @@ module.exports = function() {
var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
msg.channel = _list;
}
coll = msg.channel.toLowerCase().replace(/ /g,'');
if(msg.hasOwnProperty("channel")) {
msg.channel = Functions.encodeChannelName(msg.channel);
}
coll = msg.channel.toLowerCase();//.replace(/ /g,'');
if(coll.length == 0) return;
coll = Functions.removeEmojis(coll).toLowerCase();
coll = coll.replace(/_/g, "");
//coll = coll.replace(/_/g, "");
coll = filter.clean(coll);
} catch(e) {
@@ -418,12 +480,15 @@ module.exports = function() {
var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
msg.channel = _list;
}
if(msg.hasOwnProperty("channel")) {
msg.channel = Functions.encodeChannelName(msg.channel);
}
if(coll !== undefined) {
try {
coll = msg.channel.toLowerCase().replace(/ /g,'');
coll = msg.channel.toLowerCase();//.replace(/ /g,'');
if(coll.length == 0) return;
coll = Functions.removeEmojis(coll).toLowerCase();
coll = coll.replace(/_/g, "");
//coll = coll.replace(/_/g, "");
coll = filter.clean(coll);
} catch(e) {
@@ -439,7 +504,10 @@ module.exports = function() {
var _list = inp.channel.substring(0, inp.channel.indexOf("?"));
inp.channel = _list;
}
if(coll != undefined) coll.replace(/ /g,'');
if(inp.hasOwnProperty("channel")) {
inp.channel = Functions.encodeChannelName(inp.channel);
}
//if(coll != undefined) coll.replace(/ /g,'');
ListSettings.password(inp, coll, guid, offline, socket);
});
@@ -450,7 +518,10 @@ module.exports = function() {
list.channel = _list;
coll = list.channel;
}
if(coll != undefined) coll.replace(/ /g,'');
if(list.hasOwnProperty("channel")) {
list.channel = Functions.encodeChannelName(list.channel);
}
//if(coll != undefined) coll.replace(/ /g,'');
List.skip(list, guid, coll, offline, socket);
});
@@ -461,7 +532,10 @@ module.exports = function() {
conf.channel = _list;
coll = conf.channel;
}
if(coll != undefined) coll.replace(/ /g,'');
if(conf.hasOwnProperty("channel")) {
conf.channel = Functions.encodeChannelName(conf.channel);
}
//if(coll != undefined) coll.replace(/ /g,'');
ListSettings.conf_function(conf, coll, guid, offline, socket);
});
@@ -471,12 +545,15 @@ module.exports = function() {
var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
msg.channel = _list;
}
if(msg.hasOwnProperty("channel")) {
msg.channel = Functions.encodeChannelName(msg.channel);
}
if(coll !== undefined) {
try {
coll = msg.channel.toLowerCase().replace(/ /g,'');
coll = msg.channel.toLowerCase();//.replace(/ /g,'');
if(coll.length == 0) return;
coll = Functions.removeEmojis(coll).toLowerCase();
coll = coll.replace(/_/g, "");
//coll = coll.replace(/_/g, "");
coll = filter.clean(coll);
} catch(e) {
@@ -495,12 +572,15 @@ module.exports = function() {
var _list = obj.channel.substring(0, obj.channel.indexOf("?"));
obj.channel = _list;
}
if(obj.hasOwnProperty("channel")) {
obj.channel = Functions.encodeChannelName(obj.channel);
}
if(coll === undefined && obj !== undefined && obj.channel !== undefined){
try {
coll = obj.channel.toLowerCase().replace(/ /g,'');
coll = obj.channel.toLowerCase();//.replace(/ /g,'');
if(coll.length == 0) return;
coll = Functions.removeEmojis(coll).toLowerCase();
coll = coll.replace(/_/g, "");
//coll = coll.replace(/_/g, "");
coll = filter.clean(coll);
} catch(e) {
@@ -526,8 +606,11 @@ module.exports = function() {
var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
msg.channel = _list;
}
if(msg.hasOwnProperty("channel")) {
msg.channel = Functions.encodeChannelName(msg.channel);
}
if(msg.hasOwnProperty("channel") && msg.channel != "" && typeof(msg.channel) == "string") {
coll = msg.channel.replace(/ /g,'');
coll = msg.channel;//.replace(/ /g,'');
coll = Functions.removeEmojis(coll).toLowerCase();
coll = filter.clean(coll);
List.left_channel(coll, guid, short_id, in_list, socket, false);
@@ -555,13 +638,16 @@ module.exports = function() {
var _list = obj.channel.substring(0, obj.channel.indexOf("?"));
obj.channel = _list;
}
if(obj.hasOwnProperty("channel")) {
obj.channel = Functions.encodeChannelName(obj.channel);
}
if(!obj.hasOwnProperty("channel") || typeof(obj.channel) != "string")
if(coll !== undefined) {
try {
coll = obj.channel.toLowerCase().replace(/ /g,'');
coll = obj.channel.toLowerCase();//.replace(/ /g,'');
if(coll.length == 0) return;
coll = Functions.removeEmojis(coll).toLowerCase();
coll = coll.replace(/_/g, "");
//coll = coll.replace(/_/g, "");
coll = filter.clean(coll);
} catch(e) {

View File

@@ -4,7 +4,12 @@ var Functions = require(pathThumbnails + '/handlers/functions.js');
var Frontpage = require(pathThumbnails + '/handlers/frontpage.js');
var crypto = require('crypto');
var Filter = require('bad-words');
var filter = new Filter({ placeHolder: 'x'});
//var filter = new Filter({ placeHolder: 'x'});
var filter = {
clean: function(str) {
return str;
}
}
var request = require('request');
var db = require(pathThumbnails + '/handlers/db.js');
@@ -53,7 +58,7 @@ function list(msg, guid, coll, offline, socket) {
socket.emit('update_required', result);
return;
}
coll = msg.channel.toLowerCase().replace(/ /g,'');
coll = msg.channel.toLowerCase(); //.replace(/ /g,'');
coll = Functions.removeEmojis(coll).toLowerCase();
coll = filter.clean(coll);
var pass = crypto.createHash('sha256').update(Functions.decrypt_string(msg.pass)).digest("base64");
@@ -119,10 +124,10 @@ function skip(list, guid, coll, offline, socket) {
if(coll == undefined && list.hasOwnProperty('channel')) coll = list.channel.toLowerCase();
if(coll !== undefined) {
try {
coll = list.channel.toLowerCase().replace(/ /g,'');
coll = list.channel.toLowerCase();//.replace(/ /g,'');
if(coll.length == 0) return;
coll = Functions.removeEmojis(coll).toLowerCase();
coll = coll.replace(/_/g, "");
//coll = coll.replace(/_/g, "");
coll = filter.clean(coll);
} catch(e) {
@@ -241,7 +246,7 @@ function skip(list, guid, coll, offline, socket) {
}
function change_song(coll, error, id, callback, socket) {
coll = coll.replace(/ /g,'');
//coll = coll.replace(/ /g,'');
db.collection(coll + "_settings").find(function(err, docs){
var startTime = docs[0].startTime;
if(docs !== null && docs.length !== 0)
@@ -339,7 +344,7 @@ function change_song(coll, error, id, callback, socket) {
}
function change_song_post(coll, next_song, callback, socket) {
coll = coll.replace(/ /g,'');
//coll = coll.replace(/ /g,'');
db.collection(coll).aggregate([{
$match:{
now_playing:false,
@@ -398,7 +403,7 @@ function change_song_post(coll, next_song, callback, socket) {
function send_list(coll, socket, send, list_send, configs, shuffled)
{
coll = coll.replace(/ /g,'');
//coll = coll.replace(/ /g,'');
db.collection(coll + "_settings").find({id: "config"}, function(err, _conf){
var conf = _conf;
if(conf.length == 0) {
@@ -580,7 +585,7 @@ function end(obj, coll, guid, offline, socket) {
socket.emit("update_required", result);
return;
}
coll = coll.replace(/ /g,'');
//coll = coll.replace(/ /g,'');
Functions.getSessionAdminUser(Functions.getSession(socket), coll, function(userpass) {
if(userpass != "" || obj.pass == undefined) {
obj.pass = userpass;
@@ -627,7 +632,7 @@ function end(obj, coll, guid, offline, socket) {
}
function send_play(coll, socket, broadcast) {
coll = coll.replace(/ /g,'');
//coll = coll.replace(/ /g,'');
db.collection(coll).find({now_playing:true}, function(err, np){
db.collection(coll + "_settings").find(function(err, conf){
if(err !== null) console.log(err);
@@ -677,7 +682,7 @@ function send_play(coll, socket, broadcast) {
function sendColor(coll, socket, url, ajax, res) {
if(coll != undefined && typeof(coll) == "string") {
coll = coll.replace(/ /g,'');
//coll = coll.replace(/ /g,'');
}
if(url.indexOf("://") == -1) url = 'https://img.youtube.com/vi/'+url+'/mqdefault.jpg';
//var url = 'https://img.youtube.com/vi/'+id+'/mqdefault.jpg';
@@ -700,7 +705,7 @@ function sendColor(coll, socket, url, ajax, res) {
}
function getNextSong(coll, callback) {
coll = coll.replace(/ /g,'');
//coll = coll.replace(/ /g,'');
db.collection(coll).aggregate([{
$match:{
views:{
@@ -735,7 +740,7 @@ function getNextSong(coll, callback) {
function left_channel(coll, guid, short_id, in_list, socket, change) {
if(!coll) return;
coll = coll.replace(/ /g,'');
//coll = coll.replace(/ /g,'');
db.collection("connected_users").update({"_id": coll}, {$pull: {users: guid}}, function(err, updated) {
if(updated.nModified > 0) {
db.collection("connected_users").find({"_id": coll}, function(err, new_doc){

View File

@@ -4,7 +4,12 @@ var Frontpage = require(pathThumbnails + '/handlers/frontpage.js');
var Search = require(pathThumbnails + '/handlers/search.js');
var crypto = require('crypto');
var Filter = require('bad-words');
var filter = new Filter({ placeHolder: 'x'});
//var filter = new Filter({ placeHolder: 'x'});
var filter = {
clean: function(str) {
return str;
}
}
var db = require(pathThumbnails + '/handlers/db.js');
function addFromOtherList(arr, guid, offline, socket) {
@@ -25,8 +30,8 @@ function addFromOtherList(arr, guid, offline, socket) {
socket.emit('update_required', result);
return;
}
var channel = arr.channel.replace(/ /g,'').toLowerCase();
var new_channel = arr.new_channel.replace(/ /g, '').toLowerCase();
var channel = arr.channel;//.replace(/ /g,'').toLowerCase();
var new_channel = Functions.encodeChannelName(arr.new_channel);//.replace(/ /g, '').toLowerCase();
db.collection("frontpage_lists").find({_id: new_channel}, function(err, fp) {
if(fp.length == 0) {
socket.emit("toast", "nolist");
@@ -163,7 +168,7 @@ function addPlaylist(arr, guid, offline, socket) {
socket.emit('update_required', result);
return;
}
var channel = arr.channel.replace(/ /g,'').toLowerCase();
var channel = arr.channel;//.replace(/ /g,'').toLowerCase();
db.collection("frontpage_lists").find({_id: channel}, function(err, fp) {
if(fp.length == 0) {
socket.emit("toast", "nolist");
@@ -372,7 +377,7 @@ function add_function(arr, coll, guid, offline, socket) {
socket.emit('update_required', result);
return;
}
coll = coll.replace(/ /g,'');
//coll = coll.replace(/ /g,'');
Functions.getSessionAdminUser(Functions.getSession(socket), coll, function(userpass, adminpass) {
if(adminpass != "" || arr.adminpass == undefined) {
arr.adminpass = adminpass;
@@ -380,10 +385,8 @@ function add_function(arr, coll, guid, offline, socket) {
if(userpass != "" || arr.userpass == undefined) {
arr.userpass = userpass;
}
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);
var id = arr.id;
@@ -527,7 +530,7 @@ function voteUndecided(msg, coll, guid, offline, socket) {
socket.emit('update_required', result);
return;
}
coll = msg.channel.toLowerCase().replace(/ /g,'');
coll = msg.channel.toLowerCase();//.replace(/ /g,'');
coll = Functions.removeEmojis(coll).toLowerCase();
coll = filter.clean(coll);
Functions.getSessionAdminUser(Functions.getSession(socket), coll, function(userpass, adminpass) {
@@ -591,7 +594,7 @@ function shuffle(msg, coll, guid, offline, socket) {
socket.emit('update_required', result);
return;
}
coll = msg.channel.toLowerCase().replace(/ /g,'');
coll = msg.channel.toLowerCase();//.replace(/ /g,'');
coll = Functions.removeEmojis(coll).toLowerCase();
coll = filter.clean(coll);
Functions.getSessionAdminUser(Functions.getSession(socket), coll, function(userpass, adminpass) {
@@ -664,7 +667,7 @@ function shuffle(msg, coll, guid, offline, socket) {
function del(params, socket, socketid) {
if(params.id){
var coll = Functions.removeEmojis(params.channel).toLowerCase();
coll = coll.replace(/_/g, "").replace(/ /g,'');
//coll = coll.replace(/_/g, "").replace(/ /g,'');
coll = filter.clean(coll);
db.collection(coll + "_settings").find(function(err, docs){
@@ -713,7 +716,7 @@ function delete_all(msg, coll, guid, offline, socket) {
if(coll == undefined) {
coll = msg.channel;
}
coll = coll.replace(/ /g,'');
//coll = coll.replace(/ /g,'');
coll = Functions.removeEmojis(coll).toLowerCase();
coll = filter.clean(coll);
Functions.getSessionAdminUser(Functions.getSession(socket), coll, function(userpass, adminpass, gotten) {
@@ -753,7 +756,7 @@ function delete_all(msg, coll, guid, offline, socket) {
}
function vote(coll, id, guid, socket) {
coll = coll.replace(/ /g,'');
//coll = coll.replace(/ /g,'');
db.collection(coll).find({id:id, now_playing: false, type:"video"}, function(err, docs){
if(docs !== null && docs.length > 0 && !Functions.contains(docs[0].guids, guid))
{

View File

@@ -1,7 +1,12 @@
var Functions = require(pathThumbnails + '/handlers/functions.js');
var crypto = require('crypto');
var Filter = require('bad-words');
var filter = new Filter({ placeHolder: 'x'});
//var filter = new Filter({ placeHolder: 'x'});
var filter = {
clean: function(str) {
return str;
}
}
var db = require(pathThumbnails + '/handlers/db.js');
function password(inp, coll, guid, offline, socket) {
@@ -29,13 +34,13 @@ function password(inp, coll, guid, offline, socket) {
coll = inp.channel;
if(coll.length == 0) return;
coll = Functions.removeEmojis(coll).toLowerCase();
coll = coll.replace(/_/g, "");
//coll = coll.replace(/_/g, "");
coll = filter.clean(coll);
} catch(e) {
return;
}
coll = coll.replace(/ /g,'');
//coll = coll.replace(/ /g,'');
uncrypted = pw;
pw = Functions.hash_pass(Functions.decrypt_string(pw), true);
Functions.check_inlist(coll, guid, socket, offline);
@@ -90,10 +95,10 @@ function conf_function(params, coll, guid, offline, socket) {
{
if(coll !== undefined) {
try {
coll = params.channel.replace(/ /g,'');
coll = params.channel;//.replace(/ /g,'');
if(coll.length == 0) return;
coll = Functions.removeEmojis(coll).toLowerCase();
coll = coll.replace(/_/g, "");
//coll = coll.replace(/_/g, "");
coll = filter.clean(coll);
} catch(e) {

View File

@@ -2,7 +2,7 @@ var path = require('path');
function requested_change(type, string, channel) {
try {
channel = channel.replace(/ /g,'');
//channel = channel.replace(/ /g,'');
var nodemailer = require('nodemailer');
var mailconfig = require(path.join(__dirname, '../config/mailconfig.js'));

View File

@@ -11,7 +11,7 @@ var request = require('request');
var db = require(pathThumbnails + '/handlers/db.js');
function get_correct_info(song_generated, channel, broadcast, callback) {
channel = channel.replace(/ /g,'');
//channel = channel.replace(/ /g,'');
request({
type: "GET",
url: "https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key="+key+"&id=" + song_generated.id,
@@ -85,7 +85,7 @@ function check_error_video(msg, channel) {
return;
}
if(msg.source == "soundcloud") return;
channel = channel.replace(/ /g,'');
//channel = channel.replace(/ /g,'');
request({
type: "GET",
url: "https://www.googleapis.com/youtube/v3/videos?part=id&key="+key+"&id=" + msg.id,
@@ -103,7 +103,7 @@ function check_error_video(msg, channel) {
}
function findSimilar(msg, channel, broadcast, callback) {
channel = channel.replace(/ /g,'');
//channel = channel.replace(/ /g,'');
var yt_url = "https://www.googleapis.com/youtube/v3/search?key="+key+"&videoEmbeddable=true&part=id&type=video&order=viewCount&safeSearch=none&maxResults=5&q=" + encodeURIComponent(msg.title);
request({
method: "GET",

View File

@@ -28,7 +28,7 @@ function thumbnail(msg, coll, guid, offline, socket) {
socket.emit("update_required", result);
return;
}
coll = coll.replace(/ /g,'');
//coll = coll.replace(/ /g,'');
Functions.getSessionAdminUser(Functions.getSession(socket), coll, function(userpass, adminpass) {
if(userpass != "" || msg.userpass == undefined) {
msg.userpass = userpass;
@@ -84,7 +84,7 @@ function description(msg, coll, guid, offline, socket) {
socket.emit("update_required", result);
return;
}
coll = coll.replace(/ /g,'');
//coll = coll.replace(/ /g,'');
Functions.getSessionAdminUser(Functions.getSession(socket), coll, function(userpass, adminpass, gotten) {
if(userpass != "" || msg.userpass == undefined) {
msg.userpass = userpass;