From f9154b632a1668bc2f4aff3d749182eeae7bddce Mon Sep 17 00:00:00 2001 From: biglyderv Date: Fri, 13 Dec 2024 20:57:10 -0500 Subject: [PATCH] mime tpye stuff --- docs/index.php | 15 +++++++++++++-- libs/markdown.php | 6 +++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/docs/index.php b/docs/index.php index 5df21fc..fdac724 100755 --- a/docs/index.php +++ b/docs/index.php @@ -30,8 +30,19 @@ } if (is_uploaded_file($_FILES['file']['tmp_name'])) { $fid = bin2hex(random_bytes(16)); - move_uploaded_file($_FILES['file']['tmp_name'], $_SERVER["DOCUMENT_ROOT"] . '/../docs/pic/' . $fid . '.png'); - $postie .= "\nhttps://" . $_SERVER['HTTP_HOST'] . '/pic/' . $fid . '.png'; + + $type = pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION); + + $type = strtolower($type); + + $mime = mime_content_type('test' . $type); + + $legal = ['png','gif','jpeg','jpg','mp4','webm','mp3','wav']; + + if (in_array($type, $legal)) { + move_uploaded_file($_FILES['file']['tmp_name'], $_SERVER["DOCUMENT_ROOT"] . '/../docs/pic/' . $fid . '.' . $type); + $postie .= "\nhttps://" . $_SERVER['HTTP_HOST'] . '/pic/' . $fid . '.' . $type; + } } diff --git a/libs/markdown.php b/libs/markdown.php index 03a1ad2..2f99223 100755 --- a/libs/markdown.php +++ b/libs/markdown.php @@ -1,7 +1,9 @@
$1
', + '
$1
', + '
$1
', '$0', '@$1', '$2',