Example #1
0
 public function get_current_count($curdatetime = '')
 {
     if (empty($curdatetime)) {
         $curdatetime = cdate('Y-m-d H:i:s', ctimestamp() - 600);
     }
     $this->db->select('count(*) as rownum');
     $this->db->join('member', 'currentvisitor.mem_id = member.mem_id', 'left');
     $this->db->where(array('cur_datetime >' => $curdatetime));
     $this->db->group_start();
     $this->db->where(array('member.mem_is_admin' => 0));
     $this->db->or_where(array('member.mem_is_admin' => null));
     $this->db->group_end();
     $qry = $this->db->get($this->_table);
     $rows = $qry->row_array();
     return $rows['rownum'];
 }
Example #2
0
 /**
  * 오래된로그 삭제>자동로그인로그삭제 페이지입니다
  */
 public function autologin()
 {
     // 이벤트 라이브러리를 로딩합니다
     $eventname = 'event_admin_config_cleanlog_autologin';
     $this->load->event($eventname);
     $view = array();
     $view['view'] = array();
     // 이벤트가 존재하면 실행합니다
     $view['view']['event']['before'] = Events::trigger('before', $eventname);
     /**
      * Validation 라이브러리를 가져옵니다
      */
     $this->load->library('form_validation');
     /**
      * 전송된 데이터의 유효성을 체크합니다
      */
     $config = array(array('field' => 'day', 'label' => '기간', 'rules' => 'trim|required|numeric|is_natural'));
     $this->form_validation->set_rules($config);
     /**
      * 유효성 검사를 하지 않는 경우, 또는 유효성 검사에 실패한 경우입니다.
      * 즉 글쓰기나 수정 페이지를 보고 있는 경우입니다
      */
     if ($this->form_validation->run() === false) {
         // 이벤트가 존재하면 실행합니다
         $view['view']['event']['formrunfalse'] = Events::trigger('formrunfalse', $eventname);
     } else {
         /**
          * 유효성 검사를 통과한 경우입니다.
          * 즉 데이터의 insert 나 update 의 process 처리가 필요한 상황입니다
          */
         // 이벤트가 존재하면 실행합니다
         $view['view']['event']['formruntrue'] = Events::trigger('formruntrue', $eventname);
         if ($this->input->post('criterion') && $this->input->post('day')) {
             $deletewhere = array('aul_datetime <=' => $this->input->post('criterion'));
             $this->Autologin_model->delete_where($deletewhere);
             $view['view']['alert_message'] = '총 ' . number_format($this->input->post('log_count')) . ' 건의 ' . $this->input->post('day') . '일 이상된 자동로그인로그가 모두 삭제되었습니다';
         } else {
             $criterion = cdate('Y-m-d H:i:s', ctimestamp() - $this->input->post('day') * 24 * 60 * 60);
             $countwhere = array('aul_datetime <=' => $criterion);
             $log_count = $this->Autologin_model->count_by($countwhere);
             $view['view']['criterion'] = $criterion;
             $view['view']['day'] = $this->input->post('day');
             $view['view']['log_count'] = $log_count;
             if ($log_count > 0) {
                 $view['view']['msg'] = '총 ' . number_format($log_count) . ' 건의 ' . $this->input->post('day') . '일 이상된 자동로그인로그가 발견되었습니다. 이를 모두 삭제하시겠습니까?';
             } else {
                 $view['view']['alert_message'] = $this->input->post('day') . '일 이상된 자동로그인로그가 발견되지 않았습니다';
             }
         }
     }
     // 이벤트가 존재하면 실행합니다
     $view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
     /**
      * 어드민 레이아웃을 정의합니다
      */
     $layoutconfig = array('layout' => 'layout', 'skin' => 'autologin');
     $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));
 }
Example #3
0
 /**
  * 게시판 목록페이지입니다.
  */
 public function _get_list($brd_key, $from_view = '')
 {
     // 이벤트 라이브러리를 로딩합니다
     $eventname = 'event_board_post_get_list';
     $this->load->event($eventname);
     $view = array();
     $view['view'] = array();
     // 이벤트가 존재하면 실행합니다
     $view['view']['event']['before'] = Events::trigger('before', $eventname);
     $return = array();
     $board = $this->_get_board($brd_key);
     $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_list', $board), element('access_list_level', $board), element('access_list_group', $board), $alertmessage, $check);
     if (element('use_personal', $board) && $this->member->is_member() === false) {
         alert('이 게시판은 1:1 게시판입니다. 비회원은 접근할 수 없습니다');
         return false;
     }
     $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']['is_admin'] = $is_admin = $this->member->is_admin(array('board_id' => element('brd_id', $board), 'group_id' => element('bgr_id', $board)));
     /**
      * 페이지에 숫자가 아닌 문자가 입력되거나 1보다 작은 숫자가 입력되면 에러 페이지를 보여줍니다.
      */
     $param =& $this->querystring;
     $page = (int) $this->input->get('page') > 0 ? (int) $this->input->get('page') : 1;
     $order_by_field = element('order_by_field', $board) ? element('order_by_field', $board) : 'post_num, post_reply';
     $findex = $this->input->get('findex', null, $order_by_field);
     $sfield = $sfieldchk = $this->input->get('sfield', null, '');
     if ($sfield === 'post_both') {
         $sfield = array('post_title', 'post_content');
     }
     $skeyword = $this->input->get('skeyword', null, '');
     if ($this->cbconfig->get_device_view_type() === 'mobile') {
         $per_page = element('mobile_list_count', $board) ? (int) element('mobile_list_count', $board) : 10;
     } else {
         $per_page = element('list_count', $board) ? (int) element('list_count', $board) : 20;
     }
     $offset = ($page - 1) * $per_page;
     $this->Post_model->allow_search_field = array('post_id', 'post_title', 'post_content', 'post_both', 'post_category', 'post_userid', 'post_nickname');
     // 검색이 가능한 필드
     $this->Post_model->search_field_equal = array('post_id', 'post_userid', 'post_nickname');
     // 검색중 like 가 아닌 = 검색을 하는 필드
     // 이벤트가 존재하면 실행합니다
     $view['view']['event']['step1'] = Events::trigger('step1', $eventname);
     /**
      * 상단에 공지사항 부분에 필요한 정보를 가져옵니다.
      */
     $except_all_notice = false;
     if (element('except_all_notice', $board) && $this->cbconfig->get_device_view_type() !== 'mobile') {
         $except_all_notice = true;
     }
     if (element('mobile_except_all_notice', $board) && $this->cbconfig->get_device_view_type() === 'mobile') {
         $except_all_notice = true;
     }
     $use_sideview = $this->cbconfig->get_device_view_type() === 'mobile' ? element('use_mobile_sideview', $board) : element('use_sideview', $board);
     $list_date_style = $this->cbconfig->get_device_view_type() === 'mobile' ? element('mobile_list_date_style', $board) : element('list_date_style', $board);
     $list_date_style_manual = $this->cbconfig->get_device_view_type() === 'mobile' ? element('mobile_list_date_style_manual', $board) : element('list_date_style_manual', $board);
     if (element('use_gallery_list', $board)) {
         $this->load->model('Post_file_model');
         $board['gallery_cols'] = $gallery_cols = $this->cbconfig->get_device_view_type() === 'mobile' ? element('mobile_gallery_cols', $board) : element('gallery_cols', $board);
         $board['gallery_image_width'] = $gallery_image_width = $this->cbconfig->get_device_view_type() === 'mobile' ? element('mobile_gallery_image_width', $board) : element('gallery_image_width', $board);
         $board['gallery_image_height'] = $gallery_image_height = $this->cbconfig->get_device_view_type() === 'mobile' ? element('mobile_gallery_image_height', $board) : element('gallery_image_height', $board);
         $board['gallery_percent'] = floor(102 / $board['gallery_cols']) - 2;
     }
     if (element('use_category', $board)) {
         $this->load->model('Board_category_model');
         $board['category'] = $this->Board_category_model->get_all_category(element('brd_id', $board));
     }
     $noticeresult = $this->Post_model->get_notice_list(element('brd_id', $board), $except_all_notice, $sfield, $skeyword);
     if ($noticeresult) {
         foreach ($noticeresult as $key => $val) {
             $notice_brd_key = $this->board->item_id('brd_key', element('brd_id', $val));
             $noticeresult[$key]['post_url'] = post_url($notice_brd_key, element('post_id', $val));
             $noticeresult[$key]['meta'] = $meta = $this->Post_meta_model->get_all_meta(element('post_id', $val));
             if ($this->cbconfig->get_device_view_type() === 'mobile') {
                 $noticeresult[$key]['title'] = element('mobile_subject_length', $board) ? cut_str(element('post_title', $val), element('mobile_subject_length', $board)) : element('post_title', $val);
             } else {
                 $noticeresult[$key]['title'] = element('subject_length', $board) ? cut_str(element('post_title', $val), element('subject_length', $board)) : element('post_title', $val);
             }
             if (element('post_del', $val)) {
                 $noticeresult[$key]['title'] = '게시물이 삭제 되었습니다';
             }
             $noticeresult[$key]['display_name'] = display_username(element('post_userid', $val), element('post_nickname', $val), element('mem_icon', $val), $use_sideview ? 'Y' : 'N');
             $noticeresult[$key]['display_datetime'] = display_datetime(element('post_datetime', $val), $list_date_style, $list_date_style_manual);
             $noticeresult[$key]['category'] = '';
             if (element('use_category', $board) && element('post_category', $val)) {
                 $noticeresult[$key]['category'] = $this->Board_category_model->get_category_info(element('brd_id', $val), element('post_category', $val));
             }
             if ($param->output()) {
                 $noticeresult[$key]['post_url'] .= '?' . $param->output();
             }
             $noticeresult[$key]['is_mobile'] = element('post_device', $val) === 'mobile' ? true : false;
         }
     }
     /**
      * 게시판 목록에 필요한 정보를 가져옵니다.
      */
     $where = array('brd_id' => $this->board->item_key('brd_id', $brd_key));
     $where['post_del <>'] = 2;
     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;
     }
     $category_id = (int) $this->input->get('category_id');
     if (empty($category_id) or $category < 1) {
         $category_id = '';
     }
     $result = $this->Post_model->get_post_list($per_page, $offset, $where, $category_id, $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]['post_url'] = post_url(element('brd_key', $board), element('post_id', $val));
             $result['list'][$key]['meta'] = $meta = $this->Post_meta_model->get_all_meta(element('post_id', $val));
             if ($this->cbconfig->get_device_view_type() === 'mobile') {
                 $result['list'][$key]['title'] = element('mobile_subject_length', $board) ? cut_str(element('post_title', $val), element('mobile_subject_length', $board)) : element('post_title', $val);
             } else {
                 $result['list'][$key]['title'] = element('subject_length', $board) ? cut_str(element('post_title', $val), element('subject_length', $board)) : element('post_title', $val);
             }
             if (element('post_del', $val)) {
                 $result['list'][$key]['title'] = '게시물이 삭제 되었습니다';
             }
             $is_blind = element('blame_blind_count', $board) > 0 && element('post_blame', $val) >= element('blame_blind_count', $board) ? true : false;
             if ($is_blind) {
                 $result['list'][$key]['title'] = '신고가 접수된 게시글입니다.';
             }
             $result['list'][$key]['display_name'] = display_username(element('post_userid', $val), element('post_nickname', $val), element('mem_icon', $val), $use_sideview ? 'Y' : 'N');
             $result['list'][$key]['display_datetime'] = display_datetime(element('post_datetime', $val), $list_date_style, $list_date_style_manual);
             $result['list'][$key]['category'] = '';
             if (element('use_category', $board) && element('post_category', $val)) {
                 $result['list'][$key]['category'] = $this->Board_category_model->get_category_info(element('brd_id', $val), element('post_category', $val));
             }
             if ($param->output()) {
                 $result['list'][$key]['post_url'] .= '?' . $param->output();
             }
             $result['list'][$key]['num'] = $list_num--;
             $result['list'][$key]['is_hot'] = false;
             $hot_icon_day = $this->cbconfig->get_device_view_type() === 'mobile' ? element('mobile_hot_icon_day', $board) : element('hot_icon_day', $board);
             $hot_icon_hit = $this->cbconfig->get_device_view_type() === 'mobile' ? element('mobile_hot_icon_hit', $board) : element('hot_icon_hit', $board);
             if ($hot_icon_day && ctimestamp() - strtotime(element('post_datetime', $val)) <= $hot_icon_day * 86400) {
                 if ($hot_icon_hit && $hot_icon_hit <= element('post_hit', $val)) {
                     $result['list'][$key]['is_hot'] = true;
                 }
             }
             $result['list'][$key]['is_new'] = false;
             $new_icon_hour = $this->cbconfig->get_device_view_type() === 'mobile' ? element('mobile_new_icon_hour', $board) : element('new_icon_hour', $board);
             if ($new_icon_hour && ctimestamp() - strtotime(element('post_datetime', $val)) <= $new_icon_hour * 3600) {
                 $result['list'][$key]['is_new'] = true;
             }
             $result['list'][$key]['is_mobile'] = element('post_device', $val) === 'mobile' ? true : false;
             $result['list'][$key]['thumb_url'] = '';
             $result['list'][$key]['origin_image_url'] = '';
             if (element('use_gallery_list', $board)) {
                 if (element('post_image', $val)) {
                     $filewhere = array('post_id' => element('post_id', $val), 'pfi_is_image' => 1);
                     $file = $this->Post_file_model->get_one('', '', $filewhere, '', '', 'pfi_id', 'ASC');
                     $result['list'][$key]['thumb_url'] = thumb_url('post', element('pfi_filename', $file), $gallery_image_width, $gallery_image_height);
                     $result['list'][$key]['origin_image_url'] = thumb_url('post', element('pfi_filename', $file));
                 } else {
                     $thumb_url = get_post_image_url(element('post_content', $val), $gallery_image_width, $gallery_image_height);
                     $result['list'][$key]['thumb_url'] = $thumb_url ? $thumb_url : thumb_url('', '', $gallery_image_width, $gallery_image_height);
                     $result['list'][$key]['origin_image_url'] = $thumb_url;
                 }
             }
         }
     }
     $return['data'] = $result;
     $return['notice_list'] = $noticeresult;
     if (empty($from_view)) {
         $board['headercontent'] = $this->cbconfig->get_device_view_type() === 'mobile' ? element('mobile_header_content', $board) : element('header_content', $board);
     }
     $board['footercontent'] = $this->cbconfig->get_device_view_type() === 'mobile' ? element('mobile_footer_content', $board) : element('footer_content', $board);
     $board['cat_display_style'] = $this->cbconfig->get_device_view_type() === 'mobile' ? element('mobile_category_display_style', $board) : element('category_display_style', $board);
     $return['board'] = $board;
     $return['point_info'] = '';
     if ($this->cbconfig->item('use_point') && element('use_point', $board) && element('use_point_info', $board)) {
         $point_info = '';
         if (element('point_write', $board)) {
             $point_info .= '원글작성 : ' . element('point_write', $board) . '<br />';
         }
         if (element('point_comment', $board)) {
             $point_info .= '댓글작성 : ' . element('point_comment', $board) . '<br />';
         }
         if (element('point_fileupload', $board)) {
             $point_info .= '파일업로드 : ' . element('point_fileupload', $board) . '<br />';
         }
         if (element('point_filedownload', $board)) {
             $point_info .= '파일다운로드 : ' . element('point_filedownload', $board) . '<br />';
         }
         if (element('point_filedownload_uploader', $board)) {
             $point_info .= '파일다운로드시업로더에게 : ' . element('point_filedownload_uploader', $board) . '<br />';
         }
         if (element('point_read', $board)) {
             $point_info .= '게시글조회 : ' . element('point_read', $board) . '<br />';
         }
         if (element('point_post_like', $board)) {
             $point_info .= '원글추천함 : ' . element('point_post_like', $board) . '<br />';
         }
         if (element('point_post_dislike', $board)) {
             $point_info .= '원글비추천함 : ' . element('point_post_dislike', $board) . '<br />';
         }
         if (element('point_post_liked', $board)) {
             $point_info .= '원글추천받음 : ' . element('point_post_liked', $board) . '<br />';
         }
         if (element('point_post_disliked', $board)) {
             $point_info .= '원글비추천받음 : ' . element('point_post_disliked', $board) . '<br />';
         }
         if (element('point_comment_like', $board)) {
             $point_info .= '댓글추천함 : ' . element('point_comment_like', $board) . '<br />';
         }
         if (element('point_comment_dislike', $board)) {
             $point_info .= '댓글비추천함 : ' . element('point_comment_dislike', $board) . '<br />';
         }
         if (element('point_comment_liked', $board)) {
             $point_info .= '댓글추천받음 : ' . element('point_comment_liked', $board) . '<br />';
         }
         if (element('point_comment_disliked', $board)) {
             $point_info .= '댓글비추천받음 : ' . element('point_comment_disliked', $board) . '<br />';
         }
         $return['point_info'] = $point_info;
     }
     // 이벤트가 존재하면 실행합니다
     $view['view']['event']['step2'] = Events::trigger('step2', $eventname);
     /**
      * primary key 정보를 저장합니다
      */
     $return['primary_key'] = $this->Post_model->primary_key;
     $highlight_keyword = '';
     if ($skeyword) {
         if (!$this->session->userdata('skeyword_' . $skeyword)) {
             $sfieldarray = array('post_title', 'post_content', 'post_both');
             if (in_array($sfieldchk, $sfieldarray)) {
                 $this->load->model('Search_keyword_model');
                 $searchinsert = array('sek_keyword' => $skeyword, 'sek_datetime' => cdate('Y-m-d H:i:s'), 'sek_ip' => $this->input->ip_address(), 'mem_id' => $mem_id);
                 $this->Search_keyword_model->insert($searchinsert);
                 $this->session->set_userdata('skeyword_' . $skeyword, 1);
             }
         }
         $key_explode = explode(' ', $skeyword);
         if ($key_explode) {
             foreach ($key_explode as $seval) {
                 if ($highlight_keyword) {
                     $highlight_keyword .= ',';
                 }
                 $highlight_keyword .= '\'' . html_escape($seval) . '\'';
             }
         }
     }
     $return['highlight_keyword'] = $highlight_keyword;
     /**
      * 페이지네이션을 생성합니다
      */
     $config['base_url'] = board_url($brd_key) . '?' . $param->replace('page');
     $config['total_rows'] = $result['total_rows'];
     $config['per_page'] = $per_page;
     if ($this->cbconfig->get_device_view_type() === 'mobile') {
         $config['num_links'] = element('mobile_page_count', $board) ? element('mobile_page_count', $board) : 3;
     } else {
         $config['num_links'] = element('page_count', $board) ? element('page_count', $board) : 5;
     }
     $this->pagination->initialize($config);
     $return['paging'] = $this->pagination->create_links();
     $return['page'] = $page;
     /**
      * 쓰기 주소, 삭제 주소등 필요한 주소를 구합니다
      */
     $search_option = array('post_title' => '제목', 'post_content' => '내용');
     $return['search_option'] = search_option($search_option, $sfield);
     if ($skeyword) {
         $return['list_url'] = board_url(element('brd_key', $board));
         $return['search_list_url'] = board_url(element('brd_key', $board) . '?' . $param->output());
     } else {
         $return['list_url'] = board_url(element('brd_key', $board) . '?' . $param->output());
         $return['search_list_url'] = '';
     }
     $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);
     $return['write_url'] = '';
     if ($can_write === true) {
         $return['write_url'] = write_url($brd_key);
     } elseif ($this->cbconfig->get_device_view_type() !== 'mobile' && element('always_show_write_button', $board)) {
         $return['write_url'] = 'javascript:alert(\'비회원은 글쓰기 권한이 없습니다.\\n\\n회원이시라면 로그인 후 이용해 보십시오.\');';
     } elseif ($this->cbconfig->get_device_view_type() === 'mobile' && element('mobile_always_show_write_button', $board)) {
         $return['write_url'] = 'javascript:alert(\'비회원은 글쓰기 권한이 없습니다.\\n\\n회원이시라면 로그인 후 이용해 보십시오.\');';
     }
     $return['list_delete_url'] = site_url('postact/listdelete/' . $brd_key . '?' . $param->output());
     return $return;
 }
