Added to your code.

The following code:
Doesn't post if the same one already exists.
Changes the title of the forum thread upon edit.
Upon insertion places a post inside the thread that links back to the original word press post.

Placing: <?php ih_add_comment($post->ID); ?>

in sinple_post.php and index.php allows you to directly link to the forum post from the word press article.


you can get the code here:

click here

This is an old post but I've got updated code.
The code below will create the thread in your punbb installation but it will also update the last post status on the forum index right off the bat and update the post counts for that forum right off the bat.

Things to do today:
1.  Make it to where when you edit a post in the blog it updates the thread in the forums.
2.  When you delete a post in the blog it deletes the thread in the forum (maybe - have to think of usability - blog thread might have started a great discussion that you want to keep)
3.  When you add a comment to the blog it adds it to the forum thread as a reply.

Things for consideration:
1.  If user deletes their comment out of the forum does it delete it out of the blog?  This would require a reverse method as it integrates punbb into WP not WP into punbb.
2.  If user edits their comment in the forum does it edit in the blog?

After considering those two options and other usability items - it might be beneficial to disable manual replies and editing for that forum in punbb and make it to where all that takes place in WP.  This keeps the comments in one place.  (It also makes my work load lighter today haha)
Might get around to those considerations when I have time.

Any rate here's my contribution:
<?php
/*
Plugin Name: Ian's WordPress2PunBB plugin
Plugin URI: http://punbb.org/forums/viewtopic.php?id=8373
Description: Sends a new post to a comment forum in punbb
Version: 0.2
Revision Author: Randall Potter
Revision Author URL: services.randallpotter.com 
Original Author: Ian Huston
Original Author URI: http://www.ianhuston.net
*/

/*Main Wordpress post processing function*/
function ih_wp2punbb( $post_id )
{
//get wordpress options and define variables
$punbb_info = get_option("wp2punbb_info");
$username = $punbb_info[0];
$pun_user['id'] = $punbb_info[2];
$userid = $punbb_info[2];

$fid = $punbb_info[1];
define('PUN_ROOT', $punbb_info[3]);

global $wpdb;
//include punbb functions needed
require PUN_ROOT.'config.php';
require PUN_ROOT.'/include/functions.php';
require PUN_ROOT.'/include/dblayer/common_db.php';

// Start a transaction
$db->start_transaction();


//fetch and process wp data
$postdata = get_postdata($post_id);
$message = $postdata['Content'];
$message = ih_cleanArticle($message);
$subject = $postdata['Title'];
$now = time();


// Create the topic
$db->query('INSERT INTO '.$db->prefix.'topics (poster, subject, posted, last_post, last_poster, forum_id) VALUES(\''.$db->escape($username).'\', \''.$db->escape($subject).'\', '.$now.', '.$now.', \''.$db->escape($username).'\', '.$fid.')') or error('Unable to create topic', __FILE__, __LINE__, $db->error());
$new_tid = $db->insert_id();

// Create the post ("topic post")
$db->query('INSERT INTO '.$db->prefix.'posts (poster, poster_id, poster_ip, message, hide_smilies, posted, topic_id) VALUES(\''.$db->escape($username).'\', '.$pun_user['id'].', \''.$_SERVER['REMOTE_ADDR'].'\', \''.$db->escape($message).'\', \''.$hide_smilies.'\', '.$now.', '.$new_tid.')') or error('Unable to create post', __FILE__, __LINE__, $db->error());

$new_pid = $db->insert_id();

// Update the topic with last_post_id
$db->query('UPDATE '.$db->prefix.'topics SET last_post_id='.$new_pid.' WHERE id='.$new_tid) or error('Unable to update topic', __FILE__, __LINE__, $db->error());

/*not implemented yet due to function conflicts
update_search_index('post', $new_pid, $message, $subject);

update_forum($fid);*/

$low_prio = ($db_type == 'mysql') ? 'LOW_PRIORITY ' : '';
$db->query('UPDATE '.$low_prio.$db->prefix.'users SET num_posts=num_posts+1, last_post='.$now.' WHERE id='.$pun_user['id']) or error('Unable to update user', __FILE__, __LINE__, $db->error());
//$querystring = " ";
$db->query('UPDATE '.$low_prio.$db->prefix.'forums SET num_topics=num_topics+1, last_post='.$now.', last_post_id=\''.$pun_user['id'].'\', last_poster=\''.$db->escape($username).'\' WHERE id=19') or error('Unable to update forum', __FILE__, __LINE__, $db->error());

           

//add custom field to wordpress post
$qry = "INSERT INTO {$wpdb->postmeta} (Post_ID, meta_key, meta_value) VALUES ({$post_id}, 'topicid','{$new_tid}');";

$wpdb->query($qry);

return $post_id;
}


/* Cleans WordPress HTML and adds BBCode.
    This is from NP_PunBB at http://nupusi.com, by Radek HULAN, Bert Garcia and Rickard Andersson. I just removed some Nucleus specific stuff*/
