summaryrefslogtreecommitdiff
path: root/src/controllers/NewMessage.class.php
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2011-09-04 21:13:47 -0400
committerLuke Shumaker <LukeShu@sbcglobal.net>2011-09-04 21:13:47 -0400
commitad4a7ff9159c2c64cea98d7189f46fa7d6174fc2 (patch)
tree508f971f1dbc6c6f01207426c675542b55e0333e /src/controllers/NewMessage.class.php
parentf3b3ea69fb46e45bf3598aa7a6bcf62aa80e4703 (diff)
Screw it, I'm tired of trying to break this into individual commits
Diffstat (limited to 'src/controllers/NewMessage.class.php')
-rw-r--r--src/controllers/NewMessage.class.php37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/controllers/NewMessage.class.php b/src/controllers/NewMessage.class.php
new file mode 100644
index 0000000..e778385
--- /dev/null
+++ b/src/controllers/NewMessage.class.php
@@ -0,0 +1,37 @@
+<?php
+ /*
+class NewMessage extends Controller {
+$cmdline = isset($argv[0]); // called from the command line
+@$method = $_SERVER['REQUEST_METHOD']; // What HTTP method was used
+if ( ($method=='PUT') || ($method=='POST') || $cmdline ) {
+ // We're going to be uploading a new message.
+
+ // so 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);
+ //apache_request_headers()
+ require_once('MimeMailParser.class.php');
+ $parser = new MimeMailParser();
+ $parser->setPath($tmpfile);
+ $id = preg_replace('/<(.*)>/', '$1',
+ $parser->getHeader('message-id'));
+ $id = str_replace('/', '', $id); // for security reasons
+ $msg_file = "$BASE/msg/$id";
+ rename($tmpfile, $msg_file);
+
+ if (!$cmdline) {
+ $m->status('201 Created');
+ header("Location: ".$m->baseUrl().'messages/'.$id);
+ }
+ exit();
+}
+
+}
+ */ \ No newline at end of file