- Dynamic Pages (MyPage)
- Uploading files to the Server FTP.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user