video + downloads

This commit is contained in:
Sanpaku 2021-09-03 22:58:51 +02:00
parent ac68c6f127
commit 5f7db55d11
7 changed files with 119 additions and 21 deletions

BIN
assets/img/video.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

View File

@ -30,8 +30,8 @@ $thumb_res_op = 250; //250x250
$thumb_res_reply = 125; //125x125
$thumb_spoiler = 'spoiler.png';
$thumb_audio = 'audio.png';
$thumb_video = 'spoiler.png';
$thumb_downloadable = 'spoiler.png';
$thumb_video = 'video.png';
$thumb_download = 'download.png';
$spoiler_enabled = true;
$thumbnail_bg_red = 255; //rgb - yotsuba default, 238,242,255 for yotsuba b.
@ -58,8 +58,15 @@ $config['allowed_ext']['audio'][] = '.ogg';
$config['allowed_ext']['video'][] = '.mp4';
$config['allowed_ext']['video'][] = '.webm';
$config['allowed_ext']['video'][] = '.ogv';
$config['allowed_ext']['video'][] = '.avi';
$config['allowed_ext']['video'][] = '.mkv';
$config['allowed_ext']['downloads'][] = '.pdf';
$config['allowed_ext']['downloads'][] = '.txt';
$config['allowed_ext']['downloads'][] = '.zip';
$config['allowed_ext']['downloads'][] = '.rar';
$config['allowed_ext']['downloads'][] = '.7z';
@ -78,7 +85,7 @@ $config['css'][] = 'Tomorrow';
$config['css'][] = 'Late';
$config['css'][] = 'Kind';
$default_theme = 'Yotsuba';
$default_theme = 'Futaba';
// JAVASCRIPTS
$config['js'][] = 'main.js'; //mandatory

View File

@ -46,10 +46,10 @@ function isAllowedFile($file_upload, $array) {
exit();
}
//is audio, video, or downloads?
if (isAllowedFile($fileext_, $config['allowed_ext']['video']) === true || isAllowedFile($fileext_, $config['allowed_ext']['downloads']) === true) {
echo 'havent coded these files yet lol but i will';
exit();
//is downloads?
if (isAllowedFile($fileext_, $config['allowed_ext']['downloads']) === true) {
$isDownload_ = true;
$file_type = 'download';
}
// IS THIS AUDIO?
@ -59,6 +59,7 @@ function isAllowedFile($file_upload, $array) {
$type = $info->buffer(file_get_contents($_FILES['file']['tmp_name']));
$type = preg_replace('/;(.*)/', '', $type);
//dunno if im gonna add anything here
switch ($type) {
case 'audio/mpeg':
break;
@ -82,6 +83,37 @@ function isAllowedFile($file_upload, $array) {
$file_type = "audio";
}
// IS THIS VIDEO?
if (isAllowedFile($fileext_, $config['allowed_ext']['video']) === true) {
$info = new finfo(FILEINFO_MIME);
$type = $info->buffer(file_get_contents($_FILES['file']['tmp_name']));
$type = preg_replace('/;(.*)/', '', $type);
//this is where something like imagemagick support could be added
switch ($type) {
case 'video/x-msvideo': //.avi
break;
case 'video/mp4': //mp4
break;
case 'video/mpeg': //mpeg
break;
case 'video/ogg': //.ogv
break;
case 'video/webm': //.webm
break;
case 'video/x-matroska': //.mkv
break;
default:
error('Format not supported!');
exit();
break;
}
$isVideo_ = true;
$file_type = "video";
}
//IS THIS IMAGE?
if (isAllowedFile($fileext_, $config['allowed_ext']['img']) === true) {

View File

@ -1,4 +1,4 @@
<a name="top"/>
<a name="top"></a>
<div id="boardlist">
[<?php
echo '<a href="' . $prefix_folder . '/' . $main_file . '">';

View File

@ -31,5 +31,5 @@
}
?>
<br>
<a name="bottom"/>
<a name="bottom"></a>
</div>

View File

@ -36,9 +36,9 @@
</div>
<?php
if ($reply_file != '') {
if ($reply_file[0][0] == 'image') {
<?php
if ($reply_file[0][0] != '') {
echo '<div class="post-file">';
echo '<div class="file-info">';
if ($original_filename == true && strlen($reply_file[0][2]) > $max_filename ) {
@ -50,10 +50,11 @@
echo $reply_file[0][2];
echo '</a>';
} else {
echo 'File: <a href="' . $prefix_folder . '/' . $uploads_folder . '/' . $current_board . '/' . $op_file[0][1] . '">';
echo $op_file[0][1];
echo 'File: <a href="' . $prefix_folder . '/' . $uploads_folder . '/' . $current_board . '/' . $reply_file[0][1] . '">';
echo $reply_file[0][1];
echo '</a>';
}
if ($reply_file[0][0] == 'image') {
echo ' (' . formatBytes($reply_file[0][4]) . ', ' . $reply_file[0][3] . ')';
echo '</div>';
echo '<div class="post-image">';
@ -61,19 +62,53 @@
$thmb_width = preg_replace('/x[^x]*$/', '', $reply_file[0][7]);
$thmb_height = preg_replace('/^[^x]*x/', '', $reply_file[0][7]);
$full_width = preg_replace('/x[^x]*$/', '', $reply_file[0][3]);
$full_height = preg_replace('/^[^x]*x/', '', $reply_file[0][3]);
if ($reply_file[0][5] != "1") {
echo '<img width="'.$thmb_width.'" height="'.$thmb_height.'" src="' . $prefix_folder . '/' . $uploads_folder . '/' . $current_board . '/' . $reply_file[0][6] . '"/>';
echo '<img id="'.$post_number_reply.'" class="thumb" width="'.$thmb_width.'" height="'.$thmb_height.'" src="' . $prefix_folder . '/' . $uploads_folder . '/' . $current_board . '/' . $reply_file[0][6] . '"/>';
} else {
echo '<img width="'.$thumb_res_reply.'" height="'.$thumb_res_reply.'" src="' . $prefix_folder . '/' . '/assets/img/' . $thumb_spoiler . '"/>';
echo '<img id="'.$post_number_reply.'" class="thumb" width="'.$thumb_res_reply.'" height="'.$thumb_res_reply.'" src="' . $prefix_folder . '/' . '/assets/img/' . $thumb_spoiler . '"/>';
}
echo '<img id="'.$post_number_reply.'" class="expand" style="display:none;" width="'.$full_width.'" height="'.$full_height.'" src="' . $prefix_folder . '/' . $uploads_folder . '/' . $current_board . '/' . $reply_file[0][1] . '"/>';
//image full
echo '</a>';
echo '</div>';
}
if ($reply_file[0][0] == 'audio') {
echo ' (' . formatBytes($reply_file[0][4]) . ')';
echo '</div>';
echo '<div class="post-image">';
echo '<a href="' . $prefix_folder . '/' . $uploads_folder . '/' . $current_board . '/' . $reply_file[0][1] . '">';
echo '<img width="'.$thumb_res_reply.'" height="'.$thumb_res_reply.'" src="' . $prefix_folder . '/' . '/assets/img/' . $thumb_audio . '"/>';
echo '</a>';
echo '</div>';
}
if ($reply_file[0][0] == 'video') {
echo ' (' . formatBytes($reply_file[0][4]) . ')';
echo '</div>';
echo '<div class="post-image">';
echo '<a href="' . $prefix_folder . '/' . $uploads_folder . '/' . $current_board . '/' . $reply_file[0][1] . '">';
echo '<img width="'.$thumb_res_reply.'" height="'.$thumb_res_reply.'" src="' . $prefix_folder . '/' . '/assets/img/' . $thumb_video . '"/>';
echo '</a>';
echo '</div>';
}
if ($reply_file[0][0] == 'download') {
echo ' (' . formatBytes($reply_file[0][4]) . ')';
echo '</div>';
echo '<div class="post-image">';
echo '<a href="' . $prefix_folder . '/' . $uploads_folder . '/' . $current_board . '/' . $reply_file[0][1] . '">';
echo '<img width="'.$thumb_res_reply.'" height="'.$thumb_res_reply.'" src="' . $prefix_folder . '/' . '/assets/img/' . $thumb_download . '"/>';
echo '</a>';
echo '</div>';
}
echo '</div>';
//reset images
$reply_file = false;
}
}
//reset files
$reply_file = false;
?>

View File

@ -27,16 +27,22 @@
$thmb_width = preg_replace('/x[^x]*$/', '', $op_file[0][7]);
$thmb_height = preg_replace('/^[^x]*x/', '', $op_file[0][7]);
$full_width = preg_replace('/x[^x]*$/', '', $op_file[0][3]);
$full_height = preg_replace('/^[^x]*x/', '', $op_file[0][3]);
if ($op_file[0][5] != "1") {
echo '<img width="'.$thmb_width.'" height="'.$thmb_height.'" src="' . $prefix_folder . '/' . $uploads_folder . '/' . $current_board . '/' . $op_file[0][6] . '"/>';
echo '<img id="'.$post_number_op.'" class="thumb" width="'.$thmb_width.'" height="'.$thmb_height.'" src="' . $prefix_folder . '/' . $uploads_folder . '/' . $current_board . '/' . $op_file[0][6] . '"/>';
} else {
echo '<img width="'.$thumb_res_reply.'" height="'.$thumb_res_reply.'" src="' . $prefix_folder . '/' . '/assets/img/' . $thumb_spoiler . '"/>';
echo '<img id="'.$post_number_op.'" class="thumb" width="'.$thumb_res_reply.'" height="'.$thumb_res_reply.'" src="' . $prefix_folder . '/' . '/assets/img/' . $thumb_spoiler . '"/>';
}
echo '<img id="'.$post_number_op.'" class="expand" style="display:none;" width="'.$full_width.'" height="'.$full_height.'" src="' . $prefix_folder . '/' . $uploads_folder . '/' . $current_board . '/' . $op_file[0][1] . '"/>';
//image full
echo '</a>';
echo '</div>';
}
if ($op_file[0][0] == 'audio') {
echo ' (' . formatBytes($op_file[0][4]) . ')';
echo '</div>';
echo '<div class="post-image">';
echo '<a href="' . $prefix_folder . '/' . $uploads_folder . '/' . $current_board . '/' . $op_file[0][1] . '">';
@ -44,6 +50,24 @@
echo '</a>';
echo '</div>';
}
if ($op_file[0][0] == 'video') {
echo ' (' . formatBytes($op_file[0][4]) . ')';
echo '</div>';
echo '<div class="post-image">';
echo '<a href="' . $prefix_folder . '/' . $uploads_folder . '/' . $current_board . '/' . $op_file[0][1] . '">';
echo '<img width="'.$thumb_res_reply.'" height="'.$thumb_res_reply.'" src="' . $prefix_folder . '/' . '/assets/img/' . $thumb_video . '"/>';
echo '</a>';
echo '</div>';
}
if ($op_file[0][0] == 'download') {
echo ' (' . formatBytes($op_file[0][4]) . ')';
echo '</div>';
echo '<div class="post-image">';
echo '<a href="' . $prefix_folder . '/' . $uploads_folder . '/' . $current_board . '/' . $op_file[0][1] . '">';
echo '<img width="'.$thumb_res_reply.'" height="'.$thumb_res_reply.'" src="' . $prefix_folder . '/' . '/assets/img/' . $thumb_download . '"/>';
echo '</a>';
echo '</div>';
}
echo '</div>';
}