summaryrefslogtreecommitdiff
path: root/src/M2F.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/M2F.php')
-rw-r--r--src/M2F.php78
1 files changed, 0 insertions, 78 deletions
diff --git a/src/M2F.php b/src/M2F.php
deleted file mode 100644
index a8d2749..0000000
--- a/src/M2F.php
+++ /dev/null
@@ -1,78 +0,0 @@
-<?php
-
-try {
- require_once(__DIR__ . '/Bridge.php');
- require_once(__DIR__ . '/MailmanLib.php');
- require_once(__DIR__ . '/MailmanMessage.php');
- require_once(__DIR__ . '/PhpBB3.php');
-
- # Read the message from STDIN
- $url = 'php://stdin';
-
- $input = read_raw_message($url);
- $msg = new MailmanMessage($input);
-
- $messageId = $msg->getMessageId();
- $inReplyTo = $msg->getInReplyTo();
- $rererences = $msg->getReferences();
-
- $bridge = new Bridge();
- $seen = !$bridge->registerMessage(null, $messageId, $inReplyTo);
-
- try {
- if ($seen) {
- # This message has already been processed, bail out
- print 'Message id already seen, skipping: ' . $messageId . "\n";
- exit;
- }
-
- $phpbb = new PhpBB3();
-
- $forumId = $topicId = -1;
- $postType = null;
-
- if ($inReplyTo) {
- # Possibly a reply to an existing topic
- $parentId = $bridge->getPostId($inReplyTo);
- if ($parentId === false) {
- throw new Exception('unrecognized reply-to: ' . $inReplyTo);
- }
-
- $ids = $phpbb->getTopicAndForumIds($parentId);
- if ($ids === false) {
- throw new Exception('unrecognized parent id: ' . $parentId);
- }
-
- # Found the parent's forum and topic, post to those
- $forumId = $ids['forum_id'];
- $topicId = $ids['topic_id'];
- $postType = 'reply';
- }
- else {
- # A message starting a new topic, post to default forum for its source
- $forumId = $bridge->getDefaultForumId($msg->getSource());
- if ($forumId === false) {
- throw new Exception('unrecognized source: ' . $msg->getSource());
- }
-
- $postType = 'post';
- }
-
-# FIXME: the subject and body may be charset encoded---need to decode these
-# before posting!
-
- # Post the message to the forum
- $postId = $phpbb->postMessage($postType, $forumId, $topicId, $msg);
- $bridge->setPostId($messageId, $postId);
- }
- catch (Exception $e) {
- # Bridging failed, unregister message.
- $bridge->unregisterMessage($messageId);
- throw $e;
- }
-}
-catch (Exception $e) {
- print "$e\n";
-}
-
-?>