Example #4
0
 /**
  * 아이디와 패스워드가 일치하는지 체크합니다
  */
 public function _check_id_pw($password, $userid)
 {
     if (!function_exists('password_hash')) {
         $this->load->helper('password');
     }
     $max_login_try_count = (int) $this->cbconfig->item('max_login_try_count');
     $max_login_try_limit_second = (int) $this->cbconfig->item('max_login_try_limit_second');
     $loginfailnum = 0;
     $loginfailmessage = '';
     if ($max_login_try_count && $max_login_try_limit_second) {
         $select = 'mll_id, mll_success, mem_id, mll_ip, mll_datetime';
         $where = array('mll_ip' => $this->input->ip_address(), 'mll_datetime > ' => strtotime(ctimestamp() - 86400 * 30));
         $findex = 'mll_id';
         $forder = 'DESC';
         $logindata = $this->Member_login_log_model->get('', $select, $where, '', '', $findex, $forder);
         if ($logindata && is_array($logindata)) {
             foreach ($logindata as $key => $val) {
                 if (element('mll_success', $val) === '0') {
                     $loginfailnum++;
                 }
                 if (element('mll_success', $val) === '1') {
                     break;
                 }
             }
         }
         if ($loginfailnum > 0 && $loginfailnum % $max_login_try_count === 0) {
             $lastlogintrydatetime = $logindata[0]['mll_datetime'];
             $next_login = strtotime($lastlogintrydatetime) + $max_login_try_limit_second - ctimestamp();
             if ($next_login > 0) {
                 $this->form_validation->set_message('_check_id_pw', '회원님은 패스워드를 연속으로 ' . $loginfailnum . '회 잘못 입력하셨기 때문에 ' . $next_login . '초 후에 다시 시도가 가능합니다');
                 return false;
             }
         }
         $loginfailmessage = '<br />회원님은 ' . ($loginfailnum + 1) . '회 연속으로 패스워드를 잘못입력하셨습니다. ';
     }
     $userselect = 'mem_id, mem_password, mem_denied';
     $userinfo = $this->Member_model->get_by_userid($userid, $userselect);
     $hash = password_hash($password, PASSWORD_BCRYPT);
     if (!element('mem_id', $userinfo) or !element('mem_password', $userinfo)) {
         $this->form_validation->set_message('_check_id_pw', '회원 아이디와 패스워드가 서로 맞지 않습니다' . $loginfailmessage);
         $this->member->update_login_log(0, 0, '회원아이디가 존재하지 않습니다');
         return false;
     } elseif (!password_verify($password, element('mem_password', $userinfo))) {
         $this->form_validation->set_message('_check_id_pw', '회원 아이디와 패스워드가 서로 맞지 않습니다' . $loginfailmessage);
         $this->member->update_login_log(element('mem_id', $userinfo), 0, '패스워드가 올바르지 않습니다');
         return false;
     } elseif (element('mem_denied', $userinfo)) {
         if (element('mem_denied', $userinfo) === '1') {
             $this->form_validation->set_message('_check_id_pw', '회원님의 아이디는 탈퇴하신 아이디입니다');
             $this->member->update_login_log(element('mem_id', $userinfo), 0, '탈퇴한 회원아이디입니다');
             return false;
         } elseif (element('mem_denied', $userinfo) === '2') {
             $this->form_validation->set_message('_check_id_pw', '회원님의 아이디는 관리자에 의해 차단되었습니다');
             $this->member->update_login_log(element('mem_id', $userinfo), 0, '차단된 회원아이디입니다');
             return false;
         }
     }
     return true;
 }
