Browse Source

Merge branch 'staging' of https://github.com/vichan-devel/vichan into staging

pull/40/head
Fredrick Brennan 10 years ago
parent
commit
8e81c8c669
  1. 30
      inc/lib/webm/posthandler.php
  2. 1
      js/post-hider.js
  3. 2
      js/wPaint
  4. 2
      js/wpaint.js
  5. 9
      post.php

30
inc/lib/webm/posthandler.php

@ -5,43 +5,43 @@
function postHandler($post) { function postHandler($post) {
global $board, $config; global $board, $config;
if ($post->has_file && $post->extension == 'webm') { if ($post->has_file) foreach ($post->files as &$file) if ($file->extension == 'webm') {
require_once dirname(__FILE__) . '/videodata.php'; require_once dirname(__FILE__) . '/videodata.php';
$videoDetails = videoData($post->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'] . $post->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'])) {
// Use spoiler thumbnail // Use spoiler thumbnail
$post->thumb = 'spoiler'; $file->thumb = 'spoiler';
$size = @getimagesize($config['spoiler_image']); $size = @getimagesize($config['spoiler_image']);
$post->thumbwidth = $size[0]; $file->thumbwidth = $size[0];
$post->thumbheight = $size[1]; $file->thumbheight = $size[1];
} elseif (isset($videoDetails['frame']) && $thumbFile = fopen($thumbName, 'wb')) { } elseif (isset($videoDetails['frame']) && $thumbFile = fopen($thumbName, 'wb')) {
// Use single frame from video as pseudo-thumbnail // Use single frame from video as pseudo-thumbnail
fwrite($thumbFile, $videoDetails['frame']); fwrite($thumbFile, $videoDetails['frame']);
fclose($thumbFile); fclose($thumbFile);
$post->thumb = $post->file_id . '.webm'; $file->thumb = $file->file_id . '.webm';
} else { } else {
// Fall back to file thumbnail // Fall back to file thumbnail
$post->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'])) {
$post->width = $videoDetails['width']; $file->width = $videoDetails['width'];
$post->height = $videoDetails['height']; $file->height = $videoDetails['height'];
if ($post->thumb != 'file' && $post->thumb != 'spoiler') { if ($file->thumb != 'file' && $file->thumb != 'spoiler') {
$thumbMaxWidth = $post->op ? $config['thumb_op_width'] : $config['thumb_width']; $thumbMaxWidth = $post->op ? $config['thumb_op_width'] : $config['thumb_width'];
$thumbMaxHeight = $post->op ? $config['thumb_op_height'] : $config['thumb_height']; $thumbMaxHeight = $post->op ? $config['thumb_op_height'] : $config['thumb_height'];
if ($videoDetails['width'] > $thumbMaxWidth || $videoDetails['height'] > $thumbMaxHeight) { if ($videoDetails['width'] > $thumbMaxWidth || $videoDetails['height'] > $thumbMaxHeight) {
$post->thumbwidth = min($thumbMaxWidth, intval(round($videoDetails['width'] * $thumbMaxHeight / $videoDetails['height']))); $file->thumbwidth = min($thumbMaxWidth, intval(round($videoDetails['width'] * $thumbMaxHeight / $videoDetails['height'])));
$post->thumbheight = min($thumbMaxHeight, intval(round($videoDetails['height'] * $thumbMaxWidth / $videoDetails['width']))); $file->thumbheight = min($thumbMaxHeight, intval(round($videoDetails['height'] * $thumbMaxWidth / $videoDetails['width'])));
} else { } else {
$post->thumbwidth = $videoDetails['width']; $file->thumbwidth = $videoDetails['width'];
$post->thumbheight = $videoDetails['height']; $file->thumbheight = $videoDetails['height'];
} }
} }
} }

1
js/post-hider.js

@ -1 +0,0 @@
hide-threads.js

2
js/wPaint

@ -1 +1 @@
Subproject commit 2c272dffca0f3d7b7163bd82ba15629f54409278 Subproject commit 15bae4a9181ddb283c1cad0979c44cefd4f15a44

2
js/wpaint.js

@ -83,7 +83,7 @@ oekaki.init = function() {
stop: function(event,ui) { stop: function(event,ui) {
$("#wpaintdiv").wPaint("resize"); $("#wpaintdiv").wPaint("resize");
}, },
alsoResize: "#wpaintdiv, #wpaintdiv canvas", alsoResize: "#wpaintdiv",
}); });
$('#wpaintctr .ui-resizable-se').css({'height':'12px', 'width':'12px'}); $('#wpaintctr .ui-resizable-se').css({'height':'12px', 'width':'12px'});

9
post.php

@ -320,6 +320,7 @@ if (isset($_POST['delete'])) {
$_FILES['file'] = array( $_FILES['file'] = array(
'name' => basename($url_without_params), 'name' => basename($url_without_params),
'tmp_name' => $post['file_tmp'], 'tmp_name' => $post['file_tmp'],
'file_tmp' => true,
'error' => 0, 'error' => 0,
'size' => filesize($post['file_tmp']) 'size' => filesize($post['file_tmp'])
); );
@ -704,7 +705,7 @@ if (isset($_POST['delete'])) {
chmod($file['file'], 0644); chmod($file['file'], 0644);
} elseif (!@move_uploaded_file($file['tmp_name'], $file['file'])) } elseif (!@move_uploaded_file($file['tmp_name'], $file['file']))
error($config['error']['nomove']); error($config['error']['nomove']);
} }
} }
if ($config['image_reject_repost']) { if ($config['image_reject_repost']) {
@ -757,7 +758,11 @@ if (isset($_POST['delete'])) {
} }
$post = (object)$post; $post = (object)$post;
if ($error = event('post', $post)) { $post->files = array_map(function($a) { return (object)$a; }, $post->files);
$error = event('post', $post);
$post->files = array_map(function($a) { return (array)$a; }, $post->files);
if ($error) {
undoImage((array)$post); undoImage((array)$post);
error($error); error($error);
} }

Loading…
Cancel
Save