<?php include_once '../../../includes/user.php'; include_once '../../../includes/topic.php'; include_once '../../../includes/thread.php'; include_once '../../../includes/post.php'; include_once '../../../includes/parsedown.php'; include_once '../../../includes/permissions.php'; session_start(); if (isset($_SESSION['user'])) { if (has_permission($_SESSION['user'], 'CREATE_TOPIC')) { if (isset($_POST['create-topic'])) { if (isset($_GET['id'])) { $topic_id = create_topic($_POST['title'], get_topic_by_id($_GET['id'])); header("HTTP/1.1 303 See Other"); header("Location: /forum/topic/?id=" . $topic_id); } else { $topic_id = create_topic($_POST['title']); header("HTTP/1.1 303 See Other"); header("Location: /forum/topic/?id=" . $topic_id); } } else { header("HTTP/1.1 400 Bad Request"); } } else { header("HTTP/1.1 403 Forbidden"); } } else { header("HTTP/1.1 403 Forbidden"); }
} check_flood($errors); if ($dirs[2] == 'forum' && trim($_POST['subject']) == '') { $errors[] = translate('blanksubject'); } if (trim($_POST['message']) == '') { $errors[] = translate('blankmsg'); } $continue_posting = ExtensionConfig::run_hooks('check-post', array('type' => $dirs[2] == 'forum' ? 'topic' : 'reply', 'subject' => isset($_POST['subject']) ? $_POST['subject'] : '', 'message' => $_POST['message'], 'topic_id' => $dirs[3] == 'topic' ? intval($dirs[2]) : '', 'forum_id' => $dirs[3] == 'forum' ? intval($dirs[2]) : '')); if (!$continue_posting && empty($errors)) { $errors[] = translate('unknownerror'); } // New post + new topic if ($dirs[2] == 'forum' && empty($errors) && !isset($_POST['preview'])) { $fid = intval($dirs[3]); $topic_url = create_topic($_POST['subject'], $_POST['message'], $futurebb_user['id'], $fid, isset($_POST['hidesmilies'])); ExtensionConfig::run_hooks('new_topic', array('subject' => $_POST['subject'], 'message' => $_POST['message'], 'poster' => $futurebb_user['username'], 'forum_url' => $forum_info['url'], 'forum' => $forum_info['name'], 'topic_url' => $topic_url)); redirect($base_config['baseurl'] . '/' . $forum_info['url'] . '/' . $topic_url); } else { if ($dirs[2] == 'topic' && empty($errors) && !isset($_POST['preview'])) { //new post $tid = intval($dirs[3]); $parsedtext = BBCodeController::parse_msg($_POST['message'], !isset($_POST['hidesmilies']), $futurebb_config['enable_bbcode']); $db->query('INSERT INTO `#^posts`(poster,poster_ip,content,parsed_content,posted,topic_id,disable_smilies) VALUES(' . $futurebb_user['id'] . ',\'' . $db->escape($_SERVER['REMOTE_ADDR']) . '\',\'' . $db->escape($_POST['message']) . '\',\'' . $db->escape($parsedtext) . '\',' . time() . ',' . $tid . ',' . intval(isset($_POST['hidesmilies'])) . ')') or error('Failed to make first post', __FILE__, __LINE__, $db->error()); $pid = $db->insert_id(); // Let's take a break to fire any notifications from @ tags if ($futurebb_config['allow_notifications'] == 1) { if (preg_match_all('%@([a-zA-Z0-9_\\-]+)%', $parsedtext, $matches)) { array_slice($matches[1], 0, 8); foreach ($matches[1] as $tagged_user) { $tagged_res = $db->query('SELECT id, block_notif FROM `#^users` WHERE username = \'' . $tagged_user . '\'') or error('Failed to find users to tag', __FILE__, __LINE__, $db->error());
echo $lang['Nothing_to_do']; } // Check for texts without a post echo "<p class=\"gen\"><b>" . $lang['Checking_texts_wo_post'] . "</b></p>\n"; $sql = "SELECT pt.post_id, pt.bbcode_uid, pt.post_text\n\t\t\t\t\tFROM " . POSTS_TEXT_TABLE . " pt\n\t\t\t\t\t\tLEFT JOIN " . POSTS_TABLE . " p ON pt.post_id = p.post_id\n\t\t\t\t\tWHERE p.post_id IS NULL"; $result = $db->sql_query($sql); if (!$result) { throw_error("Couldn't get post and text data!", __LINE__, __FILE__, $sql); } while ($row = $db->sql_fetchrow($result)) { if (!$list_open) { echo "<p class=\"gen\">" . $lang['Invalid_texts_found'] . ":</p>\n"; echo "<font class=\"gen\"><ul>\n"; $list_open = TRUE; $new_forum = create_forum(); $new_topic = create_topic(); $enable_html = $board_config['allow_html']; $enable_smilies = $board_config['allow_smilies']; } $enable_bbcode = $board_config['allow_bbcode'] && $row['bbcode_uid'] != '' ? 1 : 0; echo "<li>" . sprintf($lang['Recreating_post'], $row['post_id'], $lang['New_topic_name'], $lang['New_forum_name'], substr(htmlspecialchars(strip_tags($row['post_text'])), 0, 30)) . "</li>\n"; $sql2 = "INSERT INTO " . POSTS_TABLE . ' (post_id, topic_id, forum_id, poster_id, post_time, poster_ip, post_username, enable_bbcode, enable_html, enable_smilies, enable_sig, post_edit_time, post_edit_count) VALUES (' . $row['post_id'] . ", {$new_topic}, {$new_forum}, " . ANONYMOUS . ', ' . time() . ', \'\', \'' . $lang['New_poster_name'] . "', {$enable_bbcode}, {$enable_html}, {$enable_smilies}, 0, NULL, 0)"; $result2 = $db->sql_query($sql2); if (!$result2) { throw_error("Couldn't update post information!", __LINE__, __FILE__, $sql2); } } $db->sql_freeresult($result); if ($list_open) { echo "</ul></font>\n";
update_programming_language($pl_id, Flight::request()); }); Flight::route('DELETE /programming_languages/@pl_id', function ($pl_id) { incl('delete_programming_language'); delete_programming_language($pl_id, Flight::request()); }); Flight::route('GET /programming_languages/@pl_id', function ($pl_id) { incl('get_programming_language'); get_programming_language($pl_id, Flight::request()); }); Flight::route('/programming_languages/@pl_id', function ($pl_id) { method_not_allowed(); }); Flight::route('POST /topics', function () { incl('create_topic'); create_topic(Flight::request()); }); Flight::route('GET /topics', function () { incl('get_topics'); get_topics(Flight::request()); }); Flight::route('/topics', function () { method_not_allowed(); }); Flight::route('GET /topics/@topic_id', function ($topic_id) { incl('get_topic'); get_topic($topic_id, Flight::request()); }); Flight::route('DELETE /topics/@topic_id', function ($topic_id) { incl('delete_topic'); delete_topic($topic_id, Flight::request());