From c90ebfa1c84e1ba668a65d0325e96d201c4abbf8 Mon Sep 17 00:00:00 2001 From: Minteck Date: Sat, 7 Aug 2021 20:15:23 +0200 Subject: Electrode is stable! --- php/cache.js | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'php/cache.js') diff --git a/php/cache.js b/php/cache.js index 25c47be..8cfe5e1 100644 --- a/php/cache.js +++ b/php/cache.js @@ -17,9 +17,11 @@ module.exports = (req, res, file, post, files) => { fid = "PHP_" + cid; parsed = url.parse(req.url, true); - content = " r.concat(list.reduce((rr, i) => rr.concat(i.family==='IPv4' && !i.internal && i.address || []), [])), [])[0]); @@ -65,6 +67,8 @@ module.exports = (req, res, file, post, files) => { content = content + "\n$_FILES = [];"; content = content + "\n$_POST = [];"; content = content + "\n$_GET = [];"; + content = content + "\n$GLOBALS = [];"; + content = content + "\n$GLOBALS[\"SYSTEM_ROOT\"] = \"\";"; Object.keys(parsed.query).forEach((key) => { content = content + "\n$_GET[\"" + key.split("\"").join("\\\"").split("$").join("\\\$") + "\"] = \"" + parsed.query[key].split("\"").join("\\\"").split("$").join("\\\$") + "\";" }) @@ -80,11 +84,19 @@ module.exports = (req, res, file, post, files) => { Object.keys(cookies).forEach((key) => { content = content + "\n$_COOKIE[\"" + key.split("\"").join("\\\"").split("$").join("\\\$") + "\"] = \"" + cookies[key].split("\"").join("\\\"").split("$").join("\\\$") + "\";" }) - content = content + "\nrequire_once \"" + file.split("\"").join("\\\"") + "\";\n\n__electrode_end_hooks();"; + + p = "./public" + + regex = /require_once\(["'`].*resources\/private\/relative\.php["'`]\);/gm; + regex2 = /require_once ["'`].*resources\/private\/relative\.php["'`];/gm; + + fs.writeFileSync(file + ".ELECTRODECACHE~.php", fs.readFileSync(file).toString().replace(regex, "").replace(regex2, "")); + content = content + "\nchdir(\"" + p + "\");\nfunction getRelativeDetails() {};\nrequire_once \"." + file.split("\"").join("\\\"").substr(8) + ".ELECTRODECACHE~.php" + "\";\n\n__electrode_end_hooks();"; fs.writeFileSync("./cache/" + fid + ".php", content); return [ "./cache/" + fid + ".php", - cid + cid, + file + ".ELECTRODECACHE~.php" ]; } -- cgit