Add even more cleanup

This commit is contained in:
Alf Hammerseth
2019-11-16 17:19:14 +01:00
parent 120553eac4
commit 54b745ec68
11 changed files with 129 additions and 287 deletions

View File

@@ -1,10 +1,9 @@
var gulp = require("gulp"), var gulp = require("gulp"),
uglify = require("gulp-uglify"), uglify = require("gulp-uglify"),
//sourcemaps = require('gulp-sourcemaps'),
concat = require("gulp-concat"), concat = require("gulp-concat"),
cleanCSS = require("gulp-clean-css"); cleanCSS = require("gulp-clean-css");
gulp.task("css", function() { gulp.task("css", function () {
return gulp return gulp
.src([ .src([
"server/public/assets/css/style.css", "server/public/assets/css/style.css",
@@ -13,113 +12,109 @@ gulp.task("css", function() {
"server/public/assets/css/mobile.css" "server/public/assets/css/mobile.css"
]) ])
.pipe(concat("style.css")) .pipe(concat("style.css"))
.pipe(cleanCSS({ compatibility: "ie8" })) .pipe(cleanCSS({
compatibility: "ie8"
}))
.pipe(gulp.dest("server/public/assets/dist")); .pipe(gulp.dest("server/public/assets/dist"));
}); });
gulp.task("css-embed", function() { gulp.task("css-embed", function () {
return gulp return gulp
.src("server/public/assets/css/embed.css") .src("server/public/assets/css/embed.css")
.pipe(cleanCSS({ compatibility: "ie8" })) .pipe(cleanCSS({
compatibility: "ie8"
}))
.pipe(gulp.dest("server/public/assets/dist")); .pipe(gulp.dest("server/public/assets/dist"));
}); });
gulp.task("js", function() { gulp.task("js", function () {
return ( return (
gulp gulp
.src([ .src([
"server/VERSION.js", "server/VERSION.js",
"server/config/api_key.js", "server/config/api_key.js",
"server/public/assets/js/*.js", "server/public/assets/js/*.js",
"!server/public/assets/js/embed*", "!server/public/assets/js/embed*",
"!server/public/assets/js/token*", "!server/public/assets/js/token*",
"!server/public/assets/js/remotecontroller.js", "!server/public/assets/js/remotecontroller.js",
"!server/public/assets/js/callback.js" "!server/public/assets/js/callback.js"
]) ])
//.pipe(sourcemaps.init()) .pipe(concat("main.min.js"))
.pipe(concat("main.min.js")) .pipe(
.pipe( uglify({
uglify({ mangle: true,
mangle: true, compress: true,
compress: true, enclose: true
enclose: true })
}) )
) .pipe(gulp.dest("server/public/assets/dist"))
//.pipe(sourcemaps.write('maps'))
.pipe(gulp.dest("server/public/assets/dist"))
); );
}); });
gulp.task("embed", function() { gulp.task("embed", function () {
return ( return (
gulp gulp
.src([ .src([
"server/VERSION.js", "server/VERSION.js",
"server/config/api_key.js", "server/config/api_key.js",
"server/public/assets/js/player.js", "server/public/assets/js/player.js",
"server/public/assets/js/functions.js", "server/public/assets/js/functions.js",
"server/public/assets/js/helpers.js", "server/public/assets/js/helpers.js",
"server/public/assets/js/playercontrols.js", "server/public/assets/js/playercontrols.js",
"server/public/assets/js/list.js", "server/public/assets/js/list.js",
"server/public/assets/js/embed.js", "server/public/assets/js/embed.js",
"!server/public/assets/js/frontpage*", "!server/public/assets/js/frontpage*",
"!server/public/assets/js/remotecontroller.js", "!server/public/assets/js/remotecontroller.js",
"server/public/assets/js/hostcontroller.js" "server/public/assets/js/hostcontroller.js"
]) ])
//.pipe(sourcemaps.init()) .pipe(concat("embed.min.js"))
.pipe(concat("embed.min.js")) .pipe(
.pipe( uglify({
uglify({ mangle: true,
mangle: true, compress: true,
compress: true, enclose: true
enclose: true })
}) )
) .pipe(gulp.dest("server/public/assets/dist"))
//.pipe(sourcemaps.write('maps'))
.pipe(gulp.dest("server/public/assets/dist"))
); );
}); });
gulp.task("token", function() { gulp.task("token", function () {
return ( return (
gulp gulp
.src([ .src([
"server/public/assets/js/token*", "server/public/assets/js/token*",
"server/public/assets/js/helpers.js" "server/public/assets/js/helpers.js"
]) ])
//.pipe(sourcemaps.init()) .pipe(concat("token.min.js"))
.pipe(concat("token.min.js")) .pipe(
.pipe( uglify({
uglify({ mangle: true,
mangle: true, compress: true,
compress: true, enclose: true
enclose: true })
}) )
) .pipe(gulp.dest("server/public/assets/dist"))
//.pipe(sourcemaps.write('maps'))
.pipe(gulp.dest("server/public/assets/dist"))
); );
}); });
gulp.task("callback", function() { gulp.task("callback", function () {
return ( return (
gulp gulp
.src([ .src([
"server/VERSION.js", "server/VERSION.js",
"server/config/api_key.js", "server/config/api_key.js",
"server/public/assets/js/callback.js" "server/public/assets/js/callback.js"
]) ])
//.pipe(sourcemaps.init()) .pipe(concat("callback.min.js"))
.pipe(concat("callback.min.js")) .pipe(
.pipe( uglify({
uglify({ mangle: true,
mangle: true, compress: true,
compress: true, enclose: true
enclose: true })
}) )
) .pipe(gulp.dest("server/public/assets/dist"))
//.pipe(sourcemaps.write('maps'))
.pipe(gulp.dest("server/public/assets/dist"))
); );
}); });
@@ -136,30 +131,28 @@ gulp.task("build", done => {
done(); done();
}); });
gulp.task("remotecontroller", function() { gulp.task("remotecontroller", function () {
return ( return (
gulp gulp
.src([ .src([
"server/VERSION.js", "server/VERSION.js",
"server/config/api_key.js", "server/config/api_key.js",
"server/public/assets/js/remotecontroller.js", "server/public/assets/js/remotecontroller.js",
"server/public/assets/js/helpers.js" "server/public/assets/js/helpers.js"
]) ])
////.pipe(sourcemaps.init()) .pipe(concat("remote.min.js"))
.pipe(concat("remote.min.js")) .pipe(
.pipe( uglify({
uglify({ mangle: true,
mangle: true, compress: true,
compress: true, enclose: true
enclose: true })
}) )
) .pipe(gulp.dest("server/public/assets/dist"))
//.pipe(sourcemaps.write('maps'))
.pipe(gulp.dest("server/public/assets/dist"))
); );
}); });
gulp.task("default", function() { gulp.task("default", function () {
gulp.watch(["server/VERSION.js", "server/public/assets/js/*.js"], ["js"]); gulp.watch(["server/VERSION.js", "server/public/assets/js/*.js"], ["js"]);
gulp.watch(["server/public/assets/css/*.css"], ["css"]); gulp.watch(["server/public/assets/css/*.css"], ["css"]);
gulp.watch(["server/public/assets/css/*.css"], ["css-embed"]); gulp.watch(["server/public/assets/css/*.css"], ["css-embed"]);
@@ -176,9 +169,8 @@ gulp.task("default", function() {
], ],
["callback"] ["callback"]
); );
//gulp.watch('server/public/assets/js/*.js', ['nochan']);
gulp.watch( gulp.watch(
["server/VERSION.js", "server/public/assets/js/remotecontroller.js"], ["server/VERSION.js", "server/public/assets/js/remotecontroller.js"],
["remotecontroller"] ["remotecontroller"]
); );
}); });

