From a9880643f1adebb81112835d665fb8b5b6904491 Mon Sep 17 00:00:00 2001 From: uckelman Date: Sun, 11 Apr 2010 18:52:32 +0000 Subject: Print exception stack traces. git-svn-id: https://vassalengine.svn.sourceforge.net/svnroot/vassalengine/site-src/trunk@6668 67b53d14-2c14-4ace-a08f-0dab2b34000c --- src/M2F.php | 99 ++++++++++++++++++++++++++++++++----------------------------- 1 file changed, 52 insertions(+), 47 deletions(-) (limited to 'src') diff --git a/src/M2F.php b/src/M2F.php index 8318461..d28c450 100644 --- a/src/M2F.php +++ b/src/M2F.php @@ -1,53 +1,58 @@ getMessageId(); -$inReplyTo = $msg->getInReplyTo(); -$rererences = $msg->getReferences(); - -$seen = !$bridge->registerMessage($messageId, $inReplyTo, $references); - -if ($seen) { - # This message has already been processed. - print 'Message id already seen, skipping: ' . $messageId . "\n"; - exit; +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); + + $bridge = new Bridge(); + + $messageId = $msg->getMessageId(); + $inReplyTo = $msg->getInReplyTo(); + $rererences = $msg->getReferences(); + + $seen = !$bridge->registerMessage($messageId, $inReplyTo, $references); + + if ($seen) { + # This message has already been processed. + print 'Message id already seen, skipping: ' . $messageId . "\n"; + exit; + } + + $phpbb = new PhpBB3(); + + $forumId = $topicId = -1; + $postType = null; + + if ($inReplyTo) { + # A reply to an existing topic + # FIXME: we don't want exceptions here? + $parentId = $bridge->getPostId($inReplyTo); + $ids = $phpbb->getTopicAndForumIds($parentId); + $forumId = $ids['forum_id']; + $topicId = $ids['topic_id']; + $postType = 'reply'; + } + else { + # A message starting a new topic + $forumId = $bridge->getDefaultForumId($msg->getSource()); + $postType = 'post'; + } + + # Post the message to the forum + $phpbb->postMessage($postType, $forumId, $topicId, $msg); + + $bridge->setPostId($messageId, $postId); } - -$phpbb = new PhpBB3(); - -$forumId = $topicId = -1; -$postType = null; - -if ($inReplyTo) { - # A reply to an existing topic -# FIXME: we don't want exceptions here? - $parentId = $bridge->getPostId($inReplyTo); - $ids = $phpbb->getTopicAndForumIds($parentId); - $forumId = $ids['forum_id']; - $topicId = $ids['topic_id']; - $postType = 'reply'; +catch (Exception $e) { + print $e->getTraceAsString(); } -else { - # A message starting a new topic - $forumId = $bridge->getDefaultForumId($msg->getSource()); - $postType = 'post'; -} - -# Post the message to the forum -$phpbb->postMessage($postType, $forumId, $topicId, $msg); - -$bridge->setPostId($messageId, $postId); ?> -- cgit v1.2.3