diff --git a/meshuser.js b/meshuser.js index 8d817960..4c43f42c 100644 --- a/meshuser.js +++ b/meshuser.js @@ -120,19 +120,29 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use } else return null; var rootfolder = meshpath[0], rootfoldersplit = rootfolder.split('/'), domainx = 'domain'; if (rootfoldersplit[1].length > 0) domainx = 'domain-' + rootfoldersplit[1]; - var path = parent.path.join(parent.filespath, domainx, rootfoldersplit[0] + "-" + rootfoldersplit[2]); + var path = parent.path.join(parent.filespath, domainx, rootfoldersplit[0] + '-' + rootfoldersplit[2]); for (var i = 1; i < meshpath.length; i++) { if (common.IsFilenameValid(meshpath[i]) == false) { path = null; break; } path += ("/" + meshpath[i]); } return path; } - // TODO: Replace this with something better? + // Copy a file using the best technique available function copyFile(src, dest, func, tag) { - var ss = fs.createReadStream(src), ds = fs.createWriteStream(dest); - ss.pipe(ds); - ds.ss = ss; - if (arguments.length == 3 && typeof arguments[2] === 'function') { ds.on('close', arguments[2]); } - else if (arguments.length == 4 && typeof arguments[3] === 'function') { ds.on('close', arguments[3]); } - ds.on('close', function () { func(tag); }); + if (fs.copyFile) { + // NodeJS v8.5 and higher + fs.copyFile(src, dest, function (err) { func(tag); }) + } else { + // Older NodeJS + try { + var ss = fs.createReadStream(src), ds = fs.createWriteStream(dest); + ss.on('error', function () { func(tag); }); + ds.on('error', function () { func(tag); }); + ss.pipe(ds); + ds.ss = ss; + if (arguments.length == 3 && typeof arguments[2] === 'function') { ds.on('close', arguments[2]); } + else if (arguments.length == 4 && typeof arguments[3] === 'function') { ds.on('close', arguments[3]); } + ds.on('close', function () { func(tag); }); + } catch (ex) { } + } } // Route a command to a target node @@ -607,9 +617,9 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use if ((command.fileop == 'createfolder') && (common.IsFilenameValid(command.newfolder) == true)) { // Create a new folder - try { fs.mkdirSync(path + "/" + command.newfolder); } catch (e) { - try { fs.mkdirSync(path); } catch (e) { } - try { fs.mkdirSync(path + "/" + command.newfolder); } catch (e) { } + try { fs.mkdirSync(path + '/' + command.newfolder); } catch (ex) { + try { fs.mkdirSync(path); } catch (ex) { } + try { fs.mkdirSync(path + '/' + command.newfolder); } catch (ex) { } } } else if (command.fileop == 'delete') { @@ -619,9 +629,9 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use if (common.IsFilenameValid(command.delfiles[i]) == true) { var fullpath = parent.path.join(path, command.delfiles[i]); if (command.rec == true) { - deleteFolderRecursive(fullpath); // TODO, make this an async function + try { deleteFolderRecursive(fullpath); } catch (ex) { } // TODO, make this an async function } else { - try { fs.rmdirSync(fullpath); } catch (e) { try { fs.unlinkSync(fullpath); } catch (e) { } } + try { fs.rmdirSync(fullpath); } catch (ex) { try { fs.unlinkSync(fullpath); } catch (xe) { } } } } } diff --git a/package.json b/package.json index f65aa6eb..19765991 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "meshcentral", - "version": "0.4.3-q", + "version": "0.4.3-r", "keywords": [ "Remote Management", "Intel AMT", diff --git a/public/styles/messenger.css b/public/styles/messenger.css index acc3cecc..74f419d2 100644 --- a/public/styles/messenger.css +++ b/public/styles/messenger.css @@ -3,10 +3,10 @@ border: none; margin: 2px; margin-top: 3px; - float: right; border-radius: 3px; height: 32px; width: 32px; + float: right; } .topButton:hover { diff --git a/views/default-min.handlebars b/views/default-min.handlebars index 2667d095..ac69b0ef 100644 --- a/views/default-min.handlebars +++ b/views/default-min.handlebars @@ -3524,7 +3524,7 @@ if (xxdialogMode) return; var url = '/messenger?id=meshmessenger/' + encodeURIComponent(currentNode._id) + '/' + encodeURIComponent(userinfo._id) + '&title=' + currentNode.name; if ((authCookie != null) && (authCookie != '')) { url += '&auth=' + authCookie; } - window.open(url, 'meshmessenger:' + currentNode._id); + window.open(url, 'meshmessenger:' + currentNode._id, 'directories=no,titlebar=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=400,height=560'); meshserver.send({ action: 'meshmessenger', nodeid: decodeURIComponent(currentNode._id) }); } @@ -6740,12 +6740,12 @@ var h = ''; if (f.t < 3 || f.t == 4) { var right = (f.t == 1 || f.t == 4)?p5getQuotabar(f):'', title = ''; - h = '
 ' + right + '