Example #5
0
 /**
  * 프론트페이지 레이아웃관리합니다
  */
 function front($config = array(), $device_view_type = '')
 {
     $data = array();
     $CI =& get_instance();
     if ($CI->uri->segment(1) === config_item('uri_segment_admin') && $CI->uri->segment(2) === 'preview') {
         return $this->preview($config);
     }
     $searchconfig = array('{홈페이지제목}', '{현재주소}', '{회원아이디}', '{회원닉네임}', '{회원레벨}', '{회원포인트}');
     $replaceconfig = array($CI->cbconfig->item('site_title'), current_full_url(), $CI->member->item('mem_userid'), $CI->member->item('mem_nickname'), $CI->member->item('mem_level'), $CI->member->item('mem_point'));
     $page_title = element('page_title', $config) ? element('page_title', $config) : $CI->cbconfig->item('site_meta_title_default');
     $meta_description = element('meta_description', $config) ? element('meta_description', $config) : $CI->cbconfig->item('site_meta_description_default');
     $meta_keywords = element('meta_keywords', $config) ? element('meta_keywords', $config) : $CI->cbconfig->item('site_meta_keywords_default');
     $meta_author = element('meta_author', $config) ? element('meta_author', $config) : $CI->cbconfig->item('site_meta_author_default');
     $page_name = element('page_name', $config) ? element('page_name', $config) : $CI->cbconfig->item('site_page_name_default');
     $data['page_title'] = $page_title = str_replace($searchconfig, $replaceconfig, $page_title);
     $data['meta_description'] = $meta_description = str_replace($searchconfig, $replaceconfig, $meta_description);
     $data['meta_keywords'] = $meta_keywords = str_replace($searchconfig, $replaceconfig, $meta_keywords);
     $data['meta_author'] = $meta_author = str_replace($searchconfig, $replaceconfig, $meta_author);
     $data['page_name'] = $page_name = str_replace($searchconfig, $replaceconfig, $page_name);
     $layoutdirname = $device_view_type === 'mobile' ? element('mobile_layout_dir', $config) : element('layout_dir', $config);
     if (empty($layoutdirname)) {
         $layoutdirname = $device_view_type === 'mobile' ? $CI->cbconfig->item('mobile_layout_default') : $CI->cbconfig->item('layout_default');
     }
     if (empty($layoutdirname)) {
         $layoutdirname = 'basic';
     }
     $layout = '_layout/' . $layoutdirname;
     $data['layout_skin_path'] = $layout;
     $data['layout_skin_url'] = base_url(VIEW_DIR . $data['layout_skin_path']);
     $layout .= '/';
     if (element('layout', $config)) {
         $layout .= element('layout', $config);
     }
     $data['layout_skin_file'] = $layout;
     $skindir = $device_view_type === 'mobile' ? element('mobile_skin_dir', $config) : element('skin_dir', $config);
     if (empty($skindir)) {
         $skindir = $device_view_type === 'mobile' ? $CI->cbconfig->item('mobile_skin_default') : $CI->cbconfig->item('skin_default');
     }
     if (empty($skindir)) {
         $skindir = 'basic';
     }
     $skin = '';
     if (element('path', $config)) {
         $skin .= element('path', $config) . '/';
     }
     $skin .= $skindir;
     $data['view_skin_path'] = $skin;
     $data['view_skin_url'] = base_url(VIEW_DIR . $data['view_skin_path']);
     $skin .= '/';
     if (element('skin', $config)) {
         $skin .= element('skin', $config);
     }
     $data['view_skin_file'] = $skin;
     $user_sidebar = $device_view_type === 'mobile' ? element('use_mobile_sidebar', $config) : element('use_sidebar', $config);
     if ($user_sidebar === '1') {
         $data['use_sidebar'] = '1';
     } elseif ($user_sidebar === '2') {
         $data['use_sidebar'] = '';
     } else {
         $user_sidebar = $device_view_type === 'mobile' ? $CI->cbconfig->item('mobile_sidebar_default') : $CI->cbconfig->item('sidebar_default');
         if ($user_sidebar === '1') {
             $data['use_sidebar'] = '1';
         } elseif ($user_sidebar === '2') {
             $data['use_sidebar'] = '';
         } else {
             $data['use_sidebar'] = '';
         }
     }
     $cachename = 'latest_version_from_ciboard_api';
     $cachetime = 10800;
     if (!($result = $CI->cache->get($cachename))) {
         $CI->load->library('Requests');
         $requests = new Requests();
         $requests->register_autoloader();
         $headers = array('Accept' => 'application/json');
         $postdata = array('requesturl' => current_full_url(), 'package' => CB_PACKAGE, 'version' => CB_VERSION);
         $request = $requests->post(config_item('ciboard_check_latest_version'), $headers, $postdata);
         $result['latest_versions'] = json_decode($request->body, true);
         if (strtolower(CB_PACKAGE) === 'premium') {
             $result['latest_version_name'] = $result['latest_versions']['premium_version'];
             $result['latest_download_url'] = $result['latest_versions']['premium_downloadurl'];
         } else {
             $result['latest_version_name'] = $result['latest_versions']['basic_version'];
             $result['latest_download_url'] = $result['latest_versions']['basic_downloadurl'];
         }
         $CI->cache->save($cachename, $result, $cachetime);
     }
     $data['version_latest'] = $result;
     $mem_id = (int) $CI->member->item('mem_id');
     // 현재 접속자
     $CI->load->model('Currentvisitor_model');
     $currentpage = $page_name ? $page_name : $page_title;
     $currentpage = $currentpage ? $currentpage : $CI->cbconfig->item('site_title');
     $CI->Currentvisitor_model->add_visitor($CI->input->ip_address(), $mem_id, $CI->member->item('mem_nickname'), cdate('Y-m-d H:i:s'), $currentpage, current_full_url(), $CI->agent->referrer(), $CI->agent->agent_string());
     if ($CI->cbconfig->item('open_currentvisitor') or $CI->member->is_admin() === 'super') {
         $minute = (int) $CI->cbconfig->item('currentvisitor_minute');
         if ($minute < 1) {
             $minute = 10;
         }
         $curdatetime = cdate('Y-m-d H:i:s', ctimestamp() - $minute * 60);
         $data['current_visitor_num'] = $CI->Currentvisitor_model->get_current_count($curdatetime);
     }
     // 알림
     $data['notification_num'] = 0;
     if ($CI->cbconfig->item('use_notification')) {
         if ($CI->member->is_member()) {
             $CI->load->model('Notification_model');
             $data['notification_num'] = $CI->Notification_model->unread_notification_num($mem_id);
         }
     }
     // 메뉴관리
     $CI->load->model('Menu_model');
     $data['menu'] = $CI->Menu_model->get_all_menu($device_view_type);
     //팝업관리
     $CI->load->library('popuplib');
     $data['popup'] = $CI->popuplib->display_popup();
     return $data;
 }
Example #6
0
 /**
  * 최근 댓글을 가져옵니다
  */
 public function latest_comment($config)
 {
     $view = array();
     $view['view'] = array();
     $this->CI->load->model(array('Comment_model'));
     $skin = element('skin', $config);
     $brd_id = element('brd_id', $config);
     $brd_key = element('brd_key', $config);
     $exclude_brd_id = element('exclude_brd_id', $config);
     $exclude_brd_key = element('exclude_brd_key', $config);
     $findex = element('findex', $config) ? element('findex', $config) : 'cmt_id';
     $forder = element('forder', $config) ? element('forder', $config) : 'DESC';
     $limit = element('limit', $config);
     $length = element('length', $config);
     $period_second = element('period_second', $config);
     $cache_minute = element('cache_minute', $config);
     if ($limit <= 0) {
         return false;
     }
     if ($cache_minute > 0) {
         $cache_brd_id = is_array($brd_id) ? implode('-', $brd_id) : $brd_id;
         $cache_brd_key = is_array($brd_key) ? implode('-', $brd_key) : $brd_key;
         $cache_exclude_brd_id = is_array($exclude_brd_id) ? implode('-', $exclude_brd_id) : $exclude_brd_id;
         $cache_exclude_brd_key = is_array($exclude_brd_key) ? implode('-', $exclude_brd_key) : $exclude_brd_key;
         $cachename = 'latest-comment-s-' . $skin . '-i-' . $cache_brd_id . '-k-' . $cache_brd_key . '-l-' . $cache_exclude_brd_id . '-k-' . $cache_exclude_brd_key . '-l-' . $limit . '-t-' . $length . '-p-' . $period_second;
         $html = $this->CI->cache->get($cachename);
         if ($html) {
             return $html;
         }
     }
     if (empty($skin)) {
         $skin = 'basic';
     }
     $view['view']['config'] = $config;
     $view['view']['length'] = $length;
     if ($brd_key) {
         if (is_array($brd_key)) {
             foreach ($brd_key as $v) {
                 $brd_id[] = $this->CI->board->item_key('brd_id', $v);
             }
         } else {
             $brd_id = $this->CI->board->item_key('brd_id', $brd_key);
         }
     }
     if ($exclude_brd_key) {
         if (is_array($exclude_brd_key)) {
             foreach ($exclude_brd_key as $v) {
                 $exclude_brd_id[] = $this->CI->board->item_key('brd_id', $v);
             }
         } else {
             $exclude_brd_id = $this->CI->board->item_key('brd_id', $exclude_brd_key);
         }
     }
     if ($brd_id && !is_array($brd_id)) {
         $view['view']['board'] = $this->CI->board->item_all($brd_id);
     }
     $where = array();
     $where['cmt_del'] = 0;
     $where['cmt_secret'] = 0;
     $where['post_secret'] = 0;
     $where['post_del'] = 0;
     $this->CI->db->from('comment');
     $this->CI->db->join('post', 'post.post_id=comment.post_id', 'inner');
     $this->CI->db->where($where);
     if ($brd_id) {
         if (is_array($brd_id)) {
             $this->CI->db->group_start();
             foreach ($brd_id as $v) {
                 $this->CI->db->or_where('comment.brd_id', $v);
             }
             $this->CI->db->group_end();
         } else {
             $this->CI->db->where('comment.brd_id', $brd_id);
         }
     }
     if ($exclude_brd_id) {
         if (is_array($exclude_brd_id)) {
             foreach ($exclude_brd_id as $v) {
                 $this->CI->db->where('comment.brd_id <>', $v);
             }
         } else {
             $this->CI->db->where('comment.brd_id <>', $exclude_brd_id);
         }
     }
     if ($period_second) {
         $comment_start_datetime = cdate('Y-m-d H:i:s', ctimestamp() - $period_second);
         $this->CI->db->where('cmt_datetime >=', $comment_start_datetime);
     }
     if ($findex && $forder) {
         $forder = strtoupper($forder) === 'ASC' ? 'ASC' : 'DESC';
         $this->CI->db->order_by($findex, $forder);
     }
     if (is_numeric($limit)) {
         $this->CI->db->limit($limit);
     }
     $result = $this->CI->db->get();
     $view['view']['latest'] = $latest = $result->result_array();
     $view['view']['latest_limit'] = $limit;
     if ($latest && is_array($latest)) {
         foreach ($latest as $key => $value) {
             $view['view']['latest'][$key]['name'] = display_username(element('cmt_userid', $value), element('cmt_nickname', $value));
             $brd_key = $this->CI->board->item_id('brd_key', element('brd_id', $value));
             $view['view']['latest'][$key]['url'] = post_url($brd_key, element('post_id', $value)) . '#comment_' . element('cmt_id', $value);
             $view['view']['latest'][$key]['title'] = $length ? cut_str(element('cmt_content', $value), $length) : element('cmt_content', $value);
             $view['view']['latest'][$key]['display_datetime'] = display_datetime(element('cmt_datetime', $value), '');
         }
     }
     $view['view']['skinurl'] = base_url(VIEW_DIR . 'latest/' . $skin);
     $html = $this->CI->load->view('latest/' . $skin . '/latest', $view, true);
     if ($cache_minute > 0) {
         $this->CI->cache->save($cachename, $html, $cache_minute);
     }
     return $html;
 }
