diff --git a/wheeparam/application/controllers/Board.php b/wheeparam/application/controllers/Board.php index 940e21a..8357422 100644 --- a/wheeparam/application/controllers/Board.php +++ b/wheeparam/application/controllers/Board.php @@ -692,17 +692,17 @@ class Board extends WB_Controller { { $filedata = $this->upload->data(); $this->data['upload_array'][] = array( - "brd_key" => $brd_key, + "att_target_type" => 'BOARD', "att_origin" => $filedata['orig_name'], - "att_filename" => $dir_path . "/" . $filedata['file_name'], - "att_caption" => $filedata['orig_name'], + "att_filepath" => $dir_path . "/" . $filedata['file_name'], "att_downloads" => 0, "att_filesize" => $filedata['file_size'] * 1024, - "att_image_width" => $filedata['image_width'] ? $filedata['image_width'] : 0, - "att_image_height" => $filedata['image_height'] ? $filedata['image_height'] : 0, + "att_width" => $filedata['image_width'] ? $filedata['image_width'] : 0, + "att_height" => $filedata['image_height'] ? $filedata['image_height'] : 0, "att_ext" => $filedata['file_ext'], "att_is_image" => ($filedata['is_image'] == 1) ? 'Y' : 'N', - "att_regtime" => date('Y-m-d H:i:s') + "reg_user" => $this->member->is_login(), + "reg_datetime" => date('Y-m-d H:i:s') ); } } @@ -806,9 +806,9 @@ class Board extends WB_Controller { if(isset($this->data['upload_array']) && count($this->data['upload_array']) >0 ) { foreach($this->data['upload_array'] as &$arr) { - $arr['post_idx'] = $post_idx; + $arr['att_target'] = $post_idx; } - $this->db->insert_batch("board_attach", $this->data['upload_array']); + $this->db->insert_batch("attach", $this->data['upload_array']); } // 자신의 글은 바로 볼수 있도록 @@ -885,7 +885,7 @@ class Board extends WB_Controller { $this->board_common($brd_key, 'download'); - if(! $att = $this->db->where('att_idx', $att_idx)->where('brd_key', $brd_key)->where('post_idx', $post_idx)->get('board_attach')->row_array()) + if(! $att = $this->db->where('att_idx', $att_idx)->where('att_target_type', 'BOARD')->where('att_target', $post_idx)->get('attach')->row_array()) { alert(langs( 'board/msg/invalid_attach_file' )); exit; @@ -895,8 +895,10 @@ class Board extends WB_Controller { $this->point_process('brd_point_download', "POST_ATTACH_DOWNLOAD", "첨부파일 다운로드", $post_idx, ($post['mem_userid'] == $this->member->info('userid')) ); + $this->db->where('att_idx', $att['att_idx'])->set('att_downloads', 'att_downloads + 1', FALSE)->update('attach'); + $this->load->helper('download'); - $data = file_get_contents(FCPATH.$att['att_filename']); + $data = file_get_contents(FCPATH.$att['att_filepath']); $name = urlencode($att['att_origin']); force_download($name, $data); } diff --git a/wheeparam/application/controllers/admin/Board.php b/wheeparam/application/controllers/admin/Board.php index 7f0a3c8..d59aa8b 100644 --- a/wheeparam/application/controllers/admin/Board.php +++ b/wheeparam/application/controllers/admin/Board.php @@ -446,17 +446,17 @@ class Board extends WB_Controller { $filedata = $this->upload->data(); $this->data['upload_array'][] = array( - "brd_key" => $brd_key, + "att_target_type" => 'BOARD', "att_origin" => $filedata['orig_name'], - "att_filename" => $dir_path . "/" . $filedata['file_name'], - "att_caption" => $filedata['orig_name'], + "att_filepath" => $dir_path . "/" . $filedata['file_name'], "att_downloads" => 0, "att_filesize" => $filedata['file_size'] * 1024, - "att_image_width" => $filedata['image_width'] ? $filedata['image_width'] : 0, - "att_image_height" => $filedata['image_height'] ? $filedata['image_height'] : 0, + "att_width" => $filedata['image_width'] ? $filedata['image_width'] : 0, + "att_height" => $filedata['image_height'] ? $filedata['image_height'] : 0, "att_ext" => $filedata['file_ext'], "att_is_image" => ($filedata['is_image'] == 1) ? 'Y' : 'N', - "att_regtime" => date('Y-m-d H:i:s') + "reg_user" => $this->member->is_login(), + "reg_datetime" => date('Y-m-d H:i:s') ); } } @@ -554,9 +554,9 @@ class Board extends WB_Controller if(isset($this->data['upload_array']) && count($this->data['upload_array']) >0 ) { foreach($this->data['upload_array'] as &$arr) { - $arr['post_idx'] = $post_idx; + $arr['att_target'] = $post_idx; } - $this->db->insert_batch("board_attach", $this->data['upload_array']); + $this->db->insert_batch("attach", $this->data['upload_array']); } alert(langs('게시판/msg/write_success'), base_url("admin/board/read/{$brd_key}/{$post_idx}")); diff --git a/wheeparam/application/helpers/common_helper.php b/wheeparam/application/helpers/common_helper.php index 0f7858f..a6f136d 100644 --- a/wheeparam/application/helpers/common_helper.php +++ b/wheeparam/application/helpers/common_helper.php @@ -712,7 +712,7 @@ function get_post_thumbnail($post, $thumb_width = '', $thumb_height = '') { if($file['att_is_image'] == 'Y') { - return thumbnail($file['att_filename'], $thumb_width, $thumb_height); + return thumbnail($file['att_filepath'], $thumb_width, $thumb_height); } } } diff --git a/wheeparam/application/models/Board_model.php b/wheeparam/application/models/Board_model.php index cdc308b..cef4087 100644 --- a/wheeparam/application/models/Board_model.php +++ b/wheeparam/application/models/Board_model.php @@ -203,7 +203,7 @@ class Board_model extends WB_Model function get_attach_list($brd_key, $post_idx) { if(empty($brd_key) OR empty($post_idx)) return array(); - $file_list = $this->db->where('brd_key', $brd_key)->where('post_idx', $post_idx)->get('board_attach')->result_array(); + $file_list = $this->db->where('att_target_type', 'BOARD')->where('att_target', $post_idx)->get('attach')->result_array(); foreach($file_list as &$f) { $f['link'] = base_url("board/{$brd_key}/download/{$post_idx}/{$f['att_idx']}"); @@ -290,15 +290,15 @@ class Board_model extends WB_Model { if(empty($att_idx)) return false; $this->db->where("att_idx", $att_idx); - $result = $this->db->get('board_attach'); + $result = $this->db->get('attach'); $attach = $result->row_array(); if(! $attach) return false; - if( file_exists(FCPATH. $attach['att_filename']) ) + if( file_exists(FCPATH. $attach['att_filepath']) ) { - @unlink(FCPATH.$attach['att_filename']); + @unlink(FCPATH.$attach['att_filepath']); } $this->db->where("att_idx", $att_idx); - $this->db->delete("board_attach"); + $this->db->delete("attach"); } /** diff --git a/wheeparam/config/wheeparam.sql b/wheeparam/config/wheeparam.sql index ee495f8..a439595 100644 --- a/wheeparam/config/wheeparam.sql +++ b/wheeparam/config/wheeparam.sql @@ -135,29 +135,6 @@ PRIMARY KEY (`brd_key`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; - -DROP TABLE IF EXISTS `wb_board_attach`; -CREATE TABLE `wb_board_attach` ( - `att_idx` int(10) unsigned NOT NULL AUTO_INCREMENT, - `brd_key` varchar(20) NOT NULL DEFAULT '''''', - `post_idx` int(10) unsigned NOT NULL DEFAULT '0', - `att_is_image` enum('Y','N') NOT NULL DEFAULT 'N', - `att_origin` varchar(255) NOT NULL DEFAULT '''''', - `att_filename` varchar(255) NOT NULL DEFAULT '0', - `att_caption` varchar(255) NOT NULL DEFAULT '''''', - `att_downloads` int(10) unsigned NOT NULL DEFAULT '0', - `att_ext` varchar(10) NOT NULL DEFAULT '''''', - `att_regtime` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - `att_ip` int(10) unsigned NOT NULL DEFAULT '0', - `att_filesize` int(10) unsigned NOT NULL DEFAULT '0', - `att_image_width` int(10) unsigned NOT NULL DEFAULT '0', - `att_image_height` int(10) unsigned NOT NULL DEFAULT '0', - PRIMARY KEY (`att_idx`), - KEY `brd_key` (`brd_key`), - KEY `post_idx` (`post_idx`), - KEY `att_is_image` (`att_is_image`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - DROP TABLE IF EXISTS `wb_board_category`; CREATE TABLE `wb_board_category` ( `bca_idx` int(10) unsigned NOT NULL AUTO_INCREMENT, diff --git a/wheeparam/views/skins/board/view/basic/view.php b/wheeparam/views/skins/board/view/basic/view.php index 7d63f0c..bf5d0ab 100644 --- a/wheeparam/views/skins/board/view/basic/view.php +++ b/wheeparam/views/skins/board/view/basic/view.php @@ -54,7 +54,7 @@