' + shortname + '
'; + h = '
 ' + right + '
' + shortname + '
'; } else { var link = shortname, publiclink = ''; - if (publicfolder) { publiclink = ' (' + "Link" + ')'; } - if (f.s > 0) { link = '' + shortname + '' + publiclink; } - h = '
 ' + fdatestr + '' + fsize + '
' + link + '
'; + if (publicfolder) { publiclink = ' (' + "Link" + ')'; } + if (f.s > 0) { link = '' + shortname + '' + publiclink; } + h = '
 ' + fdatestr + '' + fsize + '
' + link + '
'; } if (f.t < 3) { html1 += h; } else { html2 += h; } @@ -6883,7 +6883,16 @@ */ var p5clipboard = null, p5clipboardFolder = null, p5clipboardCut = 0; - function p5copyFile(cut) { var checkboxes = document.getElementsByName('fc'); p5clipboard = []; p5clipboardCut = cut, p5clipboardFolder = Clone(filetreelocation); for (var i = 0; i < checkboxes.length; i++) { if ((checkboxes[i].checked) && (checkboxes[i].attributes.file.value == '3')) { p5clipboard.push(checkboxes[i].value); } } p5updateClipview(); } + function p5copyFile(cut) { + var checkboxes = document.getElementsByName('fc'); p5clipboard = []; p5clipboardCut = cut, p5clipboardFolder = Clone(filetreelocation); + for (var i = 0; i < checkboxes.length; i++) { + if ((checkboxes[i].checked) && (checkboxes[i].attributes.file.value == '3')) { + console.log('yy', checkboxes[i].value); + p5clipboard.push(checkboxes[i].value); + } + } + p5updateClipview(); + } function p5pasteFile() { var x = ''; if ((p5clipboard != null) && (p5clipboard.length > 0)) { x = format("Confim {0} of {1} entrie{2} to this location?", (p5clipboardCut == 0?'copy':'move'), p5clipboard.length, ((p5clipboard.length > 1)?'s':'')) } setDialogMode(2, "Paste", 3, p5pasteFileEx, x); } function p5pasteFileEx() { meshserver.send({ action: 'fileoperation', fileop: (p5clipboardCut == 0?'copy':'move'), scpath: p5clipboardFolder, path: filetreelocation, names: p5clipboard }); p5folderup(999); if (p5clipboardCut == 1) { p5clipboard = null, p5clipboardFolder = null, p5clipboardCut = 0; p5updateClipview(); } } function p5updateClipview() { var x = ''; if ((p5clipboard != null) && (p5clipboard.length > 0)) { x = format("Holding {0} entrie{1} for {2}", p5clipboard.length, ((p5clipboard.length > 1)?'s':''), (p5clipboardCut == 0?"copy":"move")) + ', ' + "Clear" + '.' } QH('p5bottomstatus', x); p5setActions(); } diff --git a/views/default.handlebars b/views/default.handlebars index a044fa68..b4df2d15 100644 --- a/views/default.handlebars +++ b/views/default.handlebars @@ -4506,7 +4506,7 @@ if (xxdialogMode) return; var url = '/messenger?id=meshmessenger/' + encodeURIComponent(currentNode._id) + '/' + encodeURIComponent(userinfo._id) + '&title=' + currentNode.name; if ((authCookie != null) && (authCookie != '')) { url += '&auth=' + authCookie; } - window.open(url, 'meshmessenger:' + currentNode._id); + window.open(url, 'meshmessenger:' + currentNode._id, 'directories=no,titlebar=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=400,height=560'); meshserver.send({ action: 'meshmessenger', nodeid: decodeURIComponent(currentNode._id) }); } @@ -7722,12 +7722,12 @@ var h = ''; if (f.t < 3 || f.t == 4) { var right = (f.t == 1 || f.t == 4)?p5getQuotabar(f):'', title = ''; - h = '
 ' + right + '
' + shortname + '
'; + h = '
 ' + right + '
' + shortname + '
'; } else { var link = shortname, publiclink = ''; - if (publicfolder) { publiclink = ' (' + "Link" + ')'; } - if (f.s > 0) { link = '' + shortname + '' + publiclink; } - h = '
 ' + fdatestr + '' + fsize + '