Example #7
0
 /**
  * 패스워드 리셋위한 함수입니다.
  */
 public function resetpassword()
 {
     // 이벤트 라이브러리를 로딩합니다
     $eventname = 'event_verify_resetpassword';
     $this->load->event($eventname);
     $view = array();
     $view['view'] = array();
     // 이벤트가 존재하면 실행합니다
     $view['view']['event']['before'] = Events::trigger('before', $eventname);
     if (!$this->input->get('code')) {
         show_404();
     }
     if (!$this->input->get('user')) {
         show_404();
     }
     if ($this->member->is_member()) {
         redirect();
     }
     $this->load->library(array('form_validation'));
     $password_length = $this->cbconfig->item('password_length');
     $view['view']['password_length'] = $password_length;
     $where = array('mae_key' => $this->input->get('code'));
     $result = $this->Member_auth_email_model->get_one('', '', $where);
     $view['view']['error_message'] = '';
     $view['view']['successs_message'] = '';
     if (!element('mae_id', $result)) {
         $view['view']['error_message'] = '잘못된 접근입니다';
     } elseif (!empty($result['mae_use_datetime']) && element('mae_use_datetime', $result) !== '0000-00-00 00:00:00') {
         $view['view']['error_message'] = '회원님은 이미 패스워드 변경을 하셨습니다';
     } elseif (strtotime(element('mae_generate_datetime', $result)) < ctimestamp() - 86400) {
         $view['view']['message'] = '24 시간 이내에 인증을 받으셔야 합니다';
     } elseif (element('mae_type', $result) !== '3') {
         $view['view']['error_message'] = '잘못된 접근입니다';
     } else {
         $select = 'mem_id, mem_userid, mem_denied, mem_email_cert';
         $dbmember = $this->Member_model->get_by_memid(element('mem_id', $result), $select);
         if (!element('mem_id', $dbmember)) {
             $view['view']['error_message'] = '잘못된 접근입니다';
         } elseif (element('mem_userid', $dbmember) !== $this->input->get('user')) {
             $view['view']['error_message'] = '잘못된 접근입니다';
         } elseif (element('mem_denied', $dbmember)) {
             if (element('mem_denied', $dbmember) === '1') {
                 $view['view']['error_message'] = '회원님의 아이디는 탈퇴하신 아이디입니다';
             } elseif (element('mem_denied', $dbmember) === '2') {
                 $view['view']['error_message'] = '회원님의 아이디는 차단된 아이디입니다';
             }
         } elseif ($this->cbconfig->item('use_register_email_auth') && !element('mem_email_cert', $dbmember)) {
             $view['view']['error_message'] = '회원님은 회원가입 후, 또는 이메일 정보 변경후 아직 이메일 인증을 받지 않으셨습니다';
         }
         $view['view']['mem_userid'] = element('mem_userid', $dbmember);
     }
     $config = array(array('field' => 'new_password', 'label' => '패스워드', 'rules' => 'trim|required|min_length[' . $password_length . ']|callback__mem_password_check'), array('field' => 'new_password_re', 'label' => '패스워드', 'rules' => 'trim|required|min_length[' . $password_length . ']'));
     $this->form_validation->set_rules($config);
     /**
      * 유효성 검사를 하지 않는 경우, 또는 유효성 검사에 실패한 경우입니다.
      * 즉 글쓰기나 수정 페이지를 보고 있는 경우입니다
      */
     if ($this->form_validation->run() === false) {
         // 이벤트가 존재하면 실행합니다
         $view['view']['event']['formrunfalse'] = Events::trigger('formrunfalse', $eventname);
     } else {
         // 이벤트가 존재하면 실행합니다
         $view['view']['event']['formruntrue'] = Events::trigger('formruntrue', $eventname);
         if (empty($view['view']['error_message'])) {
             $hash = password_hash($this->input->post('new_password'), PASSWORD_BCRYPT);
             $updatedata = array('mem_password' => $hash);
             $this->Member_model->update(element('mem_id', $result), $updatedata);
             $metadata = array('meta_change_pw_datetime' => cdate('Y-m-d H:i:s'));
             $this->Member_meta_model->save(element('mem_id', $result), $metadata);
             $updateemail = array('mae_use_datetime' => cdate('Y-m-d H:i:s'), 'mae_expired' => 1);
             $this->Member_auth_email_model->update(element('mae_id', $result), $updateemail);
             $view['view']['success_message'] = '회원님의 패스워드가 변경되었습니다.<br />감사합니다';
             $this->member->update_login_log(element('mem_id', $result), 1, '패스워드 변경 후 로그인 성공');
             $this->session->set_userdata('mem_id', element('mem_id', $result));
         }
     }
     $password_description = '비밀번호는 ' . $password_length . '자리 이상이어야 ';
     if ($this->cbconfig->item('password_uppercase_length') or $this->cbconfig->item('password_numbers_length') or $this->cbconfig->item('password_specialchars_length')) {
         $password_description .= '하며 ';
         if ($this->cbconfig->item('password_uppercase_length')) {
             $password_description .= ', ' . $this->cbconfig->item('password_uppercase_length') . '개의 대문자';
         }
         if ($this->cbconfig->item('password_numbers_length')) {
             $password_description .= ', ' . $this->cbconfig->item('password_numbers_length') . '개의 숫자';
         }
         if ($this->cbconfig->item('password_specialchars_length')) {
             $password_description .= ', ' . $this->cbconfig->item('password_specialchars_length') . '개의 특수문자';
         }
         $password_description .= '를 포함해야 ';
     }
     $password_description .= '합니다';
     $view['view']['info'] = $password_description;
     // 이벤트가 존재하면 실행합니다
     $view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
     /**
      * 레이아웃을 정의합니다
      */
     $page_title = '패스워드 변경';
     $layoutconfig = array('path' => 'findaccount', 'layout' => 'layout', 'skin' => 'findaccount_change_pw', 'layout_dir' => $this->cbconfig->item('layout_findaccount'), 'mobile_layout_dir' => $this->cbconfig->item('mobile_layout_findaccount'), 'use_sidebar' => $this->cbconfig->item('sidebar_findaccount'), 'use_mobile_sidebar' => $this->cbconfig->item('mobile_sidebar_findaccount'), 'skin_dir' => $this->cbconfig->item('skin_findaccount'), 'mobile_skin_dir' => $this->cbconfig->item('mobile_skin_findaccount'), '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));
 }
Example #8
0
 /**
  * 게시물 삭제하기
  */
 public function delete($post_id = 0)
 {
     // 이벤트 라이브러리를 로딩합니다
     $eventname = 'event_postact_delete';
     $this->load->event($eventname);
     // 이벤트가 존재하면 실행합니다
     Events::trigger('before', $eventname);
     $post_id = (int) $post_id;
     if (empty($post_id) or $post_id < 1) {
         show_404();
     }
     if (!$this->session->userdata('post_id_' . $post_id)) {
         alert('해당 게시물에서만 접근 가능합니다');
     }
     $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');
     $is_admin = $this->member->is_admin(array('board_id' => element('brd_id', $board), 'group_id' => element('bgr_id', $board)));
     if (element('block_delete', $board) && $is_admin === false) {
         alert('이 게시판의 글은 관리자에 의해서만 삭제가 가능합니다');
         return false;
     }
     if (element('protect_post_day', $board) > 0 && $is_admin === false) {
         if (ctimestamp() - strtotime(element('post_datetime', $post)) >= element('protect_post_day', $board) * 86400) {
             alert('이 게시판은 ' . element('protect_post_day', $board) . '일 이상된 게시글의 삭제를 금지합니다');
             return false;
         }
     }
     if (element('protect_comment_num', $board) > 0 && $is_admin === false) {
         if (element('protect_comment_num', $board) <= element('post_comment_count', $post)) {
             alert(element('protect_comment_num', $board) . '개 이상의 댓글이 달린 게시글은 삭제할 수 없습니다');
             return false;
         }
     }
     // 이벤트가 존재하면 실행합니다
     Events::trigger('step1', $eventname);
     if (element('mem_id', $post)) {
         if ($is_admin === false and $mem_id !== (int) element('mem_id', $post)) {
             alert('회원님은 이 글을 삭제할 권한이 없습니다');
             return false;
         }
     } else {
         $view = array();
         $view['view'] = array();
         // 이벤트가 존재하면 실행합니다
         $view['view']['event']['step2'] = Events::trigger('step2', $eventname);
         if ($is_admin !== false) {
             $this->session->set_userdata('can_delete_' . element('post_id', $post), '1');
         }
         if (!$this->session->userdata('can_delete_' . 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('can_delete_' . element('post_id', $post), '1');
                 redirect(current_url());
             } else {
                 $view['view']['message'] = '패스워드가 잘못 입력되었습니다';
             }
         }
         if (!$this->session->userdata('can_delete_' . element('post_id', $post))) {
             // 이벤트가 존재하면 실행합니다
             $view['view']['event']['before_layout'] = Events::trigger('before_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;
         }
     }
     // 이벤트가 존재하면 실행합니다
     Events::trigger('step3', $eventname);
     if (element('use_post_delete_log', $board)) {
         $updata = array('post_del' => 1);
         $this->Post_model->update(element('post_id', $post), $updata);
         $metadata = array('delete_mem_id' => $mem_id, 'delete_mem_nickname' => $this->member->item('mem_nickname'), 'delete_datetime' => cdate('Y-m-d H:i:s'), 'delete_ip' => $this->input->ip_address());
         $this->load->model('Post_meta_model');
         $this->Post_meta_model->save(element('post_id', $post), element('brd_id', $board), $metadata);
     } else {
         $this->board->delete_post($post_id);
     }
     // 이벤트가 존재하면 실행합니다
     Events::trigger('after', $eventname);
     redirect(board_url(element('brd_key', $board)));
 }
Example #9
0
 /**
  * 댓글 작성시 업데이트하는 함수입니다
  */
 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>&nbsp;</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));
         }
     }
 }
Example #10
0
 /**
  * 알림 페이지 입니다
  */
 public function index()
 {
     // 이벤트 라이브러리를 로딩합니다
     $eventname = 'event_notification_index';
     $this->load->event($eventname);
     /**
      * 로그인이 필요한 페이지입니다
      */
     required_user_login();
     $mem_id = (int) $this->member->item('mem_id');
     $view = array();
     $view['view'] = array();
     // 이벤트가 존재하면 실행합니다
     $view['view']['event']['before'] = Events::trigger('before', $eventname);
     // 2개월 이상된 알림은 하루에 한번씩 체크해서 삭제합니다.
     $cachename = 'delete_old_notifications_cache';
     $cachetime = 86400;
     if (!($result = $this->cache->get($cachename))) {
         $sdate = cdate('Y-m-d H:i:s', ctimestamp() - 24 * 60 * 60 * 60);
         $where = array('not_datetime <=' => $sdate);
         $this->Notification_model->delete_where($where);
         $this->cache->save($cachename, cdate('Y-m-d H:i:s'), $cachetime);
     }
     /**
      * 페이지에 숫자가 아닌 문자가 입력되거나 1보다 작은 숫자가 입력되면 에러 페이지를 보여줍니다.
      */
     $param =& $this->querystring;
     $page = (int) $this->input->get('page') > 0 ? (int) $this->input->get('page') : 1;
     $per_page = $this->cbconfig->item('list_count') ? (int) $this->cbconfig->item('list_count') : 20;
     $offset = ($page - 1) * $per_page;
     /**
      * 게시판 목록에 필요한 정보를 가져옵니다.
      */
     $read = $this->input->get('read', null, '');
     $result = $this->Notification_model->get_notification_list($per_page, $offset, $mem_id, $read);
     $list_num = $result['total_rows'] - ($page - 1) * $per_page;
     if (element('list', $result)) {
         foreach (element('list', $result) as $key => $val) {
             $result['list'][$key]['num'] = $list_num--;
             $result['list'][$key]['delete_url'] = site_url('notification/delete/' . element('not_id', $val) . '?' . $param->output());
             $result['list'][$key]['read_url'] = site_url('notification/read/' . element('not_id', $val) . '?' . $param->output());
             $result['list'][$key]['onClick'] = '';
             if (element('not_type', $val) === 'note') {
                 $result['list'][$key]['read_url'] = 'javascript:;';
                 $result['list'][$key]['onClick'] = 'note_list(' . element('not_content_id', $val) . ');';
             }
         }
     }
     $view['view']['data'] = $result;
     $view['view']['list_delete_url'] = site_url('notification/listdelete?' . $param->output());
     $view['view']['list_update_url'] = site_url('notification/listupdate?' . $param->output());
     /**
      * 페이지네이션을 생성합니다
      */
     $config['base_url'] = site_url('notification') . '?' . $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'] = site_url('notification');
     // 이벤트가 존재하면 실행합니다
     $view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
     /**
      * 레이아웃을 정의합니다
      */
     $page_title = $this->cbconfig->item('site_meta_title_notification');
     $meta_description = $this->cbconfig->item('site_meta_description_notification');
     $meta_keywords = $this->cbconfig->item('site_meta_keywords_notification');
     $meta_author = $this->cbconfig->item('site_meta_author_notification');
     $page_name = $this->cbconfig->item('site_page_name_notification');
     $layoutconfig = array('path' => 'notification', 'layout' => 'layout', 'skin' => 'notification', 'layout_dir' => $this->cbconfig->item('layout_notification'), 'mobile_layout_dir' => $this->cbconfig->item('mobile_layout_notification'), 'use_sidebar' => $this->cbconfig->item('sidebar_notification'), 'use_mobile_sidebar' => $this->cbconfig->item('mobile_sidebar_notification'), 'skin_dir' => $this->cbconfig->item('skin_notification'), 'mobile_skin_dir' => $this->cbconfig->item('mobile_skin_notification'), '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));
 }
Example #11
0
 /**
  * 목록을 가져오는 메소드입니다
  */
 public function index()
 {
     // 이벤트 라이브러리를 로딩합니다
     $eventname = 'event_admin_stat_currentvisitor_index';
     $this->load->event($eventname);
     $view = array();
     $view['view'] = array();
     // 이벤트가 존재하면 실행합니다
     $view['view']['event']['before'] = Events::trigger('before', $eventname);
     /**
      * 페이지에 숫자가 아닌 문자가 입력되거나 1보다 작은 숫자가 입력되면 에러 페이지를 보여줍니다.
      */
     $param =& $this->querystring;
     $page = (int) $this->input->get('page') > 0 ? (int) $this->input->get('page') : 1;
     $view['view']['sort'] = array('cur_ip' => $param->sort('cur_ip', 'asc'), 'cur_datetime' => $param->sort('cur_datetime', 'asc'), 'cur_page' => $param->sort('cur_page', 'asc'), 'cur_url' => $param->sort('cur_url', 'asc'), 'cur_referer' => $param->sort('cur_referer', 'asc'));
     $findex = $this->input->get('findex', null, 'cur_datetime');
     $forder = $this->input->get('forder', null, 'desc');
     $sfield = $this->input->get('sfield', null, '');
     $skeyword = $this->input->get('skeyword', null, '');
     $per_page = 100;
     $offset = ($page - 1) * $per_page;
     $minute = (int) $this->cbconfig->item('currentvisitor_minute');
     if ($minute < 1) {
         $minute = 10;
     }
     $curdatetime = cdate('Y-m-d H:i:s', ctimestamp() - $minute * 60);
     $cachename = 'delete_old_currentvisitor_cache';
     $cachetime = 60;
     if (!($result = $this->cache->get($cachename))) {
         $deletewhere = array('cur_datetime < ' => $curdatetime);
         $this->Currentvisitor_model->delete_where($deletewhere);
         $this->cache->save($cachename, cdate('Y-m-d H:i:s'), $cachetime);
     }
     /**
      * 게시판 목록에 필요한 정보를 가져옵니다.
      */
     $this->{$this->modelname}->allow_search_field = array('cur_ip', 'cur_mem_name', 'cur_datetime', 'cur_page', 'cur_url', 'cur_referer', 'cur_useragent', 'currentvisitor.mem_id');
     // 검색이 가능한 필드
     $this->{$this->modelname}->search_field_equal = array('currentvisitor.mem_id');
     // 검색중 like 가 아닌 = 검색을 하는 필드
     $this->{$this->modelname}->allow_order_field = array('cur_ip', 'cur_datetime', 'cur_page', 'cur_url', 'cur_referer');
     // 정렬이 가능한 필드
     $where = array('cur_datetime >' => $curdatetime);
     $result = $this->{$this->modelname}->get_admin_list($per_page, $offset, $where, '', $findex, $forder, $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]['display_name'] = display_username(element('mem_userid', $val), element('mem_nickname', $val), element('mem_icon', $val));
             if (element('cur_useragent', $val)) {
                 $userAgent = get_useragent_info(element('cur_useragent', $val));
                 $result['list'][$key]['browsername'] = $userAgent['browsername'];
                 $result['list'][$key]['browserversion'] = $userAgent['browserversion'];
                 $result['list'][$key]['os'] = $userAgent['os'];
                 $result['list'][$key]['engine'] = $userAgent['engine'];
             }
             $result['list'][$key]['num'] = $list_num--;
         }
     }
     $view['view']['data'] = $result;
     /**
      * primary key 정보를 저장합니다
      */
     $view['view']['primary_key'] = $this->{$this->modelname}->primary_key;
     /**
      * 페이지네이션을 생성합니다
      */
     $config['base_url'] = admin_url($this->pagedir) . '?' . $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;
     /**
      * 쓰기 주소, 삭제 주소등 필요한 주소를 구합니다
      */
     $search_option = array('cur_ip' => '아이피', 'cur_datetime' => '날짜', 'cur_page' => '페이지이름', 'cur_url' => '현재주소', 'cur_referer' => '이전주소', 'cur_useragent' => '운영체제/브라우저');
     $view['view']['skeyword'] = $sfield && array_key_exists($sfield, $search_option) ? $skeyword : '';
     $view['view']['search_option'] = search_option($search_option, $sfield);
     $view['view']['listall_url'] = admin_url($this->pagedir);
     // 이벤트가 존재하면 실행합니다
     $view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
     /**
      * 어드민 레이아웃을 정의합니다
      */
     $layoutconfig = array('layout' => 'layout', 'skin' => 'index');
     $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));
 }
