Fix PHP Shebang (#17)
This commit is contained in:
parent
db1cc005a3
commit
dbb008ccda
15
main.js
15
main.js
@ -38,6 +38,10 @@ if (ports.length === 0) {
|
|||||||
ports.push(8080);
|
ports.push(8080);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const stringsToRemove = [
|
||||||
|
RegExp("#!/usr/bin/php\n", "g")
|
||||||
|
]
|
||||||
|
|
||||||
//// Functions ////
|
//// Functions ////
|
||||||
|
|
||||||
/* Code exists inside a main function so that we may use async/await.
|
/* 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) {
|
for (let key in pages) {
|
||||||
console.log(" * Creating router for", key);
|
console.log(" * Creating router for", key);
|
||||||
router.get("/" + key, function (req,res) {
|
router.get("/" + key, function (req,res) {
|
||||||
console.log(key, "fulfilling request to", req.socket.remoteAddress, "asking for", req.url)
|
console.log(key, "fulfilling request to", req.socket.remoteAddress, "asking for", req.url);
|
||||||
res.send("" + execSync(pages[key]));
|
let html = "" + execSync(pages[key]);
|
||||||
|
stringsToRemove.forEach(string => {
|
||||||
|
html = html.replace(string, "");
|
||||||
|
});
|
||||||
|
res.send(html);
|
||||||
});
|
});
|
||||||
|
|
||||||
/* Append the page to the sitemap variables.
|
/* Append the page to the sitemap variables.
|
||||||
@ -230,6 +238,9 @@ async function main() {
|
|||||||
//console.log(res);
|
//console.log(res);
|
||||||
console.log("*wildcard* replying to", req.socket.remoteAddress, "asking for", req.url)
|
console.log("*wildcard* replying to", req.socket.remoteAddress, "asking for", req.url)
|
||||||
let html = execSync("./pages/home.php");
|
let html = execSync("./pages/home.php");
|
||||||
|
stringsToRemove.forEach(string => {
|
||||||
|
html = html.replace(string, "");
|
||||||
|
});
|
||||||
res.send(html);
|
res.send(html);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -7,6 +7,12 @@ DIR=`dirname $0`
|
|||||||
header="<html>\n\t<header>\n\t\t<title>ALBUM</title>\n\t</header>\n\t<body>"
|
header="<html>\n\t<header>\n\t\t<title>ALBUM</title>\n\t</header>\n\t<body>"
|
||||||
footer="\n\t</body>\n</html>"
|
footer="\n\t</body>\n</html>"
|
||||||
|
|
||||||
|
# Functions
|
||||||
|
function remove_problem_strings {
|
||||||
|
file="$1"
|
||||||
|
sed -i -e 's/#!\/usr\/bin\/php//g' $file
|
||||||
|
}
|
||||||
|
|
||||||
# Move to the main directory.
|
# Move to the main directory.
|
||||||
cd $DIR/..
|
cd $DIR/..
|
||||||
|
|
||||||
@ -153,11 +159,15 @@ ls $PHOTOS_DIR/ | sort -r | while read album; do
|
|||||||
# Close out the ALBUM's page.
|
# Close out the ALBUM's page.
|
||||||
$HELPER_DIR/body_close.php >> $subpage
|
$HELPER_DIR/body_close.php >> $subpage
|
||||||
echo "<!-- Built on `date`. -->" >> $subpage
|
echo "<!-- Built on `date`. -->" >> $subpage
|
||||||
|
|
||||||
|
remove_problem_strings $subpage
|
||||||
done
|
done
|
||||||
|
|
||||||
# Finish the web page.
|
# Finish the web page.
|
||||||
$HELPER_DIR/body_close.php >> $mainpage
|
$HELPER_DIR/body_close.php >> $mainpage
|
||||||
echo "<!-- Built on `date`. -->" >> $mainpage
|
echo "<!-- Built on `date`. -->" >> $mainpage
|
||||||
|
|
||||||
|
remove_problem_strings $mainpage
|
||||||
|
|
||||||
cat $mainpage
|
cat $mainpage
|
||||||
exit 0
|
exit 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user