' + link + '
'; + if (publicfolder) { publiclink = ' (' + "Link" + ')'; } + if (f.s > 0) { link = '' + shortname + '' + publiclink; } + h = '
 ' + fdatestr + '' + fsize + '
' + link + '
'; } if (f.t < 3) { html1 += h; } else { html2 += h; } @@ -7865,7 +7865,16 @@ */ var p5clipboard = null, p5clipboardFolder = null, p5clipboardCut = 0; - function p5copyFile(cut) { var checkboxes = document.getElementsByName('fc'); p5clipboard = []; p5clipboardCut = cut, p5clipboardFolder = Clone(filetreelocation); for (var i = 0; i < checkboxes.length; i++) { if ((checkboxes[i].checked) && (checkboxes[i].attributes.file.value == '3')) { p5clipboard.push(checkboxes[i].value); } } p5updateClipview(); } + function p5copyFile(cut) { + var checkboxes = document.getElementsByName('fc'); p5clipboard = []; p5clipboardCut = cut, p5clipboardFolder = Clone(filetreelocation); + for (var i = 0; i < checkboxes.length; i++) { + if ((checkboxes[i].checked) && (checkboxes[i].attributes.file.value == '3')) { + console.log('yy', checkboxes[i].value); + p5clipboard.push(checkboxes[i].value); + } + } + p5updateClipview(); + } function p5pasteFile() { var x = ''; if ((p5clipboard != null) && (p5clipboard.length > 0)) { x = format("Confim {0} of {1} entrie{2} to this location?", (p5clipboardCut == 0?'copy':'move'), p5clipboard.length, ((p5clipboard.length > 1)?'s':'')) } setDialogMode(2, "Paste", 3, p5pasteFileEx, x); } function p5pasteFileEx() { meshserver.send({ action: 'fileoperation', fileop: (p5clipboardCut == 0?'copy':'move'), scpath: p5clipboardFolder, path: filetreelocation, names: p5clipboard }); p5folderup(999); if (p5clipboardCut == 1) { p5clipboard = null, p5clipboardFolder = null, p5clipboardCut = 0; p5updateClipview(); } } function p5updateClipview() { var x = ''; if ((p5clipboard != null) && (p5clipboard.length > 0)) { x = format("Holding {0} entrie{1} for {2}", p5clipboard.length, ((p5clipboard.length > 1)?'s':''), (p5clipboardCut == 0?"copy":"move")) + ', ' + "Clear" + '.' } QH('p5bottomstatus', x); p5setActions(); } diff --git a/views/messenger-min.handlebars b/views/messenger-min.handlebars index 5efd3707..26a2e4a6 100644 --- a/views/messenger-min.handlebars +++ b/views/messenger-min.handlebars @@ -1 +1 @@ -MeshMessenger
MeshMessenger
\ No newline at end of file +MeshMessenger
MeshMessenger
\ No newline at end of file diff --git a/views/messenger.handlebars b/views/messenger.handlebars index 8c6931a2..6a8629b2 100644 --- a/views/messenger.handlebars +++ b/views/messenger.handlebars @@ -12,13 +12,14 @@
- - - - - -
-
MeshMessenger
+
+ + + + + +
+
MeshMessenger
@@ -65,7 +66,7 @@ var currentFileDownload = null; // Set the title - if (args.title) { QH('xtitle', ' - ' + args.title); document.title = document.title + ' - ' + args.title; } + if (args.title) { QH('xtitle', args.title.split(' ').join(' ')); document.title = document.title + ' - ' + args.title; } // Setup web notifications if (Notification) { QV('notifyButton', Notification.permission != 'granted'); } diff --git a/views/translations/default-min_fr.handlebars b/views/translations/default-min_fr.handlebars index 103b492d..7b352709 100644 --- a/views/translations/default-min_fr.handlebars +++ b/views/translations/default-min_fr.handlebars @@ -3524,7 +3524,7 @@ if (xxdialogMode) return; var url = '/messenger?id=meshmessenger/' + encodeURIComponent(currentNode._id) + '/' + encodeURIComponent(userinfo._id) + '&title=' + currentNode.name; if ((authCookie != null) && (authCookie != '')) { url += '&auth=' + authCookie; } - window.open(url, 'meshmessenger:' + currentNode._id); + window.open(url, 'meshmessenger:' + currentNode._id, 'directories=no,titlebar=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=400,height=560'); meshserver.send({ action: 'meshmessenger', nodeid: decodeURIComponent(currentNode._id) }); } @@ -6740,12 +6740,12 @@ var h = ''; if (f.t < 3 || f.t == 4) { var right = (f.t == 1 || f.t == 4)?p5getQuotabar(f):'', title = ''; - h = '
 ' + right + '