Example #12
0
 /**
  * 회원정보 수정 페이지입니다
  */
 public function modify()
 {
     // 이벤트 라이브러리를 로딩합니다
     $eventname = 'event_membermodify_modify';
     $this->load->event($eventname);
     if (!$this->session->userdata('membermodify')) {
         redirect('membermodify');
     }
     /**
      * 로그인이 필요한 페이지입니다
      */
     required_user_login();
     $mem_id = (int) $this->member->item('mem_id');
     if (!function_exists('password_hash')) {
         $this->load->helper('password');
     }
     $view = array();
     $view['view'] = array();
     // 이벤트가 존재하면 실행합니다
     $view['view']['event']['before'] = Events::trigger('before', $eventname);
     $email_description = '';
     if ($this->cbconfig->item('use_register_email_auth')) {
         $email_description = '이메일을 변경하시면 메일 인증 후에 계속 사용이 가능합니다';
     }
     $configbasic = array();
     $can_update_nickname = false;
     $change_nickname_date = $this->cbconfig->item('change_nickname_date');
     if (empty($change_nickname_date)) {
         $can_update_nickname = true;
     } elseif (strtotime($this->member->item('meta_nickname_datetime')) < ctimestamp() - $change_nickname_date * 86400) {
         $can_update_nickname = true;
     }
     $when_can_update_nickname = cdate('Y-m-d H:s', strtotime($this->member->item('meta_nickname_datetime')) + $change_nickname_date * 86400);
     $can_update_open_profile = false;
     $change_open_profile_date = $this->cbconfig->item('change_open_profile_date');
     if (empty($change_open_profile_date)) {
         $can_update_open_profile = true;
     } elseif (strtotime($this->member->item('meta_open_profile_datetime')) < ctimestamp() - $change_open_profile_date * 86400) {
         $can_update_open_profile = true;
     }
     $view['view']['can_update_open_profile'] = $can_update_open_profile;
     $when_can_update_open_profile = cdate('Y-m-d H:s', strtotime($this->member->item('meta_open_profile_datetime')) + $change_open_profile_date * 86400);
     $can_update_use_note = false;
     $change_use_note_date = $this->cbconfig->item('change_use_note_date');
     if (empty($change_use_note_date)) {
         $can_update_use_note = true;
     } elseif (strtotime($this->member->item('meta_use_note_datetime')) < ctimestamp() - $change_use_note_date * 86400) {
         $can_update_use_note = true;
     }
     $view['view']['can_update_use_note'] = $can_update_use_note;
     $when_can_update_use_note = cdate('Y-m-d H:s', strtotime($this->member->item('meta_use_note_datetime')) + $change_use_note_date * 86400);
     $nickname_description = '';
     if ($this->cbconfig->item('change_nickname_date')) {
         if ($can_update_nickname === false) {
             $nickname_description = '<br />닉네임을 변경하시면 ' . $this->cbconfig->item('change_nickname_date') . '일 이내에는 변경할 수 없습니다<br>회원님은 ' . $when_can_update_nickname . ' 이후에 닉네임 변경이 가능합니다';
         } else {
             $nickname_description = '<br />닉네임을 변경하시면 ' . $this->cbconfig->item('change_nickname_date') . '일 이내에는 변경할 수 없습니다';
         }
     }
     $configbasic['mem_username'] = array('field' => 'mem_username', 'label' => '이름', 'rules' => 'trim|min_length[2]|max_length[20]');
     $configbasic['mem_nickname'] = array('field' => 'mem_nickname', 'label' => '닉네임', 'rules' => 'trim|required|min_length[2]|max_length[20]|callback__mem_nickname_check', 'description' => '공백없이 한글, 영문, 숫자만 입력 가능 2글자 이상' . $nickname_description);
     $configbasic['mem_email'] = array('field' => 'mem_email', 'label' => '이메일', 'rules' => 'trim|required|valid_email|max_length[50]|is_unique[member.mem_email.mem_id.' . $mem_id . ']|callback__mem_email_check', 'description' => $email_description);
     $configbasic['mem_homepage'] = array('field' => 'mem_homepage', 'label' => '홈페이지', 'rules' => 'prep_url|valid_url');
     $configbasic['mem_phone'] = array('field' => 'mem_phone', 'label' => '전화번호', 'rules' => 'trim|valid_phone');
     $configbasic['mem_birthday'] = array('field' => 'mem_birthday', 'label' => '생년월일', 'rules' => 'trim|exact_length[10]');
     $configbasic['mem_sex'] = array('field' => 'mem_sex', 'label' => '성별', 'rules' => 'trim|exact_length[1]');
     $configbasic['mem_zipcode'] = array('field' => 'mem_zipcode', 'label' => '우편번호', 'rules' => 'trim|exact_length[7]');
     $configbasic['mem_address1'] = array('field' => 'mem_address1', 'label' => '기본주소', 'rules' => 'trim');
     $configbasic['mem_address2'] = array('field' => 'mem_address2', 'label' => '상세주소', 'rules' => 'trim');
     $configbasic['mem_address3'] = array('field' => 'mem_address3', 'label' => '참고항목', 'rules' => 'trim');
     $configbasic['mem_address4'] = array('field' => 'mem_address4', 'label' => '지번', 'rules' => 'trim');
     $configbasic['mem_profile_content'] = array('field' => 'mem_profile_content', 'label' => '자기소개', 'rules' => 'trim');
     $configbasic['mem_open_profile'] = array('field' => 'mem_open_profile', 'label' => '정보공개', 'rules' => 'trim|exact_length[1]');
     if ($this->cbconfig->item('use_note')) {
         $configbasic['mem_use_note'] = array('field' => 'mem_use_note', 'label' => '쪽지사용', 'rules' => 'trim|exact_length[1]');
     }
     $configbasic['mem_receive_email'] = array('field' => 'mem_receive_email', 'label' => '이메일수신여부', 'rules' => 'trim|exact_length[1]');
     $configbasic['mem_receive_sms'] = array('field' => 'mem_receive_sms', 'label' => 'SMS 문자수신여부', 'rules' => 'trim|exact_length[1]');
     $this->load->library(array('form_validation'));
     $login_fail = false;
     $valid_fail = false;
     $registerform = $this->cbconfig->item('registerform');
     $form = json_decode($registerform, true);
     $config = array();
     if ($form && is_array($form)) {
         foreach ($form as $key => $value) {
             if (!element('use', $value)) {
                 continue;
             }
             if ($key === 'mem_userid' or $key === 'mem_password' or $key === 'mem_recommend') {
                 continue;
             }
             if (element('func', $value) === 'basic') {
                 if ($key === 'mem_address') {
                     if (element('required', $value) === '1') {
                         $configbasic['mem_zipcode']['rules'] = $configbasic['mem_zipcode']['rules'] . '|required';
                     }
                     $config[] = $configbasic['mem_zipcode'];
                     if (element('required', $value) === '1') {
                         $configbasic['mem_address1']['rules'] = $configbasic['mem_address1']['rules'] . '|required';
                     }
                     $config[] = $configbasic['mem_address1'];
                     if (element('required', $value) === '1') {
                         $configbasic['mem_address2']['rules'] = $configbasic['mem_address2']['rules'] . '|required';
                     }
                     $config[] = $configbasic['mem_address2'];
                 } else {
                     if (element('required', $value) === '1') {
                         $configbasic[$value['field_name']]['rules'] = $configbasic[$value['field_name']]['rules'] . '|required';
                     }
                     if (element('field_type', $value) === 'phone') {
                         $configbasic[$value['field_name']]['rules'] = $configbasic[$value['field_name']]['rules'] . '|valid_phone';
                     }
                     $config[] = $configbasic[$value['field_name']];
                 }
             } else {
                 $required = element('required', $value) ? '|required' : '';
                 if (element('field_type', $value) === 'checkbox') {
                     $config[] = array('field' => element('field_name', $value) . '[]', 'label' => $value['display_name'], 'rules' => 'trim' . $required);
                 } else {
                     $config[] = array('field' => element('field_name', $value), 'label' => $value['display_name'], 'rules' => 'trim' . $required);
                 }
             }
         }
     }
     $this->form_validation->set_rules($config);
     $form_validation = $this->form_validation->run();
     $file_error = '';
     $updatephoto = '';
     $file_error2 = '';
     $updateicon = '';
     if ($form_validation) {
         $this->load->library('upload');
         if ($this->cbconfig->item('use_member_photo') && $this->cbconfig->item('member_photo_width') > 0 && $this->cbconfig->item('member_photo_height') > 0) {
             if (isset($_FILES) && isset($_FILES['mem_photo']) && isset($_FILES['mem_photo']['name']) && $_FILES['mem_photo']['name']) {
                 $upload_path = './uploads/member_photo/';
                 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);
                 }
                 $uploadconfig = '';
                 $uploadconfig['upload_path'] = $upload_path;
                 $uploadconfig['allowed_types'] = 'jpg|jpeg|png|gif';
                 $uploadconfig['max_size'] = '2000';
                 $uploadconfig['max_width'] = '1000';
                 $uploadconfig['max_height'] = '1000';
                 $uploadconfig['encrypt_name'] = true;
                 $this->upload->initialize($uploadconfig);
                 if ($this->upload->do_upload('mem_photo')) {
                     $img = $this->upload->data();
                     $updatephoto = cdate('Y') . '/' . cdate('m') . '/' . $img['file_name'];
                 } else {
                     $file_error = $this->upload->display_errors();
                 }
             }
         }
         if ($this->cbconfig->item('use_member_icon') && $this->cbconfig->item('member_icon_width') > 0 && $this->cbconfig->item('member_icon_height') > 0) {
             if (isset($_FILES) && isset($_FILES['mem_icon']) && isset($_FILES['mem_icon']['name']) && $_FILES['mem_icon']['name']) {
                 $upload_path = './uploads/member_icon/';
                 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);
                 }
                 $uploadconfig = '';
                 $uploadconfig['upload_path'] = $upload_path;
                 $uploadconfig['allowed_types'] = 'jpg|jpeg|png|gif';
                 $uploadconfig['max_size'] = '2000';
                 $uploadconfig['max_width'] = '1000';
                 $uploadconfig['max_height'] = '1000';
                 $uploadconfig['encrypt_name'] = true;
                 $this->upload->initialize($uploadconfig);
                 if ($this->upload->do_upload('mem_icon')) {
                     $img = $this->upload->data();
                     $updateicon = cdate('Y') . '/' . cdate('m') . '/' . $img['file_name'];
                 } else {
                     $file_error2 = $this->upload->display_errors();
                 }
             }
         }
     }
     /**
      * 유효성 검사를 하지 않는 경우, 또는 유효성 검사에 실패한 경우입니다.
      * 즉 글쓰기나 수정 페이지를 보고 있는 경우입니다
      */
     if ($form_validation === false or $file_error !== '' or $file_error2 !== '') {
         // 이벤트가 존재하면 실행합니다
         $view['view']['event']['formrunfalse'] = Events::trigger('formrunfalse', $eventname);
         $view['view']['message'] = $file_error . $file_error2;
         $html_content = '';
         $k = 0;
         if ($form && is_array($form)) {
             foreach ($form as $key => $value) {
                 if (!element('use', $value)) {
                     continue;
                 }
                 if ($key === 'mem_userid' or $key === 'mem_password' or $key === 'mem_recommend') {
                     continue;
                 }
                 $required = element('required', $value) ? 'required' : '';
                 $item = $this->member->item(element('field_name', $value));
                 $html_content[$k]['field_name'] = element('field_name', $value);
                 $html_content[$k]['display_name'] = element('display_name', $value);
                 $html_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') {
                         $html_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), $item) . '" readonly="readonly" ' . $required . ' />';
                     } elseif (element('field_type', $value) === 'phone') {
                         $html_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), $item) . '" ' . $required . ' />';
                     } else {
                         $readonly = '';
                         if (element('field_name', $value) === 'mem_nickname' && $can_update_nickname === false) {
                             $readonly = 'readonly="readonly"';
                         }
                         $html_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), $item) . '" ' . $readonly . ' ' . $required . ' />';
                     }
                 } elseif (element('field_type', $value) === 'textarea') {
                     $html_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), $item) . '</textarea>';
                 } elseif (element('field_type', $value) === 'radio') {
                     $html_content[$k]['input'] .= '<div class="checkbox">';
                     if (element('field_name', $value) === 'mem_sex') {
                         $options = array('1' => '남성', '2' => '여성');
                     } else {
                         $options = explode("\n", element('options', $value));
                     }
                     $i = 1;
                     if ($options) {
                         foreach ($options as $okey => $oval) {
                             $oval = trim($oval);
                             $radiovalue = element('field_name', $value) === 'mem_sex' ? $okey : $oval;
                             $html_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, $item === $radiovalue ? true : false) . ' /> ' . $oval . ' </label> ';
                             $i++;
                         }
                     }
                     $html_content[$k]['input'] .= '</div>';
                 } elseif (element('field_type', $value) === 'checkbox') {
                     $html_content[$k]['input'] .= '<div class="checkbox">';
                     $options = explode("\n", element('options', $value));
                     $item = json_decode($item, true);
                     $i = 1;
                     if ($options) {
                         foreach ($options as $okey => $oval) {
                             $oval = trim($oval);
                             $chkvalue = is_array($item) && in_array($oval, $item) ? $oval : '';
                             $html_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, $chkvalue === $oval ? true : false) . ' /> ' . $oval . ' </label> ';
                             $i++;
                         }
                     }
                     $html_content[$k]['input'] .= '</div>';
                 } elseif (element('field_type', $value) === 'select') {
                     $html_content[$k]['input'] .= '<div class="input-group">';
                     $html_content[$k]['input'] .= '<select name="' . element('field_name', $value) . '" class="form-control input" ' . $required . '>';
                     $html_content[$k]['input'] .= '<option value="" >선택하세요</option> ';
                     $options = explode("\n", element('options', $value));
                     if ($options) {
                         foreach ($options as $okey => $oval) {
                             $oval = trim($oval);
                             $html_content[$k]['input'] .= '<option value="' . $oval . '" ' . set_select(element('field_name', $value), $oval, $item === $oval ? true : false) . ' >' . $oval . '</option> ';
                         }
                     }
                     $html_content[$k]['input'] .= '</select>';
                     $html_content[$k]['input'] .= '</div>';
                 } elseif (element('field_name', $value) === 'mem_address') {
                     $html_content[$k]['input'] .= '
                         <label for="mem_zipcode">우편번호</label>
                         <label>
                             <input type="text" name="mem_zipcode" value="' . set_value('mem_zipcode', $this->member->item('mem_zipcode')) . '" id="mem_zipcode" class="form-control input" size="7" maxlength="7" ' . $required . ' />
                         </label>
                         <label>
                             <button type="button" class="btn btn-black btn-sm" style="margin-top:0px;" onclick="win_zip(\'fregisterform\', \'mem_zipcode\', \'mem_address1\', \'mem_address2\', \'mem_address3\', \'mem_address4\');">주소 검색</button>
                         </label>
                         <div class="addr-line mt10">
                             <label for="mem_address1">기본주소</label>
                             <input type="text" name="mem_address1" value="' . set_value('mem_address1', $this->member->item('mem_address1')) . '" id="mem_address1" class="form-control input" placeholder="기본주소" ' . $required . ' />
                         </div>
                         <div class="addr-line mt10 ">
                             <label for="mem_address2">상세주소</label>
                             <input type="text" name="mem_address2" value="' . set_value('mem_address2', $this->member->item('mem_address2')) . '" id="mem_address2" class="form-control input" placeholder="상세주소" ' . $required . ' />
                         </div>
                         <div class="addr-line mt10 ">
                             <label for="mem_address3">참고항목</label>
                             <input type="text" name="mem_address3" value="' . set_value('mem_address3', $this->member->item('mem_address3')) . '" id="mem_address3" class="form-control input" readonly="readonly" placeholder="참고항목" />
                         </div>
                         <input type="hidden" name="mem_address4" value="' . set_value('mem_address4', $this->member->item('mem_address4')) . '" />
                     ';
                 }
                 $html_content[$k]['description'] = '';
                 if (isset($configbasic[$value['field_name']]['description']) && $configbasic[$value['field_name']]['description']) {
                     $html_content[$k]['description'] = $configbasic[$value['field_name']]['description'];
                 }
                 $k++;
             }
         }
         $view['view']['html_content'] = $html_content;
         $view['view']['open_profile_description'] = '';
         if ($this->cbconfig->item('change_open_profile_date')) {
             if ($can_update_open_profile === false) {
                 $view['view']['open_profile_description'] = '정보공개 설정을 변경하시면 ' . $this->cbconfig->item('change_open_profile_date') . '일 이내에는 다시 변경할 수 없습니다<br>회원님은 ' . $when_can_update_open_profile . ' 이후에 정보공개설정변경이 가능합니다';
             } else {
                 $view['view']['open_profile_description'] = '정보공개 설정을 변경하시면 ' . $this->cbconfig->item('change_open_profile_date') . '일 이내에는 다시 변경할 수 없습니다';
             }
         }
         $view['view']['use_note_description'] = '';
         if ($this->cbconfig->item('change_use_note_date')) {
             if ($can_update_use_note === false) {
                 $view['view']['use_note_description'] = '쪽지 사용 설정을 변경하시면 ' . $this->cbconfig->item('change_use_note_date') . '일 이내에는 다시 변경할 수 없습니다<br>회원님은 ' . $when_can_update_use_note . ' 이후에 쪽지사용설정변경이 가능합니다';
             } else {
                 $view['view']['use_note_description'] = '쪽지 사용 설정을 변경하시면 ' . $this->cbconfig->item('change_use_note_date') . '일 이내에는 다시 변경할 수 없습니다';
             }
         }
         $view['view']['canonical'] = site_url('membermodify/modify');
         // 이벤트가 존재하면 실행합니다
         $view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
         /**
          * 레이아웃을 정의합니다
          */
         $page_title = $this->cbconfig->item('site_meta_title_membermodify');
         $meta_description = $this->cbconfig->item('site_meta_description_membermodify');
         $meta_keywords = $this->cbconfig->item('site_meta_keywords_membermodify');
         $meta_author = $this->cbconfig->item('site_meta_author_membermodify');
         $page_name = $this->cbconfig->item('site_page_name_membermodify');
         $layoutconfig = array('path' => 'mypage', 'layout' => 'layout', 'skin' => 'member_modify', 'layout_dir' => $this->cbconfig->item('layout_mypage'), 'mobile_layout_dir' => $this->cbconfig->item('mobile_layout_mypage'), 'use_sidebar' => $this->cbconfig->item('sidebar_mypage'), 'use_mobile_sidebar' => $this->cbconfig->item('mobile_sidebar_mypage'), 'skin_dir' => $this->cbconfig->item('skin_mypage'), 'mobile_skin_dir' => $this->cbconfig->item('mobile_skin_mypage'), '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);
         $updatedata = array();
         $metadata = array();
         $updatedata['mem_email'] = $this->input->post('mem_email');
         if ($this->member->item('mem_email') !== $this->input->post('mem_email')) {
             $updatedata['mem_email_cert'] = 0;
             $metadata['meta_email_cert_datetime'] = '';
         }
         if ($can_update_nickname && $this->member->item('mem_nickname') !== $this->input->post('mem_nickname')) {
             $updatedata['mem_nickname'] = $this->input->post('mem_nickname');
             $metadata['meta_nickname_datetime'] = cdate('Y-m-d H:i:s');
             $upnick = array('mni_end_datetime' => cdate('Y-m-d H:i:s'));
             $nickwhere = array('mem_id' => $mem_id, 'mni_nickname' => $this->member->item('mem_nickname'));
             $this->Member_nickname_model->update('', $upnick, $nickwhere);
             $nickinsert = array('mem_id' => $mem_id, 'mni_nickname' => $this->input->post('mem_nickname'), 'mni_start_datetime' => cdate('Y-m-d H:i:s'));
             $this->Member_nickname_model->insert($nickinsert);
         }
         if (isset($form['mem_username']['use']) && $form['mem_username']['use']) {
             $updatedata['mem_username'] = $this->input->post('mem_username', null, '');
         }
         if (isset($form['mem_homepage']['use']) && $form['mem_homepage']['use']) {
             $updatedata['mem_homepage'] = $this->input->post('mem_homepage', null, '');
         }
         if (isset($form['mem_phone']['use']) && $form['mem_phone']['use']) {
             $updatedata['mem_phone'] = $this->input->post('mem_phone', null, '');
         }
         if (isset($form['mem_birthday']['use']) && $form['mem_birthday']['use']) {
             $updatedata['mem_birthday'] = $this->input->post('mem_birthday', null, '');
         }
         if (isset($form['mem_sex']['use']) && $form['mem_sex']['use']) {
             $updatedata['mem_sex'] = $this->input->post('mem_sex', null, '');
         }
         if (isset($form['mem_address']['use']) && $form['mem_address']['use']) {
             $updatedata['mem_zipcode'] = $this->input->post('mem_zipcode', null, '');
             $updatedata['mem_address1'] = $this->input->post('mem_address1', null, '');
             $updatedata['mem_address2'] = $this->input->post('mem_address2', null, '');
             $updatedata['mem_address3'] = $this->input->post('mem_address3', null, '');
             $updatedata['mem_address4'] = $this->input->post('mem_address4', null, '');
         }
         $updatedata['mem_receive_email'] = $this->input->post('mem_receive_email') ? 1 : 0;
         if ($this->cbconfig->item('use_note') && $can_update_use_note && ($this->member->item('mem_use_note') === '1' && $this->input->post('mem_use_note') !== '1' or $this->member->item('mem_use_note') !== '1' && $this->input->post('mem_use_note') === '1')) {
             $updatedata['mem_use_note'] = $this->input->post('mem_use_note') ? 1 : 0;
             $metadata['meta_use_note_datetime'] = cdate('Y-m-d H:i:s');
         }
         $updatedata['mem_receive_sms'] = $this->input->post('mem_receive_sms') ? 1 : 0;
         if ($can_update_open_profile && ($this->member->item('mem_open_profile') === '1' && $this->input->post('mem_open_profile') !== '1' or $this->member->item('mem_open_profile') !== '1' && $this->input->post('mem_open_profile') === '1')) {
             $updatedata['mem_open_profile'] = $this->input->post('mem_open_profile') ? 1 : 0;
             $metadata['meta_open_profile_datetime'] = cdate('Y-m-d H:i:s');
         }
         if (isset($form['mem_profile_content']['use']) && $form['mem_profile_content']['use']) {
             $updatedata['mem_profile_content'] = $this->input->post('mem_profile_content', null, '');
         }
         if ($this->input->post('mem_photo_del')) {
             $updatedata['mem_photo'] = '';
         } elseif ($updatephoto) {
             $updatedata['mem_photo'] = $updatephoto;
         }
         if ($this->member->item('mem_photo') && ($this->input->post('mem_photo_del') or $updatephoto)) {
             // 기존 파일 삭제
             @unlink('./uploads/member_photo/' . $this->member->item('mem_photo'));
         }
         if ($this->input->post('mem_icon_del')) {
             $updatedata['mem_icon'] = '';
         } elseif ($updateicon) {
             $updatedata['mem_icon'] = $updateicon;
         }
         if ($this->member->item('mem_icon') && ($this->input->post('mem_icon_del') or $updateicon)) {
             // 기존 파일 삭제
             @unlink('./uploads/member_icon/' . $this->member->item('mem_icon'));
         }
         $this->Member_model->update($mem_id, $updatedata);
         $this->Member_meta_model->save($mem_id, $metadata);
         $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->Member_extra_vars_model->save($mem_id, $extradata);
         }
         if ($this->cbconfig->item('use_register_email_auth') && $this->member->item('mem_email') !== $this->input->post('mem_email')) {
             $vericode = array('$', '/', '.');
             $verificationcode = str_replace($vericode, '', password_hash($mem_id . '-' . $this->input->post('mem_email') . '-' . random_string('alnum', 10), PASSWORD_BCRYPT));
             $beforeauthdata = array('mem_id' => $mem_id, 'mae_type' => 2);
             $this->Member_auth_email_model->delete_where($beforeauthdata);
             $authdata = array('mem_id' => $mem_id, 'mae_key' => $verificationcode, 'mae_type' => 2, 'mae_generate_datetime' => cdate('Y-m-d H:i:s'));
             $this->Member_auth_email_model->insert($authdata);
             $verify_url = site_url('verify/confirmemail?user='******'mem_userid') . '&code=' . $verificationcode);
             $searchconfig = array('{홈페이지명}', '{회사명}', '{홈페이지주소}', '{회원아이디}', '{회원닉네임}', '{회원실명}', '{회원이메일}', '{변경전이메일}', '{메일수신여부}', '{쪽지수신여부}', '{문자수신여부}', '{회원아이피}', '{메일인증주소}');
             $receive_email = $this->member->item('mem_receive_email') ? '동의' : '거부';
             $receive_note = $this->member->item('mem_use_note') ? '동의' : '거부';
             $receive_sms = $this->member->item('mem_receive_sms') ? '동의' : '거부';
             $replaceconfig = array($this->cbconfig->item('site_title'), $this->cbconfig->item('company_name'), site_url(), $this->member->item('mem_userid'), $this->member->item('mem_nickname'), $this->member->item('mem_username'), $this->input->post('mem_email'), $this->member->item('mem_email'), $receive_email, $receive_note, $receive_sms, $this->input->ip_address(), $verify_url);
             $replaceconfig_escape = array(html_escape($this->cbconfig->item('site_title')), html_escape($this->cbconfig->item('company_name')), site_url(), $this->member->item('mem_userid'), html_escape($this->member->item('mem_nickname')), html_escape($this->member->item('mem_username')), html_escape($this->input->post('mem_email')), html_escape($this->member->item('mem_email')), $receive_email, $receive_note, $receive_sms, $this->input->ip_address(), $verify_url);
             $title = str_replace($searchconfig, $replaceconfig, $this->cbconfig->item('send_email_changeemail_user_title'));
             $content = str_replace($searchconfig, $replaceconfig_escape, $this->cbconfig->item('send_email_changeemail_user_content'));
             $this->email->clear(true);
             $this->email->from($this->cbconfig->item('webmaster_email'), $this->cbconfig->item('webmaster_name'));
             $this->email->to($this->input->post('mem_email'));
             $this->email->subject($title);
             $this->email->message($content);
             $this->email->send();
             $view['view']['result_message'] = $this->input->post('mem_email') . '로 인증메일이 발송되었습니다. <br />발송된 인증메일을 확인하신 후에 사이트 이용이 가능합니다';
             $this->session->sess_destroy();
         } else {
             $view['view']['result_message'] = '회원정보가 변경되었습니다. <br />감사합니다';
         }
         // 이벤트가 존재하면 실행합니다
         $view['view']['event']['before_result_layout'] = Events::trigger('before_result_layout', $eventname);
         $page_title = $this->cbconfig->item('site_meta_title_membermodify');
         $meta_description = $this->cbconfig->item('site_meta_description_membermodify');
         $meta_keywords = $this->cbconfig->item('site_meta_keywords_membermodify');
         $meta_author = $this->cbconfig->item('site_meta_author_membermodify');
         $page_name = $this->cbconfig->item('site_page_name_membermodify');
         $layoutconfig = array('path' => 'mypage', 'layout' => 'layout', 'skin' => 'member_modify_result', 'layout_dir' => $this->cbconfig->item('layout_mypage'), 'mobile_layout_dir' => $this->cbconfig->item('mobile_layout_mypage'), 'use_sidebar' => $this->cbconfig->item('sidebar_mypage'), 'use_mobile_sidebar' => $this->cbconfig->item('mobile_sidebar_mypage'), 'skin_dir' => $this->cbconfig->item('skin_mypage'), 'mobile_skin_dir' => $this->cbconfig->item('mobile_skin_mypage'), '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));
     }
 }
