summaryrefslogtreecommitdiff
path: root/apps/mm/scripts
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2012-01-08 17:45:50 -0800
committerLuke Shumaker <LukeShu@sbcglobal.net>2012-01-08 17:45:50 -0800
commit4c58c41d818918b1690b56f05876d9af642354c0 (patch)
treeb07c0f2925a5753ab3c34379db5c90c5dc38bad1 /apps/mm/scripts
parent83e460cdc3fc09867a3adb48c3d0894579dd3050 (diff)
parent3d64793a1ee45857856be1cd71c3a0a040a3e869 (diff)
add message manager back as another app depending on umummm
Diffstat (limited to 'apps/mm/scripts')
-rw-r--r--apps/mm/scripts/newmail.php36
1 files changed, 36 insertions, 0 deletions
diff --git a/apps/mm/scripts/newmail.php b/apps/mm/scripts/newmail.php
new file mode 100644
index 0000000..e4fc740
--- /dev/null
+++ b/apps/mm/scripts/newmail.php
@@ -0,0 +1,36 @@
+<?php
+// What directory are we in on the server? /////////////////////////////////////
+$_dir_scripts = dirname(__FILE__);
+$_dir_app = dirname($_dir_scripts);
+$_dir_apps = dirname($_dir_app);
+$_dir_base = dirname($_dir_apps);
+require_once($_dir_base.'/stub.php');
+
+$cmdline = isset($argv[0]); // called from the command line
+@$method = $_SERVER['REQUEST_METHOD']; // What HTTP method was used
+if ( ($method=='PUT') || $cmdline ) {
+ // We're going to be uploading a new message.
+
+ // uniqid() isn't 'secure', it doesn't need to be, it's to prevent
+ // random collisions.
+ $tmpfile = "$BASE/tmp/".uniqid(getmypid().'.');
+ $infile = ($cmdline?'php://stdin':'php://input');
+ $out = fopen($tmpfile, "w");
+ $in = fopen($infile, "r");
+ while ($data = fread($in, 1024))
+ fwrite($out, $data);
+ fclose($out);
+ fclose($in);
+
+ require_once('Message.class.php');
+ $msg = Message::add($tmpfile);
+ $id = $msg->msgid();
+
+ if ($cmdline) {
+ echo $id."\n";
+ } else {
+ $m->status('201 Created');
+ header("Location: ".$m->baseUrl().'messages/'.$id);
+ }
+ exit();
+} \ No newline at end of file