' + shortname + '
'; + h = '
 ' + right + '
' + shortname + '
'; } else { var link = shortname, publiclink = ''; - if (publicfolder) { publiclink = ' (' + "Link" + ')'; } - if (f.s > 0) { link = '' + shortname + '' + publiclink; } - h = '
 ' + fdatestr + '' + fsize + '
' + link + '
'; + if (publicfolder) { publiclink = ' (' + "Link" + ')'; } + if (f.s > 0) { link = '' + shortname + '' + publiclink; } + h = '
 ' + fdatestr + '' + fsize + '
' + link + '
'; } if (f.t < 3) { html1 += h; } else { html2 += h; } @@ -6883,7 +6883,16 @@ */ var p5clipboard = null, p5clipboardFolder = null, p5clipboardCut = 0; - function p5copyFile(cut) { var checkboxes = document.getElementsByName('fc'); p5clipboard = []; p5clipboardCut = cut, p5clipboardFolder = Clone(filetreelocation); for (var i = 0; i < checkboxes.length; i++) { if ((checkboxes[i].checked) && (checkboxes[i].attributes.file.value == '3')) { p5clipboard.push(checkboxes[i].value); } } p5updateClipview(); } + function p5copyFile(cut) { + var checkboxes = document.getElementsByName('fc'); p5clipboard = []; p5clipboardCut = cut, p5clipboardFolder = Clone(filetreelocation); + for (var i = 0; i < checkboxes.length; i++) { + if ((checkboxes[i].checked) && (checkboxes[i].attributes.file.value == '3')) { + console.log('yy', checkboxes[i].value); + p5clipboard.push(checkboxes[i].value); + } + } + p5updateClipview(); + } function p5pasteFile() { var x = ''; if ((p5clipboard != null) && (p5clipboard.length > 0)) { x = format("Confim {0} of {1} entrie{2} to this location?", (p5clipboardCut == 0?'copy':'move'), p5clipboard.length, ((p5clipboard.length > 1)?'s':'')) } setDialogMode(2, "Paste", 3, p5pasteFileEx, x); } function p5pasteFileEx() { meshserver.send({ action: 'fileoperation', fileop: (p5clipboardCut == 0?'copy':'move'), scpath: p5clipboardFolder, path: filetreelocation, names: p5clipboard }); p5folderup(999); if (p5clipboardCut == 1) { p5clipboard = null, p5clipboardFolder = null, p5clipboardCut = 0; p5updateClipview(); } } function p5updateClipview() { var x = ''; if ((p5clipboard != null) && (p5clipboard.length > 0)) { x = format("Holding {0} entrie{1} for {2}", p5clipboard.length, ((p5clipboard.length > 1)?'s':''), (p5clipboardCut == 0?"copy":"move")) + ', ' + "Clear" + '.' } QH('p5bottomstatus', x); p5setActions(); } diff --git a/views/translations/default_fr.handlebars b/views/translations/default_fr.handlebars index 4d0b2a12..64de35c3 100644 --- a/views/translations/default_fr.handlebars +++ b/views/translations/default_fr.handlebars @@ -4504,7 +4504,7 @@ if (xxdialogMode) return; var url = '/messenger?id=meshmessenger/' + encodeURIComponent(currentNode._id) + '/' + encodeURIComponent(userinfo._id) + '&title=' + currentNode.name; if ((authCookie != null) && (authCookie != '')) { url += '&auth=' + authCookie; } - window.open(url, 'meshmessenger:' + currentNode._id); + window.open(url, 'meshmessenger:' + currentNode._id, 'directories=no,titlebar=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=400,height=560'); meshserver.send({ action: 'meshmessenger', nodeid: decodeURIComponent(currentNode._id) }); } @@ -7720,12 +7720,12 @@ var h = ''; if (f.t < 3 || f.t == 4) { var right = (f.t == 1 || f.t == 4)?p5getQuotabar(f):'', title = ''; - h = '
 ' + right + '
' + shortname + '
'; + h = '
 ' + right + '
' + shortname + '
'; } else { var link = shortname, publiclink = ''; - if (publicfolder) { publiclink = ' (' + "Link" + ')'; } - if (f.s > 0) { link = '' + shortname + '' + publiclink; } - h = '
 ' + fdatestr + '' + fsize + '
' + link + '
'; + if (publicfolder) { publiclink = ' (' + "Link" + ')'; } + if (f.s > 0) { link = '' + shortname + '' + publiclink; } + h = '
 ' + fdatestr + '' + fsize + '
