From c5f6c91d58e0202fe3337a488a1b538c26f76e24 Mon Sep 17 00:00:00 2001 From: techno-express Date: Wed, 26 Sep 2018 10:10:35 -0400 Subject: [PATCH] Create index.php - merged from https://github.com/webdev-kiwi/node.php --- index.php | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 index.php diff --git a/index.php b/index.php new file mode 100644 index 0000000..11c754f --- /dev/null +++ b/index.php @@ -0,0 +1,78 @@ + $value) { + $headers[] = $key . ": " . $value; + } + + curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); + curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $_SERVER["REQUEST_METHOD"]); + + if($_SERVER["REQUEST_METHOD"] === "POST") { + + curl_setopt($curl, CURLOPT_POST, 1); + curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($_POST)); + + } + + $resp = curl_exec($curl); + + if($resp === false) { + + header('HTTP/1.0 404 Not Found'); + exit; + + } else { + + list($head, $body) = explode("\r\n\r\n", $resp, 2); + $headarr = explode("\n", $head); + foreach($headarr as $headval) { + header($headval); + } + echo $body; + + } + + curl_close($curl); +} + +function node_dispatch() { + isset($_GET['path']) ? node_serve($_GET['path']) : node_serve(); +} + +node_dispatch();