mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-04 17:21:39 +09:00
is_command() 대체
This commit is contained in:
parent
9a78f0f0a0
commit
77122a32b2
6 changed files with 18 additions and 25 deletions
|
|
@ -143,6 +143,18 @@ class Storage
|
|||
return @self::exists($path) && @is_writable($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the given path is executable.
|
||||
*
|
||||
* @param string $path
|
||||
* @return bool
|
||||
*/
|
||||
public static function isExecutable($path)
|
||||
{
|
||||
$path = rtrim($path, '/\\');
|
||||
return @self::exists($path) && @is_executable($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the size of a file.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -691,23 +691,4 @@ function is_empty_html_content($str)
|
|||
$str = strip_tags($str, '<img><audio><video><iframe><object><embed>');
|
||||
$str = utf8_trim(utf8_clean(html_entity_decode($str, ENT_QUOTES, 'UTF-8')));
|
||||
return $str === '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a external program can be executed.
|
||||
*
|
||||
* @param string $command
|
||||
* @return bool
|
||||
*/
|
||||
function is_command($command)
|
||||
{
|
||||
if ($command && function_exists('exec'))
|
||||
{
|
||||
@exec('ls ' . escapeshellarg($command), $output, $return_var);
|
||||
return $return_var === 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -219,7 +219,7 @@ class fileAdminView extends file
|
|||
$oFileModel = getModel('file');
|
||||
$config = $oFileModel->getFileConfig();
|
||||
Context::set('config', $config);
|
||||
Context::set('is_ffmpeg', is_command($config->ffmpeg_command) && is_command($config->ffprobe_command));
|
||||
Context::set('is_ffmpeg', function_exists('exec') && Rhymix\Framework\Storage::isExecutable($config->ffmpeg_command) && Rhymix\Framework\Storage::isExecutable($config->ffprobe_command));
|
||||
|
||||
// Set a template file
|
||||
$this->setTemplatePath($this->module_path.'tpl');
|
||||
|
|
|
|||
|
|
@ -1102,7 +1102,7 @@ class fileController extends file
|
|||
$is_animated = Rhymix\Framework\Image::isAnimatedGIF($file_info['tmp_name']);
|
||||
|
||||
// Adjust image type
|
||||
if ($config->image_autoconv['gif2mp4'] && $is_animated && is_command($config->ffmpeg_command))
|
||||
if ($config->image_autoconv['gif2mp4'] && $is_animated && function_exists('exec') && Rhymix\Framework\Storage::isExecutable($config->ffmpeg_command))
|
||||
{
|
||||
$adjusted['type'] = 'mp4';
|
||||
}
|
||||
|
|
@ -1267,7 +1267,7 @@ class fileController extends file
|
|||
*/
|
||||
public function adjustUploadedVideo($file_info, $config)
|
||||
{
|
||||
if (!is_command($config->ffmpeg_command) || !is_command($config->ffprobe_command))
|
||||
if (!function_exists('exec') || !Rhymix\Framework\Storage::isExecutable($config->ffmpeg_command) || !Rhymix\Framework\Storage::isExecutable($config->ffprobe_command))
|
||||
{
|
||||
return $file_info;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,10 +83,10 @@ class fileModel extends file
|
|||
$obj->file_srl = $file_info->file_srl;
|
||||
$obj->source_filename = $file_info->source_filename;
|
||||
$obj->thumbnail_filename = $file_info->thumbnail_filename;
|
||||
$obj->type = $file_info->type;
|
||||
$obj->original_type = $file_info->original_type;
|
||||
$obj->file_size = $file_info->file_size;
|
||||
$obj->disp_file_size = FileHandler::filesize($file_info->file_size);
|
||||
$obj->mime_type = $file_info->mime_type;
|
||||
$obj->original_type = $file_info->original_type;
|
||||
$obj->direct_download = $file_info->direct_download;
|
||||
$obj->cover_image = ($file_info->cover_image === 'Y') ? true : false;
|
||||
$obj->download_url = $file_info->download_url;
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ class fileView extends file
|
|||
$oFileModel = getModel('file');
|
||||
$config = $oFileModel->getFileConfig($current_module_srl);
|
||||
Context::set('config', $config);
|
||||
Context::set('is_ffmpeg', is_command($config->ffmpeg_command) && is_command($config->ffprobe_command));
|
||||
Context::set('is_ffmpeg', function_exists('exec') && Rhymix\Framework\Storage::isExecutable($config->ffmpeg_command) && Rhymix\Framework\Storage::isExecutable($config->ffprobe_command));
|
||||
|
||||
// Get a permission for group setting
|
||||
$oMemberModel = getModel('member');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue