|
@ -1,27 +1,22 @@ |
|
|
<?php |
|
|
<?php |
|
|
// Glue code for handling a Tinyboard post. |
|
|
// Glue code for handling a Tinyboard post. |
|
|
// Portions of this file are derived from Tinyboard code. |
|
|
// Portions of this file are derived from Tinyboard code. |
|
|
|
|
|
|
|
|
function postHandler($post) { |
|
|
function postHandler($post) { |
|
|
global $board, $config; |
|
|
global $board, $config; |
|
|
|
|
|
if ($post->has_file) foreach ($post->files as &$file) if ($file->extension == 'webm' || $file->extension == 'mp4') { |
|
|
if ($post->has_file) foreach ($post->files as &$file) if ($file->extension == 'webm') { |
|
|
|
|
|
if ($config['webm']['use_ffmpeg']) { |
|
|
if ($config['webm']['use_ffmpeg']) { |
|
|
require_once dirname(__FILE__) . '/ffmpeg.php'; |
|
|
require_once dirname(__FILE__) . '/ffmpeg.php'; |
|
|
$webminfo = get_webm_info($file->file_path); |
|
|
$webminfo = get_webm_info($file->file_path); |
|
|
|
|
|
|
|
|
if (empty($webminfo['error'])) { |
|
|
if (empty($webminfo['error'])) { |
|
|
$file->width = $webminfo['width']; |
|
|
$file->width = $webminfo['width']; |
|
|
$file->height = $webminfo['height']; |
|
|
$file->height = $webminfo['height']; |
|
|
|
|
|
|
|
|
if ($config['spoiler_images'] && isset($_POST['spoiler'])) { |
|
|
if ($config['spoiler_images'] && isset($_POST['spoiler'])) { |
|
|
$file = webm_set_spoiler($file); |
|
|
$file = webm_set_spoiler($file); |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
$file = set_thumbnail_dimensions($post, $file); |
|
|
$file = set_thumbnail_dimensions($post, $file); |
|
|
$tn_path = $board['dir'] . $config['dir']['thumb'] . $file->file_id . '.jpg'; |
|
|
$tn_path = $board['dir'] . $config['dir']['thumb'] . $file->file_id . '.jpg'; |
|
|
|
|
|
if(0 == make_webm_thumbnail($file->file_path, $tn_path, $file->thumbwidth, $file->thumbheight, $webminfo['duration'])) { |
|
|
if(false == make_webm_thumbnail($file->file_path, $tn_path, $file->thumbwidth, $file->thumbheight)) { |
|
|
|
|
|
$file->thumb = $file->file_id . '.jpg'; |
|
|
$file->thumb = $file->file_id . '.jpg'; |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
@ -37,7 +32,6 @@ function postHandler($post) { |
|
|
require_once dirname(__FILE__) . '/videodata.php'; |
|
|
require_once dirname(__FILE__) . '/videodata.php'; |
|
|
$videoDetails = videoData($file->file_path); |
|
|
$videoDetails = videoData($file->file_path); |
|
|
if (!isset($videoDetails['container']) || $videoDetails['container'] != 'webm') return "not a WebM file"; |
|
|
if (!isset($videoDetails['container']) || $videoDetails['container'] != 'webm') return "not a WebM file"; |
|
|
|
|
|
|
|
|
// Set thumbnail |
|
|
// Set thumbnail |
|
|
$thumbName = $board['dir'] . $config['dir']['thumb'] . $file->file_id . '.webm'; |
|
|
$thumbName = $board['dir'] . $config['dir']['thumb'] . $file->file_id . '.webm'; |
|
|
if ($config['spoiler_images'] && isset($_POST['spoiler'])) { |
|
|
if ($config['spoiler_images'] && isset($_POST['spoiler'])) { |
|
@ -53,12 +47,10 @@ function postHandler($post) { |
|
|
$file->thumb = 'file'; |
|
|
$file->thumb = 'file'; |
|
|
} |
|
|
} |
|
|
unset($videoDetails['frame']); |
|
|
unset($videoDetails['frame']); |
|
|
|
|
|
|
|
|
// Set width and height |
|
|
// Set width and height |
|
|
if (isset($videoDetails['width']) && isset($videoDetails['height'])) { |
|
|
if (isset($videoDetails['width']) && isset($videoDetails['height'])) { |
|
|
$file->width = $videoDetails['width']; |
|
|
$file->width = $videoDetails['width']; |
|
|
$file->height = $videoDetails['height']; |
|
|
$file->height = $videoDetails['height']; |
|
|
|
|
|
|
|
|
if ($file->thumb != 'file' && $file->thumb != 'spoiler') { |
|
|
if ($file->thumb != 'file' && $file->thumb != 'spoiler') { |
|
|
$file = set_thumbnail_dimensions($post, $file); |
|
|
$file = set_thumbnail_dimensions($post, $file); |
|
|
} |
|
|
} |
|
@ -66,14 +58,11 @@ function postHandler($post) { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function set_thumbnail_dimensions($post,$file) { |
|
|
function set_thumbnail_dimensions($post,$file) { |
|
|
global $board, $config; |
|
|
global $board, $config; |
|
|
|
|
|
|
|
|
$tn_dimensions = array(); |
|
|
$tn_dimensions = array(); |
|
|
$tn_maxw = $post->op ? $config['thumb_op_width'] : $config['thumb_width']; |
|
|
$tn_maxw = $post->op ? $config['thumb_op_width'] : $config['thumb_width']; |
|
|
$tn_maxh = $post->op ? $config['thumb_op_height'] : $config['thumb_height']; |
|
|
$tn_maxh = $post->op ? $config['thumb_op_height'] : $config['thumb_height']; |
|
|
|
|
|
|
|
|
if ($file->width > $tn_maxw || $file->height > $tn_maxh) { |
|
|
if ($file->width > $tn_maxw || $file->height > $tn_maxh) { |
|
|
$file->thumbwidth = min($tn_maxw, intval(round($file->width * $tn_maxh / $file->height))); |
|
|
$file->thumbwidth = min($tn_maxw, intval(round($file->width * $tn_maxh / $file->height))); |
|
|
$file->thumbheight = min($tn_maxh, intval(round($file->height * $tn_maxw / $file->width))); |
|
|
$file->thumbheight = min($tn_maxh, intval(round($file->height * $tn_maxw / $file->width))); |
|
@ -81,17 +70,13 @@ function set_thumbnail_dimensions($post,$file) { |
|
|
$file->thumbwidth = $file->width; |
|
|
$file->thumbwidth = $file->width; |
|
|
$file->thumbheight = $file->height; |
|
|
$file->thumbheight = $file->height; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return $file; |
|
|
return $file; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function webm_set_spoiler($file) { |
|
|
function webm_set_spoiler($file) { |
|
|
global $board, $config; |
|
|
global $board, $config; |
|
|
|
|
|
|
|
|
$file->thumb = 'spoiler'; |
|
|
$file->thumb = 'spoiler'; |
|
|
$size = @getimagesize($config['spoiler_image']); |
|
|
$size = @getimagesize($config['spoiler_image']); |
|
|
$file->thumbwidth = $size[0]; |
|
|
$file->thumbwidth = $size[0]; |
|
|
$file->thumbheight = $size[1]; |
|
|
$file->thumbheight = $size[1]; |
|
|
|
|
|
|
|
|
return $file; |
|
|
return $file; |
|
|
} |
|
|
} |
|
|