summaryrefslogtreecommitdiff
path: root/endpoint.php
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2012-03-13 15:25:25 +0000
committerTrygve Laugstøl <trygvis@inamo.no>2012-03-13 15:25:25 +0000
commite67fa24d3c21792b3adab3f88e2383219018b696 (patch)
treeef1ab28143ef4f1007ec37926e84ace786ed045e /endpoint.php
downloadhttp-mq-e67fa24d3c21792b3adab3f88e2383219018b696.tar.gz
http-mq-e67fa24d3c21792b3adab3f88e2383219018b696.tar.bz2
http-mq-e67fa24d3c21792b3adab3f88e2383219018b696.tar.xz
http-mq-e67fa24d3c21792b3adab3f88e2383219018b696.zip
o Initial import.
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 . "'.");
+?>