diff options
Diffstat (limited to 'thread.php')
-rw-r--r-- | thread.php | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -5,8 +5,8 @@ include_once 'includes/db_inc.php'; function add_quote($dbc, $thread_id, $matches) { foreach ($matches as $match) { - $id = (int) filter_var($match, FILTER_SANITIZE_NUMBER_INT); - $sql = "SELECT post_content, post_author, user_name FROM posts LEFT JOIN users ON post_author = user_id WHERE post_thread = " . $thread_id . " LIMIT 1 OFFSET " . $id - 1; + $id = (int) filter_var($match, FILTER_SANITIZE_NUMBER_INT) - 1; + $sql = "SELECT post_content, post_author, user_name FROM posts LEFT JOIN users ON post_author = user_id WHERE post_thread = " . $thread_id . " LIMIT 1 OFFSET " . $id; $result = mysqli_query($dbc, $sql); if (!$result) { @@ -15,7 +15,7 @@ function add_quote($dbc, $thread_id, $matches) { $reply = mysqli_fetch_assoc($result); - return '<blockquote><a href="#' . $id .'">Quote from ' . $reply['user_name'] . '</a><br>' . $reply['post_content'] . '</blockquote>'; + return '<blockquote><a href="#' . $id + 1 .'">Quote from ' . $reply['user_name'] . '</a><br>' . $reply['post_content'] . '</blockquote>'; } } @@ -64,6 +64,14 @@ if (mysqli_num_rows($result) == 0) { return add_quote($dbc, $thread_id, $matches); }, $post_content); + $post_content = preg_replace( + "/\s*[a-zA-Z\/\/:\.]*youtu(be.com\/watch\?v=|.be\/)([a-zA-Z0-9\-_]+)([a-zA-Z0-9\/\*\-\_\?\&\;\%\=\.]*)/i", + '<br><iframe class="youtube-embed" src="//www.youtube.com/embed/$2" allowfullscreen></iframe>', $post_content); + + $post_content = preg_replace('/(https?:\/\/[^ ]+?(?:\.jpg|\.png|\.gif))/', '<img class="image-embed" src="$1" alt="$1" />', $post_content); + + $post_content = preg_replace('@\b(http(s)?://)?([^\s]*?(?:\.[a-z\d?=/_-]+)+)(?![^<]*?(?:</\w+>|/?>))@i', '<a href="http$2://$3">$0</a>', $post_content); + echo '<td class="post-content">' . $post_content . '</td></tr>'; $post_index++; |