Fix #1635 uninitialized variables in procLayoutAdminCopyLayout()

This commit is contained in:
Kijin Sung 2021-02-23 15:37:52 +09:00
parent d0916abf7f
commit 6a568e8e79

View file

@ -695,12 +695,23 @@ class layoutAdminController extends layout
$args = new stdClass();
$args->extra_vars = $output->extra_vars;
$extra_vars = unserialize($args->extra_vars);
$image_list = array();
if($layout->extra_var_count) {
if($layout->extra_var_count && $extra_vars)
{
$reg = "/^.\/files\/attach\/images\/([0-9]+)\/(.*)/";
if($extra_vars) foreach($extra_vars as $key => $val) {
if($layout->extra_var->{$key}->type == 'image') {
if(!preg_match($reg,$val,$matches)) continue;
foreach($extra_vars as $key => $val)
{
if($layout->extra_var->{$key}->type == 'image')
{
if(!preg_match($reg, $val, $matches))
{
continue;
}
if(!isset($image_list[$key]))
{
$image_list[$key] = new stdClass;
}
$image_list[$key]->filename = $matches[2];
$image_list[$key]->old_file = $val;
}
@ -732,9 +743,11 @@ class layoutAdminController extends layout
$args->layout_srl = getNextSequence();
$args->title = $value;
if(is_array($image_list)) {
foreach($image_list as $key=>$val) {
$new_file = sprintf("./files/attach/images/%d/%s", $args->layout_srl,$val->filename);
if($image_list)
{
foreach($image_list as $key => $val)
{
$new_file = sprintf("./files/attach/images/%d/%s", $args->layout_srl, $val->filename);
FileHandler::copyFile($val->old_file, $new_file);
$extra_vars->{$key} = $new_file;
}