Example #13
0
 /**
  * 현재접속자 페이지입니다
  */
 public function index()
 {
     // 이벤트 라이브러리를 로딩합니다
     $eventname = 'event_currentvisitor_index';
     $this->load->event($eventname);
     if (!$this->cbconfig->item('open_currentvisitor') && $this->member->is_admin() === false) {
         alert('이 웹사이트는 현재접속자 기능을 사용하지 않습니다');
     }
     $view = array();
     $view['view'] = array();
     // 이벤트가 존재하면 실행합니다
     $view['view']['event']['before'] = Events::trigger('before', $eventname);
     /**
      * 페이지에 숫자가 아닌 문자가 입력되거나 1보다 작은 숫자가 입력되면 에러 페이지를 보여줍니다.
      */
     $param =& $this->querystring;
     $page = (int) $this->input->get('page') > 0 ? (int) $this->input->get('page') : 1;
     $per_page = 100;
     $offset = ($page - 1) * $per_page;
     $minute = (int) $this->cbconfig->item('currentvisitor_minute');
     if ($minute < 1) {
         $minute = 10;
     }
     $curdatetime = cdate('Y-m-d H:i:s', ctimestamp() - $minute * 60);
     $cachename = 'delete_old_currentvisitor_cache';
     $cachetime = 60;
     if (!($result = $this->cache->get($cachename))) {
         $deletewhere = array('cur_datetime < ' => $curdatetime);
         $this->Currentvisitor_model->delete_where($deletewhere);
         $this->cache->save($cachename, cdate('Y-m-d H:i:s'), $cachetime);
     }
     $result = $this->Currentvisitor_model->get_current_list($curdatetime, $per_page, $offset);
     $list_num = ($page - 1) * $per_page + 1;
     $visitor = array();
     if (element('list', $result)) {
         foreach (element('list', $result) as $key => $value) {
             $data = $value;
             if (element('mem_userid', $value)) {
                 $data['name_or_ip'] = display_username(element('mem_userid', $value), element('mem_nickname', $value), element('mem_icon', $value));
             } else {
                 $ip_display_style = $this->member->is_admin() === 'super' ? '1111' : $this->cbconfig->item('ip_display_style');
                 $data['name_or_ip'] = display_ipaddress(element('cur_ip', $value), $ip_display_style);
             }
             $data['num'] = $list_num++;
             $visitor[] = $data;
         }
     }
     $view['view']['list'] = $visitor;
     $view['view']['total_rows'] = $result['total_rows'];
     /**
      * 페이지네이션을 생성합니다
      */
     $config['base_url'] = site_url('currentvisitor') . '?' . $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'] = site_url('currentvisitor');
     // 이벤트가 존재하면 실행합니다
     $view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
     /**
      * 레이아웃을 정의합니다
      */
     $page_title = $this->cbconfig->item('site_meta_title_currentvisitor');
     $meta_description = $this->cbconfig->item('site_meta_description_currentvisitor');
     $meta_keywords = $this->cbconfig->item('site_meta_keywords_currentvisitor');
     $meta_author = $this->cbconfig->item('site_meta_author_currentvisitor');
     $page_name = $this->cbconfig->item('site_page_name_currentvisitor');
     $searchconfig = array('{현재접속자수}');
     $replaceconfig = array($result['total_rows']);
     $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);
     $layoutconfig = array('path' => 'currentvisitor', 'layout' => 'layout', 'skin' => 'currentvisitor', 'layout_dir' => $this->cbconfig->item('layout_currentvisitor'), 'mobile_layout_dir' => $this->cbconfig->item('mobile_layout_currentvisitor'), 'use_sidebar' => $this->cbconfig->item('sidebar_currentvisitor'), 'use_mobile_sidebar' => $this->cbconfig->item('mobile_sidebar_currentvisitor'), 'skin_dir' => $this->cbconfig->item('skin_currentvisitor'), 'mobile_skin_dir' => $this->cbconfig->item('mobile_skin_currentvisitor'), '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));
 }
