v0.9.57
- move wtv-guide romcache + some fixes - fix getAbsolutePath - fix adding users (broken with getAbsolutePath update) - fix bugs, update badwords, more bugs with account addition to fix yet - implement bad username check (wordlist from Redialed) - update zefie server IP (again) - proper x-powered-by version format - fix: also respect in hide_minisrv_version in cgi - fix: properly respect hide_minisrv_version flag - removed a scary warning - add default php_binpath config entry (php is still disabled by default)
This commit is contained in:
@@ -494,8 +494,8 @@ class WTVShared {
|
||||
};
|
||||
|
||||
log(" *** Reading global configuration...");
|
||||
try {
|
||||
var minisrv_config = this.parseJSON(this.fs.readFileSync(this.getAbsolutePath(".." + this.path.sep + "config.json", __dirname)));
|
||||
try {
|
||||
var minisrv_config = this.parseJSON(this.fs.readFileSync(this.getAbsolutePath("includes" + this.path.sep + "config.json", this.appdir)));
|
||||
} catch (e) {
|
||||
throw new Error("ERROR: Could not read config.json", e);
|
||||
}
|
||||
@@ -522,10 +522,10 @@ class WTVShared {
|
||||
debugFlags.quiet = minisrv_config.config.verbosity < 2;
|
||||
debugFlags.show_headers = minisrv_config.config.verbosity === 2
|
||||
debugFlags.debug = minisrv_config.config.verbosity === 3;
|
||||
log(` * Console Verbosity level ${minisrv_config.config.verbosity}`);
|
||||
log(` *** Console Verbosity level ${minisrv_config.config.verbosity}`);
|
||||
} else {
|
||||
Object.assign(debugFlags, { debug: true, quiet: false, show_headers: true });
|
||||
log(" * Console Verbosity level 4 (debug verbosity)");
|
||||
log(" *** Console Verbosity level 4 (debug verbosity)");
|
||||
}
|
||||
|
||||
minisrv_config.config.debug_flags = debugFlags;
|
||||
@@ -832,17 +832,29 @@ class WTVShared {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an absolute path
|
||||
* Returns an absolute path with an trailing path seperator
|
||||
* @param {string} path
|
||||
* @param {string} directory Root directory
|
||||
*/
|
||||
getAbsolutePath(path = '', directory = '.') {
|
||||
if (directory[0] == "/") {
|
||||
return this.path.resolve(directory + this.path.sep + path);
|
||||
if (directory[0] == "/" || directory.substr(1, 2) == ":" + this.path.sep) {
|
||||
var newpath = this.path.resolve(directory + this.path.sep + path);
|
||||
if (this.fs.existsSync(newpath)) {
|
||||
this.fs.statSync(newpath, (err, stats) => {
|
||||
if (err) {
|
||||
console.log('Error checking path:', err);
|
||||
} else {
|
||||
if (stats.isDirectory()) {
|
||||
newpath += this.path.sep
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return newpath;
|
||||
}
|
||||
try {
|
||||
// start with our absolute path (of app.js)
|
||||
const appdir = this.path.resolve(__dirname + this.path.sep + '..' + this.path.sep + '..')
|
||||
const appdir = this.path.resolve(__dirname + this.path.sep + '..' + this.path.sep + '..') + this.path.sep
|
||||
|
||||
if (path == '' && directory == '.') {
|
||||
return appdir;
|
||||
@@ -862,8 +874,27 @@ class WTVShared {
|
||||
// If there's an error accessing the directory, log it or handle as needed
|
||||
console.error('Error resolving directory:', e);
|
||||
}
|
||||
// determine if the final path is a directory, and add a final path.sep if so
|
||||
var add_sep = false;
|
||||
if (this.fs.existsSync(path)) {
|
||||
this.fs.statSync(path, (err, stats) => {
|
||||
if (err) {
|
||||
console.log('Error checking path:', err);
|
||||
} else {
|
||||
if (stats.isDirectory()) {
|
||||
add_sep = true
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// path doesn't exist, we have to guess if its a directory
|
||||
var path_split = this.path.resolve(path).split(this.path.sep);
|
||||
if (path_split[(path_split.length - 1)].indexOf('.') > -1) {
|
||||
add_sep = true;
|
||||
}
|
||||
}
|
||||
// The path.resolve method will take care of normalizing slashes
|
||||
return this.path.resolve(path);
|
||||
return this.path.resolve(path) + ((add_sep) ? this.path.sep : '');
|
||||
}
|
||||
|
||||
|
||||
@@ -974,6 +1005,15 @@ class WTVShared {
|
||||
}
|
||||
}
|
||||
|
||||
doRedirect(url) {
|
||||
var headers = []
|
||||
headers['Status'] = "302 Moved";
|
||||
headers["Location"] = url;
|
||||
headers["wtv-visit"] = url;
|
||||
var data = ''
|
||||
return [headers, data]
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an error message and sends it to the client
|
||||
* @param {number} code HTTP Error Code
|
||||
@@ -1090,7 +1130,7 @@ class WTVShared {
|
||||
if (found) return;
|
||||
if (template) dep_vault_dir += self.path.sep + "templates";
|
||||
|
||||
var search = self.getAbsolutePath(dep_vault_dir + self.path.sep + file);
|
||||
var search = self.getAbsolutePath(file, dep_vault_dir);
|
||||
if (self.fs.existsSync(search)) {
|
||||
if (path_only) outdata = search;
|
||||
else outdata = self.fs.readFileSync(search);
|
||||
|
||||
Reference in New Issue
Block a user