Example #1
0
 require_once INCLUDES . "flood_include.php";
 // all data is sanitized here.
 if (!flood_control("post_datestamp", DB_FORUM_POSTS, "post_author='" . $userdata['user_id'] . "'")) {
     // have notice
     // get the forum data.
     // run permissions for posting
     //
     if (PHPFusion\Forums\Functions::verify_forum($thread_data['forum_id'])) {
         $forum = new PHPFusion\Forums\Forum();
         $forum_data = dbarray(dbquery("SELECT f.*, f2.forum_name AS forum_cat_name\n\t\t\t\t\tFROM " . DB_FORUMS . " f\n\t\t\t\t\tLEFT JOIN " . DB_FORUMS . " f2 ON f.forum_cat=f2.forum_id\n\t\t\t\t\tWHERE f.forum_id='" . intval($thread_data['forum_id']) . "'\n\t\t\t\t\tAND " . groupaccess('f.forum_access') . "\n\t\t\t\t\t"));
         if ($forum_data['forum_type'] == 1) {
             redirect(INFUSIONS . "forum/index.php");
         }
         define_forum_mods($forum_data);
         // Use the new permission settings
         $forum->setForumPermission($forum_data);
         $permission = $forum->getForumPermission();
         $forum_data['lock_edit'] = $forum_settings['forum_edit_lock'] == 1 ? TRUE : FALSE;
         if ($permission['can_post'] && $permission['can_access']) {
             $post_data['forum_cat'] = $forum_data['forum_cat'];
             // create a new thread.
             dbquery_insert(DB_FORUM_THREADS, $thread_data, 'save', array('primary_key' => 'thread_id', 'keep_session' => TRUE));
             $post_data['thread_id'] = dblastid();
             dbquery_insert(DB_FORUM_POSTS, $post_data, 'save', array('primary_key' => 'post_id', 'keep_session' => TRUE));
             $post_data['post_id'] = dblastid();
             dbquery("UPDATE " . DB_USERS . " SET user_posts=user_posts+1 WHERE user_id='" . $post_data['post_author'] . "'");
             // Update stats in forum and threads
             // find all parents and update them
             $list_of_forums = get_all_parent(dbquery_tree(DB_FORUMS, 'forum_id', 'forum_cat'), $post_data['forum_id']);
             foreach ($list_of_forums as $fid) {
                 dbquery("UPDATE " . DB_FORUMS . " SET forum_lastpost='" . time() . "', forum_postcount=forum_postcount+1, forum_threadcount=forum_threadcount+1, forum_lastpostid='" . $post_data['post_id'] . "', forum_lastuser='******'post_author'] . "' WHERE forum_id='" . $fid . "'");