mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-07 10:41:40 +09:00
GIF → MP4 더 완벽하게...
This commit is contained in:
parent
1ac14a6964
commit
1fcba0a44c
7 changed files with 194 additions and 109 deletions
|
|
@ -150,15 +150,20 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if(result.error == 0) {
|
if(result.error == 0) {
|
||||||
if(/\.(jpe?g|png|gif)$/i.test(result.source_filename)) {
|
if(/\.(jpe?g|png|gif|webp)$/i.test(result.source_filename)) {
|
||||||
temp_code += '<img src="' + result.download_url + '" alt="' + result.source_filename + '" editor_component="image_link" data-file-srl="' + result.file_srl + '" />';
|
temp_code += '<img src="' + result.download_url + '" alt="' + result.source_filename + '" editor_component="image_link" data-file-srl="' + result.file_srl + '" />';
|
||||||
}
|
}
|
||||||
if(/\.(mp3)$/i.test(result.source_filename)) {
|
else if(/\.(mp3)$/i.test(result.source_filename)) {
|
||||||
temp_code += '<audio src="' + result.download_url + '" controls data-file-srl="' + result.file_srl + '" />';
|
temp_code += '<audio src="' + result.download_url + '" controls data-file-srl="' + result.file_srl + '" />';
|
||||||
}
|
}
|
||||||
if(/\.(mp4|webm)$/i.test(result.source_filename)) {
|
else if(/\.(mp4|webm)$/i.test(result.source_filename)) {
|
||||||
temp_code += '<video src="' + result.download_url + '" controls data-file-srl="' + result.file_srl + '" />';
|
if(/\.gif$/i.test(result.original_filename)) {
|
||||||
|
temp_code += '<video src="' + result.download_url + '" autoplay loop muted data-file-srl="' + result.file_srl + '" />';
|
||||||
|
} else {
|
||||||
|
temp_code += '<video src="' + result.download_url + '" controls data-file-srl="' + result.file_srl + '" />';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(temp_code !== '') {
|
if(temp_code !== '') {
|
||||||
if (opt.autoinsertImage === 'paragraph') {
|
if (opt.autoinsertImage === 'paragraph') {
|
||||||
temp_code = "<p>" + temp_code + "</p>\n";
|
temp_code = "<p>" + temp_code + "</p>\n";
|
||||||
|
|
@ -317,15 +322,20 @@
|
||||||
if(!result) return;
|
if(!result) return;
|
||||||
var temp_code = '';
|
var temp_code = '';
|
||||||
|
|
||||||
if(/\.(jpe?g|png|gif)$/i.test(result.source_filename)) {
|
if(/\.(jpe?g|png|gif|webp)$/i.test(result.source_filename)) {
|
||||||
temp_code += '<img src="' + result.download_url + '" alt="' + result.source_filename + '" editor_component="image_link" data-file-srl="' + result.file_srl + '" />';
|
temp_code += '<img src="' + result.download_url + '" alt="' + result.source_filename + '" editor_component="image_link" data-file-srl="' + result.file_srl + '" />';
|
||||||
}
|
}
|
||||||
if(/\.(mp3)$/i.test(result.source_filename)) {
|
else if(/\.(mp3)$/i.test(result.source_filename)) {
|
||||||
temp_code += '<audio src="' + result.download_url + '" controls data-file-srl="' + result.file_srl + '" />';
|
temp_code += '<audio src="' + result.download_url + '" controls data-file-srl="' + result.file_srl + '" />';
|
||||||
}
|
}
|
||||||
if(/\.(mp4|webm)$/i.test(result.source_filename)) {
|
else if(/\.(mp4|webm)$/i.test(result.source_filename)) {
|
||||||
temp_code += '<video src="' + result.download_url + '" controls data-file-srl="' + result.file_srl + '" />';
|
if(/\.gif$/i.test(result.original_filename)) {
|
||||||
|
temp_code += '<video src="' + result.download_url + '" autoplay loop muted data-file-srl="' + result.file_srl + '" />';
|
||||||
|
} else {
|
||||||
|
temp_code += '<video src="' + result.download_url + '" controls data-file-srl="' + result.file_srl + '" />';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(temp_code !== '') {
|
if(temp_code !== '') {
|
||||||
if (data.settings.autoinsertImage === 'paragraph') {
|
if (data.settings.autoinsertImage === 'paragraph') {
|
||||||
temp_code = "<p>" + temp_code + "</p>\n";
|
temp_code = "<p>" + temp_code + "</p>\n";
|
||||||
|
|
@ -417,16 +427,18 @@
|
||||||
// 이미지와 그외 파일 분리
|
// 이미지와 그외 파일 분리
|
||||||
$.each(res.files, function (index, file) {
|
$.each(res.files, function (index, file) {
|
||||||
if(data.files[file.file_srl]) return;
|
if(data.files[file.file_srl]) return;
|
||||||
|
|
||||||
data.files[file.file_srl] = file;
|
data.files[file.file_srl] = file;
|
||||||
$container.data(data);
|
$container.data(data);
|
||||||
|
|
||||||
file.source_filename = file.source_filename.replace("&", "&");
|
file.source_filename = file.source_filename.replace("&", "&");
|
||||||
if(/\.(jpe?g|png|gif)$/i.test(file.source_filename)) {
|
if(file.thumbnail_filename) {
|
||||||
|
file.download_url = file.thumbnail_filename;
|
||||||
result_image.push(template_fileimte_image(file));
|
result_image.push(template_fileimte_image(file));
|
||||||
}
|
}
|
||||||
else
|
else if(/\.(jpe?g|png|gif|webp)$/i.test(file.source_filename)) {
|
||||||
{
|
result_image.push(template_fileimte_image(file));
|
||||||
|
} else {
|
||||||
result.push(template_fileimte(file));
|
result.push(template_fileimte(file));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1126,30 +1126,34 @@ class documentItem extends BaseObject
|
||||||
// Find an image file among attached files if exists
|
// Find an image file among attached files if exists
|
||||||
if($this->hasUploadedFiles())
|
if($this->hasUploadedFiles())
|
||||||
{
|
{
|
||||||
$file_list = $this->getUploadedFiles();
|
|
||||||
|
|
||||||
$first_image = null;
|
$first_image = null;
|
||||||
foreach($file_list as $file)
|
foreach($this->getUploadedFiles() as $file)
|
||||||
{
|
{
|
||||||
if($file->direct_download !== 'Y') continue;
|
if($file->thumbnail_filename && file_exists($file->thumbnail_filename))
|
||||||
|
{
|
||||||
if($file->cover_image === 'Y' && file_exists($file->uploaded_filename))
|
$file->uploaded_filename = $file->thumbnail_filename;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if($file->direct_download !== 'Y' || !preg_match('/\.(jpe?g|png|gif|webp|bmp)$/i', $file->source_filename))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(!file_exists($file->uploaded_filename))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if($file->cover_image === 'Y')
|
||||||
{
|
{
|
||||||
$source_file = $file->uploaded_filename;
|
$source_file = $file->uploaded_filename;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if(!$first_image)
|
||||||
if($first_image) continue;
|
|
||||||
|
|
||||||
if(preg_match("/\.(jpe?g|png|gif|bmp)$/i", $file->source_filename))
|
|
||||||
{
|
{
|
||||||
if(file_exists($file->uploaded_filename))
|
$first_image = $file->uploaded_filename;
|
||||||
{
|
|
||||||
$first_image = $file->uploaded_filename;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$source_file && $first_image)
|
if(!$source_file && $first_image)
|
||||||
{
|
{
|
||||||
$source_file = $first_image;
|
$source_file = $first_image;
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,14 @@ class file extends ModuleObject
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if(!$oDB->isColumnExists('files', 'original_filename'))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if(!$oDB->isColumnExists('files', 'thumbnail_filename'))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -161,6 +168,14 @@ class file extends ModuleObject
|
||||||
{
|
{
|
||||||
$oModuleController->insertTrigger('comment.copyCommentByDocument', 'file', 'controller', 'triggerAddCopyCommentByDocument', 'add');
|
$oModuleController->insertTrigger('comment.copyCommentByDocument', 'file', 'controller', 'triggerAddCopyCommentByDocument', 'add');
|
||||||
}
|
}
|
||||||
|
if(!$oDB->isColumnExists('files', 'original_filename'))
|
||||||
|
{
|
||||||
|
$oDB->addColumn('files', 'original_filename', 'varchar', '250');
|
||||||
|
}
|
||||||
|
if(!$oDB->isColumnExists('files', 'thumbnail_filename'))
|
||||||
|
{
|
||||||
|
$oDB->addColumn('files', 'thumbnail_filename', 'varchar', '250');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -147,6 +147,8 @@ class fileController extends file
|
||||||
$this->add('direct_download', $output->get('direct_download'));
|
$this->add('direct_download', $output->get('direct_download'));
|
||||||
$this->add('source_filename', $output->get('source_filename'));
|
$this->add('source_filename', $output->get('source_filename'));
|
||||||
$this->add('upload_target_srl', $output->get('upload_target_srl'));
|
$this->add('upload_target_srl', $output->get('upload_target_srl'));
|
||||||
|
$this->add('original_filename', $output->get('original_filename'));
|
||||||
|
$this->add('thumbnail_filename', $output->get('thumbnail_filename'));
|
||||||
if ($output->get('direct_download') === 'Y')
|
if ($output->get('direct_download') === 'Y')
|
||||||
{
|
{
|
||||||
$this->add('download_url', $oFileModel->getDirectFileUrl($output->get('uploaded_filename')));
|
$this->add('download_url', $oFileModel->getDirectFileUrl($output->get('uploaded_filename')));
|
||||||
|
|
@ -864,23 +866,25 @@ class fileController extends file
|
||||||
$trigger_obj->upload_target_srl = $upload_target_srl;
|
$trigger_obj->upload_target_srl = $upload_target_srl;
|
||||||
$output = ModuleHandler::triggerCall('file.insertFile', 'before', $trigger_obj);
|
$output = ModuleHandler::triggerCall('file.insertFile', 'before', $trigger_obj);
|
||||||
if(!$output->toBool()) return $output;
|
if(!$output->toBool()) return $output;
|
||||||
|
|
||||||
// A workaround for Firefox upload bug
|
// A workaround for Firefox upload bug
|
||||||
if(preg_match('/^=\?UTF-8\?B\?(.+)\?=$/i', $file_info['name'], $match))
|
if(preg_match('/^=\?UTF-8\?B\?(.+)\?=$/i', $file_info['name'], $match))
|
||||||
{
|
{
|
||||||
$file_info['name'] = base64_decode(strtr($match[1], ':', '/'));
|
$file_info['name'] = base64_decode(strtr($match[1], ':', '/'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sanitize filename
|
// Sanitize filename
|
||||||
$file_info['name'] = Rhymix\Framework\Filters\FilenameFilter::clean($file_info['name']);
|
$file_info['name'] = Rhymix\Framework\Filters\FilenameFilter::clean($file_info['name']);
|
||||||
|
|
||||||
// Get extension
|
// Get extension
|
||||||
$extension = explode('.', $file_info['name']) ?: array('');
|
$extension = explode('.', $file_info['name']) ?: array('');
|
||||||
$extension = strtolower(array_pop($extension));
|
$extension = strtolower(array_pop($extension));
|
||||||
|
|
||||||
// Add extra fields to file info array
|
// Add extra fields to file info array
|
||||||
|
$file_info['original_name'] = $file_info['name'];
|
||||||
$file_info['extension'] = $extension;
|
$file_info['extension'] = $extension;
|
||||||
$file_info['resized'] = false;
|
$file_info['resized'] = false;
|
||||||
|
$file_info['thumbnail'] = null;
|
||||||
|
|
||||||
// Get file module configuration
|
// Get file module configuration
|
||||||
$oFileModel = getModel('file');
|
$oFileModel = getModel('file');
|
||||||
|
|
@ -889,7 +893,6 @@ class fileController extends file
|
||||||
// Check file type
|
// Check file type
|
||||||
if(!$manual_insert && !$this->user->isAdmin())
|
if(!$manual_insert && !$this->user->isAdmin())
|
||||||
{
|
{
|
||||||
// Check file type
|
|
||||||
if(isset($config->allowed_extensions) && count($config->allowed_extensions))
|
if(isset($config->allowed_extensions) && count($config->allowed_extensions))
|
||||||
{
|
{
|
||||||
if(!in_array($extension, $config->allowed_extensions))
|
if(!in_array($extension, $config->allowed_extensions))
|
||||||
|
|
@ -907,7 +910,7 @@ class fileController extends file
|
||||||
$file_info = $this->checkUploadedImage($file_info, $config);
|
$file_info = $this->checkUploadedImage($file_info, $config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check file size
|
// Check file size
|
||||||
if(!$manual_insert && !$this->user->isAdmin())
|
if(!$manual_insert && !$this->user->isAdmin())
|
||||||
{
|
{
|
||||||
|
|
@ -928,102 +931,67 @@ class fileController extends file
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get file_srl
|
$args = new stdClass;
|
||||||
$file_srl = getNextSequence();
|
$args->file_srl = getNextSequence();
|
||||||
$file_regdate = date('YmdHis');
|
$args->regdate = date('YmdHis');
|
||||||
|
$args->module_srl = $module_srl;
|
||||||
// Set upload path by checking if the attachement is an image or other kinds of file
|
$args->upload_target_srl = $upload_target_srl;
|
||||||
if(Rhymix\Framework\Filters\FilenameFilter::isDirectDownload($file_info['name']))
|
$args->download_count = $download_count;
|
||||||
|
$args->member_srl = getModel('member')->getLoggedMemberSrl();
|
||||||
|
$args->source_filename = $file_info['name'];
|
||||||
|
$args->original_filename = $file_info['original_name'];
|
||||||
|
$args->sid = Rhymix\Framework\Security::getRandom(32, 'hex');
|
||||||
|
|
||||||
|
// Set storage path by checking if the attachement is an image or other kinds of file
|
||||||
|
if($direct = Rhymix\Framework\Filters\FilenameFilter::isDirectDownload($args->source_filename))
|
||||||
{
|
{
|
||||||
$path = $this->getStoragePath('images', $file_srl, $module_srl, $upload_target_srl, $file_regdate);
|
$storage_path = $this->getStoragePath('images', $args->file_srl, $module_srl, $upload_target_srl, $args->regdate);
|
||||||
|
|
||||||
// change to random file name. because window php bug. window php is not recognize unicode character file name - by cherryfilter
|
|
||||||
$ext = substr(strrchr($file_info['name'],'.'),1);
|
|
||||||
$filename = $path . Rhymix\Framework\Security::getRandom(32, 'hex') . '.' . $ext;
|
|
||||||
while(file_exists($filename))
|
|
||||||
{
|
|
||||||
$filename = $path . Rhymix\Framework\Security::getRandom(32, 'hex') . '.' . $ext;
|
|
||||||
}
|
|
||||||
$direct_download = 'Y';
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$path = $this->getStoragePath('binaries', $file_srl, $module_srl, $upload_target_srl, $file_regdate);
|
$storage_path = $this->getStoragePath('binaries', $args->file_srl, $module_srl, $upload_target_srl, $args->regdate);
|
||||||
$filename = $path . Rhymix\Framework\Security::getRandom(32, 'hex');
|
|
||||||
while(file_exists($filename))
|
|
||||||
{
|
|
||||||
$filename = $path . Rhymix\Framework\Security::getRandom(32, 'hex');
|
|
||||||
}
|
|
||||||
$direct_download = 'N';
|
|
||||||
}
|
}
|
||||||
|
$args->direct_download = $direct ? 'Y' : 'N';
|
||||||
|
|
||||||
// Create a directory
|
// Create a directory
|
||||||
if(!Rhymix\Framework\Storage::isDirectory($path) && !Rhymix\Framework\Storage::createDirectory($path))
|
if(!Rhymix\Framework\Storage::isDirectory($storage_path) && !Rhymix\Framework\Storage::createDirectory($storage_path))
|
||||||
{
|
{
|
||||||
throw new Rhymix\Framework\Exception('msg_not_permitted_create');
|
throw new Rhymix\Framework\Exception('msg_not_permitted_create');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move the file
|
// Upload file
|
||||||
if($manual_insert && !$file_info['converted'])
|
$method = $manual_insert ? 'copy' : '';
|
||||||
|
if(starts_with(RX_BASEDIR . 'files/attach/chunks/', $file_info['tmp_name']) || $file_info['converted'])
|
||||||
{
|
{
|
||||||
@copy($file_info['tmp_name'], $filename);
|
$method = 'move';
|
||||||
if(!file_exists($filename))
|
|
||||||
{
|
|
||||||
@copy($file_info['tmp_name'], $filename);
|
|
||||||
if(!file_exists($filename))
|
|
||||||
{
|
|
||||||
throw new Rhymix\Framework\Exception('msg_file_upload_error');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
elseif(starts_with(RX_BASEDIR . 'files/attach/chunks/', $file_info['tmp_name']) || $file_info['converted'])
|
if(!$uploaded_filename = $this->uploadFile($file_info['tmp_name'], $args->source_filename, $storage_path, $direct, $method))
|
||||||
{
|
{
|
||||||
if (!Rhymix\Framework\Storage::move($file_info['tmp_name'], $filename))
|
throw new Rhymix\Framework\Exception('msg_file_upload_error');
|
||||||
{
|
|
||||||
if (!Rhymix\Framework\Storage::move($file_info['tmp_name'], $filename))
|
|
||||||
{
|
|
||||||
throw new Rhymix\Framework\Exception('msg_file_upload_error');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(!@move_uploaded_file($file_info['tmp_name'], $filename))
|
|
||||||
{
|
|
||||||
if(!@move_uploaded_file($file_info['tmp_name'], $filename))
|
|
||||||
{
|
|
||||||
throw new Rhymix\Framework\Exception('msg_file_upload_error');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
$args->uploaded_filename = './' . substr($uploaded_filename, strlen(RX_BASEDIR));
|
||||||
|
$args->file_size = @filesize($uploaded_filename);
|
||||||
|
|
||||||
// Get member information
|
// Upload thumbnail
|
||||||
$oMemberModel = getModel('member');
|
if($file_info['thumbnail'])
|
||||||
$member_srl = $oMemberModel->getLoggedMemberSrl();
|
{
|
||||||
// List file information
|
$thumbnail_filename = $this->uploadFile($file_info['thumbnail'], 'thumbnail.jpg', $storage_path, true, 'move');
|
||||||
$args = new stdClass;
|
$args->thumbnail_filename = './' . substr($thumbnail_filename, strlen(RX_BASEDIR));
|
||||||
$args->file_srl = $file_srl;
|
}
|
||||||
$args->upload_target_srl = $upload_target_srl;
|
|
||||||
$args->module_srl = $module_srl;
|
|
||||||
$args->direct_download = $direct_download;
|
|
||||||
$args->source_filename = $file_info['name'];
|
|
||||||
$args->uploaded_filename = './' . substr($filename, strlen(RX_BASEDIR));
|
|
||||||
$args->download_count = $download_count;
|
|
||||||
$args->file_size = @filesize($filename);
|
|
||||||
$args->comment = NULL;
|
|
||||||
$args->member_srl = $member_srl;
|
|
||||||
$args->regdate = $file_regdate;
|
|
||||||
$args->sid = Rhymix\Framework\Security::getRandom(32, 'hex');
|
|
||||||
|
|
||||||
$oDB = DB::getInstance();
|
$oDB = DB::getInstance();
|
||||||
$oDB->begin();
|
$oDB->begin();
|
||||||
|
|
||||||
|
// Insert file information
|
||||||
$output = executeQuery('file.insertFile', $args);
|
$output = executeQuery('file.insertFile', $args);
|
||||||
if(!$output->toBool())
|
if(!$output->toBool())
|
||||||
{
|
{
|
||||||
$oDB->rollback();
|
$oDB->rollback();
|
||||||
|
$this->deleteFile($args);
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Insert changelog
|
||||||
if($config->save_changelog === 'Y')
|
if($config->save_changelog === 'Y')
|
||||||
{
|
{
|
||||||
$clargs = new stdClass;
|
$clargs = new stdClass;
|
||||||
|
|
@ -1036,6 +1004,7 @@ class fileController extends file
|
||||||
if(!$output->toBool())
|
if(!$output->toBool())
|
||||||
{
|
{
|
||||||
$oDB->rollback();
|
$oDB->rollback();
|
||||||
|
$this->deleteFile($args);
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1044,9 +1013,9 @@ class fileController extends file
|
||||||
|
|
||||||
// Call a trigger (after)
|
// Call a trigger (after)
|
||||||
ModuleHandler::triggerCall('file.insertFile', 'after', $args);
|
ModuleHandler::triggerCall('file.insertFile', 'after', $args);
|
||||||
|
|
||||||
$_SESSION['__XE_UPLOADING_FILES_INFO__'][$args->file_srl] = true;
|
$_SESSION['__XE_UPLOADING_FILES_INFO__'][$args->file_srl] = true;
|
||||||
|
|
||||||
$output->add('file_srl', $args->file_srl);
|
$output->add('file_srl', $args->file_srl);
|
||||||
$output->add('file_size', $args->file_size);
|
$output->add('file_size', $args->file_size);
|
||||||
$output->add('sid', $args->sid);
|
$output->add('sid', $args->sid);
|
||||||
|
|
@ -1054,9 +1023,69 @@ class fileController extends file
|
||||||
$output->add('source_filename', $args->source_filename);
|
$output->add('source_filename', $args->source_filename);
|
||||||
$output->add('upload_target_srl', $upload_target_srl);
|
$output->add('upload_target_srl', $upload_target_srl);
|
||||||
$output->add('uploaded_filename', $args->uploaded_filename);
|
$output->add('uploaded_filename', $args->uploaded_filename);
|
||||||
|
$output->add('original_filename', $args->original_filename);
|
||||||
|
$output->add('thumbnail_filename', $args->thumbnail_filename);
|
||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Upload file
|
||||||
|
*/
|
||||||
|
public function uploadFile($tmp_name, $file_name, $storage_path, $direct = false, $method = '')
|
||||||
|
{
|
||||||
|
$extension = explode('.', $file_name) ?: array('');
|
||||||
|
$extension = strtolower(array_pop($extension));
|
||||||
|
|
||||||
|
// change to random file name.
|
||||||
|
// because window php bug. window php is not recognize unicode character file name - by cherryfilter
|
||||||
|
$uploaded_filename = $storage_path . Rhymix\Framework\Security::getRandom(32, 'hex');
|
||||||
|
while(file_exists($uploaded_filename))
|
||||||
|
{
|
||||||
|
$uploaded_filename = $storage_path . Rhymix\Framework\Security::getRandom(32, 'hex');
|
||||||
|
}
|
||||||
|
if($direct)
|
||||||
|
{
|
||||||
|
$uploaded_filename .= '.' . $extension;
|
||||||
|
}
|
||||||
|
|
||||||
|
// move the file
|
||||||
|
if($method === 'copy')
|
||||||
|
{
|
||||||
|
@copy($tmp_name, $uploaded_filename);
|
||||||
|
if(!file_exists($uploaded_filename))
|
||||||
|
{
|
||||||
|
@copy($tmp_name, $uploaded_filename);
|
||||||
|
if(!file_exists($uploaded_filename))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elseif($method === 'move')
|
||||||
|
{
|
||||||
|
if (!Rhymix\Framework\Storage::move($tmp_name, $uploaded_filename))
|
||||||
|
{
|
||||||
|
if (!Rhymix\Framework\Storage::move($tmp_name, $uploaded_filename))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(!@move_uploaded_file($tmp_name, $uploaded_filename))
|
||||||
|
{
|
||||||
|
if(!@move_uploaded_file($tmp_name, $uploaded_filename))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $uploaded_filename;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check uploaded image
|
* Check uploaded image
|
||||||
*/
|
*/
|
||||||
|
|
@ -1183,6 +1212,7 @@ class fileController extends file
|
||||||
{
|
{
|
||||||
if ($convert[2] === 'mp4')
|
if ($convert[2] === 'mp4')
|
||||||
{
|
{
|
||||||
|
// Convert using ffmpeg
|
||||||
$command = $config->ffmpeg_command ?: '/usr/bin/ffmpeg';
|
$command = $config->ffmpeg_command ?: '/usr/bin/ffmpeg';
|
||||||
$command .= ' -i ' . escapeshellarg($file_info['tmp_name']);
|
$command .= ' -i ' . escapeshellarg($file_info['tmp_name']);
|
||||||
$command .= ' -movflags faststart -pix_fmt yuv420p -c:v libx264 -crf 23 -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2"';
|
$command .= ' -movflags faststart -pix_fmt yuv420p -c:v libx264 -crf 23 -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2"';
|
||||||
|
|
@ -1190,6 +1220,13 @@ class fileController extends file
|
||||||
$status = @exec($command, $output, $return_var);
|
$status = @exec($command, $output, $return_var);
|
||||||
$result = $return_var == 0 ? true : false;
|
$result = $return_var == 0 ? true : false;
|
||||||
$newext = '.mp4';
|
$newext = '.mp4';
|
||||||
|
|
||||||
|
// Create thumbnail
|
||||||
|
if ($result)
|
||||||
|
{
|
||||||
|
$file_info['thumbnail'] = $file_info['tmp_name'] . 'thumbnail';
|
||||||
|
FileHandler::createImageFile($file_info['tmp_name'], $file_info['thumbnail'], $image_width, $image_height, 'jpg');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -1304,6 +1341,13 @@ class fileController extends file
|
||||||
|
|
||||||
// Remove empty directories
|
// Remove empty directories
|
||||||
Rhymix\Framework\Storage::deleteEmptyDirectory(dirname(FileHandler::getRealPath($file->uploaded_filename)), true);
|
Rhymix\Framework\Storage::deleteEmptyDirectory(dirname(FileHandler::getRealPath($file->uploaded_filename)), true);
|
||||||
|
|
||||||
|
// Remove thumbnail
|
||||||
|
if ($file->thumbnail_filename)
|
||||||
|
{
|
||||||
|
Rhymix\Framework\Storage::delete(FileHandler::getRealPath($file->thumbnail_filename));
|
||||||
|
Rhymix\Framework\Storage::deleteEmptyDirectory(dirname(FileHandler::getRealPath($file->thumbnail_filename)), true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$oDB->commit();
|
$oDB->commit();
|
||||||
|
|
@ -1537,9 +1581,10 @@ class fileController extends file
|
||||||
* @param int $upload_target_srl
|
* @param int $upload_target_srl
|
||||||
* @param string $regdate
|
* @param string $regdate
|
||||||
* @param bool $absolute_path
|
* @param bool $absolute_path
|
||||||
|
* @param int $folder_structure
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getStoragePath($file_type, $file_srl, $module_srl = 0, $upload_target_srl = 0, $regdate = '', $absolute_path = true)
|
public function getStoragePath($file_type, $file_srl = 0, $module_srl = 0, $upload_target_srl = 0, $regdate = '', $absolute_path = true, $folder_structure = null)
|
||||||
{
|
{
|
||||||
// 변수 확인 및 넘어오지 않은 변수 기본값 지정
|
// 변수 확인 및 넘어오지 않은 변수 기본값 지정
|
||||||
$file_srl = intval($file_srl);
|
$file_srl = intval($file_srl);
|
||||||
|
|
@ -1548,7 +1593,10 @@ class fileController extends file
|
||||||
$regdate = $regdate ?: date('YmdHis');
|
$regdate = $regdate ?: date('YmdHis');
|
||||||
|
|
||||||
// 시스템 설정 참고 (기존 사용자는 1, 신규 설치시 2가 기본값임)
|
// 시스템 설정 참고 (기존 사용자는 1, 신규 설치시 2가 기본값임)
|
||||||
$folder_structure = config('file.folder_structure');
|
if(!$folder_structure)
|
||||||
|
{
|
||||||
|
$folder_structure = config('file.folder_structure');
|
||||||
|
}
|
||||||
|
|
||||||
// 기본 경로 지정
|
// 기본 경로 지정
|
||||||
$prefix = $absolute_path ? \RX_BASEDIR : './';
|
$prefix = $absolute_path ? \RX_BASEDIR : './';
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,8 @@ class fileModel extends file
|
||||||
$obj->source_filename = $file_info->source_filename;
|
$obj->source_filename = $file_info->source_filename;
|
||||||
$obj->file_size = $file_info->file_size;
|
$obj->file_size = $file_info->file_size;
|
||||||
$obj->disp_file_size = FileHandler::filesize($file_info->file_size);
|
$obj->disp_file_size = FileHandler::filesize($file_info->file_size);
|
||||||
|
$obj->original_filename = $file_info->original_filename;
|
||||||
|
$obj->thumbnail_filename = $file_info->thumbnail_filename;
|
||||||
if($file_info->direct_download == 'N')
|
if($file_info->direct_download == 'N')
|
||||||
{
|
{
|
||||||
$obj->download_url = $this->getDownloadUrl($file_info->file_srl, $file_info->sid, $file_info->module_srl);
|
$obj->download_url = $this->getDownloadUrl($file_info->file_srl, $file_info->sid, $file_info->module_srl);
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,8 @@
|
||||||
<column name="module_srl" var="module_srl" filter="number" default="0" notnull="notnull" />
|
<column name="module_srl" var="module_srl" filter="number" default="0" notnull="notnull" />
|
||||||
<column name="source_filename" var="source_filename" notnull="notnull" minlength="1" maxlength="250" />
|
<column name="source_filename" var="source_filename" notnull="notnull" minlength="1" maxlength="250" />
|
||||||
<column name="uploaded_filename" var="uploaded_filename" notnull="notnull" minlength="1" maxlength="250" />
|
<column name="uploaded_filename" var="uploaded_filename" notnull="notnull" minlength="1" maxlength="250" />
|
||||||
|
<column name="original_filename" var="original_filename" notnull="notnull" minlength="1" maxlength="250" />
|
||||||
|
<column name="thumbnail_filename" var="thumbnail_filename" />
|
||||||
<column name="file_size" var="file_size" notnull="notnull" default="0" />
|
<column name="file_size" var="file_size" notnull="notnull" default="0" />
|
||||||
<column name="direct_download" var="direct_download" notnull="notnull" default="N" />
|
<column name="direct_download" var="direct_download" notnull="notnull" default="N" />
|
||||||
<column name="comment" var="comment" />
|
<column name="comment" var="comment" />
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,8 @@
|
||||||
<column name="direct_download" type="char" size="1" default="N" notnull="notnull" />
|
<column name="direct_download" type="char" size="1" default="N" notnull="notnull" />
|
||||||
<column name="source_filename" type="varchar" size="250" />
|
<column name="source_filename" type="varchar" size="250" />
|
||||||
<column name="uploaded_filename" type="varchar" size="250" />
|
<column name="uploaded_filename" type="varchar" size="250" />
|
||||||
|
<column name="original_filename" type="varchar" size="250" />
|
||||||
|
<column name="thumbnail_filename" type="varchar" size="250" />
|
||||||
<column name="file_size" type="number" size="11" default="0" notnull="notnull" index="idx_file_size" />
|
<column name="file_size" type="number" size="11" default="0" notnull="notnull" index="idx_file_size" />
|
||||||
<column name="comment" type="varchar" size="250" />
|
<column name="comment" type="varchar" size="250" />
|
||||||
<column name="isvalid" type="char" size="1" default="N" index="idx_is_valid" />
|
<column name="isvalid" type="char" size="1" default="N" index="idx_is_valid" />
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue