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;

View File

@@ -28,13 +28,20 @@ $(document).on("click", "#refresh_all", function(e){
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){
$("#listeners").append("<p>Private listeners: " + obj.offline + "</p>");
$("#listeners").append("<p>Total listeners: " + obj.total + "</p>");
$("#listeners").append("<hr>");
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){
$("#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>';
for(var x = 0; x < response.length; x++){
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);
@@ -232,9 +239,9 @@ $(document).on("click", ".thumbnail_link", function(e) {
function add_to_tab(dest, resp){
for(var x = 0; x < resp.length; x++){
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 {
$("#" + 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");
return;
}
var r = confirm("Delete list " + to_delete + "?");
var r = confirm("Delete list \""+ decodeChannelName(to_delete) + "\"?");
if (r == true) {
$.ajax({
type: "POST",
@@ -443,26 +450,7 @@ $(document).on("submit", "#delete_channel", function(e){
},
success: function(response){
if(response == true){
$.ajax({
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();
}
});
loaded();
Materialize.toast("Deleted channel!", 2000, "green lighten");
} else {
Materialize.toast("Something went wrong...", 2000, "red lighten");

View File

@@ -27,7 +27,9 @@ var Channel = {
number_suggested = 0;
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();
var side = Helper.mobilecheck() ? "left" : "right";
@@ -185,9 +187,9 @@ var Channel = {
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);
Helper.setHtml("#channel-name-join", "client." + window.location.hostname + "/" + chan.toLowerCase());
Helper.setHtml("#channel-name-join", "client." + window.location.hostname + "/" + encodeURIComponent(chan.toLowerCase()));
} else {
Helper.removeElement(".video-container");
Helper.removeElement(".offline-panel");

View File

@@ -72,7 +72,8 @@ var Frontpage = {
]);
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) {
var id = lists[x].id;
var viewers = lists[x].viewers;
@@ -126,7 +127,7 @@ var Frontpage = {
options_list = options_list.sort(Frontpage.sortFunction_active);
var data = {};
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()) {
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-repeat" , "no-repeat");
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);
}
},500);
@@ -231,12 +232,12 @@ var Frontpage = {
Helper.css("#mega-background", "background-size" , "cover");
Helper.css("#mega-background", "background-repeat" , "no-repeat");
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) {}
},500);
},
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-repeat" , "no-repeat");
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) {}
};

View File

@@ -195,7 +195,7 @@ function get_list_ajax() {
token: zoff_api_token,
},
headers: {"Content-Type": "application/json;charset=UTF-8"},
url: "/api/list/" + chan.toLowerCase(),
url: "/api/list/" + Helper.encodeChannelName(chan.toLowerCase()),
success: function(response) {
response = JSON.parse(response);
if(response.results.length > 0) {
@@ -283,7 +283,7 @@ function get_np_ajax() {
token: zoff_api_token
},
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) {
response = JSON.parse(response);
Player.getTitle(response.results[0].title, 1);
@@ -314,7 +314,7 @@ function del_ajax(id) {
token: zoff_api_token
},
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) {
toast("deletesong");
get_list_ajax();
@@ -351,7 +351,7 @@ function add_ajax(id, title, duration, playlist, num, full_num, start, end, sour
token: zoff_api_token
},
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) {
toast("addedsong");
get_list_ajax();
@@ -384,7 +384,7 @@ function vote_ajax(id) {
token: zoff_api_token
},
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) {
toast("voted");
get_list_ajax();

View File

@@ -1,5 +1,23 @@
var Helper = {
logs: [],
decodeChannelName: function(str) {
var _fn = decodeURIComponent;
str = str.toUpperCase();
var toReturn = _fn(str.replace(/%5F/g, "_"));
toReturn = toReturn.toLowerCase().replace(/&amp;/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) {
if(localStorage.debug === "true") {
console.log("------------ " + new Date() + " ------------");/*RemoveLogging:skip*/

View File

@@ -76,6 +76,7 @@ var Player = {
if(obj.np != undefined && !offline) {
seekTo = (time - conf.startTime) + Player.np.start;
Player.getTitle(song_title, viewers);
Player.setThumbnail(conf, Player.np.id);
if(((embed && autoplay) || !embed) && (!was_stopped || buffering) && !client) {
Helper.log(["loadVideoById \nwas_stopped="+was_stopped+"\noffline="+offline])
Player.loadVideoById(Player.np.id, duration, Player.np.start, Player.np.end);

View File

@@ -13,7 +13,7 @@
autocomplete="off"
autofocus
required
pattern="[a-zA-Z0-9]+"
spellcheck="false"
maxlength="18"
data-length="18"

View File

@@ -6,6 +6,10 @@ var ObjectId = mongojs.ObjectId;
var token_db = mongojs("tokens");
var cookieParser = require("cookie-parser");
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 = {
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 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");
var userpass = req.body.userpass;
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([
{
"$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({"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 searchQuery = {id: video_id};
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({"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) {
if(docs.length > 0 && docs[0].userpass == "" || docs[0].userpass == undefined) {
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 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");
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 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");
var userpass = req.body.userpass;
@@ -1384,10 +1388,11 @@ function checkTimeout(guid, res, authorized, type, callback) {
}
function cleanChannelName(channel_name) {
var coll = emojiStrip(channel_name).toLowerCase();
coll = coll.replace("_", "");
coll = encodeURIComponent(coll).replace(/\W/g, '');
coll = filter.clean(coll);
var coll = Functions.removeEmojis(channel_name).toLowerCase();
//coll = coll.replace("_", "");
//coll = encodeURIComponent(coll).replace(/\W/g, '');
coll = Functions.encodeChannelName(channel_name);
//coll = filter.clean(coll);
return coll;
}

View File

@@ -6,6 +6,7 @@ var path = require('path');
var analytics = "xx";
var mongojs = require('mongojs');
var token_db = mongojs("tokens");
var Functions = require(pathThumbnails + '/handlers/functions.js');
try {
analytics = require(path.join(path.join(__dirname, '../../config/'), 'analytics.js'));
} catch(e) {
@@ -177,9 +178,10 @@ function channel(req, res, next) {
} else if(req.params.channel_name == "o_callback") {
res.sendFile(path.join(pathThumbnails, '/public/assets/html/callback.html'));
} else {
var data = {
title: "404: File Not Found",
list_name: capitalizeFirstLetter(req.params.channel_name),
list_name: capitalizeFirstLetter(Functions.decodeChannelName(req.params.channel_name)),
year: year,
javascript_file: "main.min.js",
captcha: res.recaptcha,
@@ -194,7 +196,6 @@ function channel(req, res, next) {
if(req.params.channel_name == "404") {
res.status(404);
}
res.render('layouts/client/channel', data);
}
}