최근에 사용중인 호스팅에서 이미지매직 모듈이 추가돼서 카르마님 이미지프로세스 모듈에 적용하려고 했는데요
shell_exec가 막혀 있어서 실행파일 경로를 입력해줘도 실행파일을 못 찾고 작동이 안되네요
오류가 나는 부분이 이 부분인데요
function procImageprocessAdminEtcSetup()
{
$oModuleController = &getController('module');
$oModuleModel = &getModel('module');
$ipConfig = $oModuleModel->getModuleConfig('imageprocess');
$ipConfig->change_kfile= Context::get('change_kfile');
$ipConfig->magic_use = Context::get('magic_use');
$ipConfig->rotate_use = Context::get('rotate_use');
$ipConfig->magic_path = str_replace('\\','/',Context::get('magic_path'));
$ipConfig->magic_conversion = Context::get('magic_conversion');
$ipConfig->magic_target = Context::get('magic_target');
if(ini_get('safe_mode') && $ipConfig->magic_use == 'Y') return new Object(-1, 'ip_safe_mode');
elseif($ipConfig->magic_use == 'Y' )
{
if($ipConfig->magic_path && !preg_match('/\/$/',$ipConfig->magic_path)) $ipConfig->magic_path .= '/';
$command =$ipConfig->magic_path."identify -version";
if (stripos(PHP_OS, 'WIN') === 0)
{
$magic_path = str_replace('/','\\',$ipConfig->magic_path);
$command = "\"".$magic_path."convert\" -version";
$ver = shell_exec($command);
}
else $ver = shell_exec($command);
if(!stripos($ver,'imagemagick')) return new Object(-1, 'check_magic_path');
$ipConfig->magic_conversion = Context::get('magic_conversion');
$ipConfig->original_format = Context::get('original_format');
$ipConfig->target_format = Context::get('target_format');
if(!$ipConfig->target_format) $ipConfig->target_format = 'jpg';
}
$oModuleController->insertModuleConfig('imageprocess', $ipConfig);
return new Object(0,"success_updated");
}
{
$oModuleController = &getController('module');
$oModuleModel = &getModel('module');
$ipConfig = $oModuleModel->getModuleConfig('imageprocess');
$ipConfig->change_kfile= Context::get('change_kfile');
$ipConfig->magic_use = Context::get('magic_use');
$ipConfig->rotate_use = Context::get('rotate_use');
$ipConfig->magic_path = str_replace('\\','/',Context::get('magic_path'));
$ipConfig->magic_conversion = Context::get('magic_conversion');
$ipConfig->magic_target = Context::get('magic_target');
if(ini_get('safe_mode') && $ipConfig->magic_use == 'Y') return new Object(-1, 'ip_safe_mode');
elseif($ipConfig->magic_use == 'Y' )
{
if($ipConfig->magic_path && !preg_match('/\/$/',$ipConfig->magic_path)) $ipConfig->magic_path .= '/';
$command =$ipConfig->magic_path."identify -version";
if (stripos(PHP_OS, 'WIN') === 0)
{
$magic_path = str_replace('/','\\',$ipConfig->magic_path);
$command = "\"".$magic_path."convert\" -version";
$ver = shell_exec($command);
}
else $ver = shell_exec($command);
if(!stripos($ver,'imagemagick')) return new Object(-1, 'check_magic_path');
$ipConfig->magic_conversion = Context::get('magic_conversion');
$ipConfig->original_format = Context::get('original_format');
$ipConfig->target_format = Context::get('target_format');
if(!$ipConfig->target_format) $ipConfig->target_format = 'jpg';
}
$oModuleController->insertModuleConfig('imageprocess', $ipConfig);
return new Object(0,"success_updated");
}
일단 인터넷 찾아보니까 웹호스팅에서 shell_exec 제한하는 게 일반적인지는 모르겠는데 그런 업체들이 다수 있긴 한거 같던데
이미지매직을 사용하려면 shell_exec 권한이 반드시 필요한가요?
이미지매직이 추가되었는데 정작 저 권한이 없어서 적용을 못하네요
댓글 3
네, shell_exec 권한이 없으면 안됩니다. exec, system, passthru 등 대체 가능한 명령이 몇 가지 있긴 하지만, shell_exec을 막아놓은 호스팅이라면 이것도 막아놓았을 가능성이 높지요.
http://php.net/manual/kr/book.imagick.php