mime tpye stuff

This commit is contained in:
biglyderv 2024-12-13 20:57:10 -05:00
parent 78bfff6945
commit f9154b632a
2 changed files with 18 additions and 3 deletions

View file

@ -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;
}
}

View file

@ -1,7 +1,9 @@
<?php
function markdown($text) {
$search = array (
'~(https://[^.]+\.dervland\.net/[^\s<]+)~i',
'~(https://[^.]+\.dervland\.net/[^\s<]+\.(png|jpg|jpeg|gif))~i',
'~(https://[^.]+\.dervland\.net/[^\s<]+\.(mp3|wav))~i',
'~(https://[^.]+\.dervland\.net/[^\s<]+\.(webm|mp4))~i',
'~(?:\s|^)(?:(https?)://([^\s<]+)|(www\.[^\s<]+?\.[^\s<]+))(?<![\.,:])~i',
'~(?:@)([^\s]+)(?:\s|$)~i',
'~(\[b\])(.*?)(\[\/b\])~i',
@ -16,6 +18,8 @@
$replace = array (
'<a class="link" href="$1" target="_blank"><div>$1</div><img src="$1" class="img"></a>',
'<a class="link" href="$1" target="_blank"><div>$1</div><audio controls src="$1"></a>',
'<a class="link" href="$1" target="_blank"><div>$1</div><video controls class="img"><source src="$1"/></video></a>',
'<a class="link" href="$0" target="_blank">$0</a>',
'<a class="link" href="/user.php?id=$1" target="_blank">@$1</a>',
'<strong>$2</strong>',