mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Multi-word channel-names and API-fixes
- Spaces and signs allowed in channel-name - Added missing functioncalls in RESTApi
This commit is contained in:
@@ -1,7 +1,12 @@
|
|||||||
var Functions = require(pathThumbnails + '/handlers/functions.js');
|
var Functions = require(pathThumbnails + '/handlers/functions.js');
|
||||||
var crypto = require('crypto');
|
var crypto = require('crypto');
|
||||||
var Filter = require('bad-words');
|
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');
|
var db = require(pathThumbnails + '/handlers/db.js');
|
||||||
|
|
||||||
function get_history(channel, all, socket) {
|
function get_history(channel, all, socket) {
|
||||||
@@ -16,7 +21,7 @@ function get_history(channel, all, socket) {
|
|||||||
channel: channel,
|
channel: channel,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
channel = channel.replace(/ /g,'');
|
//channel = channel.replace(/ /g,'');
|
||||||
var pass = "";
|
var pass = "";
|
||||||
if(!query.all) {
|
if(!query.all) {
|
||||||
Functions.getSessionAdminUser(Functions.getSession(socket), channel, function(userpass) {
|
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) {
|
function getAndSendLogs(channel, all, socket, pass, query) {
|
||||||
channel = channel.replace(/ /g,'');
|
//channel = channel.replace(/ /g,'');
|
||||||
db.collection("chat_logs").find(query, {
|
db.collection("chat_logs").find(query, {
|
||||||
from: 1,
|
from: 1,
|
||||||
createdAt: 1,
|
createdAt: 1,
|
||||||
@@ -72,7 +77,7 @@ function chat(msg, guid, offline, socket) {
|
|||||||
socket.emit('update_required', result);
|
socket.emit('update_required', result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var coll = msg.channel.toLowerCase().replace(/ /g,'');
|
var coll = msg.channel.toLowerCase();//.replace(/ /g,'');
|
||||||
coll = Functions.removeEmojis(coll).toLowerCase();
|
coll = Functions.removeEmojis(coll).toLowerCase();
|
||||||
coll = filter.clean(coll);
|
coll = filter.clean(coll);
|
||||||
Functions.getSessionAdminUser(Functions.getSession(socket), coll, function(userpass) {
|
Functions.getSessionAdminUser(Functions.getSession(socket), coll, function(userpass) {
|
||||||
@@ -124,7 +129,7 @@ function all_chat(msg, guid, offline, socket) {
|
|||||||
socket.emit('update_required', result);
|
socket.emit('update_required', result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var coll = msg.channel.toLowerCase().replace(/ /g,'');
|
var coll = msg.channel.toLowerCase();//.replace(/ /g,'');
|
||||||
var data = msg.data;
|
var data = msg.data;
|
||||||
coll = Functions.removeEmojis(coll).toLowerCase();
|
coll = Functions.removeEmojis(coll).toLowerCase();
|
||||||
coll = filter.clean(coll);
|
coll = filter.clean(coll);
|
||||||
@@ -216,7 +221,7 @@ function namechange(data, guid, socket, tried) {
|
|||||||
//socket.emit('name', {type: "name", accepted: true});
|
//socket.emit('name', {type: "name", accepted: true});
|
||||||
if(old_name != name && !first) {
|
if(old_name != name && !first) {
|
||||||
if(data.hasOwnProperty("channel") && typeof(data.channel) == "string") {
|
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});
|
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) {
|
function removename(guid, coll, socket) {
|
||||||
coll = coll.replace(/ /g,'');
|
//coll = coll.replace(/ /g,'');
|
||||||
db.collection("user_names").find({"guid": guid}, function(err, docs) {
|
db.collection("user_names").find({"guid": guid}, function(err, docs) {
|
||||||
if(docs.length == 1) {
|
if(docs.length == 1) {
|
||||||
var old_name = docs[0].name;
|
var old_name = docs[0].name;
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ function frontpage_lists(msg, socket) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function update_frontpage(coll, id, title, thumbnail, source, callback) {
|
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) {
|
db.collection("frontpage_lists").find({_id: coll}, function(e, doc) {
|
||||||
var updateObject = {
|
var updateObject = {
|
||||||
id: id,
|
id: id,
|
||||||
|
|||||||
@@ -12,6 +12,22 @@ var crypto = require('crypto');
|
|||||||
var db = require(pathThumbnails + '/handlers/db.js');
|
var db = require(pathThumbnails + '/handlers/db.js');
|
||||||
var uniqid = require('uniqid');
|
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) {
|
function remove_unique_id(short_id) {
|
||||||
db.collection("unique_ids").update({"_id": "unique_ids"}, {$pull: {unique_ids: short_id}}, function(err, docs) {});
|
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;
|
if(coll == undefined) return;
|
||||||
coll = coll.replace(/ /g,'');
|
//coll = coll.replace(/ /g,'');
|
||||||
if(!offline && coll != undefined){
|
if(!offline && coll != undefined){
|
||||||
db.collection("connected_users").update({"_id": coll}, {$addToSet:{users: guid}}, {upsert: true}, function(err, updated) {
|
db.collection("connected_users").update({"_id": coll}, {$addToSet:{users: guid}}, {upsert: true}, function(err, updated) {
|
||||||
if(updated.nModified > 0 || updated.upserted != undefined) {
|
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.isUrl = isUrl;
|
||||||
module.exports.removeEmojis = removeEmojis;
|
module.exports.removeEmojis = removeEmojis;
|
||||||
module.exports.getSessionChatPass = getSessionChatPass;
|
module.exports.getSessionChatPass = getSessionChatPass;
|
||||||
|
|||||||
@@ -11,7 +11,12 @@ var Frontpage = require(pathThumbnails + '/handlers/frontpage.js');
|
|||||||
var Search = require(pathThumbnails + '/handlers/search.js');
|
var Search = require(pathThumbnails + '/handlers/search.js');
|
||||||
var crypto = require('crypto');
|
var crypto = require('crypto');
|
||||||
var Filter = require('bad-words');
|
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');
|
var db = require(pathThumbnails + '/handlers/db.js');
|
||||||
|
|
||||||
module.exports = function() {
|
module.exports = function() {
|
||||||
@@ -53,7 +58,10 @@ module.exports = function() {
|
|||||||
if(channel.indexOf("?") > -1){
|
if(channel.indexOf("?") > -1){
|
||||||
channel = channel.substring(0, channel.indexOf("?"));
|
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) {
|
if(offline) {
|
||||||
db.collection("connected_users").update({"_id": "offline_users"}, {$addToSet: {users: guid}}, {upsert: true}, function(err, docs){});
|
db.collection("connected_users").update({"_id": "offline_users"}, {$addToSet: {users: guid}}, {upsert: true}, function(err, docs){});
|
||||||
} else {
|
} else {
|
||||||
@@ -81,7 +89,10 @@ module.exports = function() {
|
|||||||
guid = msg.guid;
|
guid = msg.guid;
|
||||||
socketid = msg.socket_id;
|
socketid = msg.socket_id;
|
||||||
socket.zoff_id = socketid;
|
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 = Functions.removeEmojis(coll).toLowerCase();
|
||||||
coll = filter.clean(coll);
|
coll = filter.clean(coll);
|
||||||
if(coll.indexOf("?") > -1){
|
if(coll.indexOf("?") > -1){
|
||||||
@@ -104,19 +115,22 @@ module.exports = function() {
|
|||||||
|
|
||||||
socket.on("error_video", function(msg) {
|
socket.on("error_video", function(msg) {
|
||||||
try {
|
try {
|
||||||
var _list = msg.channel.replace(/ /g,'');
|
var _list = msg.channel;//.replace(/ /g,'');
|
||||||
if(_list.length == 0) return;
|
if(_list.length == 0) return;
|
||||||
if(_list.indexOf("?") > -1){
|
if(_list.indexOf("?") > -1){
|
||||||
_list = _list.substring(0, _list.indexOf("?"));
|
_list = _list.substring(0, _list.indexOf("?"));
|
||||||
msg.channel = _list;
|
msg.channel = _list;
|
||||||
}
|
}
|
||||||
coll = Functions.removeEmojis(_list).toLowerCase();
|
coll = Functions.removeEmojis(_list).toLowerCase();
|
||||||
coll = coll.replace(/_/g, "");
|
//coll = coll.replace(/_/g, "");
|
||||||
|
|
||||||
coll = filter.clean(coll);
|
coll = filter.clean(coll);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if(msg.hasOwnProperty("channel")) {
|
||||||
|
msg.channel = Functions.encodeChannelName(msg.channel);
|
||||||
|
}
|
||||||
Search.check_error_video(msg, coll);
|
Search.check_error_video(msg, coll);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -139,7 +153,10 @@ module.exports = function() {
|
|||||||
var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
|
var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
|
||||||
msg.channel = _list;
|
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){
|
socket.on('suggest_description', function(msg){
|
||||||
@@ -147,7 +164,10 @@ module.exports = function() {
|
|||||||
var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
|
var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
|
||||||
msg.channel = _list;
|
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) {
|
socket.on("namechange", function(msg) {
|
||||||
@@ -155,6 +175,9 @@ module.exports = function() {
|
|||||||
var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
|
var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
|
||||||
msg.channel = _list;
|
msg.channel = _list;
|
||||||
}
|
}
|
||||||
|
if(msg.hasOwnProperty("channel")) {
|
||||||
|
msg.channel = Functions.encodeChannelName(msg.channel);
|
||||||
|
}
|
||||||
Chat.namechange(msg, guid, socket);
|
Chat.namechange(msg, guid, socket);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -163,6 +186,9 @@ module.exports = function() {
|
|||||||
var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
|
var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
|
||||||
msg.channel = _list;
|
msg.channel = _list;
|
||||||
}
|
}
|
||||||
|
if(msg.hasOwnProperty("channel")) {
|
||||||
|
msg.channel = Functions.encodeChannelName(msg.channel);
|
||||||
|
}
|
||||||
if(typeof(msg) != "object" || !msg.hasOwnProperty("channel")) {
|
if(typeof(msg) != "object" || !msg.hasOwnProperty("channel")) {
|
||||||
var result = {
|
var result = {
|
||||||
channel: {
|
channel: {
|
||||||
@@ -181,6 +207,9 @@ module.exports = function() {
|
|||||||
var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
|
var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
|
||||||
msg.channel = _list;
|
msg.channel = _list;
|
||||||
}
|
}
|
||||||
|
if(msg.hasOwnProperty("channel")) {
|
||||||
|
msg.channel = Functions.encodeChannelName(msg.channel);
|
||||||
|
}
|
||||||
if(!msg.hasOwnProperty('status') || !msg.hasOwnProperty('channel') ||
|
if(!msg.hasOwnProperty('status') || !msg.hasOwnProperty('channel') ||
|
||||||
typeof(msg.status) != "boolean" || typeof(msg.channel) != "string") {
|
typeof(msg.status) != "boolean" || typeof(msg.channel) != "string") {
|
||||||
var result = {
|
var result = {
|
||||||
@@ -197,7 +226,7 @@ module.exports = function() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var status = msg.status;
|
var status = msg.status;
|
||||||
var channel = msg.channel.replace(/ /g,'');
|
var channel = msg.channel;//.replace(/ /g,'');
|
||||||
if(status){
|
if(status){
|
||||||
in_list = false;
|
in_list = false;
|
||||||
offline = true;
|
offline = true;
|
||||||
@@ -205,7 +234,6 @@ module.exports = function() {
|
|||||||
if(coll !== undefined) {
|
if(coll !== undefined) {
|
||||||
coll = Functions.removeEmojis(coll).toLowerCase();
|
coll = Functions.removeEmojis(coll).toLowerCase();
|
||||||
coll = filter.clean(coll);
|
coll = filter.clean(coll);
|
||||||
|
|
||||||
db.collection("connected_users").findAndModify({
|
db.collection("connected_users").findAndModify({
|
||||||
query: {"_id": coll},
|
query: {"_id": coll},
|
||||||
update: {$pull: {users: guid}},
|
update: {$pull: {users: guid}},
|
||||||
@@ -219,7 +247,7 @@ module.exports = function() {
|
|||||||
io.to(coll).emit("viewers", num);
|
io.to(coll).emit("viewers", num);
|
||||||
db.collection("frontpage_lists").update({"_id": coll, "viewers": {$gt: 0}}, {$inc: {viewers: -1}}, function(err, docs) { });
|
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": "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 != "")) {
|
if(docs.nModified == 1 && (coll != undefined && coll != "")) {
|
||||||
db.collection("connected_users").update({"_id": "total_users"}, {$addToSet: {total_users: guid + coll}}, function(err, docs) {});
|
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("?"));
|
var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
|
||||||
msg.channel = _list;
|
msg.channel = _list;
|
||||||
}
|
}
|
||||||
|
if(msg.hasOwnProperty("channel")) {
|
||||||
|
msg.channel = Functions.encodeChannelName(msg.channel);
|
||||||
|
}
|
||||||
if(!msg.hasOwnProperty("channel") || !msg.hasOwnProperty("all") ||
|
if(!msg.hasOwnProperty("channel") || !msg.hasOwnProperty("all") ||
|
||||||
typeof(msg.channel) != "string" || typeof(msg.all) != "boolean") {
|
typeof(msg.channel) != "string" || typeof(msg.all) != "boolean") {
|
||||||
var result = {
|
var result = {
|
||||||
@@ -263,7 +294,7 @@ module.exports = function() {
|
|||||||
socket.emit('update_required', result);
|
socket.emit('update_required', result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Chat.get_history(msg.channel.replace(/ /g,''), msg.all, socket);
|
Chat.get_history(msg.channel, msg.all, socket);
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('chat', function (msg) {
|
socket.on('chat', function (msg) {
|
||||||
@@ -271,6 +302,9 @@ module.exports = function() {
|
|||||||
var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
|
var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
|
||||||
msg.channel = _list;
|
msg.channel = _list;
|
||||||
}
|
}
|
||||||
|
if(msg.hasOwnProperty("channel")) {
|
||||||
|
msg.channel = Functions.encodeChannelName(msg.channel);
|
||||||
|
}
|
||||||
Chat.chat(msg, guid, offline, socket);
|
Chat.chat(msg, guid, offline, socket);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -280,6 +314,9 @@ module.exports = function() {
|
|||||||
var _list = data.channel.substring(0, data.channel.indexOf("?"));
|
var _list = data.channel.substring(0, data.channel.indexOf("?"));
|
||||||
data.channel = _list;
|
data.channel = _list;
|
||||||
}
|
}
|
||||||
|
if(data.hasOwnProperty("channel")) {
|
||||||
|
data.channel = Functions.encodeChannelName(data.channel);
|
||||||
|
}
|
||||||
Chat.all_chat(data, guid, offline, socket);
|
Chat.all_chat(data, guid, offline, socket);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -289,6 +326,9 @@ module.exports = function() {
|
|||||||
var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
|
var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
|
||||||
msg.channel = _list;
|
msg.channel = _list;
|
||||||
}
|
}
|
||||||
|
if(msg.hasOwnProperty("channel")) {
|
||||||
|
msg.channel = Functions.encodeChannelName(msg.channel);
|
||||||
|
}
|
||||||
Frontpage.frontpage_lists(msg, socket);
|
Frontpage.frontpage_lists(msg, socket);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -297,6 +337,9 @@ module.exports = function() {
|
|||||||
var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
|
var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
|
||||||
msg.channel = _list;
|
msg.channel = _list;
|
||||||
}
|
}
|
||||||
|
if(msg.hasOwnProperty("channel")) {
|
||||||
|
msg.channel = Functions.encodeChannelName(msg.channel);
|
||||||
|
}
|
||||||
ListChange.addFromOtherList(msg, guid, offline, socket);
|
ListChange.addFromOtherList(msg, guid, offline, socket);
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -311,6 +354,9 @@ module.exports = function() {
|
|||||||
var _list = arr.channel.substring(0, arr.channel.indexOf("?"));
|
var _list = arr.channel.substring(0, arr.channel.indexOf("?"));
|
||||||
arr.channel = _list;
|
arr.channel = _list;
|
||||||
}
|
}
|
||||||
|
if(arr.hasOwnProperty("channel")) {
|
||||||
|
arr.channel = Functions.encodeChannelName(arr.channel);
|
||||||
|
}
|
||||||
if(typeof(arr) == 'object')
|
if(typeof(arr) == 'object')
|
||||||
io.to(arr.id).emit(arr.id.toLowerCase(), {type: arr.type, value: arr.value});
|
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("?"));
|
var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
|
||||||
msg.channel = _list;
|
msg.channel = _list;
|
||||||
}
|
}
|
||||||
|
if(msg.hasOwnProperty("channel")) {
|
||||||
|
msg.channel = Functions.encodeChannelName(msg.channel);
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
var _list = msg.channel.replace(/ /g,'');
|
//var _list = msg.channel.replace(/ /g,'');
|
||||||
|
var _list = msg.channel;
|
||||||
if(_list.length == 0) return;
|
if(_list.length == 0) return;
|
||||||
if(_list.indexOf("?") > -1){
|
if(_list.indexOf("?") > -1){
|
||||||
_list = _list.substring(0, _list.indexOf("?"));
|
_list = _list.substring(0, _list.indexOf("?"));
|
||||||
msg.channel = _list;
|
msg.channel = _list;
|
||||||
}
|
}
|
||||||
coll = Functions.removeEmojis(_list).toLowerCase();
|
coll = Functions.removeEmojis(_list).toLowerCase();
|
||||||
coll = coll.replace(/_/g, "");
|
//coll = coll.replace(/_/g, "");
|
||||||
//
|
//
|
||||||
coll = filter.clean(coll);
|
coll = filter.clean(coll);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
@@ -349,12 +399,15 @@ module.exports = function() {
|
|||||||
var _list = obj.channel.substring(0, obj.channel.indexOf("?"));
|
var _list = obj.channel.substring(0, obj.channel.indexOf("?"));
|
||||||
obj.channel = _list;
|
obj.channel = _list;
|
||||||
}
|
}
|
||||||
|
if(obj.hasOwnProperty("channel")) {
|
||||||
|
obj.channel = Functions.encodeChannelName(obj.channel);
|
||||||
|
}
|
||||||
if(coll === undefined) {
|
if(coll === undefined) {
|
||||||
try {
|
try {
|
||||||
coll = obj.channel.toLowerCase().replace(/ /g,'');
|
coll = obj.channel.toLowerCase();//.replace(/ /g,'');
|
||||||
if(coll.length == 0) return;
|
if(coll.length == 0) return;
|
||||||
coll = Functions.removeEmojis(coll).toLowerCase();
|
coll = Functions.removeEmojis(coll).toLowerCase();
|
||||||
coll = coll.replace(/_/g, "");
|
//coll = coll.replace(/_/g, "");
|
||||||
|
|
||||||
coll = filter.clean(coll);
|
coll = filter.clean(coll);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
@@ -369,21 +422,27 @@ module.exports = function() {
|
|||||||
var _list = arr.channel.substring(0, arr.channel.indexOf("?"));
|
var _list = arr.channel.substring(0, arr.channel.indexOf("?"));
|
||||||
arr.channel = _list;
|
arr.channel = _list;
|
||||||
}
|
}
|
||||||
|
if(arr.hasOwnProperty("channel")) {
|
||||||
|
arr.channel = Functions.encodeChannelName(arr.channel);
|
||||||
|
}
|
||||||
ListChange.addPlaylist(arr, guid, offline, socket);
|
ListChange.addPlaylist(arr, guid, offline, socket);
|
||||||
})
|
})
|
||||||
|
|
||||||
socket.on('add', function(arr)
|
socket.on('add', function(arr)
|
||||||
{
|
{
|
||||||
if(arr.hasOwnProperty("channel") && arr.channel.indexOf("?") > -1){
|
if(arr.hasOwnProperty("list") && arr.list.indexOf("?") > -1){
|
||||||
var _list = arr.channel.substring(0, arr.channel.indexOf("?"));
|
var _list = arr.list.substring(0, arr.list.indexOf("?"));
|
||||||
arr.channel = _list;
|
arr.list = _list;
|
||||||
|
}
|
||||||
|
if(arr.hasOwnProperty("list")) {
|
||||||
|
arr.list = Functions.encodeChannelName(arr.list);
|
||||||
}
|
}
|
||||||
if(coll !== undefined) {
|
if(coll !== undefined) {
|
||||||
try {
|
try {
|
||||||
coll = arr.list.replace(/ /g,'');
|
coll = arr.list;//.replace(/ /g,'');
|
||||||
if(coll.length == 0) return;
|
if(coll.length == 0) return;
|
||||||
coll = Functions.removeEmojis(coll).toLowerCase();
|
coll = Functions.removeEmojis(coll).toLowerCase();
|
||||||
coll = coll.replace(/_/g, "");
|
//coll = coll.replace(/_/g, "");
|
||||||
|
|
||||||
coll = filter.clean(coll);
|
coll = filter.clean(coll);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
@@ -399,10 +458,13 @@ module.exports = function() {
|
|||||||
var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
|
var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
|
||||||
msg.channel = _list;
|
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;
|
if(coll.length == 0) return;
|
||||||
coll = Functions.removeEmojis(coll).toLowerCase();
|
coll = Functions.removeEmojis(coll).toLowerCase();
|
||||||
coll = coll.replace(/_/g, "");
|
//coll = coll.replace(/_/g, "");
|
||||||
|
|
||||||
coll = filter.clean(coll);
|
coll = filter.clean(coll);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
@@ -418,12 +480,15 @@ module.exports = function() {
|
|||||||
var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
|
var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
|
||||||
msg.channel = _list;
|
msg.channel = _list;
|
||||||
}
|
}
|
||||||
|
if(msg.hasOwnProperty("channel")) {
|
||||||
|
msg.channel = Functions.encodeChannelName(msg.channel);
|
||||||
|
}
|
||||||
if(coll !== undefined) {
|
if(coll !== undefined) {
|
||||||
try {
|
try {
|
||||||
coll = msg.channel.toLowerCase().replace(/ /g,'');
|
coll = msg.channel.toLowerCase();//.replace(/ /g,'');
|
||||||
if(coll.length == 0) return;
|
if(coll.length == 0) return;
|
||||||
coll = Functions.removeEmojis(coll).toLowerCase();
|
coll = Functions.removeEmojis(coll).toLowerCase();
|
||||||
coll = coll.replace(/_/g, "");
|
//coll = coll.replace(/_/g, "");
|
||||||
|
|
||||||
coll = filter.clean(coll);
|
coll = filter.clean(coll);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
@@ -439,7 +504,10 @@ module.exports = function() {
|
|||||||
var _list = inp.channel.substring(0, inp.channel.indexOf("?"));
|
var _list = inp.channel.substring(0, inp.channel.indexOf("?"));
|
||||||
inp.channel = _list;
|
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);
|
ListSettings.password(inp, coll, guid, offline, socket);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -450,7 +518,10 @@ module.exports = function() {
|
|||||||
list.channel = _list;
|
list.channel = _list;
|
||||||
coll = list.channel;
|
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);
|
List.skip(list, guid, coll, offline, socket);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -461,7 +532,10 @@ module.exports = function() {
|
|||||||
conf.channel = _list;
|
conf.channel = _list;
|
||||||
coll = conf.channel;
|
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);
|
ListSettings.conf_function(conf, coll, guid, offline, socket);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -471,12 +545,15 @@ module.exports = function() {
|
|||||||
var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
|
var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
|
||||||
msg.channel = _list;
|
msg.channel = _list;
|
||||||
}
|
}
|
||||||
|
if(msg.hasOwnProperty("channel")) {
|
||||||
|
msg.channel = Functions.encodeChannelName(msg.channel);
|
||||||
|
}
|
||||||
if(coll !== undefined) {
|
if(coll !== undefined) {
|
||||||
try {
|
try {
|
||||||
coll = msg.channel.toLowerCase().replace(/ /g,'');
|
coll = msg.channel.toLowerCase();//.replace(/ /g,'');
|
||||||
if(coll.length == 0) return;
|
if(coll.length == 0) return;
|
||||||
coll = Functions.removeEmojis(coll).toLowerCase();
|
coll = Functions.removeEmojis(coll).toLowerCase();
|
||||||
coll = coll.replace(/_/g, "");
|
//coll = coll.replace(/_/g, "");
|
||||||
|
|
||||||
coll = filter.clean(coll);
|
coll = filter.clean(coll);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
@@ -495,12 +572,15 @@ module.exports = function() {
|
|||||||
var _list = obj.channel.substring(0, obj.channel.indexOf("?"));
|
var _list = obj.channel.substring(0, obj.channel.indexOf("?"));
|
||||||
obj.channel = _list;
|
obj.channel = _list;
|
||||||
}
|
}
|
||||||
|
if(obj.hasOwnProperty("channel")) {
|
||||||
|
obj.channel = Functions.encodeChannelName(obj.channel);
|
||||||
|
}
|
||||||
if(coll === undefined && obj !== undefined && obj.channel !== undefined){
|
if(coll === undefined && obj !== undefined && obj.channel !== undefined){
|
||||||
try {
|
try {
|
||||||
coll = obj.channel.toLowerCase().replace(/ /g,'');
|
coll = obj.channel.toLowerCase();//.replace(/ /g,'');
|
||||||
if(coll.length == 0) return;
|
if(coll.length == 0) return;
|
||||||
coll = Functions.removeEmojis(coll).toLowerCase();
|
coll = Functions.removeEmojis(coll).toLowerCase();
|
||||||
coll = coll.replace(/_/g, "");
|
//coll = coll.replace(/_/g, "");
|
||||||
|
|
||||||
coll = filter.clean(coll);
|
coll = filter.clean(coll);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
@@ -526,8 +606,11 @@ module.exports = function() {
|
|||||||
var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
|
var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
|
||||||
msg.channel = _list;
|
msg.channel = _list;
|
||||||
}
|
}
|
||||||
|
if(msg.hasOwnProperty("channel")) {
|
||||||
|
msg.channel = Functions.encodeChannelName(msg.channel);
|
||||||
|
}
|
||||||
if(msg.hasOwnProperty("channel") && msg.channel != "" && typeof(msg.channel) == "string") {
|
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 = Functions.removeEmojis(coll).toLowerCase();
|
||||||
coll = filter.clean(coll);
|
coll = filter.clean(coll);
|
||||||
List.left_channel(coll, guid, short_id, in_list, socket, false);
|
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("?"));
|
var _list = obj.channel.substring(0, obj.channel.indexOf("?"));
|
||||||
obj.channel = _list;
|
obj.channel = _list;
|
||||||
}
|
}
|
||||||
|
if(obj.hasOwnProperty("channel")) {
|
||||||
|
obj.channel = Functions.encodeChannelName(obj.channel);
|
||||||
|
}
|
||||||
if(!obj.hasOwnProperty("channel") || typeof(obj.channel) != "string")
|
if(!obj.hasOwnProperty("channel") || typeof(obj.channel) != "string")
|
||||||
if(coll !== undefined) {
|
if(coll !== undefined) {
|
||||||
try {
|
try {
|
||||||
coll = obj.channel.toLowerCase().replace(/ /g,'');
|
coll = obj.channel.toLowerCase();//.replace(/ /g,'');
|
||||||
if(coll.length == 0) return;
|
if(coll.length == 0) return;
|
||||||
coll = Functions.removeEmojis(coll).toLowerCase();
|
coll = Functions.removeEmojis(coll).toLowerCase();
|
||||||
coll = coll.replace(/_/g, "");
|
//coll = coll.replace(/_/g, "");
|
||||||
|
|
||||||
coll = filter.clean(coll);
|
coll = filter.clean(coll);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
|
|||||||
@@ -4,7 +4,12 @@ var Functions = require(pathThumbnails + '/handlers/functions.js');
|
|||||||
var Frontpage = require(pathThumbnails + '/handlers/frontpage.js');
|
var Frontpage = require(pathThumbnails + '/handlers/frontpage.js');
|
||||||
var crypto = require('crypto');
|
var crypto = require('crypto');
|
||||||
var Filter = require('bad-words');
|
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 request = require('request');
|
||||||
var db = require(pathThumbnails + '/handlers/db.js');
|
var db = require(pathThumbnails + '/handlers/db.js');
|
||||||
|
|
||||||
@@ -53,7 +58,7 @@ function list(msg, guid, coll, offline, socket) {
|
|||||||
socket.emit('update_required', result);
|
socket.emit('update_required', result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
coll = msg.channel.toLowerCase().replace(/ /g,'');
|
coll = msg.channel.toLowerCase(); //.replace(/ /g,'');
|
||||||
coll = Functions.removeEmojis(coll).toLowerCase();
|
coll = Functions.removeEmojis(coll).toLowerCase();
|
||||||
coll = filter.clean(coll);
|
coll = filter.clean(coll);
|
||||||
var pass = crypto.createHash('sha256').update(Functions.decrypt_string(msg.pass)).digest("base64");
|
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 && list.hasOwnProperty('channel')) coll = list.channel.toLowerCase();
|
||||||
if(coll !== undefined) {
|
if(coll !== undefined) {
|
||||||
try {
|
try {
|
||||||
coll = list.channel.toLowerCase().replace(/ /g,'');
|
coll = list.channel.toLowerCase();//.replace(/ /g,'');
|
||||||
if(coll.length == 0) return;
|
if(coll.length == 0) return;
|
||||||
coll = Functions.removeEmojis(coll).toLowerCase();
|
coll = Functions.removeEmojis(coll).toLowerCase();
|
||||||
coll = coll.replace(/_/g, "");
|
//coll = coll.replace(/_/g, "");
|
||||||
|
|
||||||
coll = filter.clean(coll);
|
coll = filter.clean(coll);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
@@ -241,7 +246,7 @@ function skip(list, guid, coll, offline, socket) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function change_song(coll, error, id, callback, 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){
|
db.collection(coll + "_settings").find(function(err, docs){
|
||||||
var startTime = docs[0].startTime;
|
var startTime = docs[0].startTime;
|
||||||
if(docs !== null && docs.length !== 0)
|
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) {
|
function change_song_post(coll, next_song, callback, socket) {
|
||||||
coll = coll.replace(/ /g,'');
|
//coll = coll.replace(/ /g,'');
|
||||||
db.collection(coll).aggregate([{
|
db.collection(coll).aggregate([{
|
||||||
$match:{
|
$match:{
|
||||||
now_playing:false,
|
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)
|
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){
|
db.collection(coll + "_settings").find({id: "config"}, function(err, _conf){
|
||||||
var conf = _conf;
|
var conf = _conf;
|
||||||
if(conf.length == 0) {
|
if(conf.length == 0) {
|
||||||
@@ -580,7 +585,7 @@ function end(obj, coll, guid, offline, socket) {
|
|||||||
socket.emit("update_required", result);
|
socket.emit("update_required", result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
coll = coll.replace(/ /g,'');
|
//coll = coll.replace(/ /g,'');
|
||||||
Functions.getSessionAdminUser(Functions.getSession(socket), coll, function(userpass) {
|
Functions.getSessionAdminUser(Functions.getSession(socket), coll, function(userpass) {
|
||||||
if(userpass != "" || obj.pass == undefined) {
|
if(userpass != "" || obj.pass == undefined) {
|
||||||
obj.pass = userpass;
|
obj.pass = userpass;
|
||||||
@@ -627,7 +632,7 @@ function end(obj, coll, guid, offline, socket) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function send_play(coll, socket, broadcast) {
|
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).find({now_playing:true}, function(err, np){
|
||||||
db.collection(coll + "_settings").find(function(err, conf){
|
db.collection(coll + "_settings").find(function(err, conf){
|
||||||
if(err !== null) console.log(err);
|
if(err !== null) console.log(err);
|
||||||
@@ -677,7 +682,7 @@ function send_play(coll, socket, broadcast) {
|
|||||||
|
|
||||||
function sendColor(coll, socket, url, ajax, res) {
|
function sendColor(coll, socket, url, ajax, res) {
|
||||||
if(coll != undefined && typeof(coll) == "string") {
|
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';
|
if(url.indexOf("://") == -1) url = 'https://img.youtube.com/vi/'+url+'/mqdefault.jpg';
|
||||||
//var url = 'https://img.youtube.com/vi/'+id+'/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) {
|
function getNextSong(coll, callback) {
|
||||||
coll = coll.replace(/ /g,'');
|
//coll = coll.replace(/ /g,'');
|
||||||
db.collection(coll).aggregate([{
|
db.collection(coll).aggregate([{
|
||||||
$match:{
|
$match:{
|
||||||
views:{
|
views:{
|
||||||
@@ -735,7 +740,7 @@ function getNextSong(coll, callback) {
|
|||||||
|
|
||||||
function left_channel(coll, guid, short_id, in_list, socket, change) {
|
function left_channel(coll, guid, short_id, in_list, socket, change) {
|
||||||
if(!coll) return;
|
if(!coll) return;
|
||||||
coll = coll.replace(/ /g,'');
|
//coll = coll.replace(/ /g,'');
|
||||||
db.collection("connected_users").update({"_id": coll}, {$pull: {users: guid}}, function(err, updated) {
|
db.collection("connected_users").update({"_id": coll}, {$pull: {users: guid}}, function(err, updated) {
|
||||||
if(updated.nModified > 0) {
|
if(updated.nModified > 0) {
|
||||||
db.collection("connected_users").find({"_id": coll}, function(err, new_doc){
|
db.collection("connected_users").find({"_id": coll}, function(err, new_doc){
|
||||||
|
|||||||
@@ -4,7 +4,12 @@ var Frontpage = require(pathThumbnails + '/handlers/frontpage.js');
|
|||||||
var Search = require(pathThumbnails + '/handlers/search.js');
|
var Search = require(pathThumbnails + '/handlers/search.js');
|
||||||
var crypto = require('crypto');
|
var crypto = require('crypto');
|
||||||
var Filter = require('bad-words');
|
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');
|
var db = require(pathThumbnails + '/handlers/db.js');
|
||||||
|
|
||||||
function addFromOtherList(arr, guid, offline, socket) {
|
function addFromOtherList(arr, guid, offline, socket) {
|
||||||
@@ -25,8 +30,8 @@ function addFromOtherList(arr, guid, offline, socket) {
|
|||||||
socket.emit('update_required', result);
|
socket.emit('update_required', result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var channel = arr.channel.replace(/ /g,'').toLowerCase();
|
var channel = arr.channel;//.replace(/ /g,'').toLowerCase();
|
||||||
var new_channel = arr.new_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) {
|
db.collection("frontpage_lists").find({_id: new_channel}, function(err, fp) {
|
||||||
if(fp.length == 0) {
|
if(fp.length == 0) {
|
||||||
socket.emit("toast", "nolist");
|
socket.emit("toast", "nolist");
|
||||||
@@ -163,7 +168,7 @@ function addPlaylist(arr, guid, offline, socket) {
|
|||||||
socket.emit('update_required', result);
|
socket.emit('update_required', result);
|
||||||
return;
|
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) {
|
db.collection("frontpage_lists").find({_id: channel}, function(err, fp) {
|
||||||
if(fp.length == 0) {
|
if(fp.length == 0) {
|
||||||
socket.emit("toast", "nolist");
|
socket.emit("toast", "nolist");
|
||||||
@@ -372,7 +377,7 @@ function add_function(arr, coll, guid, offline, socket) {
|
|||||||
socket.emit('update_required', result);
|
socket.emit('update_required', result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
coll = coll.replace(/ /g,'');
|
//coll = coll.replace(/ /g,'');
|
||||||
Functions.getSessionAdminUser(Functions.getSession(socket), coll, function(userpass, adminpass) {
|
Functions.getSessionAdminUser(Functions.getSession(socket), coll, function(userpass, adminpass) {
|
||||||
if(adminpass != "" || arr.adminpass == undefined) {
|
if(adminpass != "" || arr.adminpass == undefined) {
|
||||||
arr.adminpass = adminpass;
|
arr.adminpass = adminpass;
|
||||||
@@ -380,10 +385,8 @@ function add_function(arr, coll, guid, offline, socket) {
|
|||||||
if(userpass != "" || arr.userpass == undefined) {
|
if(userpass != "" || arr.userpass == undefined) {
|
||||||
arr.userpass = userpass;
|
arr.userpass = userpass;
|
||||||
}
|
}
|
||||||
|
|
||||||
db.collection(coll + "_settings").find(function(err, docs){
|
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")))) {
|
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);
|
||||||
|
|
||||||
var id = arr.id;
|
var id = arr.id;
|
||||||
@@ -527,7 +530,7 @@ function voteUndecided(msg, coll, guid, offline, socket) {
|
|||||||
socket.emit('update_required', result);
|
socket.emit('update_required', result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
coll = msg.channel.toLowerCase().replace(/ /g,'');
|
coll = msg.channel.toLowerCase();//.replace(/ /g,'');
|
||||||
coll = Functions.removeEmojis(coll).toLowerCase();
|
coll = Functions.removeEmojis(coll).toLowerCase();
|
||||||
coll = filter.clean(coll);
|
coll = filter.clean(coll);
|
||||||
Functions.getSessionAdminUser(Functions.getSession(socket), coll, function(userpass, adminpass) {
|
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);
|
socket.emit('update_required', result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
coll = msg.channel.toLowerCase().replace(/ /g,'');
|
coll = msg.channel.toLowerCase();//.replace(/ /g,'');
|
||||||
coll = Functions.removeEmojis(coll).toLowerCase();
|
coll = Functions.removeEmojis(coll).toLowerCase();
|
||||||
coll = filter.clean(coll);
|
coll = filter.clean(coll);
|
||||||
Functions.getSessionAdminUser(Functions.getSession(socket), coll, function(userpass, adminpass) {
|
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) {
|
function del(params, socket, socketid) {
|
||||||
if(params.id){
|
if(params.id){
|
||||||
var coll = Functions.removeEmojis(params.channel).toLowerCase();
|
var coll = Functions.removeEmojis(params.channel).toLowerCase();
|
||||||
coll = coll.replace(/_/g, "").replace(/ /g,'');
|
//coll = coll.replace(/_/g, "").replace(/ /g,'');
|
||||||
|
|
||||||
coll = filter.clean(coll);
|
coll = filter.clean(coll);
|
||||||
db.collection(coll + "_settings").find(function(err, docs){
|
db.collection(coll + "_settings").find(function(err, docs){
|
||||||
@@ -713,7 +716,7 @@ function delete_all(msg, coll, guid, offline, socket) {
|
|||||||
if(coll == undefined) {
|
if(coll == undefined) {
|
||||||
coll = msg.channel;
|
coll = msg.channel;
|
||||||
}
|
}
|
||||||
coll = coll.replace(/ /g,'');
|
//coll = coll.replace(/ /g,'');
|
||||||
coll = Functions.removeEmojis(coll).toLowerCase();
|
coll = Functions.removeEmojis(coll).toLowerCase();
|
||||||
coll = filter.clean(coll);
|
coll = filter.clean(coll);
|
||||||
Functions.getSessionAdminUser(Functions.getSession(socket), coll, function(userpass, adminpass, gotten) {
|
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) {
|
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){
|
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))
|
if(docs !== null && docs.length > 0 && !Functions.contains(docs[0].guids, guid))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,12 @@
|
|||||||
var Functions = require(pathThumbnails + '/handlers/functions.js');
|
var Functions = require(pathThumbnails + '/handlers/functions.js');
|
||||||
var crypto = require('crypto');
|
var crypto = require('crypto');
|
||||||
var Filter = require('bad-words');
|
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');
|
var db = require(pathThumbnails + '/handlers/db.js');
|
||||||
|
|
||||||
function password(inp, coll, guid, offline, socket) {
|
function password(inp, coll, guid, offline, socket) {
|
||||||
@@ -29,13 +34,13 @@ function password(inp, coll, guid, offline, socket) {
|
|||||||
coll = inp.channel;
|
coll = inp.channel;
|
||||||
if(coll.length == 0) return;
|
if(coll.length == 0) return;
|
||||||
coll = Functions.removeEmojis(coll).toLowerCase();
|
coll = Functions.removeEmojis(coll).toLowerCase();
|
||||||
coll = coll.replace(/_/g, "");
|
//coll = coll.replace(/_/g, "");
|
||||||
|
|
||||||
coll = filter.clean(coll);
|
coll = filter.clean(coll);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
coll = coll.replace(/ /g,'');
|
//coll = coll.replace(/ /g,'');
|
||||||
uncrypted = pw;
|
uncrypted = pw;
|
||||||
pw = Functions.hash_pass(Functions.decrypt_string(pw), true);
|
pw = Functions.hash_pass(Functions.decrypt_string(pw), true);
|
||||||
Functions.check_inlist(coll, guid, socket, offline);
|
Functions.check_inlist(coll, guid, socket, offline);
|
||||||
@@ -90,10 +95,10 @@ function conf_function(params, coll, guid, offline, socket) {
|
|||||||
{
|
{
|
||||||
if(coll !== undefined) {
|
if(coll !== undefined) {
|
||||||
try {
|
try {
|
||||||
coll = params.channel.replace(/ /g,'');
|
coll = params.channel;//.replace(/ /g,'');
|
||||||
if(coll.length == 0) return;
|
if(coll.length == 0) return;
|
||||||
coll = Functions.removeEmojis(coll).toLowerCase();
|
coll = Functions.removeEmojis(coll).toLowerCase();
|
||||||
coll = coll.replace(/_/g, "");
|
//coll = coll.replace(/_/g, "");
|
||||||
|
|
||||||
coll = filter.clean(coll);
|
coll = filter.clean(coll);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ var path = require('path');
|
|||||||
|
|
||||||
function requested_change(type, string, channel) {
|
function requested_change(type, string, channel) {
|
||||||
try {
|
try {
|
||||||
channel = channel.replace(/ /g,'');
|
//channel = channel.replace(/ /g,'');
|
||||||
var nodemailer = require('nodemailer');
|
var nodemailer = require('nodemailer');
|
||||||
var mailconfig = require(path.join(__dirname, '../config/mailconfig.js'));
|
var mailconfig = require(path.join(__dirname, '../config/mailconfig.js'));
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ var request = require('request');
|
|||||||
var db = require(pathThumbnails + '/handlers/db.js');
|
var db = require(pathThumbnails + '/handlers/db.js');
|
||||||
|
|
||||||
function get_correct_info(song_generated, channel, broadcast, callback) {
|
function get_correct_info(song_generated, channel, broadcast, callback) {
|
||||||
channel = channel.replace(/ /g,'');
|
//channel = channel.replace(/ /g,'');
|
||||||
request({
|
request({
|
||||||
type: "GET",
|
type: "GET",
|
||||||
url: "https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key="+key+"&id=" + song_generated.id,
|
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;
|
return;
|
||||||
}
|
}
|
||||||
if(msg.source == "soundcloud") return;
|
if(msg.source == "soundcloud") return;
|
||||||
channel = channel.replace(/ /g,'');
|
//channel = channel.replace(/ /g,'');
|
||||||
request({
|
request({
|
||||||
type: "GET",
|
type: "GET",
|
||||||
url: "https://www.googleapis.com/youtube/v3/videos?part=id&key="+key+"&id=" + msg.id,
|
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) {
|
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);
|
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({
|
request({
|
||||||
method: "GET",
|
method: "GET",
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ function thumbnail(msg, coll, guid, offline, socket) {
|
|||||||
socket.emit("update_required", result);
|
socket.emit("update_required", result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
coll = coll.replace(/ /g,'');
|
//coll = coll.replace(/ /g,'');
|
||||||
Functions.getSessionAdminUser(Functions.getSession(socket), coll, function(userpass, adminpass) {
|
Functions.getSessionAdminUser(Functions.getSession(socket), coll, function(userpass, adminpass) {
|
||||||
if(userpass != "" || msg.userpass == undefined) {
|
if(userpass != "" || msg.userpass == undefined) {
|
||||||
msg.userpass = userpass;
|
msg.userpass = userpass;
|
||||||
@@ -84,7 +84,7 @@ function description(msg, coll, guid, offline, socket) {
|
|||||||
socket.emit("update_required", result);
|
socket.emit("update_required", result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
coll = coll.replace(/ /g,'');
|
//coll = coll.replace(/ /g,'');
|
||||||
Functions.getSessionAdminUser(Functions.getSession(socket), coll, function(userpass, adminpass, gotten) {
|
Functions.getSessionAdminUser(Functions.getSession(socket), coll, function(userpass, adminpass, gotten) {
|
||||||
if(userpass != "" || msg.userpass == undefined) {
|
if(userpass != "" || msg.userpass == undefined) {
|
||||||
msg.userpass = userpass;
|
msg.userpass = userpass;
|
||||||
|
|||||||
@@ -28,13 +28,20 @@ $(document).on("click", "#refresh_all", function(e){
|
|||||||
socket.emit("get_spread");
|
socket.emit("get_spread");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function decodeChannelName(str) {
|
||||||
|
var _fn = decodeURIComponent;
|
||||||
|
str = str.toUpperCase();
|
||||||
|
var toReturn = _fn(str.replace(/%5F/g, "_"));
|
||||||
|
return toReturn.toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
socket.on("spread_listeners", function(obj){
|
socket.on("spread_listeners", function(obj){
|
||||||
$("#listeners").append("<p>Private listeners: " + obj.offline + "</p>");
|
$("#listeners").append("<p>Private listeners: " + obj.offline + "</p>");
|
||||||
$("#listeners").append("<p>Total listeners: " + obj.total + "</p>");
|
$("#listeners").append("<p>Total listeners: " + obj.total + "</p>");
|
||||||
$("#listeners").append("<hr>");
|
$("#listeners").append("<hr>");
|
||||||
for(var x in obj.online_users){
|
for(var x in obj.online_users){
|
||||||
if(obj.online_users[x]._id != "total_users" && obj.online_users[x].hasOwnProperty("users") && obj.online_users[x].users.length > 0){
|
if(obj.online_users[x]._id != "total_users" && obj.online_users[x].hasOwnProperty("users") && obj.online_users[x].users.length > 0){
|
||||||
$("#listeners").append("<p>" + obj.online_users[x]._id + ": " + obj.online_users[x].users.length + "</p>");
|
$("#listeners").append("<p>" + decodeChannelName(obj.online_users[x]._id) + ": " + obj.online_users[x].users.length + "</p>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -144,9 +151,9 @@ function loaded() {
|
|||||||
var output_delete = '<option value="" disabled selected>Channels</option>';
|
var output_delete = '<option value="" disabled selected>Channels</option>';
|
||||||
for(var x = 0; x < response.length; x++){
|
for(var x = 0; x < response.length; x++){
|
||||||
if(response[x].count > 2){
|
if(response[x].count > 2){
|
||||||
output_pinned += "<option class='" + response[x]._id + "' value='" + response[x]._id + "'>" + response[x]._id + "</option>";
|
output_pinned += "<option class='" + response[x]._id + "' value='" + response[x]._id + "'>" + decodeChannelName(response[x]._id) + "</option>";
|
||||||
}
|
}
|
||||||
output_delete += "<option class='" + response[x]._id + "' value='" + response[x]._id + "'>" + response[x]._id + "</option>";
|
output_delete += "<option class='" + response[x]._id + "' value='" + response[x]._id + "'>" + decodeChannelName(response[x]._id) + "</option>";
|
||||||
}
|
}
|
||||||
|
|
||||||
$("#frontpage_pinned").html(output_pinned);
|
$("#frontpage_pinned").html(output_pinned);
|
||||||
@@ -232,9 +239,9 @@ $(document).on("click", ".thumbnail_link", function(e) {
|
|||||||
function add_to_tab(dest, resp){
|
function add_to_tab(dest, resp){
|
||||||
for(var x = 0; x < resp.length; x++){
|
for(var x = 0; x < resp.length; x++){
|
||||||
if(dest == "thumbnails"){
|
if(dest == "thumbnails"){
|
||||||
$("#" + dest + "_cont").append("<div><div class='col s4 m3'>" + resp[x].channel + "</div><input type='text' readonly class='col s4 m6 thumbnail_link' value='" + resp[x].thumbnail + "'><a class='btn green waves-effect col s2 m1 approve_" + dest + "' href='#' data-channel='" + resp[x].channel + "'><i class='material-icons'>check</i></a><a class='btn red waves-effect col s2 m1 deny_" + dest + "' href='#' data-channel='" + resp[x].channel + "'>X</a></div>");
|
$("#" + dest + "_cont").append("<div><div class='col s4 m3'>" + decodeChannelName(resp[x].channel) + "</div><input type='text' readonly class='col s4 m6 thumbnail_link' value='" + resp[x].thumbnail + "'><a class='btn green waves-effect col s2 m1 approve_" + dest + "' href='#' data-channel='" + resp[x].channel + "'><i class='material-icons'>check</i></a><a class='btn red waves-effect col s2 m1 deny_" + dest + "' href='#' data-channel='" + resp[x].channel + "'>X</a></div>");
|
||||||
} else {
|
} else {
|
||||||
$("#" + dest + "_cont").append("<div><div class='col s4 m3'>" + resp[x].channel + "</div><input type='text' readonly class='col s4 m6' value='" + resp[x].description + "'><a class='btn green waves-effect col s2 m1 approve_" + dest + "' href='#' data-channel='" + resp[x].channel + "'><i class='material-icons'>check</i></a><a class='btn red waves-effect col s2 m1 deny_" + dest + "' href='#' data-channel='" + resp[x].channel + "'>X</a></div>");
|
$("#" + dest + "_cont").append("<div><div class='col s4 m3'>" + decodeChannelName(resp[x].channel) + "</div><input type='text' readonly class='col s4 m6' value='" + resp[x].description + "'><a class='btn green waves-effect col s2 m1 approve_" + dest + "' href='#' data-channel='" + resp[x].channel + "'><i class='material-icons'>check</i></a><a class='btn red waves-effect col s2 m1 deny_" + dest + "' href='#' data-channel='" + resp[x].channel + "'>X</a></div>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -433,7 +440,7 @@ $(document).on("submit", "#delete_channel", function(e){
|
|||||||
Materialize.toast("Something went wrong...", 2000, "red lighten");
|
Materialize.toast("Something went wrong...", 2000, "red lighten");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var r = confirm("Delete list " + to_delete + "?");
|
var r = confirm("Delete list \""+ decodeChannelName(to_delete) + "\"?");
|
||||||
if (r == true) {
|
if (r == true) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
@@ -443,26 +450,7 @@ $(document).on("submit", "#delete_channel", function(e){
|
|||||||
},
|
},
|
||||||
success: function(response){
|
success: function(response){
|
||||||
if(response == true){
|
if(response == true){
|
||||||
$.ajax({
|
loaded();
|
||||||
type: "GET",
|
|
||||||
url: "/api/lists",
|
|
||||||
success: function(response){
|
|
||||||
var output_pinned = "";
|
|
||||||
var output_delete = "";
|
|
||||||
for(var x = 0; x < response.length; x++){
|
|
||||||
if(response[x].count > 5){
|
|
||||||
output_pinned += "<option class='" + response[x]._id + "' value='" + response[x]._id + "'>" + response[x]._id + "</option>";
|
|
||||||
}
|
|
||||||
output_delete += "<option class='" + response[x]._id + "' value='" + response[x]._id + "'>" + response[x]._id + "</option>";
|
|
||||||
}
|
|
||||||
|
|
||||||
$("#frontpage_pinned").html(output_pinned);
|
|
||||||
$("#delete_list_name").html(output_delete);
|
|
||||||
$("#delete_userpass_name").html(output_delete);
|
|
||||||
$("#delete_channel_name").html(output_delete);
|
|
||||||
$("select").material_select();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
Materialize.toast("Deleted channel!", 2000, "green lighten");
|
Materialize.toast("Deleted channel!", 2000, "green lighten");
|
||||||
} else {
|
} else {
|
||||||
Materialize.toast("Something went wrong...", 2000, "red lighten");
|
Materialize.toast("Something went wrong...", 2000, "red lighten");
|
||||||
|
|||||||
@@ -27,7 +27,9 @@ var Channel = {
|
|||||||
number_suggested = 0;
|
number_suggested = 0;
|
||||||
var no_socket = true;
|
var no_socket = true;
|
||||||
|
|
||||||
chan = Helper.html("#chan");
|
chan = Helper.decodeChannelName(Helper.html("#chan"));
|
||||||
|
console.log(chan);
|
||||||
|
console.log(Helper.decodeChannelName(chan));
|
||||||
mobile_beginning = Helper.mobilecheck();
|
mobile_beginning = Helper.mobilecheck();
|
||||||
var side = Helper.mobilecheck() ? "left" : "right";
|
var side = Helper.mobilecheck() ? "left" : "right";
|
||||||
|
|
||||||
@@ -185,9 +187,9 @@ var Channel = {
|
|||||||
|
|
||||||
|
|
||||||
if(!client) {
|
if(!client) {
|
||||||
var shareCodeUrl = window.location.protocol + "//client."+window.location.hostname+"/"+chan.toLowerCase();
|
var shareCodeUrl = window.location.protocol + "//client."+window.location.hostname+"/"+encodeURIComponent(chan.toLowerCase());
|
||||||
document.getElementById("share-join-qr").setAttribute("src", "https://chart.googleapis.com/chart?chs=221x221&cht=qr&choe=UTF-8&chld=L|1&chl="+shareCodeUrl);
|
document.getElementById("share-join-qr").setAttribute("src", "https://chart.googleapis.com/chart?chs=221x221&cht=qr&choe=UTF-8&chld=L|1&chl="+shareCodeUrl);
|
||||||
Helper.setHtml("#channel-name-join", "client." + window.location.hostname + "/" + chan.toLowerCase());
|
Helper.setHtml("#channel-name-join", "client." + window.location.hostname + "/" + encodeURIComponent(chan.toLowerCase()));
|
||||||
} else {
|
} else {
|
||||||
Helper.removeElement(".video-container");
|
Helper.removeElement(".video-container");
|
||||||
Helper.removeElement(".offline-panel");
|
Helper.removeElement(".offline-panel");
|
||||||
|
|||||||
@@ -72,7 +72,8 @@ var Frontpage = {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
for(var x in lists) {
|
for(var x in lists) {
|
||||||
var chan = lists[x]._id;
|
//console.log(lists[x]._id);
|
||||||
|
var chan = Helper.decodeChannelName(lists[x]._id);
|
||||||
if(num<12 || !popular) {
|
if(num<12 || !popular) {
|
||||||
var id = lists[x].id;
|
var id = lists[x].id;
|
||||||
var viewers = lists[x].viewers;
|
var viewers = lists[x].viewers;
|
||||||
@@ -126,7 +127,7 @@ var Frontpage = {
|
|||||||
options_list = options_list.sort(Frontpage.sortFunction_active);
|
options_list = options_list.sort(Frontpage.sortFunction_active);
|
||||||
var data = {};
|
var data = {};
|
||||||
for(var x in options_list) {
|
for(var x in options_list) {
|
||||||
data[options_list[x]._id] = null;
|
data[Helper.decodeChannelName(options_list[x]._id)] = null;
|
||||||
}
|
}
|
||||||
if(document.querySelectorAll(".pin").length == 1 && !Helper.mobilecheck()) {
|
if(document.querySelectorAll(".pin").length == 1 && !Helper.mobilecheck()) {
|
||||||
Helper.tooltip(document.querySelectorAll(".pin")[0].parentElement.parentElement.parentElement, {
|
Helper.tooltip(document.querySelectorAll(".pin")[0].parentElement.parentElement.parentElement, {
|
||||||
@@ -206,7 +207,7 @@ var Frontpage = {
|
|||||||
Helper.css("#mega-background","background-size" , "cover");
|
Helper.css("#mega-background","background-size" , "cover");
|
||||||
Helper.css("#mega-background","background-repeat" , "no-repeat");
|
Helper.css("#mega-background","background-repeat" , "no-repeat");
|
||||||
Helper.css("#mega-background","opacity", 1);
|
Helper.css("#mega-background","opacity", 1);
|
||||||
document.querySelector(".autocomplete").setAttribute("placeholder", list[i]._id);
|
document.querySelector(".autocomplete").setAttribute("placeholder", Helper.decodeChannelName(list[i]._id));
|
||||||
//$(".room-namer").css("opacity", 1);
|
//$(".room-namer").css("opacity", 1);
|
||||||
}
|
}
|
||||||
},500);
|
},500);
|
||||||
@@ -231,12 +232,12 @@ var Frontpage = {
|
|||||||
Helper.css("#mega-background", "background-size" , "cover");
|
Helper.css("#mega-background", "background-size" , "cover");
|
||||||
Helper.css("#mega-background", "background-repeat" , "no-repeat");
|
Helper.css("#mega-background", "background-repeat" , "no-repeat");
|
||||||
Helper.css("#mega-background", "opacity", 1);
|
Helper.css("#mega-background", "opacity", 1);
|
||||||
document.querySelector(".autocomplete").setAttribute("placeholder", list[i]._id);
|
document.querySelector(".autocomplete").setAttribute("placeholder", Helper.decodeChannelName(list[i]._id));
|
||||||
} catch(e) {}
|
} catch(e) {}
|
||||||
},500);
|
},500);
|
||||||
},
|
},
|
||||||
error: function() {
|
error: function() {
|
||||||
document.querySelector(".autocomplete").setAttribute("placeholder", list[i]._id);
|
document.querySelector(".autocomplete").setAttribute("placeholder", Helper.decodeChannelName(list[i]._id));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -246,7 +247,7 @@ var Frontpage = {
|
|||||||
Helper.css("#mega-background", "background-size" , "cover");
|
Helper.css("#mega-background", "background-size" , "cover");
|
||||||
Helper.css("#mega-background", "background-repeat" , "no-repeat");
|
Helper.css("#mega-background", "background-repeat" , "no-repeat");
|
||||||
Helper.css("#mega-background", "opacity", 1);
|
Helper.css("#mega-background", "opacity", 1);
|
||||||
document.querySelector(".autocomplete").setAttribute("placeholder", list[i]._id);
|
document.querySelector(".autocomplete").setAttribute("placeholder", Helper.decodeChannelName(list[i]._id));
|
||||||
} catch(e) {}
|
} catch(e) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -195,7 +195,7 @@ function get_list_ajax() {
|
|||||||
token: zoff_api_token,
|
token: zoff_api_token,
|
||||||
},
|
},
|
||||||
headers: {"Content-Type": "application/json;charset=UTF-8"},
|
headers: {"Content-Type": "application/json;charset=UTF-8"},
|
||||||
url: "/api/list/" + chan.toLowerCase(),
|
url: "/api/list/" + Helper.encodeChannelName(chan.toLowerCase()),
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
response = JSON.parse(response);
|
response = JSON.parse(response);
|
||||||
if(response.results.length > 0) {
|
if(response.results.length > 0) {
|
||||||
@@ -283,7 +283,7 @@ function get_np_ajax() {
|
|||||||
token: zoff_api_token
|
token: zoff_api_token
|
||||||
},
|
},
|
||||||
headers: {"Content-Type": "application/json;charset=UTF-8"},
|
headers: {"Content-Type": "application/json;charset=UTF-8"},
|
||||||
url: "/api/list/" + chan.toLowerCase() + "/__np__",
|
url: "/api/list/" + Helper.encodeChannelName(chan.toLowerCase()) + "/__np__",
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
response = JSON.parse(response);
|
response = JSON.parse(response);
|
||||||
Player.getTitle(response.results[0].title, 1);
|
Player.getTitle(response.results[0].title, 1);
|
||||||
@@ -314,7 +314,7 @@ function del_ajax(id) {
|
|||||||
token: zoff_api_token
|
token: zoff_api_token
|
||||||
},
|
},
|
||||||
headers: {"Content-Type": "application/json;charset=UTF-8"},
|
headers: {"Content-Type": "application/json;charset=UTF-8"},
|
||||||
url: "/api/list/" + chan.toLowerCase() + "/" + id,
|
url: "/api/list/" + Helper.encodeChannelName(chan.toLowerCase()) + "/" + id,
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
toast("deletesong");
|
toast("deletesong");
|
||||||
get_list_ajax();
|
get_list_ajax();
|
||||||
@@ -351,7 +351,7 @@ function add_ajax(id, title, duration, playlist, num, full_num, start, end, sour
|
|||||||
token: zoff_api_token
|
token: zoff_api_token
|
||||||
},
|
},
|
||||||
headers: {"Content-Type": "application/json;charset=UTF-8"},
|
headers: {"Content-Type": "application/json;charset=UTF-8"},
|
||||||
url: "/api/list/" + chan.toLowerCase() + "/" + id,
|
url: "/api/list/" + Helper.encodeChannelName(chan.toLowerCase()) + "/" + id,
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
toast("addedsong");
|
toast("addedsong");
|
||||||
get_list_ajax();
|
get_list_ajax();
|
||||||
@@ -384,7 +384,7 @@ function vote_ajax(id) {
|
|||||||
token: zoff_api_token
|
token: zoff_api_token
|
||||||
},
|
},
|
||||||
headers: {"Content-Type": "application/json;charset=UTF-8"},
|
headers: {"Content-Type": "application/json;charset=UTF-8"},
|
||||||
url: "/api/list/" + chan.toLowerCase() + "/" + id,
|
url: "/api/list/" + Helper.encodeChannelName(chan.toLowerCase()) + "/" + id,
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
toast("voted");
|
toast("voted");
|
||||||
get_list_ajax();
|
get_list_ajax();
|
||||||
|
|||||||
@@ -1,5 +1,23 @@
|
|||||||
var Helper = {
|
var Helper = {
|
||||||
logs: [],
|
logs: [],
|
||||||
|
|
||||||
|
decodeChannelName: function(str) {
|
||||||
|
var _fn = decodeURIComponent;
|
||||||
|
str = str.toUpperCase();
|
||||||
|
var toReturn = _fn(str.replace(/%5F/g, "_"));
|
||||||
|
toReturn = toReturn.toLowerCase().replace(/&/g, "&");
|
||||||
|
return toReturn.toLowerCase();
|
||||||
|
},
|
||||||
|
|
||||||
|
encodeChannelName: function(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;
|
||||||
|
},
|
||||||
|
|
||||||
log: function(to_log) {
|
log: function(to_log) {
|
||||||
if(localStorage.debug === "true") {
|
if(localStorage.debug === "true") {
|
||||||
console.log("------------ " + new Date() + " ------------");/*RemoveLogging:skip*/
|
console.log("------------ " + new Date() + " ------------");/*RemoveLogging:skip*/
|
||||||
@@ -315,12 +333,12 @@ var Helper = {
|
|||||||
var xmlhttp = new XMLHttpRequest();
|
var xmlhttp = new XMLHttpRequest();
|
||||||
xmlhttp.onreadystatechange = function() {
|
xmlhttp.onreadystatechange = function() {
|
||||||
if (xmlhttp.readyState == XMLHttpRequest.DONE) { // XMLHttpRequest.DONE == 4
|
if (xmlhttp.readyState == XMLHttpRequest.DONE) { // XMLHttpRequest.DONE == 4
|
||||||
if (xmlhttp.status == 200 || xmlhttp.status == 201 || xmlhttp.status == 202) {
|
if (xmlhttp.status == 200 || xmlhttp.status == 201 || xmlhttp.status == 202) {
|
||||||
obj.success(xmlhttp.responseText, xmlhttp);
|
obj.success(xmlhttp.responseText, xmlhttp);
|
||||||
}
|
}
|
||||||
else if(obj.hasOwnProperty("error")){
|
else if(obj.hasOwnProperty("error")){
|
||||||
obj.error(xmlhttp);
|
obj.error(xmlhttp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ var Player = {
|
|||||||
if(obj.np != undefined && !offline) {
|
if(obj.np != undefined && !offline) {
|
||||||
seekTo = (time - conf.startTime) + Player.np.start;
|
seekTo = (time - conf.startTime) + Player.np.start;
|
||||||
Player.getTitle(song_title, viewers);
|
Player.getTitle(song_title, viewers);
|
||||||
|
Player.setThumbnail(conf, Player.np.id);
|
||||||
if(((embed && autoplay) || !embed) && (!was_stopped || buffering) && !client) {
|
if(((embed && autoplay) || !embed) && (!was_stopped || buffering) && !client) {
|
||||||
Helper.log(["loadVideoById \nwas_stopped="+was_stopped+"\noffline="+offline])
|
Helper.log(["loadVideoById \nwas_stopped="+was_stopped+"\noffline="+offline])
|
||||||
Player.loadVideoById(Player.np.id, duration, Player.np.start, Player.np.end);
|
Player.loadVideoById(Player.np.id, duration, Player.np.start, Player.np.end);
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
autocomplete="off"
|
autocomplete="off"
|
||||||
autofocus
|
autofocus
|
||||||
required
|
required
|
||||||
pattern="[a-zA-Z0-9]+"
|
|
||||||
spellcheck="false"
|
spellcheck="false"
|
||||||
maxlength="18"
|
maxlength="18"
|
||||||
data-length="18"
|
data-length="18"
|
||||||
|
|||||||
@@ -6,6 +6,10 @@ var ObjectId = mongojs.ObjectId;
|
|||||||
var token_db = mongojs("tokens");
|
var token_db = mongojs("tokens");
|
||||||
var cookieParser = require("cookie-parser");
|
var cookieParser = require("cookie-parser");
|
||||||
var db = require(pathThumbnails + '/handlers/db.js');
|
var db = require(pathThumbnails + '/handlers/db.js');
|
||||||
|
var List = require(pathThumbnails + '/handlers/list.js');
|
||||||
|
var Functions = require(pathThumbnails + '/handlers/functions.js');
|
||||||
|
var Frontpage = require(pathThumbnails + '/handlers/frontpage.js');
|
||||||
|
var Search = require(pathThumbnails + '/handlers/search.js');
|
||||||
|
|
||||||
var toShowChannel = {
|
var toShowChannel = {
|
||||||
start: 1,
|
start: 1,
|
||||||
@@ -533,7 +537,7 @@ router.route('/api/list/:channel_name/__np__').post(function(req, res) {
|
|||||||
|
|
||||||
var ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
|
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 guid = Functions.hash_pass(req.get('User-Agent') + ip + req.headers["accept-language"]);
|
||||||
var channel_name = req.params.channel_name;
|
var channel_name = cleanChannelName(req.params.channel_name);
|
||||||
req.body.userpass = req.body.userpass == "" ? "" : crypto.createHash('sha256').update(req.body.userpass, 'utf8').digest("base64");
|
req.body.userpass = req.body.userpass == "" ? "" : crypto.createHash('sha256').update(req.body.userpass, 'utf8').digest("base64");
|
||||||
var userpass = req.body.userpass;
|
var userpass = req.body.userpass;
|
||||||
var token = "";
|
var token = "";
|
||||||
@@ -831,7 +835,7 @@ router.route('/api/list/:channel_name').get(function(req, res) {
|
|||||||
} ]
|
} ]
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
var channel_name = req.params.channel_name;
|
var channel_name = cleanChannelName(req.params.channel_name);
|
||||||
db.collection(channel_name).aggregate([
|
db.collection(channel_name).aggregate([
|
||||||
{
|
{
|
||||||
"$match": { }
|
"$match": { }
|
||||||
@@ -866,7 +870,7 @@ router.route('/api/list/:channel_name/:video_id').get(function(req, res) {
|
|||||||
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
|
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
|
||||||
res.header({"Content-Type": "application/json"});
|
res.header({"Content-Type": "application/json"});
|
||||||
|
|
||||||
var channel_name = req.params.channel_name;
|
var channel_name = cleanChannelName(req.params.channel_name);
|
||||||
var video_id = req.params.video_id;
|
var video_id = req.params.video_id;
|
||||||
var searchQuery = {id: video_id};
|
var searchQuery = {id: video_id};
|
||||||
if(video_id == "__np__") {
|
if(video_id == "__np__") {
|
||||||
@@ -904,7 +908,7 @@ router.route('/api/conf/:channel_name').get(function(req, res) {
|
|||||||
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
|
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
|
||||||
res.header({"Content-Type": "application/json"});
|
res.header({"Content-Type": "application/json"});
|
||||||
|
|
||||||
var channel_name = req.params.channel_name;
|
var channel_name = cleanChannelName(req.params.channel_name);
|
||||||
db.collection(channel_name + "_settings").find({ id: "config" }, toShowConfig, function(err, docs) {
|
db.collection(channel_name + "_settings").find({ id: "config" }, toShowConfig, function(err, docs) {
|
||||||
if(docs.length > 0 && docs[0].userpass == "" || docs[0].userpass == undefined) {
|
if(docs.length > 0 && docs[0].userpass == "" || docs[0].userpass == undefined) {
|
||||||
var conf = docs[0];
|
var conf = docs[0];
|
||||||
@@ -946,7 +950,7 @@ router.route('/api/conf/:channel_name').post(function(req, res) {
|
|||||||
}
|
}
|
||||||
var ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
|
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 guid = Functions.hash_pass(req.get('User-Agent') + ip + req.headers["accept-language"]);
|
||||||
var channel_name = req.params.channel_name;
|
var channel_name = cleanChannelName(req.params.channel_name);
|
||||||
req.body.userpass = req.body.userpass == "" ? "" : crypto.createHash('sha256').update(req.body.userpass, 'utf8').digest("base64");
|
req.body.userpass = req.body.userpass == "" ? "" : crypto.createHash('sha256').update(req.body.userpass, 'utf8').digest("base64");
|
||||||
var userpass = req.body.userpass;
|
var userpass = req.body.userpass;
|
||||||
|
|
||||||
@@ -1068,7 +1072,7 @@ router.route('/api/list/:channel_name').post(function(req, res) {
|
|||||||
}
|
}
|
||||||
var ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
|
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 guid = Functions.hash_pass(req.get('User-Agent') + ip + req.headers["accept-language"]);
|
||||||
var channel_name = req.params.channel_name;
|
var channel_name = cleanChannelName(req.params.channel_name);
|
||||||
req.body.userpass = req.body.userpass == "" ? "" : crypto.createHash('sha256').update(req.body.userpass, 'utf8').digest("base64");
|
req.body.userpass = req.body.userpass == "" ? "" : crypto.createHash('sha256').update(req.body.userpass, 'utf8').digest("base64");
|
||||||
var userpass = req.body.userpass;
|
var userpass = req.body.userpass;
|
||||||
|
|
||||||
@@ -1384,10 +1388,11 @@ function checkTimeout(guid, res, authorized, type, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function cleanChannelName(channel_name) {
|
function cleanChannelName(channel_name) {
|
||||||
var coll = emojiStrip(channel_name).toLowerCase();
|
var coll = Functions.removeEmojis(channel_name).toLowerCase();
|
||||||
coll = coll.replace("_", "");
|
//coll = coll.replace("_", "");
|
||||||
coll = encodeURIComponent(coll).replace(/\W/g, '');
|
//coll = encodeURIComponent(coll).replace(/\W/g, '');
|
||||||
coll = filter.clean(coll);
|
coll = Functions.encodeChannelName(channel_name);
|
||||||
|
//coll = filter.clean(coll);
|
||||||
return coll;
|
return coll;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ var path = require('path');
|
|||||||
var analytics = "xx";
|
var analytics = "xx";
|
||||||
var mongojs = require('mongojs');
|
var mongojs = require('mongojs');
|
||||||
var token_db = mongojs("tokens");
|
var token_db = mongojs("tokens");
|
||||||
|
var Functions = require(pathThumbnails + '/handlers/functions.js');
|
||||||
try {
|
try {
|
||||||
analytics = require(path.join(path.join(__dirname, '../../config/'), 'analytics.js'));
|
analytics = require(path.join(path.join(__dirname, '../../config/'), 'analytics.js'));
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
@@ -177,9 +178,10 @@ function channel(req, res, next) {
|
|||||||
} else if(req.params.channel_name == "o_callback") {
|
} else if(req.params.channel_name == "o_callback") {
|
||||||
res.sendFile(path.join(pathThumbnails, '/public/assets/html/callback.html'));
|
res.sendFile(path.join(pathThumbnails, '/public/assets/html/callback.html'));
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
var data = {
|
var data = {
|
||||||
title: "404: File Not Found",
|
title: "404: File Not Found",
|
||||||
list_name: capitalizeFirstLetter(req.params.channel_name),
|
list_name: capitalizeFirstLetter(Functions.decodeChannelName(req.params.channel_name)),
|
||||||
year: year,
|
year: year,
|
||||||
javascript_file: "main.min.js",
|
javascript_file: "main.min.js",
|
||||||
captcha: res.recaptcha,
|
captcha: res.recaptcha,
|
||||||
@@ -194,7 +196,6 @@ function channel(req, res, next) {
|
|||||||
if(req.params.channel_name == "404") {
|
if(req.params.channel_name == "404") {
|
||||||
res.status(404);
|
res.status(404);
|
||||||
}
|
}
|
||||||
|
|
||||||
res.render('layouts/client/channel', data);
|
res.render('layouts/client/channel', data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user