Your true you can replace everything, but then it's in my mind an easier way to do without the include thing.
I will post the code here so that you can see how did I solved it.
function punbb_publish_post($id)
{
global $wpdb;
$wppost = $wpdb->get_row("SELECT ID, post_date, post_title, post_content FROM ".$wpdb->posts." WHERE ID = ".$id." LIMIT 1");
/* Check if edited or new */
$wppost_check = $wpdb->get_row("SELECT id, topic_id FROM ".PUNPREFIX."posts WHERE poster = 'Greenday' AND posted = ".strtotime($wppost->post_date));
if($wppost_check)
{
$wpdb->query("UPDATE ".PUNPREFIX."topics SET subject = '".$wppost->post_title."' WHERE id = ".$wppost_check->topic_id);
$wpdb->query("UPDATE ".PUNPREFIX."posts SET message = '".$wppost->post_content."' WHERE id = ".$wppost_check->id);
}
/*If New */
else {
$wpdb->query("INSERT INTO ".PUNPREFIX."topics (poster, subject, posted, last_post, last_poster, forum_id) VALUES(
'Greenday',
'".$wppost->post_title."',
".strtotime($wppost->post_date).",
".strtotime($wppost->post_date).",
'Greenday',
1)");
$topic_id = $wpdb->insert_id;
$wpdb->query("INSERT INTO ".PUNPREFIX."posts (poster, poster_id, message, posted, topic_id, poster_ip) VALUES(
'Greenday',
2,
'".$wppost->post_content."',
".strtotime($wppost->post_date).",
".$topic_id.",
'192.168.0.1'
)");
$post_id = $wpdb->insert_id;
$wpdb->query("UPDATE ".PUNPREFIX."topics SET last_post_id = ".$post_id.", first_post_id = ".$post_id." WHERE id = ".$topic_id);
$wpdb->query("UPDATE ".PUNPREFIX."forums SET last_post = ".strtotime($wppost->post_date).", last_post_id = ".$post_id.", last_poster = 'Greenday' WHERE id = 1");
$punbb_postnumber = $wpdb->get_row("SELECT num_posts, username FROM ".PUNPREFIX."users WHERE username = 'Greenday' LIMIT 1");
$wpdb->query("UPDATE ".PUNPREFIX."users SET num_posts = ".$punbb_postnumber->num_posts."+1 WHERE username = 'Greenday'");
/* Puts a Link to the forum topic in the post */
$wp_add = "<p>Diskutiere <a href=\"/\" title=\"Link zum Topic im Forum\">hier. -></a></p>";
$wp_content = $wppost->post_content.$wp_add;
}
}
How I said thats maybe not the best solution, but it's working very well for now.
Should be nearly the same what the function does.