function ih_cleanArticle($article)
    {
        global $CONF;

        // Make sure all linebreaks are \n
        $article = str_replace("\r", "", $article);
        // convert links into bbCode
        $article = preg_replace('/<a(.*?)href=[\'|\"](.*?)[\'|\"]>(.*?)<\/a>/', '$3', $article);

        $article = preg_replace('/<img(.*?)src=[\'|\"](.*?)[\'|\"]>/', '[img]$2[/img]', $article);
        $article = preg_replace('/<%(.*?)%>/', '', $article);
        // do bold, italic and underline
        $article = str_replace(array('<b>', '</b>', '<i>', '</i>', '<u>', '</u>'), array('', '', '', '', '', ''), $article);
        // pre/code into bbCode
        $article = str_replace('<pre>', "

", $article);
        $article = str_replace('</pre>', "

", $article);
        $article = str_replace('<code>', "

", $article);
        $article = str_replace('</code>', "

", $article);
        // blockquote into bbCode
        $article=str_replace('<blockquote>',"

",$article);
        $article=str_replace('</blockquote>',"

",$article);
        // ending tags into line breaks
        $article = str_replace('</p>', "\n\n", $article);
        $article = str_replace("<br />\n", "\n", $article);
        $article = str_replace('<br />', "\n", $article);
        $article = str_replace("<br>\n", "\n", $article);
        $article = str_replace('<br>', "\n", $article);
        $article = str_replace('</li>', "\n", $article);
        // lists
        $article = str_replace('<li>', "* ", $article);
        // headlines in bold
        $article = preg_replace('/<h(.*?)>(.*?)<\/h(.*?)>/', "$2\n", $article);
        // strip all other tags
        $article = trim(strip_tags($article));
        // convert < and > if entered to display code
        $article = str_replace(array('<', '>'), array('<', '>'), $article);

        return $article;
    }

//Adds a link to the relevant forum topic
function ih_add_comment($post_id)
{
    $punbb_info = get_option("wp2punbb_info");
    $forumurl = $punbb_info[4];
    $commentlink = $punbb_info[5];
    $tid = get_post_meta($post_id, 'topicid', TRUE);
    if($tid){
    //echo '| asdf<a href="'.$forumurl.'viewtopic.php?id='.$tid.'">'.$commentlink.'</a>asdf';
    echo ('<a href="'.$forumurl.'viewtopic.php?id='.$tid.'">Discuss in Forum</a> | ');
    }
}

//Wordpress options handler
function ih_add_pages()
{
add_options_page('WP2PunBB', 'WP2PunBB', 8, __FILE__, 'ih_options_page');
}
//Wordpress Options page interface
function ih_options_page()
{
if (isset($_POST['info_update'])) {
    $punbb_info[0]=$_POST['username'];
    $punbb_info[1]=$_POST['forumid'];
    $punbb_info[2]=$_POST['userid'];
    $punbb_info[3]=$_POST['forumdir'];
    $punbb_info[4]=$_POST['forumurl'];
    $punbb_info[5]=$_POST['commentlink'];

    update_option("wp2punbb_info", $punbb_info);
?><div class="updated"><p><strong>Options updated</strong></p></div><?php
    }
$punbb_info = get_option("wp2punbb_info");

?>
<div class=wrap>
  <form method="post">
    <h2>Ians WP2PunBB Plugin</h2>
     <fieldset name="set1">
    <legend>PunBB forum options</legend>
    <h3>PunBB username:<input type=text name="username" value="<?php echo $punbb_info[0];?>" /></h3>
    <h3>PunBB user ID:<input type=text name="userid" value="<?php echo $punbb_info[2];?>" /></h3>
    <h3>PunBB comment forum ID:<input type=text name="forumid" value="<?php echo $punbb_info[1];?>" /></h3>
    <h3>Comment link text:<input type=text name="commentlink" value="<?php echo $punbb_info[5];?>" /></h3>
    <h3>URL to punbb:<input type=text name="forumurl" value="<?php echo $punbb_info[4];?>" /></h3>
    <em>Include final slash e.g. http://www.example.com/forum/</em>
    <h3>Absolute path to punbb:<input type=text name="forumdir" value="<?php echo $punbb_info[3];?>" /></h3>
    <em>Include final slash e.g. /var/www/httpdocs/forum/</em>
     </fieldset>
<div class="submit">
  <input type="submit" name="info_update" value="<?php
    _e('Update options', 'Localization name')
    ?>" /></div>
  </form>
</div>
<?php
}

//Add wordpress plugin hooks
add_action('save_post', 'ih_wp2punbb', 8);
add_action('admin_menu', 'ih_add_pages');
//


forums messed with the code a little:

this is the main change:

update_forum($fid);*/

$low_prio = ($db_type == 'mysql') ? 'LOW_PRIORITY ' : '';
$db->query('UPDATE '.$low_prio.$db->prefix.'users SET num_posts=num_posts+1, last_post='.$now.' WHERE id='.$pun_user['id']) or error('Unable to update user', __FILE__, __LINE__, $db->error());
//$querystring = " ";
$db->query('UPDATE '.$low_prio.$db->prefix.'forums SET num_topics=num_topics+1, last_post='.$now.', last_post_id=\''.$pun_user['id'].'\', last_poster=\''.$db->escape($username).'\' WHERE id=19') or error('Unable to update forum', __FILE__, __LINE__, $db->error());