Example #14
0
 function init()
 {
     $CI =& get_instance();
     if ($CI->uri->segment(1) === 'install') {
         return;
     }
     if (config_item('use_lock_ip') && $CI->cbconfig->item('site_ip_whitelist')) {
         $whitelist = $CI->cbconfig->item('site_ip_whitelist');
         $whitelist = preg_replace("/[\r|\n|\r\n]+/", ',', $whitelist);
         $whitelist = preg_replace("/\\s+/", '', $whitelist);
         if (preg_match('/(<\\?|<\\?php|\\?>)/xsm', $whitelist)) {
             $whitelist = '';
         }
         if ($whitelist) {
             $whitelist = explode(',', trim($whitelist, ','));
             $whitelist = array_unique($whitelist);
             if (is_array($whitelist)) {
                 $CI->load->library('Ipfilter');
                 $ipfilter = new Ipfilter();
                 if (!$ipfilter->filter($whitelist)) {
                     $title = $CI->cbconfig->item('site_blacklist_title') ? $CI->cbconfig->item('site_blacklist_title') : 'Maintenance in progress...';
                     $message = $CI->cbconfig->item('site_blacklist_content');
                     show_error($message, '500', $title);
                     exit;
                 }
             }
         }
     }
     if (config_item('use_lock_ip') && $CI->cbconfig->item('site_ip_blacklist')) {
         $blacklist = $CI->cbconfig->item('site_ip_blacklist');
         $blacklist = preg_replace("/[\r|\n|\r\n]+/", ',', $blacklist);
         $blacklist = preg_replace("/\\s+/", '', $blacklist);
         if (preg_match('/(<\\?|<\\?php|\\?>)/xsm', $blacklist)) {
             $blacklist = '';
         }
         if ($blacklist) {
             $blacklist = explode(',', trim($blacklist, ','));
             $blacklist = array_unique($blacklist);
             if (is_array($blacklist)) {
                 $CI->load->library('Ipfilter');
                 $ipfilter = new Ipfilter();
                 if ($ipfilter->filter($blacklist)) {
                     $title = $CI->cbconfig->item('site_blacklist_title') ? $CI->cbconfig->item('site_blacklist_title') : 'Maintenance in progress...';
                     $message = $CI->cbconfig->item('site_blacklist_content');
                     show_error($message, '500', $title);
                     exit;
                 }
             }
         }
     }
     if ($CI->input->get('device') === 'desktop' or $CI->input->get('device') === 'mobile') {
         $cookie_name = 'device_view_type';
         $cookie_value = $CI->input->get('device');
         $cookie_expire = 3600;
         // 1일간 저장
         set_cookie($cookie_name, $cookie_value, $cookie_expire);
     }
     $CI->load->library('Mobile_detect');
     $detect = new Mobile_detect();
     $device_view_type = ($CI->input->get('device') === 'desktop' or $CI->input->get('device') === 'mobile') ? $CI->input->get('device') : '';
     if (empty($device_view_type)) {
         $device_view_type = (get_cookie('device_view_type') === 'desktop' or get_cookie('device_view_type') === 'mobile') ? get_cookie('device_view_type') : '';
     }
     if (empty($device_view_type)) {
         $device_view_type = $detect->isMobile() ? 'mobile' : 'desktop';
     }
     $CI->cbconfig->set_device_view_type($device_view_type);
     $device_type = $detect->isMobile() ? 'mobile' : 'desktop';
     $CI->cbconfig->set_device_type($device_type);
     if (get_cookie('autologin') && !$CI->session->userdata('mem_id')) {
         $CI->load->model('Autologin_model');
         $where = array('aul_key' => get_cookie('autologin'));
         $autodata = $CI->Autologin_model->get_one('', '', $where);
         if (!element('mem_id', $autodata)) {
             delete_cookie('autologin');
         } elseif (!element('aul_datetime', $autodata) or strtotime(element('aul_datetime', $autodata)) < ctimestamp() * 86400 * 30) {
             $CI->Autologin_model->delete(element('aul_id', $autodata));
             delete_cookie('autologin');
         } elseif ($CI->input->ip_address() !== element('aul_ip', $autodata)) {
             $CI->Autologin_model->delete(element('aul_id', $autodata));
             delete_cookie('autologin');
         } else {
             $tmpmember = $CI->Member_model->get_by_memid(element('mem_id', $autodata), 'mem_id, mem_denied, mem_is_admin');
             if (!element('mem_id', $tmpmember)) {
                 $CI->Autologin_model->delete(element('aul_id', $autodata));
                 delete_cookie('autologin');
             } elseif (element('mem_denied', $tmpmember)) {
                 $CI->Autologin_model->delete(element('aul_id', $autodata));
                 delete_cookie('autologin');
             } elseif (element('mem_is_admin', $tmpmember)) {
                 $CI->Autologin_model->delete(element('aul_id', $autodata));
                 delete_cookie('autologin');
             } else {
                 $CI->session->set_userdata('mem_id', element('mem_id', $autodata));
             }
         }
     }
     if ($CI->member->is_member()) {
         if ($CI->member->item('mem_id') === false) {
             unset($CI->member);
             $CI->session->sess_destroy();
             redirect(current_full_url(), 'refresh');
         }
         $mem_id = (int) $CI->member->item('mem_id');
         if ($CI->member->item('mem_denied')) {
             unset($CI->member);
             $CI->session->sess_destroy();
             redirect(current_full_url(), 'refresh');
         } else {
             if (substr($CI->member->item('mem_lastlogin_datetime'), 0, 10) !== cdate('Y-m-d')) {
                 if ($CI->cbconfig->item('point_login')) {
                     $CI->load->library('point');
                     $CI->point->insert_point($mem_id, $CI->cbconfig->item('point_login'), cdate('Y-m-d') . ' 첫로그인', 'login', $mem_id, cdate('Y-m-d') . ' 로그인');
                 }
                 $updatedata = array('mem_lastlogin_datetime' => cdate('Y-m-d H:i:s'), 'mem_lastlogin_ip' => $CI->input->ip_address());
                 $CI->Member_model->update($mem_id, $updatedata);
             }
         }
     }
     // 관리자 페이지
     if ($CI->member->is_admin() !== 'super' && $CI->uri->segment(1) === config_item('uri_segment_admin')) {
         redirect('login?url=' . $CI->uri->uri_string());
     }
     if (config_item('use_lock_ip') && $CI->uri->segment(1) === config_item('uri_segment_admin') && $CI->cbconfig->item('admin_ip_whitelist')) {
         $whitelist = $CI->cbconfig->item('admin_ip_whitelist');
         $whitelist = preg_replace("/[\r|\n|\r\n]+/", ',', $whitelist);
         $whitelist = preg_replace("/\\s+/", '', $whitelist);
         if (preg_match('/(<\\?|<\\?php|\\?>)/xsm', $whitelist)) {
             $whitelist = '';
         }
         if ($whitelist) {
             $whitelist = explode(',', trim($whitelist, ','));
             $whitelist = array_unique($whitelist);
             if (is_array($whitelist)) {
                 $CI->load->library('Ipfilter');
                 if (!Ipfilter::filter($whitelist)) {
                     $title = '관리자 페이지';
                     $message = '현재 접속하신 아이피는 관리자 페이지 접근이 차단되었습니다';
                     show_error($message, '500', $title);
                     exit;
                 }
             }
         }
     }
 }
