diff --git a/main.js b/main.js index 5ef14f1..6687400 100755 --- a/main.js +++ b/main.js @@ -38,6 +38,10 @@ if (ports.length === 0) { ports.push(8080); } +const stringsToRemove = [ + RegExp("#!/usr/bin/php\n", "g") +] + //// Functions //// /* Code exists inside a main function so that we may use async/await. @@ -133,8 +137,12 @@ async function main() { for (let key in pages) { console.log(" * Creating router for", key); router.get("/" + key, function (req,res) { - console.log(key, "fulfilling request to", req.socket.remoteAddress, "asking for", req.url) - res.send("" + execSync(pages[key])); + console.log(key, "fulfilling request to", req.socket.remoteAddress, "asking for", req.url); + let html = "" + execSync(pages[key]); + stringsToRemove.forEach(string => { + html = html.replace(string, ""); + }); + res.send(html); }); /* Append the page to the sitemap variables. @@ -230,6 +238,9 @@ async function main() { //console.log(res); console.log("*wildcard* replying to", req.socket.remoteAddress, "asking for", req.url) let html = execSync("./pages/home.php"); + stringsToRemove.forEach(string => { + html = html.replace(string, ""); + }); res.send(html); }); diff --git a/pages/photos.sh b/pages/photos.sh index 88e63bb..37f0366 100755 --- a/pages/photos.sh +++ b/pages/photos.sh @@ -7,6 +7,12 @@ DIR=`dirname $0` header="\n\t
\n\t\tALBUM\n\t
\n\t" footer="\n\t\n" +# Functions +function remove_problem_strings { + file="$1" + sed -i -e 's/#!\/usr\/bin\/php//g' $file +} + # Move to the main directory. cd $DIR/.. @@ -153,11 +159,15 @@ ls $PHOTOS_DIR/ | sort -r | while read album; do # Close out the ALBUM's page. $HELPER_DIR/body_close.php >> $subpage echo "" >> $subpage + + remove_problem_strings $subpage done # Finish the web page. $HELPER_DIR/body_close.php >> $mainpage echo "" >> $mainpage +remove_problem_strings $mainpage + cat $mainpage exit 0