From bea66d3a8845221e50138aba0417ca732afb7d97 Mon Sep 17 00:00:00 2001 From: Arcturus Date: Thu, 4 Dec 2025 01:01:37 +0900 Subject: [PATCH] update --- AvocadoAmber/adm/board_move_update.php | 56 ++++++++++++++------------ 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/AvocadoAmber/adm/board_move_update.php b/AvocadoAmber/adm/board_move_update.php index 6ada99c..b456191 100644 --- a/AvocadoAmber/adm/board_move_update.php +++ b/AvocadoAmber/adm/board_move_update.php @@ -61,7 +61,7 @@ $error_messages = []; foreach ($chk as $wr_id) { $wr_id = (int) $wr_id; - $write = sql_fetch("SELECT * FROM {$source_table} WHERE wr_id = '{$wr_id}'"); + $write = sql_fetch("SELECT * FROM {$source_table} WHERE wr_id = '{$wr_id}'"); if (!$write) { $fail_count++; @@ -69,27 +69,27 @@ foreach ($chk as $wr_id) { continue; } - $is_reply = $write['wr_reply'] ? true : false; + $is_reply = $write['wr_reply'] ? true : false; - if ($is_reply && $act_button === 'move') { + if ($is_reply && $act_button === 'move') { $parent_id = $write['wr_parent']; $parent_check = sql_fetch("SELECT wr_id FROM {$source_table} WHERE wr_id = '{$parent_id}'"); if (!$parent_check) { - $write['wr_reply'] = ''; + $write['wr_reply'] = ''; $write['wr_parent'] = 0; } } try { - $insert_values = []; + $insert_values = []; $insert_fields = []; foreach ($common_columns as $col) { - if ($col === 'wr_num') + if ($col === 'wr_num') continue; if ($col === 'wr_reply' || $col === 'wr_parent') { - if ($col === 'wr_reply') { + if ($col === 'wr_reply') { $insert_fields[] = $col; $insert_values[] = "''"; } else if ($col === 'wr_parent') { @@ -102,39 +102,43 @@ foreach ($chk as $wr_id) { $insert_fields[] = $col; $value = $write[$col]; - if ($col === 'bo_table') { + if ($col === 'bo_table') { $insert_values[] = "'{$target_board}'"; } else { $insert_values[] = "'" . sql_real_escape_string($value) . "'"; } } - $row = sql_fetch("SELECT MIN(wr_num) AS min_wr_num FROM {$target_table}"); + $row = sql_fetch("SELECT MIN(wr_num) AS min_wr_num FROM {$target_table}"); $wr_num = $row['min_wr_num'] - 1; $insert_fields[] = 'wr_num'; $insert_values[] = "'{$wr_num}'"; - $sql = "INSERT INTO {$target_table} (" . implode(', ', $insert_fields) . ") + $sql = "INSERT INTO {$target_table} (" . implode(', ', $insert_fields) . ") VALUES (" . implode(', ', $insert_values) . ")"; sql_query($sql); $new_wr_id = sql_insert_id(); - if ($write['wr_file']) { + if (isset($write['wr_is_comment']) && $write['wr_is_comment'] == 0) { + sql_query("UPDATE {$target_table} SET wr_parent = '{$new_wr_id}' WHERE wr_id = '{$new_wr_id}'"); + } + + if ($write['wr_file']) { copy_board_files($bo_table, $wr_id, $target_board, $new_wr_id, $write); } - if ($act_button === 'move') { - sql_query("DELETE FROM {$g5['board_new_table']} WHERE bo_table = '{$bo_table}' AND wr_id = '{$wr_id}'"); + if ($act_button === 'move') { + sql_query("DELETE FROM {$g5['board_new_table']} WHERE bo_table = '{$bo_table}' AND wr_id = '{$wr_id}'"); sql_query("DELETE FROM {$g5['board_good_table']} WHERE bo_table = '{$bo_table}' AND wr_id = '{$wr_id}'"); - sql_query("DELETE FROM {$source_table} WHERE wr_id = '{$wr_id}'"); + sql_query("DELETE FROM {$source_table} WHERE wr_id = '{$wr_id}'"); - move_board_files($bo_table, $wr_id, $target_board, $new_wr_id); + move_board_files($bo_table, $wr_id, $target_board, $new_wr_id); } - sql_query("UPDATE {$g5['board_table']} SET bo_count_write = bo_count_write + 1 WHERE bo_table = '{$target_board}'"); + sql_query("UPDATE {$g5['board_table']} SET bo_count_write = bo_count_write + 1 WHERE bo_table = '{$target_board}'"); if ($act_button === 'move') { sql_query("UPDATE {$g5['board_table']} SET bo_count_write = bo_count_write - 1 WHERE bo_table = '{$bo_table}'"); @@ -185,7 +189,7 @@ function copy_board_files($source_bo_table, $source_wr_id, $target_bo_table, $ta @chmod($target_dir, G5_DIR_PERMISSION); } - for ($i = 0; $i < 10; $i++) { + for ($i = 0; $i < 10; $i++) { $file_field = 'wr_file' . $i; $source_field = 'bf_source' . $i; @@ -193,19 +197,19 @@ function copy_board_files($source_bo_table, $source_wr_id, $target_bo_table, $ta $source_file = $source_dir . '/' . $write_data[$file_field]; if (file_exists($source_file)) { - $new_filename = $target_wr_id . '_' . $i . '_' . time() . substr($write_data[$file_field], strrpos($write_data[$file_field], '.')); + $new_filename = $target_wr_id . '_' . $i . '_' . time() . substr($write_data[$file_field], strrpos($write_data[$file_field], '.')); $target_file = $target_dir . '/' . $new_filename; - if (@copy($source_file, $target_file)) { + if (@copy($source_file, $target_file)) { @chmod($target_file, G5_FILE_PERMISSION); - $bf_source = isset($write_data[$source_field]) ? $write_data[$source_field] : basename($write_data[$file_field]); + $bf_source = isset($write_data[$source_field]) ? $write_data[$source_field] : basename($write_data[$file_field]); $bf_filesize = filesize($target_file); $bf_width = 0; $bf_height = 0; $bf_type = 0; - if (preg_match("/\.(gif|jpg|jpeg|png)$/i", $new_filename)) { + if (preg_match("/\.(gif|jpg|jpeg|png)$/i", $new_filename)) { $size = @getimagesize($target_file); if ($size) { $bf_width = $size[0]; @@ -238,7 +242,7 @@ function move_board_files($source_bo_table, $source_wr_id, $target_bo_table, $ta { global $g5; - $sql = "SELECT * FROM {$g5['board_file_table']} + $sql = "SELECT * FROM {$g5['board_file_table']} WHERE bo_table = '{$source_bo_table}' AND wr_id = '{$source_wr_id}' ORDER BY bf_no"; $result = sql_query($sql); @@ -255,11 +259,11 @@ function move_board_files($source_bo_table, $source_wr_id, $target_bo_table, $ta $source_file = $source_dir . '/' . $row['bf_file']; if (file_exists($source_file)) { - $new_filename = $target_wr_id . '_' . $row['bf_no'] . '_' . time() . substr($row['bf_file'], strrpos($row['bf_file'], '.')); + $new_filename = $target_wr_id . '_' . $row['bf_no'] . '_' . time() . substr($row['bf_file'], strrpos($row['bf_file'], '.')); $target_file = $target_dir . '/' . $new_filename; - if (@rename($source_file, $target_file)) { - $sql = " INSERT INTO {$g5['board_file_table']} + if (@rename($source_file, $target_file)) { + $sql = " INSERT INTO {$g5['board_file_table']} SET bo_table = '{$target_bo_table}', wr_id = '{$target_wr_id}', bf_no = '{$row['bf_no']}', @@ -277,6 +281,6 @@ function move_board_files($source_bo_table, $source_wr_id, $target_bo_table, $ta } } - sql_query("DELETE FROM {$g5['board_file_table']} WHERE bo_table = '{$source_bo_table}' AND wr_id = '{$source_wr_id}'"); + sql_query("DELETE FROM {$g5['board_file_table']} WHERE bo_table = '{$source_bo_table}' AND wr_id = '{$source_wr_id}'"); } ?>