' + link + '
'; } if (f.t < 3) { html1 += h; } else { html2 += h; } @@ -7863,7 +7863,16 @@ */ var p5clipboard = null, p5clipboardFolder = null, p5clipboardCut = 0; - function p5copyFile(cut) { var checkboxes = document.getElementsByName('fc'); p5clipboard = []; p5clipboardCut = cut, p5clipboardFolder = Clone(filetreelocation); for (var i = 0; i < checkboxes.length; i++) { if ((checkboxes[i].checked) && (checkboxes[i].attributes.file.value == '3')) { p5clipboard.push(checkboxes[i].value); } } p5updateClipview(); } + function p5copyFile(cut) { + var checkboxes = document.getElementsByName('fc'); p5clipboard = []; p5clipboardCut = cut, p5clipboardFolder = Clone(filetreelocation); + for (var i = 0; i < checkboxes.length; i++) { + if ((checkboxes[i].checked) && (checkboxes[i].attributes.file.value == '3')) { + console.log('yy', checkboxes[i].value); + p5clipboard.push(checkboxes[i].value); + } + } + p5updateClipview(); + } function p5pasteFile() { var x = ''; if ((p5clipboard != null) && (p5clipboard.length > 0)) { x = format("Confim {0} of {1} entrie{2} to this location?", (p5clipboardCut == 0?'copy':'move'), p5clipboard.length, ((p5clipboard.length > 1)?'s':'')) } setDialogMode(2, "Paste", 3, p5pasteFileEx, x); } function p5pasteFileEx() { meshserver.send({ action: 'fileoperation', fileop: (p5clipboardCut == 0?'copy':'move'), scpath: p5clipboardFolder, path: filetreelocation, names: p5clipboard }); p5folderup(999); if (p5clipboardCut == 1) { p5clipboard = null, p5clipboardFolder = null, p5clipboardCut = 0; p5updateClipview(); } } function p5updateClipview() { var x = ''; if ((p5clipboard != null) && (p5clipboard.length > 0)) { x = format("Holding {0} entrie{1} for {2}", p5clipboard.length, ((p5clipboard.length > 1)?'s':''), (p5clipboardCut == 0?"copy":"move")) + ', ' + "Clear" + '.' } QH('p5bottomstatus', x); p5setActions(); } diff --git a/views/translations/messenger-min_fr.handlebars b/views/translations/messenger-min_fr.handlebars index 0832659f..3d6aa1e7 100644 --- a/views/translations/messenger-min_fr.handlebars +++ b/views/translations/messenger-min_fr.handlebars @@ -1 +1 @@ -MeshMessenger
MeshMessenger
\ No newline at end of file +MeshMessenger
MeshMessenger
\ No newline at end of file diff --git a/views/translations/messenger_fr.handlebars b/views/translations/messenger_fr.handlebars index 270eb714..6fb48109 100644 --- a/views/translations/messenger_fr.handlebars +++ b/views/translations/messenger_fr.handlebars @@ -10,13 +10,14 @@
- - - - - -
-
MeshMessenger
+
+ + + + + +
+
MeshMessenger
@@ -63,7 +64,7 @@ var currentFileDownload = null; // Set the title - if (args.title) { QH('xtitle', ' - ' + args.title); document.title = document.title + ' - ' + args.title; } + if (args.title) { QH('xtitle', args.title.split(' ').join(' ')); document.title = document.title + ' - ' + args.title; } // Setup web notifications if (Notification) { QV('notifyButton', Notification.permission != 'granted'); } diff --git a/webserver.js b/webserver.js index 2ea78c05..5409b2ad 100644 --- a/webserver.js +++ b/webserver.js @@ -2691,11 +2691,13 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) { // Delete a folder and all sub items. (TODO: try to make all async version) function deleteFolderRec(path) { if (obj.fs.existsSync(path) == false) return; - obj.fs.readdirSync(path).forEach(function (file, index) { - var pathx = path + "/" + file; - if (obj.fs.lstatSync(pathx).isDirectory()) { deleteFolderRec(pathx); } else { obj.fs.unlinkSync(pathx); } - }); - obj.fs.rmdirSync(path); + try { + obj.fs.readdirSync(path).forEach(function (file, index) { + var pathx = path + '/' + file; + if (obj.fs.lstatSync(pathx).isDirectory()) { deleteFolderRec(pathx); } else { obj.fs.unlinkSync(pathx); } + }); + obj.fs.rmdirSync(path); + } catch (ex) { } } // Handle Intel AMT events