Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /var/www/html/proxy_server/node_modules/rtail/node_modules/configstore/ drwxr-xr-x | |
| Viewing file: Select action/file-type: 'use strict';
var path = require('path');
var fs = require('graceful-fs');
var osenv = require('osenv');
var assign = require('object-assign');
var mkdirp = require('mkdirp');
var uuid = require('uuid');
var xdgBasedir = require('xdg-basedir');
var osTmpdir = require('os-tmpdir');
var writeFileAtomic = require('write-file-atomic');
var user = (osenv.user() || uuid.v4()).replace(/\\/g, '');
var configDir = xdgBasedir.config || path.join(osTmpdir(), user, '.config');
var permissionError = 'You don\'t have access to this file.';
var defaultPathMode = parseInt('0700', 8);
var writeFileOptions = {mode: parseInt('0600', 8)};
function Configstore(id, defaults, opts) {
opts = opts || {};
var pathPrefix = opts.globalConfigPath ?
path.join(id, 'config.json') :
path.join('configstore', id + '.json');
this.path = path.join(configDir, pathPrefix);
this.all = assign({}, defaults || {}, this.all || {});
}
Configstore.prototype = Object.create(Object.prototype, {
all: {
get: function () {
try {
return JSON.parse(fs.readFileSync(this.path, 'utf8'));
} catch (err) {
// create dir if it doesn't exist
if (err.code === 'ENOENT') {
mkdirp.sync(path.dirname(this.path), defaultPathMode);
return {};
}
// improve the message of permission errors
if (err.code === 'EACCES') {
err.message = err.message + '\n' + permissionError + '\n';
}
// empty the file if it encounters invalid JSON
if (err.name === 'SyntaxError') {
writeFileAtomic.sync(this.path, '', writeFileOptions);
return {};
}
throw err;
}
},
set: function (val) {
try {
// make sure the folder exists as it
// could have been deleted in the meantime
mkdirp.sync(path.dirname(this.path), defaultPathMode);
writeFileAtomic.sync(this.path, JSON.stringify(val, null, '\t'), writeFileOptions);
} catch (err) {
// improve the message of permission errors
if (err.code === 'EACCES') {
err.message = err.message + '\n' + permissionError + '\n';
}
throw err;
}
}
},
size: {
get: function () {
return Object.keys(this.all || {}).length;
}
}
});
Configstore.prototype.get = function (key) {
return this.all[key];
};
Configstore.prototype.set = function (key, val) {
var config = this.all;
if (arguments.length === 1) {
Object.keys(key).forEach(function (k) {
config[k] = key[k];
});
} else {
config[key] = val;
}
this.all = config;
};
Configstore.prototype.del = function (key) {
var config = this.all;
delete config[key];
this.all = config;
};
Configstore.prototype.clear = function () {
this.all = {};
};
module.exports = Configstore;
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0062 ]-- |