- Dynamic Pages (MyPage)

- Uploading files to the Server FTP.
This commit is contained in:
Paolo Arena
2019-12-27 12:41:39 +01:00
parent 9d0e6136ac
commit e62cc62d88
11 changed files with 343 additions and 64 deletions

View File

@@ -1,5 +1,7 @@
var os = require("os");
const fs = require('fs');
require('../config/config');
require('../models/subscribers');
@@ -46,6 +48,7 @@ module.exports = {
typeinrec: 128,
multiselect: 256,
password: 512,
listimages: 1024,
},
MAX_PHASES: 5,
@@ -356,6 +359,16 @@ module.exports = {
return '';
},
getdirByIdApp: function (idapp) {
const myapp =
MYAPPS.find(item => item.idapp === idapp);
if (myapp) {
return myapp.dir;
} else
return '';
},
getAdminEmailByIdApp: function (idapp) {
const myapp = MYAPPS.find((item) => item.idapp === idapp);
if (myapp)
@@ -518,6 +531,34 @@ module.exports = {
StrToBool(mystr) {
return (mystr === '-1') ? true : false
}
},
move(oldPath, newPath, callback) {
fs.rename(oldPath, newPath, function (err) {
if (err) {
if (err.code === 'EXDEV') {
copy();
} else {
callback(err);
}
return;
}
callback();
});
function copy() {
const readStream = fs.createReadStream(oldPath);
const writeStream = fs.createWriteStream(newPath);
readStream.on('error', callback);
writeStream.on('error', callback);
readStream.on('close', function () {
fs.unlink(oldPath, callback);
});
readStream.pipe(writeStream);
}
},
};