summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoruckelman <uckelman@nomic.net>2010-07-15 13:25:11 +0000
committeruckelman <uckelman@nomic.net>2010-07-15 13:25:11 +0000
commitca20fcce0798ebd6300722d5e9f7100551f47c99 (patch)
treee53c382f2994454d5d13ab7037709903ae1830a8 /src
parent7d9bae3106d2e941e75930ab4e70b9f4117aed0d (diff)
Added logging.
git-svn-id: https://vassalengine.svn.sourceforge.net/svnroot/vassalengine/site-src/trunk@6990 67b53d14-2c14-4ace-a08f-0dab2b34000c
Diffstat (limited to 'src')
-rw-r--r--src/forum_post_send.php7
-rw-r--r--src/list_post_receive.php56
2 files changed, 46 insertions, 17 deletions
diff --git a/src/forum_post_send.php b/src/forum_post_send.php
index aa86422..d179226 100644
--- a/src/forum_post_send.php
+++ b/src/forum_post_send.php
@@ -15,6 +15,9 @@ catch (Exception $e) {
function send_post_to_lists($config, $user, $mode, $data, $post_data) {
+ require_once('Log.php');
+ $logger = &Log::singleton('file', '/var/log/listbridge', 'test2');
+
/*
print '<p>';
var_dump($data);
@@ -37,6 +40,8 @@ function send_post_to_lists($config, $user, $mode, $data, $post_data) {
$postId = $data['post_id'];
$forumId = $data['forum_id'];
+ $logger->info($postId . ' received from phpBB forum ' . $forumId);
+
$bridge = new Bridge();
$to = $bridge->getLists($forumId);
@@ -205,6 +210,8 @@ EOF;
if (PEAR::isError($err)) {
throw new Exception('Mail::send error: ' . $err->toString());
}
+
+ $logger->info($postId . ' sent to ' . $to . ' as ' . $messageId);
}
catch (Exception $e) {
# Bridging failed, unregister message.
diff --git a/src/list_post_receive.php b/src/list_post_receive.php
index 5343ec6..9de0174 100644
--- a/src/list_post_receive.php
+++ b/src/list_post_receive.php
@@ -3,32 +3,44 @@
# TODO: logging!
# TODO: Refactor postMessage().
+require_once('Log.php');
+$logger = &Log::singleton('file', '/var/log/listbridge', 'test2');
+
try {
- require_once(__DIR__ . '/Bridge.php');
- require_once(__DIR__ . '/MailmanLib.php');
- require_once(__DIR__ . '/MailmanMessage.php');
- require_once(__DIR__ . '/PhpBB3.php');
+ require_once('/var/www/bridge/src/Bridge.php');
+ require_once('/var/www/bridge/src/MailmanLib.php');
+ require_once('/var/www/bridge/src/MailmanMessage.php');
+ require_once('/var/www/bridge/src/PhpBB3.php');
# Read the message from STDIN
- $url = 'php://stdin';
+# $url = 'php://stdin';
- $input = read_raw_message($url);
- $msg = new MailmanMessage($input);
+# $input = read_raw_message($url);
+# $msg = new MailmanMessage($input);
+
+ if (!isset($_POST['message'])) {
+ throw new Exception('No message in POST');
+ }
+
+ $msg = new MailmanMessage($_POST['message']);
$messageId = $msg->getMessageId();
$inReplyTo = $msg->getInReplyTo();
$rererences = $msg->getReferences();
+ $soruce = $msg->getSource();
+ $logger->info($messageId . ' received from ' . $source);
+
$bridge = new Bridge();
$editId = $bridge->registerByMessageId($messageId, $inReplyTo);
-
+
+ if ($editId === false) {
+ # This message has already been processed, bail out
+ $logger->info($messageId . ' already seen, skipping');
+ exit;
+ }
+
try {
- if ($editId === false) {
- # This message has already been processed, bail out
- print 'Message id already seen, skipping: ' . $messageId . "\n";
- exit;
- }
-
$phpbb = new PhpBB3();
$forumId = $topicId = null;
@@ -50,20 +62,29 @@ try {
$forumId = $ids['forum_id'];
$topicId = $ids['topic_id'];
$postType = 'reply';
+
+ $logger->info($messageId . ' replies to ' . $parentId);
}
else {
# A message starting a new topic, post to default forum for its source
- $forumId = $bridge->getDefaultForumId($msg->getSource());
+ $forumId = $bridge->getDefaultForumId($source);
if ($forumId === false) {
- throw new Exception('unrecognized source: ' . $msg->getSource());
+ throw new Exception('unrecognized source: ' . $source);
}
$postType = 'post';
+
+ $logger->info($messageId . ' is a new post');
}
+
+ $logger->info(
+ $messageId . ' will be posted to ' . $forumId . ':' . $topicId);
# Post the message to the forum
$postId = $phpbb->postMessage($postType, $forumId, $topicId, $msg);
$bridge->setPostId($messageId, $postId);
+
+ $logger->info($messageId . ' posted as ' . $postId);
}
catch (Exception $e) {
# Bridging failed, unregister message.
@@ -72,7 +93,8 @@ try {
}
}
catch (Exception $e) {
- print "$e\n";
+ $logger->err($e);
+ error_log($e);
}
?>