/** * 팝업을 보여줍니다 */ public function display_popup() { /** * 레이아웃을 정의합니다 */ $pagetitle = '팝업알림'; $skin_file = 'popup'; $skindir = $this->CI->cbconfig->get_device_view_type() === 'mobile' ? $this->CI->cbconfig->item('mobile_skin_popup') : $this->CI->cbconfig->item('skin_popup'); if (empty($skindir)) { $skindir = $this->CI->cbconfig->get_device_view_type() === 'mobile' ? $this->CI->cbconfig->item('mobile_skin_default') : $this->CI->cbconfig->item('skin_default'); } $view_skin_file = 'popup/' . $skindir . '/' . $skin_file; $view = array(); $view['view'] = array(); $view['view'] = $this->get_today_popup_data(); $list = array(); if (element('list', element('view', $view))) { foreach (element('list', element('view', $view)) as $key => $value) { if (get_cookie('popup_layer_' . element('pop_id', $value))) { continue; } if ($this->CI->cbconfig->get_device_view_type() === 'mobile' && element('pop_device', $value) === 'pc') { continue; } if ($this->CI->cbconfig->get_device_view_type() !== 'mobile' && element('pop_device', $value) === 'mobile') { continue; } if (!element('pop_page', $value) && $this->CI->uri->segment(1)) { continue; } $content = element('pop_content', $value); $thumb_width = $this->CI->cbconfig->get_device_view_type() === 'mobile' ? $this->CI->cbconfig->item('popup_mobile_thumb_width') : $this->CI->cbconfig->item('popup_thumb_width'); $autolink = $this->CI->cbconfig->get_device_view_type() === 'mobile' ? $this->CI->cbconfig->item('use_popup_mobile_auto_url') : $this->CI->cbconfig->item('use_popup_auto_url'); $popup = $this->CI->cbconfig->get_device_view_type() === 'mobile' ? $this->CI->cbconfig->item('popup_mobile_content_target_blank') : $this->CI->cbconfig->item('popup_content_target_blank'); $value['content'] = display_html_content($content, element('pop_content_html_type', $value), $thumb_width, $autolink, $popup, $writer_is_admin = true); $list[] = $value; } } $view['view']['popup'] = $list; if ($list) { return $this->CI->load->view($view_skin_file, $view, true); } }
/** * FAQ 페이지입니다 */ public function index($fgr_key = '') { // 이벤트 라이브러리를 로딩합니다 $eventname = 'event_faq_index'; $this->load->event($eventname); $view = array(); $view['view'] = array(); // 이벤트가 존재하면 실행합니다 $view['view']['event']['before'] = Events::trigger('before', $eventname); if (empty($fgr_key)) { show_404(); } $where = array('fgr_key' => $fgr_key); $faqgroup = $this->Faq_group_model->get_one('', '', $where); if (!element('fgr_id', $faqgroup)) { show_404(); } /** * 페이지에 숫자가 아닌 문자가 입력되거나 1보다 작은 숫자가 입력되면 에러 페이지를 보여줍니다. */ $param =& $this->querystring; $page = (int) $this->input->get('page') > 0 ? (int) $this->input->get('page') : 1; $findex = 'faq_order'; $forder = 'asc'; $sfield = array('faq_title', 'faq_content', 'faq_mobile_content'); $skeyword = $this->input->get('skeyword', null, ''); $per_page = $this->cbconfig->item('list_count') ? (int) $this->cbconfig->item('list_count') : 20; $offset = ($page - 1) * $per_page; /** * 게시판 목록에 필요한 정보를 가져옵니다. */ $this->Faq_model->allow_search_field = array('faq_title', 'faq_content', 'faq_mobile_content'); // 검색이 가능한 필드 $this->Faq_model->search_field_equal = array(); // 검색중 like 가 아닌 = 검색을 하는 필드 $this->Faq_model->allow_order_field = array('faq_order'); // 정렬이 가능한 필드 $where = array('fgr_id' => element('fgr_id', $faqgroup)); $result = $this->Faq_model->get_list($per_page, $offset, $where, '', $findex, $forder, $sfield, $skeyword); if (element('list', $result)) { foreach (element('list', $result) as $key => $val) { $content = $this->cbconfig->get_device_view_type() === 'mobile' ? element('faq_mobile_content', $val) ? element('faq_mobile_content', $val) : element('faq_content', $val) : element('faq_content', $val); $thumb_width = $this->cbconfig->get_device_view_type() === 'mobile' ? $this->cbconfig->item('faq_mobile_thumb_width') : $this->cbconfig->item('faq_thumb_width'); $autolink = $this->cbconfig->get_device_view_type() === 'mobile' ? $this->cbconfig->item('use_faq_mobile_auto_url') : $this->cbconfig->item('use_faq_auto_url'); $popup = $this->cbconfig->get_device_view_type() === 'mobile' ? $this->cbconfig->item('faq_mobile_content_target_blank') : $this->cbconfig->item('faq_content_target_blank'); $result['list'][$key]['title'] = display_html_content(element('faq_title', $val), element('faq_content_html_type', $val), $thumb_width, $autolink, $popup, $writer_is_admin = true); $result['list'][$key]['content'] = display_html_content($content, element('faq_content_html_type', $val), $thumb_width, $autolink, $popup, $writer_is_admin = true); } } $list_num = $result['total_rows'] - ($page - 1) * $per_page; $view['view']['data'] = $result; $view['view']['faqgroup'] = $faqgroup; /** * 페이지네이션을 생성합니다 */ $config['base_url'] = faq_url($fgr_key) . '?' . $param->replace('page'); $config['total_rows'] = $result['total_rows']; $config['per_page'] = $per_page; $this->pagination->initialize($config); $view['view']['paging'] = $this->pagination->create_links(); $view['view']['page'] = $page; $view['view']['canonical'] = faq_url($fgr_key); // 이벤트가 존재하면 실행합니다 $view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname); /** * 레이아웃을 정의합니다 */ $page_title = $this->cbconfig->item('site_meta_title_faq'); $meta_description = $this->cbconfig->item('site_meta_description_faq'); $meta_keywords = $this->cbconfig->item('site_meta_keywords_faq'); $meta_author = $this->cbconfig->item('site_meta_author_faq'); $page_name = $this->cbconfig->item('site_page_name_faq'); $searchconfig = array('{FAQ제목}', '{FAQ아이디}'); $replaceconfig = array(element('fgr_title', $faqgroup), $fgr_key); $page_title = str_replace($searchconfig, $replaceconfig, $page_title); $meta_description = str_replace($searchconfig, $replaceconfig, $meta_description); $meta_keywords = str_replace($searchconfig, $replaceconfig, $meta_keywords); $meta_author = str_replace($searchconfig, $replaceconfig, $meta_author); $page_name = str_replace($searchconfig, $replaceconfig, $page_name); $layout_dir = element('fgr_layout', $faqgroup) ? element('fgr_layout', $faqgroup) : $this->cbconfig->item('layout_faq'); $mobile_layout_dir = element('fgr_mobile_layout', $faqgroup) ? element('fgr_mobile_layout', $faqgroup) : $this->cbconfig->item('mobile_layout_faq'); $use_sidebar = element('fgr_sidebar', $faqgroup) ? element('fgr_sidebar', $faqgroup) : $this->cbconfig->item('sidebar_faq'); $use_mobile_sidebar = element('fgr_mobile_sidebar', $faqgroup) ? element('fgr_mobile_sidebar', $faqgroup) : $this->cbconfig->item('mobile_sidebar_faq'); $skin_dir = element('fgr_skin', $faqgroup) ? element('fgr_skin', $faqgroup) : $this->cbconfig->item('skin_faq'); $mobile_skin_dir = element('fgr_mobile_skin', $faqgroup) ? element('fgr_mobile_skin', $faqgroup) : $this->cbconfig->item('mobile_skin_faq'); $layoutconfig = array('path' => 'faq', 'layout' => 'layout', 'skin' => 'faq', 'layout_dir' => $layout_dir, 'mobile_layout_dir' => $mobile_layout_dir, 'use_sidebar' => $use_sidebar, 'use_mobile_sidebar' => $use_mobile_sidebar, 'skin_dir' => $skin_dir, 'mobile_skin_dir' => $mobile_skin_dir, 'page_title' => $page_title, 'meta_description' => $meta_description, 'meta_keywords' => $meta_keywords, 'meta_author' => $meta_author, 'page_name' => $page_name); $view['layout'] = $this->managelayout->front($layoutconfig, $this->cbconfig->get_device_view_type()); $this->data = $view; $this->layout = element('layout_skin_file', element('layout', $view)); $this->view = element('view_skin_file', element('layout', $view)); }
/** * 게시물 열람 페이지입니다 */ public function post($post_id = 0, $print = false) { // 이벤트 라이브러리를 로딩합니다 $eventname = 'event_board_post_post'; $this->load->event($eventname); $view = array(); $view['view'] = array(); // 이벤트가 존재하면 실행합니다 $view['view']['event']['before'] = Events::trigger('before', $eventname); /** * 프라이머리키에 숫자형이 입력되지 않으면 에러처리합니다 */ $post_id = (int) $post_id; if (empty($post_id) or $post_id < 1) { show_404(); } $post = $this->Post_model->get_one($post_id); $post['meta'] = $this->Post_meta_model->get_all_meta($post_id); $post['extravars'] = $this->Post_extra_vars_model->get_all_meta($post_id); $view['view']['post'] = $post; $mem_id = (int) $this->member->item('mem_id'); if (!element('post_id', $post)) { show_404(); } if (element('post_del', $post) > 1) { show_404(); } $board = $this->board->item_all(element('brd_id', $post)); if (!element('brd_id', $board)) { show_404(); } $skeyword = $this->input->get('skeyword', null, ''); if ($print === false && $this->uri->segment('1') !== config_item('uri_segment_admin')) { if (strtoupper(config_item('uri_segment_post_type')) === 'B') { if ($this->uri->segment('1') !== element('brd_key', $board)) { show_404(); } } elseif (strtoupper(config_item('uri_segment_post_type')) === 'C') { if ($this->uri->segment('2') !== element('brd_key', $board)) { show_404(); } } } $alertmessage = $this->member->is_member() ? '회원님은 내용을 볼 수 있는 권한이 없습니다' : '비회원은 내용을 볼 수 있는 권한이 없습니다.\\n\\n회원이시라면 로그인 후 이용해 보십시오'; $check = array('group_id' => element('bgr_id', $board), 'board_id' => element('brd_id', $board)); $this->accesslevel->check(element('access_view', $board), element('access_view_level', $board), element('access_view_group', $board), $alertmessage, $check); $view['view']['is_admin'] = $is_admin = $this->member->is_admin(array('board_id' => element('brd_id', $board), 'group_id' => element('bgr_id', $board))); $view['view']['board_key'] = element('brd_key', $board); if (element('use_personal', $board) && $this->member->is_member() === false) { alert('이 게시판은 1:1 게시판입니다. 비회원은 접근할 수 없습니다'); return false; } if ($print && !element('use_print', $board)) { alert('이 게시판은 프린트 기능을 지원하지 않습니다'); return false; } if (element('post_secret', $post)) { if (element('mem_id', $post)) { if ($is_admin === false && $mem_id !== (int) element('mem_id', $post)) { alert('비밀글은 본인과 관리자만 확인 가능합니다'); return false; } } else { if ($is_admin !== false) { $this->session->set_userdata('view_secret_' . element('post_id', $post), '1'); } if (!$this->session->userdata('view_secret_' . element('post_id', $post)) && $this->input->post('modify_password')) { if (!function_exists('password_hash')) { $this->load->helper('password'); } if (password_verify($this->input->post('modify_password'), element('post_password', $post))) { $this->session->set_userdata('view_secret_' . element('post_id', $post), '1'); redirect(current_url()); } else { $view['view']['message'] = '패스워드가 잘못 입력되었습니다'; } } if (!$this->session->userdata('view_secret_' . element('post_id', $post))) { // 이벤트가 존재하면 실행합니다 $view['view']['event']['before_secret_layout'] = Events::trigger('before_secret_layout', $eventname); /** * 레이아웃을 정의합니다 */ $view['view']['info'] = '비밀글 열람을 위한 패스워드 입력페이지입니다.<br />패스워드를 입력하시면 비밀글 열람이 가능합니다'; $page_title = element('board_name', $board) . ' 글열람'; $layout_dir = element('board_layout', $board) ? element('board_layout', $board) : $this->cbconfig->item('layout_board'); $mobile_layout_dir = element('board_mobile_layout', $board) ? element('board_mobile_layout', $board) : $this->cbconfig->item('mobile_layout_board'); $use_sidebar = element('board_sidebar', $board) ? element('board_sidebar', $board) : $this->cbconfig->item('sidebar_board'); $use_mobile_sidebar = element('board_mobile_sidebar', $board) ? element('board_mobile_sidebar', $board) : $this->cbconfig->item('mobile_sidebar_board'); $skin_dir = element('board_skin', $board) ? element('board_skin', $board) : $this->cbconfig->item('skin_board'); $mobile_skin_dir = element('board_mobile_skin', $board) ? element('board_mobile_skin', $board) : $this->cbconfig->item('mobile_skin_board'); $layoutconfig = array('path' => 'board', 'layout' => 'layout', 'skin' => 'password', 'layout_dir' => $layout_dir, 'mobile_layout_dir' => $mobile_layout_dir, 'use_sidebar' => $use_sidebar, 'use_mobile_sidebar' => $use_mobile_sidebar, 'skin_dir' => $skin_dir, 'mobile_skin_dir' => $mobile_skin_dir, 'page_title' => $page_title); $view['layout'] = $this->managelayout->front($layoutconfig, $this->cbconfig->get_device_view_type()); $this->data = $view; $this->layout = element('layout_skin_file', element('layout', $view)); $this->view = element('view_skin_file', element('layout', $view)); return true; } } } if ($mem_id > 0 && $mem_id !== (int) element('mem_id', $post) && element('use_point', $board)) { $point = $this->point->insert_point($mem_id, element('point_read', $board), element('board_name', $board) . ' ' . $post_id . ' 게시글열람', 'post_read', $post_id, '게시글열람'); if (element('point_read', $board) < 0 && $point < 0 && $this->cbconfig->item('block_read_zeropoint')) { $this->point->delete_point($mem_id, 'post_read', $post_id, '게시글열람'); alert('회원님은 포인트가 부족하므로 글을 열람하실 수 없습니다. 글 읽기시 ' . element('point_read', $board) * -1 . ' 포인트가 차감됩니다'); return false; } } if (element('use_personal', $board) && $is_admin === false && $mem_id !== (int) element('mem_id', $post)) { alert('1:1 게시판은 본인의 글 이외의 열람이 금지되어있습니다.'); return false; } // 이벤트가 존재하면 실행합니다 $view['view']['event']['step1'] = Events::trigger('step1', $eventname); $this->_stat_count_board(element('brd_id', $board)); // stat_count_board ++ // 세션 생성 if (!$this->session->userdata('post_id_' . $post_id)) { $this->Post_model->update_plus($post_id, 'post_hit', 1); $this->session->set_userdata('post_id_' . $post_id, '1'); } $use_sideview = $this->cbconfig->get_device_view_type() === 'mobile' ? element('use_mobile_sideview', $board) : element('use_sideview', $board); $view_date_style = $this->cbconfig->get_device_view_type() === 'mobile' ? element('mobile_view_date_style', $board) : element('view_date_style', $board); $view_date_style_manual = $this->cbconfig->get_device_view_type() === 'mobile' ? element('mobile_view_date_style_manual', $board) : element('view_date_style_manual', $board); $dbmember = $this->Member_model->get_by_memid(element('mem_id', $post), 'mem_icon'); $view['view']['post']['display_name'] = display_username(element('post_userid', $post), element('post_nickname', $post), element('mem_icon', $dbmember), $use_sideview ? 'Y' : 'N'); $view['view']['post']['display_datetime'] = display_datetime(element('post_datetime', $post), $view_date_style, $view_date_style_manual); $view['view']['post']['is_mobile'] = element('post_device', $post) === 'mobile' ? true : false; $view['view']['post']['category'] = ''; if (element('use_category', $board) && element('post_category', $post)) { $this->load->model('Board_category_model'); $view['view']['post']['category'] = $this->Board_category_model->get_category_info(element('brd_id', $post), element('post_category', $post)); } $view['view']['post']['display_ip'] = ''; $show_ip = $this->cbconfig->get_device_view_type() === 'mobile' ? element('show_mobile_ip', $board) : element('show_ip', $board); if ($this->member->is_admin() === 'super' or $show_ip === '2') { $view['view']['post']['display_ip'] = display_ipaddress(element('post_ip', $post), '1111'); } elseif ($show_ip === '1') { $view['view']['post']['display_ip'] = display_ipaddress(element('post_ip', $post), $this->cbconfig->item('ip_display_style')); } $image_width = $this->cbconfig->get_device_view_type() === 'mobile' ? element('post_mobile_image_width', $board) : element('post_image_width', $board); $board['target_blank'] = $target_blank = $this->cbconfig->get_device_view_type() === 'mobile' ? element('mobile_content_target_blank', $board) : element('content_target_blank', $board); $link_player = ''; $view['view']['link'] = $link = array(); if (element('post_link_count', $post)) { $this->load->model('Post_link_model'); $linkwhere = array('post_id' => $post_id); $view['view']['link'] = $link = $this->Post_link_model->get('', '', $linkwhere, '', '', 'pln_id', 'ASC'); if ($link && is_array($link)) { foreach ($link as $key => $value) { $view['view']['link'][$key]['link_link'] = site_url('postact/link/' . element('pln_id', $value)); if (element('use_autoplay', $board)) { $link_player .= $this->videoplayer->get_video(prep_url(element('pln_url', $value))); } } } } $view['view']['link_count'] = $link_count = count($link); $file_player = ''; if (element('post_file', $post) or element('post_image', $post)) { $this->load->model('Post_file_model'); $filewhere = array('post_id' => $post_id); $view['view']['file'] = $file = $this->Post_file_model->get('', '', $filewhere, '', '', 'pfi_id', 'ASC'); $view['view']['file_download'] = array(); $view['view']['file_image'] = array(); $play_extension = array('acc', 'flv', 'f4a', 'f4v', 'mov', 'mp3', 'mp4', 'm4a', 'm4v', 'oga', 'ogg', 'rss', 'webm'); if ($file && is_array($file)) { foreach ($file as $key => $value) { if (element('pfi_is_image', $value)) { $value['origin_image_url'] = site_url('uploads/post/' . element('pfi_filename', $value)); $value['thumb_image_url'] = thumb_url('post', element('pfi_filename', $value), $image_width); $view['view']['file_image'][] = $value; } else { $value['download_link'] = site_url('postact/download/' . element('pfi_id', $value)); $view['view']['file_download'][] = $value; if (element('use_autoplay', $board) && in_array(element('pfi_type', $value), $play_extension)) { $file_player .= $this->videoplayer->get_jwplayer(site_url('uploads/post/' . element('pfi_filename', $value)), $image_width); } } } } $view['view']['file_count'] = count($file); $view['view']['file_download_count'] = count($view['view']['file_download']); $view['view']['file_image_count'] = count($view['view']['file_image']); } $autourl = $this->cbconfig->get_device_view_type() === 'mobile' ? element('use_mobile_auto_url', $board) : element('use_auto_url', $board); $autolink = $autourl ? true : false; $popup = $target_blank ? true : false; $view['view']['post']['content'] = ''; if (element('post_del', $post)) { $view['view']['post']['post_title'] = '게시물이 삭제되었습니다'; $view['view']['post']['content'] = '<div class="alert alert-danger">이 게시물은 ' . html_escape(element('delete_mem_nickname', element('meta', $post))) . '님에 의해 ' . html_escape(element('delete_datetime', element('meta', $post))) . ' 에 삭제 되었습니다</div>'; } else { $is_blind = element('blame_blind_count', $board) > 0 && element('post_blame', $post) >= element('blame_blind_count', $board) ? true : false; if ($is_blind === true) { $view['view']['post']['content'] .= '<div class="alert alert-danger">신고가 접수된 게시글입니다. 본인과 관리자만 확인이 가능합니다</div>'; } if ($is_blind === false or $is_admin !== false or element('mem_id', $post) && (int) element('mem_id', $post) === $mem_id) { $view['view']['post']['content'] .= $file_player . $link_player . display_html_content(element('post_content', $post), element('post_html', $post), $image_width, $autolink, $popup); if (element('syntax_highlighter', $board)) { if (element('post_html', $post)) { $view['view']['post']['content'] = preg_replace_callback("/(\\[code\\]|\\[code=(.*)\\])(.*)\\[\\/code\\]/iUs", "content_syntaxhighlighter_html", $view['view']['post']['content']); // SyntaxHighlighter } else { $view['view']['post']['content'] = preg_replace_callback("/(\\[code\\]|\\[code=(.*)\\])(.*)\\[\\/code\\]/iUs", "content_syntaxhighlighter", $view['view']['post']['content']); // SyntaxHighlighter } } } $extravars = element('extravars', $board); $form = json_decode($extravars, true); $extra_content = ''; $k = 0; if ($form && is_array($form)) { foreach ($form as $key => $value) { if (!element('use', $value)) { continue; } $item = element(element('field_name', $value), element('extravars', $post)); $extra_content[$k]['field_name'] = element('field_name', $value); $extra_content[$k]['display_name'] = element('display_name', $value); if (element('field_type', $value) === 'checkbox') { $tmp_value = json_decode($item); $tmp = ''; if ($tmp_value) { foreach ($tmp_value as $val) { if ($tmp) { $tmp .= ', '; } $tmp .= $val; } } $item = $tmp; } $extra_content[$k]['output'] = $item; $k++; } } $view['view']['extra_content'] = $extra_content; } $show_list_from_view = $this->cbconfig->get_device_view_type() === 'mobile' ? element('mobile_show_list_from_view', $board) : element('show_list_from_view', $board); $board['headercontent'] = $this->cbconfig->get_device_view_type() === 'mobile' ? element('mobile_header_content', $board) : element('header_content', $board); if (empty($show_list_from_view)) { $board['footercontent'] = $this->cbconfig->get_device_view_type() === 'mobile' ? element('mobile_footer_content', $board) : element('footer_content', $board); } $skindir = $this->cbconfig->get_device_view_type() === 'mobile' ? element('board_mobile_skin', $board) ? element('board_mobile_skin', $board) : element('board_skin', $board) : element('board_skin', $board); $skinurl = base_url(VIEW_DIR . 'board/' . $skindir); $view['view']['post_url'] = $post_url = post_url(element('brd_key', $board), $post_id); $param =& $this->querystring; $view['view']['board'] = $board; $this->load->model('Scrap_model'); $countwhere = array('post_id' => element('post_id', $post)); $view['view']['post']['scrap_count'] = $this->Scrap_model->count_by($countwhere); $view['view']['comment']['is_cmt_name'] = $is_cmt_name = $this->member->is_member() === false ? true : false; $view['view']['comment']['show_textarea'] = $this->cbconfig->get_device_view_type() === 'mobile' ? element('mobile_always_show_comment_textarea', $board) : element('always_show_comment_textarea', $board); $check = array('group_id' => element('bgr_id', $board), 'board_id' => element('brd_id', $board)); $can_write = $this->accesslevel->is_accessable(element('access_write', $board), element('access_write_level', $board), element('access_write_group', $board), $check); $can_comment_write = $this->accesslevel->is_accessable(element('access_comment', $board), element('access_comment_level', $board), element('access_comment_group', $board), $check); $can_comment_write_message = ''; if ($can_comment_write === false) { $can_comment_write_message = '비회원은 댓글쓰기 권한이 없습니다. 회원이시라면 로그인후 이용해보십시오'; } $can_reply = $this->accesslevel->is_accessable(element('access_reply', $board), element('access_reply_level', $board), element('access_reply_group', $board), $check); $can_modify = ($is_admin !== false or $mem_id > 0 && $mem_id === (int) element('mem_id', $post) or !element('mem_id', $post)) ? true : false; $can_delete = ($is_admin !== false or $mem_id > 0 && $mem_id === (int) element('mem_id', $post) or !element('mem_id', $post)) ? true : false; $view['view']['write_url'] = ''; if ($can_write === true) { $view['view']['write_url'] = write_url(element('brd_key', $board)); } elseif ($this->cbconfig->get_device_view_type() !== 'mobile' && element('always_show_write_button', $board)) { $view['view']['write_url'] = 'javascript:alert(\'비회원은 글쓰기 권한이 없습니다.\\n\\n회원이시라면 로그인 후 이용해 보십시오.\');'; } elseif ($this->cbconfig->get_device_view_type() === 'mobile' && element('mobile_always_show_write_button', $board)) { $view['view']['write_url'] = 'javascript:alert(\'비회원은 글쓰기 권한이 없습니다.\\n\\n회원이시라면 로그인 후 이용해 보십시오.\');'; } $view['view']['reply_url'] = $can_reply === true && !element('post_del', $post) ? reply_url(element('post_id', $post)) : ''; $view['view']['modify_url'] = $can_modify && !element('post_del', $post) ? modify_url(element('post_id', $post) . '?' . $param->output()) : ''; $view['view']['delete_url'] = $can_delete && !element('post_del', $post) ? site_url('postact/delete/' . element('post_id', $post) . '?' . $param->output()) : ''; if ($skeyword) { $view['view']['list_url'] = board_url(element('brd_key', $board)); $view['view']['search_list_url'] = board_url(element('brd_key', $board) . '?' . $param->output()); } else { $view['view']['list_url'] = board_url(element('brd_key', $board) . '?' . $param->output()); $view['view']['search_list_url'] = ''; } $view['view']['trash_url'] = site_url('boards/trash/' . element('post_id', $post) . '?' . $param->output()); if (element('notice_comment_block', $board) && element('post_notice', $post)) { $can_comment_write = false; $can_comment_write_message = '공지사항 글에는 댓글 입력이 제한되어 있습니다.'; } if (element('post_del', $post)) { $can_comment_write = false; $can_comment_write_message = '삭제된 글에는 댓글 입력이 제한되어 있습니다.'; } $use_sns_button = false; if ($this->cbconfig->get_device_view_type() !== 'mobile' && element('use_sns', $board)) { $use_sns_button = true; } if ($this->cbconfig->get_device_view_type() === 'mobile' && element('use_mobile_sns', $board)) { $use_sns_button = true; } $view['view']['use_sns_button'] = $use_sns_button; $highlight_keyword = ''; if ($skeyword) { $key_explode = explode(' ', $skeyword); if ($key_explode) { foreach ($key_explode as $seval) { if ($highlight_keyword) { $highlight_keyword .= ','; } $highlight_keyword .= '\'' . html_escape($seval) . '\''; } } } $view['view']['highlight_keyword'] = $highlight_keyword; // 이벤트가 존재하면 실행합니다 $view['view']['event']['step2'] = Events::trigger('step2', $eventname); $view['view']['next_post'] = ''; $view['view']['prev_post'] = ''; $use_prev_next = false; if ($this->cbconfig->get_device_view_type() !== 'mobile' && element('use_prev_next_post', $board)) { $use_prev_next = true; } if ($this->cbconfig->get_device_view_type() === 'mobile' && element('use_mobile_prev_next_post', $board)) { $use_prev_next = true; } if ($use_prev_next) { $where = ''; $where['brd_id'] = element('brd_id', $post); $where['post_del <>'] = 2; $where['post_secret'] = 0; if (element('except_notice', $board) && $this->cbconfig->get_device_view_type() !== 'mobile') { $where['post_notice'] = 0; } if (element('mobile_except_notice', $board) && $this->cbconfig->get_device_view_type() === 'mobile') { $where['post_notice'] = 0; } if (element('use_personal', $board) && $is_admin === false) { $where['post.mem_id'] = $mem_id; } $sfield = $sfieldchk = $this->input->get('sfield', null, ''); if ($sfield === 'post_both') { $sfield = array('post_title', 'post_content'); } $skeyword = $this->input->get('skeyword', null, ''); $view['view']['next_post'] = $next_post = $this->Post_model->get_prev_next_post(element('post_id', $post), element('post_num', $post), 'next', $where, $sfield, $skeyword); if (element('post_id', $next_post)) { $view['view']['next_post']['url'] = post_url(element('brd_key', $board), element('post_id', $next_post)) . '?' . $param->output(); } $view['view']['prev_post'] = $prev_post = $this->Post_model->get_prev_next_post(element('post_id', $post), element('post_num', $post), 'prev', $where, $sfield, $skeyword); if (element('post_id', $prev_post)) { $view['view']['prev_post']['url'] = post_url(element('brd_key', $board), element('post_id', $prev_post)) . '?' . $param->output(); } } $view['view']['comment']['can_comment_write'] = $can_comment_write; $view['view']['comment']['can_comment_write_message'] = $can_comment_write_message; $view['view']['comment']['can_comment_view'] = true; $view['view']['comment']['is_comment_name'] = $this->member->is_member() === false ? true : false; $view['view']['comment']['can_comment_secret'] = element('use_comment_secret', $board) === '1' && $this->member->is_member() ? true : false; $view['view']['comment']['cmt_secret'] = element('use_comment_secret_selected', $board) ? '1' : ''; $password_length = $this->cbconfig->item('password_length'); $view['view']['comment']['password_length'] = $password_length; $view['view']['comment']['cmt_content'] = $this->cbconfig->get_device_view_type() === 'mobile' ? element('mobile_comment_default_content', $board) : element('comment_default_content', $board); if ($show_list_from_view) { $view['view']['list'] = $list = $this->_get_list(element('brd_key', $board), 1); } // 이벤트가 존재하면 실행합니다 $view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname); /** * 레이아웃을 정의합니다 */ $page_title = $this->cbconfig->item('site_meta_title_board_post'); $meta_description = $this->cbconfig->item('site_meta_description_board_post'); $meta_keywords = $this->cbconfig->item('site_meta_keywords_board_post'); $meta_author = $this->cbconfig->item('site_meta_author_board_post'); $page_name = $this->cbconfig->item('site_page_name_board_post'); $searchconfig = array('{게시판명}', '{게시판아이디}', '{글제목}', '{작성자명}'); $replaceconfig = array(element('board_name', $board), element('brd_key', $board), element('post_title', $post), element('post_nickname', $post)); $page_title = str_replace($searchconfig, $replaceconfig, $page_title); $meta_description = str_replace($searchconfig, $replaceconfig, $meta_description); $meta_keywords = str_replace($searchconfig, $replaceconfig, $meta_keywords); $meta_author = str_replace($searchconfig, $replaceconfig, $meta_author); $page_name = str_replace($searchconfig, $replaceconfig, $page_name); if ($print === false) { // 이벤트가 존재하면 실행합니다 $view['view']['event']['before_post_layout'] = Events::trigger('before_post_layout', $eventname); $view['view']['canonical'] = post_url(element('brd_key', $board), $post_id); $layout_dir = element('board_layout', $board) ? element('board_layout', $board) : $this->cbconfig->item('layout_board'); $mobile_layout_dir = element('board_mobile_layout', $board) ? element('board_mobile_layout', $board) : $this->cbconfig->item('mobile_layout_board'); $use_sidebar = element('board_sidebar', $board) ? element('board_sidebar', $board) : $this->cbconfig->item('sidebar_board'); $use_mobile_sidebar = element('board_mobile_sidebar', $board) ? element('board_mobile_sidebar', $board) : $this->cbconfig->item('mobile_sidebar_board'); $skin_dir = element('board_skin', $board) ? element('board_skin', $board) : $this->cbconfig->item('skin_board'); $mobile_skin_dir = element('board_mobile_skin', $board) ? element('board_mobile_skin', $board) : $this->cbconfig->item('mobile_skin_board'); $layoutconfig = array('path' => 'board', 'layout' => 'layout', 'skin' => 'post', 'layout_dir' => $layout_dir, 'mobile_layout_dir' => $mobile_layout_dir, 'use_sidebar' => $use_sidebar, 'use_mobile_sidebar' => $use_mobile_sidebar, 'skin_dir' => $skin_dir, 'mobile_skin_dir' => $mobile_skin_dir, 'page_title' => $page_title, 'meta_description' => $meta_description, 'meta_keywords' => $meta_keywords, 'meta_author' => $meta_author, 'page_name' => $page_name); $view['layout'] = $this->managelayout->front($layoutconfig, $this->cbconfig->get_device_view_type()); $this->data = $view; $this->layout = element('layout_skin_file', element('layout', $view)); if ($show_list_from_view) { $list_skin_file = element('use_gallery_list', $board) ? 'gallerylist' : 'list'; $listskindir = $this->cbconfig->get_device_view_type() === 'mobile' ? $mobile_skin_dir : $skin_dir; if (empty($listskindir)) { $listskindir = $this->cbconfig->get_device_view_type() === 'mobile' ? $this->cbconfig->item('mobile_skin_default') : $this->cbconfig->item('skin_default'); } $this->view = array(element('view_skin_file', element('layout', $view)), 'board/' . $listskindir . '/' . $list_skin_file); } else { $this->view = element('view_skin_file', element('layout', $view)); } } else { // 이벤트가 존재하면 실행합니다 $view['view']['event']['before_print_layout'] = Events::trigger('before_print_layout', $eventname); $layoutconfig = array('path' => 'helptool', 'layout' => 'layout_popup', 'skin' => 'print', 'layout_dir' => $this->cbconfig->item('layout_helptool'), 'mobile_layout_dir' => $this->cbconfig->item('mobile_layout_helptool'), 'skin_dir' => $this->cbconfig->item('skin_helptool'), 'mobile_skin_dir' => $this->cbconfig->item('mobile_skin_helptool'), 'page_title' => $page_title); $view['layout'] = $this->managelayout->front($layoutconfig, $this->cbconfig->get_device_view_type()); $this->data = $view; $this->layout = element('layout_skin_file', element('layout', $view)); $this->view = element('view_skin_file', element('layout', $view)); } }
/** * 댓글 목록을 ajax 로 가져옵니다 */ public function lists($post_id = 0) { // 이벤트 라이브러리를 로딩합니다 $eventname = 'event_comment_list_lists'; $this->load->event($eventname); $post_id = (int) $post_id; if (empty($post_id) or $post_id < 1) { show_404(); } $view = array(); $view['view'] = array(); // 이벤트가 존재하면 실행합니다 $view['view']['event']['before'] = Events::trigger('before', $eventname); $post = $this->Post_model->get_one($post_id); if (!element('post_id', $post)) { show_404(); } $board = $this->board->item_all(element('brd_id', $post)); $mem_id = (int) $this->member->item('mem_id'); $alertmessage = $this->member->is_member() ? '회원님은 이 댓글 목록을 볼 수 있는 권한이 없습니다' : '비회원은 이 댓글 접근할 권한이 없습니다.\\n\\n회원이시라면 로그인 후 이용해 보십시오'; $check = array('group_id' => element('bgr_id', $board), 'board_id' => element('brd_id', $board)); $this->accesslevel->check(element('access_view', $board), element('access_view_level', $board), element('access_view_group', $board), $alertmessage, $check); $is_admin = $this->member->is_admin(array('board_id' => element('brd_id', $board), 'group_id' => element('bgr_id', $board))); $check = array('group_id' => element('bgr_id', $board), 'board_id' => element('brd_id', $board)); $can_comment_write = $this->accesslevel->is_accessable(element('access_comment', $board), element('access_comment_level', $board), element('access_comment_group', $board), $check); /** * 페이지에 숫자가 아닌 문자가 입력되거나 1보다 작은 숫자가 입력되면 에러 페이지를 보여줍니다. */ $param =& $this->querystring; $findex = strtolower(element('comment_order', $board)) === 'desc' ? 'cmt_num, cmt_reply' : 'cmt_num desc, cmt_reply'; if ($this->cbconfig->get_device_view_type() === 'mobile') { $per_page = element('mobile_comment_count', $board) ? (int) element('mobile_comment_count', $board) : 0; } else { $per_page = element('comment_count', $board) ? (int) element('comment_count', $board) : 0; } $page = (int) $this->input->get('page'); if (empty($page)) { if (strtolower(element('comment_order', $board)) === 'desc') { $page = 1; } else { $page = $per_page ? ceil(element('post_comment_count', $post) / $per_page) : 1; if ($page === 0) { $page = 1; } } } if ($page < 1) { show_404(); } $offset = ($page - 1) * $per_page; $this->Comment_model->allow_search_field = array('cmt_id', 'post_id', 'cmt_content', 'cmt_userid', 'cmt_nickname'); // 검색이 가능한 필드 $this->Comment_model->search_field_equal = array('cmt_id', 'cmt_userid', 'cmt_nickname'); // 검색중 like 가 아닌 = 검색을 하는 필드 $image_width = $this->cbconfig->get_device_view_type() === 'mobile' ? element('post_mobile_image_width', $board) : element('post_image_width', $board); $use_sideview = $this->cbconfig->get_device_view_type() === 'mobile' ? element('use_mobile_sideview', $board) : element('use_sideview', $board); $comment_date_style = $this->cbconfig->get_device_view_type() === 'mobile' ? element('mobile_comment_date_style', $board) : element('comment_date_style', $board); $comment_date_style_manual = $this->cbconfig->get_device_view_type() === 'mobile' ? element('mobile_comment_date_style_manual', $board) : element('comment_date_style_manual', $board); // 이벤트가 존재하면 실행합니다 $view['view']['event']['step1'] = Events::trigger('step1', $eventname); /** * 게시판 목록에 필요한 정보를 가져옵니다. */ $where = array('post_id' => $post_id, 'cmt_del <>' => 2); $result = $this->Comment_model->get_comment_list($per_page, $offset, $where, '', $findex, $sfield = '', $skeyword = ''); $list_num = $result['total_rows'] - ($page - 1) * $per_page; if (element('list', $result)) { foreach (element('list', $result) as $key => $val) { $result['list'][$key]['meta'] = $meta = $this->Comment_meta_model->get_all_meta(element('cmt_id', $val)); $result['list'][$key]['content'] = ''; $is_blind = element('comment_blame_blind_count', $board) > 0 && element('cmt_blame', $val) >= element('comment_blame_blind_count', $board) ? true : false; if ($is_blind === true) { $result['list'][$key]['content'] .= '<div class="alert alert-danger">신고가 접수된 게시글입니다. 본인과 관리자만 확인이 가능합니다</div>'; } if (element('cmt_secret', $val)) { $result['list'][$key]['content'] .= '<span class="label label-warning">비밀글입니다</span>'; } if ($is_blind === false && !element('cmt_secret', $val) or $is_admin !== false or element('mem_id', $val) && (int) element('mem_id', $val) === $mem_id or element('mem_id', $post) && (int) element('mem_id', $post) === $mem_id) { $result['list'][$key]['content'] .= display_html_content(element('cmt_content', $val), element('cmt_html', $val), $image_width, $autolink = true, $popup = true); if (element('comment_syntax_highlighter', $board)) { $result['list'][$key]['content'] = preg_replace_callback("/(\\[code\\]|\\[code=(.*)\\])(.*)\\[\\/code\\]/iUs", "content_syntaxhighlighter", $result['list'][$key]['content']); // SyntaxHighlighter } } if (element('cmt_del', $val)) { $result['list'][$key]['content'] = '<div class="alert alert-danger">이 게시물은 ' . html_escape(element('delete_mem_nickname', $meta)) . '님에 의해 ' . html_escape(element('delete_datetime', $meta)) . ' 에 삭제 되었습니다</div>'; } $result['list'][$key]['display_name'] = display_username(element('cmt_userid', $val), element('cmt_nickname', $val), element('mem_icon', $val), $use_sideview ? 'Y' : 'N'); $result['list'][$key]['display_datetime'] = display_datetime(element('cmt_datetime', $val), $comment_date_style, $comment_date_style_manual); $result['list'][$key]['is_mobile'] = element('cmt_device', $val) === 'mobile' ? true : false; $result['list'][$key]['display_ip'] = ''; if ($this->member->is_admin() === 'super' or element('show_comment_ip', $board) === '2') { $result['list'][$key]['display_ip'] = display_ipaddress(element('cmt_ip', $val), '1111'); } elseif (element('show_comment_ip', $board) === '1') { $result['list'][$key]['display_ip'] = display_ipaddress(element('cmt_ip', $val), $this->cbconfig->item('ip_display_style')); } $result['list'][$key]['member_photo_url'] = member_photo_url(element('mem_photo', $val), 64, 64) ? member_photo_url(element('mem_photo', $val), 64, 64) : site_url('assets/images/member_default.gif'); $result['list'][$key]['cmt_depth'] = strlen($result['list'][$key]['cmt_reply']) * 30; $result['list'][$key]['can_update'] = false; $result['list'][$key]['can_delete'] = false; $result['list'][$key]['can_reply'] = false; if (!element('post_del', $post) && !element('cmt_del', $val)) { if (!element('mem_id', $val)) { $result['list'][$key]['can_delete'] = true; } if ($is_admin !== false or element('mem_id', $val) && $mem_id === (int) element('mem_id', $val)) { $result['list'][$key]['can_update'] = true; $result['list'][$key]['can_delete'] = true; } if ($key > 0 && $is_admin === false) { if (element('cmt_reply', $val)) { $prev_reply = substr(element('cmt_reply', $val), 0, strlen(element('cmt_reply', $val)) - 1); if ($prev_reply === $result['list'][$key - 1]['cmt_reply']) { $result['list'][$key - 1]['can_update'] = false; $result['list'][$key - 1]['can_delete'] = false; } } } if (strlen(element('cmt_reply', $val)) < 5 && $can_comment_write === true) { $result['list'][$key]['can_reply'] = true; } } } } $view['view']['data'] = $result; $view['view']['board'] = $board; $view['view']['post'] = $post; $view['view']['is_admin'] = $is_admin; /** * primary key 정보를 저장합니다 */ $view['view']['primary_key'] = $this->Post_model->primary_key; /** * 페이지네이션을 생성합니다 */ $config['base_url'] = site_url('comment_list/lists/' . $post_id) . '?' . $param->replace('page'); $config['total_rows'] = $result['total_rows']; $config['per_page'] = $per_page; if (!$this->input->get('page')) { $_GET['page'] = (string) $page; } $config['_attributes'] = 'onClick="comment_page(\'' . $post_id . '\', $(this).attr(\'data-ci-pagination-page\'));return false;"'; if ($this->cbconfig->get_device_view_type() === 'mobile') { $config['num_links'] = element('mobile_comment_page_count', $board) ? element('mobile_comment_page_count', $board) : 3; } else { $config['num_links'] = element('comment_page_count', $board) ? element('comment_page_count', $board) : 5; } $this->pagination->initialize($config); $view['view']['paging'] = $this->pagination->create_links(); $view['view']['page'] = $page; // 이벤트가 존재하면 실행합니다 $view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname); /** * 레이아웃을 정의합니다 */ $skindir = $this->cbconfig->get_device_view_type() === 'mobile' ? element('board_mobile_skin', $board) : element('board_skin', $board); if (empty($skindir)) { $skindir = $this->cbconfig->get_device_view_type() === 'mobile' ? $this->cbconfig->item('mobile_skin_board') : $this->cbconfig->item('skin_board'); } if (empty($skindir)) { $skindir = $this->cbconfig->get_device_view_type() === 'mobile' ? $this->cbconfig->item('mobile_skin_default') : $this->cbconfig->item('skin_default'); } if (empty($skindir)) { $skindir = 'basic'; } $skin = 'board/' . $skindir . '/comment_list'; $this->data = $view; $this->view = $skin; }
/** * 일반문서를 보여주는 함수입니다 */ public function index($doc_key = '') { // 이벤트 라이브러리를 로딩합니다 $eventname = 'event_document_index'; $this->load->event($eventname); $view = array(); $view['view'] = array(); if (empty($doc_key)) { show_404(); } // 이벤트가 존재하면 실행합니다 $view['view']['event']['before'] = Events::trigger('before', $eventname); $docinfo = $this->cache->get('document-key-id-info'); $doc_id = $docinfo && element($doc_key, $docinfo) ? element($doc_key, $docinfo) : ''; if ($doc_id) { $data = $this->Document_model->get_one($doc_id); } else { $where = array('doc_key' => $doc_key); $data = $this->Document_model->get_one('', '', $where); } if (!element('doc_id', $data)) { show_404(); } if (!$this->session->userdata('doc_id_' . element('doc_id', $data))) { $this->Document_model->update_hit(element('doc_id', $data)); $this->session->set_userdata('doc_id_' . element('doc_id', $data), '1'); } $data['content'] = $this->cbconfig->get_device_view_type() === 'mobile' ? element('doc_mobile_content', $data) ? element('doc_mobile_content', $data) : element('doc_content', $data) : element('doc_content', $data); $thumb_width = $this->cbconfig->get_device_view_type() === 'mobile' ? $this->cbconfig->item('document_mobile_thumb_width') : $this->cbconfig->item('document_thumb_width'); $autolink = $this->cbconfig->get_device_view_type() === 'mobile' ? $this->cbconfig->item('use_document_mobile_auto_url') : $this->cbconfig->item('use_document_auto_url'); $popup = $this->cbconfig->get_device_view_type() === 'mobile' ? $this->cbconfig->item('document_mobile_content_target_blank') : $this->cbconfig->item('document_content_target_blank'); $data['content'] = display_html_content(element('content', $data), element('doc_content_html_type', $data), $thumb_width, $autolink, $popup, $writer_is_admin = true); $view['view']['data'] = $data; $view['view']['doc_key'] = $doc_key; $view['view']['canonical'] = document_url($doc_key); // 이벤트가 존재하면 실행합니다 $view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname); /** * 레이아웃을 정의합니다 */ $page_title = $this->cbconfig->item('site_meta_title_document'); $meta_description = $this->cbconfig->item('site_meta_description_document'); $meta_keywords = $this->cbconfig->item('site_meta_keywords_document'); $meta_author = $this->cbconfig->item('site_meta_author_document'); $page_name = $this->cbconfig->item('site_page_name_document'); $searchconfig = array('{문서제목}', '{문서아이디}'); $replaceconfig = array(element('doc_title', $data), $doc_key); $page_title = str_replace($searchconfig, $replaceconfig, $page_title); $meta_description = str_replace($searchconfig, $replaceconfig, $meta_description); $meta_keywords = str_replace($searchconfig, $replaceconfig, $meta_keywords); $meta_author = str_replace($searchconfig, $replaceconfig, $meta_author); $page_name = str_replace($searchconfig, $replaceconfig, $page_name); $layout_dir = element('doc_layout', $data) ? element('doc_layout', $data) : $this->cbconfig->item('layout_document'); $mobile_layout_dir = element('doc_mobile_layout', $data) ? element('doc_mobile_layout', $data) : $this->cbconfig->item('mobile_layout_document'); $use_sidebar = element('doc_sidebar', $data) ? element('doc_sidebar', $data) : $this->cbconfig->item('sidebar_document'); $use_mobile_sidebar = element('doc_mobile_sidebar', $data) ? element('doc_mobile_sidebar', $data) : $this->cbconfig->item('mobile_sidebar_document'); $skin_dir = element('doc_skin', $data) ? element('doc_skin', $data) : $this->cbconfig->item('skin_document'); $mobile_skin_dir = element('doc_mobile_skin', $data) ? element('doc_mobile_skin', $data) : $this->cbconfig->item('mobile_skin_document'); $layoutconfig = array('path' => 'document', 'layout' => 'layout', 'skin' => 'document', 'layout_dir' => $layout_dir, 'mobile_layout_dir' => $mobile_layout_dir, 'use_sidebar' => $use_sidebar, 'use_mobile_sidebar' => $use_mobile_sidebar, 'skin_dir' => $skin_dir, 'mobile_skin_dir' => $mobile_skin_dir, 'page_title' => $page_title, 'meta_description' => $meta_description, 'meta_keywords' => $meta_keywords, 'meta_author' => $meta_author, 'page_name' => $page_name); $view['layout'] = $this->managelayout->front($layoutconfig, $this->cbconfig->get_device_view_type()); $this->data = $view; $this->layout = element('layout_skin_file', element('layout', $view)); $this->view = element('view_skin_file', element('layout', $view)); }
/** * 상세 페이지입니다 */ public function view($cmt_id = 0) { // 이벤트 라이브러리를 로딩합니다 $eventname = 'event_admin_board_trash_comment_view'; $this->load->event($eventname); $view = array(); $view['view'] = array(); // 이벤트가 존재하면 실행합니다 $view['view']['event']['before'] = Events::trigger('before', $eventname); $cmt_id = (int) $cmt_id; if (empty($cmt_id) or $cmt_id < 1) { show_404(); } $param =& $this->querystring; $result = $this->{$this->modelname}->get_one($cmt_id); $result['meta'] = $this->Comment_meta_model->get_all_meta($cmt_id); if (!element('cmt_id', $result)) { show_404(); } if (element('cmt_del', $result) !== '2') { show_404(); } $result['cmt_display_name'] = display_username(element('cmt_userid', $result), element('cmt_nickname', $result)); $select = 'mem_id, mem_userid, mem_nickname, mem_icon'; $result['member'] = $dbmember = $this->Member_model->get_by_memid($result['meta']['trash_mem_id'], $select); $result['display_name'] = display_username(element('mem_userid', $dbmember), element('mem_nickname', $dbmember), element('mem_icon', $dbmember)); $result['post'] = $post = $this->Post_model->get_one(element('post_id', $result)); $result['board'] = $board = $this->board->item_all($post['brd_id']); if ($board) { $result['boardurl'] = board_url(element('brd_key', $board)); $result['posturl'] = post_url(element('brd_key', $board), element('post_id', $result) . '#comment_id=' . element('cmt_id', $result)); } $result['content'] = display_html_content($result['cmt_content'], $result['cmt_html'], element('post_image_width', $board)); $view['view']['data'] = $result; $view['view']['delete_url'] = admin_url($this->pagedir . '/delete/' . $cmt_id . '?' . $param->output()); $view['view']['recover_url'] = admin_url($this->pagedir . '/recover/' . $cmt_id . '?' . $param->output()); // 이벤트가 존재하면 실행합니다 $view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname); /** * 어드민 레이아웃을 정의합니다 */ $layoutconfig = array('layout' => 'layout', 'skin' => 'view'); $view['layout'] = $this->managelayout->admin($layoutconfig, $this->cbconfig->get_device_view_type()); $this->data = $view; $this->layout = element('layout_skin_file', element('layout', $view)); $this->view = element('view_skin_file', element('layout', $view)); }
/** * RSS 페이지 함수입니다 */ public function index($brd_key = '') { // 이벤트 라이브러리를 로딩합니다 $eventname = 'event_rss_index'; $this->load->event($eventname); $rsstype = $brd_key ? 'board' : 'all'; $view = array(); $view['view'] = array(); // 이벤트가 존재하면 실행합니다 $view['view']['event']['before'] = Events::trigger('before', $eventname); if ($rsstype === 'board') { $board_id = $this->board->item_key('brd_id', $brd_key); if (empty($board_id)) { show_404(); } $board = $this->board->item_all($board_id); if (element('access_view', $board) > 0 or element('access_list', $board) > 0) { alert('비회원이 볼 수 없는 게시판은 RSS 접근이 금지되어 있습니다'); return false; } if (!element('use_rss_feed', $board)) { alert('이 게시판은 RSS 보기가 금지되어 있습니다'); return false; } } else { if (!$this->cbconfig->item('use_total_rss_feed')) { alert('통합게시판의 사용이 금지되어 있습니다'); return false; } } header('content-type: text/xml'); header('cache-control: no-cache, must-revalidate'); header('pragma: no-cache'); /** * 페이지에 숫자가 아닌 문자가 입력되거나 1보다 작은 숫자가 입력되면 에러 페이지를 보여줍니다. */ if ($rsstype === 'board') { $limit = element('rss_feed_post_count', $board) ? element('rss_feed_post_count', $board) : 50; } else { $limit = $this->cbconfig->item('total_rss_feed_count') ? $this->cbconfig->item('total_rss_feed_count') : 50; } /** * 게시판 목록에 필요한 정보를 가져옵니다. */ $boardarray = array(); if ($rsstype === 'board') { $where = array('brd_id' => element('brd_id', $board), 'post_secret' => 0, 'post_del' => 0); } else { $whereboard = array('bmt_key' => 'use_rss_total_feed', 'bmt_value' => '1'); $boardlist = $this->Board_meta_model->get('', '', $whereboard); if ($boardlist && is_array($boardlist)) { foreach ($boardlist as $key => $value) { $boardarray[] = element('brd_id', $value); } } $where = array('post_secret' => 0, 'post_del' => 0); } $result = $this->Post_model->get_rss_list($where, $boardarray, $limit); if (element('list', $result)) { foreach (element('list', $result) as $key => $val) { $result['list'][$key]['title'] = element('post_title', $val); $result['list'][$key]['pubdate'] = cdate('c', strtotime(element('post_datetime', $val))); $result['list'][$key]['author'] = element('post_nickname', $val); $result['list'][$key]['content'] = ''; $result['list'][$key]['category'] = ''; if ($rsstype === 'board') { if (element('rss_feed_content', $board) === '1') { $result['list'][$key]['content'] = strip_tags(element('post_content', $val)); } elseif (element('rss_feed_content', $board) === '2') { $result['list'][$key]['content'] = display_html_content(element('post_content', $val), element('post_html', $val), 700); } } else { if ($this->cbconfig->item('total_rss_feed_content') === '1') { $result['list'][$key]['content'] = strip_tags(element('post_content', $val)); } elseif ($this->cbconfig->item('total_rss_feed_content') === '2') { $result['list'][$key]['content'] = display_html_content(element('post_content', $val), element('post_html', $val), 700); } $board = $this->board->item_all(element('brd_id', $val)); } if (element('use_category', $board) && element('post_category', $val)) { $category = $this->Board_category_model->get_category_info(element('brd_id', $val), element('post_category', $val)); $result['list'][$key]['category'] = element('bca_value', $category); } $result['list'][$key]['link'] = post_url(element('brd_key', $board), element('post_id', $val)); } } $view['view']['data'] = $result; if ($rsstype === 'board') { $view['view']['title'] = element('brd_name', $board); $view['view']['url'] = board_url(element('brd_key', $board)); $view['view']['copyright'] = element('rss_feed_copyright', $board) ? element('rss_feed_copyright', $board) : $this->cbconfig->item('total_rss_feed_copyright'); $view['view']['description'] = element('rss_feed_description', $board) ? element('rss_feed_description', $board) : $this->cbconfig->item('total_rss_feed_description'); } else { $view['view']['title'] = $this->cbconfig->item('total_rss_feed_title') ? $this->cbconfig->item('total_rss_feed_title') : $this->cbconfig->item('site_title'); $view['view']['url'] = site_url(); $view['view']['copyright'] = $this->cbconfig->item('total_rss_feed_copyright'); $view['view']['description'] = $this->cbconfig->item('total_rss_feed_description'); } $view['view']['board'] = isset($board) ? $board : ''; /** * primary key 정보를 저장합니다 */ $view['view']['primary_key'] = $this->Post_model->primary_key; // 이벤트가 존재하면 실행합니다 $view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname); /** * 레이아웃을 정의합니다 */ $this->data = $view; $skin = $this->cbconfig->item('skin_helptool') ? $this->cbconfig->item('skin_helptool') : $this->cbconfig->item('skin_default'); $this->view = 'helptool/' . $skin . '/rss'; }
/** * 게시물을 네이버에 핑 보내는 페이지입니다 */ public function naversyndi($post_id = 0) { // 이벤트 라이브러리를 로딩합니다 $eventname = 'event_postact_naversyndi'; $this->load->event($eventname); // 이벤트가 존재하면 실행합니다 Events::trigger('before', $eventname); if (!$this->cbconfig->item('naver_syndi_key')) { die('신디케이션 키가 입력되지 않았습니다'); } $post_id = (int) $post_id; if (empty($post_id) or $post_id < 1) { show_404(); } $post = $this->Post_model->get_one($post_id); if (!element('post_id', $post)) { show_404(); } if (element('post_del', $post)) { show_404(); } $board = $this->board->item_all(element('brd_id', $post)); if (!element('brd_id', $board)) { show_404(); } if (!element('use_naver_syndi', $board)) { die('이 게시판은 신디케이션 기능을 사용하지 않습니다'); } if (element('access_view', $board)) { die('비회원이 읽기가 가능한 게시판만 신디케이션을 지원합니다'); } if (element('post_secret', $post)) { die('비밀글은 신디케이션을 지원하지 않습니다'); } if (element('use_personal', $board)) { die('1:1 게시판은 신디케이션을 지원하지 않습니다'); } $site_url = trim(site_url(), '/'); $post_content = display_html_content(element('post_content', $post), element('post_html', $post), element('post_image_width', $board), element('use_auto_url', $board), element('content_target_blank', $board)); $content = str_replace(array('&', ' '), array('&', ' '), $post_content); $summary = str_replace(array('&', ' '), array('&', ' '), strip_tags($post_content)); // 이벤트가 존재하면 실행합니다 Events::trigger('after', $eventname); header('content-type: text/xml'); header('cache-control: no-cache, must-revalidate'); header('pragma: no-cache'); $xml = ""; $xml .= "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; $xml .= "<feed xmlns=\"http://webmastertool.naver.com\">\n"; $xml .= "<id>" . $site_url . "</id>\n"; $xml .= "<title>naver syndication feed document</title>\n"; $xml .= "<author>\n"; $xml .= "<name>webmaster</name>\n"; $xml .= "</author>\n"; $xml .= "<updated>" . cdate('Y-m-d\\TH:i:s\\+09:00') . "</updated>\n"; $xml .= "<link rel=\"site\" href=\"" . $site_url . "\" title=\"" . html_escape($this->cbconfig->item('site_title')) . "\" />\n"; $xml .= "<entry>\n"; $xml .= "<id>" . post_url(element('brd_key', $board), $post_id) . "</id>\n"; $xml .= "<title><![CDATA[" . html_escape(element('post_title', $post)) . "]]></title>\n"; $xml .= "<author>\n"; $xml .= "<name>" . html_escape(element('post_nickname', $post)) . "</name>\n"; $xml .= "</author>\n"; $xml .= "<updated>" . date('Y-m-d\\TH:i:s\\+09:00', strtotime(element('post_datetime', $post))) . "</updated>\n"; $xml .= "<published>" . date('Y-m-d\\TH:i:s\\+09:00', strtotime(element('post_datetime', $post))) . "</published>\n"; $xml .= "<link rel=\"via\" href=\"" . board_url(element('brd_key', $board)) . "\" title=\"" . html_escape(element('brd_name', $board)) . "\" />\n"; $xml .= "<link rel=\"mobile\" href=\"" . post_url(element('brd_key', $board), $post_id) . "\" />\n"; $xml .= "<content type=\"html\"><![CDATA[{$content}]]></content>\n"; $xml .= "<summary type=\"text\"><![CDATA[{$summary}]]></summary>\n"; $xml .= "<category term=\"" . element('brd_key', $board) . "\" label=\"" . html_escape(element('brd_name', $board)) . "\" />\n"; $xml .= "</entry>\n"; $xml .= "</feed>"; echo $xml; }
/** * 댓글 작성시 업데이트하는 함수입니다 */ public function update() { // 이벤트 라이브러리를 로딩합니다 $eventname = 'event_comment_write_update'; $this->load->event($eventname); // 이벤트가 존재하면 실행합니다 Events::trigger('before', $eventname); $post_id = (int) $this->input->post('post_id'); if (empty($post_id) or $post_id < 1) { $result = array('error' => '잘못된 접근입니다'); exit(json_encode($result)); } $post = $this->Post_model->get_one($post_id); if (!element('post_id', $post)) { $result = array('error' => '잘못된 접근입니다'); exit(json_encode($result)); } $board = $this->board->item_all(element('brd_id', $post)); $mem_id = (int) $this->member->item('mem_id'); $mode = $this->input->post('mode') === 'cu' ? 'cu' : 'c'; if ($mode === 'cu') { $cmt_id = (int) $this->input->post('cmt_id'); if (empty($cmt_id) or $cmt_id < 1) { $result = array('error' => '잘못된 접근입니다'); exit(json_encode($result)); } $comment = $this->Comment_model->get_one($cmt_id); if (!element('cmt_id', $comment)) { $result = array('error' => '잘못된 접근입니다'); exit(json_encode($result)); } if (element('cmt_del', $comment)) { $result = array('error' => '삭제된 글은 수정하실 수 없습니다'); exit(json_encode($result)); } } if (element('notice_comment_block', $board) && element('post_notice', $post)) { $result = array('error' => '공지사항 글에는 댓글을 입력하실 수 없습니다.'); exit(json_encode($result)); } $check = array('group_id' => element('bgr_id', $board), 'board_id' => element('brd_id', $board)); $is_accessable = $this->accesslevel->is_accessable(element('access_comment', $board), element('access_comment_level', $board), element('access_comment_group', $board), $check); if ($is_accessable === false) { $alertmessage = $this->member->is_member() ? '회원님은 댓글을 작성할 수 있는 권한이 없습니다' : '비회원은 댓글을 작성할 수 있는 권한이 없습니다.<br>회원이시라면 로그인 후 이용해 보십시오'; $result = array('error' => $alertmessage); exit(json_encode($result)); } $is_admin = $this->member->is_admin(array('board_id' => element('brd_id', $board), 'group_id' => element('bgr_id', $board))); $origin = ''; $reply = ''; if ($this->input->post('cmt_id') && $mode === 'c') { $parent_id = (int) $this->input->post('cmt_id'); if (empty($parent_id) or $parent_id < 1) { $result = array('error' => '잘못된 접근입니다'); exit(json_encode($result)); } $origin = $this->Comment_model->get_one($parent_id); if (!element('cmt_id', $origin)) { $result = array('error' => '잘못된 접근입니다'); exit(json_encode($result)); } if (element('cmt_del', $origin)) { $result = array('error' => '삭제된 글에는 답변을 입력하실 수 없습니다'); exit(json_encode($result)); } if (strlen(element('cmt_reply', $origin)) >= 5) { $result = array('error' => '더 이상 답변하실 수 없습니다.\\n답변은 5단계 까지만 가능합니다'); exit(json_encode($result)); } $reply_len = strlen(element('cmt_reply', $origin)) + 1; $begin_reply_char = 'A'; $end_reply_char = 'Z'; $reply_number = +1; $this->db->select('MAX(SUBSTRING(cmt_reply, ' . $reply_len . ', 1)) as reply', false); $this->db->where('cmt_num', element('cmt_num', $origin)); $this->db->where('SUBSTRING(cmt_reply, ' . $reply_len . ', 1) <>', ''); if (element('cmt_id', $origin)) { $this->db->like('cmt_reply', element('cmt_reply', $origin), 'after'); } $result = $this->db->get('comment'); $row = $result->row_array(); if (!element('reply', $row)) { $reply_char = $begin_reply_char; } elseif (element('reply', $row) === $end_reply_char) { // A~Z은 26 입니다. $result = array('error' => '더 이상 답변하실 수 없습니다.\\n답변은 26개 까지만 가능합니다'); exit(json_encode($result)); } else { $reply_char = chr(ord(element('reply', $row)) + $reply_number); } $reply = element('cmt_reply', $origin) . $reply_char; } if ($mode === 'cu') { if (element('protect_comment_day', $board) > 0 && $is_admin === false) { if (ctimestamp() - strtotime(element('cmt_datetime', $comment)) >= element('protect_comment_day', $board) * 86400) { $result = array('error' => '이 게시판은 ' . element('protect_comment_day', $board) . '일 이상된 댓글의 수정을 금지합니다'); exit(json_encode($result)); } } if (!$mem_id) { $result = array('error' => '비회원은 수정 권한이 없습니다'); exit(json_encode($result)); } if (!element('mem_id', $comment) && $is_admin === false) { $result = array('error' => '비회원이 작성하신 글은 수정할 수 없습니다'); exit(json_encode($result)); } if (element('mem_id', $comment) && (int) element('mem_id', $comment) !== $mem_id && $is_admin === false) { $result = array('error' => '다른 회원님의 댓글은 수정할 수 없습니다'); exit(json_encode($result)); } } if ($mode === 'c' && $this->session->userdata('lastest_post_time') && $this->cbconfig->item('new_post_second')) { if ($this->session->userdata('lastest_post_time') >= ctimestamp() - $this->cbconfig->item('new_post_second') && $is_admin === false) { $result = array('error' => '너무 빠른 시간내에 게시물을 연속해서 올릴 수 없습니다.<br />' . ($this->cbconfig->item('new_post_second') - (ctimestamp() - $this->session->userdata('lastest_post_time'))) . '초 후 글쓰기가 가능합니다'); exit(json_encode($result)); } } $is_comment_name = $this->member->is_member() === false ? true : false; $can_comment_secret = element('use_comment_secret', $board) === '1' && $this->member->is_member() ? true : false; /** * Validation 라이브러리를 가져옵니다 */ $this->load->library('form_validation'); /** * 전송된 데이터의 유효성을 체크합니다 */ $config = array(array('field' => 'cmt_content', 'label' => '내용', 'rules' => 'trim|required')); if ($is_comment_name) { $password_length = $this->cbconfig->item('password_length'); $config[] = array('field' => 'cmt_nickname', 'label' => '닉네임', 'rules' => 'trim|required|min_length[2]|max_length[20]|callback__mem_nickname_check'); $config[] = array('field' => 'cmt_password', 'label' => '패스워드', 'rules' => 'trim|required|min_length[' . $password_length . ']|callback__mem_password_check'); } if ($this->member->is_member() === false) { if ($this->cbconfig->item('use_recaptcha')) { $config[] = array('field' => 'g-recaptcha-response', 'label' => '자동등록방지문자', 'rules' => 'trim|required|callback__check_recaptcha'); } else { $config[] = array('field' => 'captcha_key', 'label' => '자동등록방지문자', 'rules' => 'trim|required|callback__check_captcha'); } } $this->form_validation->set_rules($config); $form_validation = $this->form_validation->run(); /** * 유효성 검사를 하지 않는 경우, 또는 유효성 검사에 실패한 경우입니다. * 즉 글쓰기나 수정 페이지를 보고 있는 경우입니다 */ if ($form_validation === false) { // 이벤트가 존재하면 실행합니다 Events::trigger('formrunfalse', $eventname); $result = array('error' => validation_errors('<div class="alert alert-warning" role="alert">', '</div>')); exit(json_encode($result)); } else { /** * 유효성 검사를 통과한 경우입니다. * 즉 데이터의 insert 나 update 의 process 처리가 필요한 상황입니다 */ // 이벤트가 존재하면 실행합니다 Events::trigger('formruntrue', $eventname); $content_type = 0; $cmt_content = ($this->input->post('cmt_content') === '<p></p>' or $this->input->post('cmt_content') === '<p> </p>') ? '' : $this->input->post('cmt_content'); if ($mode === 'c') { if ($origin) { $cmt_num = element('cmt_num', $origin); $cmt_reply = $reply; } else { $cmt_num = $this->Comment_model->next_comment_num(); $cmt_reply = ''; } $updatedata = array('cmt_num' => $cmt_num, 'cmt_reply' => $cmt_reply, 'cmt_content' => $cmt_content, 'cmt_html' => $content_type, 'cmt_datetime' => cdate('Y-m-d H:i:s'), 'cmt_updated_datetime' => cdate('Y-m-d H:i:s'), 'cmt_ip' => $this->input->ip_address(), 'post_id' => element('post_id', $post), 'brd_id' => element('brd_id', $post)); if ($mem_id) { $updatedata['mem_id'] = $mem_id; $updatedata['cmt_userid'] = $this->member->item('mem_userid'); $updatedata['cmt_username'] = $this->member->item('mem_username'); $updatedata['cmt_nickname'] = $this->member->item('mem_nickname'); $updatedata['cmt_email'] = $this->member->item('mem_email'); $updatedata['cmt_homepage'] = $this->member->item('mem_homepage'); } if ($is_comment_name) { if (!function_exists('password_hash')) { $this->load->helper('password'); } $updatedata['cmt_nickname'] = $this->input->post('cmt_nickname', null, ''); $updatedata['cmt_password'] = password_hash($this->input->post('cmt_password', null, ''), PASSWORD_BCRYPT); } if ($can_comment_secret) { $updatedata['cmt_secret'] = $this->input->post('cmt_secret') ? 1 : 0; } if ($this->member->is_member() && element('use_comment_secret', $board) === '2') { $updatedata['cmt_secret'] = 1; } $updatedata['cmt_device'] = $this->cbconfig->get_device_type() === 'mobile' ? 'mobile' : 'desktop'; $cmt_id = $this->Comment_model->insert($updatedata); $this->Post_model->comment_updated($post_id, cdate('Y-m-d H:i:s')); if ($this->cbconfig->item('use_notification') && $this->cbconfig->item('notification_comment')) { $this->load->library('notificationlib'); $not_message = $updatedata['cmt_nickname'] . '님께서 [' . element('post_title', $post) . '] 에 댓글을 남기셨습니다'; $not_url = post_url(element('brd_key', $board), $post_id) . '#comment_' . $cmt_id; $this->notificationlib->set_noti(element('mem_id', $post), $mem_id, 'comment', $cmt_id, $not_message, $not_url); } if ($origin && $cmt_reply && $this->cbconfig->item('use_notification') && $this->cbconfig->item('notification_comment_comment') && element('mem_id', $post) !== element('mem_id', $origin)) { $this->load->library('notificationlib'); $not_message = $updatedata['cmt_nickname'] . '님께서 [' . element('post_title', $post) . '] 글의 회원님의 댓글에 답변댓글을 남기셨습니다'; $not_url = post_url(element('brd_key', $board), $post_id) . '#comment_' . $cmt_id; $this->notificationlib->set_noti(element('mem_id', $origin), $mem_id, 'comment_comment', $cmt_id, $not_message, $not_url); } if (element('use_point', $board)) { $point = $this->point->insert_point($mem_id, element('point_comment', $board), element('board_name', $board) . ' ' . $cmt_id . ' 댓글 작성', 'comment', $cmt_id, '댓글 작성'); } $emailsendlistadmin = array(); $notesendlistadmin = array(); $emailsendlistpostwriter = array(); $notesendlistpostwriter = array(); $emailsendlistcmtwriter = array(); $notesendlistcmtwriter = array(); $post_writer = array(); if (element('send_email_comment_super_admin', $board) or element('send_note_comment_super_admin', $board)) { $mselect = 'mem_id, mem_email, mem_nickname, mem_phone'; $superadminlist = $this->Member_model->get_superadmin_list($mselect); } if (element('send_email_comment_group_admin', $board) or element('send_note_comment_group_admin', $board)) { $this->load->model('Board_group_admin_model'); $groupadminlist = $this->Board_group_admin_model->get_board_group_admin_member(element('bgr_id', $board)); } if (element('send_email_comment_board_admin', $board) or element('send_note_comment_board_admin', $board)) { $this->load->model('Board_admin_model'); $boardadminlist = $this->Board_admin_model->get_board_admin_member(element('brd_id', $board)); } if (element('send_email_comment_super_admin', $board) && $superadminlist) { foreach ($superadminlist as $key => $value) { $emailsendlistadmin[$value['mem_id']] = $value; } } if (element('send_email_comment_group_admin', $board) && $groupadminlist) { foreach ($groupadminlist as $key => $value) { $emailsendlistadmin[$value['mem_id']] = $value; } } if (element('send_email_comment_board_admin', $board) && $boardadminlist) { foreach ($boardadminlist as $key => $value) { $emailsendlistadmin[$value['mem_id']] = $value; } } if (element('send_email_comment_post_writer', $board) or element('send_note_comment_post_writer', $board) or element('post_receive_email', $post)) { $post_writer = $this->Member_model->get_one(element('mem_id', $post)); } if (element('mem_email', $post_writer) && element('post_receive_email', $post) or element('send_email_comment_post_writer', $board) && element('mem_receive_email', $post_writer)) { $emailsendlistpostwriter['mem_email'] = $post['post_email']; } if (element('send_email_comment_comment_writer', $board)) { $emailsendlistcmtwriter['mem_email'] = $this->member->item('mem_email'); } if (element('send_note_comment_super_admin', $board) && $superadminlist) { foreach ($superadminlist as $key => $value) { $notesendlistadmin[$value['mem_id']] = $value; } } if (element('send_note_comment_group_admin', $board) && $groupadminlist) { foreach ($groupadminlist as $key => $value) { $notesendlistadmin[$value['mem_id']] = $value; } } if (element('send_note_comment_board_admin', $board) && $boardadminlist) { foreach ($boardadminlist as $key => $value) { $notesendlistadmin[$value['mem_id']] = $value; } } if (element('send_note_comment_post_writer', $board) && element('mem_use_note', $post_writer)) { $notesendlistpostwriter['mem_id'] = element('mem_id', $post_writer); } if (element('send_note_comment_comment_writer', $board) && $this->member->item('mem_use_note')) { $notesendlistcmtwriter['mem_id'] = $mem_id; } $searchconfig = array('{홈페이지명}', '{회사명}', '{홈페이지주소}', '{댓글내용}', '{댓글작성자닉네임}', '{댓글작성자아이디}', '{댓글작성시간}', '{댓글주소}', '{게시글제목}', '{게시글내용}', '{게시글작성자닉네임}', '{게시글작성자아이디}', '{게시글작성시간}', '{게시글주소}', '{게시판명}', '{게시판주소}'); $autolink = element('use_auto_url', $board) ? true : false; $popup = element('content_target_blank', $board) ? true : false; $replaceconfig = array($this->cbconfig->item('site_title'), $this->cbconfig->item('company_name'), site_url(), display_html_content($cmt_content, 0), $updatedata['cmt_nickname'], $this->member->item('mem_userid'), cdate('Y-m-d H:i:s'), post_url(element('brd_key', $board), element('post_id', $post)) . '#comment_' . $cmt_id, element('post_title', $post), display_html_content(element('post_content', $post), element('post_html', $post), element('post_image_width', $board), $autolink, $popup), element('post_nickname', $post), element('post_userid', $post), element('post_datetime', $post), post_url(element('brd_key', $board), element('post_id', $post)), element('brd_name', $board), board_url(element('brd_key', $board))); $replaceconfig_escape = array(html_escape($this->cbconfig->item('site_title')), html_escape($this->cbconfig->item('company_name')), site_url(), display_html_content($cmt_content, 0), html_escape($updatedata['cmt_nickname']), $this->member->item('mem_userid'), cdate('Y-m-d H:i:s'), post_url(element('brd_key', $board), element('post_id', $post)) . '#comment_' . $cmt_id, html_escape(element('post_title', $post)), display_html_content(element('post_content', $post), element('post_html', $post), element('post_image_width', $board), $autolink, $popup), html_escape(element('post_nickname', $post)), element('post_userid', $post), element('post_datetime', $post), post_url(element('brd_key', $board), element('post_id', $post)), html_escape(element('brd_name', $board)), board_url(element('brd_key', $board))); if ($emailsendlistadmin) { $title = str_replace($searchconfig, $replaceconfig, $this->cbconfig->item('send_email_comment_admin_title')); $content = str_replace($searchconfig, $replaceconfig_escape, $this->cbconfig->item('send_email_comment_admin_content')); foreach ($emailsendlistadmin as $akey => $aval) { $this->email->clear(true); $this->email->from($this->cbconfig->item('webmaster_email'), $this->cbconfig->item('webmaster_name')); $this->email->to(element('mem_email', $aval)); $this->email->subject($title); $this->email->message($content); $this->email->send(); } } if ($emailsendlistpostwriter) { $title = str_replace($searchconfig, $replaceconfig, $this->cbconfig->item('send_email_comment_post_writer_title')); $content = str_replace($searchconfig, $replaceconfig_escape, $this->cbconfig->item('send_email_comment_post_writer_content')); $this->email->clear(true); $this->email->from($this->cbconfig->item('webmaster_email'), $this->cbconfig->item('webmaster_name')); $this->email->to(element('mem_email', $emailsendlistpostwriter)); $this->email->subject($title); $this->email->message($content); $this->email->send(); } if ($emailsendlistcmtwriter) { $title = str_replace($searchconfig, $replaceconfig, $this->cbconfig->item('send_email_comment_comment_writer_title')); $content = str_replace($searchconfig, $replaceconfig_escape, $this->cbconfig->item('send_email_comment_comment_writer_content')); $this->email->clear(true); $this->email->from($this->cbconfig->item('webmaster_email'), $this->cbconfig->item('webmaster_name')); $this->email->to(element('mem_email', $emailsendlistcmtwriter)); $this->email->subject($title); $this->email->message($content); $this->email->send(); } if ($notesendlistadmin) { $title = str_replace($searchconfig, $replaceconfig, $this->cbconfig->item('send_note_comment_admin_title')); $content = str_replace($searchconfig, $replaceconfig_escape, $this->cbconfig->item('send_note_comment_admin_content')); foreach ($notesendlistadmin as $akey => $aval) { $note_result = $this->notelib->send_note($sender = 0, $receiver = element('mem_id', $aval), $title, $content, 1); } } if ($notesendlistpostwriter && element('mem_id', $notesendlistpostwriter)) { $title = str_replace($searchconfig, $replaceconfig, $this->cbconfig->item('send_note_comment_post_writer_title')); $content = str_replace($searchconfig, $replaceconfig_escape, $this->cbconfig->item('send_note_comment_post_writer_content')); $note_result = $this->notelib->send_note($sender = 0, $receiver = element('mem_id', $notesendlistpostwriter), $title, $content, 1); } if ($notesendlistcmtwriter && element('mem_id', $notesendlistcmtwriter)) { $title = str_replace($searchconfig, $replaceconfig, $this->cbconfig->item('send_note_comment_comment_writer_title')); $content = str_replace($searchconfig, $replaceconfig_escape, $this->cbconfig->item('send_note_comment_comment_writer_content')); $note_result = $this->notelib->send_note($sender = 0, $receiver = element('mem_id', $notesendlistcmtwriter), $title, $content, 1); } $this->session->set_userdata('lastest_post_time', ctimestamp()); // 이벤트가 존재하면 실행합니다 Events::trigger('after_insert', $eventname); $result = array('success' => '댓글이 등록되었습니다'); exit(json_encode($result)); } else { $updatedata = array('cmt_content' => $cmt_content, 'cmt_html' => $content_type, 'cmt_updated_datetime' => cdate('Y-m-d H:i:s'), 'cmt_ip' => $this->input->ip_address()); if ($can_comment_secret) { $updatedata['cmt_secret'] = $this->input->post('cmt_secret') ? 1 : 0; } if ($this->member->is_member() && element('use_comment_secret', $board) === '2') { $updatedata['cmt_secret'] = 1; } $updatedata['cmt_device'] = $this->cbconfig->get_device_type() === 'mobile' ? 'mobile' : 'desktop'; $this->Comment_model->update($cmt_id, $updatedata); // 이벤트가 존재하면 실행합니다 Events::trigger('after_update', $eventname); $result = array('success' => '댓글이 수정되었습니다'); exit(json_encode($result)); } } }
/** * 폼메일 작성 페이지입니다 */ public function write($userid = '') { // 이벤트 라이브러리를 로딩합니다 $eventname = 'event_formmail_write'; $this->load->event($eventname); $view = array(); $view['view'] = array(); // 이벤트가 존재하면 실행합니다 $view['view']['event']['before'] = Events::trigger('before', $eventname); /** * 로그인이 필요한 페이지입니다 */ required_user_login(); if ($this->cbconfig->get_device_view_type() !== 'mobile' && !$this->cbconfig->item('use_sideview_email')) { alert_close('이메일 기능을 사용하지 않는 사이트입니다'); return false; } elseif ($this->cbconfig->get_device_view_type() === 'mobile' && !$this->cbconfig->item('use_mobile_sideview_email')) { alert_close('모바일 버전에서는 이메일 기능을 사용하지 않는 사이트입니다'); return false; } elseif (!$this->member->item('mem_receive_email') && $this->member->is_admin() !== 'super') { alert_close('회원님은 메일수신에 체크하지 않으셨습니다. 회원정보 수정 페이지에 가셔서, 메일 수신에 체크하신 후에 사용이 가능합니다'); return false; } if (empty($userid)) { alert_close('상대방이 지정되지 않았습니다'); return false; } $view['view']['userid'] = $userid; $memberselect = 'mem_id, mem_denied, mem_receive_email, mem_nickname, mem_email'; $view['view']['member'] = $member = $this->Member_model->get_by_userid($userid, $memberselect); if (!element('mem_id', $member)) { alert_close('존재하지 않는 회원 아이디입니다'); return false; } if (element('mem_denied', $member)) { alert_close('탈퇴 또는 차단된 회원입니다'); return false; } if (!element('mem_receive_email', $member) && $this->member->is_admin() !== 'super') { alert_close(html_escape(element('mem_nickname', $member)) . ' 님은 메일 수신을 원하지 않으십니다'); return false; } $view['view']['use_dhtml'] = false; if ($this->cbconfig->item('use_formmail_dhtml')) { $view['view']['use_dhtml'] = true; } /** * Validation 라이브러리를 가져옵니다 */ $this->load->library('form_validation'); /** * 전송된 데이터의 유효성을 체크합니다 */ $config = array(array('field' => 'title', 'label' => '제목', 'rules' => 'trim|required'), array('field' => 'content', 'label' => '내용', 'rules' => 'trim|required')); $this->form_validation->set_rules($config); /** * 유효성 검사를 하지 않는 경우, 또는 유효성 검사에 실패한 경우입니다. * 즉 글쓰기나 수정 페이지를 보고 있는 경우입니다 */ if ($this->form_validation->run() === false) { // 이벤트가 존재하면 실행합니다 $view['view']['event']['formrunfalse'] = Events::trigger('formrunfalse', $eventname); /** * 레이아웃을 정의합니다 */ $page_title = $this->cbconfig->item('site_meta_title_formmail'); $meta_description = $this->cbconfig->item('site_meta_description_formmail'); $meta_keywords = $this->cbconfig->item('site_meta_keywords_formmail'); $meta_author = $this->cbconfig->item('site_meta_author_formmail'); $page_name = $this->cbconfig->item('site_page_name_formmail'); $layoutconfig = array('path' => 'formmail', 'layout' => 'layout_popup', 'skin' => 'formmail', 'layout_dir' => $this->cbconfig->item('layout_formmail'), 'mobile_layout_dir' => $this->cbconfig->item('mobile_layout_formmail'), 'skin_dir' => $this->cbconfig->item('skin_formmail'), 'mobile_skin_dir' => $this->cbconfig->item('mobile_skin_formmail'), 'page_title' => $page_title, 'meta_description' => $meta_description, 'meta_keywords' => $meta_keywords, 'meta_author' => $meta_author, 'page_name' => $page_name); $view['layout'] = $this->managelayout->front($layoutconfig, $this->cbconfig->get_device_view_type()); $this->data = $view; $this->layout = element('layout_skin_file', element('layout', $view)); $this->view = element('view_skin_file', element('layout', $view)); } else { // 이벤트가 존재하면 실행합니다 $view['view']['event']['formruntrue'] = Events::trigger('formruntrue', $eventname); // 메일 발송 $this->load->library('email'); $this->email->from($this->member->item('mem_email'), $this->member->item('mem_nickname')); $this->email->to(element('mem_email', $member)); $this->email->subject($this->input->post('title')); $content_type = $this->cbconfig->item('use_formmail_dhtml') ? 1 : 0; $this->email->message(display_html_content($this->input->post('content'), $content_type, 800)); $this->email->send(); alert_close(element('mem_nickname', $member) . ' 님에게 메일을 발송하였습니다. '); } }
/** * 게시물 작성과 답변에 공통으로 쓰입니다 */ public function _write_common($board, $origin = '', $reply = '') { // 이벤트 라이브러리를 로딩합니다 $eventname = 'event_board_write_write_common'; $this->load->event($eventname); $param =& $this->querystring; $view = array(); $view['view'] = array(); // 이벤트가 존재하면 실행합니다 $view['view']['event']['before'] = Events::trigger('before', $eventname); $view['view']['post'] = array(); $view['view']['board'] = $board; $view['view']['board_key'] = element('brd_key', $board); $mem_id = (int) $this->member->item('mem_id'); $primary_key = $this->Post_model->primary_key; $view['view']['is_admin'] = $is_admin = $this->member->is_admin(array('board_id' => element('brd_id', $board), 'group_id' => element('bgr_id', $board))); // 글 한개만 작성 가능 if (element('use_only_one_post', $board) && $is_admin === false) { if ($this->member->is_member() === false) { alert('비회원은 글을 작성할 수 있는 권한이 없습니다. 회원이사라면 로그인 후 이용해주세요'); } $mywhere = array('brd_id' => element('brd_id', $board), 'mem_id' => $mem_id); $cnt = $this->Post_model->count_by($mywhere); if ($cnt) { alert('이 게시판은 한 사람이 하나의 글만 등록 가능합니다.'); } } // 글쓰기 기간제한 if (element('write_possible_days', $board) && $is_admin === false) { if ($this->member->is_member() === false) { alert('비회원은 글을 작성할 수 있는 권한이 없습니다. 회원이사라면 로그인 후 이용해주세요'); } if (ctimestamp() - strtotime($this->member->item('mem_register_datetime')) < element('write_possible_days', $board) * 86400) { alert('이 게시판은 회원가입한지 ' . element('write_possible_days', $board) . '일이 지난 회원만 게시물 작성이 가능합니다'); } } if ($this->session->userdata('lastest_post_time') && $this->cbconfig->item('new_post_second')) { if ($this->session->userdata('lastest_post_time') >= ctimestamp() - $this->cbconfig->item('new_post_second') && $is_admin === false) { alert('너무 빠른 시간내에 게시물을 연속해서 올릴 수 없습니다.\\n\\n' . ($this->cbconfig->item('new_post_second') - (ctimestamp() - $this->session->userdata('lastest_post_time'))) . '초 후 글쓰기가 가능합니다'); } } if (element('use_point', $board) && $this->cbconfig->item('block_write_zeropoint') && element('point_write', $board) < 0 && $this->member->item('mem_point') + element('point_write', $board) < 0) { alert('회원님은 포인트가 부족하므로 글을 작성하실 수 없습니다. 글 작성시 ' . element('point_write', $board) * -1 . ' 포인트가 차감됩니다'); return false; } // 이벤트가 존재하면 실행합니다 $view['view']['event']['step1'] = Events::trigger('step1', $eventname); $view['view']['post']['is_post_name'] = $is_post_name = $this->member->is_member() === false ? true : false; $view['view']['post']['post_title'] = $this->cbconfig->get_device_view_type() === 'mobile' ? element('mobile_post_default_title', $board) : element('post_default_title', $board); $view['view']['post']['post_content'] = $this->cbconfig->get_device_view_type() === 'mobile' ? element('mobile_post_default_content', $board) : element('post_default_content', $board); $view['view']['post']['can_post_notice'] = $can_post_notice = $is_admin !== false ? true : false; $view['view']['post']['can_post_secret'] = $can_post_secret = element('use_post_secret', $board) === '1' ? true : false; $view['view']['post']['post_secret'] = element('use_post_secret_selected', $board) ? '1' : ''; $view['view']['post']['can_post_receive_email'] = $can_post_receive_email = element('use_post_receive_email', $board) ? true : false; $extravars = element('extravars', $board); $form = json_decode($extravars, true); /** * Validation 라이브러리를 가져옵니다 */ $this->load->library('form_validation'); /** * 전송된 데이터의 유효성을 체크합니다 */ $config = array(array('field' => 'post_title', 'label' => '제목', 'rules' => 'trim|required'), array('field' => 'post_content', 'label' => '내용', 'rules' => 'trim|required')); if ($form && is_array($form)) { foreach ($form as $key => $value) { if (!element('use', $value)) { continue; } $required = element('required', $value) ? '|required' : ''; if (element('field_type', $value) === 'checkbox') { $config[] = array('field' => element('field_name', $value) . '[]', 'label' => element('display_name', $value), 'rules' => 'trim' . $required); } else { $config[] = array('field' => element('field_name', $value), 'label' => element('display_name', $value), 'rules' => 'trim' . $required); } } } if ($is_post_name) { $config[] = array('field' => 'post_nickname', 'label' => '닉네임', 'rules' => 'trim|required|min_length[2]|max_length[20]|callback__mem_nickname_check'); $config[] = array('field' => 'post_email', 'label' => '이메일', 'rules' => 'trim|required|valid_email|max_length[50]|callback__mem_email_check'); $config[] = array('field' => 'post_homepage', 'label' => '홈페이지', 'rules' => 'prep_url|valid_url'); } if ($this->member->is_member() === false) { $password_length = $this->cbconfig->item('password_length'); $config[] = array('field' => 'post_password', 'label' => '패스워드', 'rules' => 'trim|required|min_length[' . $password_length . ']|callback__mem_password_check'); if ($this->cbconfig->item('use_recaptcha')) { $config[] = array('field' => 'g-recaptcha-response', 'label' => '자동등록방지문자', 'rules' => 'trim|required|callback__check_recaptcha'); } else { $config[] = array('field' => 'captcha_key', 'label' => '자동등록방지문자', 'rules' => 'trim|required|callback__check_captcha'); } } if (element('use_category', $board) && $is_admin === false) { $config[] = array('field' => 'post_category', 'label' => '카테고리', 'rules' => 'trim|required'); } $this->form_validation->set_rules($config); $form_validation = $this->form_validation->run(); $file_error = ''; $uploadfiledata = ''; if (element('use_upload_file', $board)) { $check = array('group_id' => element('bgr_id', $board), 'board_id' => element('brd_id', $board)); $use_upload = $this->accesslevel->is_accessable(element('access_upload', $board), element('access_upload_level', $board), element('access_upload_group', $board), $check); } else { $use_upload = false; } $view['view']['board']['use_upload'] = $use_upload; $view['view']['board']['upload_file_count'] = $this->cbconfig->get_device_view_type() === 'mobile' ? element('mobile_upload_file_num', $board) : element('upload_file_num', $board); $use_post_dhtml = $this->cbconfig->get_device_view_type() === 'mobile' ? element('use_mobile_post_dhtml', $board) : element('use_post_dhtml', $board); if ($use_post_dhtml) { $check = array('group_id' => element('bgr_id', $board), 'board_id' => element('brd_id', $board)); $use_dhtml = $this->accesslevel->is_accessable(element('access_dhtml', $board), element('access_dhtml_level', $board), element('access_dhtml_group', $board), $check); } else { $use_dhtml = false; } $view['view']['board']['use_dhtml'] = $use_dhtml; $view['view']['board']['link_count'] = $this->cbconfig->get_device_view_type() === 'mobile' ? element('mobile_link_num', $board) : element('link_num', $board); $view['view']['board']['headercontent'] = $this->cbconfig->get_device_view_type() === 'mobile' ? element('mobile_header_content', $board) : element('header_content', $board); $view['view']['board']['footercontent'] = $this->cbconfig->get_device_view_type() === 'mobile' ? element('mobile_footer_content', $board) : element('footer_content', $board); // 이벤트가 존재하면 실행합니다 $view['view']['event']['step2'] = Events::trigger('step2', $eventname); if ($use_upload === true && $form_validation && element('use_upload_file', $board)) { $this->load->library('upload'); if (isset($_FILES) && isset($_FILES['post_file']) && isset($_FILES['post_file']['name']) && is_array($_FILES['post_file']['name'])) { $filecount = count($_FILES['post_file']['name']); $upload_path = './uploads/post/'; if (is_dir($upload_path) === false) { mkdir($upload_path, 0707); $file = $upload_path . 'index.php'; $f = @fopen($file, 'w'); @fwrite($f, ''); @fclose($f); @chmod($file, 0644); } $upload_path .= cdate('Y') . '/'; if (is_dir($upload_path) === false) { mkdir($upload_path, 0707); $file = $upload_path . 'index.php'; $f = @fopen($file, 'w'); @fwrite($f, ''); @fclose($f); @chmod($file, 0644); } $upload_path .= cdate('m') . '/'; if (is_dir($upload_path) === false) { mkdir($upload_path, 0707); $file = $upload_path . 'index.php'; $f = @fopen($file, 'w'); @fwrite($f, ''); @fclose($f); @chmod($file, 0644); } foreach ($_FILES['post_file']['name'] as $i => $value) { if ($value) { $uploadconfig = ''; $uploadconfig['upload_path'] = $upload_path; $uploadconfig['allowed_types'] = element('upload_file_extension', $board) ? element('upload_file_extension', $board) : '*'; $uploadconfig['max_size'] = element('upload_file_max_size', $board) * 1024; $uploadconfig['encrypt_name'] = true; $this->upload->initialize($uploadconfig); $_FILES['userfile']['name'] = $_FILES['post_file']['name'][$i]; $_FILES['userfile']['type'] = $_FILES['post_file']['type'][$i]; $_FILES['userfile']['tmp_name'] = $_FILES['post_file']['tmp_name'][$i]; $_FILES['userfile']['error'] = $_FILES['post_file']['error'][$i]; $_FILES['userfile']['size'] = $_FILES['post_file']['size'][$i]; if ($this->upload->do_upload()) { $filedata = $this->upload->data(); $uploadfiledata[$i]['pfi_filename'] = cdate('Y') . '/' . cdate('m') . '/' . element('file_name', $filedata); $uploadfiledata[$i]['pfi_originname'] = element('orig_name', $filedata); $uploadfiledata[$i]['pfi_filesize'] = intval(element('file_size', $filedata) * 1024); $uploadfiledata[$i]['pfi_width'] = element('image_width', $filedata) ? element('image_width', $filedata) : 0; $uploadfiledata[$i]['pfi_height'] = element('image_height', $filedata) ? element('image_height', $filedata) : 0; $uploadfiledata[$i]['pfi_type'] = str_replace('.', '', element('file_ext', $filedata)); $uploadfiledata[$i]['is_image'] = element('is_image', $filedata) ? 1 : 0; } else { $file_error = $this->upload->display_errors(); break; } } } } } /** * 유효성 검사를 하지 않는 경우, 또는 유효성 검사에 실패한 경우입니다. * 즉 글쓰기나 수정 페이지를 보고 있는 경우입니다 */ if ($form_validation === false or $file_error) { // 이벤트가 존재하면 실행합니다 $view['view']['event']['formrunfalse'] = Events::trigger('formrunfalse', $eventname); if ($file_error) { $view['view']['message'] = $file_error; } /** * primary key 정보를 저장합니다 */ $view['view']['primary_key'] = $primary_key; $extra_content = array(); $k = 0; if ($form && is_array($form)) { foreach ($form as $key => $value) { if (!element('use', $value)) { continue; } $required = element('required', $value) ? 'required' : ''; $extra_content[$k]['field_name'] = element('field_name', $value); $extra_content[$k]['display_name'] = element('display_name', $value); $extra_content[$k]['input'] = ''; //field_type : text, url, email, phone, textarea, radio, select, checkbox, date if (element('field_type', $value) === 'text' or element('field_type', $value) === 'url' or element('field_type', $value) === 'email' or element('field_type', $value) === 'phone' or element('field_type', $value) === 'date') { if (element('field_type', $value) === 'date') { $extra_content[$k]['input'] .= '<input type="text" id="' . element('field_name', $value) . '" name="' . element('field_name', $value) . '" class="form-control input datepicker" value="' . set_value(element('field_name', $value)) . '" readonly="readonly" ' . $required . ' />'; } elseif (element('field_type', $value) === 'phone') { $extra_content[$k]['input'] .= '<input type="text" id="' . element('field_name', $value) . '" name="' . element('field_name', $value) . '" class="form-control input validphone" value="' . set_value(element('field_name', $value)) . '" ' . $required . ' />'; } else { $extra_content[$k]['input'] .= '<input type="' . element('field_type', $value) . '" id="' . element('field_name', $value) . '" name="' . element('field_name', $value) . '" class="form-control input" value="' . set_value(element('field_name', $value)) . '" ' . $required . '/>'; } } elseif (element('field_type', $value) === 'textarea') { $extra_content[$k]['input'] .= '<textarea id="' . element('field_name', $value) . '" name="' . element('field_name', $value) . '" class="form-control input" ' . $required . '>' . set_value(element('field_name', $value)) . '</textarea>'; } elseif (element('field_type', $value) === 'radio') { $extra_content[$k]['input'] .= '<div class="checkbox">'; $options = explode("\n", element('options', $value)); $i = 1; if ($options) { foreach ($options as $okey => $oval) { $radiovalue = $oval; $extra_content[$k]['input'] .= '<label for="' . element('field_name', $value) . '_' . $i . '"><input type="radio" name="' . element('field_name', $value) . '" id="' . element('field_name', $value) . '_' . $i . '" value="' . $radiovalue . '" ' . set_radio(element('field_name', $value), $radiovalue) . ' /> ' . $oval . ' </label> '; $i++; } } $extra_content[$k]['input'] .= '</div>'; } elseif (element('field_type', $value) === 'checkbox') { $extra_content[$k]['input'] .= '<div class="checkbox">'; $options = explode("\n", element('options', $value)); $i = 1; if ($options) { foreach ($options as $okey => $oval) { $extra_content[$k]['input'] .= '<label for="' . element('field_name', $value) . '_' . $i . '"><input type="checkbox" name="' . element('field_name', $value) . '[]" id="' . element('field_name', $value) . '_' . $i . '" value="' . $oval . '" ' . set_checkbox(element('field_name', $value), $oval) . ' /> ' . $oval . ' </label> '; $i++; } } $extra_content[$k]['input'] .= '</div>'; } elseif (element('field_type', $value) === 'select') { $extra_content[$k]['input'] .= '<div class="input-group">'; $extra_content[$k]['input'] .= '<select name="' . element('field_name', $value) . '" class="form-control input" ' . $required . '>'; $extra_content[$k]['input'] .= '<option value="" >선택하세요</option> '; $options = explode("\n", element('options', $value)); if ($options) { foreach ($options as $okey => $oval) { $extra_content[$k]['input'] .= '<option value="' . $oval . '" ' . set_select(element('field_name', $value), $oval) . ' >' . $oval . '</option> '; } } $extra_content[$k]['input'] .= '</select>'; $extra_content[$k]['input'] .= '</div>'; } $k++; } } $view['view']['extra_content'] = $extra_content; if (element('use_category', $board)) { $this->load->model('Board_category_model'); $view['view']['category'] = $this->Board_category_model->get_all_category(element('brd_id', $board)); } $view['view']['has_tempsave'] = false; if ($this->member->is_member() && element('use_tempsave', $board)) { $this->load->model('Tempsave_model'); $twhere = array('brd_id' => element('brd_id', $board), 'mem_id' => $mem_id); $tempsave = $this->Tempsave_model->get_one('', '', $twhere); if (element('tmp_id', $tempsave)) { $view['view']['has_tempsave'] = true; } } // 이벤트가 존재하면 실행합니다 $view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname); /** * 레이아웃을 정의합니다 */ $page_title = $this->cbconfig->item('site_meta_title_board_write'); $meta_description = $this->cbconfig->item('site_meta_description_board_write'); $meta_keywords = $this->cbconfig->item('site_meta_keywords_board_write'); $meta_author = $this->cbconfig->item('site_meta_author_board_write'); $page_name = $this->cbconfig->item('site_page_name_board_write'); $searchconfig = array('{게시판명}', '{게시판아이디}'); $replaceconfig = array(element('board_name', $board), element('brd_key', $board)); $page_title = str_replace($searchconfig, $replaceconfig, $page_title); $meta_description = str_replace($searchconfig, $replaceconfig, $meta_description); $meta_keywords = str_replace($searchconfig, $replaceconfig, $meta_keywords); $meta_author = str_replace($searchconfig, $replaceconfig, $meta_author); $page_name = str_replace($searchconfig, $replaceconfig, $page_name); $layout_dir = element('board_layout', $board) ? element('board_layout', $board) : $this->cbconfig->item('layout_board'); $mobile_layout_dir = element('board_mobile_layout', $board) ? element('board_mobile_layout', $board) : $this->cbconfig->item('mobile_layout_board'); $use_sidebar = element('board_sidebar', $board) ? element('board_sidebar', $board) : $this->cbconfig->item('sidebar_board'); $use_mobile_sidebar = element('board_mobile_sidebar', $board) ? element('board_mobile_sidebar', $board) : $this->cbconfig->item('mobile_sidebar_board'); $skin_dir = element('board_skin', $board) ? element('board_skin', $board) : $this->cbconfig->item('skin_board'); $mobile_skin_dir = element('board_mobile_skin', $board) ? element('board_mobile_skin', $board) : $this->cbconfig->item('mobile_skin_board'); $layoutconfig = array('path' => 'board', 'layout' => 'layout', 'skin' => 'write', 'layout_dir' => $layout_dir, 'mobile_layout_dir' => $mobile_layout_dir, 'use_sidebar' => $use_sidebar, 'use_mobile_sidebar' => $use_mobile_sidebar, 'skin_dir' => $skin_dir, 'mobile_skin_dir' => $mobile_skin_dir, 'page_title' => $page_title, 'meta_description' => $meta_description, 'meta_keywords' => $meta_keywords, 'meta_author' => $meta_author, 'page_name' => $page_name); $view['layout'] = $this->managelayout->front($layoutconfig, $this->cbconfig->get_device_view_type()); $this->data = $view; $this->layout = element('layout_skin_file', element('layout', $view)); $this->view = element('view_skin_file', element('layout', $view)); } else { /** * 유효성 검사를 통과한 경우입니다. * 즉 데이터의 insert 나 update 의 process 처리가 필요한 상황입니다 */ // 이벤트가 존재하면 실행합니다 $view['view']['event']['formruntrue'] = Events::trigger('formruntrue', $eventname); $content_type = $use_dhtml ? 1 : 0; if ($origin) { $post_num = element('post_num', $origin); $post_reply = $reply; } else { $post_num = $this->Post_model->next_post_num(); $post_reply = ''; } $metadata = array(); $post_title = $this->input->post('post_title', null, ''); $post_content = $this->input->post('post_content', null, ''); if (element('save_external_image', $board)) { $post_content = $this->imagelib->replace_external_image($post_content); } $updatedata = array('post_num' => $post_num, 'post_reply' => $post_reply, 'post_title' => $post_title, 'post_content' => $post_content, 'post_html' => $content_type, 'post_datetime' => cdate('Y-m-d H:i:s'), 'post_updated_datetime' => cdate('Y-m-d H:i:s'), 'post_ip' => $this->input->ip_address(), 'brd_id' => element('brd_id', $board)); if ($mem_id) { $updatedata['mem_id'] = $mem_id; $updatedata['post_userid'] = $this->member->item('mem_userid'); $updatedata['post_username'] = $this->member->item('mem_username'); $updatedata['post_nickname'] = $this->member->item('mem_nickname'); $updatedata['post_email'] = $this->member->item('mem_email'); $updatedata['post_homepage'] = $this->member->item('mem_homepage'); } if ($is_post_name) { $updatedata['post_nickname'] = $this->input->post('post_nickname', null, ''); $updatedata['post_email'] = $this->input->post('post_email', null, ''); $updatedata['post_homepage'] = $this->input->post('post_homepage', null, ''); } if ($this->member->is_member() === false && $this->input->post('post_password')) { if (!function_exists('password_hash')) { $this->load->helper('password'); } $updatedata['post_password'] = password_hash($this->input->post('post_password'), PASSWORD_BCRYPT); } if ($can_post_notice) { $updatedata['post_notice'] = $this->input->post('post_notice', null, 0); } if ($can_post_secret) { $updatedata['post_secret'] = $this->input->post('post_secret') ? 1 : 0; } if (element('use_post_secret', $board) === '2') { $updatedata['post_secret'] = 1; } if ($can_post_receive_email) { $updatedata['post_receive_email'] = $this->input->post('post_receive_email') ? 1 : 0; } if (element('use_category', $board)) { $updatedata['post_category'] = $this->input->post('post_category', null, ''); } $updatedata['post_device'] = $this->cbconfig->get_device_type() === 'mobile' ? 'mobile' : 'desktop'; $post_id = $this->Post_model->insert($updatedata); if ($can_post_secret && $this->input->post('post_secret')) { $this->session->set_userdata('view_secret_' . $post_id, '1'); } if ($mem_id > 0 && element('use_point', $board)) { $point = $this->point->insert_point($mem_id, element('point_write', $board), element('board_name', $board) . ' ' . $post_id . ' 게시글 작성', 'post', $post_id, '게시글 작성'); } $extradata = array(); if ($form && is_array($form)) { foreach ($form as $key => $value) { if (!element('use', $value)) { continue; } if (element('func', $value) === 'basic') { continue; } $extradata[element('field_name', $value)] = $this->input->post(element('field_name', $value), null, ''); } $this->Post_extra_vars_model->save($post_id, element('brd_id', $board), $extradata); } if ($reply && $origin && $this->cbconfig->item('use_notification') && $this->cbconfig->item('notification_reply')) { $this->load->library('notificationlib'); $not_message = $updatedata['post_nickname'] . '님께서 [' . element('post_title', $origin) . '] 에 답변을 남기셨습니다'; $not_url = post_url(element('brd_key', $board), $post_id); $this->notificationlib->set_noti(element('mem_id', $origin), $mem_id, 'reply', $post_id, $not_message, $not_url); } if (isset($metadata) && $metadata) { $this->Post_meta_model->save($post_id, element('brd_id', $board), $metadata); } $post_link = $this->input->post('post_link'); if ($post_link && is_array($post_link) && count($post_link) > 0) { foreach ($post_link as $pkey => $pval) { if ($pval) { $linkupdate = array('post_id' => $post_id, 'brd_id' => element('brd_id', $board), 'pln_url' => prep_url($pval)); $this->Post_link_model->insert($linkupdate); } } $postupdate = array('post_link_count' => count($post_link)); $this->Post_model->update($post_id, $postupdate); } if ($this->member->is_member() && element('use_tempsave', $board)) { $this->load->model('Tempsave_model'); $tempwhere = array('brd_id' => element('brd_id', $board), 'mem_id' => $mem_id); $this->Tempsave_model->delete_where($tempwhere); } $file_updated = false; if ($use_upload && $uploadfiledata && is_array($uploadfiledata) && count($uploadfiledata) > 0) { foreach ($uploadfiledata as $pkey => $pval) { if ($pval) { $fileupdate = array('post_id' => $post_id, 'brd_id' => element('brd_id', $board), 'mem_id' => $mem_id, 'pfi_originname' => element('pfi_originname', $pval), 'pfi_filename' => element('pfi_filename', $pval), 'pfi_filesize' => element('pfi_filesize', $pval), 'pfi_width' => element('pfi_width', $pval), 'pfi_height' => element('pfi_height', $pval), 'pfi_type' => element('pfi_type', $pval), 'pfi_is_image' => element('is_image', $pval), 'pfi_datetime' => cdate('Y-m-d H:i:s'), 'pfi_ip' => $this->input->ip_address()); $file_id = $this->Post_file_model->insert($fileupdate); if (!element('is_image', $pval)) { if (element('use_point', $board)) { $point = $this->point->insert_point($mem_id, element('point_fileupload', $board), element('board_name', $board) . ' ' . $post_id . ' 파일 업로드', 'fileupload', $file_id, '파일 업로드'); } } $file_updated = true; } } } $result = $this->Post_file_model->get_post_file_count($post_id); $postupdatedata = array(); if ($result && is_array($result)) { foreach ($result as $value) { if (element('pfi_is_image', $value)) { $postupdatedata['post_image'] = element('cnt', $value); } else { $postupdatedata['post_file'] = element('cnt', $value); } } $this->Post_model->update($post_id, $postupdatedata); } $emailsendlistadmin = array(); $notesendlistadmin = array(); $emailsendlistpostwriter = array(); $notesendlistpostwriter = array(); if (element('send_email_post_super_admin', $board) or element('send_note_post_super_admin', $board)) { $mselect = 'mem_id, mem_email, mem_nickname, mem_phone'; $superadminlist = $this->Member_model->get_superadmin_list($mselect); } if (element('send_email_post_group_admin', $board) or element('send_note_post_group_admin', $board)) { $this->load->model('Board_group_admin_model'); $groupadminlist = $this->Board_group_admin_model->get_board_group_admin_member(element('bgr_id', $board)); } if (element('send_email_post_board_admin', $board) or element('send_note_post_board_admin', $board)) { $this->load->model('Board_admin_model'); $boardadminlist = $this->Board_admin_model->get_board_admin_member(element('brd_id', $board)); } if (element('send_email_post_super_admin', $board) && $superadminlist) { foreach ($superadminlist as $key => $value) { $emailsendlistadmin[$value['mem_id']] = $value; } } if (element('send_email_post_group_admin', $board) && $groupadminlist) { foreach ($groupadminlist as $key => $value) { $emailsendlistadmin[$value['mem_id']] = $value; } } if (element('send_email_post_board_admin', $board) && $boardadminlist) { foreach ($boardadminlist as $key => $value) { $emailsendlistadmin[$value['mem_id']] = $value; } } if (element('send_email_post_writer', $board) && $this->member->item('mem_receive_email')) { $emailsendlistpostwriter['mem_email'] = $updatedata['post_email']; } if (element('send_note_post_super_admin', $board) && $superadminlist) { foreach ($superadminlist as $key => $value) { $notesendlistadmin[$value['mem_id']] = $value; } } if (element('send_note_post_group_admin', $board) && $groupadminlist) { foreach ($groupadminlist as $key => $value) { $notesendlistadmin[$value['mem_id']] = $value; } } if (element('send_note_post_board_admin', $board) && $boardadminlist) { foreach ($boardadminlist as $key => $value) { $notesendlistadmin[$value['mem_id']] = $value; } } if (element('send_note_post_writer', $board) && $this->member->item('mem_use_note')) { $notesendlistpostwriter['mem_id'] = $mem_id; } $searchconfig = array('{홈페이지명}', '{회사명}', '{홈페이지주소}', '{게시글제목}', '{게시글내용}', '{게시글작성자닉네임}', '{게시글작성자아이디}', '{게시글작성시간}', '{게시글주소}', '{게시판명}', '{게시판주소}'); $autolink = element('use_auto_url', $board) ? true : false; $popup = element('content_target_blank', $board) ? true : false; $replaceconfig = array($this->cbconfig->item('site_title'), $this->cbconfig->item('company_name'), site_url(), $post_title, display_html_content($post_content, $content_type, element('post_image_width', $board), $autolink, $popup), $updatedata['post_nickname'], $this->member->item('mem_userid'), cdate('Y-m-d H:i:s'), post_url(element('brd_key', $board), $post_id), element('brd_name', $board), board_url(element('brd_key', $board))); $replaceconfig_escape = array(html_escape($this->cbconfig->item('site_title')), html_escape($this->cbconfig->item('company_name')), site_url(), html_escape($post_title), display_html_content($post_content, $content_type, element('post_image_width', $board), $autolink, $popup), html_escape($updatedata['post_nickname']), $this->member->item('mem_userid'), cdate('Y-m-d H:i:s'), post_url(element('brd_key', $board), $post_id), html_escape(element('brd_name', $board)), board_url(element('brd_key', $board))); if ($emailsendlistadmin) { $title = str_replace($searchconfig, $replaceconfig, $this->cbconfig->item('send_email_post_admin_title')); $content = str_replace($searchconfig, $replaceconfig_escape, $this->cbconfig->item('send_email_post_admin_content')); foreach ($emailsendlistadmin as $akey => $aval) { $this->email->clear(true); $this->email->from($this->cbconfig->item('webmaster_email'), $this->cbconfig->item('webmaster_name')); $this->email->to(element('mem_email', $aval)); $this->email->subject($title); $this->email->message($content); $this->email->send(); } } if ($emailsendlistpostwriter) { $title = str_replace($searchconfig, $replaceconfig, $this->cbconfig->item('send_email_post_writer_title')); $content = str_replace($searchconfig, $replaceconfig_escape, $this->cbconfig->item('send_email_post_writer_content')); $this->email->clear(true); $this->email->from($this->cbconfig->item('webmaster_email'), $this->cbconfig->item('webmaster_name')); $this->email->to(element('mem_email', $emailsendlistpostwriter)); $this->email->subject($title); $this->email->message($content); $this->email->send(); } if ($notesendlistadmin) { $title = str_replace($searchconfig, $replaceconfig, $this->cbconfig->item('send_note_post_admin_title')); $content = str_replace($searchconfig, $replaceconfig_escape, $this->cbconfig->item('send_note_post_admin_content')); foreach ($notesendlistadmin as $akey => $aval) { $note_result = $this->notelib->send_note($sender = 0, $receiver = element('mem_id', $aval), $title, $content, 1); } } if ($notesendlistpostwriter && element('mem_id', $notesendlistpostwriter)) { $title = str_replace($searchconfig, $replaceconfig, $this->cbconfig->item('send_note_post_writer_title')); $content = str_replace($searchconfig, $replaceconfig_escape, $this->cbconfig->item('send_note_post_writer_content')); $note_result = $this->notelib->send_note($sender = 0, $receiver = element('mem_id', $notesendlistpostwriter), $title, $content, 1); } // 네이버 신디케이션 보내기 if (!element('post_secret', $updatedata)) { $this->_naver_syndi($post_id, $board); } $this->session->set_flashdata('message', '게시물이 정상적으로 입력되었습니다'); $this->session->set_userdata('lastest_post_time', ctimestamp()); // 이벤트가 존재하면 실행합니다 Events::trigger('after', $eventname); /** * 게시물의 신규입력 또는 수정작업이 끝난 후 뷰 페이지로 이동합니다 */ $redirecturl = post_url(element('brd_key', $board), $post_id); redirect($redirecturl); } }