Trying to improve cpu on server..

This commit is contained in:
Kasper Rynning-Tønnesen
2017-09-18 12:30:16 +02:00
parent 71f5be88df
commit 440d5dc677
14 changed files with 2451 additions and 647 deletions

View File

@@ -20,22 +20,22 @@ var password = function(inp, coll, guid, offline, socket) {
}
uncrypted = pw;
pw = Functions.decrypt_string(socket.zoff_id, pw);
pw = decrypt_string(socket.zoff_id, pw);
Functions.check_inlist(coll, guid, socket, offline);
check_inlist(coll, guid, socket, offline);
if(inp.oldpass)
{
opw = inp.oldpass;
}
opw = Functions.decrypt_string(socket.zoff_id, opw);
opw = decrypt_string(socket.zoff_id, opw);
db.collection(coll).find({views:{$exists:true}}, function(err, docs){
if(docs !== null && docs.length !== 0)
{
if(docs[0].adminpass === "" || docs[0].adminpass == Functions.hash_pass(opw))
if(docs[0].adminpass === "" || docs[0].adminpass == hash_pass(opw))
{
db.collection(coll).update({views:{$exists:true}}, {$set:{adminpass:Functions.hash_pass(pw)}}, function(err, docs){
db.collection(coll).update({views:{$exists:true}}, {$set:{adminpass:hash_pass(pw)}}, function(err, docs){
if(inp.oldpass)
socket.emit("toast", "changedpass");
else
@@ -82,7 +82,7 @@ var conf = function(params, coll, guid, offline, socket) {
return;
}
Functions.check_inlist(coll, guid, socket, offline);
check_inlist(coll, guid, socket, offline);
var voting = params.voting;
var addsongs = params.addsongs;
@@ -93,7 +93,7 @@ var conf = function(params, coll, guid, offline, socket) {
var adminpass = params.adminpass;
var skipping = params.skipping;
var shuffling = params.shuffling;
var userpass = Functions.decrypt_string(socket.zoff_id, params.userpass);
var userpass = decrypt_string(socket.zoff_id, params.userpass);
if((!params.userpass_changed && frontpage) || (params.userpass_changed && userpass == "")) {
userpass = "";
@@ -105,7 +105,7 @@ var conf = function(params, coll, guid, offline, socket) {
if(params.description) description = params.description;
if(adminpass !== "") {
hash = Functions.hash_pass(Functions.decrypt_string(socket.zoff_id, adminpass));
hash = hash_pass(decrypt_string(socket.zoff_id, adminpass));
} else {
hash = adminpass;
}
@@ -139,7 +139,7 @@ var conf = function(params, coll, guid, offline, socket) {
socket.emit("toast", "savedsettings");
db.collection("frontpage_lists").update({_id: coll}, {$set:{
frontpage:frontpage, accessed: Functions.get_time()}
frontpage:frontpage, accessed: get_time()}
},
{upsert:true}, function(err, docs){});
});
@@ -152,6 +152,3 @@ var conf = function(params, coll, guid, offline, socket) {
socket.emit('update_required');
}
}
module.exports.conf = conf;
module.exports.password = password;