Example #15
0
 /**
  * 게시물 수정 페이지입니다
  */
 public function modify($post_id = 0)
 {
     // 이벤트 라이브러리를 로딩합니다
     $eventname = 'event_board_write_modify';
     $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);
     if (!element('post_id', $post)) {
         show_404();
     }
     if (element('post_del', $post)) {
         alert('삭제된 글은 수정하실 수 없습니다');
         return false;
     }
     $post['extravars'] = $this->Post_extra_vars_model->get_all_meta($post_id);
     $post['meta'] = $this->Post_meta_model->get_all_meta($post_id);
     $view['view']['post'] = $post;
     $board = $this->board->item_all(element('brd_id', $post));
     if (!element('brd_id', $board)) {
         show_404();
     }
     $view['view']['board'] = $board;
     $view['view']['board_key'] = element('brd_key', $board);
     $mem_id = (int) $this->member->item('mem_id');
     $postwhere = array('post_id' => $post_id);
     $view['view']['link'] = $link = $this->Post_link_model->get('', '', $postwhere, '', '', 'pln_id', 'ASC');
     $view['view']['file'] = $file = $this->Post_file_model->get('', '', $postwhere, '', '', 'pfi_id', 'ASC');
     if ($file && is_array($file)) {
         foreach ($file as $key => $value) {
             $view['view']['file'][$key]['download_link'] = site_url('postact/download/' . element('pfi_id', $value));
         }
     }
     $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('protect_post_day', $board) > 0 && $is_admin === false) {
         if (ctimestamp() - strtotime(element('post_datetime', $post)) >= element('protect_post_day', $board) * 86400) {
             alert('이 게시판은 ' . element('protect_post_day', $board) . '일 이상된 게시글의 수정을 금지합니다');
             return false;
         }
     }
     if (element('protect_comment_num', $board) > 0 && $is_admin === false) {
         if (element('protect_comment_num', $board) <= element('post_comment_count', $post)) {
             alert(element('protect_comment_num', $board) . '개 이상의 댓글이 달린 게시글은 수정할 수 없습니다');
             return false;
         }
     }
     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('can_modify_' . element('post_id', $post), '1');
         }
         if (!$this->session->userdata('can_modify_' . 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('can_modify_' . element('post_id', $post), '1');
                 redirect(current_url());
             } else {
                 $view['view']['message'] = '패스워드가 잘못 입력되었습니다';
             }
         }
         if (!$this->session->userdata('can_modify_' . element('post_id', $post))) {
             // 이벤트가 존재하면 실행합니다
             $view['view']['event']['before_password_layout'] = Events::trigger('before_password_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 (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);
     $extravars = element('extravars', $board);
     $form = json_decode($extravars, true);
     $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']['post']['is_post_name'] = $is_post_name = ($this->member->is_member() === false or $is_admin !== false && $mem_id !== (int) element('mem_id', $post)) ? true : false;
     $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']['can_post_receive_email'] = $can_post_receive_email = element('use_post_receive_email', $board) ? true : false;
     $primary_key = $this->Post_model->primary_key;
     // 이벤트가 존재하면 실행합니다
     $view['view']['event']['step1'] = Events::trigger('step1', $eventname);
     /**
      * Validation 라이브러리를 가져옵니다
      */
     $this->load->library('form_validation');
     /**
      * 전송된 데이터의 유효성을 체크합니다
      */
     $config = array(array('field' => 'post_id', 'label' => 'POSTID', 'rules' => 'trim|required|numeric'), 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|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 = '';
     $uploadfiledata2 = '';
     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) ? element('is_image', $filedata) : 0;
                     } else {
                         $file_error = $this->upload->display_errors();
                         break;
                     }
                 }
             }
         }
         if (isset($_FILES) && isset($_FILES['post_file_update']) && isset($_FILES['post_file_update']['name']) && is_array($_FILES['post_file_update']['name']) && $file_error === '') {
             $filecount = count($_FILES['post_file_update']['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_update']['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_update']['name'][$i];
                     $_FILES['userfile']['type'] = $_FILES['post_file_update']['type'][$i];
                     $_FILES['userfile']['tmp_name'] = $_FILES['post_file_update']['tmp_name'][$i];
                     $_FILES['userfile']['error'] = $_FILES['post_file_update']['error'][$i];
                     $_FILES['userfile']['size'] = $_FILES['post_file_update']['size'][$i];
                     if ($this->upload->do_upload()) {
                         $filedata = $this->upload->data();
                         $uploadfiledata2[$i]['pfi_id'] = $i;
                         $uploadfiledata2[$i]['pfi_filename'] = cdate('Y') . '/' . cdate('m') . '/' . element('file_name', $filedata);
                         $uploadfiledata2[$i]['pfi_originname'] = element('orig_name', $filedata);
                         $uploadfiledata2[$i]['pfi_filesize'] = intval(element('file_size', $filedata) * 1024);
                         $uploadfiledata2[$i]['pfi_width'] = element('image_width', $filedata) ? element('image_width', $filedata) : 0;
                         $uploadfiledata2[$i]['pfi_height'] = element('image_height', $filedata) ? element('image_height', $filedata) : 0;
                         $uploadfiledata2[$i]['pfi_type'] = str_replace('.', '', element('file_ext', $filedata));
                         $uploadfiledata2[$i]['is_image'] = element('is_image', $filedata) ? element('is_image', $filedata) : 0;
                     } else {
                         $file_error = $this->upload->display_errors();
                         break;
                     }
                 }
             }
         }
     }
     /**
      * 유효성 검사를 하지 않는 경우, 또는 유효성 검사에 실패한 경우입니다.
      * 즉 글쓰기나 수정 페이지를 보고 있는 경우입니다
      */
     if ($form_validation === false or $file_error) {
         // 이벤트가 존재하면 실행합니다
         $view['view']['event']['formrunfalse'] = Events::trigger('formrunfalse', $eventname);
         /**
          * primary key 정보를 저장합니다
          */
         $view['view']['primary_key'] = $primary_key;
         if ($file_error) {
             $view['view']['message'] = $file_error;
         }
         $extra_content = '';
         $k = 0;
         if ($form && is_array($form)) {
             foreach ($form as $key => $value) {
                 if (!element('use', $value)) {
                     continue;
                 }
                 $required = element('required', $value) ? 'required' : '';
                 $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);
                 $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), $item) . '" 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), $item) . '" ' . $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), $item) . '" ' . $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), $item) . '</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) {
                             $oval = trim($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, $item === $radiovalue ? true : false) . ' /> ' . $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));
                     $item = json_decode($item, true);
                     $i = 1;
                     if ($options) {
                         foreach ($options as $okey => $oval) {
                             $oval = trim($oval);
                             $chkvalue = is_array($item) && in_array($oval, $item) ? $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, $chkvalue === $oval ? true : false) . ' /> ' . $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) {
                             $oval = trim($oval);
                             $extra_content[$k]['input'] .= '<option value="' . $oval . '" ' . set_select(element('field_name', $value), $oval, $item === $oval ? true : false) . ' >' . $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']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
         /**
          * 레이아웃을 정의합니다
          */
         $page_title = $this->cbconfig->item('site_meta_title_board_modify');
         $meta_description = $this->cbconfig->item('site_meta_description_board_modify');
         $meta_keywords = $this->cbconfig->item('site_meta_keywords_board_modify');
         $meta_author = $this->cbconfig->item('site_meta_author_board_modify');
         $page_name = $this->cbconfig->item('site_page_name_board_modify');
         $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);
         $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;
         $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);
         }
         $metadata = array();
         $updatedata = array('post_title' => $post_title, 'post_content' => $post_content, 'post_html' => $content_type, 'post_updated_datetime' => cdate('Y-m-d H:i:s'), 'post_update_mem_id' => $mem_id);
         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) {
             if ($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, '');
         }
         $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 (isset($metadata) && $metadata) {
             $this->Post_meta_model->save($post_id, element('brd_id', $board), $metadata);
         }
         $post_link_update = $this->input->post('post_link_update');
         $link_count = 0;
         if ($post_link_update && is_array($post_link_update) && count($post_link_update) > 0) {
             foreach ($post_link_update as $pkey => $pval) {
                 if ($pval) {
                     $linkupdate = array('pln_url' => prep_url($pval));
                     $this->Post_link_model->update($pkey, $linkupdate);
                     $link_count++;
                 } else {
                     $this->Post_link_model->delete($pkey);
                 }
             }
         }
         $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);
                     $link_count++;
                 }
             }
         }
         $updatedata['post_link_count'] = $link_count;
         $file_updated = false;
         $file_changed = 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;
                 }
             }
             $file_changed = true;
         }
         if ($use_upload && $uploadfiledata2 && is_array($uploadfiledata2) && count($uploadfiledata2) > 0) {
             foreach ($uploadfiledata2 as $pkey => $pval) {
                 if ($pval) {
                     $fileupdate = array('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());
                     $this->Post_file_model->update($pkey, $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', $pkey, '파일 업로드');
                         }
                     } else {
                         $this->point->delete_point($mem_id, 'fileupload', $pkey, '파일 업로드');
                     }
                     $file_changed = true;
                 }
             }
         }
         if ($use_upload && $this->input->post('post_file_del')) {
             foreach ($this->input->post('post_file_del') as $key => $val) {
                 if ($val === '1' && !isset($uploadfiledata2[$key])) {
                     $this->Post_file_model->delete($key);
                     $this->point->delete_point($mem_id, 'fileupload', $key, '파일 업로드');
                     $file_changed = true;
                 }
             }
         }
         $updatedata['post_image'] = 0;
         $updatedata['post_file'] = 0;
         $result = $this->Post_file_model->get_post_file_count($post_id);
         if ($result && is_array($result)) {
             $total_cnt = 0;
             foreach ($result as $value) {
                 if (element('pfi_is_image', $value)) {
                     $updatedata['post_image'] = element('cnt', $value);
                     $total_cnt += element('cnt', $value);
                 } else {
                     $updatedata['post_file'] = element('cnt', $value);
                     $total_cnt += element('cnt', $value);
                 }
             }
         }
         // 이벤트가 존재하면 실행합니다
         Events::trigger('before_post_update', $eventname);
         $this->Post_model->update($this->input->post($primary_key), $updatedata);
         // 네이버 신디케이션 보내기
         if (!element('post_secret', $updatedata)) {
             $this->_naver_syndi($post_id, $board);
         }
         // 이벤트가 존재하면 실행합니다
         Events::trigger('after', $eventname);
         $this->session->set_flashdata('message', '게시물이 정상적으로 수정되었습니다');
         /**
          * 게시물의 신규입력 또는 수정작업이 끝난 후 뷰 페이지로 이동합니다
          */
         $param =& $this->querystring;
         $redirecturl = post_url(element('brd_key', $board), $this->input->post($primary_key)) . '?' . $param->output();
         redirect($redirecturl);
     }
 }