Example #1
0
            } else {
                // Notify of new post
                $notification_handler->triggerEvent('thread', $topic_id, 'new_post', $tags);
            }
            $notification_handler->triggerEvent('global', 0, 'new_post', $tags);
            $notification_handler->triggerEvent('forum', $forum, 'new_post', $tags);
            $myts =& MyTextSanitizer::getInstance();
            $tags['POST_CONTENT'] = $myts->stripSlashesGPC($HTTP_POST_VARS['message']);
            $tags['POST_NAME'] = $myts->stripSlashesGPC($HTTP_POST_VARS['subject']);
            $notification_handler->triggerEvent('global', 0, 'new_fullpost', $tags);
        }
        // If user checked notification box, subscribe them to the
        // appropriate event; if unchecked, then unsubscribe
        if (!empty($xoopsUser) && !empty($xoopsModuleConfig['notification_enabled'])) {
            if (!empty($HTTP_POST_VARS['notify'])) {
                $notification_handler->subscribe('thread', $forumpost->getTopicId(), 'new_post');
            } else {
                $notification_handler->unsubscribe('thread', $forumpost->getTopicId(), 'new_post');
            }
        }
        if ($HTTP_POST_VARS['viewmode'] == "flat") {
            redirect_header("viewtopic.php?topic_id=" . $forumpost->topic() . "&post_id=" . $postid . "&order=" . $order . "&viewmode=flat&pid=" . $pid . "&forum=" . $forum . "#forumpost" . $postid . "", 2, _MD_THANKSSUBMIT);
            exit;
        } else {
            $post_id = $forumpost->postid();
            redirect_header("viewtopic.php?topic_id=" . $forumpost->topic() . "&post_id=" . $postid . "&order=" . $order . "&viewmode=thread&pid=" . $pid . "&forum=" . $forum . "#forumpost" . $postid . "", 2, _MD_THANKSSUBMIT);
            exit;
        }
    }
    include XOOPS_ROOT_PATH . '/footer.php';
}
<?php

if (!defined('XOOPS_ROOT_PATH')) {
    exit;
}
// get (object)$forumpost
$forumpost = new ForumPosts(intval(@$_GET['post_id']));
$post_id = intval($forumpost->postid());
if (empty($post_id)) {
    die(_MD_XHNEWBB_ERRORPOST);
}
$topic_id = intval($forumpost->topic());
$forum = intval($forumpost->forum());
// lock check (even admin cannot post into locked topic)
if (xhnewbb_is_locked($topic_id)) {
    die(_MD_XHNEWBB_TOPICLOCKED);
}
 if ($pid == 0) {
     // create a new topic
     $sql = "INSERT INTO " . $xoopsDB->prefix("xhnewbb_topics") . " SET topic_title='" . addslashes($forumpost->subject) . "', topic_poster='" . addslashes($forumpost->uid()) . "', forum_id='{$forum}', topic_time=UNIX_TIMESTAMP(), topic_solved=0";
     if (!$xoopsDB->query($sql)) {
         die(_MD_XHNEWBB_DATABASEERROR);
     }
     $new_topic_id = intval($xoopsDB->getInsertId());
     $new_forum = $forum;
     $sql = "UPDATE " . $xoopsDB->prefix("xhnewbb_posts") . " SET pid=0 WHERE post_id={$post_id}";
     if (!$xoopsDB->query($sql)) {
         die(_MD_XHNEWBB_DATABASEERROR);
     }
 } else {
     // get topic_id from post_id
     $targetpost = new ForumPosts($pid);
     $pid = intval($targetpost->postid());
     // loop check
     if (in_array($pid, $children)) {
         die(_MD_XHNEWBB_ERROR_PIDLOOP);
     }
     $new_forum = intval($targetpost->forum());
     if (empty($pid)) {
         die(_MD_XHNEWBB_ERRORPOST);
     }
     $new_topic_id = intval($targetpost->topic());
     $sql = "UPDATE " . $xoopsDB->prefix("xhnewbb_posts") . " SET pid={$pid} WHERE post_id={$post_id}";
     if (!$xoopsDB->query($sql)) {
         die(_MD_XHNEWBB_DATABASEERROR);
     }
 }
 foreach ($children as $child_post_id) {