summaryrefslogtreecommitdiff
path: root/endpoint.php
diff options
context:
space:
mode:
Diffstat (limited to 'endpoint.php')
-rw-r--r--endpoint.php36
1 files changed, 36 insertions, 0 deletions
diff --git a/endpoint.php b/endpoint.php
new file mode 100644
index 0000000..e133c90
--- /dev/null
+++ b/endpoint.php
@@ -0,0 +1,36 @@
+<?php
+$id = $_SERVER["PATH_INFO"];
+$match = preg_match('/^\/[0-9a-zA-Z]+$/', $id);
+if($match == 0 || $match == FALSE) {
+ header("HTTP/1.1 500 Invalid/missing parameter 'id'.");
+ exit(0);
+}
+
+$id = substr($id, 1);
+
+$filename = "/tmp/mq/endpoint." . $id . ".log";
+
+$fd = fopen($filename, "a");
+fwrite($fd, date(DateTime::ATOM));
+fwrite($fd, "\n");
+foreach($_SERVER as $key => $value) {
+ if(strpos($key, "HTTP_") === 0) {
+ $key = str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($key, 5)))));
+ fwrite($fd, $key . ": ". $value . "\n");
+ }
+}
+$content_type = $_SERVER["CONTENT_TYPE"];
+if(isset($content_type)) {
+ fwrite($fd, "Content-Type: ". $content_type . "\n");
+}
+
+$content_length = $_SERVER["CONTENT_LENGTH"];
+if(isset($content_length)) {
+ fwrite($fd, "Content-Length: ". $content_length . "\n");
+}
+fwrite($fd, "\n");
+fflush($fd);
+fclose($fd);
+
+header("HTTP/1.1 200 Stored message for endpoint '" . $id . "'.");
+?>