diff --git a/bbs.php b/bbs.php index 81a0399..e1c4c3e 100644 --- a/bbs.php +++ b/bbs.php @@ -69,7 +69,7 @@ // Validate and move the uploaded image file, if necessary if(!empty($img['tmp_name'])) { - if ((($img['type'] == 'image/gif') || ($img['type'] == 'image/jpeg') || ($img['type'] == 'image/pjpeg') + if((($img['type'] == 'image/gif') || ($img['type'] == 'image/jpeg') || ($img['type'] == 'image/pjpeg') || ($img['type'] == 'image/png') || ($img['type'] == 'image/bmp')) && ($img['size'] > 0) && ($img['size'] <= MAX_FILE_SIZE)) { if($img['error'] == 0) { @@ -142,7 +142,7 @@ // Print posts $show_delete = FALSE; echo '
'; - while ($row = pg_fetch_array($result)) { + while($row = pg_fetch_array($result)) { echo "
"; echo ''; @@ -151,7 +151,13 @@ $show_delete = TRUE; } echo "{$row['name']} {$row['post_time']} "; - echo "#{$row['post_id']}"; + echo "#{$row['post_id']} "; + // Find references + $post_id = pg_escape_string($row['post_id']); + $ref_query = "SELECT post_id FROM posts WHERE comment LIKE '%>>$post_id%'"; + $ref_result = pg_query_params($ref_query, []) or die('Query failed: ' . pg_last_error()); + while($ref = pg_fetch_array($ref_result)) + echo ">>{$ref['post_id']} "; echo ''; if(!empty($row['img'])){ @@ -163,9 +169,9 @@ // Process quotes, links, and newlines if(!empty($row['comment'])) { $comment = $row['comment']; - $comment = preg_replace('/^>[^>].*/m', '$0', $comment); + $comment = preg_replace('/^>(?!>\d).+/m', '$0', $comment); $comment = preg_replace('/https?:\/\/[^\s]+/m', '$0', $comment); - $comment = preg_replace_callback('/>>\s*(\d+)/', quote_link, $comment); + $comment = preg_replace_callback('/>>\s*(\d+)/', quote_link, $comment); $comment = str_replace("\n", "
", $comment); echo "

$comment

"; }