function discussion_forum_post_create($post, $options) { $post['author'] = isset($post['author']) ? $post['author'] : $_SESSION['login']['id']; if ($post['author'] < 1) { die('Fatal error at line #' . __LINE__ . ', no author set'); } if ($post['mode'] == 'new_thread' && strlen($post['title']) == 0) { die('Fatal error at line #' . __LINE__ . ', no title set'); } if (strlen($post['content']) <= 3) { die('Mer än så där får du allt skriva!'); } if (content_check($post['content']) != 1) { die(content_check($post['content'])); } $post['timestamp'] = isset($post['timestamp']) ? $post['timestamp'] : time(); $post['handle'] = isset($post['title']) ? discussion_forum_post_handle($post['title']) : ''; $post['forum_type'] = isset($post['forum_type']) ? $post['forum_type'] : 'public_forum'; $post['child_count'] = $post['mode'] == 'new_thread' ? 1 : 0; $post['anonymous'] = $post['anonymous'] == 1 ? 1 : 0; $post['fp_module_id'] = isset($post['fp_module_id']) ? $post['fp_module_id'] : 0; $query = 'INSERT INTO forum_posts (handle, author, timestamp, parent_post, forum_id, forum_type'; $query .= ', title, content, child_count, anonymous, fp_module_id)'; $query .= ' VALUES("' . $post['handle'] . '", "' . $post['author'] . '", "' . $post['timestamp'] . '"'; $query .= ', "' . $post['parent_post'] . '", "' . $post['forum_id'] . '", "' . $post['forum_type'] . '"'; $query .= ', "' . $post['title'] . '", "' . $post['content'] . '", "' . $post['child_count'] . '"'; $query .= ', "' . $post['anonymous'] . '", "' . $post['fp_module_id'] . '")'; mysql_query($query) or report_sql_error($query, __FILE__, __LINE__); $post_id = mysql_insert_id(); if ($post['parent_post'] > 0) { $query = 'UPDATE forum_posts SET child_count = child_count + 1, last_post = "' . $post_id . '", last_post_timestamp = "' . time() . '" WHERE id = "' . $post['parent_post'] . '" LIMIT 1'; mysql_query($query) or report_sql_error($query, __FILE__, __LINE__); } if ($post['mode'] == 'new_thread') { $query = 'UPDATE public_forums SET thread_count = thread_count + 1, post_count = post_count + 1, last_thread = "' . $post_id . '" WHERE id = "' . $post['forum_id'] . '"'; mysql_query($query) or report_sql_error($query, __FILE__, __LINE__); $query = 'UPDATE forum_posts SET last_post = "' . $post_id . '", parent_post = "' . $post_id . '", last_post_timestamp = "' . time() . '" WHERE id = "' . $post_id . '" LIMIT 1'; mysql_query($query) or report_sql_error($query, __FILE__, __LINE__); } else { $query = 'UPDATE public_forums SET post_count = post_count + 1, last_post = "' . $post_id . '" WHERE id = "' . $post['forum_id'] . '"'; mysql_query($query) or report_sql_error($query, __FILE__, __LINE__); } discussion_forum_parse_input(array('text' => $post['content'], 'post_id' => $post_id, 'author' => $post['author'], 'title' => $post['title'])); if ($post['mode'] == 'new_thread') { forum_thread_cache_latest_threads(); } else { forum_latest_posts_cache(); } if ($post['mode'] == 'new_thread' && $post['forum_id'] == 82) { forum_thread_cache_latest_open_source_threads(); } $query = 'SELECT quality_level FROM public_forums WHERE id = "' . $post['forum_id'] . '" LIMIT 1'; $data = query_cache(array('category' => 'forum_categories', 'query' => $query, 'max_delay' => 3600)); if ($data[0]['quality_level'] == 1) { $query = 'UPDATE userinfo SET forum_spam = forum_spam + 1 WHERE userid = "' . $_SESSION['login']['id'] . '" LIMIT 1'; mysql_query($query) or report_sql_error($query, __FILE__, __LINE__); } else { $query = 'UPDATE userinfo SET forum_posts = forum_posts + 1 WHERE userid = "' . $_SESSION['login']['id'] . '" LIMIT 1'; mysql_query($query) or report_sql_error($query, __FILE__, __LINE__); } $_SESSION['forum']['last_post_timestamp'] = time(); return $post_id; }
<?php forum_thread_cache_latest_threads();