So this is what I did from the code I found in post.php.
It does post a topic, but I want to know if it is correctly done.
I have no idea what $fid is.
require(PUN_ROOT . 'include/search_idx.php');
$fid = 1;//isset($_GET['fid']) ? intval($_GET['fid']) : 0;
$now = time();
$hide_smilies = 1;
$subject = "test subject";
$message = "test message";
// 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'] . ', \'' . get_remote_address() . '\', \'' . $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());
update_search_index('post', $new_pid, $message, $subject);
update_forum($fid);