function ipb_make_post($forum_id, $forum_subj, $forum_post, $poster_id = 0, $update_old_topic = true) { global $ipb_prefix, $THIS_BASEPATH, $btit_settings, $registry, $DBDT; if ($poster_id == 0) { if (isset($btit_settings["ipb_autoposter"]) && $btit_settings["ipb_autoposter"] != 0) { $poster_id = (int) (0 + $btit_settings["ipb_autoposter"]); } else { return; } } if (!isset($THIS_BASEPATH) || empty($THIS_BASEPATH)) { $THIS_BASEPATH = str_replace(array("\\", "/include"), array("/", ""), dirname(__FILE__)); } if (!defined('IPS_ENFORCE_ACCESS')) { define('IPS_ENFORCE_ACCESS', true); } if (!defined('IPB_THIS_SCRIPT')) { define('IPB_THIS_SCRIPT', 'public'); } if (!isset($registry) || empty($registry)) { require_once $THIS_BASEPATH . '/ipb/initdata.php'; require_once IPS_ROOT_PATH . 'sources/base/ipsRegistry.php'; require_once IPS_ROOT_PATH . 'sources/base/ipsController.php'; $registry = ipsRegistry::instance(); $registry->init(); } require_once IPSLib::getAppDir('forums') . '/sources/classes/post/classPost.php'; $classPost = new classPost($registry); $old_topic = false; $clean_subj = trim($forum_subj, "'"); $clean_post = trim($forum_post, "'"); $forum = ipsRegistry::getClass('class_forums')->forum_by_id[$forum_id]; $classPost->setForumID($forum_id); $classPost->setForumData($forum); $classPost->setAuthor($poster_id); $classPost->setPostContentPreFormatted($clean_post); $classPost->setPublished(TRUE); if ($update_old_topic === false) { $mycount = 0; } else { $res = get_result("SELECT `t`.* FROM `{$ipb_prefix}topics` `t` LEFT JOIN `{$ipb_prefix}posts` `p` ON `t`.`tid`=`p`.`topic_id` WHERE `t`.`forum_id`=" . $forum_id . " AND `t`.`title`='" . mysqli_real_escape_string($DBDT, $clean_subj) . "' AND `t`.`last_post`=`p`.`post_date` AND `t`.`last_poster_id`=`p`.`author_id`"); $mycount = count($res); } if ($mycount > 0) { $topic = $res[0]; $topicID = $topic["tid"]; $classPost->setTopicID($topicID); $classPost->setTopicData($topic); $classPost->addReply(); } else { $topic = get_result("SELECT MAX(`tid`)+1 `tid` FROM `{$ipb_prefix}topics`"); $topicID = $topic[0]["tid"]; $classPost->setTopicID($topicID); $classPost->setTopicTitle($clean_subj); $classPost->addTopic(); } return $topicID; }