View File

@@ -14,7 +14,6 @@ function get_history(channel, all, socket) {
channel: channel channel: channel
}; };
} }
//channel = channel.replace(/ /g,'');
var pass = ""; var pass = "";
if (!query.all) { if (!query.all) {
Functions.getSessionAdminUser( Functions.getSessionAdminUser(
@@ -49,7 +48,6 @@ function get_history(channel, all, socket) {
} }
function getAndSendLogs(channel, all, socket, pass, query) { function getAndSendLogs(channel, all, socket, pass, query) {
//channel = channel.replace(/ /g,'');
db.collection("chat_logs") db.collection("chat_logs")
.find(query, { .find(query, {
from: 1, from: 1,
@@ -108,9 +106,8 @@ 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();
coll = Functions.removeEmojis(coll).toLowerCase(); coll = Functions.removeEmojis(coll).toLowerCase();
//coll = filter.clean(coll);
checkIfUserIsBanned(coll, socket, guid, function () { checkIfUserIsBanned(coll, socket, guid, function () {
Functions.getSessionAdminUser(Functions.getSession(socket), coll, function ( Functions.getSessionAdminUser(Functions.getSession(socket), coll, function (
@@ -379,10 +376,9 @@ 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();
var data = msg.data; var data = msg.data;
coll = Functions.removeEmojis(coll).toLowerCase(); coll = Functions.removeEmojis(coll).toLowerCase();
//coll = filter.clean(coll);
Functions.check_inlist( Functions.check_inlist(
coll, coll,
guid, guid,
@@ -481,8 +477,7 @@ function checkIfUserIsBanned(channel, socket, guid, callback, callback_error) {
else { else {
db.collection("user_names").findAndModify({ db.collection("user_names").findAndModify({
query: { query: {
guid, guid: guid
guid
}, },
update: { update: {
$addToSet: { $addToSet: {
@@ -685,7 +680,6 @@ function namechange(data, guid, socket, tried, callback) {
} }
}, },
function (err, docs) { function (err, docs) {
//socket.emit('name', {type: "name", accepted: true});
if (old_name != name && !first && !no_name) { if (old_name != name && !first && !no_name) {
if ( if (
data.hasOwnProperty("channel") && data.hasOwnProperty("channel") &&
@@ -741,7 +735,6 @@ function namechange(data, guid, socket, tried, callback) {
} }
function removename(guid, coll, socket) { function removename(guid, coll, socket) {
//coll = coll.replace(/ /g,'');
checkIfChatEnabled(coll, socket, function (enabled) { checkIfChatEnabled(coll, socket, function (enabled) {
if (!enabled) return; if (!enabled) return;
db.collection("user_names").find({ db.collection("user_names").find({

View File

@@ -12,10 +12,6 @@ try {
} }
var mongojs = require("mongojs"); var mongojs = require("mongojs");
var db = mongojs("mongodb://" + mongo_config.host + "/" + mongo_config.config); var db = mongojs("mongodb://" + mongo_config.host + "/" + mongo_config.config);
var connected_db = mongojs(
"mongodb://" + mongo_config.host + "/user_credentials"
);
var ObjectId = mongojs.ObjectId;
db.collection("chat_logs").createIndex({ db.collection("chat_logs").createIndex({
createdAt: 1 createdAt: 1

View File

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

View File

@@ -100,9 +100,7 @@ function remove_name_from_db(guid, channel) {
channels: channel channels: channel
} }
}, },
function (err, docs) { function (err, docs) {}
//console.log("Pulled user from current channel");
}
); );
} }
}); });
@@ -130,10 +128,6 @@ function isUrl(str) {
function getSession(socket) { function getSession(socket) {
try { try {
/*var cookieParser = require("cookie-parser");
var cookie = require("cookie");
var parsedCookies = cookie.parse(socket.handshake.headers.cookie);
return parsedCookies["_uI"];*/
if (socket.cookie_id == undefined) throw "Undefined error"; if (socket.cookie_id == undefined) throw "Undefined error";
return socket.cookie_id; return socket.cookie_id;
} catch (e) { } catch (e) {
@@ -143,7 +137,6 @@ function getSession(socket) {
socket.handshake.address + socket.handshake.address +
socket.handshake.headers["accept-language"] socket.handshake.headers["accept-language"]
); );
//return "empty";
} }
} }
@@ -186,7 +179,6 @@ function check_inlist(coll, guid, socket, offline, callback, double_check) {
if (typeof callback == "function") callback(); if (typeof callback == "function") callback();
return; return;
} }
//coll = coll.replace(/ /g,'');
if (!offline && coll != undefined) { if (!offline && coll != undefined) {
db.collection("connected_users").update({ db.collection("connected_users").update({
_id: coll _id: coll
@@ -256,10 +248,6 @@ function check_inlist(coll, guid, socket, offline, callback, double_check) {
}); });
} }
} else if (docs.length == 0) { } else if (docs.length == 0) {
//console.log("User doesn't have a name for some reason.");
//console.log("guid", guid);
//console.log("channel", coll);
//console.log("Trying to get a chat-name");
Chat.get_name(guid, { Chat.get_name(guid, {
announce: false, announce: false,
socket: socket, socket: socket,
@@ -323,7 +311,6 @@ function check_inlist(coll, guid, socket, offline, callback, double_check) {
function (err, docs) {} function (err, docs) {}
); );
} }
//
if (coll != undefined && coll != "") { if (coll != undefined && coll != "") {
db.collection("connected_users").update({ db.collection("connected_users").update({
_id: "total_users" _id: "total_users"
@@ -649,7 +636,6 @@ function left_channel(coll, guid, short_id, in_list, socket, change, caller) {
} }
return; return;
} }
//coll = coll.replace(/ /g,'');
db.collection("connected_users").update({ db.collection("connected_users").update({
_id: coll _id: coll
}, { }, {
@@ -720,7 +706,6 @@ function left_channel(coll, guid, short_id, in_list, socket, change, caller) {
} }
}, },
function (err, updated) { function (err, updated) {
//if(updated.nModified > 0) {
db.collection("connected_users").update({ db.collection("connected_users").update({
_id: "total_users" _id: "total_users"
}, { }, {
@@ -735,7 +720,6 @@ function left_channel(coll, guid, short_id, in_list, socket, change, caller) {
} else { } else {
remove_from_chat_channel(coll, guid); remove_from_chat_channel(coll, guid);
} }
//}
} }
); );
} }

View File

@@ -1,4 +1,3 @@
var cookieParser = require("cookie-parser");
var cookie = require("cookie"); var cookie = require("cookie");
var Functions = require(pathThumbnails + "/handlers/functions.js"); var Functions = require(pathThumbnails + "/handlers/functions.js");
@@ -10,15 +9,6 @@ var ListSettings = require(pathThumbnails + "/handlers/list_settings.js");
var Frontpage = require(pathThumbnails + "/handlers/frontpage.js"); 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 = 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 () {
@@ -26,7 +16,6 @@ module.exports = function () {
try { try {
var parsedCookies = cookie.parse(socket.handshake.headers.cookie); var parsedCookies = cookie.parse(socket.handshake.headers.cookie);
socket.cookie_id = parsedCookies["_uI"]; socket.cookie_id = parsedCookies["_uI"];
//return socket.guid;
} catch (e) { } catch (e) {
socket.cookie_id = "empty"; socket.cookie_id = "empty";
} }
@@ -47,7 +36,6 @@ module.exports = function () {
socket.emit("ok"); socket.emit("ok");
}); });
var ping_timeout;
var socketid = socket.zoff_id; var socketid = socket.zoff_id;
var coll; var coll;
var in_list = false; var in_list = false;
@@ -70,7 +58,6 @@ module.exports = function () {
if (msg.hasOwnProperty("channel")) { if (msg.hasOwnProperty("channel")) {
msg.channel = Functions.encodeChannelName(msg.channel); msg.channel = Functions.encodeChannelName(msg.channel);
} }
//channel = channel.replace(/ /g,'');
if (offline) { if (offline) {
db.collection("connected_users").update({ db.collection("connected_users").update({
_id: "offline_users" _id: "offline_users"
@@ -178,9 +165,8 @@ module.exports = function () {
connected_users_channel.length > 0 && connected_users_channel.length > 0 &&
connected_users_channel[0].users.indexOf(msg.guid) > -1 connected_users_channel[0].users.indexOf(msg.guid) > -1
) { ) {
coll = msg.channel.toLowerCase(); //.replace(/ /g,''); coll = msg.channel.toLowerCase();
coll = Functions.removeEmojis(coll).toLowerCase(); coll = Functions.removeEmojis(coll).toLowerCase();
//coll = filter.clean(coll);
if (coll.indexOf("?") > -1) { if (coll.indexOf("?") > -1) {
coll = coll.substring(0, coll.indexOf("?")); coll = coll.substring(0, coll.indexOf("?"));
} }
@@ -190,7 +176,6 @@ module.exports = function () {
msg.channel, msg.channel,
function (results) {} function (results) {}
); );
//socket.cookie_id = msg.guid;
guid = msg.guid; guid = msg.guid;
socketid = msg.socket_id; socketid = msg.socket_id;
socket.zoff_id = socketid; socket.zoff_id = socketid;
@@ -216,16 +201,13 @@ module.exports = function () {
socket.on("error_video", function (msg) { socket.on("error_video", function (msg) {
try { try {
msg.channel = Functions.encodeChannelName(msg.channel); msg.channel = Functions.encodeChannelName(msg.channel);
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 = filter.clean(coll);
} catch (e) { } catch (e) {
return; return;
} }
@@ -368,14 +350,13 @@ module.exports = function () {
return; return;
} }
var status = msg.status; var status = msg.status;
var channel = msg.channel; //.replace(/ /g,''); var channel = msg.channel;
if (status) { if (status) {
in_list = false; in_list = false;
offline = true; offline = true;
if (channel != "") coll = channel; if (channel != "") coll = channel;
if (coll !== undefined) { if (coll !== undefined) {
coll = Functions.removeEmojis(coll).toLowerCase(); coll = Functions.removeEmojis(coll).toLowerCase();
//coll = filter.clean(coll);
db.collection("connected_users").findAndModify({ db.collection("connected_users").findAndModify({
query: { query: {
_id: coll _id: coll
@@ -591,7 +572,6 @@ module.exports = function () {
msg.channel = Functions.encodeChannelName(msg.channel); msg.channel = Functions.encodeChannelName(msg.channel);
} }
try { try {
//var _list = msg.channel.replace(/ /g,'');
var _list = msg.channel; var _list = msg.channel;
if (_list.length == 0) return; if (_list.length == 0) return;
if (_list.indexOf("?") > -1) { if (_list.indexOf("?") > -1) {
@@ -599,9 +579,6 @@ module.exports = function () {
msg.channel = _list; msg.channel = _list;
} }
coll = Functions.removeEmojis(_list).toLowerCase(); coll = Functions.removeEmojis(_list).toLowerCase();
//coll = coll.replace(/_/g, "");
//
//coll = filter.clean(coll);
} catch (e) { } catch (e) {
return; return;
} }
@@ -621,12 +598,9 @@ module.exports = function () {
if (obj.hasOwnProperty("channel")) { if (obj.hasOwnProperty("channel")) {
obj.channel = Functions.encodeChannelName(obj.channel); obj.channel = Functions.encodeChannelName(obj.channel);
try { try {
coll = obj.channel.toLowerCase(); //.replace(/ /g,''); coll = obj.channel.toLowerCase();
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 = filter.clean(coll);
} catch (e) { } catch (e) {
return; return;
} }
@@ -660,12 +634,9 @@ module.exports = function () {
!arr.hasOwnProperty("offsiteAdd")) !arr.hasOwnProperty("offsiteAdd"))
) { ) {
try { try {
coll = arr.list; //.replace(/ /g,''); coll = arr.list;
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 = filter.clean(coll);
} catch (e) { } catch (e) {
return; return;
} }
@@ -684,12 +655,9 @@ module.exports = function () {
if (msg.hasOwnProperty("channel")) { if (msg.hasOwnProperty("channel")) {
msg.channel = Functions.encodeChannelName(msg.channel); msg.channel = Functions.encodeChannelName(msg.channel);
} }
coll = msg.channel.toLowerCase(); //.replace(/ /g,''); coll = msg.channel.toLowerCase();
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 = filter.clean(coll);
} catch (e) { } catch (e) {
return; return;
} }
@@ -707,12 +675,9 @@ module.exports = function () {
} }
if (coll !== undefined) { if (coll !== undefined) {
try { try {
coll = msg.channel.toLowerCase(); //.replace(/ /g,''); coll = msg.channel.toLowerCase();
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 = filter.clean(coll);
} catch (e) { } catch (e) {
return; return;
} }
@@ -728,7 +693,6 @@ module.exports = function () {
if (inp.hasOwnProperty("channel")) { if (inp.hasOwnProperty("channel")) {
inp.channel = Functions.encodeChannelName(inp.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);
}); });
@@ -741,7 +705,6 @@ module.exports = function () {
if (list.hasOwnProperty("channel")) { if (list.hasOwnProperty("channel")) {
list.channel = Functions.encodeChannelName(list.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);
}); });
@@ -755,7 +718,6 @@ module.exports = function () {
conf.channel = Functions.encodeChannelName(conf.channel); conf.channel = Functions.encodeChannelName(conf.channel);
coll = conf.channel; coll = conf.channel;
} }
//if(coll != undefined) coll.replace(/ /g,'');
ListSettings.conf_function(conf, coll, guid, offline, socket); ListSettings.conf_function(conf, coll, guid, offline, socket);
}); });
@@ -768,12 +730,9 @@ module.exports = function () {
msg.channel = Functions.encodeChannelName(msg.channel); msg.channel = Functions.encodeChannelName(msg.channel);
} }
try { try {
coll = msg.channel.toLowerCase(); //.replace(/ /g,''); coll = msg.channel.toLowerCase();
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 = filter.clean(coll);
} catch (e) { } catch (e) {
return; return;
} }
@@ -805,12 +764,9 @@ module.exports = function () {
obj.channel !== undefined obj.channel !== undefined
) { ) {
try { try {
coll = obj.channel.toLowerCase(); //.replace(/ /g,''); coll = obj.channel.toLowerCase();
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 = filter.clean(coll);
} catch (e) { } catch (e) {
return; return;
} }
@@ -864,9 +820,8 @@ module.exports = function () {
msg.channel != "" && msg.channel != "" &&
typeof msg.channel == "string" typeof msg.channel == "string"
) { ) {
coll = msg.channel; //.replace(/ /g,''); coll = msg.channel;
coll = Functions.removeEmojis(coll).toLowerCase(); coll = Functions.removeEmojis(coll).toLowerCase();
//coll = filter.clean(coll);
Functions.left_channel( Functions.left_channel(
coll, coll,
guid, guid,
@@ -932,12 +887,9 @@ module.exports = function () {
} }
if (coll !== undefined) { if (coll !== undefined) {
try { try {
coll = obj.channel.toLowerCase(); //.replace(/ /g,''); coll = obj.channel.toLowerCase();
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 = filter.clean(coll);
} catch (e) { } catch (e) {
return; return;
} }
@@ -994,18 +946,4 @@ module.exports = function () {
}); });
}); });
}); });
};
//send_ping();
};
/*
function send_ping() {
db.collection("connected_users").update({users: {$exists: true}}, {$set: {users: []}}, {multi: true}, function(err, docs){
db.collection("connected_users").update({"_id": "total_users"}, {$add: {total_users: 0}}, {multi: true}, function(err, docs){
db.collection("frontpage_lists").update({viewers: {$ne: 0}}, {$set: {"viewers": 0}}, {multi: true}, function(err, docs) {
io.emit("self_ping");
setTimeout(send_ping, 25000);
});
});
});
}*/

View File

@@ -28,7 +28,6 @@ function now_playing(list, fn, socket) {
function join_silent(msg, socket) { function join_silent(msg, socket) {
if (typeof msg === "object" && msg !== undefined && msg !== null) { if (typeof msg === "object" && msg !== undefined && msg !== null) {
var channelName = msg.channel; var channelName = msg.channel;
var tryingPassword = false;
var password = ""; var password = "";
if (msg.password != "") { if (msg.password != "") {
tryingPassword = true; tryingPassword = true;
@@ -39,7 +38,7 @@ function join_silent(msg, socket) {
.digest("base64"); .digest("base64");
} }
channelName = channelName.toLowerCase(); //.replace(/ /g,''); channelName = channelName.toLowerCase();
channelName = Functions.removeEmojis(channelName).toLowerCase(); channelName = Functions.removeEmojis(channelName).toLowerCase();
db.collection(channelName + "_settings").find(function (err, docs) { db.collection(channelName + "_settings").find(function (err, docs) {
if (docs.length == 0) { if (docs.length == 0) {
@@ -61,7 +60,6 @@ function join_silent(msg, socket) {
} }
function list(msg, guid, coll, offline, socket) { function list(msg, guid, coll, offline, socket) {
var socketid = socket.zoff_id;
if (typeof msg === "object" && msg !== undefined && msg !== null) { if (typeof msg === "object" && msg !== undefined && msg !== null) {
Functions.getSessionAdminUser(Functions.getSession(socket), coll, function ( Functions.getSessionAdminUser(Functions.getSession(socket), coll, function (
userpass, userpass,
@@ -244,19 +242,14 @@ function list(msg, guid, coll, offline, socket) {
} }
function skip(list, guid, coll, offline, socket, callback) { function skip(list, guid, coll, offline, socket, callback) {
var socketid = socket.zoff_id;
if (list !== undefined && list !== null && list !== "") { if (list !== undefined && list !== null && list !== "") {
if (coll == undefined && list.hasOwnProperty("channel")) if (coll == undefined && list.hasOwnProperty("channel"))
coll = list.channel.toLowerCase(); coll = list.channel.toLowerCase();
if (coll !== undefined) { if (coll !== undefined) {
try { try {
coll = list.channel.toLowerCase(); //.replace(/ /g,''); coll = list.channel.toLowerCase();
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 = filter.clean(coll);
} catch (e) { } catch (e) {
return; return;
} }
@@ -356,7 +349,6 @@ function skip(list, guid, coll, offline, socket, callback) {
error = true; error = true;
} }
hash = adminpass; hash = adminpass;
//db.collection(coll + "_settings").find(function(err, docs){
var strictSkip = false; var strictSkip = false;
var strictSkipNumber = 10; var strictSkipNumber = 10;
if (docs[0].strictSkip) strictSkip = docs[0].strictSkip; if (docs[0].strictSkip) strictSkip = docs[0].strictSkip;
@@ -488,7 +480,6 @@ function skip(list, guid, coll, offline, socket, callback) {
} }
} }
); );
//});
} else { } else {
socket.emit("auth_required"); socket.emit("auth_required");
} }
@@ -506,9 +497,6 @@ function skip(list, guid, coll, offline, socket, callback) {
} }
function change_song(coll, error, id, conf, callback, socket) { function change_song(coll, error, id, conf, callback, socket) {
//coll = coll.replace(/ /g,'');
//db.collection(coll + "_settings").find(function(err, docs){
var startTime = conf[0].startTime;
if (conf !== null && conf.length !== 0) { if (conf !== null && conf.length !== 0) {
db.collection(coll).aggregate( db.collection(coll).aggregate(
[{ [{
@@ -678,11 +666,9 @@ function change_song(coll, error, id, conf, callback, socket) {
} }
); );
} }
//});
} }
function change_song_post(coll, next_song, conf, callback, socket, removed) { function change_song_post(coll, next_song, conf, callback, socket, removed) {
//coll = coll.replace(/ /g,'');
db.collection(coll).aggregate( db.collection(coll).aggregate(
[{ [{
$match: { $match: {
@@ -743,7 +729,6 @@ function change_song_post(coll, next_song, conf, callback, socket, removed) {
} }
}, },
function (err, returnDocs) { function (err, returnDocs) {
//db.collection(coll + "_settings").find({id: "config"}, function(err, conf){
if (!callback) { if (!callback) {
io.to(coll).emit("channel", { io.to(coll).emit("channel", {
type: "song_change", type: "song_change",
@@ -778,7 +763,6 @@ function change_song_post(coll, next_song, conf, callback, socket, removed) {
docs[0].thumbnail, docs[0].thumbnail,
docs[0].source docs[0].source
); );
//});
} }
); );
} }
@@ -789,7 +773,6 @@ function change_song_post(coll, next_song, conf, callback, socket, removed) {
} }
function send_list(coll, socket, send, list_send, configs, shuffled) { function send_list(coll, socket, send, list_send, configs, shuffled) {
//coll = coll.replace(/ /g,'');
db.collection(coll + "_settings").aggregate( db.collection(coll + "_settings").aggregate(
[{ [{
$match: { $match: {
@@ -855,7 +838,7 @@ function send_list(coll, socket, send, list_send, configs, shuffled) {
], ],
function ( function (
err, err,
docs //db.collection(coll).find({type: {$ne: "suggested"}}, function(err, docs) docs
) { ) {
if (docs.length > 0) { if (docs.length > 0) {
db.collection(coll).find({ db.collection(coll).find({
@@ -1096,7 +1079,6 @@ function send_list(coll, socket, send, list_send, configs, shuffled) {
} }
function end(obj, coll, guid, offline, socket) { function end(obj, coll, guid, offline, socket) {
var socketid = socket.zoff_id;
if (typeof obj !== "object") { if (typeof obj !== "object") {
return; return;
} }
@@ -1203,7 +1185,6 @@ function end(obj, coll, guid, offline, socket) {
} }
function send_play(coll, socket, broadcast) { function send_play(coll, socket, broadcast) {
//coll = coll.replace(/ /g,'');
db.collection(coll).find({ db.collection(coll).find({
now_playing: true now_playing: true
}, function (err, np) { }, function (err, np) {
@@ -1226,7 +1207,6 @@ function send_play(coll, socket, broadcast) {
}; };
if (socket === undefined) { if (socket === undefined) {
io.to(coll).emit("np", toSend); io.to(coll).emit("np", toSend);
//
getNextSong(coll, undefined); getNextSong(coll, undefined);
var url = var url =
"https://img.youtube.com/vi/" + np[0].id + "/mqdefault.jpg"; "https://img.youtube.com/vi/" + np[0].id + "/mqdefault.jpg";
@@ -1260,12 +1240,8 @@ 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") {
//coll = coll.replace(/ /g,'');
}
if (url.indexOf("://") == -1) if (url.indexOf("://") == -1)
url = "https://img.youtube.com/vi/" + url + "/mqdefault.jpg"; url = "https://img.youtube.com/vi/" + url + "/mqdefault.jpg";
//var url = 'https://img.youtube.com/vi/'+id+'/mqdefault.jpg';
Jimp.read(url) Jimp.read(url)
.then(function (image) { .then(function (image) {

View File

@@ -7,7 +7,6 @@ var crypto = require("crypto");
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) {
var socketid = socket.zoff_id;
if (typeof arr == "object") { if (typeof arr == "object") {
if ( if (
!arr.hasOwnProperty("channel") || !arr.hasOwnProperty("channel") ||
@@ -29,8 +28,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;
var new_channel = Functions.encodeChannelName(arr.new_channel); //.replace(/ /g, '').toLowerCase(); var new_channel = Functions.encodeChannelName(arr.new_channel);
db.collection("frontpage_lists").find({ db.collection("frontpage_lists").find({
_id: new_channel _id: new_channel
}, function ( }, function (
@@ -359,7 +358,6 @@ function addFromOtherList(arr, guid, offline, socket) {
} }
function addPlaylist(arr, guid, offline, socket) { function addPlaylist(arr, guid, offline, socket) {
var socketid = socket.zoff_id;
if (typeof arr == "object") { if (typeof arr == "object") {
if ( if (
!arr.hasOwnProperty("channel") || !arr.hasOwnProperty("channel") ||
@@ -380,7 +378,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;
if (arr.length == 0 || arr.songs.length == 0) { if (arr.length == 0 || arr.songs.length == 0) {
socket.emit("toast", "Empty list.."); socket.emit("toast", "Empty list..");
return; return;
@@ -683,7 +681,6 @@ function addPlaylist(arr, guid, offline, socket) {
} }
function add_function(arr, coll, guid, offline, socket) { function add_function(arr, coll, guid, offline, socket) {
var socketid = socket.zoff_id;
if ( if (
typeof arr === "object" && typeof arr === "object" &&
arr !== undefined && arr !== undefined &&
@@ -1085,9 +1082,8 @@ 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();
coll = Functions.removeEmojis(coll).toLowerCase(); coll = Functions.removeEmojis(coll).toLowerCase();
//coll = filter.clean(coll);
Functions.getSessionAdminUser(Functions.getSession(socket), coll, function ( Functions.getSessionAdminUser(Functions.getSession(socket), coll, function (
userpass, userpass,
adminpass adminpass
@@ -1163,7 +1159,6 @@ function voteUndecided(msg, coll, guid, offline, socket) {
} }
function shuffle(msg, coll, guid, offline, socket) { function shuffle(msg, coll, guid, offline, socket) {
var socketid = socket.zoff_id;
if (!msg.hasOwnProperty("channel") || typeof msg.channel != "string") { if (!msg.hasOwnProperty("channel") || typeof msg.channel != "string") {
var result = { var result = {
channel: { channel: {
@@ -1182,9 +1177,8 @@ 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();
coll = Functions.removeEmojis(coll).toLowerCase(); coll = Functions.removeEmojis(coll).toLowerCase();
//coll = filter.clean(coll);
Functions.getSessionAdminUser(Functions.getSession(socket), coll, function ( Functions.getSessionAdminUser(Functions.getSession(socket), coll, function (
userpass, userpass,
adminpass adminpass
@@ -1263,13 +1257,6 @@ function shuffle(msg, coll, guid, offline, socket) {
socket.emit("auth_required"); socket.emit("auth_required");
} }
}); });
var complete = function (tot, curr) {
if (tot == curr) {
List.send_list(coll, undefined, false, true, false);
List.getNextSong(coll, undefined);
}
};
} }
); );
}); });
@@ -1278,9 +1265,6 @@ 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 = filter.clean(coll);
db.collection(coll + "_settings").find(function (err, docs) { db.collection(coll + "_settings").find(function (err, docs) {
if ( if (
docs !== null && docs !== null &&
@@ -1330,7 +1314,6 @@ function del(params, socket, socketid) {
} }
function delete_all(msg, coll, guid, offline, socket) { function delete_all(msg, coll, guid, offline, socket) {
var socketid = socket.zoff_id;
if (typeof msg == "object") { if (typeof msg == "object") {
if (!msg.hasOwnProperty("channel") || typeof msg.channel != "string") { if (!msg.hasOwnProperty("channel") || typeof msg.channel != "string") {
var result = { var result = {
@@ -1354,9 +1337,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 = Functions.removeEmojis(coll).toLowerCase(); coll = Functions.removeEmojis(coll).toLowerCase();
//coll = filter.clean(coll);
Functions.getSessionAdminUser(Functions.getSession(socket), coll, function ( Functions.getSessionAdminUser(Functions.getSession(socket), coll, function (
userpass, userpass,
adminpass, adminpass,
@@ -1435,7 +1416,6 @@ function delete_all(msg, coll, guid, offline, socket) {
} }
function vote(coll, id, guid, socket) { function vote(coll, id, guid, socket) {
//coll = coll.replace(/ /g,'');
db.collection(coll).find({ db.collection(coll).find({
id: id, id: id,
now_playing: false, now_playing: false,

View File

@@ -31,13 +31,9 @@ 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 = filter.clean(coll);
} catch (e) { } catch (e) {
return; return;
} }
//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, undefined, "place 8"); Functions.check_inlist(coll, guid, socket, offline, undefined, "place 8");
@@ -129,12 +125,9 @@ function conf_function(params, coll, guid, offline, socket) {
if (params !== undefined && params !== null && params !== "") { if (params !== undefined && params !== null && params !== "") {
if (coll !== undefined) { if (coll !== undefined) {
try { try {
coll = params.channel; //.replace(/ /g,''); coll = params.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 = filter.clean(coll);
} catch (e) { } catch (e) {
return; return;
} }

View File

@@ -2,11 +2,9 @@ var path = require("path");
function requested_change(type, string, channel) { function requested_change(type, string, channel) {
try { try {
//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"));
var transporter = nodemailer.createTransport(mailconfig);
let transporter = nodemailer.createTransport(mailconfig);
transporter.verify(function (error, success) { transporter.verify(function (error, success) {
if (error) { if (error) {

View File

@@ -23,20 +23,18 @@ function thumbnail(msg, coll, guid, offline, socket) {
thumbnail: { thumbnail: {
expected: "string", expected: "string",
got: msg.hasOwnProperty("thumbnail") ? got: msg.hasOwnProperty("thumbnail") ?
typeof msg.thumbnail : typeof msg.thumbnail : undefined
undefined
}, },
adminpass: { adminpass: {
expected: "string", expected: "string",
got: msg.hasOwnProperty("adminpass") ? got: msg.hasOwnProperty("adminpass") ?
typeof msg.adminpass : typeof msg.adminpass : undefined
undefined
} }
}; };
socket.emit("update_required", result); socket.emit("update_required", result);
return; return;
} }
//coll = coll.replace(/ /g,'');
Functions.getSessionAdminUser(Functions.getSession(socket), coll, function ( Functions.getSessionAdminUser(Functions.getSession(socket), coll, function (
userpass, userpass,
adminpass adminpass
@@ -125,20 +123,17 @@ function description(msg, coll, guid, offline, socket) {
description: { description: {
expected: "string", expected: "string",
got: msg.hasOwnProperty("description") ? got: msg.hasOwnProperty("description") ?
typeof msg.description : typeof msg.description : undefined
undefined
}, },
adminpass: { adminpass: {
expected: "string", expected: "string",
got: msg.hasOwnProperty("adminpass") ? got: msg.hasOwnProperty("adminpass") ?
typeof msg.adminpass : typeof msg.adminpass : undefined
undefined
} }
}; };
socket.emit("update_required", result); socket.emit("update_required", result);
return; return;
} }
//coll = coll.replace(/ /g,'');
Functions.getSessionAdminUser(Functions.getSession(socket), coll, function ( Functions.getSessionAdminUser(Functions.getSession(socket), coll, function (
userpass, userpass,
adminpass, adminpass,
@@ -227,14 +222,12 @@ function rules(msg, coll, guid, offline, socket) {
adminpass: { adminpass: {
expected: "string", expected: "string",
got: msg.hasOwnProperty("adminpass") ? got: msg.hasOwnProperty("adminpass") ?
typeof msg.adminpass : typeof msg.adminpass : undefined
undefined
} }
}; };
socket.emit("update_required", result); socket.emit("update_required", result);
return; return;
} }
//coll = coll.replace(/ /g,'');
Functions.getSessionAdminUser(Functions.getSession(socket), coll, function ( Functions.getSessionAdminUser(Functions.getSession(socket), coll, function (
userpass, userpass,
adminpass, adminpass,