Initial import from local backup (Documents-Playground/pakerpale)
This commit is contained in:
1437
application/controllers/Board_post.php
Normal file
1437
application/controllers/Board_post.php
Normal file
File diff suppressed because it is too large
Load Diff
2477
application/controllers/Board_write.php
Normal file
2477
application/controllers/Board_write.php
Normal file
File diff suppressed because it is too large
Load Diff
102
application/controllers/Captcha.php
Normal file
102
application/controllers/Captcha.php
Normal file
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Captcha class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 비회원이 접근시 보여주는 captcha 에 관한 controller 입니다.
|
||||
*/
|
||||
class Captcha extends CB_Controller
|
||||
{
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/**
|
||||
* 라이브러리를 로딩합니다
|
||||
*/
|
||||
$this->load->helper(array('captcha', 'string'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 캡차 세션 생성후 보여주는 함수입니다.
|
||||
*/
|
||||
function show($width = '', $height = '')
|
||||
{
|
||||
$this->output->set_content_type('application/json');
|
||||
|
||||
if ( ! $width) {
|
||||
$width = 150;
|
||||
}
|
||||
if ( ! $height) {
|
||||
$height = 40;
|
||||
}
|
||||
|
||||
$img_path = config_item('uploads_dir') . '/captcha/';
|
||||
if ( ! is_dir($img_path)) {
|
||||
@mkdir($img_path, 0755);
|
||||
@chmod($img_path, 0755);
|
||||
$file = $img_path . 'index.php';
|
||||
$f = @fopen($file, 'w');
|
||||
@fwrite($f, '');
|
||||
@fclose($f);
|
||||
@chmod($file, 0644);
|
||||
}
|
||||
|
||||
$data = array(
|
||||
'img_path' => $img_path,
|
||||
'img_url' => site_url(config_item('uploads_dir') . '/captcha') . '/',
|
||||
'img_width' => $width,
|
||||
'img_height' => $height,
|
||||
'font_size' => 15,
|
||||
'font_path' => FCPATH . 'assets/fonts/BreeSerif-Regular.ttf',
|
||||
'pool' => '23456789abcdefghjkmnpqrstuvwxyzABCDEFGHJKMNPQRSTUVWXYZ',
|
||||
'word_length' => '8',
|
||||
'img_id' => 'captcha',
|
||||
);
|
||||
|
||||
$cap = create_captcha($data);
|
||||
|
||||
$save = array(
|
||||
'captcha_time' => $cap['time'],
|
||||
'ip_address' => $this->input->ip_address(),
|
||||
'word' => $cap['word'],
|
||||
);
|
||||
$this->session->set_userdata('captcha', $save);
|
||||
|
||||
exit(json_encode($cap));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 구글 캡차 생성후 보여주는 함수입니다.
|
||||
*/
|
||||
function recaptcha()
|
||||
{
|
||||
$html = '<div id="google-recaptcha">';
|
||||
$html .= '<script src="https://www.google.com/recaptcha/api.js"></script>';
|
||||
|
||||
if ( (int) $this->cbconfig->item('use_recaptcha') === 2 ){
|
||||
|
||||
$html .= '<div id="recaptcha" class="g-recaptcha" data-sitekey="' . $this->cbconfig->item('recaptcha_sitekey') . '" data-callback="recaptcha_validate" data-badge="inline" data-size="invisible"></div>';
|
||||
$html .= '<script>jQuery("#recaptcha").hide().parent("div").hide();</script>';
|
||||
|
||||
} else {
|
||||
|
||||
$html .= '<div class="g-recaptcha" data-sitekey="' . $this->cbconfig->item('recaptcha_sitekey') . '"></div>';
|
||||
|
||||
}
|
||||
|
||||
$html .= '</div>';
|
||||
|
||||
echo $html;
|
||||
}
|
||||
}
|
||||
541
application/controllers/Comment_list.php
Normal file
541
application/controllers/Comment_list.php
Normal file
@@ -0,0 +1,541 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Comment_list class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 게시물 열람 페이지에 보이는 댓글 목록에 관한 controller 입니다.
|
||||
*/
|
||||
class Comment_list extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array('Post', 'Comment', 'Comment_meta');
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/**
|
||||
* 라이브러리를 로딩합니다
|
||||
*/
|
||||
$this->load->library(array('pagination', 'querystring', 'accesslevel'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 댓글 목록을 ajax 로 가져옵니다
|
||||
*/
|
||||
public function lists($post_id = 0)
|
||||
{
|
||||
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_comment_list_lists';
|
||||
$this->load->event($eventname);
|
||||
|
||||
$post_id = (int) $post_id;
|
||||
if (empty($post_id) OR $post_id < 1) {
|
||||
show_404();
|
||||
}
|
||||
|
||||
$view = array();
|
||||
$view['view'] = array();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before'] = Events::trigger('before', $eventname);
|
||||
|
||||
$post = $this->Post_model->get_one($post_id);
|
||||
if ( ! element('post_id', $post)) {
|
||||
show_404();
|
||||
}
|
||||
|
||||
$board = $this->board->item_all(element('brd_id', $post));
|
||||
$mem_id = (int) $this->member->item('mem_id');
|
||||
|
||||
$alertmessage = $this->member->is_member()
|
||||
? '회원님은 이 댓글 목록을 볼 수 있는 권한이 없습니다'
|
||||
: '비회원은 이 댓글 접근할 권한이 없습니다.\\n\\n회원이시라면 로그인 후 이용해 보십시오';
|
||||
$check = array(
|
||||
'group_id' => element('bgr_id', $board),
|
||||
'board_id' => element('brd_id', $board),
|
||||
);
|
||||
$this->accesslevel->check(
|
||||
element('access_view', $board),
|
||||
element('access_view_level', $board),
|
||||
element('access_view_group', $board),
|
||||
$alertmessage,
|
||||
$check
|
||||
);
|
||||
|
||||
$is_admin = $this->member->is_admin(
|
||||
array(
|
||||
'board_id' => element('brd_id', $board),
|
||||
'group_id' => element('bgr_id', $board)
|
||||
)
|
||||
);
|
||||
|
||||
$check = array(
|
||||
'group_id' => element('bgr_id', $board),
|
||||
'board_id' => element('brd_id', $board),
|
||||
);
|
||||
$can_comment_write = $this->accesslevel->is_accessable(
|
||||
element('access_comment', $board),
|
||||
element('access_comment_level', $board),
|
||||
element('access_comment_group', $board),
|
||||
$check
|
||||
);
|
||||
|
||||
/**
|
||||
* 페이지에 숫자가 아닌 문자가 입력되거나 1보다 작은 숫자가 입력되면 에러 페이지를 보여줍니다.
|
||||
*/
|
||||
$param =& $this->querystring;
|
||||
$findex = strtolower(element('comment_order', $board)) === 'desc'
|
||||
? 'cmt_num, cmt_reply' : 'cmt_num desc, cmt_reply';
|
||||
if ($this->cbconfig->get_device_view_type() === 'mobile') {
|
||||
$per_page = element('mobile_comment_count', $board)
|
||||
? (int) element('mobile_comment_count', $board) : 0;
|
||||
} else {
|
||||
$per_page = element('comment_count', $board) ? (int) element('comment_count', $board) : 0;
|
||||
}
|
||||
|
||||
$page = (int) $this->input->get('page');
|
||||
if ($page === 0) $page = 1;
|
||||
if (empty($page)) {
|
||||
if (strtolower(element('comment_order', $board)) === 'desc') {
|
||||
$page = 1;
|
||||
} else {
|
||||
$page = $per_page ? ceil(element('post_comment_count', $post) / $per_page) : 1;
|
||||
if ($page === 0) {
|
||||
$page = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($page < 1) {
|
||||
show_404();
|
||||
}
|
||||
|
||||
$offset = ($page - 1) * $per_page;
|
||||
|
||||
$this->Comment_model->allow_search_field = array('cmt_id', 'post_id', 'cmt_content', 'cmt_userid', 'cmt_nickname'); // 검색이 가능한 필드
|
||||
$this->Comment_model->search_field_equal = array('cmt_id', 'cmt_userid', 'cmt_nickname'); // 검색중 like 가 아닌 = 검색을 하는 필드
|
||||
|
||||
$image_width = ($this->cbconfig->get_device_view_type() === 'mobile')
|
||||
? element('post_mobile_image_width', $board)
|
||||
: element('post_image_width', $board);
|
||||
$use_sideview = ($this->cbconfig->get_device_view_type() === 'mobile')
|
||||
? element('use_mobile_sideview', $board)
|
||||
: element('use_sideview', $board);
|
||||
$use_sideview_icon = ($this->cbconfig->get_device_view_type() === 'mobile')
|
||||
? element('use_mobile_sideview_icon', $board)
|
||||
: element('use_sideview_icon', $board);
|
||||
$comment_date_style = ($this->cbconfig->get_device_view_type() === 'mobile')
|
||||
? element('mobile_comment_date_style', $board)
|
||||
: element('comment_date_style', $board);
|
||||
$comment_date_style_manual = ($this->cbconfig->get_device_view_type() === 'mobile')
|
||||
? element('mobile_comment_date_style_manual', $board)
|
||||
: element('comment_date_style_manual', $board);
|
||||
$comment_best = ($this->cbconfig->get_device_view_type() === 'mobile')
|
||||
? element('mobile_comment_best', $board)
|
||||
: element('comment_best', $board);
|
||||
|
||||
$board['use_comment_profile'] = ($this->cbconfig->get_device_view_type() === 'mobile')
|
||||
? element('use_mobile_comment_profile', $board)
|
||||
: element('use_comment_profile', $board);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['step1'] = Events::trigger('step1', $eventname);
|
||||
|
||||
/**
|
||||
* 상단에 베스트 부분에 필요한 정보를 가져옵니다.
|
||||
*/
|
||||
$bestresult = '';
|
||||
if ($comment_best) {
|
||||
$bestresult = $this->Comment_model
|
||||
->get_best_list($post_id, $comment_best, element('comment_best_like_num', $board));
|
||||
if ($bestresult) {
|
||||
foreach ($bestresult as $key => $val) {
|
||||
$bestresult[$key]['meta'] = $meta = $this->Comment_meta_model->get_all_meta(element('cmt_id', $val));
|
||||
$bestresult[$key]['content'] = '';
|
||||
|
||||
$is_blind = (element('comment_blame_blind_count', $board) > 0 && element('cmt_blame', $val) >= element('comment_blame_blind_count', $board)) ? true : false;
|
||||
|
||||
if ($is_blind === true) {
|
||||
$bestresult[$key]['content'] .= '<div class="alert alert-danger">신고가 접수된 게시글입니다. 본인과 관리자만 확인이 가능합니다</div>';
|
||||
}
|
||||
if (element('cmt_secret', $val)) {
|
||||
$bestresult[$key]['content'] .= '<span class="label label-warning">비밀글입니다</span>';
|
||||
}
|
||||
if (($is_blind === false && ! element('cmt_secret', $val)) OR $is_admin !== false OR (element('mem_id', $val) && (int) element('mem_id', $val) === $mem_id)) {
|
||||
$bestresult[$key]['content'] .= display_html_content(
|
||||
element('cmt_content', $val),
|
||||
element('cmt_html', $val),
|
||||
$image_width,
|
||||
$autolink = true,
|
||||
$popup = true
|
||||
);
|
||||
if (element('comment_syntax_highlighter', $board)) {
|
||||
$bestresult[$key]['content'] = preg_replace_callback(
|
||||
"/(\[code\]|\[code=(.*)\])(.*)\[\/code\]/iUs",
|
||||
"content_syntaxhighlighter",
|
||||
$bestresult[$key]['content']
|
||||
); // SyntaxHighlighter
|
||||
}
|
||||
}
|
||||
if (element('cmt_del', $val)) {
|
||||
$bestresult[$key]['content'] = '<div class="alert alert-danger">이 게시물은 '
|
||||
. html_escape(element('delete_mem_nickname', $meta)) . '님에 의해 '
|
||||
. html_escape(element('delete_datetime', $meta)) . ' 에 삭제 되었습니다</div>';
|
||||
}
|
||||
if (element('mem_id', $val) >= 0) {
|
||||
$bestresult[$key]['display_name'] = display_username(
|
||||
element('cmt_userid', $val),
|
||||
element('cmt_nickname', $val),
|
||||
($use_sideview_icon ? element('mem_icon', $val) : ''),
|
||||
($use_sideview ? 'Y' : 'N')
|
||||
);
|
||||
} else {
|
||||
$bestresult[$key]['display_name'] = '익명사용자';
|
||||
}
|
||||
$bestresult[$key]['display_datetime'] = display_datetime(
|
||||
element('cmt_datetime', $val),
|
||||
$comment_date_style,
|
||||
$comment_date_style_manual
|
||||
);
|
||||
$bestresult[$key]['is_mobile'] = (element('cmt_device', $val) === 'mobile') ? true : false;
|
||||
$bestresult[$key]['display_ip'] = '';
|
||||
|
||||
$show_comment_ip = ($this->cbconfig->get_device_view_type() === 'mobile')
|
||||
? element('show_mobile_comment_ip', $board)
|
||||
: element('show_comment_ip', $board);
|
||||
if ($this->member->is_admin() === 'super' OR $show_comment_ip === '2') {
|
||||
$bestresult[$key]['display_ip'] = display_ipaddress(element('cmt_ip', $val), '1111');
|
||||
} elseif ($show_comment_ip === '1') {
|
||||
$bestresult[$key]['display_ip'] = display_ipaddress(element('cmt_ip', $val), $this->cbconfig->item('ip_display_style'));
|
||||
}
|
||||
$bestresult[$key]['member_photo_url']
|
||||
= member_photo_url(element('mem_photo', $val), 64, 64)
|
||||
? member_photo_url(element('mem_photo', $val), 64, 64)
|
||||
: site_url('assets/images/member_default.gif');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 게시판 목록에 필요한 정보를 가져옵니다.
|
||||
*/
|
||||
$where = array(
|
||||
'post_id' => $post_id,
|
||||
'cmt_del <>' => 2,
|
||||
);
|
||||
$result = $this->Comment_model
|
||||
->get_comment_list($per_page, $offset, $where, '', $findex, $sfield = '', $skeyword = '');
|
||||
$list_num = $result['total_rows'] - ($page - 1) * $per_page;
|
||||
|
||||
if (element('list', $result)) {
|
||||
foreach (element('list', $result) as $key => $val) {
|
||||
$result['list'][$key]['meta'] = $meta
|
||||
= $this->Comment_meta_model->get_all_meta(element('cmt_id', $val));
|
||||
$result['list'][$key]['content'] = '';
|
||||
|
||||
$is_blind = (element('comment_blame_blind_count', $board) > 0 && element('cmt_blame', $val) >= element('comment_blame_blind_count', $board)) ? true : false;
|
||||
|
||||
if ($is_blind === true) {
|
||||
$result['list'][$key]['content'] .= '<div class="alert alert-danger">신고가 접수된 게시글입니다. 본인과 관리자만 확인이 가능합니다</div>';
|
||||
}
|
||||
if (element('cmt_secret', $val)) {
|
||||
$result['list'][$key]['content'] .= '<span class="label label-warning">비밀글입니다</span>';
|
||||
}
|
||||
if (($is_blind === false && ! element('cmt_secret', $val)) OR $is_admin !== false OR (element('mem_id', $val) && abs(element('mem_id', $val)) === $mem_id)
|
||||
OR (element('mem_id', $post) && abs(element('mem_id', $post)) === $mem_id)) {
|
||||
$result['list'][$key]['content'] .= display_html_content(
|
||||
element('cmt_content', $val),
|
||||
element('cmt_html', $val),
|
||||
$image_width,
|
||||
$autolink = true,
|
||||
$popup = true
|
||||
);
|
||||
if (element('comment_syntax_highlighter', $board)) {
|
||||
$result['list'][$key]['content'] = preg_replace_callback(
|
||||
"/(\[code\]|\[code=(.*)\])(.*)\[\/code\]/iUs",
|
||||
"content_syntaxhighlighter",
|
||||
$result['list'][$key]['content']
|
||||
); // SyntaxHighlighter
|
||||
}
|
||||
}
|
||||
if (element('cmt_del', $val)) {
|
||||
$result['list'][$key]['content'] = '<div class="alert alert-danger">이 게시물은 '
|
||||
. html_escape(element('delete_mem_nickname', $meta)) . '님에 의해 '
|
||||
. html_escape(element('delete_datetime', $meta)) . ' 에 삭제 되었습니다</div>';
|
||||
}
|
||||
if (element('mem_id', $val) >= 0) {
|
||||
$result['list'][$key]['display_name'] = display_username(
|
||||
element('cmt_userid', $val),
|
||||
element('cmt_nickname', $val),
|
||||
($use_sideview_icon ? element('mem_icon', $val) : ''),
|
||||
($use_sideview ? 'Y' : 'N')
|
||||
);
|
||||
} else {
|
||||
$result['list'][$key]['display_name'] = '익명사용자';
|
||||
}
|
||||
$result['list'][$key]['display_datetime'] = display_datetime(
|
||||
element('cmt_datetime', $val),
|
||||
$comment_date_style,
|
||||
$comment_date_style_manual
|
||||
);
|
||||
$result['list'][$key]['is_mobile'] = (element('cmt_device', $val) === 'mobile') ? true : false;
|
||||
$result['list'][$key]['display_ip'] = '';
|
||||
|
||||
$result['list'][$key]['lucky'] = '';
|
||||
if (element('comment-lucky', $meta)) {
|
||||
$result['list'][$key]['lucky'] = element('comment_lucky_name', $board). '에 당첨되어 <span class="luckypoint">' . number_format(element('comment-lucky', $meta)) . '</span> 포인트 지급되었습니다.';
|
||||
}
|
||||
if ($this->member->is_admin() === 'super'
|
||||
OR element('show_comment_ip', $board) === '2') {
|
||||
$result['list'][$key]['display_ip'] = display_ipaddress(element('cmt_ip', $val), '1111');
|
||||
} elseif (element('show_comment_ip', $board) === '1') {
|
||||
$result['list'][$key]['display_ip'] = display_ipaddress(element('cmt_ip', $val), $this->cbconfig->item('ip_display_style'));
|
||||
}
|
||||
$result['list'][$key]['member_photo_url']
|
||||
= member_photo_url(element('mem_photo', $val), 64, 64)
|
||||
? member_photo_url(element('mem_photo', $val), 64, 64)
|
||||
: site_url('assets/images/member_default.gif');
|
||||
|
||||
$result['list'][$key]['cmt_depth'] = strlen($result['list'][$key]['cmt_reply']) * 30;
|
||||
|
||||
$result['list'][$key]['can_update'] = false;
|
||||
$result['list'][$key]['can_delete'] = false;
|
||||
$result['list'][$key]['can_reply'] = false;
|
||||
if ( ! element('post_del', $post) && ! element('cmt_del', $val)) {
|
||||
if ( ! element('mem_id', $val)) {
|
||||
$result['list'][$key]['can_delete'] = true;
|
||||
}
|
||||
if ($is_admin !== false
|
||||
OR (element('mem_id', $val) && $mem_id === abs(element('mem_id', $val)))) {
|
||||
$result['list'][$key]['can_update'] = true;
|
||||
$result['list'][$key]['can_delete'] = true;
|
||||
}
|
||||
if ($key > 0 && $is_admin === false) {
|
||||
if (element('cmt_reply', $val)) {
|
||||
$prev_reply = substr(
|
||||
element('cmt_reply', $val),
|
||||
0,
|
||||
strlen(element('cmt_reply', $val)) - 1
|
||||
);
|
||||
if ($prev_reply === $result['list'][$key-1]['cmt_reply']) {
|
||||
$result['list'][$key-1]['can_update'] = false;
|
||||
$result['list'][$key-1]['can_delete'] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (element('block_delete', $board) && $is_admin === false) {
|
||||
$result['list'][$key]['can_delete'] = false;
|
||||
}
|
||||
if (strlen(element('cmt_reply', $val)) < 5 && $can_comment_write === true) {
|
||||
$result['list'][$key]['can_reply'] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$view['view']['data'] = $result;
|
||||
$view['view']['best_list'] = $bestresult;
|
||||
$view['view']['board'] = $board;
|
||||
$view['view']['post'] = $post;
|
||||
$view['view']['is_admin'] = $is_admin;
|
||||
|
||||
/**
|
||||
* primary key 정보를 저장합니다
|
||||
*/
|
||||
$view['view']['primary_key'] = $this->Post_model->primary_key;
|
||||
|
||||
/**
|
||||
* 페이지네이션을 생성합니다
|
||||
*/
|
||||
$config['base_url'] = site_url('comment_list/lists/' . $post_id) . '?' . $param->replace('page');
|
||||
$config['total_rows'] = $result['total_rows'];
|
||||
$config['per_page'] = $per_page;
|
||||
|
||||
if ( ! $this->input->get('page')) {
|
||||
$_GET['page'] = (string) $page;
|
||||
}
|
||||
|
||||
$config['_attributes'] = 'onClick="comment_page(\'' . $post_id . '\', $(this).attr(\'data-ci-pagination-page\'));return false;"';
|
||||
if ($this->cbconfig->get_device_view_type() === 'mobile') {
|
||||
$config['num_links'] = element('mobile_comment_page_count', $board)
|
||||
? element('mobile_comment_page_count', $board) : 3;
|
||||
} else {
|
||||
$config['num_links'] = element('comment_page_count', $board)
|
||||
? element('comment_page_count', $board) : 5;
|
||||
}
|
||||
$this->pagination->initialize($config);
|
||||
$view['view']['paging'] = $this->pagination->create_links();
|
||||
$view['view']['page'] = $page;
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
|
||||
|
||||
/**
|
||||
* 레이아웃을 정의합니다
|
||||
*/
|
||||
$skindir = ($this->cbconfig->get_device_view_type() === 'mobile')
|
||||
? element('board_mobile_skin', $board)
|
||||
: element('board_skin', $board);
|
||||
if (empty($skindir)) {
|
||||
$skindir = ($this->cbconfig->get_device_view_type() === 'mobile')
|
||||
? $this->cbconfig->item('mobile_skin_board')
|
||||
: $this->cbconfig->item('skin_board');
|
||||
}
|
||||
if (empty($skindir)) {
|
||||
$skindir = ($this->cbconfig->get_device_view_type() === 'mobile')
|
||||
? $this->cbconfig->item('mobile_skin_default')
|
||||
: $this->cbconfig->item('skin_default');
|
||||
}
|
||||
if (empty($skindir)) {
|
||||
$skindir = 'basic';
|
||||
}
|
||||
$skin = 'board/' . $skindir . '/comment_list';
|
||||
|
||||
$this->data = $view;
|
||||
$this->view = $skin;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 비회원이 작성한 댓글 삭제시 패스워드를 물을 때 필요합니다.
|
||||
*/
|
||||
public function password($post_id = 0, $cmt_id = 0)
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_comment_list_password';
|
||||
$this->load->event($eventname);
|
||||
|
||||
$view = array();
|
||||
$view['view'] = array();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before'] = Events::trigger('before', $eventname);
|
||||
|
||||
$cmt_id = (int) $cmt_id;
|
||||
if (empty($cmt_id) OR $cmt_id < 1) {
|
||||
show_404();
|
||||
}
|
||||
|
||||
$post_id = (int) $post_id;
|
||||
if (empty($post_id) OR $post_id < 1) {
|
||||
show_404();
|
||||
}
|
||||
|
||||
|
||||
$comment = $this->Comment_model->get_one($cmt_id);
|
||||
if ( ! element('cmt_id', $comment)) {
|
||||
show_404();
|
||||
}
|
||||
if ((int) element('post_id', $comment) !== $post_id) {
|
||||
show_404();
|
||||
}
|
||||
|
||||
$post = $this->Post_model->get_one($post_id);
|
||||
if ( ! element('post_id', $post)) {
|
||||
show_404();
|
||||
}
|
||||
|
||||
$board = $this->board->item_all(element('brd_id', $post));
|
||||
|
||||
/**
|
||||
* Validation 라이브러리를 가져옵니다
|
||||
*/
|
||||
$this->load->library('form_validation');
|
||||
|
||||
/**
|
||||
* 전송된 데이터의 유효성을 체크합니다
|
||||
*/
|
||||
$config = array(
|
||||
array(
|
||||
'field' => 'modify_password',
|
||||
'label' => '패스워드',
|
||||
'rules' => 'trim|required',
|
||||
),
|
||||
);
|
||||
$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);
|
||||
|
||||
$modify_password = $this->input->post('modify_password');
|
||||
$return = $this->board->delete_comment_check($cmt_id, $modify_password);
|
||||
$result = json_decode($return, true);
|
||||
|
||||
if (element('error', $result)) {
|
||||
$view['view']['message'] = element('error', $result);
|
||||
}
|
||||
if (element('password', $result)) {
|
||||
$view['view']['message'] = element('password', $result);
|
||||
}
|
||||
if (element('success', $result)) {
|
||||
redirect(post_url(element('brd_key', $board), $post_id));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$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;
|
||||
}
|
||||
}
|
||||
894
application/controllers/Comment_write.php
Normal file
894
application/controllers/Comment_write.php
Normal file
@@ -0,0 +1,894 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Comment_write class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 댓글 작성시 업데이트 할 때 작동하는 controller 입니다.
|
||||
*/
|
||||
class Comment_write extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array('Post', 'Comment');
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/**
|
||||
* 라이브러리를 로딩합니다
|
||||
*/
|
||||
$this->load->library(array('querystring', 'accesslevel', 'email', 'notelib', 'point'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 댓글 작성시 업데이트하는 함수입니다
|
||||
*/
|
||||
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)
|
||||
&& abs(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));
|
||||
}
|
||||
}
|
||||
if (element('comment_possible_day', $board) > 0 && $is_admin === false
|
||||
&& $mode === 'c' && ! $this->input->post('cmt_id')) {
|
||||
if (ctimestamp() - strtotime(element('post_datetime', $post)) >= element('comment_possible_day', $board) * 86400) {
|
||||
$result = array('error' => '이 게시판은 ' . element('comment_possible_day', $board) . '일 이상된 게시글에 댓글 입력을 금지합니다');
|
||||
exit(json_encode($result));
|
||||
}
|
||||
}
|
||||
|
||||
$is_comment_name = ($this->member->is_member() === false) ? true : false;
|
||||
$can_comment_secret = (element('use_comment_secret', $board) === '1' && $this->member->is_member()) ? true : false;
|
||||
|
||||
/**
|
||||
* Validation 라이브러리를 가져옵니다
|
||||
*/
|
||||
$this->load->library('form_validation');
|
||||
|
||||
/**
|
||||
* 전송된 데이터의 유효성을 체크합니다
|
||||
*/
|
||||
$config = array(
|
||||
array(
|
||||
'field' => 'cmt_content',
|
||||
'label' => '내용',
|
||||
'rules' => 'trim|required',
|
||||
),
|
||||
);
|
||||
if ($is_comment_name) {
|
||||
$password_length = $this->cbconfig->item('password_length');
|
||||
$config[] = array(
|
||||
'field' => 'cmt_nickname',
|
||||
'label' => '닉네임',
|
||||
'rules' => 'trim|required|min_length[2]|max_length[20]|callback__mem_nickname_check',
|
||||
);
|
||||
$config[] = array(
|
||||
'field' => 'cmt_password',
|
||||
'label' => '패스워드',
|
||||
'rules' => 'trim|required|min_length[' . $password_length . ']|callback__mem_password_check',
|
||||
);
|
||||
}
|
||||
if ($this->member->is_member() === false) {
|
||||
if ($this->cbconfig->item('use_recaptcha')) {
|
||||
$config[] = array(
|
||||
'field' => 'g-recaptcha-response',
|
||||
'label' => '자동등록방지문자',
|
||||
'rules' => 'trim|required|callback__check_recaptcha',
|
||||
);
|
||||
} else {
|
||||
$config[] = array(
|
||||
'field' => 'captcha_key',
|
||||
'label' => '자동등록방지문자',
|
||||
'rules' => 'trim|required|callback__check_captcha',
|
||||
);
|
||||
}
|
||||
}
|
||||
$this->form_validation->set_rules($config);
|
||||
$form_validation = $this->form_validation->run();
|
||||
|
||||
|
||||
/**
|
||||
* 유효성 검사를 하지 않는 경우, 또는 유효성 검사에 실패한 경우입니다.
|
||||
* 즉 글쓰기나 수정 페이지를 보고 있는 경우입니다
|
||||
*/
|
||||
if ($form_validation === false) {
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('formrunfalse', $eventname);
|
||||
|
||||
$result = array('error' => validation_errors('<div class="alert alert-warning" role="alert">', '</div>'));
|
||||
exit(json_encode($result));
|
||||
|
||||
} else {
|
||||
/**
|
||||
* 유효성 검사를 통과한 경우입니다.
|
||||
* 즉 데이터의 insert 나 update 의 process 처리가 필요한 상황입니다
|
||||
*/
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('formruntrue', $eventname);
|
||||
|
||||
$content_type = 0;
|
||||
$cmt_content
|
||||
= ($this->input->post('cmt_content') === '<p></p>' OR $this->input->post('cmt_content') === '<p> </p>')
|
||||
? '' : $this->input->post('cmt_content');
|
||||
|
||||
if ($mode === 'c') {
|
||||
if ($origin) {
|
||||
$cmt_num = element('cmt_num', $origin);
|
||||
$cmt_reply = $reply;
|
||||
} else {
|
||||
$cmt_num = $this->Comment_model->next_comment_num();
|
||||
$cmt_reply = '';
|
||||
}
|
||||
$updatedata = array(
|
||||
'cmt_num' => $cmt_num,
|
||||
'cmt_reply' => $cmt_reply,
|
||||
'cmt_content' => $cmt_content,
|
||||
'cmt_html' => $content_type,
|
||||
'cmt_datetime' => cdate('Y-m-d H:i:s'),
|
||||
'cmt_updated_datetime' => cdate('Y-m-d H:i:s'),
|
||||
'cmt_ip' => $this->input->ip_address(),
|
||||
'post_id' => element('post_id', $post),
|
||||
'brd_id' => element('brd_id', $post),
|
||||
);
|
||||
|
||||
if ($mem_id) {
|
||||
if (element('use_anonymous', $board)) {
|
||||
$updatedata['mem_id'] = (-1) * $mem_id;
|
||||
$updatedata['cmt_userid'] = '';
|
||||
$updatedata['cmt_username'] = '익명사용자';
|
||||
$updatedata['cmt_nickname'] = '익명사용자';
|
||||
$updatedata['cmt_email'] = '';
|
||||
$updatedata['cmt_homepage'] = '';
|
||||
} else {
|
||||
$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(
|
||||
abs(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')
|
||||
&& abs(element('mem_id', $post)) !== abs(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(
|
||||
abs(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,
|
||||
'댓글 작성'
|
||||
);
|
||||
}
|
||||
if (element('use_comment_lucky', $board)) {
|
||||
$rand = rand(1,100);
|
||||
if (element('comment_lucky_percent', $board) >= $rand) {
|
||||
$luckypoint = rand(element('comment_lucky_point_min', $board), element('comment_lucky_point_max', $board));
|
||||
$luckytitle = element('board_name', $board) . ' ' . $cmt_id . ' ' . element('comment_lucky_name', $board) . ' 당첨';
|
||||
$point = $this->point->insert_point(
|
||||
$mem_id,
|
||||
$luckypoint,
|
||||
$luckytitle,
|
||||
'lucky-comment',
|
||||
$cmt_id,
|
||||
'럭키포인트'
|
||||
);
|
||||
$metadata = array(
|
||||
'comment-lucky' => $luckypoint,
|
||||
);
|
||||
$this->load->model('Comment_meta_model');
|
||||
$this->Comment_meta_model->save($cmt_id, $metadata);
|
||||
}
|
||||
}
|
||||
|
||||
$emailsendlistadmin = array();
|
||||
$notesendlistadmin = array();
|
||||
$smssendlistadmin = array();
|
||||
$emailsendlistpostwriter = array();
|
||||
$notesendlistpostwriter = array();
|
||||
$smssendlistpostwriter = array();
|
||||
$emailsendlistcmtwriter = array();
|
||||
$notesendlistcmtwriter = array();
|
||||
$smssendlistcmtwriter = array();
|
||||
$post_writer = array();
|
||||
|
||||
if (element('send_email_comment_super_admin', $board)
|
||||
OR element('send_note_comment_super_admin', $board)
|
||||
OR element('send_sms_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)
|
||||
OR element('send_sms_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)
|
||||
OR element('send_sms_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('send_sms_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;
|
||||
}
|
||||
if (element('send_sms_comment_super_admin', $board) && $superadminlist) {
|
||||
foreach ($superadminlist as $key => $value) {
|
||||
$smssendlistadmin[$value['mem_id']] = $value;
|
||||
}
|
||||
}
|
||||
if (element('send_sms_comment_group_admin', $board) && $groupadminlist) {
|
||||
foreach ($groupadminlist as $key => $value) {
|
||||
$smssendlistadmin[$value['mem_id']] = $value;
|
||||
}
|
||||
}
|
||||
if (element('send_sms_comment_board_admin', $board) && $boardadminlist) {
|
||||
foreach ($boardadminlist as $key => $value) {
|
||||
$smssendlistadmin[$value['mem_id']] = $value;
|
||||
}
|
||||
}
|
||||
if (element('send_sms_comment_post_writer', $board)
|
||||
&& element('mem_phone', $post_writer)
|
||||
&& element('mem_receive_sms', $post_writer)) {
|
||||
$smssendlistpostwriter['mem_id'] = element('mem_id', $post_writer);
|
||||
$smssendlistpostwriter['mem_nickname'] = element('mem_nickname', $post_writer);
|
||||
$smssendlistpostwriter['mem_phone'] = element('mem_phone', $post_writer);
|
||||
}
|
||||
if (element('send_sms_comment_comment_writer', $board)
|
||||
&& $this->member->item('mem_phone')
|
||||
&& $this->member->item('mem_receive_sms')) {
|
||||
$smssendlistcmtwriter['mem_id'] = $mem_id;
|
||||
$smssendlistcmtwriter['mem_nickname'] = $this->member->item('mem_nickname');
|
||||
$smssendlistcmtwriter['mem_phone'] = $this->member->item('mem_phone');
|
||||
}
|
||||
|
||||
$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
|
||||
);
|
||||
}
|
||||
if ($smssendlistadmin) {
|
||||
if (file_exists(APPPATH . 'libraries/Smslib.php')) {
|
||||
$this->load->library(array('smslib'));
|
||||
$content = str_replace(
|
||||
$searchconfig,
|
||||
$replaceconfig,
|
||||
$this->cbconfig->item('send_sms_comment_admin_content')
|
||||
);
|
||||
$sender = array(
|
||||
'phone' => $this->cbconfig->item('sms_admin_phone'),
|
||||
);
|
||||
$receiver = array();
|
||||
foreach ($smssendlistadmin as $akey => $aval) {
|
||||
$receiver[] = array(
|
||||
'mem_id' => element('mem_id', $aval),
|
||||
'name' => element('mem_nickname', $aval),
|
||||
'phone' => element('mem_phone', $aval),
|
||||
);
|
||||
}
|
||||
$smsresult = $this->smslib->send($receiver, $sender, $content, $date = '', '댓글 작성 알림');
|
||||
}
|
||||
}
|
||||
if ($smssendlistpostwriter) {
|
||||
if (file_exists(APPPATH . 'libraries/Smslib.php')) {
|
||||
$this->load->library(array('smslib'));
|
||||
$content = str_replace(
|
||||
$searchconfig,
|
||||
$replaceconfig,
|
||||
$this->cbconfig->item('send_sms_comment_post_writer_content')
|
||||
);
|
||||
$sender = array(
|
||||
'phone' => $this->cbconfig->item('sms_admin_phone'),
|
||||
);
|
||||
$receiver = array();
|
||||
$receiver[] = $smssendlistpostwriter;
|
||||
$smsresult = $this->smslib->send($receiver, $sender, $content, $date = '', '댓글 작성 알림');
|
||||
}
|
||||
}
|
||||
if ($smssendlistcmtwriter) {
|
||||
if (file_exists(APPPATH . 'libraries/Smslib.php')) {
|
||||
$this->load->library(array('smslib'));
|
||||
$content = str_replace(
|
||||
$searchconfig,
|
||||
$replaceconfig,
|
||||
$this->cbconfig->item('send_sms_comment_comment_writer_content')
|
||||
);
|
||||
$sender = array(
|
||||
'phone' => $this->cbconfig->item('sms_admin_phone'),
|
||||
);
|
||||
$receiver = array();
|
||||
$receiver[] = $smssendlistcmtwriter;
|
||||
$smsresult = $this->smslib->send($receiver, $sender, $content, $date = '', '댓글 작성 알림');
|
||||
}
|
||||
}
|
||||
|
||||
$this->session->set_userdata(
|
||||
'lastest_post_time',
|
||||
ctimestamp()
|
||||
);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after_insert', $eventname);
|
||||
|
||||
$result = array('success' => '댓글이 등록되었습니다');
|
||||
exit(json_encode($result));
|
||||
|
||||
} else {
|
||||
|
||||
$updatedata = array(
|
||||
'cmt_content' => $cmt_content,
|
||||
'cmt_html' => $content_type,
|
||||
'cmt_updated_datetime' => cdate('Y-m-d H:i:s'),
|
||||
'cmt_ip' => $this->input->ip_address(),
|
||||
);
|
||||
|
||||
if ($can_comment_secret) {
|
||||
$updatedata['cmt_secret'] = $this->input->post('cmt_secret') ? 1 : 0;
|
||||
}
|
||||
if ($this->member->is_member() && element('use_comment_secret', $board) === '2') {
|
||||
$updatedata['cmt_secret'] = 1;
|
||||
}
|
||||
|
||||
$updatedata['cmt_device'] = ($this->cbconfig->get_device_type() === 'mobile')
|
||||
? 'mobile' : 'desktop';
|
||||
|
||||
$this->Comment_model->update($cmt_id, $updatedata);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after_update', $eventname);
|
||||
|
||||
$result = array('success' => '댓글이 수정되었습니다');
|
||||
exit(json_encode($result));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 댓글입력시 비회원이 입력한 경우 닉네임을 체크합니다
|
||||
*/
|
||||
public function _mem_nickname_check($str)
|
||||
{
|
||||
$this->load->helper('chkstring');
|
||||
if (chkstring($str, _HANGUL_ + _ALPHABETIC_ + _NUMERIC_) === false) {
|
||||
$this->form_validation->set_message(
|
||||
'_mem_nickname_check',
|
||||
'닉네임은 공백없이 한글, 영문, 숫자만 입력 가능합니다'
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (preg_match("/[\,]?{$str}/i", $this->cbconfig->item('denied_nickname_list'))) {
|
||||
$this->form_validation->set_message(
|
||||
'_mem_nickname_check',
|
||||
$str . ' 은(는) 예약어로 사용하실 수 없는 닉네임입니다'
|
||||
);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 새로 입력한 패스워드가 규약에 맞는지 체크합니다.
|
||||
*/
|
||||
public function _mem_password_check($str)
|
||||
{
|
||||
$uppercase = $this->cbconfig->item('password_uppercase_length');
|
||||
$number = $this->cbconfig->item('password_numbers_length');
|
||||
$specialchar = $this->cbconfig->item('password_specialchars_length');
|
||||
|
||||
$this->load->helper('chkstring');
|
||||
$str_uc = count_uppercase($str);
|
||||
$str_num = count_numbers($str);
|
||||
$str_spc = count_specialchars($str);
|
||||
|
||||
if ($str_uc < $uppercase OR $str_num < $number OR $str_spc < $specialchar) {
|
||||
|
||||
$description = '비밀번호는 ';
|
||||
if ($str_uc < $uppercase) {
|
||||
$description .= ' ' . $uppercase . '개 이상의 대문자';
|
||||
}
|
||||
if ($str_num < $number) {
|
||||
$description .= ' ' . $number . '개 이상의 숫자';
|
||||
}
|
||||
if ($str_spc < $specialchar) {
|
||||
$description .= ' ' . $specialchar . '개 이상의 특수문자';
|
||||
}
|
||||
$description .= '를 포함해야 합니다';
|
||||
|
||||
$this->form_validation->set_message(
|
||||
'_mem_password_check',
|
||||
$description
|
||||
);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 댓글입력시 비회원이 입력한 경우 captcha를 체크합니다
|
||||
*/
|
||||
public function _check_captcha($str)
|
||||
{
|
||||
$captcha = $this->session->userdata('captcha');
|
||||
if ( ! is_array($captcha) OR ! element('word', $captcha)
|
||||
OR strtolower(element('word', $captcha)) !== strtolower($str)) {
|
||||
$this->session->unset_userdata('captcha');
|
||||
$this->form_validation->set_message(
|
||||
'_check_captcha',
|
||||
'자동등록방지코드가 잘못되었습니다'
|
||||
);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 회원가입시 recaptcha 체크하는 함수입니다
|
||||
*/
|
||||
public function _check_recaptcha($str)
|
||||
{
|
||||
$url = 'https://www.google.com/recaptcha/api/siteverify';
|
||||
$data = array(
|
||||
'secret' => $this->cbconfig->item('recaptcha_secret'),
|
||||
'response' => $str,
|
||||
);
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_POST, sizeof($data));
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
$result = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
|
||||
$obj = json_decode($result);
|
||||
|
||||
if ((string) $obj->success !== '1') {
|
||||
$this->form_validation->set_message(
|
||||
'_check_recaptcha',
|
||||
'자동등록방지코드가 잘못되었습니다'
|
||||
);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
166
application/controllers/Currentvisitor.php
Normal file
166
application/controllers/Currentvisitor.php
Normal file
@@ -0,0 +1,166 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Currentvisitor class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 현재 접속자를 보여주는 controller 입니다.
|
||||
*/
|
||||
class Currentvisitor extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array('Currentvisitor');
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/**
|
||||
* 라이브러리를 로딩합니다
|
||||
*/
|
||||
$this->load->library(array('pagination', 'querystring'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 현재접속자 페이지입니다
|
||||
*/
|
||||
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));
|
||||
}
|
||||
}
|
||||
164
application/controllers/Document.php
Normal file
164
application/controllers/Document.php
Normal file
@@ -0,0 +1,164 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Document class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 일반 문서 페이지를 보여주는 controller 입니다.
|
||||
*/
|
||||
class Document extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array('Document');
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/**
|
||||
* 라이브러리를 로딩합니다
|
||||
*/
|
||||
$this->load->library(array('querystring'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 일반문서를 보여주는 함수입니다
|
||||
*/
|
||||
public function index($doc_key = '')
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_document_index';
|
||||
$this->load->event($eventname);
|
||||
|
||||
$view = array();
|
||||
$view['view'] = array();
|
||||
|
||||
if (empty($doc_key)) {
|
||||
show_404();
|
||||
}
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before'] = Events::trigger('before', $eventname);
|
||||
|
||||
$docinfo = $this->cache->get('document-key-id-info');
|
||||
|
||||
$doc_id = ($docinfo && element($doc_key, $docinfo)) ? element($doc_key, $docinfo) : '';
|
||||
if ($doc_id) {
|
||||
$data = $this->Document_model->get_one($doc_id);
|
||||
} else {
|
||||
$where = array(
|
||||
'doc_key' => $doc_key,
|
||||
);
|
||||
$data = $this->Document_model->get_one('', '', $where);
|
||||
}
|
||||
if ( ! element('doc_id', $data)) {
|
||||
show_404();
|
||||
}
|
||||
|
||||
if ( ! $this->session->userdata('doc_id_' . element('doc_id', $data))) {
|
||||
$this->Document_model->update_hit(element('doc_id', $data));
|
||||
$this->session->set_userdata(
|
||||
'doc_id_' . element('doc_id', $data),
|
||||
'1'
|
||||
);
|
||||
}
|
||||
|
||||
$data['content'] = ($this->cbconfig->get_device_view_type() === 'mobile')
|
||||
? (element('doc_mobile_content', $data) ? element('doc_mobile_content', $data)
|
||||
: element('doc_content', $data)) : element('doc_content', $data);
|
||||
|
||||
$thumb_width = ($this->cbconfig->get_device_view_type() === 'mobile')
|
||||
? $this->cbconfig->item('document_mobile_thumb_width')
|
||||
: $this->cbconfig->item('document_thumb_width');
|
||||
|
||||
$autolink = ($this->cbconfig->get_device_view_type() === 'mobile')
|
||||
? $this->cbconfig->item('use_document_mobile_auto_url')
|
||||
: $this->cbconfig->item('use_document_auto_url');
|
||||
|
||||
$popup = ($this->cbconfig->get_device_view_type() === 'mobile')
|
||||
? $this->cbconfig->item('document_mobile_content_target_blank')
|
||||
: $this->cbconfig->item('document_content_target_blank');
|
||||
|
||||
$data['content'] = display_html_content(
|
||||
element('content', $data),
|
||||
element('doc_content_html_type', $data),
|
||||
$thumb_width,
|
||||
$autolink,
|
||||
$popup,
|
||||
$writer_is_admin = true
|
||||
);
|
||||
$view['view']['data'] = $data;
|
||||
$view['view']['doc_key'] = $doc_key;
|
||||
|
||||
$view['view']['canonical'] = document_url($doc_key);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
|
||||
|
||||
/**
|
||||
* 레이아웃을 정의합니다
|
||||
*/
|
||||
$page_title = $this->cbconfig->item('site_meta_title_document');
|
||||
$meta_description = $this->cbconfig->item('site_meta_description_document');
|
||||
$meta_keywords = $this->cbconfig->item('site_meta_keywords_document');
|
||||
$meta_author = $this->cbconfig->item('site_meta_author_document');
|
||||
$page_name = $this->cbconfig->item('site_page_name_document');
|
||||
|
||||
$searchconfig = array(
|
||||
'{문서제목}',
|
||||
'{문서아이디}',
|
||||
);
|
||||
$replaceconfig = array(
|
||||
element('doc_title', $data),
|
||||
$doc_key,
|
||||
);
|
||||
|
||||
$page_title = str_replace($searchconfig, $replaceconfig, $page_title);
|
||||
$meta_description = str_replace($searchconfig, $replaceconfig, $meta_description);
|
||||
$meta_keywords = str_replace($searchconfig, $replaceconfig, $meta_keywords);
|
||||
$meta_author = str_replace($searchconfig, $replaceconfig, $meta_author);
|
||||
$page_name = str_replace($searchconfig, $replaceconfig, $page_name);
|
||||
|
||||
$layout_dir = element('doc_layout', $data) ? element('doc_layout', $data) : $this->cbconfig->item('layout_document');
|
||||
$mobile_layout_dir = element('doc_mobile_layout', $data) ? element('doc_mobile_layout', $data) : $this->cbconfig->item('mobile_layout_document');
|
||||
$use_sidebar = element('doc_sidebar', $data) ? element('doc_sidebar', $data) : $this->cbconfig->item('sidebar_document');
|
||||
$use_mobile_sidebar = element('doc_mobile_sidebar', $data) ? element('doc_mobile_sidebar', $data) : $this->cbconfig->item('mobile_sidebar_document');
|
||||
$skin_dir = element('doc_skin', $data) ? element('doc_skin', $data) : $this->cbconfig->item('skin_document');
|
||||
$mobile_skin_dir = element('doc_mobile_skin', $data) ? element('doc_mobile_skin', $data) : $this->cbconfig->item('mobile_skin_document');
|
||||
$layoutconfig = array(
|
||||
'path' => 'document',
|
||||
'layout' => 'layout',
|
||||
'skin' => 'document',
|
||||
'layout_dir' => $layout_dir,
|
||||
'mobile_layout_dir' => $mobile_layout_dir,
|
||||
'use_sidebar' => $use_sidebar,
|
||||
'use_mobile_sidebar' => $use_mobile_sidebar,
|
||||
'skin_dir' => $skin_dir,
|
||||
'mobile_skin_dir' => $mobile_skin_dir,
|
||||
'page_title' => $page_title,
|
||||
'meta_description' => $meta_description,
|
||||
'meta_keywords' => $meta_keywords,
|
||||
'meta_author' => $meta_author,
|
||||
'page_name' => $page_name,
|
||||
);
|
||||
$view['layout'] = $this->managelayout->front($layoutconfig, $this->cbconfig->get_device_view_type());
|
||||
$this->data = $view;
|
||||
$this->layout = element('layout_skin_file', element('layout', $view));
|
||||
$this->view = element('view_skin_file', element('layout', $view));
|
||||
}
|
||||
}
|
||||
252
application/controllers/Editorfileupload.php
Normal file
252
application/controllers/Editorfileupload.php
Normal file
@@ -0,0 +1,252 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Editorfileupload class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 에디터를 통해 파일을 업로드하는 controller 입니다.
|
||||
*/
|
||||
class Editorfileupload extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array('Editor_image');
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('array', 'dhtml_editor');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->library('upload');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 스마트 에디터를 통해 이미지를 업로드하는 컨트롤러입니다.
|
||||
*/
|
||||
public function smarteditor($ed_nonce='')
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_editorfileupload_smarteditor';
|
||||
$this->load->event($eventname);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('before', $eventname);
|
||||
|
||||
$this->_init();
|
||||
|
||||
$mem_id = (int) $this->member->item('mem_id');
|
||||
|
||||
$upload_path = config_item('uploads_dir') . '/editor/' . cdate('Y') . '/' . cdate('m') . '/';
|
||||
|
||||
if( ! ft_nonce_is_valid( urldecode($ed_nonce) , 'smarteditor' ) ){
|
||||
exit(json_encode(array('files'=>array('0'=>array('error'=>'토큰오류')))));
|
||||
}
|
||||
|
||||
if (isset($_FILES)
|
||||
&& isset($_FILES['files'])
|
||||
&& isset($_FILES['files']['name'])
|
||||
&& isset($_FILES['files']['name'][0])) {
|
||||
|
||||
$uploadconfig = array(
|
||||
'upload_path' => $upload_path,
|
||||
'allowed_types' => 'jpg|jpeg|png|gif',
|
||||
'max_size' => 10 * 1024,
|
||||
'encrypt_name' => true,
|
||||
);
|
||||
|
||||
$this->upload->initialize($uploadconfig);
|
||||
$upload = isset($_FILES['files']) ? $_FILES['files'] : null;
|
||||
if( is_array( $upload['tmp_name'] ) ){
|
||||
$_FILES['userfile']['name'] = $upload['name'][0];
|
||||
$_FILES['userfile']['type'] = $upload['type'][0];
|
||||
$_FILES['userfile']['tmp_name'] = $upload['tmp_name'][0];
|
||||
$_FILES['userfile']['error'] = $upload['error'][0];
|
||||
$_FILES['userfile']['size'] = $upload['size'][0];
|
||||
} else {
|
||||
if($upload['type'] == "application/octet-stream"){
|
||||
$imageMime = getimagesize($upload['tmp_name']); // get temporary file REAL info
|
||||
$upload['type'] = $imageMime['mime']; //set in our array the correct mime
|
||||
}
|
||||
$_FILES['userfile']['name'] = $upload['name'];
|
||||
$_FILES['userfile']['type'] = $upload['type'];
|
||||
$_FILES['userfile']['tmp_name'] = $upload['tmp_name'];
|
||||
$_FILES['userfile']['error'] = $upload['error'];
|
||||
$_FILES['userfile']['size'] = $upload['size'];
|
||||
}
|
||||
|
||||
if ($this->upload->do_upload()) {
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('doupload', $eventname);
|
||||
|
||||
$filedata = $this->upload->data();
|
||||
$fileupdate = array(
|
||||
'mem_id' => $mem_id,
|
||||
'eim_originname' => element('orig_name', $filedata),
|
||||
'eim_filename' => cdate('Y') . '/' . cdate('m') . '/' . element('file_name', $filedata),
|
||||
'eim_filesize' => intval(element('file_size', $filedata) * 1024),
|
||||
'eim_width' => element('image_width', $filedata) ? element('image_width', $filedata) : 0,
|
||||
'eim_height' => element('image_height', $filedata) ? element('image_height', $filedata) : 0,
|
||||
'eim_type' => str_replace('.', '', element('file_ext', $filedata)),
|
||||
'eim_datetime' => cdate('Y-m-d H:i:s'),
|
||||
'eim_ip' => $this->input->ip_address(),
|
||||
);
|
||||
$image_id = $this->Editor_image_model->insert($fileupdate);
|
||||
|
||||
$image_url = site_url(config_item('uploads_dir') . '/editor/' . cdate('Y') . '/' . cdate('m') . '/' . element('file_name', $filedata));
|
||||
$info = new stdClass();
|
||||
$info->oriname = element('orig_name', $filedata);
|
||||
$info->name = element('file_name', $filedata);
|
||||
$info->size = intval(element('file_size', $filedata) * 1024);
|
||||
$info->type = 'image/' . str_replace('.', '', element('file_ext', $filedata));
|
||||
$info->url = $image_url;
|
||||
$info->width = element('image_width', $filedata)
|
||||
? element('image_width', $filedata) : 0;
|
||||
$info->height = element('image_height', $filedata)
|
||||
? element('image_height', $filedata) : 0;
|
||||
|
||||
$return['files'][0] = $info;
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('doupload_after', $eventname);
|
||||
|
||||
exit(json_encode($return));
|
||||
|
||||
} else {
|
||||
exit($this->upload->display_errors());
|
||||
}
|
||||
} elseif ($this->input->get('file') && $mem_id) {
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('delete_before', $eventname);
|
||||
|
||||
$where = array(
|
||||
'mem_id' => $mem_id,
|
||||
'eim_filename' => cdate('Y') . '/' . cdate('m') . '/' . $this->input->get('file'),
|
||||
'eim_ip' => $this->input->ip_address(),
|
||||
);
|
||||
$image = $this->Editor_image_model->get_one('', '', $where);
|
||||
if (element('eim_filename', $image)) {
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('delete_after', $eventname);
|
||||
|
||||
unlink($upload_path . $this->input->get('file'));
|
||||
$this->Editor_image_model->delete_where($where);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* CK 에디터를 통해 이미지를 업로드하는 컨트롤러입니다.
|
||||
*/
|
||||
public function ckeditor()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_editorfileupload_ckeditor';
|
||||
$this->load->event($eventname);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('before', $eventname);
|
||||
|
||||
$this->_init();
|
||||
|
||||
$mem_id = (int) $this->member->item('mem_id');
|
||||
|
||||
$upload_path = config_item('uploads_dir') . '/editor/' . cdate('Y') . '/' . cdate('m') . '/';
|
||||
|
||||
$uploadconfig = array(
|
||||
'upload_path' => $upload_path,
|
||||
'allowed_types' => 'jpg|jpeg|png|gif',
|
||||
'max_size' => 10 * 1024,
|
||||
'encrypt_name' => true,
|
||||
);
|
||||
|
||||
if (isset($_FILES)
|
||||
&& isset($_FILES['upload'])
|
||||
&& isset($_FILES['upload']['name'])) {
|
||||
|
||||
$this->upload->initialize($uploadconfig);
|
||||
$_FILES['userfile']['name'] = $_FILES['upload']['name'];
|
||||
$_FILES['userfile']['type'] = $_FILES['upload']['type'];
|
||||
$_FILES['userfile']['tmp_name'] = $_FILES['upload']['tmp_name'];
|
||||
$_FILES['userfile']['error'] = $_FILES['upload']['error'];
|
||||
$_FILES['userfile']['size'] = $_FILES['upload']['size'];
|
||||
|
||||
if ($this->upload->do_upload()) {
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('doupload', $eventname);
|
||||
|
||||
$filedata = $this->upload->data();
|
||||
$fileupdate = array(
|
||||
'mem_id' => $mem_id,
|
||||
'eim_originname' => element('orig_name', $filedata),
|
||||
'eim_filename' => cdate('Y') . '/' . cdate('m') . '/' . element('file_name', $filedata),
|
||||
'eim_filesize' => intval(element('file_size', $filedata) * 1024),
|
||||
'eim_width' => element('image_width', $filedata) ? element('image_width', $filedata) : 0,
|
||||
'eim_height' => element('image_height', $filedata) ? element('image_height', $filedata) : 0,
|
||||
'eim_type' => str_replace('.', '', element('file_ext', $filedata)),
|
||||
'eim_datetime' => cdate('Y-m-d H:i:s'),
|
||||
'eim_ip' => $this->input->ip_address(),
|
||||
);
|
||||
$this->Editor_image_model->insert($fileupdate);
|
||||
$image_url = site_url(config_item('uploads_dir') . '/editor/' . cdate('Y') . '/' . cdate('m') . '/' . element('file_name', $filedata));
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('doupload_after', $eventname);
|
||||
|
||||
echo "<script>window.parent.CKEDITOR.tools.callFunction("
|
||||
. $this->input->get('CKEditorFuncNum', null, '') . ", '"
|
||||
. $image_url . "', '업로드완료');</script>";
|
||||
} else {
|
||||
echo $this->upload->display_errors();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function _init()
|
||||
{
|
||||
$upload_path = config_item('uploads_dir') . '/editor/';
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
208
application/controllers/Faq.php
Normal file
208
application/controllers/Faq.php
Normal file
@@ -0,0 +1,208 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Faq class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* FAQ 페이지를 보여주는 controller 입니다.
|
||||
*/
|
||||
class Faq extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array('Faq', 'Faq_group');
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array', 'url');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/**
|
||||
* 라이브러리를 로딩합니다
|
||||
*/
|
||||
$this->load->library(array('pagination', 'querystring'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* FAQ 페이지입니다
|
||||
*/
|
||||
public function index($fgr_key = '')
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_faq_index';
|
||||
$this->load->event($eventname);
|
||||
|
||||
$view = array();
|
||||
$view['view'] = array();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before'] = Events::trigger('before', $eventname);
|
||||
|
||||
if (empty($fgr_key)) {
|
||||
show_404();
|
||||
}
|
||||
|
||||
$where = array(
|
||||
'fgr_key' => $fgr_key,
|
||||
);
|
||||
$faqgroup = $this->Faq_group_model->get_one('', '', $where);
|
||||
|
||||
if ( ! element('fgr_id', $faqgroup)) {
|
||||
show_404();
|
||||
}
|
||||
|
||||
/**
|
||||
* 페이지에 숫자가 아닌 문자가 입력되거나 1보다 작은 숫자가 입력되면 에러 페이지를 보여줍니다.
|
||||
*/
|
||||
$param =& $this->querystring;
|
||||
$page = (((int) $this->input->get('page')) > 0) ? ((int) $this->input->get('page')) : 1;
|
||||
$findex = 'faq_order';
|
||||
$forder = 'asc';
|
||||
$sfield = array('faq_title', 'faq_content', 'faq_mobile_content');
|
||||
$skeyword = $this->input->get('skeyword', null, '');
|
||||
|
||||
$per_page = $this->cbconfig->item('list_count') ? (int) $this->cbconfig->item('list_count') : 20;
|
||||
$offset = ($page - 1) * $per_page;
|
||||
|
||||
/**
|
||||
* 게시판 목록에 필요한 정보를 가져옵니다.
|
||||
*/
|
||||
$this->Faq_model->allow_search_field = array('faq_title', 'faq_content', 'faq_mobile_content'); // 검색이 가능한 필드
|
||||
$this->Faq_model->search_field_equal = array(); // 검색중 like 가 아닌 = 검색을 하는 필드
|
||||
$this->Faq_model->allow_order_field = array('faq_order'); // 정렬이 가능한 필드
|
||||
$where = array(
|
||||
'fgr_id' => element('fgr_id', $faqgroup),
|
||||
);
|
||||
$result = $this->Faq_model
|
||||
->get_list($per_page, $offset, $where, '', $findex, $forder, $sfield, $skeyword);
|
||||
if (element('list', $result)) {
|
||||
foreach (element('list', $result) as $key => $val) {
|
||||
$content = ($this->cbconfig->get_device_view_type() === 'mobile')
|
||||
? (element('faq_mobile_content', $val) ? element('faq_mobile_content', $val)
|
||||
: element('faq_content', $val)) : element('faq_content', $val);
|
||||
|
||||
$thumb_width = ($this->cbconfig->get_device_view_type() === 'mobile')
|
||||
? $this->cbconfig->item('faq_mobile_thumb_width')
|
||||
: $this->cbconfig->item('faq_thumb_width');
|
||||
|
||||
$autolink = ($this->cbconfig->get_device_view_type() === 'mobile')
|
||||
? $this->cbconfig->item('use_faq_mobile_auto_url')
|
||||
: $this->cbconfig->item('use_faq_auto_url');
|
||||
|
||||
$popup = ($this->cbconfig->get_device_view_type() === 'mobile')
|
||||
? $this->cbconfig->item('faq_mobile_content_target_blank')
|
||||
: $this->cbconfig->item('faq_content_target_blank');
|
||||
|
||||
$result['list'][$key]['title'] = display_html_content(
|
||||
element('faq_title', $val),
|
||||
element('faq_content_html_type', $val),
|
||||
$thumb_width,
|
||||
$autolink,
|
||||
$popup,
|
||||
$writer_is_admin = true
|
||||
);
|
||||
|
||||
$result['list'][$key]['content'] = display_html_content(
|
||||
$content,
|
||||
element('faq_content_html_type', $val),
|
||||
$thumb_width,
|
||||
$autolink,
|
||||
$popup,
|
||||
$writer_is_admin = true
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$list_num = $result['total_rows'] - ($page - 1) * $per_page;
|
||||
$view['view']['data'] = $result;
|
||||
$view['view']['faqgroup'] = $faqgroup;
|
||||
|
||||
/**
|
||||
* 페이지네이션을 생성합니다
|
||||
*/
|
||||
$config['base_url'] = faq_url($fgr_key) . '?' . $param->replace('page');
|
||||
$config['total_rows'] = $result['total_rows'];
|
||||
$config['per_page'] = $per_page;
|
||||
$this->pagination->initialize($config);
|
||||
$view['view']['paging'] = $this->pagination->create_links();
|
||||
$view['view']['page'] = $page;
|
||||
|
||||
$view['view']['canonical'] = faq_url($fgr_key);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
|
||||
|
||||
/**
|
||||
* 레이아웃을 정의합니다
|
||||
*/
|
||||
$page_title = $this->cbconfig->item('site_meta_title_faq');
|
||||
$meta_description = $this->cbconfig->item('site_meta_description_faq');
|
||||
$meta_keywords = $this->cbconfig->item('site_meta_keywords_faq');
|
||||
$meta_author = $this->cbconfig->item('site_meta_author_faq');
|
||||
$page_name = $this->cbconfig->item('site_page_name_faq');
|
||||
|
||||
$searchconfig = array(
|
||||
'{FAQ제목}',
|
||||
'{FAQ아이디}',
|
||||
);
|
||||
$replaceconfig = array(
|
||||
element('fgr_title', $faqgroup),
|
||||
$fgr_key,
|
||||
);
|
||||
|
||||
$page_title = str_replace($searchconfig, $replaceconfig, $page_title);
|
||||
$meta_description = str_replace($searchconfig, $replaceconfig, $meta_description);
|
||||
$meta_keywords = str_replace($searchconfig, $replaceconfig, $meta_keywords);
|
||||
$meta_author = str_replace($searchconfig, $replaceconfig, $meta_author);
|
||||
$page_name = str_replace($searchconfig, $replaceconfig, $page_name);
|
||||
|
||||
$layout_dir = element('fgr_layout', $faqgroup) ?
|
||||
element('fgr_layout', $faqgroup) : $this->cbconfig->item('layout_faq');
|
||||
$mobile_layout_dir = element('fgr_mobile_layout', $faqgroup)
|
||||
? element('fgr_mobile_layout', $faqgroup)
|
||||
: $this->cbconfig->item('mobile_layout_faq');
|
||||
$use_sidebar = element('fgr_sidebar', $faqgroup)
|
||||
? element('fgr_sidebar', $faqgroup)
|
||||
: $this->cbconfig->item('sidebar_faq');
|
||||
$use_mobile_sidebar = element('fgr_mobile_sidebar', $faqgroup)
|
||||
? element('fgr_mobile_sidebar', $faqgroup)
|
||||
: $this->cbconfig->item('mobile_sidebar_faq');
|
||||
$skin_dir = element('fgr_skin', $faqgroup)
|
||||
? element('fgr_skin', $faqgroup) : $this->cbconfig->item('skin_faq');
|
||||
$mobile_skin_dir = element('fgr_mobile_skin', $faqgroup)
|
||||
? element('fgr_mobile_skin', $faqgroup) : $this->cbconfig->item('mobile_skin_faq');
|
||||
$layoutconfig = array(
|
||||
'path' => 'faq',
|
||||
'layout' => 'layout',
|
||||
'skin' => 'faq',
|
||||
'layout_dir' => $layout_dir,
|
||||
'mobile_layout_dir' => $mobile_layout_dir,
|
||||
'use_sidebar' => $use_sidebar,
|
||||
'use_mobile_sidebar' => $use_mobile_sidebar,
|
||||
'skin_dir' => $skin_dir,
|
||||
'mobile_skin_dir' => $mobile_skin_dir,
|
||||
'page_title' => $page_title,
|
||||
'meta_description' => $meta_description,
|
||||
'meta_keywords' => $meta_keywords,
|
||||
'meta_author' => $meta_author,
|
||||
'page_name' => $page_name,
|
||||
);
|
||||
$view['layout'] = $this->managelayout->front($layoutconfig, $this->cbconfig->get_device_view_type());
|
||||
$this->data = $view;
|
||||
$this->layout = element('layout_skin_file', element('layout', $view));
|
||||
$this->view = element('view_skin_file', element('layout', $view));
|
||||
}
|
||||
}
|
||||
700
application/controllers/Findaccount.php
Normal file
700
application/controllers/Findaccount.php
Normal file
@@ -0,0 +1,700 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Findaccount class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 회원정보 찾기에 관련도니 controller 입니다.
|
||||
*/
|
||||
class Findaccount extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array( 'Member_auth_email');
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array', 'string');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/**
|
||||
* 라이브러리를 로딩합니다
|
||||
*/
|
||||
$this->load->library(array('querystring', 'email'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 아이디/패스워드찾기 페이지입니다
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_findaccount_index';
|
||||
$this->load->event($eventname);
|
||||
|
||||
if ($this->member->is_member() !== false
|
||||
&& ! (
|
||||
$this->member->is_admin() === 'super' && $this->uri->segment(1) === config_item('uri_segment_admin')
|
||||
)) {
|
||||
redirect();
|
||||
}
|
||||
|
||||
$view = array();
|
||||
$view['view'] = array();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before'] = Events::trigger('before', $eventname);
|
||||
|
||||
$this->load->library(array('form_validation'));
|
||||
|
||||
if ( ! function_exists('password_hash')) {
|
||||
$this->load->helper('password');
|
||||
}
|
||||
|
||||
/**
|
||||
* 전송된 데이터의 유효성을 체크합니다
|
||||
*/
|
||||
$config = array();
|
||||
if ($this->input->post('findtype') === 'findidpw') {
|
||||
$config[] = array(
|
||||
'field' => 'idpw_email',
|
||||
'label' => '이메일',
|
||||
'rules' => 'trim|required|valid_email|callback__existemail',
|
||||
);
|
||||
} elseif ($this->input->post('findtype') === 'verifyemail') {
|
||||
$config[] = array(
|
||||
'field' => 'verify_email',
|
||||
'label' => '이메일',
|
||||
'rules' => 'trim|required|valid_email|callback__verifyemail',
|
||||
);
|
||||
} elseif ($this->input->post('findtype') === 'changeemail') {
|
||||
$config[] = array(
|
||||
'field' => 'change_userid',
|
||||
'label' => '아이디',
|
||||
'rules' => 'trim|required|alphanumunder|min_length[3]|max_length[20]',
|
||||
);
|
||||
$config[] = array(
|
||||
'field' => 'change_password',
|
||||
'label' => '패스워드',
|
||||
'rules' => 'trim|required|callback__check_id_pw[' . $this->input->post('change_userid') . ']',
|
||||
);
|
||||
$config[] = array(
|
||||
'field' => 'change_email',
|
||||
'label' => '이메일',
|
||||
'rules' => 'trim|required|valid_email|callback__change_email',
|
||||
);
|
||||
}
|
||||
|
||||
$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 ($this->input->post('findtype') === 'findidpw') {
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['findidpw_before'] = Events::trigger('findidpw_before', $eventname);
|
||||
|
||||
$mb = $this->Member_model->get_by_email($this->input->post('idpw_email'));
|
||||
if ( ! $mb) {
|
||||
$this->load->model('Member_dormant_model');
|
||||
$mb = $this->Member_dormant_model->get_by_email($this->input->post('idpw_email'));
|
||||
}
|
||||
|
||||
$mem_id = (int) element('mem_id', $mb);
|
||||
$mae_type = 3;
|
||||
|
||||
$vericode = array('$', '/', '.');
|
||||
$verificationcode = str_replace(
|
||||
$vericode,
|
||||
'',
|
||||
password_hash($mem_id . '-' . $this->input->post('idpw_email') . '-' . random_string('alnum', 10), PASSWORD_BCRYPT)
|
||||
);
|
||||
|
||||
$beforeauthdata = array(
|
||||
'mem_id' => $mem_id,
|
||||
'mae_type' => $mae_type,
|
||||
);
|
||||
$this->Member_auth_email_model->delete_where($beforeauthdata);
|
||||
$authdata = array(
|
||||
'mem_id' => $mem_id,
|
||||
'mae_key' => $verificationcode,
|
||||
'mae_type' => $mae_type,
|
||||
'mae_generate_datetime' => cdate('Y-m-d H:i:s'),
|
||||
);
|
||||
$this->Member_auth_email_model->insert($authdata);
|
||||
|
||||
$verify_url = site_url('verify/resetpassword?user=' . element('mem_userid', $mb) . '&code=' . $verificationcode);
|
||||
|
||||
$searchconfig = array(
|
||||
'{홈페이지명}',
|
||||
'{회사명}',
|
||||
'{홈페이지주소}',
|
||||
'{회원아이디}',
|
||||
'{회원닉네임}',
|
||||
'{회원실명}',
|
||||
'{회원이메일}',
|
||||
'{메일수신여부}',
|
||||
'{쪽지수신여부}',
|
||||
'{문자수신여부}',
|
||||
'{회원아이피}',
|
||||
'{패스워드변경주소}',
|
||||
);
|
||||
$receive_email = element('mem_receive_email', $mb) ? '동의' : '거부';
|
||||
$receive_note = element('mem_use_note', $mb) ? '동의' : '거부';
|
||||
$receive_sms = element('mem_receive_sms', $mb) ? '동의' : '거부';
|
||||
$replaceconfig = array(
|
||||
$this->cbconfig->item('site_title'),
|
||||
$this->cbconfig->item('company_name'),
|
||||
site_url(),
|
||||
element('mem_userid', $mb),
|
||||
element('mem_nickname', $mb),
|
||||
element('mem_username', $mb),
|
||||
element('mem_email', $mb),
|
||||
$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(),
|
||||
element('mem_userid', $mb),
|
||||
html_escape(element('mem_nickname', $mb)),
|
||||
html_escape(element('mem_username', $mb)),
|
||||
html_escape(element('mem_email', $mb)),
|
||||
$receive_email,
|
||||
$receive_note,
|
||||
$receive_sms,
|
||||
$this->input->ip_address(),
|
||||
$verify_url,
|
||||
);
|
||||
|
||||
$title = str_replace(
|
||||
$searchconfig,
|
||||
$replaceconfig,
|
||||
$this->cbconfig->item('send_email_findaccount_user_title')
|
||||
);
|
||||
$content = str_replace(
|
||||
$searchconfig,
|
||||
$replaceconfig_escape,
|
||||
$this->cbconfig->item('send_email_findaccount_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('idpw_email'));
|
||||
$this->email->subject($title);
|
||||
$this->email->message($content);
|
||||
$this->email->send();
|
||||
|
||||
$view['view']['message'] = $this->input->post('idpw_email') . '로 인증메일이 발송되었습니다. <br />발송된 인증메일을 확인하신 후에 회원님의 정보 확인이 가능합니다';
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['findidpw_after'] = Events::trigger('findidpw_after', $eventname);
|
||||
|
||||
} elseif ($this->input->post('findtype') === 'verifyemail') {
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['verifyemail_before'] = Events::trigger('verifyemail_before', $eventname);
|
||||
|
||||
$mb = $this->Member_model->get_by_email($this->input->post('verify_email'));
|
||||
if ( ! $mb) {
|
||||
$this->load->model('Member_dormant_model');
|
||||
$mb = $this->Member_dormant_model->get_by_email($this->input->post('verify_email'));
|
||||
}
|
||||
$mem_id = (int) element('mem_id', $mb);
|
||||
$mae_type = 2;
|
||||
|
||||
$vericode = array('$', '/', '.');
|
||||
$verificationcode = str_replace(
|
||||
$vericode,
|
||||
'',
|
||||
password_hash($mem_id . '-' . $this->input->post('verify_email') . '-' . random_string('alnum', 10), PASSWORD_BCRYPT)
|
||||
);
|
||||
|
||||
$beforeauthdata = array(
|
||||
'mem_id' => $mem_id,
|
||||
'mae_type' => $mae_type,
|
||||
);
|
||||
$this->Member_auth_email_model->delete_where($beforeauthdata);
|
||||
$authdata = array(
|
||||
'mem_id' => $mem_id,
|
||||
'mae_key' => $verificationcode,
|
||||
'mae_type' => $mae_type,
|
||||
'mae_generate_datetime' => cdate('Y-m-d H:i:s'),
|
||||
);
|
||||
$this->Member_auth_email_model->insert($authdata);
|
||||
|
||||
$verify_url = site_url('verify/confirmemail?user=' . element('mem_userid', $mb) . '&code=' . $verificationcode);
|
||||
|
||||
$searchconfig = array(
|
||||
'{홈페이지명}',
|
||||
'{회사명}',
|
||||
'{홈페이지주소}',
|
||||
'{회원아이디}',
|
||||
'{회원닉네임}',
|
||||
'{회원실명}',
|
||||
'{회원이메일}',
|
||||
'{메일수신여부}',
|
||||
'{쪽지수신여부}',
|
||||
'{문자수신여부}',
|
||||
'{회원아이피}',
|
||||
'{메일인증주소}',
|
||||
);
|
||||
$receive_email = element('mem_receive_email', $mb) ? '동의' : '거부';
|
||||
$receive_note = element('mem_use_note', $mb) ? '동의' : '거부';
|
||||
$receive_sms = element('mem_receive_sms', $mb) ? '동의' : '거부';
|
||||
$replaceconfig = array(
|
||||
$this->cbconfig->item('site_title'),
|
||||
$this->cbconfig->item('company_name'),
|
||||
site_url(),
|
||||
element('mem_userid', $mb),
|
||||
element('mem_nickname', $mb),
|
||||
element('mem_username', $mb),
|
||||
element('mem_email', $mb),
|
||||
$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(),
|
||||
element('mem_userid', $mb),
|
||||
html_escape(element('mem_nickname', $mb)),
|
||||
html_escape(element('mem_username', $mb)),
|
||||
html_escape(element('mem_email', $mb)),
|
||||
$receive_email,
|
||||
$receive_note,
|
||||
$receive_sms,
|
||||
$this->input->ip_address(),
|
||||
$verify_url,
|
||||
);
|
||||
|
||||
$title = str_replace(
|
||||
$searchconfig,
|
||||
$replaceconfig,
|
||||
$this->cbconfig->item('send_email_resendverify_user_title')
|
||||
);
|
||||
$content = str_replace(
|
||||
$searchconfig,
|
||||
$replaceconfig_escape,
|
||||
$this->cbconfig->item('send_email_resendverify_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('verify_email'));
|
||||
$this->email->subject($title);
|
||||
$this->email->message($content);
|
||||
$this->email->send();
|
||||
|
||||
$view['view']['message'] = $this->input->post('verify_email') . '로 인증메일이 발송되었습니다. <br />발송된 인증메일을 확인하신 후에 사이트 이용이 가능합니다';
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['verifyemail_after'] = Events::trigger('verifyemail_after', $eventname);
|
||||
|
||||
} elseif ($this->input->post('findtype') === 'changeemail') {
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['changeemail_before'] = Events::trigger('changeemail_before', $eventname);
|
||||
|
||||
$mb = $this->Member_model->get_by_userid($this->input->post('change_userid'));
|
||||
if ( ! $mb) {
|
||||
$this->load->model('Member_dormant_model');
|
||||
$mb = $this->Member_dormant_model->get_by_userid($this->input->post('change_userid'));
|
||||
}
|
||||
|
||||
$mem_id = (int) element('mem_id', $mb);
|
||||
$mae_type = 2;
|
||||
|
||||
$vericode = array('$', '/', '.');
|
||||
$verificationcode = str_replace(
|
||||
$vericode,
|
||||
'',
|
||||
password_hash($mem_id . '-' . $this->input->post('change_email') . '-' . random_string('alnum', 10), PASSWORD_BCRYPT)
|
||||
);
|
||||
|
||||
$beforeauthdata = array(
|
||||
'mem_id' => $mem_id,
|
||||
'mae_type' => $mae_type,
|
||||
);
|
||||
$this->Member_auth_email_model->delete_where($beforeauthdata);
|
||||
$authdata = array(
|
||||
'mem_id' => $mem_id,
|
||||
'mae_key' => $verificationcode,
|
||||
'mae_type' => $mae_type,
|
||||
'mae_generate_datetime' => cdate('Y-m-d H:i:s'),
|
||||
);
|
||||
$this->Member_auth_email_model->insert($authdata);
|
||||
|
||||
$searchconfig = array(
|
||||
'{홈페이지명}',
|
||||
'{회사명}',
|
||||
'{홈페이지주소}',
|
||||
'{회원아이디}',
|
||||
'{회원닉네임}',
|
||||
'{회원실명}',
|
||||
'{회원이메일}',
|
||||
'{메일수신여부}',
|
||||
'{쪽지수신여부}',
|
||||
'{문자수신여부}',
|
||||
'{회원아이피}',
|
||||
'{패스워드변경주소}',
|
||||
);
|
||||
$receive_email = element('mem_receive_email', $mb) ? '동의' : '거부';
|
||||
$receive_note = element('mem_use_note', $mb) ? '동의' : '거부';
|
||||
$receive_sms = element('mem_receive_sms', $mb) ? '동의' : '거부';
|
||||
$replaceconfig = array(
|
||||
$this->cbconfig->item('site_title'),
|
||||
$this->cbconfig->item('company_name'),
|
||||
site_url(),
|
||||
element('mem_userid', $mb),
|
||||
element('mem_nickname', $mb),
|
||||
element('mem_username', $mb),
|
||||
element('mem_email', $mb),
|
||||
$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(),
|
||||
element('mem_userid', $mb),
|
||||
html_escape(element('mem_nickname', $mb)),
|
||||
html_escape(element('mem_username', $mb)),
|
||||
html_escape(element('mem_email', $mb)),
|
||||
$receive_email,
|
||||
$receive_note,
|
||||
$receive_sms,
|
||||
$this->input->ip_address(),
|
||||
$verify_url,
|
||||
);
|
||||
|
||||
$title = str_replace(
|
||||
$searchconfig,
|
||||
$replaceconfig,
|
||||
$this->cbconfig->item('send_email_findaccount_user_title')
|
||||
);
|
||||
$content = str_replace(
|
||||
$searchconfig,
|
||||
$replaceconfig_escape,
|
||||
$this->cbconfig->item('send_email_findaccount_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('change_email'));
|
||||
$this->email->subject($title);
|
||||
$this->email->message($content);
|
||||
$this->email->send();
|
||||
|
||||
$view['view']['message'] = $this->input->post('change_email') . '로 인증메일이 발송되었습니다. <br />발송된 인증메일을 확인하신 후에 사이트 이용이 가능합니다';
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['changeemail_after'] = Events::trigger('changeemail_after', $eventname);
|
||||
}
|
||||
}
|
||||
|
||||
$view['view']['canonical'] = site_url('findaccount');
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
|
||||
|
||||
/**
|
||||
* 레이아웃을 정의합니다
|
||||
*/
|
||||
$page_title = $this->cbconfig->item('site_meta_title_findaccount');
|
||||
$meta_description = $this->cbconfig->item('site_meta_description_findaccount');
|
||||
$meta_keywords = $this->cbconfig->item('site_meta_keywords_findaccount');
|
||||
$meta_author = $this->cbconfig->item('site_meta_author_findaccount');
|
||||
$page_name = $this->cbconfig->item('site_page_name_findaccount');
|
||||
|
||||
$layoutconfig = array(
|
||||
'path' => 'findaccount',
|
||||
'layout' => 'layout',
|
||||
'skin' => 'findaccount',
|
||||
'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,
|
||||
'meta_description' => $meta_description,
|
||||
'meta_keywords' => $meta_keywords,
|
||||
'meta_author' => $meta_author,
|
||||
'page_name' => $page_name,
|
||||
);
|
||||
$view['layout'] = $this->managelayout->front($layoutconfig, $this->cbconfig->get_device_view_type());
|
||||
$this->data = $view;
|
||||
$this->layout = element('layout_skin_file', element('layout', $view));
|
||||
$this->view = element('view_skin_file', element('layout', $view));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 존재하는 이메일인지 체크합니다
|
||||
*/
|
||||
public function _existemail($str)
|
||||
{
|
||||
$userinfo = $this->Member_model
|
||||
->get_by_email($str, 'mem_id, mem_email, mem_denied, mem_email_cert');
|
||||
if ( ! $userinfo) {
|
||||
$this->load->model('Member_dormant_model');
|
||||
$userinfo = $this->Member_dormant_model
|
||||
->get_by_email($str, 'mem_id, mem_email, mem_denied, mem_email_cert');
|
||||
}
|
||||
if ( ! element('mem_id', $userinfo)) {
|
||||
$this->form_validation->set_message(
|
||||
'_existemail',
|
||||
'존재하지 않는 이메일주소입니다'
|
||||
);
|
||||
return false;
|
||||
}
|
||||
if (element('mem_denied', $userinfo)) {
|
||||
$this->form_validation->set_message(
|
||||
'_existemail',
|
||||
'회원님의 계정은 접근이 금지되어 있습니다'
|
||||
);
|
||||
return false;
|
||||
} elseif ($this->cbconfig->item('use_register_email_auth') && ! element('mem_email_cert', $userinfo)) {
|
||||
$this->form_validation->set_message(
|
||||
'_existemail',
|
||||
'회원님은 아직 이메일 인증을 받지 않으셨습니다<br> 아래 인증메일 재발송 란에서 이메일을 받아 인증해주시기 바랍니다'
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 이메일이 실제 디비에 존재하는지 체크합니다
|
||||
*/
|
||||
public function _verifyemail($str)
|
||||
{
|
||||
if ( ! $this->cbconfig->item('use_register_email_auth')) {
|
||||
$this->form_validation->set_message(
|
||||
'_verifyemail',
|
||||
'이 웹사이트는 이메일 인증 기능을 사용하고 있지 않습니다'
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
$userinfo = $this->Member_model
|
||||
->get_by_email($str, 'mem_id, mem_email, mem_denied, mem_email_cert');
|
||||
if ( ! $userinfo) {
|
||||
$this->load->model('Member_dormant_model');
|
||||
$userinfo = $this->Member_dormant_model
|
||||
->get_by_email($str, 'mem_id, mem_email, mem_denied, mem_email_cert');
|
||||
}
|
||||
if ( ! element('mem_id', $userinfo)) {
|
||||
$this->form_validation->set_message(
|
||||
'_verifyemail',
|
||||
'존재하지 않는 이메일주소입니다'
|
||||
);
|
||||
return false;
|
||||
}
|
||||
if (element('mem_denied', $userinfo)) {
|
||||
$this->form_validation->set_message(
|
||||
'_verifyemail',
|
||||
'회원님의 계정은 접근이 금지되어 있습니다'
|
||||
);
|
||||
return false;
|
||||
}
|
||||
if (element('mem_email_cert', $userinfo)) {
|
||||
$this->form_validation->set_message(
|
||||
'_verifyemail',
|
||||
'회원님의 계정은 이미 인증이 완료되어 있습니다'
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 이메일 변경시 기존에 다른 회원에 의해 사용되고 있는 이메일인지 체크합니다
|
||||
*/
|
||||
public function _change_email($str)
|
||||
{
|
||||
if ( ! $this->cbconfig->item('use_register_email_auth')) {
|
||||
$this->form_validation->set_message(
|
||||
'_change_email',
|
||||
'이 웹사이트는 이메일 인증 기능을 사용하고 있지 않습니다'
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
$userinfo = $this->Member_model
|
||||
->get_by_email($str, 'mem_id, mem_email, mem_denied, mem_email_cert');
|
||||
if ( ! $userinfo) {
|
||||
$this->load->model('Member_dormant_model');
|
||||
$userinfo = $this->Member_dormant_model
|
||||
->get_by_email($str, 'mem_id, mem_email, mem_denied, mem_email_cert');
|
||||
}
|
||||
if (element('mem_id', $userinfo)) {
|
||||
$this->form_validation->set_message(
|
||||
'_change_email',
|
||||
'이 이메일은 이미 다른 회원에 의해 사용되어지고 있는 이메일입니다'
|
||||
);
|
||||
return false;
|
||||
}
|
||||
if (element('mem_denied', $userinfo)) {
|
||||
$this->form_validation->set_message(
|
||||
'_change_email',
|
||||
'회원님의 계정은 접근이 금지되어 있습니다'
|
||||
);
|
||||
return false;
|
||||
}
|
||||
if (element('mem_email_cert', $userinfo)) {
|
||||
$this->form_validation->set_message(
|
||||
'_change_email',
|
||||
'회원님의 계정은 이미 인증이 완료되어 있습니다'
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 아이디와 패스워드가 일치하는지 체크합니다
|
||||
*/
|
||||
public function _check_id_pw($password, $userid)
|
||||
{
|
||||
if ( ! $this->cbconfig->item('use_register_email_auth')) {
|
||||
$this->form_validation->set_message(
|
||||
'_check_id_pw',
|
||||
'이 웹사이트는 이메일 인증 기능을 사용하고 있지 않습니다'
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
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';
|
||||
$this->load->model('Member_login_log_model');
|
||||
$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);
|
||||
if ( ! $userinfo) {
|
||||
$this->load->model('Member_dormant_model');
|
||||
$userinfo = $this->Member_dormant_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, $userid, 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), $userid, 0, '패스워드가 올바르지 않습니다');
|
||||
|
||||
return false;
|
||||
|
||||
} elseif (element('mem_denied', $userinfo)) {
|
||||
if (element('mem_denied', $userinfo)) {
|
||||
$this->form_validation->set_message(
|
||||
'_check_id_pw',
|
||||
'회원님의 계정은 접근이 금지되어 있습니다'
|
||||
);
|
||||
$this->member->update_login_log(element('mem_id', $userinfo), $userid, 0, '차단된 회원아이디입니다');
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
183
application/controllers/Formmail.php
Normal file
183
application/controllers/Formmail.php
Normal file
@@ -0,0 +1,183 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Formmail class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 다른 회원에게 폼메일 전송시 작동하는 controller 입니다.
|
||||
*/
|
||||
class Formmail extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array();
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array', 'dhtml_editor');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/**
|
||||
* 라이브러리를 로딩합니다
|
||||
*/
|
||||
$this->load->library(array('querystring'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 폼메일 작성 페이지입니다
|
||||
*/
|
||||
public function write($userid = '')
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_formmail_write';
|
||||
$this->load->event($eventname);
|
||||
|
||||
$view = array();
|
||||
$view['view'] = array();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before'] = Events::trigger('before', $eventname);
|
||||
|
||||
/**
|
||||
* 로그인이 필요한 페이지입니다
|
||||
*/
|
||||
required_user_login();
|
||||
|
||||
if ($this->cbconfig->get_device_view_type() !== 'mobile'
|
||||
&& ! $this->cbconfig->item('use_sideview_email')) {
|
||||
alert_close('이메일 기능을 사용하지 않는 사이트입니다');
|
||||
return false;
|
||||
} elseif ($this->cbconfig->get_device_view_type() === 'mobile'
|
||||
&& ! $this->cbconfig->item('use_mobile_sideview_email')) {
|
||||
alert_close('모바일 버전에서는 이메일 기능을 사용하지 않는 사이트입니다');
|
||||
return false;
|
||||
} elseif ( ! $this->member->item('mem_receive_email')
|
||||
&& $this->member->is_admin() !== 'super') {
|
||||
alert_close('회원님은 메일수신에 체크하지 않으셨습니다. 회원정보 수정 페이지에 가셔서, 메일 수신에 체크하신 후에 사용이 가능합니다');
|
||||
return false;
|
||||
}
|
||||
|
||||
if (empty($userid)) {
|
||||
alert_close('상대방이 지정되지 않았습니다');
|
||||
return false;
|
||||
}
|
||||
$view['view']['userid'] = $userid;
|
||||
|
||||
$memberselect = 'mem_id, mem_denied, mem_receive_email, mem_nickname, mem_email';
|
||||
$view['view']['member'] = $member
|
||||
= $this->Member_model->get_by_userid($userid, $memberselect);
|
||||
|
||||
if ( ! element('mem_id', $member)) {
|
||||
alert_close('존재하지 않는 회원 아이디입니다');
|
||||
return false;
|
||||
}
|
||||
if (element('mem_denied', $member)) {
|
||||
alert_close('탈퇴 또는 차단된 회원입니다');
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ! element('mem_receive_email', $member) && $this->member->is_admin() !== 'super') {
|
||||
alert_close(html_escape(element('mem_nickname', $member)) . ' 님은 메일 수신을 원하지 않으십니다');
|
||||
return false;
|
||||
}
|
||||
$view['view']['use_dhtml'] = false;
|
||||
if ($this->cbconfig->item('use_formmail_dhtml')) {
|
||||
$view['view']['use_dhtml'] = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validation 라이브러리를 가져옵니다
|
||||
*/
|
||||
$this->load->library('form_validation');
|
||||
|
||||
/**
|
||||
* 전송된 데이터의 유효성을 체크합니다
|
||||
*/
|
||||
$config = array(
|
||||
array(
|
||||
'field' => 'title',
|
||||
'label' => '제목',
|
||||
'rules' => 'trim|required',
|
||||
),
|
||||
array(
|
||||
'field' => 'content',
|
||||
'label' => '내용',
|
||||
'rules' => 'trim|required',
|
||||
),
|
||||
);
|
||||
$this->form_validation->set_rules($config);
|
||||
|
||||
|
||||
/**
|
||||
* 유효성 검사를 하지 않는 경우, 또는 유효성 검사에 실패한 경우입니다.
|
||||
* 즉 글쓰기나 수정 페이지를 보고 있는 경우입니다
|
||||
*/
|
||||
if ($this->form_validation->run() === false) {
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['formrunfalse'] = Events::trigger('formrunfalse', $eventname);
|
||||
|
||||
/**
|
||||
* 레이아웃을 정의합니다
|
||||
*/
|
||||
$page_title = $this->cbconfig->item('site_meta_title_formmail');
|
||||
$meta_description = $this->cbconfig->item('site_meta_description_formmail');
|
||||
$meta_keywords = $this->cbconfig->item('site_meta_keywords_formmail');
|
||||
$meta_author = $this->cbconfig->item('site_meta_author_formmail');
|
||||
$page_name = $this->cbconfig->item('site_page_name_formmail');
|
||||
|
||||
$layoutconfig = array(
|
||||
'path' => 'formmail',
|
||||
'layout' => 'layout_popup',
|
||||
'skin' => 'formmail',
|
||||
'layout_dir' => $this->cbconfig->item('layout_formmail'),
|
||||
'mobile_layout_dir' => $this->cbconfig->item('mobile_layout_formmail'),
|
||||
'skin_dir' => $this->cbconfig->item('skin_formmail'),
|
||||
'mobile_skin_dir' => $this->cbconfig->item('mobile_skin_formmail'),
|
||||
'page_title' => $page_title,
|
||||
'meta_description' => $meta_description,
|
||||
'meta_keywords' => $meta_keywords,
|
||||
'meta_author' => $meta_author,
|
||||
'page_name' => $page_name,
|
||||
);
|
||||
$view['layout'] = $this->managelayout->front($layoutconfig, $this->cbconfig->get_device_view_type());
|
||||
$this->data = $view;
|
||||
$this->layout = element('layout_skin_file', element('layout', $view));
|
||||
$this->view = element('view_skin_file', element('layout', $view));
|
||||
|
||||
} else {
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['formruntrue'] = Events::trigger('formruntrue', $eventname);
|
||||
|
||||
// 메일 발송
|
||||
$this->load->library('email');
|
||||
$this->email->from($this->member->item('mem_email'), $this->member->item('mem_nickname'));
|
||||
$this->email->to(element('mem_email', $member));
|
||||
|
||||
$this->email->subject($this->input->post('title'));
|
||||
$content_type = $this->cbconfig->item('use_formmail_dhtml') ? 1 : 0;
|
||||
$this->email->message(display_html_content(
|
||||
$this->input->post('content'),
|
||||
$content_type,
|
||||
800
|
||||
));
|
||||
$this->email->send();
|
||||
|
||||
alert_close(element('mem_nickname', $member) . ' 님에게 메일을 발송하였습니다. ');
|
||||
}
|
||||
}
|
||||
}
|
||||
103
application/controllers/Gotourl.php
Normal file
103
application/controllers/Gotourl.php
Normal file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Gotourl class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 다른 페이지로 이동시 중간에 거쳐가는 controller 입니다.
|
||||
* admin 페이지에서 외부 페이이지로 이동시 이 페이지를 거쳐가면 referer 가 이 주소로 남기 때문에 admin 주소를 referer 에서 감출 수 있습니다
|
||||
*/
|
||||
class Gotourl extends CB_Controller
|
||||
{
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* url 이동 관련 함수입니다
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_gotourl_index';
|
||||
$this->load->event($eventname);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('before', $eventname);
|
||||
|
||||
$url = $this->input->get('url');
|
||||
if (empty($url)) {
|
||||
$url = '/';
|
||||
}
|
||||
redirect($url, 'refresh');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* banner url 이동 관련 함수입니다
|
||||
*/
|
||||
public function banner($ban_id = 0)
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_gotourl_banner';
|
||||
$this->load->event($eventname);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('before', $eventname);
|
||||
|
||||
$ban_id = (int) $ban_id;
|
||||
if (empty($ban_id) OR $ban_id < 1) {
|
||||
show_404();
|
||||
}
|
||||
|
||||
$this->load->model(array('Banner_model'));
|
||||
|
||||
$banner = $this->Banner_model->get_one($ban_id);
|
||||
if ( ! element('ban_id', $banner)) {
|
||||
show_404();
|
||||
}
|
||||
if ( ! element('ban_activated', $banner)) {
|
||||
show_404();
|
||||
}
|
||||
if ( ! element('ban_url', $banner)) {
|
||||
show_404();
|
||||
}
|
||||
|
||||
if ( ! $this->session->userdata('banner_click_' . $ban_id )) {
|
||||
|
||||
$this->session->set_userdata(
|
||||
'banner_click_' . $ban_id,
|
||||
'1'
|
||||
);
|
||||
|
||||
$mem_id = (int) $this->member->item('mem_id');
|
||||
$insertdata = array(
|
||||
'ban_id' => element('ban_id', $banner),
|
||||
'mem_id' => $mem_id,
|
||||
'bcl_datetime' => cdate('Y-m-d H:i:s'),
|
||||
'bcl_ip' => $this->input->ip_address(),
|
||||
'bcl_referer' => $this->agent->referrer(),
|
||||
'bcl_url' => element('ban_url', $banner),
|
||||
'bcl_useragent' => $this->agent->agent_string(),
|
||||
);
|
||||
$this->load->model(array('Banner_click_log_model'));
|
||||
$this->Banner_click_log_model->insert($insertdata);
|
||||
|
||||
$this->Banner_model->update_plus($ban_id, 'ban_hit', 1);
|
||||
}
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after', $eventname);
|
||||
|
||||
redirect(prep_url(element('ban_url', $banner)));
|
||||
}
|
||||
}
|
||||
146
application/controllers/Group.php
Normal file
146
application/controllers/Group.php
Normal file
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Group class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 게시판 그룹 메인을 담당하는 controller 입니다.
|
||||
*/
|
||||
class Group extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array('Board');
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/**
|
||||
* 라이브러리를 로딩합니다
|
||||
*/
|
||||
$this->load->library(array('querystring', 'board_group'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 게시판 그룹 페이지입니다
|
||||
*/
|
||||
public function index($bgr_key = '')
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_group_index';
|
||||
$this->load->event($eventname);
|
||||
|
||||
if (empty($bgr_key)) {
|
||||
show_404();
|
||||
}
|
||||
|
||||
$view = array();
|
||||
$view['view'] = array();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before'] = Events::trigger('before', $eventname);
|
||||
|
||||
$group_id = $this->board_group->item_key('bgr_id', $bgr_key);
|
||||
if (empty($group_id)) {
|
||||
show_404();
|
||||
}
|
||||
|
||||
$group = $this->board_group->item_all($group_id);
|
||||
|
||||
$select = 'brd_id';
|
||||
$where = array(
|
||||
'bgr_id' => element('bgr_id', $group),
|
||||
'brd_search' => 1,
|
||||
);
|
||||
$board_id = $this->Board_model->get_board_list($where);
|
||||
$board_list = array();
|
||||
if ($board_id && is_array($board_id)) {
|
||||
foreach ($board_id as $key => $val) {
|
||||
$board_list[] = $this->board->item_all(element('brd_id', $val));
|
||||
}
|
||||
}
|
||||
|
||||
$group['headercontent'] = ($this->cbconfig->get_device_view_type() === 'mobile')
|
||||
? element('mobile_header_content', $group)
|
||||
: element('header_content', $group);
|
||||
|
||||
$group['footercontent'] = ($this->cbconfig->get_device_view_type() === 'mobile')
|
||||
? element('mobile_footer_content', $group)
|
||||
: element('footer_content', $group);
|
||||
|
||||
$view['view']['group'] = $group;
|
||||
|
||||
$view['view']['board_list'] = $board_list;
|
||||
|
||||
$view['view']['canonical'] = group_url($bgr_key);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
|
||||
|
||||
/**
|
||||
* 레이아웃을 정의합니다
|
||||
*/
|
||||
$page_title = $this->cbconfig->item('site_meta_title_group');
|
||||
$meta_description = $this->cbconfig->item('site_meta_description_group');
|
||||
$meta_keywords = $this->cbconfig->item('site_meta_keywords_group');
|
||||
$meta_author = $this->cbconfig->item('site_meta_author_group');
|
||||
$page_name = $this->cbconfig->item('site_page_name_group');
|
||||
|
||||
$searchconfig = array(
|
||||
'{그룹명}',
|
||||
'{그룹아이디}',
|
||||
);
|
||||
$replaceconfig = array(
|
||||
element('bgr_name', $group),
|
||||
$bgr_key,
|
||||
);
|
||||
|
||||
$page_title = str_replace($searchconfig, $replaceconfig, $page_title);
|
||||
$meta_description = str_replace($searchconfig, $replaceconfig, $meta_description);
|
||||
$meta_keywords = str_replace($searchconfig, $replaceconfig, $meta_keywords);
|
||||
$meta_author = str_replace($searchconfig, $replaceconfig, $meta_author);
|
||||
$page_name = str_replace($searchconfig, $replaceconfig, $page_name);
|
||||
|
||||
$layout_dir = element('group_layout', $group) ? element('group_layout', $group) : $this->cbconfig->item('layout_group');
|
||||
$mobile_layout_dir = element('group_mobile_layout', $group) ? element('group_mobile_layout', $group) : $this->cbconfig->item('mobile_layout_group');
|
||||
$use_sidebar = element('group_sidebar', $group) ? element('group_sidebar', $group) : $this->cbconfig->item('sidebar_group');
|
||||
$use_mobile_sidebar = element('group_mobile_sidebar', $group) ? element('group_mobile_sidebar', $group) : $this->cbconfig->item('mobile_sidebar_group');
|
||||
$skin_dir = element('group_skin', $group) ? element('group_skin', $group) : $this->cbconfig->item('skin_group');
|
||||
$mobile_skin_dir = element('group_mobile_skin', $group) ? element('group_mobile_skin', $group) : $this->cbconfig->item('mobile_skin_group');
|
||||
$layoutconfig = array(
|
||||
'path' => 'group',
|
||||
'layout' => 'layout',
|
||||
'skin' => 'group',
|
||||
'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));
|
||||
}
|
||||
}
|
||||
1159
application/controllers/Helptool.php
Normal file
1159
application/controllers/Helptool.php
Normal file
File diff suppressed because it is too large
Load Diff
4671
application/controllers/Install.php
Normal file
4671
application/controllers/Install.php
Normal file
File diff suppressed because it is too large
Load Diff
396
application/controllers/Login.php
Normal file
396
application/controllers/Login.php
Normal file
@@ -0,0 +1,396 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Login class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 로그인 페이지와 관련된 controller 입니다.
|
||||
*/
|
||||
class Login extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array();
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array', 'string');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 로그인 페이지입니다
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_login_index';
|
||||
$this->load->event($eventname);
|
||||
|
||||
if ($this->member->is_member() !== false && ! ($this->member->is_admin() === 'super' && $this->uri->segment(1) === config_item('uri_segment_admin'))) {
|
||||
redirect();
|
||||
}
|
||||
|
||||
$view = array();
|
||||
$view['view'] = array();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before'] = Events::trigger('before', $eventname);
|
||||
|
||||
$this->load->library(array('form_validation'));
|
||||
|
||||
if ( ! function_exists('password_hash')) {
|
||||
$this->load->helper('password');
|
||||
}
|
||||
|
||||
$use_login_account = $this->cbconfig->item('use_login_account');
|
||||
|
||||
/**
|
||||
* 전송된 데이터의 유효성을 체크합니다
|
||||
*/
|
||||
if ($use_login_account === 'both') {
|
||||
$config[] = array(
|
||||
'field' => 'mem_userid',
|
||||
'label' => '아이디 또는 이메일',
|
||||
'rules' => 'trim|required',
|
||||
);
|
||||
$view['view']['userid_label_text'] = '아이디 또는 이메일';
|
||||
} elseif ($use_login_account === 'email') {
|
||||
$config[] = array(
|
||||
'field' => 'mem_userid',
|
||||
'label' => '이메일',
|
||||
'rules' => 'trim|required|valid_email',
|
||||
);
|
||||
$view['view']['userid_label_text'] = '이메일';
|
||||
} else {
|
||||
$config[] = array(
|
||||
'field' => 'mem_userid',
|
||||
'label' => '아이디',
|
||||
'rules' => 'trim|required|alphanumunder|min_length[3]|max_length[20]',
|
||||
);
|
||||
$view['view']['userid_label_text'] = '아이디';
|
||||
}
|
||||
$config[] = array(
|
||||
'field' => 'mem_password',
|
||||
'label' => '패스워드',
|
||||
'rules' => 'trim|required|min_length[4]|callback__check_id_pw[' . $this->input->post('mem_userid') . ']',
|
||||
);
|
||||
|
||||
$this->form_validation->set_rules($config);
|
||||
/**
|
||||
* 유효성 검사를 하지 않는 경우, 또는 유효성 검사에 실패한 경우입니다.
|
||||
* 즉 글쓰기나 수정 페이지를 보고 있는 경우입니다
|
||||
*/
|
||||
if ($this->form_validation->run() === false) {
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['formrunfalse'] = Events::trigger('formrunfalse', $eventname);
|
||||
|
||||
if ($this->input->post('returnurl')) {
|
||||
if (validation_errors('<div class="alert alert-warning" role="alert">', '</div>')) {
|
||||
$this->session->set_flashdata(
|
||||
'loginvalidationmessage',
|
||||
validation_errors('<div class="alert alert-warning" role="alert">', '</div>')
|
||||
);
|
||||
}
|
||||
$this->session->set_flashdata(
|
||||
'loginuserid',
|
||||
$this->input->post('mem_userid')
|
||||
);
|
||||
redirect(urldecode($this->input->post('returnurl')));
|
||||
}
|
||||
|
||||
$view['view']['canonical'] = site_url('login');
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
|
||||
|
||||
/**
|
||||
* 레이아웃을 정의합니다
|
||||
*/
|
||||
$page_title = $this->cbconfig->item('site_meta_title_login');
|
||||
$meta_description = $this->cbconfig->item('site_meta_description_login');
|
||||
$meta_keywords = $this->cbconfig->item('site_meta_keywords_login');
|
||||
$meta_author = $this->cbconfig->item('site_meta_author_login');
|
||||
$page_name = $this->cbconfig->item('site_page_name_login');
|
||||
|
||||
$layoutconfig = array(
|
||||
'path' => 'login',
|
||||
'layout' => 'layout',
|
||||
'skin' => 'login',
|
||||
'layout_dir' => $this->cbconfig->item('layout_login'),
|
||||
'mobile_layout_dir' => $this->cbconfig->item('mobile_layout_login'),
|
||||
'use_sidebar' => $this->cbconfig->item('sidebar_login'),
|
||||
'use_mobile_sidebar' => $this->cbconfig->item('mobile_sidebar_login'),
|
||||
'skin_dir' => $this->cbconfig->item('skin_login'),
|
||||
'mobile_skin_dir' => $this->cbconfig->item('mobile_skin_login'),
|
||||
'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);
|
||||
|
||||
if ($use_login_account === 'both') {
|
||||
$userinfo = $this->Member_model->get_by_both($this->input->post('mem_userid'), 'mem_id, mem_userid');
|
||||
} elseif ($use_login_account === 'email') {
|
||||
$userinfo = $this->Member_model->get_by_email($this->input->post('mem_userid'), 'mem_id, mem_userid');
|
||||
} else {
|
||||
$userinfo = $this->Member_model->get_by_userid($this->input->post('mem_userid'), 'mem_id, mem_userid');
|
||||
}
|
||||
$this->member->update_login_log(element('mem_id', $userinfo), $this->input->post('mem_userid'), 1, '로그인 성공');
|
||||
$this->session->set_userdata(
|
||||
'mem_id',
|
||||
element('mem_id', $userinfo)
|
||||
);
|
||||
|
||||
if ($this->input->post('autologin')) {
|
||||
$vericode = array('$', '/', '.');
|
||||
$hash = str_replace(
|
||||
$vericode,
|
||||
'',
|
||||
password_hash(random_string('alnum', 10) . element('mem_id', $userinfo) . ctimestamp() . element('mem_userid', $userinfo), PASSWORD_BCRYPT)
|
||||
);
|
||||
$insertautologin = array(
|
||||
'mem_id' => element('mem_id', $userinfo),
|
||||
'aul_key' => $hash,
|
||||
'aul_ip' => $this->input->ip_address(),
|
||||
'aul_datetime' => cdate('Y-m-d H:i:s'),
|
||||
);
|
||||
$this->load->model(array('Autologin_model'));
|
||||
$this->Autologin_model->insert($insertautologin);
|
||||
|
||||
$cookie_name = 'autologin';
|
||||
$cookie_value = $hash;
|
||||
$cookie_expire = 2592000; // 30일간 저장
|
||||
set_cookie($cookie_name, $cookie_value, $cookie_expire);
|
||||
}
|
||||
|
||||
$change_password_date = $this->cbconfig->item('change_password_date');
|
||||
$site_title = $this->cbconfig->item('site_title');
|
||||
if ($change_password_date) {
|
||||
|
||||
$meta_change_pw_datetime = $this->member->item('meta_change_pw_datetime');
|
||||
if ( ctimestamp() - strtotime($meta_change_pw_datetime) > $change_password_date * 86400) {
|
||||
$this->session->set_userdata(
|
||||
'membermodify',
|
||||
'1'
|
||||
);
|
||||
$this->session->set_flashdata(
|
||||
'message',
|
||||
html_escape($site_title) . ' 은(는) 회원님의 비밀번호를 주기적으로 변경하도록 권장합니다.
|
||||
<br /> 오래된 비밀번호를 사용중인 회원님께서는 안전한 서비스 이용을 위해 비밀번호 변경을 권장합니다'
|
||||
);
|
||||
redirect('membermodify/password_modify');
|
||||
}
|
||||
}
|
||||
|
||||
$url_after_login = $this->cbconfig->item('url_after_login');
|
||||
if ($url_after_login) {
|
||||
$url_after_login = site_url($url_after_login);
|
||||
}
|
||||
if (empty($url_after_login)) {
|
||||
$url_after_login = $this->input->get_post('url') ? urldecode($this->input->get_post('url')) : site_url();
|
||||
}
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after', $eventname);
|
||||
|
||||
redirect($url_after_login);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 로그인시 아이디와 패스워드가 일치하는지 체크합니다
|
||||
*/
|
||||
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),
|
||||
);
|
||||
$this->load->model('Member_login_log_model');
|
||||
$logindata = $this->Member_login_log_model
|
||||
->get('', $select, $where, '', '', 'mll_id', 'DESC');
|
||||
|
||||
if ($logindata && is_array($logindata)) {
|
||||
foreach ($logindata as $key => $val) {
|
||||
if ((int) $val['mll_success'] === 0) {
|
||||
$loginfailnum++;
|
||||
} elseif ((int) $val['mll_success'] === 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)
|
||||
. '회 연속으로 패스워드를 잘못입력하셨습니다. ';
|
||||
}
|
||||
|
||||
$use_login_account = $this->cbconfig->item('use_login_account');
|
||||
|
||||
$this->load->model(array('Member_dormant_model'));
|
||||
|
||||
$userselect = 'mem_id, mem_password, mem_denied, mem_email_cert, mem_is_admin';
|
||||
$is_dormant_member = false;
|
||||
if ($use_login_account === 'both') {
|
||||
$userinfo = $this->Member_model->get_by_both($userid, $userselect);
|
||||
if ( ! $userinfo) {
|
||||
$userinfo = $this->Member_dormant_model->get_by_both($userid, $userselect);
|
||||
if ($userinfo) {
|
||||
$is_dormant_member = true;
|
||||
}
|
||||
}
|
||||
} elseif ($use_login_account === 'email') {
|
||||
$userinfo = $this->Member_model->get_by_email($userid, $userselect);
|
||||
if ( ! $userinfo) {
|
||||
$userinfo = $this->Member_dormant_model->get_by_email($userid, $userselect);
|
||||
if ($userinfo) {
|
||||
$is_dormant_member = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$userinfo = $this->Member_model->get_by_userid($userid, $userselect);
|
||||
if ( ! $userinfo) {
|
||||
$userinfo = $this->Member_dormant_model->get_by_userid($userid, $userselect);
|
||||
if ($userinfo) {
|
||||
$is_dormant_member = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
$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, $userid, 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), $userid, 0, '패스워드가 올바르지 않습니다');
|
||||
return false;
|
||||
} elseif (element('mem_denied', $userinfo)) {
|
||||
$this->form_validation->set_message(
|
||||
'_check_id_pw',
|
||||
'회원님의 아이디는 접근이 금지된 아이디입니다'
|
||||
);
|
||||
$this->member->update_login_log(element('mem_id', $userinfo), $userid, 0, '접근이 금지된 아이디입니다');
|
||||
return false;
|
||||
} elseif ($this->cbconfig->item('use_register_email_auth') && ! element('mem_email_cert', $userinfo)) {
|
||||
$this->form_validation->set_message(
|
||||
'_check_id_pw',
|
||||
'회원님은 아직 이메일 인증을 받지 않으셨습니다'
|
||||
);
|
||||
$this->member->update_login_log(element('mem_id', $userinfo), $userid, 0, '이메일 인증을 받지 않은 회원아이디입니다');
|
||||
return false;
|
||||
} elseif (element('mem_is_admin', $userinfo) && $this->input->post('autologin')) {
|
||||
$this->form_validation->set_message(
|
||||
'_check_id_pw',
|
||||
'최고관리자는 자동로그인 기능을 사용할 수 없습니다'
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($is_dormant_member === true) {
|
||||
$this->member->recover_from_dormant(element('mem_id', $userinfo));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 로그아웃합니다
|
||||
*/
|
||||
public function logout()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_logout_index';
|
||||
$this->load->event($eventname);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('before', $eventname);
|
||||
|
||||
if ($this->member->is_member() === false) {
|
||||
redirect();
|
||||
}
|
||||
|
||||
$where = array(
|
||||
'mem_id' => $this->member->item('mem_id'),
|
||||
);
|
||||
$this->load->model(array('Autologin_model'));
|
||||
$this->Autologin_model->delete_where($where);
|
||||
|
||||
delete_cookie('autologin');
|
||||
|
||||
$this->session->sess_destroy();
|
||||
$url_after_logout = $this->cbconfig->item('url_after_logout');
|
||||
if ($url_after_logout) {
|
||||
$url_after_logout = site_url($url_after_logout);
|
||||
}
|
||||
if (empty($url_after_logout)) {
|
||||
$url_after_logout = $this->input->get_post('url') ? $this->input->get_post('url') : site_url();
|
||||
}
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after', $eventname);
|
||||
|
||||
redirect($url_after_logout, 'refresh');
|
||||
}
|
||||
}
|
||||
100
application/controllers/Main.php
Normal file
100
application/controllers/Main.php
Normal file
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Main class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 메인 페이지를 담당하는 controller 입니다.
|
||||
*/
|
||||
class Main extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array('Board');
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/**
|
||||
* 라이브러리를 로딩합니다
|
||||
*/
|
||||
$this->load->library(array('querystring'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 전체 메인 페이지입니다
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_main_index';
|
||||
$this->load->event($eventname);
|
||||
|
||||
$view = array();
|
||||
$view['view'] = array();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before'] = Events::trigger('before', $eventname);
|
||||
|
||||
$where = array(
|
||||
'brd_search' => 1,
|
||||
);
|
||||
$board_id = $this->Board_model->get_board_list($where);
|
||||
$board_list = array();
|
||||
if ($board_id && is_array($board_id)) {
|
||||
foreach ($board_id as $key => $val) {
|
||||
$board_list[] = $this->board->item_all(element('brd_id', $val));
|
||||
}
|
||||
}
|
||||
$view['view']['board_list'] = $board_list;
|
||||
$view['view']['canonical'] = site_url();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
|
||||
|
||||
/**
|
||||
* 레이아웃을 정의합니다
|
||||
*/
|
||||
$page_title = $this->cbconfig->item('site_meta_title_main');
|
||||
$meta_description = $this->cbconfig->item('site_meta_description_main');
|
||||
$meta_keywords = $this->cbconfig->item('site_meta_keywords_main');
|
||||
$meta_author = $this->cbconfig->item('site_meta_author_main');
|
||||
$page_name = $this->cbconfig->item('site_page_name_main');
|
||||
|
||||
$layoutconfig = array(
|
||||
'path' => 'main',
|
||||
'layout' => 'layout',
|
||||
'skin' => 'main',
|
||||
'layout_dir' => $this->cbconfig->item('layout_main'),
|
||||
'mobile_layout_dir' => $this->cbconfig->item('mobile_layout_main'),
|
||||
'use_sidebar' => $this->cbconfig->item('sidebar_main'),
|
||||
'use_mobile_sidebar' => $this->cbconfig->item('mobile_sidebar_main'),
|
||||
'skin_dir' => $this->cbconfig->item('skin_main'),
|
||||
'mobile_skin_dir' => $this->cbconfig->item('mobile_skin_main'),
|
||||
'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));
|
||||
}
|
||||
}
|
||||
2076
application/controllers/Membermodify.php
Normal file
2076
application/controllers/Membermodify.php
Normal file
File diff suppressed because it is too large
Load Diff
1170
application/controllers/Mypage.php
Normal file
1170
application/controllers/Mypage.php
Normal file
File diff suppressed because it is too large
Load Diff
762
application/controllers/Note.php
Normal file
762
application/controllers/Note.php
Normal file
@@ -0,0 +1,762 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Note class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 쪽지 목록, 쪽지 읽기, 쪽지 발송과 관련된 controller 입니다.
|
||||
*/
|
||||
class Note extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array('Note');
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array', 'dhtml_editor');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/**
|
||||
* 라이브러리를 로딩합니다
|
||||
*/
|
||||
$this->load->library(array('pagination', 'querystring', 'notelib'));
|
||||
|
||||
if ($this->member->item('mem_id') && $this->member->item('meta_note_received_datetime')) {
|
||||
$this->load->model('Member_meta_model');
|
||||
$metadata = array(
|
||||
'meta_note_received_datetime' => '',
|
||||
'meta_note_received_from_id' => '',
|
||||
'meta_note_received_from_nickname' => '',
|
||||
);
|
||||
$this->Member_meta_model->save($this->member->item('mem_id'), $metadata);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 쪽지 목록 페이지입니다
|
||||
*/
|
||||
public function lists($type = 'recv')
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_note_lists';
|
||||
$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);
|
||||
|
||||
if ( ! $this->cbconfig->item('use_note')) {
|
||||
alert_close('쪽지 기능을 사용하지 않는 사이트입니다');
|
||||
return false;
|
||||
} elseif ( ! $this->member->item('mem_use_note') && $this->member->is_admin() !== 'super') {
|
||||
alert_close('회원님은 쪽지 기능을 사용하지 않는 중이십니다');
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($type !== 'send') {
|
||||
$type = 'recv';
|
||||
}
|
||||
$nte_type = ($type === 'send') ? 2 : 1;
|
||||
$mem_column = ($type === 'send') ? 'recv_mem_id' : 'send_mem_id';
|
||||
$my_column = ($type === 'send') ? 'send_mem_id' : 'recv_mem_id';
|
||||
|
||||
/**
|
||||
* 페이지에 숫자가 아닌 문자가 입력되거나 1보다 작은 숫자가 입력되면 에러 페이지를 보여줍니다.
|
||||
*/
|
||||
$param =& $this->querystring;
|
||||
$page = (((int) $this->input->get('page')) > 0) ? ((int) $this->input->get('page')) : 1;
|
||||
$findex = $this->Note_model->primary_key;
|
||||
$forder = 'desc';
|
||||
|
||||
if ($this->cbconfig->get_device_view_type() === 'mobile') {
|
||||
$per_page = $this->cbconfig->item('note_mobile_list_page')
|
||||
? (int) $this->cbconfig->item('note_mobile_list_page') : 10;
|
||||
} else {
|
||||
$per_page = $this->cbconfig->item('note_list_page')
|
||||
? (int) $this->cbconfig->item('note_list_page') : 10;
|
||||
}
|
||||
$offset = ($page - 1) * $per_page;
|
||||
|
||||
/**
|
||||
* 게시판 목록에 필요한 정보를 가져옵니다.
|
||||
*/
|
||||
$where = array(
|
||||
$my_column => $mem_id,
|
||||
'nte_type' => $nte_type,
|
||||
);
|
||||
if ($type === 'send') {
|
||||
$result = $this->Note_model
|
||||
->get_send_list($per_page, $offset, $where, '', $findex, $forder);
|
||||
} else {
|
||||
$result = $this->Note_model
|
||||
->get_recv_list($per_page, $offset, $where, '', $findex, $forder);
|
||||
}
|
||||
$list_num = $result['total_rows'] - ($page - 1) * $per_page;
|
||||
|
||||
if (element('list', $result)) {
|
||||
foreach (element('list', $result) as $key => $val) {
|
||||
if ($val[$mem_column]) {
|
||||
$result['list'][$key]['display_name'] = display_username(
|
||||
element('mem_userid', $val),
|
||||
element('mem_nickname', $val),
|
||||
element('mem_icon', $val)
|
||||
);
|
||||
} else {
|
||||
$result['list'][$key]['display_name'] = '알림';
|
||||
}
|
||||
$result['list'][$key]['delete_url'] = site_url('note/delete/' . element('nte_type', $val) . '/' . element('nte_id', $val));
|
||||
$result['list'][$key]['num'] = $list_num--;
|
||||
}
|
||||
}
|
||||
$view['view']['data'] = $result;
|
||||
$view['view']['type'] = $type;
|
||||
|
||||
/**
|
||||
* 페이지네이션을 생성합니다
|
||||
*/
|
||||
$config['base_url'] = site_url('note/lists/' . $type) . '?' . $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('note/lists/' . $type);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
|
||||
|
||||
/**
|
||||
* 레이아웃을 정의합니다
|
||||
*/
|
||||
$page_title = $this->cbconfig->item('site_meta_title_note_list');
|
||||
$meta_description = $this->cbconfig->item('site_meta_description_note_list');
|
||||
$meta_keywords = $this->cbconfig->item('site_meta_keywords_note_list');
|
||||
$meta_author = $this->cbconfig->item('site_meta_author_note_list');
|
||||
$page_name = $this->cbconfig->item('site_page_name_note_list');
|
||||
|
||||
$layoutconfig = array(
|
||||
'path' => 'note',
|
||||
'layout' => 'layout_popup',
|
||||
'skin' => 'lists',
|
||||
'layout_dir' => $this->cbconfig->item('layout_note'),
|
||||
'mobile_layout_dir' => $this->cbconfig->item('mobile_layout_note'),
|
||||
'skin_dir' => $this->cbconfig->item('skin_note'),
|
||||
'mobile_skin_dir' => $this->cbconfig->item('mobile_skin_note'),
|
||||
'page_title' => $page_title,
|
||||
'meta_description' => $meta_description,
|
||||
'meta_keywords' => $meta_keywords,
|
||||
'meta_author' => $meta_author,
|
||||
'page_name' => $page_name,
|
||||
);
|
||||
$view['layout'] = $this->managelayout->front($layoutconfig, $this->cbconfig->get_device_view_type());
|
||||
$this->data = $view;
|
||||
$this->layout = element('layout_skin_file', element('layout', $view));
|
||||
$this->view = element('view_skin_file', element('layout', $view));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 쪽지 상세보기 페이지입니다
|
||||
*/
|
||||
public function view($type = 'recv', $note_id = 0)
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_note_view';
|
||||
$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);
|
||||
|
||||
if ( ! $this->cbconfig->item('use_note')) {
|
||||
alert_close('쪽지 기능을 사용하지 않는 사이트입니다');
|
||||
return false;
|
||||
} elseif ( ! $this->member->item('mem_use_note') && $this->member->is_admin() !== 'super') {
|
||||
alert_close('회원님은 쪽지 기능을 사용하지 않는 중이십니다');
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($type !== 'send') {
|
||||
$type = 'recv';
|
||||
}
|
||||
$nte_type = ($type === 'send') ? 2 : 1;
|
||||
$columnname = ($type === 'send') ? 'send_mem_id' : 'recv_mem_id';
|
||||
$mem_column = ($type === 'send') ? 'recv_mem_id' : 'send_mem_id';
|
||||
|
||||
$note_id = (int) $note_id;
|
||||
if (empty($note_id) OR $note_id < 1) {
|
||||
show_404();
|
||||
}
|
||||
|
||||
$where = array(
|
||||
'nte_id' => $note_id,
|
||||
$columnname => $mem_id,
|
||||
'nte_type' => $nte_type,
|
||||
);
|
||||
$result = $this->Note_model->get_note($where);
|
||||
if ( ! element('nte_id', $result)) {
|
||||
show_404();
|
||||
}
|
||||
if ($result[$mem_column]) {
|
||||
$result['userid'] = element('mem_userid', $result);
|
||||
$result['display_name'] = display_username(
|
||||
element('mem_userid', $result),
|
||||
element('mem_nickname', $result),
|
||||
element('mem_icon', $result)
|
||||
);
|
||||
} else {
|
||||
$result['display_name'] = '알림';
|
||||
}
|
||||
if (element('nte_type', $result) === '1'
|
||||
&& (empty($result['nte_read_datetime']) OR $result['nte_read_datetime'] <= '0000-00-00 00:00:00')) {
|
||||
$updatedata = array(
|
||||
'nte_read_datetime' => cdate('Y-m-d H:i:s'),
|
||||
);
|
||||
$this->Note_model->update(element('nte_id', $result), $updatedata);
|
||||
if ($result[$mem_column] > 0) {
|
||||
$updatedata = array(
|
||||
'nte_read_datetime' => cdate('Y-m-d H:i:s'),
|
||||
);
|
||||
$where = array(
|
||||
'related_note_id' => element('nte_id', $result),
|
||||
);
|
||||
$this->Note_model->update('', $updatedata, $where);
|
||||
}
|
||||
|
||||
$where = array(
|
||||
'recv_mem_id' => $mem_id,
|
||||
'nte_type' => 1,
|
||||
);
|
||||
$this->db->where($where);
|
||||
$this->db->group_start();
|
||||
$this->db->where(array('nte_read_datetime <=' => '0000-00-00 00:00:00'));
|
||||
$this->db->or_where(array('nte_read_datetime' => null));
|
||||
$this->db->group_end();
|
||||
$cnt = $this->db->count_all_results('note');
|
||||
$updatedata = array(
|
||||
'meta_unread_note_num' => $cnt,
|
||||
);
|
||||
$this->load->model('Member_meta_model');
|
||||
$this->Member_meta_model->save($mem_id, $updatedata);
|
||||
}
|
||||
$result['content'] = display_html_content(
|
||||
element('nte_content', $result),
|
||||
element('nte_content_html_type', $result),
|
||||
$thumb_width = 500,
|
||||
$autolink = true,
|
||||
$popup = true
|
||||
);
|
||||
|
||||
if ($result['nte_filename']) {
|
||||
$result['download_link'] = site_url('note/download/' . $type . '/' . $note_id);
|
||||
}
|
||||
|
||||
$view['view']['data'] = $result;
|
||||
$view['view']['type'] = $type;
|
||||
$view['view']['canonical'] = site_url('note/view/' . $type . '/' . $note_id);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
|
||||
|
||||
/**
|
||||
* 레이아웃을 정의합니다
|
||||
*/
|
||||
$page_title = $this->cbconfig->item('site_meta_title_note_view');
|
||||
$meta_description = $this->cbconfig->item('site_meta_description_note_view');
|
||||
$meta_keywords = $this->cbconfig->item('site_meta_keywords_note_view');
|
||||
$meta_author = $this->cbconfig->item('site_meta_author_note_view');
|
||||
$page_name = $this->cbconfig->item('site_page_name_note_view');
|
||||
|
||||
$searchconfig = array(
|
||||
'{쪽지제목}',
|
||||
);
|
||||
$replaceconfig = array(
|
||||
element('nte_title', $result),
|
||||
);
|
||||
|
||||
$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' => 'note',
|
||||
'layout' => 'layout_popup',
|
||||
'skin' => 'view',
|
||||
'layout_dir' => $this->cbconfig->item('layout_note'),
|
||||
'mobile_layout_dir' => $this->cbconfig->item('mobile_layout_note'),
|
||||
'skin_dir' => $this->cbconfig->item('skin_note'),
|
||||
'mobile_skin_dir' => $this->cbconfig->item('mobile_skin_note'),
|
||||
'page_title' => $page_title,
|
||||
'meta_description' => $meta_description,
|
||||
'meta_keywords' => $meta_keywords,
|
||||
'meta_author' => $meta_author,
|
||||
'page_name' => $page_name,
|
||||
);
|
||||
$view['layout'] = $this->managelayout->front($layoutconfig, $this->cbconfig->get_device_view_type());
|
||||
$this->data = $view;
|
||||
$this->layout = element('layout_skin_file', element('layout', $view));
|
||||
$this->view = element('view_skin_file', element('layout', $view));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 쪽지 글쓰기 페이지입니다
|
||||
*/
|
||||
public function write($userid = '')
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_note_write';
|
||||
$this->load->event($eventname);
|
||||
|
||||
/**
|
||||
* 로그인이 필요한 페이지입니다
|
||||
*/
|
||||
required_user_login();
|
||||
|
||||
if ( ! $this->cbconfig->item('use_note')) {
|
||||
alert_close('쪽지 기능을 사용하지 않는 사이트입니다');
|
||||
return false;
|
||||
} elseif ( ! $this->member->item('mem_use_note') && $this->member->is_admin() !== 'super') {
|
||||
alert_close('회원님은 쪽지 기능을 사용하지 않는 중이십니다');
|
||||
return false;
|
||||
}
|
||||
|
||||
$view = array();
|
||||
$view['view'] = array();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before'] = Events::trigger('before', $eventname);
|
||||
|
||||
$view['view']['userid'] = $userid;
|
||||
$view['view']['use_dhtml'] = false;
|
||||
if ($this->cbconfig->get_device_view_type() !== 'mobile'
|
||||
&& $this->cbconfig->item('use_note_dhtml')) {
|
||||
$view['view']['use_dhtml'] = true;
|
||||
}
|
||||
if ($this->cbconfig->get_device_view_type() === 'mobile'
|
||||
&& $this->cbconfig->item('use_note_mobile_dhtml')) {
|
||||
$view['view']['use_dhtml'] = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validation 라이브러리를 가져옵니다
|
||||
*/
|
||||
$this->load->library('form_validation');
|
||||
|
||||
/**
|
||||
* 전송된 데이터의 유효성을 체크합니다
|
||||
*/
|
||||
$config = array(
|
||||
array(
|
||||
'field' => 'userid',
|
||||
'label' => '회원아이디',
|
||||
'rules' => 'trim|required|callback__check_userid',
|
||||
),
|
||||
array(
|
||||
'field' => 'title',
|
||||
'label' => '제목',
|
||||
'rules' => 'trim|required',
|
||||
),
|
||||
array(
|
||||
'field' => 'content',
|
||||
'label' => '내용',
|
||||
'rules' => 'trim|required',
|
||||
),
|
||||
);
|
||||
$this->form_validation->set_rules($config);
|
||||
|
||||
/**
|
||||
* 유효성 검사를 하지 않는 경우, 또는 유효성 검사에 실패한 경우입니다.
|
||||
* 즉 글쓰기나 수정 페이지를 보고 있는 경우입니다
|
||||
*/
|
||||
if ($this->form_validation->run() === false) {
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['formrunfalse'] = Events::trigger('formrunfalse', $eventname);
|
||||
|
||||
} else {
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['formruntrue'] = Events::trigger('formruntrue', $eventname);
|
||||
|
||||
$file_error = '';
|
||||
$uploadfiledata = array();
|
||||
|
||||
if ($this->cbconfig->item('use_note_file')) {
|
||||
$this->load->library('upload');
|
||||
|
||||
if (isset($_FILES)
|
||||
&& isset($_FILES['note_file'])
|
||||
&& isset($_FILES['note_file']['name'])
|
||||
&& $_FILES['note_file']['name']) {
|
||||
$upload_path = config_item('uploads_dir') . '/note/';
|
||||
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 = array();
|
||||
$uploadconfig['upload_path'] = $upload_path;
|
||||
$uploadconfig['allowed_types'] = '*';
|
||||
$uploadconfig['encrypt_name'] = true;
|
||||
|
||||
$this->upload->initialize($uploadconfig);
|
||||
$_FILES['userfile']['name'] = $_FILES['note_file']['name'];
|
||||
$_FILES['userfile']['type'] = $_FILES['note_file']['type'];
|
||||
$_FILES['userfile']['tmp_name'] = $_FILES['note_file']['tmp_name'];
|
||||
$_FILES['userfile']['error'] = $_FILES['note_file']['error'];
|
||||
$_FILES['userfile']['size'] = $_FILES['note_file']['size'];
|
||||
if ($this->upload->do_upload()) {
|
||||
$filedata = $this->upload->data();
|
||||
|
||||
$uploadfiledata['nte_filename'] = cdate('Y') . '/' . cdate('m') . '/' . element('file_name', $filedata);
|
||||
$uploadfiledata['nte_originname'] = element('orig_name', $filedata);
|
||||
} else {
|
||||
$file_error = $this->upload->display_errors();
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($file_error) {
|
||||
$view['view']['message'] = $file_error;
|
||||
} else {
|
||||
$recv_list = explode(',', $this->input->post('userid'));
|
||||
$mem_list = array();
|
||||
$error_list = array();
|
||||
$view['view']['message'] = '';
|
||||
$content_type = $view['view']['use_dhtml'] ? 1 : 0;
|
||||
|
||||
if ($recv_list && is_array($recv_list)) {
|
||||
foreach ($recv_list as $key => $value) {
|
||||
$value = trim($value);
|
||||
if ($value) {
|
||||
$mem = $this->Member_model->get_by_userid($value, 'mem_id');
|
||||
|
||||
if (element('mem_id', $mem)) {
|
||||
|
||||
$send_result = $this->notelib->send_note(
|
||||
$this->member->item('mem_id'),
|
||||
element('mem_id', $mem),
|
||||
$this->input->post('title'),
|
||||
$this->input->post('content'),
|
||||
$content_type,
|
||||
element('nte_originname', $uploadfiledata, ''),
|
||||
element('nte_filename', $uploadfiledata, '')
|
||||
);
|
||||
|
||||
$jsonresult = json_decode($send_result, true);
|
||||
|
||||
if (isset($jsonresult['error']) && $jsonresult['error']) {
|
||||
$view['view']['message'] .= $jsonresult['error'] . '<br />';
|
||||
}
|
||||
|
||||
} else {
|
||||
$view['view']['message'] .= $value . '는 존재하지 않는 회원입니다<br />';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($view['view']['message'])) {
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['after'] = Events::trigger('after', $eventname);
|
||||
|
||||
$this->session->set_flashdata(
|
||||
'message',
|
||||
'쪽지가 발송되었습니다'
|
||||
);
|
||||
redirect('note/lists/send');
|
||||
}
|
||||
}
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
|
||||
|
||||
/**
|
||||
* 레이아웃을 정의합니다
|
||||
*/
|
||||
$page_title = $this->cbconfig->item('site_meta_title_note_write');
|
||||
$meta_description = $this->cbconfig->item('site_meta_description_note_write');
|
||||
$meta_keywords = $this->cbconfig->item('site_meta_keywords_note_write');
|
||||
$meta_author = $this->cbconfig->item('site_meta_author_note_write');
|
||||
$page_name = $this->cbconfig->item('site_page_name_note_write');
|
||||
|
||||
$layoutconfig = array(
|
||||
'path' => 'note',
|
||||
'layout' => 'layout_popup',
|
||||
'skin' => 'write',
|
||||
'layout_dir' => $this->cbconfig->item('layout_note'),
|
||||
'mobile_layout_dir' => $this->cbconfig->item('mobile_layout_note'),
|
||||
'skin_dir' => $this->cbconfig->item('skin_note'),
|
||||
'mobile_skin_dir' => $this->cbconfig->item('mobile_skin_note'),
|
||||
'page_title' => $page_title,
|
||||
'meta_description' => $meta_description,
|
||||
'meta_keywords' => $meta_keywords,
|
||||
'meta_author' => $meta_author,
|
||||
'page_name' => $page_name,
|
||||
);
|
||||
$view['layout'] = $this->managelayout->front($layoutconfig, $this->cbconfig->get_device_view_type());
|
||||
$this->data = $view;
|
||||
$this->layout = element('layout_skin_file', element('layout', $view));
|
||||
$this->view = element('view_skin_file', element('layout', $view));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 쪽지 다운로드 기능입니다
|
||||
*/
|
||||
public function download($type = 'recv', $note_id = 0)
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_note_download';
|
||||
$this->load->event($eventname);
|
||||
|
||||
/**
|
||||
* 로그인이 필요한 페이지입니다
|
||||
*/
|
||||
required_user_login();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('before', $eventname);
|
||||
|
||||
if ( ! $this->cbconfig->item('use_note')) {
|
||||
alert_close('쪽지 기능을 사용하지 않는 사이트입니다');
|
||||
return false;
|
||||
} elseif ( ! $this->member->item('mem_use_note') && $this->member->is_admin() !== 'super') {
|
||||
alert_close('회원님은 쪽지 기능을 사용하지 않는 중이십니다');
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($type !== 'send') {
|
||||
$type = 'recv';
|
||||
}
|
||||
$nte_type = ($type === 'send') ? 2 : 1;
|
||||
$columnname = ($type === 'send') ? 'send_mem_id' : 'recv_mem_id';
|
||||
$mem_column = ($type === 'send') ? 'recv_mem_id' : 'send_mem_id';
|
||||
|
||||
$note_id = (int) $note_id;
|
||||
if (empty($note_id) OR $note_id < 1) {
|
||||
show_404();
|
||||
}
|
||||
|
||||
$where = array(
|
||||
'nte_id' => $note_id,
|
||||
$columnname => $this->member->item('mem_id'),
|
||||
'nte_type' => $nte_type,
|
||||
);
|
||||
$result = $this->Note_model->get_note($where);
|
||||
if ( ! element('nte_id', $result) OR ! element('nte_filename', $result) OR ! element('nte_originname', $result)) {
|
||||
show_404();
|
||||
}
|
||||
|
||||
$this->load->helper('download');
|
||||
// Read the file's contents
|
||||
$data = file_get_contents(config_item('uploads_dir') . '/note/' . element('nte_filename', $result));
|
||||
$name = element('nte_originname', $result);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after', $eventname);
|
||||
force_download($name, $data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 쪽지 발송시 실제 존재하는 회원인지, 수신가능한 회원인지 체크하는 함수입니다
|
||||
*/
|
||||
public function _check_userid($str)
|
||||
{
|
||||
$recv_list = explode(',', $str);
|
||||
$mem_list = array();
|
||||
$error_list = array();
|
||||
|
||||
if ($recv_list && is_array($recv_list)) {
|
||||
foreach ($recv_list as $key => $value) {
|
||||
$value = trim($value);
|
||||
if ($value) {
|
||||
$select = 'mem_id, mem_denied, mem_use_note, mem_userid, mem_nickname';
|
||||
$mem = $this->Member_model->get_by_userid($value, $select);
|
||||
if (element('mem_id', $mem)
|
||||
&& element('mem_denied', $mem) === '0'
|
||||
&& element('mem_use_note', $mem) === '1') {
|
||||
$mem_list['mem_id'] = element('mem_id', $mem);
|
||||
$mem_list['mem_userid'] = element('mem_userid', $mem);
|
||||
$mem_list['mem_nickname'] = element('mem_nickname', $mem);
|
||||
} else {
|
||||
$error_list[] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$error_msg = implode(',', $error_list);
|
||||
|
||||
if ($error_msg && $this->member->is_admin() !== 'super') {
|
||||
$this->form_validation->set_message(
|
||||
'_check_userid',
|
||||
$error_msg . ' 는 쪽지를 받을 수 없는 회원아이디입니다. <br />쪽지를 발송하지 않았습니다'
|
||||
);
|
||||
return false;
|
||||
}
|
||||
if ($this->member->is_admin() !== 'super') {
|
||||
if (count(element('mem_id', $mem_list))) {
|
||||
$point = $this->cbconfig->item('point_note') * count(element('mem_id', $mem_list));
|
||||
if ($point) {
|
||||
if ($this->member->item('mem_point') - $point < 0) {
|
||||
$this->form_validation->set_message(
|
||||
'_check_userid',
|
||||
'보유하신 포인트(' . number_format($this->member->item('mem_point')) . '점)가 모자라서 쪽지를 보낼 수 없습니다'
|
||||
);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 쪽지를 삭제하는 함수입니다
|
||||
*/
|
||||
public function delete($note_type = 'recv', $note_id = 0)
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_note_delete';
|
||||
$this->load->event($eventname);
|
||||
|
||||
/**
|
||||
* 로그인이 필요한 페이지입니다
|
||||
*/
|
||||
required_user_login();
|
||||
|
||||
$mem_id = (int) $this->member->item('mem_id');
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('before', $eventname);
|
||||
|
||||
if ( ! $this->cbconfig->item('use_note')) {
|
||||
alert_close('쪽지 기능을 사용하지 않는 사이트입니다');
|
||||
return false;
|
||||
} elseif ( ! $this->member->item('mem_use_note') && $this->member->is_admin() !== 'super') {
|
||||
alert_close('회원님은 쪽지 기능을 사용하지 않는 중이십니다');
|
||||
return false;
|
||||
}
|
||||
|
||||
$note_id = (int) $note_id;
|
||||
if (empty($note_id) OR $note_id < 1) {
|
||||
show_404();
|
||||
}
|
||||
|
||||
$note = $this->Note_model->get_one($note_id);
|
||||
if ( ! element('nte_id', $note)) {
|
||||
show_404();
|
||||
}
|
||||
if (element('nte_type', $note) === '1') {
|
||||
if ($note_type !== element('nte_type', $note)) {
|
||||
show_404();
|
||||
}
|
||||
if ((int) element('recv_mem_id', $note) !== $mem_id) {
|
||||
show_404();
|
||||
}
|
||||
$note_list = 'recv';
|
||||
} elseif (element('nte_type', $note) === '2') {
|
||||
if ($note_type !== element('nte_type', $note)) {
|
||||
show_404();
|
||||
}
|
||||
if ((int) element('send_mem_id', $note) !== $mem_id) {
|
||||
show_404();
|
||||
}
|
||||
$note_list = 'send';
|
||||
}
|
||||
|
||||
$this->Note_model->delete($note_id);
|
||||
|
||||
$where = array(
|
||||
'recv_mem_id' => $mem_id,
|
||||
'nte_type' => 1,
|
||||
);
|
||||
$this->db->where($where);
|
||||
$this->db->group_start();
|
||||
$this->db->where(array('nte_read_datetime <=' => '0000-00-00 00:00:00'));
|
||||
$this->db->or_where(array('nte_read_datetime' => null));
|
||||
$this->db->group_end();
|
||||
$cnt = $this->db->count_all_results('note');
|
||||
$updatedata = array(
|
||||
'meta_unread_note_num' => $cnt,
|
||||
);
|
||||
$this->load->model('Member_meta_model');
|
||||
$this->Member_meta_model->save($mem_id, $updatedata);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after', $eventname);
|
||||
|
||||
/**
|
||||
* 삭제가 끝난 후 목록페이지로 이동합니다
|
||||
*/
|
||||
$this->session->set_flashdata(
|
||||
'message',
|
||||
'정상적으로 삭제되었습니다'
|
||||
);
|
||||
$param =& $this->querystring;
|
||||
|
||||
redirect('note/lists/' . $note_list . '?' . $param->output());
|
||||
}
|
||||
}
|
||||
483
application/controllers/Notification.php
Normal file
483
application/controllers/Notification.php
Normal file
@@ -0,0 +1,483 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Notification class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 알림페이지와 관련된 controller 입니다.
|
||||
*/
|
||||
class Notification extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array('Notification');
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/**
|
||||
* 라이브러리를 로딩합니다
|
||||
*/
|
||||
$this->load->library(array('pagination', 'querystring'));
|
||||
|
||||
if ( ! $this->cbconfig->item('use_notification')) {
|
||||
alert('이 웹사이트는 알림기능을 사용하지 않습니다.');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 알림 페이지 입니다
|
||||
*/
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 알림 읽기 입니다
|
||||
*/
|
||||
public function read($not_id = 0)
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_notification_read';
|
||||
$this->load->event($eventname);
|
||||
|
||||
/**
|
||||
* 로그인이 필요한 페이지입니다
|
||||
*/
|
||||
required_user_login();
|
||||
|
||||
$mem_id = (int) $this->member->item('mem_id');
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('before', $eventname);
|
||||
|
||||
$not_id = (int) $not_id;
|
||||
if (empty($not_id) OR $not_id < 1) {
|
||||
show_404();
|
||||
}
|
||||
|
||||
$notification = $this->Notification_model->get_one($not_id);
|
||||
|
||||
if ( ! element('not_id', $notification)) {
|
||||
show_404();
|
||||
}
|
||||
|
||||
if ((int) element('mem_id', $notification) !== $mem_id) {
|
||||
show_404();
|
||||
}
|
||||
|
||||
$this->Notification_model->mark_read($not_id, $mem_id);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after', $eventname);
|
||||
|
||||
$redirecturl = element('not_url', $notification);
|
||||
redirect($redirecturl);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 알림 읽기 입니다
|
||||
*/
|
||||
public function readajax($not_id = 0)
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_notification_readajax';
|
||||
$this->load->event($eventname);
|
||||
|
||||
$this->output->set_content_type('application/json');
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('before', $eventname);
|
||||
|
||||
/**
|
||||
* 로그인이 필요한 페이지입니다
|
||||
*/
|
||||
if ($this->member->is_member() === false) {
|
||||
$result = array('error' => '로그인 후 접속 가능한 페이지입니다.');
|
||||
exit(json_encode($result));
|
||||
}
|
||||
|
||||
$mem_id = (int) $this->member->item('mem_id');
|
||||
|
||||
$not_id = (int) $not_id;
|
||||
if (empty($not_id) OR $not_id < 1) {
|
||||
$result = array('error' => '잘못된 접근입니다.');
|
||||
exit(json_encode($result));
|
||||
}
|
||||
|
||||
$notification = $this->Notification_model->get_one($not_id);
|
||||
|
||||
if ( ! element('not_id', $notification)) {
|
||||
$result = array('error' => '잘못된 접근입니다.');
|
||||
exit(json_encode($result));
|
||||
}
|
||||
|
||||
if ((int) element('mem_id', $notification) !== $mem_id) {
|
||||
$result = array('error' => '잘못된 접근입니다.');
|
||||
exit(json_encode($result));
|
||||
}
|
||||
|
||||
$this->Notification_model->mark_read($not_id, $mem_id);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after', $eventname);
|
||||
|
||||
$result = array('success' => '읽음으로 처리하였습니다');
|
||||
|
||||
exit(json_encode($result));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 알림 전체 읽기 입니다
|
||||
*/
|
||||
public function readallajax()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_notification_readallajax';
|
||||
$this->load->event($eventname);
|
||||
|
||||
$this->output->set_content_type('application/json');
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('before', $eventname);
|
||||
|
||||
/**
|
||||
* 로그인이 필요한 페이지입니다
|
||||
*/
|
||||
if ($this->member->is_member() === false) {
|
||||
$result = array('error' => '로그인 후 접속 가능한 페이지입니다.');
|
||||
exit(json_encode($result));
|
||||
}
|
||||
|
||||
$this->Notification_model->mark_allread($this->member->item('mem_id'));
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after', $eventname);
|
||||
|
||||
$result = array('success' => '읽음으로 처리하였습니다');
|
||||
exit(json_encode($result));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 알림 AJAX 리스트 입니다
|
||||
*/
|
||||
public function ajax_list()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_notification_ajax_list';
|
||||
$this->load->event($eventname);
|
||||
|
||||
/**
|
||||
* 로그인이 필요한 페이지입니다
|
||||
*/
|
||||
required_user_login();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('before', $eventname);
|
||||
|
||||
/**
|
||||
* 페이지에 숫자가 아닌 문자가 입력되거나 1보다 작은 숫자가 입력되면 에러 페이지를 보여줍니다.
|
||||
*/
|
||||
$param =& $this->querystring;
|
||||
|
||||
/**
|
||||
* 게시판 목록에 필요한 정보를 가져옵니다.
|
||||
*/
|
||||
$result = $this->Notification_model
|
||||
->get_notification_list(5, 0, $this->member->item('mem_id'), 'N');
|
||||
|
||||
$html = '<div class="notifications-list"><strong id="notification_count">'
|
||||
. $result['total_rows']
|
||||
. '</strong>개의 읽지 않은 알림이 있습니다.<span><a href="javascript:;" class="pull-right point noti-all-read">모두 읽음으로 표시</a></span></div>';
|
||||
|
||||
if (element('list', $result)) {
|
||||
foreach (element('list', $result) as $key => $val) {
|
||||
$result['list'][$key]['delete_url'] = site_url('notification/delete/' . element('not_id', $val) . '?' . $param->output());
|
||||
$jsevent = '';
|
||||
$read_url = site_url('notification/read/' . element('not_id', $val) . '?' . $param->output());
|
||||
if (element('not_type', $val) === 'note') {
|
||||
$read_url = 'javascript:;';
|
||||
$jsevent = 'onClick="note_list(' . element('not_content_id', $val) . ');"';
|
||||
}
|
||||
$html .= '<div class="notifications-list">
|
||||
<a href="' . $read_url . '" ' . $jsevent . ' class="notification_read '
|
||||
. element('not_type', $val) . '" data-not-id="' . element('not_id', $val) . '">'
|
||||
. html_escape(element('not_message', $val))
|
||||
. ' <span class="pull-right">'
|
||||
. display_datetime(element('not_datetime', $val), 'sns')
|
||||
. '</span></a></div> ';
|
||||
}
|
||||
}
|
||||
$html .= '<div class="notifications-list">
|
||||
<a class="external point" href="' . site_url('notification') . '">
|
||||
알림 페이지로 이동</a></div>';
|
||||
|
||||
echo $html;
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 알림삭제 입니다
|
||||
*/
|
||||
public function delete($not_id = 0)
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_notification_delete';
|
||||
$this->load->event($eventname);
|
||||
|
||||
/**
|
||||
* 로그인이 필요한 페이지입니다
|
||||
*/
|
||||
required_user_login();
|
||||
|
||||
$mem_id = (int) $this->member->item('mem_id');
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('before', $eventname);
|
||||
|
||||
$not_id = (int) $not_id;
|
||||
if (empty($not_id) OR $not_id < 1) {
|
||||
show_404();
|
||||
}
|
||||
|
||||
$notification = $this->Notification_model->get_one($not_id);
|
||||
|
||||
if ( ! element('not_id', $notification)) {
|
||||
show_404();
|
||||
}
|
||||
|
||||
if ((int) element('mem_id', $notification) !== $mem_id) {
|
||||
show_404();
|
||||
}
|
||||
|
||||
$this->Notification_model->delete($not_id);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after', $eventname);
|
||||
|
||||
/**
|
||||
* 삭제가 끝난 후 목록페이지로 이동합니다
|
||||
*/
|
||||
$this->session->set_flashdata(
|
||||
'message',
|
||||
'정상적으로 삭제되었습니다'
|
||||
);
|
||||
$param =& $this->querystring;
|
||||
redirect('notification?' . $param->output());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 알림 선택삭제입니다
|
||||
*/
|
||||
public function listdelete()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_notification_listdelete';
|
||||
$this->load->event($eventname);
|
||||
|
||||
/**
|
||||
* 로그인이 필요한 페이지입니다
|
||||
*/
|
||||
required_user_login();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('before', $eventname);
|
||||
|
||||
/**
|
||||
* 체크한 게시물의 삭제를 실행합니다
|
||||
*/
|
||||
if ($this->input->post('chk') && is_array($this->input->post('chk'))) {
|
||||
foreach ($this->input->post('chk') as $val) {
|
||||
if ($val) {
|
||||
$where = array(
|
||||
'not_id' => $val,
|
||||
'mem_id' => $this->member->item('mem_id'),
|
||||
);
|
||||
$this->Notification_model->delete_where($where);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after', $eventname);
|
||||
|
||||
/**
|
||||
* 삭제가 끝난 후 목록페이지로 이동합니다
|
||||
*/
|
||||
$this->session->set_flashdata(
|
||||
'message',
|
||||
'정상적으로 삭제되었습니다'
|
||||
);
|
||||
$param =& $this->querystring;
|
||||
redirect('notification?' . $param->output());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 알림 선택 읽음으로 표시 입니다
|
||||
*/
|
||||
public function listupdate()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_notification_listupdate';
|
||||
$this->load->event($eventname);
|
||||
|
||||
/**
|
||||
* 로그인이 필요한 페이지입니다
|
||||
*/
|
||||
required_user_login();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('before', $eventname);
|
||||
|
||||
/**
|
||||
* 체크한 게시물의 업데이트를 실행합니다
|
||||
*/
|
||||
if ($this->input->post('chk') && is_array($this->input->post('chk'))) {
|
||||
foreach ($this->input->post('chk') as $val) {
|
||||
if ($val) {
|
||||
$this->Notification_model->mark_read($val, $this->member->item('mem_id'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after', $eventname);
|
||||
|
||||
/**
|
||||
* 삭제가 끝난 후 목록페이지로 이동합니다
|
||||
*/
|
||||
$this->session->set_flashdata(
|
||||
'message',
|
||||
'정상적으로 삭제되었습니다'
|
||||
);
|
||||
$param =& $this->querystring;
|
||||
redirect('notification?' . $param->output());
|
||||
}
|
||||
}
|
||||
3298
application/controllers/Postact.php
Normal file
3298
application/controllers/Postact.php
Normal file
File diff suppressed because it is too large
Load Diff
445
application/controllers/Profile.php
Normal file
445
application/controllers/Profile.php
Normal file
@@ -0,0 +1,445 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Profile class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 회원님의 프로필 보기 페이지에 필요한 controller 입니다.
|
||||
*/
|
||||
class Profile extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array('Follow', 'Member_meta', 'Member_extra_vars');
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/**
|
||||
* 라이브러리를 로딩합니다
|
||||
*/
|
||||
$this->load->library(array('querystring'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 프로필보기 페이지입니다
|
||||
*/
|
||||
public function index($userid = '')
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_profile_index';
|
||||
$this->load->event($eventname);
|
||||
|
||||
/**
|
||||
* 로그인이 필요한 페이지입니다
|
||||
*/
|
||||
required_user_login();
|
||||
|
||||
$view = array();
|
||||
$view['view'] = array();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before'] = Events::trigger('before', $eventname);
|
||||
|
||||
if (empty($userid)) {
|
||||
show_404();
|
||||
}
|
||||
|
||||
if ( ! $this->member->item('mem_open_profile') && $this->member->is_admin() !== 'super' && $this->member->item('mem_userid') !== $userid) {
|
||||
alert_close('회원님이 프로필 공개를 하지 않으셨으므로, 상대방의 프로필을 볼 수 없습니다. 먼저 회원님의 프로필을 공개해주세요');
|
||||
return false;
|
||||
}
|
||||
|
||||
$view['view']['member'] = $member = $this->Member_model->get_by_userid($userid);
|
||||
$member_meta = $this->Member_meta_model->get_all_meta(element('mem_id', $member));
|
||||
if (is_array($member_meta)) {
|
||||
$view['view']['member'] = $member = array_merge($view['view']['member'], $member_meta);
|
||||
}
|
||||
if ( ! element('mem_id', $member)) {
|
||||
alert_close('존재하지 않는 회원아이디입니다');
|
||||
return false;
|
||||
}
|
||||
if (element('mem_denied', $member)) {
|
||||
alert_close('탈퇴 또는 차단된 회원아이디입니다');
|
||||
return false;
|
||||
}
|
||||
$member_extra_vars = $this->Member_extra_vars_model->get_all_meta(element('mem_id', $member));
|
||||
if (is_array($member_extra_vars)) {
|
||||
$view['view']['member'] = $member = array_merge($view['view']['member'], $member_extra_vars);
|
||||
}
|
||||
|
||||
if ( ! element('mem_open_profile', $member)
|
||||
&& $this->member->is_admin() !== 'super'
|
||||
&& $this->member->item('mem_userid') !== $userid) {
|
||||
alert_close(html_escape(element('mem_nickname', $member)) . ' 님이 프로필을 공개하지 않으셨습니다');
|
||||
return false;
|
||||
}
|
||||
|
||||
$registerform = $this->cbconfig->item('registerform');
|
||||
$form = json_decode($registerform, true);
|
||||
$display = array();
|
||||
if ($form && is_array($form)) {
|
||||
foreach ($form as $key => $value) {
|
||||
if (element('use', $value) && element('open', $value)) {
|
||||
if (element('field_name', $value) === 'mem_address') {
|
||||
$value['value']
|
||||
= element('mem_zipcode', $member) . ' ' .
|
||||
element('mem_address1', $member) . ' ' .
|
||||
element('mem_address2', $member) . ' ' .
|
||||
element('mem_address3', $member);
|
||||
} else {
|
||||
$value['value'] = element(element('field_name', $value), $member);
|
||||
if (element('field_type', $value) === 'checkbox') {
|
||||
$tmp_value = json_decode($value['value']);
|
||||
$tmp = '';
|
||||
if ($tmp_value) {
|
||||
foreach ($tmp_value as $val) {
|
||||
if ($tmp) {
|
||||
$tmp .= ', ';
|
||||
}
|
||||
$tmp .= $val;
|
||||
}
|
||||
}
|
||||
$value['value'] = $tmp;
|
||||
}
|
||||
}
|
||||
$display[] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
$view['data'] = $display;
|
||||
|
||||
$view['view']['canonical'] = site_url('profile/' . $userid);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
|
||||
|
||||
/**
|
||||
* 레이아웃을 정의합니다
|
||||
*/
|
||||
$page_title = $this->cbconfig->item('site_meta_title_profile');
|
||||
$meta_description = $this->cbconfig->item('site_meta_description_profile');
|
||||
$meta_keywords = $this->cbconfig->item('site_meta_keywords_profile');
|
||||
$meta_author = $this->cbconfig->item('site_meta_author_profile');
|
||||
$page_name = $this->cbconfig->item('site_page_name_profile');
|
||||
|
||||
$searchconfig = array(
|
||||
'{프로필회원명}',
|
||||
'{프로필회원아이디}',
|
||||
);
|
||||
$replaceconfig = array(
|
||||
element('mem_nickname', $member),
|
||||
element('mem_userid', $member),
|
||||
);
|
||||
|
||||
$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' => 'profile',
|
||||
'layout' => 'layout_popup',
|
||||
'skin' => 'profile',
|
||||
'layout_dir' => $this->cbconfig->item('layout_profile'),
|
||||
'mobile_layout_dir' => $this->cbconfig->item('mobile_layout_profile'),
|
||||
'skin_dir' => $this->cbconfig->item('skin_profile'),
|
||||
'mobile_skin_dir' => $this->cbconfig->item('mobile_skin_profile'),
|
||||
'page_title' => $page_title,
|
||||
'meta_description' => $meta_description,
|
||||
'meta_keywords' => $meta_keywords,
|
||||
'meta_author' => $meta_author,
|
||||
'page_name' => $page_name,
|
||||
);
|
||||
$view['layout'] = $this->managelayout->front($layoutconfig, $this->cbconfig->get_device_view_type());
|
||||
$this->data = $view;
|
||||
$this->layout = element('layout_skin_file', element('layout', $view));
|
||||
$this->view = element('view_skin_file', element('layout', $view));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 회원닉네임 클릭시 나타나는 사이드뷰 보기 관련 함수입니다
|
||||
*/
|
||||
public function sideview($userid = '')
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_profile_sideview';
|
||||
$this->load->event($eventname);
|
||||
|
||||
if (empty($userid)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$result = array();
|
||||
$this->output->set_content_type('application/json');
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$result['event']['before'] = Events::trigger('before', $eventname);
|
||||
|
||||
if ($this->member->is_member() === false) {
|
||||
$result = array('error' => '로그인후 이용해주세요');
|
||||
exit(json_encode($result));
|
||||
}
|
||||
if (empty($userid)) {
|
||||
$result = array('error' => '잘못된 접근입니다');
|
||||
exit(json_encode($result));
|
||||
}
|
||||
|
||||
$mem_id = (int) $this->member->item('mem_id');
|
||||
|
||||
$select = 'mem_id, mem_nickname, mem_homepage, mem_receive_email, mem_use_note, mem_open_profile, mem_denied';
|
||||
$member = $this->Member_model->get_by_userid($userid, $select);
|
||||
if ( ! element('mem_id', $member)) {
|
||||
$result = array('error' => '존재하지 않는 회원 아이디입니다');
|
||||
exit(json_encode($result));
|
||||
}
|
||||
if (element('mem_denied', $member)) {
|
||||
$result = array('error' => '탈퇴 또는 차단된 회원 아이디입니다');
|
||||
exit(json_encode($result));
|
||||
}
|
||||
$countwhere = array(
|
||||
'mem_id' => $mem_id,
|
||||
'target_mem_id' => element('mem_id', $member),
|
||||
);
|
||||
$followcount = $this->Follow_model->count_by($countwhere);
|
||||
$result = array();
|
||||
$result['success'] = html_escape(element('mem_nickname', $member)) . ' 님의 사이드뷰';
|
||||
$result['name'] = html_escape(element('mem_nickname', $member));
|
||||
|
||||
if ( ! $this->cbconfig->item('use_note')) {
|
||||
$result['note'] = '10'; // 쪽지 기능을 사용하지 않는 사이트
|
||||
} elseif ( ! $this->member->item('mem_use_note') && $this->member->is_admin() !== 'super') {
|
||||
$result['note'] = '3'; // 내가 쪽지 기능을 사용하지 않고 있음
|
||||
} elseif ($member['mem_use_note']) {
|
||||
$result['note'] = '1'; // 쪽지 기능 사용
|
||||
} else {
|
||||
$result['note'] = '2'; // 상대방이 쪽지 기능을 사용하지 않고 있음
|
||||
}
|
||||
|
||||
if ($this->cbconfig->get_device_view_type() !== 'mobile'
|
||||
&& ! $this->cbconfig->item('use_sideview_email')) {
|
||||
$result['email'] = '10'; // 이메일 기능을 사용하지 않는 사이트
|
||||
} elseif ($this->cbconfig->get_device_view_type() === 'mobile'
|
||||
&& ! $this->cbconfig->item('use_mobile_sideview_email')) {
|
||||
$result['email'] = '10'; // 이메일 기능을 사용하지 않는 사이트
|
||||
} elseif ( ! $this->member->item('mem_receive_email')
|
||||
&& $this->member->is_admin() !== 'super') {
|
||||
$result['email'] = '3'; // 내가 이메일수신 기능을 사용하지 않고 있음
|
||||
} elseif ($member['mem_receive_email']
|
||||
OR $this->member->is_admin() === 'super') {
|
||||
$result['email'] = '1'; // 이메일수신 기능 사용
|
||||
} else {
|
||||
$result['email'] = '2'; // 상대방이 이메일수신 기능을 사용하지 않고 있음
|
||||
}
|
||||
|
||||
if ( ! $this->member->item('mem_open_profile')
|
||||
&& $this->member->is_admin() !== 'super') {
|
||||
$result['profile'] = '3'; // 내가 프로필공개 기능을 사용하지 않고 있음
|
||||
} elseif ($member['mem_open_profile']
|
||||
OR $this->member->is_admin() === 'super') {
|
||||
$result['profile'] = '1'; // 프로필공개 기능 사용
|
||||
} else {
|
||||
$result['profile'] = '2'; // 상대방이 프로필공개 기능을 사용하지 않고 있음
|
||||
}
|
||||
|
||||
$result['following'] = $followcount;
|
||||
$result['homepage'] = html_escape(element('mem_homepage', $member));
|
||||
$result['memid'] = $this->member->is_admin() === 'super' ? element('mem_id', $member) : '';
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$result['event']['after'] = Events::trigger('after', $eventname);
|
||||
|
||||
exit(json_encode($result));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 친구추가 관련 함수입니다
|
||||
*/
|
||||
public function add_follow($userid = '')
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_profile_add_follow';
|
||||
$this->load->event($eventname);
|
||||
|
||||
if (empty($userid)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$result = array();
|
||||
$this->output->set_content_type('application/json');
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$resutl['event']['after'] = Events::trigger('before', $eventname);
|
||||
|
||||
if ($this->member->is_member() === false) {
|
||||
$result = array('error' => '로그인후 이용해주세요');
|
||||
exit(json_encode($result));
|
||||
}
|
||||
if (empty($userid)) {
|
||||
$result = array('error' => '잘못된 접근입니다');
|
||||
exit(json_encode($result));
|
||||
}
|
||||
|
||||
$mem_id = (int) $this->member->item('mem_id');
|
||||
|
||||
$select = 'mem_id, mem_nickname, mem_homepage, mem_receive_email, mem_use_note, mem_open_profile, mem_denied';
|
||||
$target = $this->Member_model->get_by_userid($userid, $select);
|
||||
if ( ! element('mem_id', $target)) {
|
||||
$result = array('error' => '잘못된 접근입니다');
|
||||
exit(json_encode($result));
|
||||
}
|
||||
if (element('mem_denied', $target)) {
|
||||
$result = array('error' => '탈퇴 또는 차단된 회원입니다');
|
||||
exit(json_encode($result));
|
||||
}
|
||||
if ((int) element('mem_id', $target) === $mem_id) {
|
||||
$result = array('error' => '자기자신을 친구로 등록할 수 없습니다');
|
||||
exit(json_encode($result));
|
||||
}
|
||||
$countwhere = array(
|
||||
'mem_id' => $mem_id,
|
||||
'target_mem_id' => element('mem_id', $target),
|
||||
);
|
||||
$followcount = $this->Follow_model->count_by($countwhere);
|
||||
if ($followcount > 0) {
|
||||
$result = array('error' => '이미 친구로 등록된 회원입니다');
|
||||
exit(json_encode($result));
|
||||
}
|
||||
$insertdata = array(
|
||||
'mem_id' => $mem_id,
|
||||
'target_mem_id' => element('mem_id', $target),
|
||||
'fol_datetime' => cdate('Y-m-d H:i:s'),
|
||||
);
|
||||
$this->Follow_model->insert($insertdata);
|
||||
|
||||
$countwhere = array(
|
||||
'target_mem_id' => element('mem_id', $target),
|
||||
);
|
||||
$target_count = $this->Follow_model->count_by($countwhere);
|
||||
|
||||
$countwhere = array(
|
||||
'mem_id' => $mem_id,
|
||||
);
|
||||
$my_count = $this->Follow_model->count_by($countwhere);
|
||||
|
||||
$updatedata = array(
|
||||
'mem_followed' => $target_count,
|
||||
);
|
||||
$this->Member_model->update(element('mem_id', $target), $updatedata);
|
||||
|
||||
$updatedata = array(
|
||||
'mem_following' => $my_count,
|
||||
);
|
||||
$this->Member_model->update($this->member->item('mem_id'), $updatedata);
|
||||
|
||||
$result['success'] = html_escape(element('mem_nickname', $target)) . ' 님을 Following 하셨습니다';
|
||||
$result['my_count'] = $my_count;
|
||||
$result['target_count'] = $target_count;
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$resutl['event']['after'] = Events::trigger('after', $eventname);
|
||||
|
||||
exit(json_encode($result));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 친구해제 관련 함수입니다
|
||||
*/
|
||||
public function delete_follow($userid = '')
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_profile_delete_follow';
|
||||
$this->load->event($eventname);
|
||||
|
||||
if (empty($userid)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$result = array();
|
||||
$this->output->set_content_type('application/json');
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$resutl['event']['before'] = Events::trigger('before', $eventname);
|
||||
|
||||
if ($this->member->is_member() === false) {
|
||||
$result = array('error' => '로그인후 이용해주세요');
|
||||
exit(json_encode($result));
|
||||
}
|
||||
if (empty($userid)) {
|
||||
$result = array('error' => '잘못된 접근입니다');
|
||||
exit(json_encode($result));
|
||||
}
|
||||
|
||||
$mem_id = (int) $this->member->item('mem_id');
|
||||
|
||||
$select = 'mem_id, mem_nickname, mem_homepage, mem_receive_email,
|
||||
mem_use_note, mem_open_profile, mem_denied';
|
||||
$target = $this->Member_model->get_by_userid($userid, $select);
|
||||
if ( ! element('mem_id', $target)) {
|
||||
$result = array('error' => '잘못된 접근입니다');
|
||||
exit(json_encode($result));
|
||||
}
|
||||
$countwhere = array(
|
||||
'mem_id' => $mem_id,
|
||||
'target_mem_id' => element('mem_id', $target),
|
||||
);
|
||||
$followcount = $this->Follow_model->count_by($countwhere);
|
||||
if ($followcount === 0) {
|
||||
$result = array('error' => '아직 친구로 등록되지 않은 회원입니다');
|
||||
exit(json_encode($result));
|
||||
}
|
||||
$deletewhere = array(
|
||||
'mem_id' => $mem_id,
|
||||
'target_mem_id' => element('mem_id', $target),
|
||||
);
|
||||
$this->Follow_model->delete_where($deletewhere);
|
||||
|
||||
$countwhere = array(
|
||||
'target_mem_id' => element('mem_id', $target),
|
||||
);
|
||||
$target_count = $this->Follow_model->count_by($countwhere);
|
||||
|
||||
$countwhere = array(
|
||||
'mem_id' => $mem_id,
|
||||
);
|
||||
$my_count = $this->Follow_model->count_by($countwhere);
|
||||
|
||||
$updatedata = array(
|
||||
'mem_followed' => $target_count,
|
||||
);
|
||||
$this->Member_model->update(element('mem_id', $target), $updatedata);
|
||||
|
||||
$updatedata = array(
|
||||
'mem_following' => $my_count,
|
||||
);
|
||||
$this->Member_model->update($mem_id, $updatedata);
|
||||
|
||||
$result['success'] = html_escape(element('mem_nickname', $target)) . ' 님이 Follow 해제되었습니다';
|
||||
$result['my_count'] = $my_count;
|
||||
$result['target_count'] = $target_count;
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$resutl['event']['after'] = Events::trigger('after', $eventname);
|
||||
|
||||
exit(json_encode($result));
|
||||
}
|
||||
}
|
||||
1674
application/controllers/Register.php
Normal file
1674
application/controllers/Register.php
Normal file
File diff suppressed because it is too large
Load Diff
190
application/controllers/Rss.php
Normal file
190
application/controllers/Rss.php
Normal file
@@ -0,0 +1,190 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Rss class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* RSS 보기 때 필요한 controller 입니다.
|
||||
*/
|
||||
class Rss extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array('Board_meta', 'Post', 'Board_category');
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/**
|
||||
* 라이브러리를 로딩합니다
|
||||
*/
|
||||
$this->load->library(array('querystring'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* RSS 페이지 함수입니다
|
||||
*/
|
||||
public function index($brd_key = '')
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_rss_index';
|
||||
$this->load->event($eventname);
|
||||
|
||||
$rsstype = $brd_key ? 'board' : 'all';
|
||||
|
||||
$view = array();
|
||||
$view['view'] = array();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before'] = Events::trigger('before', $eventname);
|
||||
|
||||
if ($rsstype === 'board') {
|
||||
$board_id = $this->board->item_key('brd_id', $brd_key);
|
||||
if (empty($board_id)) {
|
||||
show_404();
|
||||
}
|
||||
$board = $this->board->item_all($board_id);
|
||||
if (element('access_view', $board) > 0 OR element('access_list', $board) > 0) {
|
||||
alert('비회원이 볼 수 없는 게시판은 RSS 접근이 금지되어 있습니다');
|
||||
return false;
|
||||
}
|
||||
if ( ! element('use_rss_feed', $board)) {
|
||||
alert('이 게시판은 RSS 보기가 금지되어 있습니다');
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if ( ! $this->cbconfig->item('use_total_rss_feed')) {
|
||||
alert('통합게시판의 사용이 금지되어 있습니다');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
header('content-type: text/xml');
|
||||
header('cache-control: no-cache, must-revalidate');
|
||||
header('pragma: no-cache');
|
||||
|
||||
/**
|
||||
* 페이지에 숫자가 아닌 문자가 입력되거나 1보다 작은 숫자가 입력되면 에러 페이지를 보여줍니다.
|
||||
*/
|
||||
if ($rsstype === 'board') {
|
||||
$limit = element('rss_feed_post_count', $board) ? element('rss_feed_post_count', $board) : 50;
|
||||
} else {
|
||||
$limit = $this->cbconfig->item('total_rss_feed_count') ? $this->cbconfig->item('total_rss_feed_count') : 50;
|
||||
}
|
||||
|
||||
/**
|
||||
* 게시판 목록에 필요한 정보를 가져옵니다.
|
||||
*/
|
||||
$boardarray = array();
|
||||
if ($rsstype === 'board') {
|
||||
$where = array(
|
||||
'brd_id' => element('brd_id', $board),
|
||||
'post_secret' => 0,
|
||||
'post_del' => 0,
|
||||
);
|
||||
} else {
|
||||
$whereboard = array(
|
||||
'bmt_key' => 'use_rss_total_feed',
|
||||
'bmt_value' => '1',
|
||||
);
|
||||
$boardlist = $this->Board_meta_model->get('', '', $whereboard);
|
||||
if ($boardlist && is_array($boardlist)) {
|
||||
foreach ($boardlist as $key => $value) {
|
||||
$boardarray[] = element('brd_id', $value);
|
||||
}
|
||||
}
|
||||
$where = array(
|
||||
'post_secret' => 0,
|
||||
'post_del' => 0,
|
||||
);
|
||||
}
|
||||
$result = $this->Post_model->get_rss_list($where, $boardarray, $limit);
|
||||
if (element('list', $result)) {
|
||||
foreach (element('list', $result) as $key => $val) {
|
||||
$result['list'][$key]['title'] = element('post_title', $val);
|
||||
$result['list'][$key]['pubdate'] = cdate('c', strtotime(element('post_datetime', $val)));
|
||||
$result['list'][$key]['author'] = element('post_nickname', $val);
|
||||
$result['list'][$key]['content'] = '';
|
||||
$result['list'][$key]['category'] = '';
|
||||
if ($rsstype === 'board') {
|
||||
if (element('rss_feed_content', $board) === '1') {
|
||||
$result['list'][$key]['content'] = strip_tags(element('post_content', $val));
|
||||
} elseif (element('rss_feed_content', $board) === '2') {
|
||||
$result['list'][$key]['content'] = display_html_content(
|
||||
element('post_content', $val),
|
||||
element('post_html', $val),
|
||||
700
|
||||
);
|
||||
}
|
||||
} else {
|
||||
if ($this->cbconfig->item('total_rss_feed_content') === '1') {
|
||||
$result['list'][$key]['content'] = strip_tags(element('post_content', $val));
|
||||
} elseif ($this->cbconfig->item('total_rss_feed_content') === '2') {
|
||||
$result['list'][$key]['content'] = display_html_content(
|
||||
element('post_content', $val),
|
||||
element('post_html', $val),
|
||||
700
|
||||
);
|
||||
}
|
||||
$board = $this->board->item_all(element('brd_id', $val));
|
||||
}
|
||||
if (element('use_category', $board) && element('post_category', $val)) {
|
||||
$category = $this->Board_category_model
|
||||
->get_category_info(element('brd_id', $val), element('post_category', $val));
|
||||
$result['list'][$key]['category'] = element('bca_value', $category);
|
||||
}
|
||||
$result['list'][$key]['link'] = post_url(element('brd_key', $board), element('post_id', $val));
|
||||
}
|
||||
}
|
||||
|
||||
$view['view']['data'] = $result;
|
||||
if ($rsstype === 'board') {
|
||||
$view['view']['title'] = element('brd_name', $board);
|
||||
$view['view']['url'] = board_url(element('brd_key', $board));
|
||||
$view['view']['copyright'] = element('rss_feed_copyright', $board)
|
||||
? element('rss_feed_copyright', $board)
|
||||
: $this->cbconfig->item('total_rss_feed_copyright');
|
||||
$view['view']['description'] = element('rss_feed_description', $board)
|
||||
? element('rss_feed_description', $board)
|
||||
: $this->cbconfig->item('total_rss_feed_description');
|
||||
} else {
|
||||
$view['view']['title'] = $this->cbconfig->item('total_rss_feed_title')
|
||||
? $this->cbconfig->item('total_rss_feed_title')
|
||||
: $this->cbconfig->item('site_title');
|
||||
$view['view']['url'] = site_url();
|
||||
$view['view']['copyright'] = $this->cbconfig->item('total_rss_feed_copyright');
|
||||
$view['view']['description'] = $this->cbconfig->item('total_rss_feed_description');
|
||||
}
|
||||
$view['view']['board'] = isset($board) ? $board : '';
|
||||
|
||||
/**
|
||||
* primary key 정보를 저장합니다
|
||||
*/
|
||||
$view['view']['primary_key'] = $this->Post_model->primary_key;
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
|
||||
|
||||
/**
|
||||
* 레이아웃을 정의합니다
|
||||
*/
|
||||
$this->data = $view;
|
||||
$skin = $this->cbconfig->item('skin_helptool') ? $this->cbconfig->item('skin_helptool') : $this->cbconfig->item('skin_default');
|
||||
$this->view = 'helptool/' . $skin . '/rss';
|
||||
}
|
||||
}
|
||||
276
application/controllers/Search.php
Normal file
276
application/controllers/Search.php
Normal file
@@ -0,0 +1,276 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Search class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 게시물 전체 검색시 필요한 controller 입니다.
|
||||
*/
|
||||
class Search extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array('Board', 'Board_group', 'Post', 'Post_file', 'Search_keyword');
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/**
|
||||
* 라이브러리를 로딩합니다
|
||||
*/
|
||||
$this->load->library(array('pagination', 'querystring'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 검색 페이지 함수입니다
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_search_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;
|
||||
$findex = 'post_num, post_reply';
|
||||
$sfield = $sfield2 = $this->input->get('sfield', null, '');
|
||||
$sop = $this->input->get('sop', null, '');
|
||||
if ($sfield === 'post_both') {
|
||||
$sfield = array('post_title', 'post_content');
|
||||
}
|
||||
|
||||
$mem_id = (int) $this->member->item('mem_id');
|
||||
|
||||
$skeyword = $this->input->get('skeyword', null, '');
|
||||
if (empty($skeyword)) {
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before_nokeyword_layout'] = Events::trigger('before_nokeyword_layout', $eventname);
|
||||
|
||||
/**
|
||||
* 레이아웃을 정의합니다
|
||||
*/
|
||||
$page_title = $this->cbconfig->item('site_meta_title_search');
|
||||
$meta_description = $this->cbconfig->item('site_meta_description_search');
|
||||
$meta_keywords = $this->cbconfig->item('site_meta_keywords_search');
|
||||
$meta_author = $this->cbconfig->item('site_meta_author_search');
|
||||
$page_name = $this->cbconfig->item('site_page_name_search');
|
||||
|
||||
$layoutconfig = array(
|
||||
'path' => 'search',
|
||||
'layout' => 'layout',
|
||||
'skin' => 'search',
|
||||
'layout_dir' => $this->cbconfig->item('layout_search'),
|
||||
'mobile_layout_dir' => $this->cbconfig->item('mobile_layout_search'),
|
||||
'use_sidebar' => $this->cbconfig->item('sidebar_search'),
|
||||
'use_mobile_sidebar' => $this->cbconfig->item('mobile_sidebar_search'),
|
||||
'skin_dir' => $this->cbconfig->item('skin_search'),
|
||||
'mobile_skin_dir' => $this->cbconfig->item('mobile_skin_search'),
|
||||
'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));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 게시판 목록에 필요한 정보를 가져옵니다.
|
||||
*/
|
||||
$this->Post_model->allow_search_field = array('post_title', 'post_content', 'post_userid', 'post_nickname'); // 검색이 가능한 필드
|
||||
$this->Post_model->search_field_equal = array('post_userid'); // 검색중 like 가 아닌 = 검색을 하는 필드
|
||||
|
||||
$per_page = 15;
|
||||
$offset = ($page - 1) * $per_page;
|
||||
|
||||
$group_id = (int) $this->input->get('group_id') ? (int) $this->input->get('group_id') : '';
|
||||
$board_id = (int) $this->input->get('board_id') ? (int) $this->input->get('board_id') : '';
|
||||
|
||||
$where = array();
|
||||
$boardwhere = array(
|
||||
'brd_search' => 1,
|
||||
);
|
||||
if ($group_id) {
|
||||
$where['board.bgr_id'] = $group_id;
|
||||
$boardwhere['board.bgr_id'] = $group_id;
|
||||
}
|
||||
|
||||
$boardlisttmp = $this->Board_model->get_board_list($boardwhere);
|
||||
$boardlist = array();
|
||||
if (is_array($boardlisttmp)) {
|
||||
foreach ($boardlisttmp as $key => $value) {
|
||||
$boardlist[$value['brd_id']] = $value;
|
||||
}
|
||||
}
|
||||
$grouplisttmp = $this->Board_group_model
|
||||
->get('', '', '', '', 0, 'bgr_order', 'ASC');
|
||||
if (is_array($grouplisttmp)) {
|
||||
foreach ($grouplisttmp as $key => $value) {
|
||||
$grouplist[$value['bgr_id']] = $value;
|
||||
}
|
||||
}
|
||||
$where['post.post_secret'] = 0;
|
||||
$where['post.post_del'] = 0;
|
||||
$like = '';
|
||||
$result = $this->Post_model
|
||||
->get_search_list($per_page, $offset, $where, $like, $board_id, $findex, $sfield, $skeyword, $sop);
|
||||
$list_num = $result['total_rows'] - ($page - 1) * $per_page;
|
||||
if (element('list', $result)) {
|
||||
foreach (element('list', $result) as $key => $val) {
|
||||
$images = '';
|
||||
if (element('post_image', $val)) {
|
||||
$imagewhere = array(
|
||||
'post_id' => element('post_id', $val),
|
||||
'pfi_is_image' => 1,
|
||||
);
|
||||
$images = $this->Post_file_model
|
||||
->get_one('', '', $imagewhere, '', '', 'pfi_id', 'ASC');
|
||||
}
|
||||
$result['list'][$key]['images'] = $images;
|
||||
$result['list'][$key]['post_url'] = post_url(element('brd_key', $val), element('post_id', $val));
|
||||
$result['list'][$key]['display_name'] = display_username(
|
||||
element('post_userid', $val),
|
||||
element('post_nickname', $val),
|
||||
element('mem_icon', $val),
|
||||
'Y'
|
||||
);
|
||||
$result['list'][$key]['display_datetime'] = display_datetime(element('post_datetime', $val), 'user', 'Y-m-d H:i');
|
||||
$result['list'][$key]['content'] = cut_str(strip_tags(element('post_content', $val)),200);
|
||||
$result['list'][$key]['is_mobile'] = (element('post_device', $val) === 'mobile') ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
$view['view']['data'] = $result;
|
||||
|
||||
$view['view']['boardlist'] = $boardlist;
|
||||
$view['view']['grouplist'] = $grouplist;
|
||||
|
||||
|
||||
if ( ! $this->session->userdata('skeyword_' . urlencode($skeyword))) {
|
||||
$sfieldarray = array('post_title', 'post_content', 'post_both');
|
||||
if (in_array($sfield2, $sfieldarray)) {
|
||||
$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_' . urlencode($skeyword),
|
||||
1
|
||||
);
|
||||
}
|
||||
}
|
||||
$highlight_keyword = '';
|
||||
if ($skeyword) {
|
||||
$key_explode = explode(' ', $skeyword);
|
||||
if ($key_explode) {
|
||||
foreach ($key_explode as $seval) {
|
||||
if ($highlight_keyword) {
|
||||
$highlight_keyword .= ',';
|
||||
}
|
||||
$highlight_keyword .= '\'' . html_escape($seval) . '\'';
|
||||
}
|
||||
}
|
||||
}
|
||||
$view['view']['highlight_keyword'] = $highlight_keyword;
|
||||
|
||||
/**
|
||||
* primary key 정보를 저장합니다
|
||||
*/
|
||||
$view['view']['primary_key'] = $this->Post_model->primary_key;
|
||||
|
||||
/**
|
||||
* 페이지네이션을 생성합니다
|
||||
*/
|
||||
$config['base_url'] = site_url('search/') . '?' . $param->replace('page');
|
||||
$view['view']['tab_url'] = site_url('search/') . '?' . $param->replace('page, board_id');
|
||||
$config['total_rows'] = $result['total_rows'];
|
||||
$config['per_page'] = $per_page;
|
||||
if ($this->cbconfig->get_device_view_type() === 'mobile') {
|
||||
$config['num_links'] = 3;
|
||||
} else {
|
||||
$config['num_links'] = 5;
|
||||
}
|
||||
$this->pagination->initialize($config);
|
||||
$view['view']['paging'] = $this->pagination->create_links();
|
||||
$view['view']['page'] = $page;
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
|
||||
|
||||
/**
|
||||
* 레이아웃을 정의합니다
|
||||
*/
|
||||
$page_title = $this->cbconfig->item('site_meta_title_search');
|
||||
$meta_description = $this->cbconfig->item('site_meta_description_search');
|
||||
$meta_keywords = $this->cbconfig->item('site_meta_keywords_search');
|
||||
$meta_author = $this->cbconfig->item('site_meta_author_search');
|
||||
$page_name = $this->cbconfig->item('site_page_name_search');
|
||||
|
||||
$searchconfig = array(
|
||||
'{검색어}',
|
||||
);
|
||||
$replaceconfig = array(
|
||||
$skeyword,
|
||||
);
|
||||
|
||||
$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' => 'search',
|
||||
'layout' => 'layout',
|
||||
'skin' => 'search',
|
||||
'layout_dir' => $this->cbconfig->item('layout_search'),
|
||||
'mobile_layout_dir' => $this->cbconfig->item('mobile_layout_search'),
|
||||
'use_sidebar' => $this->cbconfig->item('sidebar_search'),
|
||||
'use_mobile_sidebar' => $this->cbconfig->item('mobile_sidebar_search'),
|
||||
'skin_dir' => $this->cbconfig->item('skin_search'),
|
||||
'mobile_skin_dir' => $this->cbconfig->item('mobile_skin_search'),
|
||||
'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));
|
||||
}
|
||||
}
|
||||
156
application/controllers/Sitemap.php
Normal file
156
application/controllers/Sitemap.php
Normal file
@@ -0,0 +1,156 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Sitemap class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Sitemap 과 관련된 controller 입니다.
|
||||
*/
|
||||
class Sitemap extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array('Board_meta', 'Post');
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/**
|
||||
* 라이브러리를 로딩합니다
|
||||
*/
|
||||
$this->load->library(array('querystring'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 사이트맵 페이지 함수입니다
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_sitemap_index';
|
||||
$this->load->event($eventname);
|
||||
|
||||
$view = array();
|
||||
$view['view'] = array();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before'] = Events::trigger('before', $eventname);
|
||||
|
||||
if ( ! $this->cbconfig->item('use_sitemap')) {
|
||||
alert('사이트맵 기능을 사용하고 있지 않습니다');
|
||||
return false;
|
||||
}
|
||||
|
||||
$whereboard = array(
|
||||
'bmt_key' => 'use_sitemap',
|
||||
'bmt_value' => '1',
|
||||
);
|
||||
$sitemap = array();
|
||||
$boardlist = $this->Board_meta_model->get('', '', $whereboard);
|
||||
if ($boardlist && is_array($boardlist)) {
|
||||
foreach ($boardlist as $key => $value) {
|
||||
$sitemap[] = array(
|
||||
'loc' => site_url('sitemap_' . element('brd_id', $value) . '.xml'),
|
||||
'brd_id' => element('brd_id', $value)
|
||||
);
|
||||
}
|
||||
}
|
||||
$view['view']['sitemap'] = $sitemap;
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
|
||||
|
||||
/**
|
||||
* 레이아웃을 정의합니다
|
||||
*/
|
||||
header('content-type: text/xml');
|
||||
header('cache-control: no-cache, must-revalidate');
|
||||
header('pragma: no-cache');
|
||||
|
||||
$this->data = $view;
|
||||
$skin = $this->cbconfig->item('skin_helptool') ? $this->cbconfig->item('skin_helptool') : $this->cbconfig->item('skin_default');
|
||||
$this->view = 'helptool/' . $skin . '/sitemap';
|
||||
}
|
||||
|
||||
/**
|
||||
* 사이트맵 페이지 함수입니다
|
||||
*/
|
||||
public function board($brd_id = '')
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_sitemap_detail';
|
||||
$this->load->event($eventname);
|
||||
|
||||
$view = array();
|
||||
$view['view'] = array();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before'] = Events::trigger('before', $eventname);
|
||||
|
||||
if ( ! $this->cbconfig->item('use_sitemap')) {
|
||||
alert('사이트맵 기능을 사용하고 있지 않습니다');
|
||||
return false;
|
||||
}
|
||||
if ( ! isset($brd_id)) {
|
||||
alert('잘못된 접근입니다');
|
||||
return false;
|
||||
}
|
||||
|
||||
$board_id = $this->board->item_id('brd_id', $brd_id);
|
||||
if ( ! $board_id) {
|
||||
alert('존재하지 않는 게시판입니다');
|
||||
return false;
|
||||
}
|
||||
$board = $this->board->item_all($board_id);
|
||||
|
||||
if ( ! element('use_sitemap', $board)) {
|
||||
alert('이 게시판은 sitemap 기능을 사용하지 않습니다');
|
||||
return false;
|
||||
}
|
||||
|
||||
$where = array(
|
||||
'brd_id' => $brd_id,
|
||||
'post_secret' => 0,
|
||||
'post_del' => 0,
|
||||
);
|
||||
$limit = $this->cbconfig->item('sitemap_count') ? $this->cbconfig->item('sitemap_count') : 100;
|
||||
$result = $this->Post_model->get_rss_list($where, '', $limit);
|
||||
if (element('list', $result)) {
|
||||
foreach (element('list', $result) as $key => $val) {
|
||||
$result['list'][$key]['link'] = post_url(element('brd_key', $board), element('post_id', $val));
|
||||
}
|
||||
}
|
||||
|
||||
$view['view']['data'] = $result;
|
||||
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
|
||||
|
||||
header('content-type: text/xml');
|
||||
header('cache-control: no-cache, must-revalidate');
|
||||
header('pragma: no-cache');
|
||||
|
||||
/**
|
||||
* 레이아웃을 정의합니다
|
||||
*/
|
||||
$this->data = $view;
|
||||
$skin = $this->cbconfig->item('skin_helptool') ? $this->cbconfig->item('skin_helptool') : $this->cbconfig->item('skin_default');
|
||||
$this->view = 'helptool/' . $skin . '/sitemap_board.php';
|
||||
}
|
||||
}
|
||||
1118
application/controllers/Social.php
Normal file
1118
application/controllers/Social.php
Normal file
File diff suppressed because it is too large
Load Diff
164
application/controllers/Tags.php
Normal file
164
application/controllers/Tags.php
Normal file
@@ -0,0 +1,164 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Tags class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 게시물 태그 목록을 열람시 필요한 controller 입니다.
|
||||
*/
|
||||
class Tags extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array('Post_file', 'Post_tag');
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/**
|
||||
* 라이브러리를 로딩합니다
|
||||
*/
|
||||
$this->load->library(array('pagination', 'querystring'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 태그 페이지 함수입니다
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_tags_index';
|
||||
$this->load->event($eventname);
|
||||
|
||||
$tag = $this->input->get('tag', null, '');
|
||||
if (empty($tag)) {
|
||||
show_404();
|
||||
}
|
||||
|
||||
$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 = 15;
|
||||
$offset = ($page - 1) * $per_page;
|
||||
|
||||
$result = $this->Post_tag_model->get_tag_list($per_page, $offset, $tag);
|
||||
|
||||
$list_num = $result['total_rows'] - ($page - 1) * $per_page;
|
||||
if (element('list', $result)) {
|
||||
foreach (element('list', $result) as $key => $val) {
|
||||
$images = '';
|
||||
if (element('post_image', $val)) {
|
||||
$imagewhere = array(
|
||||
'post_id' => element('post_id', $val),
|
||||
'pfi_is_image' => 1,
|
||||
);
|
||||
$images = $this->Post_file_model
|
||||
->get_one('', '', $imagewhere, '', '', 'pfi_id', 'ASC');
|
||||
}
|
||||
$result['list'][$key]['images'] = $images;
|
||||
$result['list'][$key]['post_url'] = post_url(element('brd_key', $val), element('post_id', $val));
|
||||
$dbmember = $this->Member_model->get_by_memid(element('mem_id', $val), 'mem_icon');
|
||||
$result['list'][$key]['display_name'] = display_username(
|
||||
element('post_userid', $val),
|
||||
element('post_nickname', $val),
|
||||
element('mem_icon', $dbmember),
|
||||
'Y'
|
||||
);
|
||||
$result['list'][$key]['display_datetime'] = display_datetime(
|
||||
element('post_datetime', $val),
|
||||
'user',
|
||||
'Y-m-d H:i'
|
||||
);
|
||||
$result['list'][$key]['content'] = cut_str(strip_tags(element('post_content', $val)),200);
|
||||
$result['list'][$key]['is_mobile'] = (element('post_device', $val) === 'mobile') ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
$view['view']['data'] = $result;
|
||||
|
||||
/**
|
||||
* 페이지네이션을 생성합니다
|
||||
*/
|
||||
$config['base_url'] = site_url('tags/') . '?' . $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'] = 3;
|
||||
} else {
|
||||
$config['num_links'] = 5;
|
||||
}
|
||||
$this->pagination->initialize($config);
|
||||
$view['view']['paging'] = $this->pagination->create_links();
|
||||
$view['view']['page'] = $page;
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
|
||||
|
||||
/**
|
||||
* 레이아웃을 정의합니다
|
||||
*/
|
||||
$page_title = $this->cbconfig->item('site_meta_title_tag');
|
||||
$meta_description = $this->cbconfig->item('site_meta_description_tag');
|
||||
$meta_keywords = $this->cbconfig->item('site_meta_keywords_tag');
|
||||
$meta_author = $this->cbconfig->item('site_meta_author_tag');
|
||||
$page_name = $this->cbconfig->item('site_page_name_tag');
|
||||
|
||||
$searchconfig = array(
|
||||
'{태그명}',
|
||||
);
|
||||
$replaceconfig = array(
|
||||
$tag,
|
||||
);
|
||||
|
||||
$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' => 'tag',
|
||||
'layout' => 'layout',
|
||||
'skin' => 'tag',
|
||||
'layout_dir' => $this->cbconfig->item('layout_tag'),
|
||||
'mobile_layout_dir' => $this->cbconfig->item('mobile_layout_tag'),
|
||||
'use_sidebar' => $this->cbconfig->item('sidebar_tag'),
|
||||
'use_mobile_sidebar' => $this->cbconfig->item('mobile_sidebar_tag'),
|
||||
'skin_dir' => $this->cbconfig->item('skin_tag'),
|
||||
'mobile_skin_dir' => $this->cbconfig->item('mobile_skin_tag'),
|
||||
'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));
|
||||
}
|
||||
}
|
||||
356
application/controllers/Verify.php
Normal file
356
application/controllers/Verify.php
Normal file
@@ -0,0 +1,356 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Verify class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 이메일 인증 시 필요한 controller 입니다.
|
||||
*/
|
||||
class Verify extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array('Member_auth_email');
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/**
|
||||
* 라이브러리를 로딩합니다
|
||||
*/
|
||||
$this->load->library(array('querystring'));
|
||||
if ( ! function_exists('password_hash')) {
|
||||
$this->load->helper('password');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 이메일 인증 함수입니다.
|
||||
*/
|
||||
public function confirmemail()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_verify_confirmemail';
|
||||
$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();
|
||||
}
|
||||
if ( ! $this->cbconfig->item('use_register_email_auth')) {
|
||||
alert('이 웹사이트는 이메일 인증 기능을 사용하고 있지 않습니다');
|
||||
}
|
||||
|
||||
$where = array(
|
||||
'mae_key' => $this->input->get('code'),
|
||||
);
|
||||
$result = $this->Member_auth_email_model->get_one('', '', $where);
|
||||
|
||||
if ( ! element('mae_id', $result)) {
|
||||
$view['view']['message'] = '잘못된 접근입니다';
|
||||
} elseif ( ! (element('mae_type', $result) === '1' OR element('mae_type', $result) === '2')) {
|
||||
$view['view']['message'] = '잘못된 접근입니다';
|
||||
} elseif ( ! empty($result['mae_use_datetime']) && element('mae_use_datetime', $result) !== '0000-00-00 00:00:00') {
|
||||
$view['view']['message'] = '회원님은 이미 인증을 받으셨습니다';
|
||||
} elseif (strtotime(element('mae_generate_datetime', $result)) < ctimestamp()- 86400) {
|
||||
$view['view']['message'] = '24 시간 이내에 인증을 받으셔야 합니다';
|
||||
} elseif (element('mae_expired', $result)) {
|
||||
$view['view']['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']['message'] = '잘못된 접근입니다';
|
||||
} elseif (element('mem_userid', $dbmember) !== $this->input->get('user')) {
|
||||
$view['view']['message'] = '잘못된 접근입니다';
|
||||
} elseif (element('mem_denied', $dbmember)) {
|
||||
$view['view']['message'] = '접근이 금지된 아이디입니다';
|
||||
} elseif (element('mem_email_cert', $dbmember)) {
|
||||
$view['view']['message'] = '회원님은 이미 인증을 받으셨습니다';
|
||||
} else {
|
||||
|
||||
$updatedata = array(
|
||||
'mem_email_cert' => 1,
|
||||
);
|
||||
$this->Member_model->update(element('mem_id', $result), $updatedata);
|
||||
$metadata = array(
|
||||
'meta_email_cert_datetime' => cdate('Y-m-d H:i:s'),
|
||||
);
|
||||
$this->load->model('Member_meta_model');
|
||||
$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
|
||||
);
|
||||
$view['view']['message'] = '이메일 인증이 완료되었습니다.<br />감사합니다';
|
||||
$this->Member_auth_email_model->update(element('mae_id', $result), $updateemail);
|
||||
|
||||
$this->member->update_login_log(element('mem_id', $dbmember), element('mem_userid', $dbmember), 1, '이메일 인증 후 로그인 성공');
|
||||
$this->session->set_userdata('mem_id', element('mem_id', $dbmember));
|
||||
}
|
||||
}
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
|
||||
|
||||
/**
|
||||
* 레이아웃을 정의합니다
|
||||
*/
|
||||
$page_title = '이메일 인증';
|
||||
$layoutconfig = array(
|
||||
'path' => 'findaccount',
|
||||
'layout' => 'layout',
|
||||
'skin' => 'verifyemail',
|
||||
'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));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 패스워드 리셋위한 함수입니다.
|
||||
*/
|
||||
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 {
|
||||
$is_dormant_member = false;
|
||||
$select = 'mem_id, mem_userid, mem_denied, mem_email_cert';
|
||||
$dbmember = $this->Member_model->get_by_memid(element('mem_id', $result), $select);
|
||||
if ( ! $dbmember) {
|
||||
$this->load->model('Member_dormant_model');
|
||||
$dbmember = $this->Member_dormant_model->get_by_memid(element('mem_id', $result), $select);
|
||||
if ($dbmember) {
|
||||
$is_dormant_member = true;
|
||||
}
|
||||
}
|
||||
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)) {
|
||||
$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'])) {
|
||||
|
||||
if ($is_dormant_member) {
|
||||
$this->member->recover_from_dormant(element('mem_id', $result));
|
||||
}
|
||||
|
||||
$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->load->model('Member_meta_model');
|
||||
$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), element('mem_userid', $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));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 새로 입력한 패스워드가 규약에 맞는지 체크합니다.
|
||||
*/
|
||||
public function _mem_password_check($str)
|
||||
{
|
||||
$uppercase = $this->cbconfig->item('password_uppercase_length');
|
||||
$number = $this->cbconfig->item('password_numbers_length');
|
||||
$specialchar = $this->cbconfig->item('password_specialchars_length');
|
||||
|
||||
$this->load->helper('chkstring');
|
||||
$str_uc = count_uppercase($str);
|
||||
$str_num = count_numbers($str);
|
||||
$str_spc = count_specialchars($str);
|
||||
|
||||
if ($str_uc < $uppercase OR $str_num < $number OR $str_spc < $specialchar) {
|
||||
|
||||
$description = '비밀번호는 ';
|
||||
if ($str_uc < $uppercase) {
|
||||
$description .= ' ' . $uppercase . '개 이상의 대문자';
|
||||
}
|
||||
if ($str_num < $number) {
|
||||
$description .= ' ' . $number . '개 이상의 숫자';
|
||||
}
|
||||
if ($str_spc < $specialchar) {
|
||||
$description .= ' ' . $specialchar . '개 이상의 특수문자';
|
||||
}
|
||||
$description .= '를 포함해야 합니다';
|
||||
|
||||
$this->form_validation->set_message(
|
||||
'_mem_password_check',
|
||||
$description
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
121
application/controllers/admin/Main.php
Normal file
121
application/controllers/admin/Main.php
Normal file
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Main class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 관리자 메인 controller 입니다.
|
||||
*/
|
||||
class Main extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 관리자 페이지 상의 현재 디렉토리입니다
|
||||
* 페이지 이동시 필요한 정보입니다
|
||||
*/
|
||||
public $pagedir = '';
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array('Post', 'Comment', 'Point');
|
||||
|
||||
/**
|
||||
* 이 컨트롤러의 메인 모델 이름입니다
|
||||
*/
|
||||
protected $modelname = '';
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/**
|
||||
* 라이브러리를 로딩합니다
|
||||
*/
|
||||
$this->load->library(array('querystring'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 관리자 메인 페이지입니다
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_main_index';
|
||||
$this->load->event($eventname);
|
||||
|
||||
$view = array();
|
||||
$view['view'] = array();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before'] = Events::trigger('before', $eventname);
|
||||
|
||||
$view['view']['latest_member'] = $this->Member_model->get_admin_list(7, '', '', '', 'mem_id', 'desc', '', '');
|
||||
if (isset($view['view']['latest_member']['list']) && is_array($view['view']['latest_member']['list'])) {
|
||||
foreach ($view['view']['latest_member']['list'] as $key => $val) {
|
||||
$view['view']['latest_member']['list'][$key]['display_name'] = display_username(
|
||||
element('mem_userid', $val),
|
||||
element('mem_nickname', $val)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$view['view']['latest_point'] = $this->Point_model->get_admin_list(7, '', '', '', 'poi_id', 'desc', '', '');
|
||||
if (isset($view['view']['latest_point']['list']) && is_array($view['view']['latest_point']['list'])) {
|
||||
foreach ($view['view']['latest_point']['list'] as $key => $val) {
|
||||
$view['view']['latest_point']['list'][$key]['display_name'] = display_username(
|
||||
element('mem_userid', $val),
|
||||
element('mem_nickname', $val)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$view['view']['latest_post'] = $this->Post_model->get_admin_list(7, '', '', '', 'post_id', 'desc', '', '');
|
||||
if (isset($view['view']['latest_post']['list']) && is_array($view['view']['latest_post']['list'])) {
|
||||
foreach ($view['view']['latest_post']['list'] as $key => $val) {
|
||||
$brd_key = $this->board->item_id('brd_key', element('brd_id', $val));
|
||||
$view['view']['latest_post']['list'][$key]['post_url'] = post_url($brd_key, element('post_id', $val));
|
||||
$view['view']['latest_post']['list'][$key]['display_name'] = display_username(
|
||||
element('post_userid', $val),
|
||||
element('post_nickname', $val)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$view['view']['latest_comment'] = $this->Comment_model->get_admin_list(7, '', '', '', 'cmt_id', 'desc', '', '');
|
||||
if (isset($view['view']['latest_comment']['list']) && is_array($view['view']['latest_comment']['list'])) {
|
||||
foreach ($view['view']['latest_comment']['list'] as $key => $val) {
|
||||
$post = $this->Post_model->get_one(element('post_id', $val), 'brd_id');
|
||||
$brd_key = $this->board->item_id('brd_key', element('brd_id', $post));
|
||||
$view['view']['latest_comment']['list'][$key]['post_url'] = post_url($brd_key, element('post_id', $val)) . '#comment_' . element('cmt_id', $val);
|
||||
$view['view']['latest_comment']['list'][$key]['display_name'] = display_username(
|
||||
element('cmt_userid', $val),
|
||||
element('cmt_nickname', $val)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
|
||||
|
||||
/**
|
||||
* 어드민 레이아웃을 정의합니다
|
||||
*/
|
||||
$layoutconfig = array('layout' => 'layout', 'skin' => 'main');
|
||||
$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));
|
||||
}
|
||||
}
|
||||
380
application/controllers/admin/board/Blame.php
Normal file
380
application/controllers/admin/board/Blame.php
Normal file
@@ -0,0 +1,380 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Blame class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 관리자>게시판설정>신고 controller 입니다.
|
||||
*/
|
||||
class Blame extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 관리자 페이지 상의 현재 디렉토리입니다
|
||||
* 페이지 이동시 필요한 정보입니다
|
||||
*/
|
||||
public $pagedir = 'board/blame';
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array('Blame', 'Board', 'Post', 'Comment');
|
||||
|
||||
/**
|
||||
* 이 컨트롤러의 메인 모델 이름입니다
|
||||
*/
|
||||
protected $modelname = 'Blame_model';
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/**
|
||||
* 라이브러리를 로딩합니다
|
||||
*/
|
||||
$this->load->library(array('pagination', 'querystring'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록을 가져오는 메소드입니다
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_blame_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;
|
||||
$findex = $this->input->get('findex') ? $this->input->get('findex') : $this->{$this->modelname}->primary_key;
|
||||
$forder = $this->input->get('forder', null, 'desc');
|
||||
$sfield = $this->input->get('sfield', null, '');
|
||||
$skeyword = $this->input->get('skeyword', null, '');
|
||||
|
||||
$per_page = admin_listnum();
|
||||
$offset = ($page - 1) * $per_page;
|
||||
|
||||
/**
|
||||
* 게시판 목록에 필요한 정보를 가져옵니다.
|
||||
*/
|
||||
$this->{$this->modelname}->allow_search_field = array('bla_id', 'target_id', 'target_type', 'blame.mem_id', 'target_mem_id', 'bla_ip'); // 검색이 가능한 필드
|
||||
$this->{$this->modelname}->search_field_equal = array('bla_id', 'target_id', 'blame.mem_id', 'target_mem_id'); // 검색중 like 가 아닌 = 검색을 하는 필드
|
||||
$this->{$this->modelname}->allow_order_field = array('bla_id'); // 정렬이 가능한 필드
|
||||
|
||||
$where = array();
|
||||
if ($brdid = (int) $this->input->get('brd_id')) {
|
||||
$where['blame.brd_id'] = $brdid;
|
||||
}
|
||||
$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)
|
||||
);
|
||||
$select = 'mem_id, mem_userid, mem_nickname, mem_icon';
|
||||
$result['list'][$key]['target_member'] = $target_member = $this->Member_model->get_by_memid(element('target_mem_id', $val), $select);
|
||||
$result['list'][$key]['target_display_name'] = display_username(
|
||||
element('mem_userid', $target_member),
|
||||
element('mem_nickname', $target_member),
|
||||
element('mem_icon', $target_member)
|
||||
);
|
||||
$result['list'][$key]['num'] = $list_num--;
|
||||
|
||||
$select = 'post_id, brd_id, post_title, post_datetime, post_ip';
|
||||
if (element('target_type', $val) === '1') {
|
||||
$result['list'][$key]['target_name'] = '원글';
|
||||
$result['list'][$key]['post'] = $post = $this->Post_model->get_one(element('target_id', $val), $select);
|
||||
if ($post) {
|
||||
$result['list'][$key]['board'] = $board = $this->board->item_all(element('brd_id', $post));
|
||||
$result['list'][$key]['origin_content'] = element('post_title', $post);
|
||||
$result['list'][$key]['origin_datetime'] = element('post_datetime', $post);
|
||||
$result['list'][$key]['origin_ip'] = element('post_ip', $post);
|
||||
$result['list'][$key]['posturl'] = post_url(element('brd_key', $board), element('post_id', $post));
|
||||
}
|
||||
} elseif (element('target_type', $val) === '2') {
|
||||
$result['list'][$key]['target_name'] = '댓글';
|
||||
$commentselect = 'cmt_id, post_id, cmt_content, cmt_datetime, cmt_ip';
|
||||
$result['list'][$key]['comment'] = $comment
|
||||
= $this->Comment_model->get_one(element('target_id', $val), $commentselect);
|
||||
if ($comment) {
|
||||
$result['list'][$key]['post'] = $post
|
||||
= $this->Post_model->get_one(element('post_id', $comment), $select);
|
||||
$result['list'][$key]['origin_content'] = cut_str(element('cmt_content', $comment),40);
|
||||
$result['list'][$key]['origin_datetime'] = element('cmt_datetime', $comment);
|
||||
$result['list'][$key]['origin_ip'] = element('cmt_ip', $comment);
|
||||
if ($post) {
|
||||
$result['list'][$key]['board'] = $board = $this->board->item_all(element('brd_id', $post));
|
||||
$result['list'][$key]['posturl'] = post_url(element('brd_key', $board), element('post_id', $post)) . '#comment_id=' . element('cmt_id', $comment);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$view['view']['data'] = $result;
|
||||
$view['view']['boardlist'] = $this->Board_model->get_board_list();
|
||||
|
||||
/**
|
||||
* 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('bla_ip' => '신고IP');
|
||||
$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']['list_delete_url'] = admin_url($this->pagedir . '/listdelete/?' . $param->output());
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$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));
|
||||
}
|
||||
|
||||
/**
|
||||
* 신고현황을 그래프 형식으로 보는 페이지입니다
|
||||
*/
|
||||
public function graph($export = '')
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_blame_graph';
|
||||
$this->load->event($eventname);
|
||||
|
||||
$view = array();
|
||||
$view['view'] = array();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before'] = Events::trigger('before', $eventname);
|
||||
|
||||
$param =& $this->querystring;
|
||||
$datetype = $this->input->get('datetype', null, 'd');
|
||||
if ($datetype !== 'm' && $datetype !== 'y') {
|
||||
$datetype = 'd';
|
||||
}
|
||||
$start_date = $this->input->get('start_date') ? $this->input->get('start_date') : cdate('Y-m-01');
|
||||
$end_date = $this->input->get('end_date') ? $this->input->get('end_date') : cdate('Y-m-d');
|
||||
if ($datetype === 'y' OR $datetype === 'm') {
|
||||
$start_year = substr($start_date, 0, 4);
|
||||
$end_year = substr($end_date, 0, 4);
|
||||
}
|
||||
if ($datetype === 'm') {
|
||||
$start_month = substr($start_date, 5, 2);
|
||||
$end_month = substr($end_date, 5, 2);
|
||||
$start_year_month = $start_year * 12 + $start_month;
|
||||
$end_year_month = $end_year * 12 + $end_month;
|
||||
}
|
||||
$orderby = (strtolower($this->input->get('orderby')) === 'desc') ? 'desc' : 'asc';
|
||||
|
||||
$brd_id = $this->input->get('brd_id', null, '');
|
||||
|
||||
$result = $this->{$this->modelname}->get_blame_count($datetype, $start_date, $end_date, $brd_id, $orderby);
|
||||
$sum_count = 0;
|
||||
$arr = array();
|
||||
$max = 0;
|
||||
|
||||
if ($result && is_array($result)) {
|
||||
foreach ($result as $key => $value) {
|
||||
$s = element('day', $value);
|
||||
if ( ! isset($arr[$s])) {
|
||||
$arr[$s] = 0;
|
||||
}
|
||||
$arr[$s] += element('cnt', $value);
|
||||
|
||||
if ($arr[$s] > $max) {
|
||||
$max = $arr[$s];
|
||||
}
|
||||
$sum_count += element('cnt', $value);
|
||||
}
|
||||
}
|
||||
|
||||
$result = array();
|
||||
$i = 0;
|
||||
$save_count = -1;
|
||||
$tot_count = 0;
|
||||
|
||||
if (count($arr)) {
|
||||
foreach ($arr as $key => $value) {
|
||||
$count = (int) $arr[$key];
|
||||
$result[$key]['count'] = $count;
|
||||
$i++;
|
||||
if ($save_count !== $count) {
|
||||
$no = $i;
|
||||
$save_count = $count;
|
||||
}
|
||||
$result[$key]['no'] = $no;
|
||||
|
||||
$result[$key]['key'] = $key;
|
||||
$rate = ($count / $sum_count * 100);
|
||||
$result[$key]['rate'] = $rate;
|
||||
$s_rate = number_format($rate, 1);
|
||||
$result[$key]['s_rate'] = $s_rate;
|
||||
|
||||
$bar = (int) ($count / $max * 100);
|
||||
$result[$key]['bar'] = $bar;
|
||||
}
|
||||
$view['view']['max_value'] = $max;
|
||||
$view['view']['sum_count'] = $sum_count;
|
||||
}
|
||||
|
||||
if ($datetype === 'y') {
|
||||
for ($i = $start_year; $i <= $end_year; $i++) {
|
||||
if( ! isset($result[$i])) $result[$i] = '';
|
||||
}
|
||||
} elseif ($datetype === 'm') {
|
||||
for ($i = $start_year_month; $i <= $end_year_month; $i++) {
|
||||
$year = floor($i / 12);
|
||||
if ($year * 12 == $i) $year--;
|
||||
$month = sprintf("%02d", ($i - ($year * 12)));
|
||||
$date = $year . '-' . $month;
|
||||
if( ! isset($result[$date])) $result[$date] = '';
|
||||
}
|
||||
} elseif ($datetype === 'd') {
|
||||
$date = $start_date;
|
||||
while ($date <= $end_date) {
|
||||
if( ! isset($result[$date])) $result[$date] = '';
|
||||
$date = cdate('Y-m-d', strtotime($date) + 86400);
|
||||
}
|
||||
}
|
||||
|
||||
if ($orderby === 'desc') {
|
||||
krsort($result);
|
||||
} else {
|
||||
ksort($result);
|
||||
}
|
||||
|
||||
$view['view']['list'] = $result;
|
||||
|
||||
$view['view']['start_date'] = $start_date;
|
||||
$view['view']['end_date'] = $end_date;
|
||||
$view['view']['datetype'] = $datetype;
|
||||
|
||||
$view['view']['boardlist'] = $this->Board_model->get_board_list();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
|
||||
|
||||
if ($export === 'excel') {
|
||||
|
||||
header('Content-type: application/vnd.ms-excel');
|
||||
header('Content-Disposition: attachment; filename=신고현황_' . cdate('Y_m_d') . '.xls');
|
||||
echo $this->load->view('admin/' . ADMIN_SKIN . '/' . $this->pagedir . '/graph_excel', $view, true);
|
||||
|
||||
} else {
|
||||
/**
|
||||
* 어드민 레이아웃을 정의합니다
|
||||
*/
|
||||
$layoutconfig = array('layout' => 'layout', 'skin' => 'graph');
|
||||
$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));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록 페이지에서 선택삭제를 하는 경우 실행되는 메소드입니다
|
||||
*/
|
||||
public function listdelete()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_blame_listdelete';
|
||||
$this->load->event($eventname);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('before', $eventname);
|
||||
|
||||
/**
|
||||
* 체크한 게시물의 삭제를 실행합니다
|
||||
*/
|
||||
if ($this->input->post('chk') && is_array($this->input->post('chk'))) {
|
||||
foreach ($this->input->post('chk') as $val) {
|
||||
if ($val) {
|
||||
$getdata = $this->{$this->modelname}->get_one($val);
|
||||
|
||||
if ( ! element('bla_id', $getdata)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->{$this->modelname}->delete($val);
|
||||
|
||||
$where = array(
|
||||
'target_id' => element('target_id', $getdata),
|
||||
'target_type' => element('target_type', $getdata),
|
||||
);
|
||||
$blame_cnt = $this->{$this->modelname}->count_by($where);
|
||||
|
||||
if (element('target_type', $getdata) === '1') { // 원글 신고의 경우
|
||||
$updatedata = array(
|
||||
'post_blame' => $blame_cnt,
|
||||
);
|
||||
$this->Post_model->update(element('target_id', $getdata), $updatedata);
|
||||
} elseif (element('target_type', $getdata) === '2') { // 댓글 신고의 경우
|
||||
$updatedata = array(
|
||||
'cmt_blame' => $blame_cnt,
|
||||
);
|
||||
$this->Comment_model->update(element('target_id', $getdata), $updatedata);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after', $eventname);
|
||||
|
||||
/**
|
||||
* 삭제가 끝난 후 목록페이지로 이동합니다
|
||||
*/
|
||||
$this->session->set_flashdata(
|
||||
'message',
|
||||
'정상적으로 삭제되었습니다'
|
||||
);
|
||||
$param =& $this->querystring;
|
||||
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
|
||||
|
||||
redirect($redirecturl);
|
||||
}
|
||||
}
|
||||
727
application/controllers/admin/board/Boardgroup.php
Normal file
727
application/controllers/admin/board/Boardgroup.php
Normal file
@@ -0,0 +1,727 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Boardgroup class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 관리자>게시판설정>게시판그룹관리 controller 입니다.
|
||||
*/
|
||||
class Boardgroup extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 관리자 페이지 상의 현재 디렉토리입니다
|
||||
* 페이지 이동시 필요한 정보입니다
|
||||
*/
|
||||
public $pagedir = 'board/boardgroup';
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array('Board_group', 'Board_group_meta', 'Board', 'Board_group_admin');
|
||||
|
||||
/**
|
||||
* 이 컨트롤러의 메인 모델 이름입니다
|
||||
*/
|
||||
protected $modelname = 'Board_group_model';
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/**
|
||||
* 라이브러리를 로딩합니다
|
||||
*/
|
||||
$this->load->library(array('pagination', 'querystring'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록을 가져오는 메소드입니다
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_boardgroup_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(
|
||||
'bgr_id' => $param->sort('bgr_id', 'asc'),
|
||||
'bgr_key' => $param->sort('bgr_key', 'asc'),
|
||||
'bgr_name' => $param->sort('bgr_name', 'asc'),
|
||||
'bgr_order' => $param->sort('bgr_order', 'asc'),
|
||||
);
|
||||
$findex = $this->input->get('findex', null, 'bgr_order');
|
||||
$forder = $this->input->get('forder', null, 'asc');
|
||||
$sfield = $this->input->get('sfield', null, '');
|
||||
$skeyword = $this->input->get('skeyword', null, '');
|
||||
|
||||
$per_page = admin_listnum();
|
||||
$offset = ($page - 1) * $per_page;
|
||||
|
||||
/**
|
||||
* 게시판 목록에 필요한 정보를 가져옵니다.
|
||||
*/
|
||||
$this->{$this->modelname}->allow_search_field = array('bgr_id', 'bgr_key', 'bgr_name', 'bgr_order'); // 검색이 가능한 필드
|
||||
$this->{$this->modelname}->search_field_equal = array('bgr_id'); // 검색중 like 가 아닌 = 검색을 하는 필드
|
||||
$this->{$this->modelname}->allow_order_field = array('bgr_id', 'bgr_key', 'bgr_name', 'bgr_order'); // 정렬이 가능한 필드
|
||||
$result = $this->{$this->modelname}
|
||||
->get_admin_list($per_page, $offset, '', '', $findex, $forder, $sfield, $skeyword);
|
||||
$list_num = $result['total_rows'] - ($page - 1) * $per_page;
|
||||
if (element('list', $result)) {
|
||||
foreach (element('list', $result) as $key => $val) {
|
||||
$countwhere = array(
|
||||
'bgr_id' => element('bgr_id', $val),
|
||||
);
|
||||
$result['list'][$key]['brd_cnt'] = $this->Board_model->count_by($countwhere);
|
||||
$result['list'][$key]['meta'] = $this->Board_group_meta_model
|
||||
->get_all_meta(element('bgr_id', $val));
|
||||
$result['list'][$key]['group_skin_option'] = get_skin_name(
|
||||
'group',
|
||||
element('group_skin', $result['list'][$key]['meta']),
|
||||
'기본설정따름'
|
||||
);
|
||||
$result['list'][$key]['group_mobile_skin_option'] = get_skin_name(
|
||||
'group',
|
||||
element('group_mobile_skin', $result['list'][$key]['meta']),
|
||||
'기본설정따름'
|
||||
);
|
||||
$result['list'][$key]['group_layout_option'] = get_skin_name(
|
||||
'_layout',
|
||||
element('group_layout', $result['list'][$key]['meta']),
|
||||
'기본설정따름'
|
||||
);
|
||||
$result['list'][$key]['group_mobile_layout_option'] = get_skin_name(
|
||||
'_layout',
|
||||
element('group_mobile_layout', $result['list'][$key]['meta']),
|
||||
'기본설정따름'
|
||||
);
|
||||
$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('bgr_key' => 'KEY', 'bgr_name' => '제목', 'bgr_order' => '정렬순서');
|
||||
$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']['write_url'] = admin_url($this->pagedir . '/write');
|
||||
$view['view']['list_update_url'] = admin_url($this->pagedir . '/listupdate/?' . $param->output());
|
||||
$view['view']['list_delete_url'] = admin_url($this->pagedir . '/listdelete/?' . $param->output());
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$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));
|
||||
}
|
||||
|
||||
/**
|
||||
* 게시판 글쓰기 또는 수정 페이지를 가져오는 메소드입니다
|
||||
*/
|
||||
public function write($pid = 0)
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_boardgroup_write';
|
||||
$this->load->event($eventname);
|
||||
|
||||
$view = array();
|
||||
$view['view'] = array();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before'] = Events::trigger('before', $eventname);
|
||||
|
||||
/**
|
||||
* 프라이머리키에 숫자형이 입력되지 않으면 에러처리합니다
|
||||
*/
|
||||
if ($pid) {
|
||||
$pid = (int) $pid;
|
||||
if (empty($pid) OR $pid < 1) {
|
||||
show_404();
|
||||
}
|
||||
}
|
||||
$primary_key = $this->{$this->modelname}->primary_key;
|
||||
|
||||
/**
|
||||
* 수정 페이지일 경우 기존 데이터를 가져옵니다
|
||||
*/
|
||||
if ($pid) {
|
||||
$getdata = $this->{$this->modelname}->get_one($pid);
|
||||
$board_group_meta = $this->Board_group_meta_model->get_all_meta($getdata['bgr_id']);
|
||||
if (is_array($board_group_meta)) {
|
||||
$getdata = array_merge($getdata, $board_group_meta);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validation 라이브러리를 가져옵니다
|
||||
*/
|
||||
$this->load->library('form_validation');
|
||||
|
||||
/**
|
||||
* 전송된 데이터의 유효성을 체크합니다
|
||||
*/
|
||||
$config = array(
|
||||
array(
|
||||
'field' => 'bgr_name',
|
||||
'label' => '그룹명',
|
||||
'rules' => 'trim|required',
|
||||
),
|
||||
array(
|
||||
'field' => 'bgr_order',
|
||||
'label' => '그룹정렬순서',
|
||||
'rules' => 'trim|required|numeric|is_natural',
|
||||
),
|
||||
array(
|
||||
'field' => 'group_layout',
|
||||
'label' => '레이아웃',
|
||||
'rules' => 'trim',
|
||||
),
|
||||
array(
|
||||
'field' => 'group_mobile_layout',
|
||||
'label' => '모바일레이아웃',
|
||||
'rules' => 'trim',
|
||||
),
|
||||
array(
|
||||
'field' => 'group_sidebar',
|
||||
'label' => '사이드바',
|
||||
'rules' => 'trim',
|
||||
),
|
||||
array(
|
||||
'field' => 'group_mobile_sidebar',
|
||||
'label' => '모바일사이드바',
|
||||
'rules' => 'trim',
|
||||
),
|
||||
array(
|
||||
'field' => 'group_skin',
|
||||
'label' => '스킨',
|
||||
'rules' => 'trim',
|
||||
),
|
||||
array(
|
||||
'field' => 'group_mobile_skin',
|
||||
'label' => '모바일스킨',
|
||||
'rules' => 'trim',
|
||||
),
|
||||
array(
|
||||
'field' => 'header_content',
|
||||
'label' => '상단내용',
|
||||
'rules' => 'trim',
|
||||
),
|
||||
array(
|
||||
'field' => 'footer_content',
|
||||
'label' => '하단내용',
|
||||
'rules' => 'trim',
|
||||
),
|
||||
array(
|
||||
'field' => 'mobile_header_content',
|
||||
'label' => '모바일상단내용',
|
||||
'rules' => 'trim',
|
||||
),
|
||||
array(
|
||||
'field' => 'mobile_footer_content',
|
||||
'label' => '모바일하단내용',
|
||||
'rules' => 'trim',
|
||||
),
|
||||
);
|
||||
if ($this->input->post($primary_key)) {
|
||||
$config[] = array(
|
||||
'field' => 'bgr_key',
|
||||
'label' => '페이지주소',
|
||||
'rules' => 'trim|required|alpha_dash|min_length[3]|max_length[50]|is_unique[board_group.bgr_key.bgr_id.' . $getdata['bgr_id'] . ']',
|
||||
);
|
||||
} else {
|
||||
$config[] = array(
|
||||
'field' => 'bgr_key',
|
||||
'label' => '페이지주소',
|
||||
'rules' => 'trim|required|alpha_dash|min_length[3]|max_length[50]|is_unique[board_group.bgr_key]',
|
||||
);
|
||||
}
|
||||
$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);
|
||||
|
||||
$bgr_order = $this->input->post('bgr_order') ? $this->input->post('bgr_order') : 0;
|
||||
$updatedata = array(
|
||||
'bgr_key' => $this->input->post('bgr_key', null, ''),
|
||||
'bgr_name' => $this->input->post('bgr_name', null, ''),
|
||||
'bgr_order' => $bgr_order,
|
||||
);
|
||||
|
||||
$array = array(
|
||||
'group_layout', 'group_mobile_layout', 'group_sidebar', 'group_mobile_sidebar',
|
||||
'group_skin', 'group_mobile_skin', 'header_content', 'footer_content',
|
||||
'mobile_header_content', 'mobile_footer_content',);
|
||||
$metadata = array();
|
||||
if ($array) {
|
||||
foreach ($array as $value) {
|
||||
$metadata[$value] = $this->input->post($value, null, '');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 게시물을 수정하는 경우입니다
|
||||
*/
|
||||
if ($this->input->post($primary_key)) {
|
||||
$this->{$this->modelname}->update($this->input->post($primary_key), $updatedata);
|
||||
$this->Board_group_meta_model->save($pid, $metadata);
|
||||
$view['view']['alert_message'] = '기본정보 설정이 저장되었습니다';
|
||||
} else {
|
||||
/**
|
||||
* 게시물을 새로 입력하는 경우입니다
|
||||
*/
|
||||
$pid = $this->{$this->modelname}->insert($updatedata);
|
||||
$this->Board_group_meta_model->save($pid, $metadata);
|
||||
$this->session->set_flashdata(
|
||||
'message',
|
||||
'기본정보 설정이 저장되었습니다'
|
||||
);
|
||||
|
||||
$redirecturl = admin_url($this->pagedir . '/write/' . $pid);
|
||||
redirect($redirecturl);
|
||||
}
|
||||
}
|
||||
|
||||
$getdata = array();
|
||||
if ($pid) {
|
||||
$getdata = $this->{$this->modelname}->get_one($pid);
|
||||
$board_group_meta = $this->Board_group_meta_model->get_all_meta($getdata['bgr_id']);
|
||||
if (is_array($board_group_meta)) {
|
||||
$getdata = array_merge($getdata, $board_group_meta);
|
||||
}
|
||||
}
|
||||
$view['view']['data'] = $getdata;
|
||||
$view['view']['data']['group_layout_option'] = get_skin_name(
|
||||
'_layout',
|
||||
set_value('group_layout', element('group_layout', $getdata)),
|
||||
'기본설정따름'
|
||||
);
|
||||
$view['view']['data']['group_mobile_layout_option'] = get_skin_name(
|
||||
'_layout',
|
||||
set_value('group_mobile_layout', element('group_mobile_layout', $getdata)),
|
||||
'기본설정따름'
|
||||
);
|
||||
$view['view']['data']['group_skin_option'] = get_skin_name(
|
||||
'group',
|
||||
set_value('group_skin', element('group_skin', $getdata)),
|
||||
'기본설정따름'
|
||||
);
|
||||
$view['view']['data']['group_mobile_skin_option'] = get_skin_name(
|
||||
'group',
|
||||
set_value('group_mobile_skin', element('group_mobile_skin', $getdata)),
|
||||
'기본설정따름'
|
||||
);
|
||||
|
||||
/**
|
||||
* primary key 정보를 저장합니다
|
||||
*/
|
||||
$view['view']['primary_key'] = $primary_key;
|
||||
$view['view']['grouplist'] = $this->Board_group_model->get_group_list();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
|
||||
|
||||
/**
|
||||
* 어드민 레이아웃을 정의합니다
|
||||
*/
|
||||
$layoutconfig = array('layout' => 'layout', 'skin' => 'write');
|
||||
$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));
|
||||
}
|
||||
|
||||
/**
|
||||
* 그룹관리자를 관리하는 페이지입니다
|
||||
*/
|
||||
public function write_admin($pid = 0)
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_boardgroup_write_admin';
|
||||
$this->load->event($eventname);
|
||||
|
||||
$view = array();
|
||||
$view['view'] = array();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before'] = Events::trigger('before', $eventname);
|
||||
|
||||
/**
|
||||
* 프라이머리키에 숫자형이 입력되지 않으면 에러처리합니다
|
||||
*/
|
||||
$pid = (int) $pid;
|
||||
if (empty($pid) OR $pid < 1) {
|
||||
show_404();
|
||||
}
|
||||
|
||||
/**
|
||||
* Validation 라이브러리를 가져옵니다
|
||||
*/
|
||||
$this->load->library('form_validation');
|
||||
/**
|
||||
* 전송된 데이터의 유효성을 체크합니다
|
||||
*/
|
||||
$config = array(
|
||||
array(
|
||||
'field' => 'bgr_id',
|
||||
'label' => '그룹아이디',
|
||||
'rules' => 'trim|required|numeric|is_natural',
|
||||
),
|
||||
array(
|
||||
'field' => 'userid',
|
||||
'label' => '회원아이디',
|
||||
'rules' => 'trim|required|alpha_dash|min_length[3]|max_length[50]|callback__userid_check[' . $pid . ']',
|
||||
),
|
||||
);
|
||||
$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);
|
||||
|
||||
$memdata = $this->Member_model
|
||||
->get_by_userid($this->input->post('userid'), 'mem_id');
|
||||
$mem_id = element('mem_id', $memdata);
|
||||
|
||||
$insertdata = array(
|
||||
'bgr_id' => $this->input->post('bgr_id'),
|
||||
'mem_id' => $mem_id,
|
||||
);
|
||||
|
||||
$this->Board_group_admin_model->insert($insertdata);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 페이지에 숫자가 아닌 문자가 입력되거나 1보다 작은 숫자가 입력되면 에러 페이지를 보여줍니다.
|
||||
*/
|
||||
$param =& $this->querystring;
|
||||
$findex = $this->input->get('findex') ? $this->input->get('findex') : $this->Board_group_admin_model->primary_key;
|
||||
$forder = $this->input->get('forder', null, 'desc');
|
||||
|
||||
$getdata = $this->{$this->modelname}->get_one($pid);
|
||||
$where = array(
|
||||
'bgr_id' => $pid,
|
||||
);
|
||||
$result = $this->Board_group_admin_model
|
||||
->get('', '', $where, '', '', $findex, $forder);
|
||||
if ($result && is_array($result)) {
|
||||
foreach ($result as $key => $val) {
|
||||
$select = 'mem_id, mem_userid, mem_nickname, mem_email, mem_icon';
|
||||
$result[$key]['member'] = $dbmember = $this->Member_model->get_by_memid(element('mem_id', $val), $select);
|
||||
$result[$key]['display_name'] = display_username(
|
||||
element('mem_userid', $dbmember),
|
||||
element('mem_nickname', $dbmember),
|
||||
element('mem_icon', $dbmember)
|
||||
);
|
||||
}
|
||||
}
|
||||
$view['view']['list'] = $result;
|
||||
$view['view']['data'] = $getdata;
|
||||
|
||||
$primary_key = $this->Board_group_admin_model->primary_key;
|
||||
|
||||
$view['view']['list_delete_url'] = admin_url($this->pagedir . '/write_admin_delete/' . $pid . '?' . $param->output());
|
||||
$view['view']['primary_key'] = $primary_key;
|
||||
$view['view']['grouplist'] = $this->Board_group_model->get_group_list();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
|
||||
|
||||
/**
|
||||
* 어드민 레이아웃을 정의합니다
|
||||
*/
|
||||
$layoutconfig = array('layout' => 'layout', 'skin' => 'write_admin');
|
||||
$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));
|
||||
}
|
||||
|
||||
/**
|
||||
* 그룹 관리자 추가시 실제 존재하는 회원인지 체크합니다.
|
||||
*/
|
||||
public function _userid_check($str, $pid)
|
||||
{
|
||||
if (empty($str)) {
|
||||
$this->form_validation->set_message(
|
||||
'_userid_check',
|
||||
'회원아이디가 입력되지 않았습니다'
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
$select = 'mem_id, mem_denied';
|
||||
$getdata = $this->Member_model->get_by_userid($str, $select);
|
||||
|
||||
if ( ! element('mem_id', $getdata)) {
|
||||
$this->form_validation->set_message(
|
||||
'_userid_check',
|
||||
$str . ' 은(는) 존재하지 않는 회원아이디입니다'
|
||||
);
|
||||
return false;
|
||||
} elseif (element('mem_denied', $getdata)) {
|
||||
$this->form_validation->set_message(
|
||||
'_userid_check',
|
||||
$str . ' 은(는) 탈퇴 또는 차단된 회원아이디입니다'
|
||||
);
|
||||
return false;
|
||||
} else {
|
||||
$where = array(
|
||||
'bgr_id' => $pid,
|
||||
'mem_id' => element('mem_id', $getdata),
|
||||
);
|
||||
$chkdata = $this->Board_group_admin_model->get_one('', '', $where);
|
||||
if (element('mem_id', $chkdata)) {
|
||||
$this->form_validation->set_message(
|
||||
'_userid_check',
|
||||
$str . ' 은(는) 이미 입력된 회원아이디입니다'
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록 페이지에서 선택수정을 하는 경우 실행되는 메소드입니다
|
||||
*/
|
||||
public function listupdate()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_boardgroup_listupdate';
|
||||
$this->load->event($eventname);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('before', $eventname);
|
||||
|
||||
/**
|
||||
* 체크한 게시물의 업데이트를 실행합니다
|
||||
*/
|
||||
if ($this->input->post('chk') && is_array($this->input->post('chk'))) {
|
||||
|
||||
$bgr_name = $this->input->post('bgr_name');
|
||||
$bgr_order = $this->input->post('bgr_order');
|
||||
$group_layout = $this->input->post('group_layout');
|
||||
$group_mobile_layout = $this->input->post('group_mobile_layout');
|
||||
$group_sidebar = $this->input->post('group_sidebar');
|
||||
$group_mobile_sidebar = $this->input->post('group_mobile_sidebar');
|
||||
$group_skin = $this->input->post('group_skin');
|
||||
$group_mobile_skin = $this->input->post('group_mobile_skin');
|
||||
|
||||
foreach ($this->input->post('chk') as $val) {
|
||||
if ($val) {
|
||||
$bgr_order_update = element($val, $bgr_order) ? element($val, $bgr_order) : 0;
|
||||
$updatedata = array(
|
||||
'bgr_name' => element($val, $bgr_name),
|
||||
'bgr_order' => $bgr_order_update,
|
||||
);
|
||||
$this->{$this->modelname}->update($val, $updatedata);
|
||||
$metadata = array(
|
||||
'group_layout' => element($val, $group_layout),
|
||||
'group_mobile_layout' => element($val, $group_mobile_layout),
|
||||
'group_sidebar' => element($val, $group_sidebar),
|
||||
'group_mobile_sidebar' => element($val, $group_mobile_sidebar),
|
||||
'group_skin' => element($val, $group_skin),
|
||||
'group_mobile_skin' => element($val, $group_mobile_skin),
|
||||
);
|
||||
$this->Board_group_meta_model->save($val, $metadata);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after', $eventname);
|
||||
|
||||
/**
|
||||
* 업데이트가 끝난 후 목록페이지로 이동합니다
|
||||
*/
|
||||
$this->session->set_flashdata(
|
||||
'message',
|
||||
'정상적으로 수정되었습니다'
|
||||
);
|
||||
$param =& $this->querystring;
|
||||
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
|
||||
|
||||
redirect($redirecturl);
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록 페이지에서 선택삭제를 하는 경우 실행되는 메소드입니다
|
||||
*/
|
||||
public function listdelete()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_boardgroup_listdelete';
|
||||
$this->load->event($eventname);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('before', $eventname);
|
||||
|
||||
$msg = '';
|
||||
/**
|
||||
* 체크한 게시물의 삭제를 실행합니다
|
||||
*/
|
||||
if ($this->input->post('chk') && is_array($this->input->post('chk'))) {
|
||||
foreach ($this->input->post('chk') as $val) {
|
||||
if ($val) {
|
||||
$countwhere = array(
|
||||
'bgr_id' => $val,
|
||||
);
|
||||
$cnt = $this->Board_model->count_by($countwhere);
|
||||
if ($cnt > 0) {
|
||||
$this->session->set_flashdata(
|
||||
'message',
|
||||
'게시판이 존재하는 그룹은 삭제할 수 없습니다'
|
||||
);
|
||||
$msg = 1;
|
||||
}
|
||||
if ($cnt === 0) {
|
||||
$this->{$this->modelname}->delete($val);
|
||||
$deletewhere = array(
|
||||
'bgr_id' => $val,
|
||||
);
|
||||
$this->Board_group_admin_model->delete_where($deletewhere);
|
||||
$this->Board_group_meta_model->deletemeta($val);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after', $eventname);
|
||||
|
||||
/**
|
||||
* 삭제가 끝난 후 목록페이지로 이동합니다
|
||||
*/
|
||||
if (empty($msg)) {
|
||||
$this->session->set_flashdata(
|
||||
'message',
|
||||
'정상적으로 삭제되었습니다'
|
||||
);
|
||||
}
|
||||
$param =& $this->querystring;
|
||||
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
|
||||
|
||||
redirect($redirecturl);
|
||||
}
|
||||
|
||||
/**
|
||||
* 그룹관리자 삭제를 할 경우 실행되는 메소드입니다
|
||||
*/
|
||||
public function write_admin_delete($pid = 0)
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_boardgroup_write_admin_delete';
|
||||
$this->load->event($eventname);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('before', $eventname);
|
||||
|
||||
$pid = (int) $pid;
|
||||
if (empty($pid) OR $pid < 1) {
|
||||
show_404();
|
||||
}
|
||||
|
||||
/**
|
||||
* 체크한 게시물의 삭제를 실행합니다
|
||||
*/
|
||||
if ($this->input->post('chk') && is_array($this->input->post('chk'))) {
|
||||
foreach ($this->input->post('chk') as $val) {
|
||||
if ($val) {
|
||||
$this->Board_group_admin_model->delete($val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after', $eventname);
|
||||
|
||||
/**
|
||||
* 삭제가 끝난 후 목록페이지로 이동합니다
|
||||
*/
|
||||
$this->session->set_flashdata(
|
||||
'message',
|
||||
'정상적으로 삭제되었습니다'
|
||||
);
|
||||
$param =& $this->querystring;
|
||||
$redirecturl = admin_url($this->pagedir . '/write_admin/' . $pid . '?' . $param->output());
|
||||
|
||||
redirect($redirecturl);
|
||||
}
|
||||
}
|
||||
4495
application/controllers/admin/board/Boards.php
Normal file
4495
application/controllers/admin/board/Boards.php
Normal file
File diff suppressed because it is too large
Load Diff
239
application/controllers/admin/board/Comment.php
Normal file
239
application/controllers/admin/board/Comment.php
Normal file
@@ -0,0 +1,239 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Comment class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 관리자>게시판설정>댓글관리 controller 입니다.
|
||||
*/
|
||||
class Comment extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 관리자 페이지 상의 현재 디렉토리입니다
|
||||
* 페이지 이동시 필요한 정보입니다
|
||||
*/
|
||||
public $pagedir = 'board/comment';
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array('Comment', 'Board', 'Comment_meta');
|
||||
|
||||
/**
|
||||
* 이 컨트롤러의 메인 모델 이름입니다
|
||||
*/
|
||||
protected $modelname = 'Comment_model';
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/**
|
||||
* 라이브러리를 로딩합니다
|
||||
*/
|
||||
$this->load->library(array('pagination', 'querystring'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록을 가져오는 메소드입니다
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_comment_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;
|
||||
$findex = 'cmt_id';
|
||||
$forder = 'desc';
|
||||
$sfield = $this->input->get('sfield', null, '');
|
||||
$skeyword = $this->input->get('skeyword', null, '');
|
||||
|
||||
$per_page = admin_listnum();
|
||||
$offset = ($page - 1) * $per_page;
|
||||
|
||||
/**
|
||||
* 게시판 목록에 필요한 정보를 가져옵니다.
|
||||
*/
|
||||
$this->{$this->modelname}->allow_search_field = array('cmt_id', 'comment.post_id', 'cmt_content', 'comment.mem_id', 'post.mem_id', 'cmt_username', 'cmt_nickname', 'cmt_datetime', 'cmt_ip', 'cmt_device'); // 검색이 가능한 필드
|
||||
$this->{$this->modelname}->search_field_equal = array('cmt_id', 'comment.post_id', 'comment.mem_id', 'post.mem_id'); // 검색중 like 가 아닌 = 검색을 하는 필드
|
||||
$this->{$this->modelname}->allow_order_field = array('cmt_id'); // 정렬이 가능한 필드
|
||||
$where = array(
|
||||
'cmt_del <>' => 2,
|
||||
);
|
||||
if ($brdid = (int) $this->input->get('brd_id')) {
|
||||
$where['post.brd_id'] = $brdid;
|
||||
}
|
||||
$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('cmt_userid', $val),
|
||||
element('cmt_nickname', $val)
|
||||
);
|
||||
|
||||
$result['list'][$key]['post_display_name'] = display_username(
|
||||
element('post_userid', $val),
|
||||
element('post_nickname', $val)
|
||||
);
|
||||
$result['list'][$key]['board'] = $board = $this->board->item_all(element('brd_id', $val));
|
||||
$result['list'][$key]['num'] = $list_num--;
|
||||
if ($board) {
|
||||
$result['list'][$key]['boardurl'] = board_url(element('brd_key', $board));
|
||||
$result['list'][$key]['posturl'] = post_url(element('brd_key', $board), element('post_id', $val));
|
||||
$result['list'][$key]['commenturl'] = post_url(element('brd_key', $board), element('post_id', $val)) . '#comment_' . element('cmt_id', $val);
|
||||
}
|
||||
}
|
||||
}
|
||||
$view['view']['data'] = $result;
|
||||
$view['view']['boardlist'] = $this->Board_model->get_board_list();
|
||||
|
||||
/**
|
||||
* 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('cmt_content' => '내용', 'cmt_username' => '실명', 'cmt_nickname' => '닉네임', 'cmt_datetime' => '날짜', 'cmt_ip' => 'IP');
|
||||
$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']['list_delete_url'] = admin_url($this->pagedir . '/listdelete/?' . $param->output());
|
||||
$view['view']['list_trash_url'] = admin_url($this->pagedir . '/listtrash/?' . $param->output());
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$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));
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록 페이지에서 선택삭제를 하는 경우 실행되는 메소드입니다
|
||||
*/
|
||||
public function listdelete()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_comment_listdelete';
|
||||
$this->load->event($eventname);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('before', $eventname);
|
||||
|
||||
/**
|
||||
* 체크한 게시물의 삭제를 실행합니다
|
||||
*/
|
||||
if ($this->input->post('chk') && is_array($this->input->post('chk'))) {
|
||||
foreach ($this->input->post('chk') as $val) {
|
||||
if ($val) {
|
||||
$this->board->delete_comment($val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after', $eventname);
|
||||
|
||||
/**
|
||||
* 삭제가 끝난 후 목록페이지로 이동합니다
|
||||
*/
|
||||
$this->session->set_flashdata(
|
||||
'message',
|
||||
'정상적으로 삭제되었습니다'
|
||||
);
|
||||
$param =& $this->querystring;
|
||||
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
|
||||
|
||||
redirect($redirecturl);
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록 페이지에서 휴지통을 클릭한 경우 실행되는 메소드입니다
|
||||
*/
|
||||
public function listtrash()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_comment_listtrash';
|
||||
$this->load->event($eventname);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('before', $eventname);
|
||||
|
||||
/**
|
||||
* 체크한 게시물의 삭제를 실행합니다
|
||||
*/
|
||||
if ($this->input->post('chk') && is_array($this->input->post('chk'))) {
|
||||
foreach ($this->input->post('chk') as $val) {
|
||||
if ($val) {
|
||||
$updatedata = array(
|
||||
'cmt_del' => 2,
|
||||
);
|
||||
$this->Comment_model->update($val, $updatedata);
|
||||
$metadata = array(
|
||||
'trash_mem_id' => $this->member->item('mem_id'),
|
||||
'trash_datetime' => cdate('Y-m-d H:i:s'),
|
||||
'trash_ip' => $this->input->ip_address(),
|
||||
);
|
||||
$this->Comment_meta_model->save($val, $metadata);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after', $eventname);
|
||||
|
||||
/**
|
||||
* 삭제가 끝난 후 목록페이지로 이동합니다
|
||||
*/
|
||||
$this->session->set_flashdata(
|
||||
'message',
|
||||
'정상적으로 휴지통으로 이동되었습니다'
|
||||
);
|
||||
$param =& $this->querystring;
|
||||
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
|
||||
|
||||
redirect($redirecturl);
|
||||
}
|
||||
}
|
||||
356
application/controllers/admin/board/Editorimage.php
Normal file
356
application/controllers/admin/board/Editorimage.php
Normal file
@@ -0,0 +1,356 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Editorimage class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 관리자>게시판설정>에디터이미지 controller 입니다.
|
||||
*/
|
||||
class Editorimage extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 관리자 페이지 상의 현재 디렉토리입니다
|
||||
* 페이지 이동시 필요한 정보입니다
|
||||
*/
|
||||
public $pagedir = 'board/editorimage';
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array('Editor_image');
|
||||
|
||||
/**
|
||||
* 이 컨트롤러의 메인 모델 이름입니다
|
||||
*/
|
||||
protected $modelname = 'Editor_image_model';
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array', 'number');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/**
|
||||
* 라이브러리를 로딩합니다
|
||||
*/
|
||||
$this->load->library(array('pagination', 'querystring'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록을 가져오는 메소드입니다
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_editorimage_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(
|
||||
'eim_id' => $param->sort('eim_id', 'asc'),
|
||||
'eim_filesize' => $param->sort('eim_filesize', 'asc'),
|
||||
'eim_datetime' => $param->sort('eim_datetime', 'asc'),
|
||||
);
|
||||
$findex = $this->input->get('findex') ? $this->input->get('findex') : $this->{$this->modelname}->primary_key;
|
||||
$forder = $this->input->get('forder', null, 'desc');
|
||||
$sfield = $this->input->get('sfield', null, '');
|
||||
$skeyword = $this->input->get('skeyword', null, '');
|
||||
|
||||
$per_page = admin_listnum();
|
||||
$offset = ($page - 1) * $per_page;
|
||||
|
||||
/**
|
||||
* 게시판 목록에 필요한 정보를 가져옵니다.
|
||||
*/
|
||||
$this->{$this->modelname}->allow_search_field = array('eim_id', 'editor_image.mem_id', 'eim_originname', 'eim_filename', 'eim_datetime', 'eim_ip'); // 검색이 가능한 필드
|
||||
$this->{$this->modelname}->search_field_equal = array('eim_id', 'editor_image.mem_id'); // 검색중 like 가 아닌 = 검색을 하는 필드
|
||||
$this->{$this->modelname}->allow_order_field = array('eim_id', 'eim_filesize', 'eim_datetime'); // 정렬이 가능한 필드
|
||||
|
||||
$result = $this->{$this->modelname}
|
||||
->get_admin_list($per_page, $offset, '', '', $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)
|
||||
);
|
||||
$result['list'][$key]['download_link'] = admin_url($this->pagedir . '/download/' . element('eim_id', $val));
|
||||
$result['list'][$key]['origin_image_url'] = thumb_url('editor', element('eim_filename', $val));
|
||||
$result['list'][$key]['thumb_url'] = thumb_url('editor', element('eim_filename', $val), '80');
|
||||
$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('eim_originname' => '파일명', 'eim_datetime' => '올린날짜', 'eim_ip' => 'IP');
|
||||
$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']['list_delete_url'] = admin_url($this->pagedir . '/listdelete/?' . $param->output());
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$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));
|
||||
}
|
||||
|
||||
/**
|
||||
* 파일 업로드 현황을 그래프 형식으로 페이지입니다
|
||||
*/
|
||||
public function graph($export = '')
|
||||
{
|
||||
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_editorimage_graph';
|
||||
$this->load->event($eventname);
|
||||
|
||||
$view = array();
|
||||
$view['view'] = array();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before'] = Events::trigger('before', $eventname);
|
||||
|
||||
$param =& $this->querystring;
|
||||
$datetype = $this->input->get('datetype', null, 'd');
|
||||
if ($datetype !== 'm' && $datetype !== 'y') {
|
||||
$datetype = 'd';
|
||||
}
|
||||
$start_date = $this->input->get('start_date') ? $this->input->get('start_date') : cdate('Y-m-01');
|
||||
$end_date = $this->input->get('end_date') ? $this->input->get('end_date') : cdate('Y-m-d');
|
||||
if ($datetype === 'y' OR $datetype === 'm') {
|
||||
$start_year = substr($start_date, 0, 4);
|
||||
$end_year = substr($end_date, 0, 4);
|
||||
}
|
||||
if ($datetype === 'm') {
|
||||
$start_month = substr($start_date, 5, 2);
|
||||
$end_month = substr($end_date, 5, 2);
|
||||
$start_year_month = $start_year * 12 + $start_month;
|
||||
$end_year_month = $end_year * 12 + $end_month;
|
||||
}
|
||||
$orderby = (strtolower($this->input->get('orderby')) === 'desc') ? 'desc' : 'asc';
|
||||
|
||||
$brd_id = $this->input->get('brd_id', null, '');
|
||||
|
||||
$result = $this->{$this->modelname}->get_editor_file_by_date($datetype, $start_date, $end_date, $orderby);
|
||||
$sum_count = 0;
|
||||
$arr = array();
|
||||
$max = 0;
|
||||
|
||||
if ($result && is_array($result)) {
|
||||
foreach ($result as $key => $value) {
|
||||
$s = element('day', $value);
|
||||
if ( ! isset($arr[$s])) {
|
||||
$arr[$s] = 0;
|
||||
}
|
||||
$arr[$s] += element('cnt', $value);
|
||||
|
||||
if ($arr[$s] > $max) {
|
||||
$max = $arr[$s];
|
||||
}
|
||||
$sum_count += element('cnt', $value);
|
||||
}
|
||||
}
|
||||
|
||||
$result = array();
|
||||
$i = 0;
|
||||
$save_count = -1;
|
||||
$tot_count = 0;
|
||||
|
||||
if (count($arr)) {
|
||||
foreach ($arr as $key => $value) {
|
||||
$count = (int) $arr[$key];
|
||||
$result[$key]['count'] = $count;
|
||||
$i++;
|
||||
if ($save_count !== $count) {
|
||||
$no = $i;
|
||||
$save_count = $count;
|
||||
}
|
||||
$result[$key]['no'] = $no;
|
||||
|
||||
$result[$key]['key'] = $key;
|
||||
$rate = ($count / $sum_count * 100);
|
||||
$result[$key]['rate'] = $rate;
|
||||
$s_rate = number_format($rate, 1);
|
||||
$result[$key]['s_rate'] = $s_rate;
|
||||
|
||||
$bar = (int)($count / $max * 100);
|
||||
$result[$key]['bar'] = $bar;
|
||||
}
|
||||
$view['view']['max_value'] = $max;
|
||||
$view['view']['sum_count'] = $sum_count;
|
||||
}
|
||||
|
||||
if ($datetype === 'y') {
|
||||
for ($i = $start_year; $i <= $end_year; $i++) {
|
||||
if( ! isset($result[$i])) $result[$i] = '';
|
||||
}
|
||||
} elseif ($datetype === 'm') {
|
||||
for ($i = $start_year_month; $i <= $end_year_month; $i++) {
|
||||
$year = floor($i / 12);
|
||||
if ($year * 12 == $i) $year--;
|
||||
$month = sprintf("%02d", ($i - ($year * 12)));
|
||||
$date = $year . '-' . $month;
|
||||
if( ! isset($result[$date])) $result[$date] = '';
|
||||
}
|
||||
} elseif ($datetype === 'd') {
|
||||
$date = $start_date;
|
||||
while ($date <= $end_date) {
|
||||
if( ! isset($result[$date])) $result[$date] = '';
|
||||
$date = cdate('Y-m-d', strtotime($date) + 86400);
|
||||
}
|
||||
}
|
||||
|
||||
if ($orderby === 'desc') {
|
||||
krsort($result);
|
||||
} else {
|
||||
ksort($result);
|
||||
}
|
||||
|
||||
$view['view']['list'] = $result;
|
||||
|
||||
$view['view']['start_date'] = $start_date;
|
||||
$view['view']['end_date'] = $end_date;
|
||||
$view['view']['datetype'] = $datetype;
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
|
||||
|
||||
if ($export === 'excel') {
|
||||
|
||||
header('Content-type: application/vnd.ms-excel');
|
||||
header('Content-Disposition: attachment; filename=에디터이미지_' . cdate('Y_m_d') . '.xls');
|
||||
echo $this->load->view('admin/' . ADMIN_SKIN . '/' . $this->pagedir . '/graph_excel', $view, true);
|
||||
|
||||
} else {
|
||||
/**
|
||||
* 어드민 레이아웃을 정의합니다
|
||||
*/
|
||||
$layoutconfig = array('layout' => 'layout', 'skin' => 'graph');
|
||||
$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));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록 페이지에서 선택삭제를 하는 경우 실행되는 메소드입니다
|
||||
*/
|
||||
public function listdelete()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_editorimage_listdelete';
|
||||
$this->load->event($eventname);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('before', $eventname);
|
||||
|
||||
/**
|
||||
* 체크한 게시물의 삭제를 실행합니다
|
||||
*/
|
||||
if ($this->input->post('chk') && is_array($this->input->post('chk'))) {
|
||||
foreach ($this->input->post('chk') as $val) {
|
||||
if ($val) {
|
||||
$this->{$this->modelname}->delete($val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after', $eventname);
|
||||
|
||||
/**
|
||||
* 삭제가 끝난 후 목록페이지로 이동합니다
|
||||
*/
|
||||
$this->session->set_flashdata(
|
||||
'message',
|
||||
'정상적으로 삭제되었습니다'
|
||||
);
|
||||
$param =& $this->querystring;
|
||||
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
|
||||
|
||||
redirect($redirecturl);
|
||||
}
|
||||
|
||||
/**
|
||||
* 파일다운로드시 실행되는 함수입니다
|
||||
*/
|
||||
public function download($eim_id = 0)
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_editorimage_download';
|
||||
$this->load->event($eventname);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('before', $eventname);
|
||||
|
||||
$eim_id = (int) $eim_id;
|
||||
if (empty($eim_id) OR $eim_id < 1) {
|
||||
show_404();
|
||||
}
|
||||
|
||||
$file = $this->{$this->modelname}->get_one($eim_id);
|
||||
|
||||
if ( ! element('eim_id', $file)) {
|
||||
show_404();
|
||||
}
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after', $eventname);
|
||||
|
||||
$this->load->helper('download');
|
||||
|
||||
$data = file_get_contents(config_item('uploads_dir') . '/editor/' . element('eim_filename', $file)); // Read the file's contents
|
||||
$name = element('eim_originname', $file);
|
||||
if ($name && $data) {
|
||||
force_download($name, $data);
|
||||
}
|
||||
}
|
||||
}
|
||||
427
application/controllers/admin/board/Filedownload.php
Normal file
427
application/controllers/admin/board/Filedownload.php
Normal file
@@ -0,0 +1,427 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Filedownload class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 관리자>게시판설정>파일다운로드 controller 입니다.
|
||||
*/
|
||||
class Filedownload extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 관리자 페이지 상의 현재 디렉토리입니다
|
||||
* 페이지 이동시 필요한 정보입니다
|
||||
*/
|
||||
public $pagedir = 'board/filedownload';
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array('Board', 'Post_file_download_log');
|
||||
|
||||
/**
|
||||
* 이 컨트롤러의 메인 모델 이름입니다
|
||||
*/
|
||||
protected $modelname = 'Post_file_download_log_model';
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array', 'number');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/**
|
||||
* 라이브러리를 로딩합니다
|
||||
*/
|
||||
$this->load->library(array('pagination', 'querystring'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록을 가져오는 메소드입니다
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_filedownload_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;
|
||||
$findex = $this->input->get('findex') ? $this->input->get('findex') : $this->{$this->modelname}->primary_key;
|
||||
$forder = $this->input->get('forder', null, 'desc');
|
||||
$sfield = $this->input->get('sfield', null, '');
|
||||
$skeyword = $this->input->get('skeyword', null, '');
|
||||
|
||||
$per_page = admin_listnum();
|
||||
$offset = ($page - 1) * $per_page;
|
||||
|
||||
/**
|
||||
* 게시판 목록에 필요한 정보를 가져옵니다.
|
||||
*/
|
||||
$this->{$this->modelname}->allow_search_field = array('pfd_id', 'pfi_id', 'post.post_id', 'post.mem_id', 'post_file_download_log.mem_id', 'pfd_datetime', 'pfd_ip'); // 검색이 가능한 필드
|
||||
$this->{$this->modelname}->search_field_equal = array('pfd_id', 'pfi_id', 'post.post_id', 'post.mem_id', 'post_file_download_log.mem_id'); // 검색중 like 가 아닌 = 검색을 하는 필드
|
||||
$this->{$this->modelname}->allow_order_field = array('pfd_id'); // 정렬이 가능한 필드
|
||||
|
||||
$where = array();
|
||||
if ($brdid = (int) $this->input->get('brd_id')) {
|
||||
$where['post.brd_id'] = $brdid;
|
||||
}
|
||||
$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) {
|
||||
$select = 'mem_id, mem_userid, mem_nickname, mem_icon';
|
||||
$result['list'][$key]['member'] = $dbmember = $this->Member_model->get_by_memid(element('mem_id', $val), $select);
|
||||
$result['list'][$key]['display_name'] = display_username(
|
||||
element('mem_userid', $dbmember),
|
||||
element('mem_nickname', $dbmember),
|
||||
element('mem_icon', $dbmember)
|
||||
);
|
||||
$result['list'][$key]['post_display_name'] = display_username(
|
||||
element('post_userid', $val),
|
||||
element('post_nickname', $val)
|
||||
);
|
||||
$brd_key = $this->board->item_id('brd_key', element('brd_id', $val));
|
||||
$result['list'][$key]['posturl'] = post_url($brd_key, element('post_id', $val));
|
||||
$result['list'][$key]['download_link'] = admin_url('board/fileupload/download/' . element('pfi_id', $val));
|
||||
$result['list'][$key]['board'] = $board = $this->board->item_all(element('brd_id', $val));
|
||||
if ($board) {
|
||||
$result['list'][$key]['boardurl'] = board_url(element('brd_key', $board));
|
||||
}
|
||||
if (element('pfd_useragent', $val)) {
|
||||
$userAgent = get_useragent_info(element('pfd_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;
|
||||
|
||||
$view['view']['boardlist'] = $this->Board_model->get_board_list();
|
||||
|
||||
/**
|
||||
* 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('pfd_datetime' => '날짜', 'pfd_ip' => 'IP');
|
||||
$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']['list_delete_url'] = admin_url($this->pagedir . '/listdelete/?' . $param->output());
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$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));
|
||||
}
|
||||
|
||||
/**
|
||||
* 파일 다운로드 현황을 그래프 형식으로 페이지입니다
|
||||
*/
|
||||
public function graph($export = '')
|
||||
{
|
||||
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_filedownload_graph';
|
||||
$this->load->event($eventname);
|
||||
|
||||
$view = array();
|
||||
$view['view'] = array();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before'] = Events::trigger('before', $eventname);
|
||||
|
||||
$param =& $this->querystring;
|
||||
$datetype = $this->input->get('datetype', null, 'd');
|
||||
if ($datetype !== 'm' && $datetype !== 'y') {
|
||||
$datetype = 'd';
|
||||
}
|
||||
$start_date = $this->input->get('start_date') ? $this->input->get('start_date') : cdate('Y-m-01');
|
||||
$end_date = $this->input->get('end_date') ? $this->input->get('end_date') : cdate('Y-m-d');
|
||||
if ($datetype === 'y' OR $datetype === 'm') {
|
||||
$start_year = substr($start_date, 0, 4);
|
||||
$end_year = substr($end_date, 0, 4);
|
||||
}
|
||||
if ($datetype === 'm') {
|
||||
$start_month = substr($start_date, 5, 2);
|
||||
$end_month = substr($end_date, 5, 2);
|
||||
$start_year_month = $start_year * 12 + $start_month;
|
||||
$end_year_month = $end_year * 12 + $end_month;
|
||||
}
|
||||
$orderby = (strtolower($this->input->get('orderby')) === 'desc') ? 'desc' : 'asc';
|
||||
|
||||
$brd_id = $this->input->get('brd_id', null, '');
|
||||
|
||||
$result = $this->{$this->modelname}->get_post_file_download_count($datetype, $start_date, $end_date, $brd_id, $orderby);
|
||||
$sum_count = 0;
|
||||
$arr = array();
|
||||
$max = 0;
|
||||
|
||||
if ($result && is_array($result)) {
|
||||
foreach ($result as $key => $value) {
|
||||
$s = element('day', $value);
|
||||
if ( ! isset($arr[$s])) {
|
||||
$arr[$s] = 0;
|
||||
}
|
||||
$arr[$s] += element('cnt', $value);
|
||||
|
||||
if ($arr[$s] > $max) {
|
||||
$max = $arr[$s];
|
||||
}
|
||||
$sum_count += element('cnt', $value);
|
||||
}
|
||||
}
|
||||
|
||||
$result = array();
|
||||
$i = 0;
|
||||
$save_count = -1;
|
||||
$tot_count = 0;
|
||||
|
||||
if (count($arr)) {
|
||||
foreach ($arr as $key => $value) {
|
||||
$count = (int) $arr[$key];
|
||||
$result[$key]['count'] = $count;
|
||||
$i++;
|
||||
if ($save_count !== $count) {
|
||||
$no = $i;
|
||||
$save_count = $count;
|
||||
}
|
||||
$result[$key]['no'] = $no;
|
||||
|
||||
$result[$key]['key'] = $key;
|
||||
$rate = ($count / $sum_count * 100);
|
||||
$result[$key]['rate'] = $rate;
|
||||
$s_rate = number_format($rate, 1);
|
||||
$result[$key]['s_rate'] = $s_rate;
|
||||
|
||||
$bar = (int)($count / $max * 100);
|
||||
$result[$key]['bar'] = $bar;
|
||||
}
|
||||
$view['view']['max_value'] = $max;
|
||||
$view['view']['sum_count'] = $sum_count;
|
||||
}
|
||||
|
||||
if ($datetype === 'y') {
|
||||
for ($i = $start_year; $i <= $end_year; $i++) {
|
||||
if( ! isset($result[$i])) $result[$i] = '';
|
||||
}
|
||||
} elseif ($datetype === 'm') {
|
||||
for ($i = $start_year_month; $i <= $end_year_month; $i++) {
|
||||
$year = floor($i / 12);
|
||||
if ($year * 12 == $i) $year--;
|
||||
$month = sprintf("%02d", ($i - ($year * 12)));
|
||||
$date = $year . '-' . $month;
|
||||
if( ! isset($result[$date])) $result[$date] = '';
|
||||
}
|
||||
} elseif ($datetype === 'd') {
|
||||
$date = $start_date;
|
||||
while ($date <= $end_date) {
|
||||
if( ! isset($result[$date])) $result[$date] = '';
|
||||
$date = cdate('Y-m-d', strtotime($date) + 86400);
|
||||
}
|
||||
}
|
||||
|
||||
if ($orderby === 'desc') {
|
||||
krsort($result);
|
||||
} else {
|
||||
ksort($result);
|
||||
}
|
||||
|
||||
$view['view']['list'] = $result;
|
||||
|
||||
$view['view']['start_date'] = $start_date;
|
||||
$view['view']['end_date'] = $end_date;
|
||||
$view['view']['datetype'] = $datetype;
|
||||
|
||||
$view['view']['boardlist'] = $this->Board_model->get_board_list();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
|
||||
|
||||
if ($export === 'excel') {
|
||||
|
||||
header('Content-type: application/vnd.ms-excel');
|
||||
header('Content-Disposition: attachment; filename=파일다운로드_' . cdate('Y_m_d') . '.xls');
|
||||
echo $this->load->view('admin/' . ADMIN_SKIN . '/' . $this->pagedir . '/graph_excel', $view, true);
|
||||
|
||||
} else {
|
||||
/**
|
||||
* 어드민 레이아웃을 정의합니다
|
||||
*/
|
||||
$layoutconfig = array('layout' => 'layout', 'skin' => 'graph');
|
||||
$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));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록 페이지에서 선택삭제를 하는 경우 실행되는 메소드입니다
|
||||
*/
|
||||
public function listdelete()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_filedownload_listdelete';
|
||||
$this->load->event($eventname);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('before', $eventname);
|
||||
|
||||
/**
|
||||
* 체크한 게시물의 삭제를 실행합니다
|
||||
*/
|
||||
if ($this->input->post('chk') && is_array($this->input->post('chk'))) {
|
||||
foreach ($this->input->post('chk') as $val) {
|
||||
if ($val) {
|
||||
$this->{$this->modelname}->delete($val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after', $eventname);
|
||||
|
||||
/**
|
||||
* 삭제가 끝난 후 목록페이지로 이동합니다
|
||||
*/
|
||||
$this->session->set_flashdata(
|
||||
'message',
|
||||
'정상적으로 삭제되었습니다'
|
||||
);
|
||||
$param =& $this->querystring;
|
||||
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
|
||||
redirect($redirecturl);
|
||||
}
|
||||
|
||||
/**
|
||||
* 오래된 파일다운로드로그 페이지입니다
|
||||
*/
|
||||
public function cleanlog()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_filedownload_cleanlog';
|
||||
$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(
|
||||
'pfd_datetime <=' => $this->input->post('criterion'),
|
||||
);
|
||||
$this->Post_file_download_log_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(
|
||||
'pfd_datetime <=' => $criterion,
|
||||
);
|
||||
$log_count = $this->Post_file_download_log_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' => 'cleanlog');
|
||||
$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));
|
||||
}
|
||||
}
|
||||
379
application/controllers/admin/board/Fileupload.php
Normal file
379
application/controllers/admin/board/Fileupload.php
Normal file
@@ -0,0 +1,379 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Fileupload class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 관리자>게시판설정>파일업로드 controller 입니다.
|
||||
*/
|
||||
class Fileupload extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 관리자 페이지 상의 현재 디렉토리입니다
|
||||
* 페이지 이동시 필요한 정보입니다
|
||||
*/
|
||||
public $pagedir = 'board/fileupload';
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array('Board', 'Post_file', 'Post_file_download_log');
|
||||
|
||||
/**
|
||||
* 이 컨트롤러의 메인 모델 이름입니다
|
||||
*/
|
||||
protected $modelname = 'Post_file_model';
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array', 'number');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/**
|
||||
* 라이브러리를 로딩합니다
|
||||
*/
|
||||
$this->load->library(array('pagination', 'querystring'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록을 가져오는 메소드입니다
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_fileupload_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(
|
||||
'pfi_id' => $param->sort('pfi_id', 'asc'),
|
||||
'pfi_filesize' => $param->sort('pfi_filesize', 'asc'),
|
||||
'pfi_download' => $param->sort('pfi_download', 'asc'),
|
||||
'pfi_datetime' => $param->sort('pfi_datetime', 'asc'),
|
||||
);
|
||||
$findex = $this->input->get('findex') ? $this->input->get('findex') : $this->{$this->modelname}->primary_key;
|
||||
$forder = $this->input->get('forder', null, 'desc');
|
||||
$sfield = $this->input->get('sfield', null, '');
|
||||
$skeyword = $this->input->get('skeyword', null, '');
|
||||
|
||||
$per_page = admin_listnum();
|
||||
$offset = ($page - 1) * $per_page;
|
||||
|
||||
/**
|
||||
* 게시판 목록에 필요한 정보를 가져옵니다.
|
||||
*/
|
||||
$this->{$this->modelname}->allow_search_field = array('pfi_id', 'post.post_id', 'post.mem_id', 'pfi_originname', 'pfi_filename', 'pfi_datetime', 'pfi_ip'); // 검색이 가능한 필드
|
||||
$this->{$this->modelname}->search_field_equal = array('pfi_id', 'post.post_id', 'post.mem_id'); // 검색중 like 가 아닌 = 검색을 하는 필드
|
||||
$this->{$this->modelname}->allow_order_field = array('pfi_id', 'pfi_filesize', 'pfi_download', 'pfi_datetime'); // 정렬이 가능한 필드
|
||||
|
||||
$where = array();
|
||||
if ($brdid = (int) $this->input->get('brd_id')) {
|
||||
$where['post.brd_id'] = $brdid;
|
||||
}
|
||||
$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]['post_display_name'] = display_username(
|
||||
element('post_userid', $val),
|
||||
element('post_nickname', $val)
|
||||
);
|
||||
$brd_key = $this->board->item_id('brd_key', element('brd_id', $val));
|
||||
$result['list'][$key]['posturl'] = post_url($brd_key, element('post_id', $val));
|
||||
$result['list'][$key]['download_link'] = admin_url($this->pagedir . '/download/' . element('pfi_id', $val));
|
||||
if (element('pfi_is_image', $val)) {
|
||||
$result['list'][$key]['origin_image_url'] = thumb_url('post', element('pfi_filename', $val));
|
||||
$result['list'][$key]['thumb_url'] = thumb_url('post', element('pfi_filename', $val), '80');
|
||||
}
|
||||
$result['list'][$key]['board'] = $board = $this->board->item_all(element('brd_id', $val));
|
||||
if ($board) {
|
||||
$result['list'][$key]['boardurl'] = board_url(element('brd_key', $board));
|
||||
}
|
||||
$result['list'][$key]['num'] = $list_num--;
|
||||
}
|
||||
}
|
||||
$view['view']['data'] = $result;
|
||||
|
||||
$view['view']['boardlist'] = $this->Board_model->get_board_list();
|
||||
|
||||
/**
|
||||
* 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('pfi_originname' => '파일명', 'pfi_datetime' => '올린날짜', 'pfi_ip' => 'IP');
|
||||
$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']['list_delete_url'] = admin_url($this->pagedir . '/listdelete/?' . $param->output());
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$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));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 파일 업로드 현황을 그래프 형식으로 페이지입니다
|
||||
*/
|
||||
public function graph($export = '')
|
||||
{
|
||||
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_fileupload_graph';
|
||||
$this->load->event($eventname);
|
||||
|
||||
$view = array();
|
||||
$view['view'] = array();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before'] = Events::trigger('before', $eventname);
|
||||
|
||||
$param =& $this->querystring;
|
||||
$datetype = $this->input->get('datetype', null, 'd');
|
||||
if ($datetype !== 'm' && $datetype !== 'y') {
|
||||
$datetype = 'd';
|
||||
}
|
||||
$start_date = $this->input->get('start_date') ? $this->input->get('start_date') : cdate('Y-m-01');
|
||||
$end_date = $this->input->get('end_date') ? $this->input->get('end_date') : cdate('Y-m-d');
|
||||
if ($datetype === 'y' OR $datetype === 'm') {
|
||||
$start_year = substr($start_date, 0, 4);
|
||||
$end_year = substr($end_date, 0, 4);
|
||||
}
|
||||
if ($datetype === 'm') {
|
||||
$start_month = substr($start_date, 5, 2);
|
||||
$end_month = substr($end_date, 5, 2);
|
||||
$start_year_month = $start_year * 12 + $start_month;
|
||||
$end_year_month = $end_year * 12 + $end_month;
|
||||
}
|
||||
$orderby = (strtolower($this->input->get('orderby')) === 'desc') ? 'desc' : 'asc';
|
||||
|
||||
$brd_id = $this->input->get('brd_id', null, '');
|
||||
|
||||
$result = $this->{$this->modelname}->get_post_file_by_date($datetype, $start_date, $end_date, $brd_id, $orderby);
|
||||
$sum_count = 0;
|
||||
$arr = array();
|
||||
$max = 0;
|
||||
|
||||
if ($result && is_array($result)) {
|
||||
foreach ($result as $key => $value) {
|
||||
$s = element('day', $value);
|
||||
if ( ! isset($arr[$s])) {
|
||||
$arr[$s] = 0;
|
||||
}
|
||||
$arr[$s] += element('cnt', $value);
|
||||
|
||||
if ($arr[$s] > $max) {
|
||||
$max = $arr[$s];
|
||||
}
|
||||
$sum_count += element('cnt', $value);
|
||||
}
|
||||
}
|
||||
|
||||
$result = array();
|
||||
$i = 0;
|
||||
$save_count = -1;
|
||||
$tot_count = 0;
|
||||
|
||||
if (count($arr)) {
|
||||
foreach ($arr as $key => $value) {
|
||||
$count = (int) $arr[$key];
|
||||
$result[$key]['count'] = $count;
|
||||
$i++;
|
||||
if ($save_count !== $count) {
|
||||
$no = $i;
|
||||
$save_count = $count;
|
||||
}
|
||||
$result[$key]['no'] = $no;
|
||||
|
||||
$result[$key]['key'] = $key;
|
||||
$rate = ($count / $sum_count * 100);
|
||||
$result[$key]['rate'] = $rate;
|
||||
$s_rate = number_format($rate, 1);
|
||||
$result[$key]['s_rate'] = $s_rate;
|
||||
|
||||
$bar = (int)($count / $max * 100);
|
||||
$result[$key]['bar'] = $bar;
|
||||
}
|
||||
$view['view']['max_value'] = $max;
|
||||
$view['view']['sum_count'] = $sum_count;
|
||||
}
|
||||
|
||||
if ($datetype === 'y') {
|
||||
for ($i = $start_year; $i <= $end_year; $i++) {
|
||||
if( ! isset($result[$i])) $result[$i] = '';
|
||||
}
|
||||
} elseif ($datetype === 'm') {
|
||||
for ($i = $start_year_month; $i <= $end_year_month; $i++) {
|
||||
$year = floor($i / 12);
|
||||
if ($year * 12 == $i) $year--;
|
||||
$month = sprintf("%02d", ($i - ($year * 12)));
|
||||
$date = $year . '-' . $month;
|
||||
if( ! isset($result[$date])) $result[$date] = '';
|
||||
}
|
||||
} elseif ($datetype === 'd') {
|
||||
$date = $start_date;
|
||||
while ($date <= $end_date) {
|
||||
if( ! isset($result[$date])) $result[$date] = '';
|
||||
$date = cdate('Y-m-d', strtotime($date) + 86400);
|
||||
}
|
||||
}
|
||||
|
||||
if ($orderby === 'desc') {
|
||||
krsort($result);
|
||||
} else {
|
||||
ksort($result);
|
||||
}
|
||||
|
||||
$view['view']['list'] = $result;
|
||||
|
||||
$view['view']['start_date'] = $start_date;
|
||||
$view['view']['end_date'] = $end_date;
|
||||
$view['view']['datetype'] = $datetype;
|
||||
|
||||
$view['view']['boardlist'] = $this->Board_model->get_board_list();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
|
||||
|
||||
if ($export === 'excel') {
|
||||
|
||||
header('Content-type: application/vnd.ms-excel');
|
||||
header('Content-Disposition: attachment; filename=파일업로드_' . cdate('Y_m_d') . '.xls');
|
||||
echo $this->load->view('admin/' . ADMIN_SKIN . '/' . $this->pagedir . '/graph_excel', $view, true);
|
||||
|
||||
} else {
|
||||
/**
|
||||
* 어드민 레이아웃을 정의합니다
|
||||
*/
|
||||
$layoutconfig = array('layout' => 'layout', 'skin' => 'graph');
|
||||
$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));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록 페이지에서 선택삭제를 하는 경우 실행되는 메소드입니다
|
||||
*/
|
||||
public function listdelete()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_fileupload_listdelete';
|
||||
$this->load->event($eventname);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('before', $eventname);
|
||||
|
||||
/**
|
||||
* 체크한 게시물의 삭제를 실행합니다
|
||||
*/
|
||||
if ($this->input->post('chk') && is_array($this->input->post('chk'))) {
|
||||
foreach ($this->input->post('chk') as $val) {
|
||||
if ($val) {
|
||||
$this->{$this->modelname}->delete($val);
|
||||
$deletewhere = array(
|
||||
'pfi_id' => $val,
|
||||
);
|
||||
$this->Post_file_download_log_model->delete_where($deletewhere);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after', $eventname);
|
||||
|
||||
/**
|
||||
* 삭제가 끝난 후 목록페이지로 이동합니다
|
||||
*/
|
||||
$this->session->set_flashdata(
|
||||
'message',
|
||||
'정상적으로 삭제되었습니다'
|
||||
);
|
||||
$param =& $this->querystring;
|
||||
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
|
||||
|
||||
redirect($redirecturl);
|
||||
}
|
||||
|
||||
/**
|
||||
* 파일다운로드시 실행되는 함수입니다
|
||||
*/
|
||||
public function download($pfi_id = 0)
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_fileupload_download';
|
||||
$this->load->event($eventname);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('before', $eventname);
|
||||
|
||||
$pfi_id = (int) $pfi_id;
|
||||
if (empty($pfi_id) OR $pfi_id < 1) {
|
||||
show_404();
|
||||
}
|
||||
|
||||
$file = $this->{$this->modelname}->get_one($pfi_id);
|
||||
|
||||
if ( ! element('pfi_id', $file)) {
|
||||
show_404();
|
||||
}
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after', $eventname);
|
||||
|
||||
$this->load->helper('download');
|
||||
|
||||
// Read the file's contents
|
||||
$data = file_get_contents(config_item('uploads_dir') . '/post/' . element('pfi_filename', $file));
|
||||
$name = element('pfi_originname', $file);
|
||||
if ($name && $data) {
|
||||
force_download($name, $data);
|
||||
}
|
||||
}
|
||||
}
|
||||
534
application/controllers/admin/board/Like.php
Normal file
534
application/controllers/admin/board/Like.php
Normal file
@@ -0,0 +1,534 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Like class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 관리자>게시판설정>추천/비추 controller 입니다.
|
||||
*/
|
||||
class Like extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 관리자 페이지 상의 현재 디렉토리입니다
|
||||
* 페이지 이동시 필요한 정보입니다
|
||||
*/
|
||||
public $pagedir = 'board/like';
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array('Like', 'Board', 'Post', 'Comment');
|
||||
|
||||
/**
|
||||
* 이 컨트롤러의 메인 모델 이름입니다
|
||||
*/
|
||||
protected $modelname = 'Like_model';
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/**
|
||||
* 라이브러리를 로딩합니다
|
||||
*/
|
||||
$this->load->library(array('pagination', 'querystring'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록을 가져오는 메소드입니다
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_like_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;
|
||||
$findex = $this->input->get('findex') ? $this->input->get('findex') : $this->{$this->modelname}->primary_key;
|
||||
$forder = $this->input->get('forder', null, 'desc');
|
||||
$sfield = $this->input->get('sfield', null, '');
|
||||
$skeyword = $this->input->get('skeyword', null, '');
|
||||
|
||||
$per_page = admin_listnum();
|
||||
$offset = ($page - 1) * $per_page;
|
||||
|
||||
/**
|
||||
* 게시판 목록에 필요한 정보를 가져옵니다.
|
||||
*/
|
||||
$this->{$this->modelname}->allow_search_field = array('lik_id', 'target_id', 'target_type', 'post_id', 'like.mem_id', 'target_mem_id', 'lik_type', 'lik_datetime', 'lik_ip'); // 검색이 가능한 필드
|
||||
$this->{$this->modelname}->search_field_equal = array('lik_id', 'target_id', 'target_type', 'post_id', 'like.mem_id', 'target_mem_id', 'lik_type'); // 검색중 like 가 아닌 = 검색을 하는 필드
|
||||
$this->{$this->modelname}->allow_order_field = array('lik_id'); // 정렬이 가능한 필드
|
||||
|
||||
$where = array();
|
||||
if ($brdid = (int) $this->input->get('brd_id')) {
|
||||
$where['like.brd_id'] = $brdid;
|
||||
}
|
||||
if ($this->input->get('target_type')) {
|
||||
$where['like.target_type'] = $this->input->get('target_type');
|
||||
}
|
||||
$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)
|
||||
);
|
||||
$result['list'][$key]['target_member'] = $target_member
|
||||
= $this->Member_model->get_by_memid(element('target_mem_id', $val), 'mem_id, mem_userid, mem_nickname, mem_icon');
|
||||
$result['list'][$key]['target_display_name'] = display_username(
|
||||
element('mem_userid', $target_member),
|
||||
element('mem_nickname', $target_member),
|
||||
element('mem_icon', $target_member)
|
||||
);
|
||||
$result['list'][$key]['num'] = $list_num--;
|
||||
|
||||
if (element('target_type', $val) === '1') {
|
||||
$result['list'][$key]['target_name'] = '원글';
|
||||
$result['list'][$key]['post'] = $post = $this->Post_model->get_one(element('target_id', $val), 'post_id, brd_id, post_title');
|
||||
if ($post) {
|
||||
$result['list'][$key]['board'] = $board = $this->board->item_all(element('brd_id', $post));
|
||||
$result['list'][$key]['origin_content'] = element('post_title', $post);
|
||||
$result['list'][$key]['posturl'] = post_url(element('brd_key', $board), element('post_id', $post));
|
||||
}
|
||||
} elseif (element('target_type', $val) === '2') {
|
||||
$result['list'][$key]['target_name'] = '댓글';
|
||||
$result['list'][$key]['comment'] = $comment = $this->Comment_model->get_one(element('target_id', $val), 'cmt_id, post_id, cmt_content');
|
||||
if ($comment) {
|
||||
$result['list'][$key]['post'] = $post = $this->Post_model->get_one(element('post_id', $comment));
|
||||
$result['list'][$key]['origin_content'] = cut_str(element('cmt_content', $comment),40);
|
||||
if ($post) {
|
||||
$result['list'][$key]['board'] = $board = $this->board->item_all(element('brd_id', $post));
|
||||
$result['list'][$key]['posturl'] = post_url(element('brd_key', $board), element('post_id', $post)) . '#comment_id=' . element('cmt_id', $comment);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (element('lik_type', $val) === '1') {
|
||||
$result['list'][$key]['like_or_dislike'] = '<span class="label label-success">추천</span>';
|
||||
} elseif (element('lik_type', $val) === '2') {
|
||||
$result['list'][$key]['like_or_dislike'] = '<span class="label label-warning">비추</span>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$view['view']['data'] = $result;
|
||||
|
||||
$view['view']['boardlist'] = $this->Board_model->get_board_list();
|
||||
|
||||
/**
|
||||
* 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('lik_datetime' => '날짜', 'lik_ip' => 'IP');
|
||||
$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']['list_delete_url'] = admin_url($this->pagedir . '/listdelete/?' . $param->output());
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$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));
|
||||
}
|
||||
|
||||
/**
|
||||
* 추천수를 그래프 형식으로 보는 페이지입니다
|
||||
*/
|
||||
public function graph($export = '')
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_like_graph';
|
||||
$this->load->event($eventname);
|
||||
|
||||
$view = array();
|
||||
$view['view'] = array();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before'] = Events::trigger('before', $eventname);
|
||||
|
||||
$param =& $this->querystring;
|
||||
$datetype = $this->input->get('datetype', null, 'd');
|
||||
if ($datetype !== 'm' && $datetype !== 'y') {
|
||||
$datetype = 'd';
|
||||
}
|
||||
$start_date = $this->input->get('start_date') ? $this->input->get('start_date') : cdate('Y-m-01');
|
||||
$end_date = $this->input->get('end_date') ? $this->input->get('end_date') : cdate('Y-m-d');
|
||||
if ($datetype === 'y' OR $datetype === 'm') {
|
||||
$start_year = substr($start_date, 0, 4);
|
||||
$end_year = substr($end_date, 0, 4);
|
||||
}
|
||||
if ($datetype === 'm') {
|
||||
$start_month = substr($start_date, 5, 2);
|
||||
$end_month = substr($end_date, 5, 2);
|
||||
$start_year_month = $start_year * 12 + $start_month;
|
||||
$end_year_month = $end_year * 12 + $end_month;
|
||||
}
|
||||
$orderby = (strtolower($this->input->get('orderby')) === 'desc') ? 'desc' : 'asc';
|
||||
|
||||
$brd_id = $this->input->get('brd_id', null, '');
|
||||
|
||||
$result = $this->{$this->modelname}->get_like_count($datetype, $start_date, $end_date, $brd_id, $orderby);
|
||||
$sum_count = 0;
|
||||
$arr = array();
|
||||
$max = 0;
|
||||
|
||||
if ($result && is_array($result)) {
|
||||
foreach ($result as $key => $value) {
|
||||
$s = element('day', $value);
|
||||
if ( ! isset($arr[$s])) {
|
||||
$arr[$s] = 0;
|
||||
}
|
||||
$arr[$s] += element('cnt', $value);
|
||||
|
||||
if ($arr[$s] > $max) {
|
||||
$max = $arr[$s];
|
||||
}
|
||||
$sum_count += element('cnt', $value);
|
||||
}
|
||||
}
|
||||
|
||||
$result = array();
|
||||
$i = 0;
|
||||
$save_count = -1;
|
||||
$tot_count = 0;
|
||||
|
||||
if (count($arr)) {
|
||||
foreach ($arr as $key => $value) {
|
||||
$count = (int) $arr[$key];
|
||||
$result[$key]['count'] = $count;
|
||||
$i++;
|
||||
if ($save_count !== $count) {
|
||||
$no = $i;
|
||||
$save_count = $count;
|
||||
}
|
||||
$result[$key]['no'] = $no;
|
||||
|
||||
$result[$key]['key'] = $key;
|
||||
$rate = ($count / $sum_count * 100);
|
||||
$result[$key]['rate'] = $rate;
|
||||
$s_rate = number_format($rate, 1);
|
||||
$result[$key]['s_rate'] = $s_rate;
|
||||
|
||||
$bar = (int)($count / $max * 100);
|
||||
$result[$key]['bar'] = $bar;
|
||||
}
|
||||
$view['view']['max_value'] = $max;
|
||||
$view['view']['sum_count'] = $sum_count;
|
||||
}
|
||||
|
||||
if ($datetype === 'y') {
|
||||
for ($i = $start_year; $i <= $end_year; $i++) {
|
||||
if( ! isset($result[$i])) $result[$i] = '';
|
||||
}
|
||||
} elseif ($datetype === 'm') {
|
||||
for ($i = $start_year_month; $i <= $end_year_month; $i++) {
|
||||
$year = floor($i / 12);
|
||||
if ($year * 12 == $i) $year--;
|
||||
$month = sprintf("%02d", ($i - ($year * 12)));
|
||||
$date = $year . '-' . $month;
|
||||
if( ! isset($result[$date])) $result[$date] = '';
|
||||
}
|
||||
} elseif ($datetype === 'd') {
|
||||
$date = $start_date;
|
||||
while ($date <= $end_date) {
|
||||
if( ! isset($result[$date])) $result[$date] = '';
|
||||
$date = cdate('Y-m-d', strtotime($date) + 86400);
|
||||
}
|
||||
}
|
||||
|
||||
if ($orderby === 'desc') {
|
||||
krsort($result);
|
||||
} else {
|
||||
ksort($result);
|
||||
}
|
||||
|
||||
$view['view']['list'] = $result;
|
||||
|
||||
$view['view']['start_date'] = $start_date;
|
||||
$view['view']['end_date'] = $end_date;
|
||||
$view['view']['datetype'] = $datetype;
|
||||
|
||||
$view['view']['boardlist'] = $this->Board_model->get_board_list();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
|
||||
|
||||
if ($export === 'excel') {
|
||||
|
||||
header('Content-type: application/vnd.ms-excel');
|
||||
header('Content-Disposition: attachment; filename=추천_' . cdate('Y_m_d') . '.xls');
|
||||
echo $this->load->view('admin/' . ADMIN_SKIN . '/' . $this->pagedir . '/graph_excel', $view, true);
|
||||
|
||||
} else {
|
||||
/**
|
||||
* 어드민 레이아웃을 정의합니다
|
||||
*/
|
||||
$layoutconfig = array('layout' => 'layout', 'skin' => 'graph');
|
||||
$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));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 비추천 수를 그래프 형식으로 보는 페이지입니다
|
||||
*/
|
||||
public function graph_dislike($export = '')
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_like_graph_dislike';
|
||||
$this->load->event($eventname);
|
||||
|
||||
$view = array();
|
||||
$view['view'] = array();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before'] = Events::trigger('before', $eventname);
|
||||
|
||||
$param =& $this->querystring;
|
||||
$datetype = $this->input->get('datetype', null, 'd');
|
||||
if ($datetype !== 'm' && $datetype !== 'y') {
|
||||
$datetype = 'd';
|
||||
}
|
||||
$start_date = $this->input->get('start_date') ? $this->input->get('start_date') : cdate('Y-m-01');
|
||||
$end_date = $this->input->get('end_date') ? $this->input->get('end_date') : cdate('Y-m-d');
|
||||
if ($datetype === 'y' OR $datetype === 'm') {
|
||||
$start_year = substr($start_date, 0, 4);
|
||||
$end_year = substr($end_date, 0, 4);
|
||||
}
|
||||
if ($datetype === 'm') {
|
||||
$start_month = substr($start_date, 5, 2);
|
||||
$end_month = substr($end_date, 5, 2);
|
||||
$start_year_month = $start_year * 12 + $start_month;
|
||||
$end_year_month = $end_year * 12 + $end_month;
|
||||
}
|
||||
$orderby = (strtolower($this->input->get('orderby')) === 'desc') ? 'desc' : 'asc';
|
||||
|
||||
$brd_id = $this->input->get('brd_id', null, '');
|
||||
|
||||
$result = $this->{$this->modelname}->get_dislike_count($datetype, $start_date, $end_date, $brd_id, $orderby);
|
||||
$sum_count = 0;
|
||||
$arr = array();
|
||||
$max = 0;
|
||||
|
||||
if ($result && is_array($result)) {
|
||||
foreach ($result as $key => $value) {
|
||||
$s = element('day', $value);
|
||||
if ( ! isset($arr[$s])) {
|
||||
$arr[$s] = 0;
|
||||
}
|
||||
$arr[$s] += element('cnt', $value);
|
||||
|
||||
if ($arr[$s] > $max) {
|
||||
$max = $arr[$s];
|
||||
}
|
||||
$sum_count += element('cnt', $value);
|
||||
}
|
||||
}
|
||||
|
||||
$result = array();
|
||||
$i = 0;
|
||||
$save_count = -1;
|
||||
$tot_count = 0;
|
||||
|
||||
if (count($arr)) {
|
||||
foreach ($arr as $key => $value) {
|
||||
$count = (int) $arr[$key];
|
||||
$result[$key]['count'] = $count;
|
||||
$i++;
|
||||
if ($save_count !== $count) {
|
||||
$no = $i;
|
||||
$save_count = $count;
|
||||
}
|
||||
$result[$key]['no'] = $no;
|
||||
|
||||
$result[$key]['key'] = $key;
|
||||
$rate = ($count / $sum_count * 100);
|
||||
$result[$key]['rate'] = $rate;
|
||||
$s_rate = number_format($rate, 1);
|
||||
$result[$key]['s_rate'] = $s_rate;
|
||||
|
||||
$bar = (int)($count / $max * 100);
|
||||
$result[$key]['bar'] = $bar;
|
||||
}
|
||||
$view['view']['max_value'] = $max;
|
||||
$view['view']['sum_count'] = $sum_count;
|
||||
}
|
||||
|
||||
if ($datetype === 'y') {
|
||||
for ($i = $start_year; $i <= $end_year; $i++) {
|
||||
if( ! isset($result[$i])) $result[$i] = '';
|
||||
}
|
||||
} elseif ($datetype === 'm') {
|
||||
for ($i = $start_year_month; $i <= $end_year_month; $i++) {
|
||||
$year = floor($i / 12);
|
||||
if ($year * 12 == $i) $year--;
|
||||
$month = sprintf("%02d", ($i - ($year * 12)));
|
||||
$date = $year . '-' . $month;
|
||||
if( ! isset($result[$date])) $result[$date] = '';
|
||||
}
|
||||
} elseif ($datetype === 'd') {
|
||||
$date = $start_date;
|
||||
while ($date <= $end_date) {
|
||||
if( ! isset($result[$date])) $result[$date] = '';
|
||||
$date = cdate('Y-m-d', strtotime($date) + 86400);
|
||||
}
|
||||
}
|
||||
|
||||
if ($orderby === 'desc') {
|
||||
krsort($result);
|
||||
} else {
|
||||
ksort($result);
|
||||
}
|
||||
|
||||
$view['view']['list'] = $result;
|
||||
|
||||
$view['view']['start_date'] = $start_date;
|
||||
$view['view']['end_date'] = $end_date;
|
||||
$view['view']['datetype'] = $datetype;
|
||||
|
||||
$view['view']['boardlist'] = $this->Board_model->get_board_list();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
|
||||
|
||||
if ($export === 'excel') {
|
||||
|
||||
header('Content-type: application/vnd.ms-excel');
|
||||
header('Content-Disposition: attachment; filename=비추천_' . cdate('Y_m_d') . '.xls');
|
||||
echo $this->load->view('admin/' . ADMIN_SKIN . '/' . $this->pagedir . '/graph_dislike_excel', $view, true);
|
||||
|
||||
} else {
|
||||
/**
|
||||
* 어드민 레이아웃을 정의합니다
|
||||
*/
|
||||
$layoutconfig = array('layout' => 'layout', 'skin' => 'graph_dislike');
|
||||
$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));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록 페이지에서 선택삭제를 하는 경우 실행되는 메소드입니다
|
||||
*/
|
||||
public function listdelete()
|
||||
{
|
||||
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_like_listdelete';
|
||||
$this->load->event($eventname);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('before', $eventname);
|
||||
|
||||
/**
|
||||
* 체크한 게시물의 삭제를 실행합니다
|
||||
*/
|
||||
if ($this->input->post('chk') && is_array($this->input->post('chk'))) {
|
||||
foreach ($this->input->post('chk') as $val) {
|
||||
if ($val) {
|
||||
$getdata = $this->{$this->modelname}->get_one($val);
|
||||
|
||||
$this->{$this->modelname}->delete($val);
|
||||
|
||||
$where = array(
|
||||
'target_id' => element('target_id', $getdata),
|
||||
'target_type' => element('target_type', $getdata),
|
||||
'lik_type' => element('lik_type', $getdata),
|
||||
);
|
||||
$like_cnt = $this->{$this->modelname}->count_by($where);
|
||||
|
||||
if (element('target_type', $getdata) === '1') { // 원글 추천의 경우
|
||||
if (element('lik_type', $getdata) === '1') {
|
||||
$updatedata = array(
|
||||
'post_like' => $like_cnt,
|
||||
);
|
||||
$this->Post_model->update(element('target_id', $getdata), $updatedata);
|
||||
} elseif (element('lik_type', $getdata) === '2') {
|
||||
$updatedata = array(
|
||||
'post_dislike' => $like_cnt,
|
||||
);
|
||||
$this->Post_model->update(element('target_id', $getdata), $updatedata);
|
||||
}
|
||||
} elseif (element('target_type', $getdata) === '2') { // 댓글 추천의 경우
|
||||
if (element('lik_type', $getdata) === '1') {
|
||||
$updatedata = array(
|
||||
'cmt_like' => $like_cnt,
|
||||
);
|
||||
$this->Comment_model->update(element('target_id', $getdata), $updatedata);
|
||||
} elseif (element('lik_type', $getdata) === '2') {
|
||||
$updatedata = array(
|
||||
'cmt_dislike' => $like_cnt,
|
||||
);
|
||||
$this->Comment_model->update(element('target_id', $getdata), $updatedata);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after', $eventname);
|
||||
|
||||
/**
|
||||
* 삭제가 끝난 후 목록페이지로 이동합니다
|
||||
*/
|
||||
$this->session->set_flashdata(
|
||||
'message',
|
||||
'정상적으로 삭제되었습니다'
|
||||
);
|
||||
$param =& $this->querystring;
|
||||
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
|
||||
|
||||
redirect($redirecturl);
|
||||
}
|
||||
}
|
||||
429
application/controllers/admin/board/Linkclick.php
Normal file
429
application/controllers/admin/board/Linkclick.php
Normal file
@@ -0,0 +1,429 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Linkclick class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 관리자>게시판설정>링크 클릭 controller 입니다.
|
||||
*/
|
||||
class Linkclick extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 관리자 페이지 상의 현재 디렉토리입니다
|
||||
* 페이지 이동시 필요한 정보입니다
|
||||
*/
|
||||
public $pagedir = 'board/linkclick';
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array('Post_link_click_log', 'Post_link', 'Board');
|
||||
|
||||
/**
|
||||
* 이 컨트롤러의 메인 모델 이름입니다
|
||||
*/
|
||||
protected $modelname = 'Post_link_click_log_model';
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/**
|
||||
* 라이브러리를 로딩합니다
|
||||
*/
|
||||
$this->load->library(array('pagination', 'querystring'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록을 가져오는 메소드입니다
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_linkclick_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;
|
||||
$findex = $this->input->get('findex') ? $this->input->get('findex') : $this->{$this->modelname}->primary_key;
|
||||
$forder = $this->input->get('forder', null, 'desc');
|
||||
$sfield = $this->input->get('sfield', null, '');
|
||||
$skeyword = $this->input->get('skeyword', null, '');
|
||||
|
||||
$per_page = admin_listnum();
|
||||
$offset = ($page - 1) * $per_page;
|
||||
|
||||
/**
|
||||
* 게시판 목록에 필요한 정보를 가져옵니다.
|
||||
*/
|
||||
$this->{$this->modelname}->allow_search_field = array('plc_id', 'pln_id', 'post.post_id', 'post.mem_id', 'post_link_click_log.mem_id', 'plc_datetime', 'plc_ip'); // 검색이 가능한 필드
|
||||
$this->{$this->modelname}->search_field_equal = array('plc_id', 'pln_id', 'post.post_id', 'post.mem_id', 'post_link_click_log.mem_id'); // 검색중 like 가 아닌 = 검색을 하는 필드
|
||||
$this->{$this->modelname}->allow_order_field = array('plc_id'); // 정렬이 가능한 필드
|
||||
|
||||
$where = array();
|
||||
if ($brdid = (int) $this->input->get('brd_id')) {
|
||||
$where['post.brd_id'] = $brdid;
|
||||
}
|
||||
$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) {
|
||||
$select = 'mem_id, mem_userid, mem_nickname, mem_icon';
|
||||
$result['list'][$key]['member'] = $dbmember = $this->Member_model->get_by_memid(element('mem_id', $val), $select);
|
||||
$result['list'][$key]['display_name'] = display_username(
|
||||
element('mem_userid', $dbmember),
|
||||
element('mem_nickname', $dbmember),
|
||||
element('mem_icon', $dbmember)
|
||||
);
|
||||
$result['list'][$key]['post_display_name'] = display_username(
|
||||
element('post_userid', $val),
|
||||
element('post_nickname', $val)
|
||||
);
|
||||
$brd_key = $this->board->item_id('brd_key', element('brd_id', $val));
|
||||
$result['list'][$key]['posturl'] = post_url($brd_key, element('post_id', $val));
|
||||
$result['list'][$key]['post_link'] = $this->Post_link_model->get_one(element('pln_id', $val));
|
||||
$result['list'][$key]['board'] = $board = $this->board->item_all(element('brd_id', $val));
|
||||
if ($board) {
|
||||
$result['list'][$key]['boardurl'] = board_url(element('brd_key', $board));
|
||||
}
|
||||
if (element('plc_useragent', $val)) {
|
||||
$userAgent = get_useragent_info(element('plc_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;
|
||||
|
||||
$view['view']['boardlist'] = $this->Board_model->get_board_list();
|
||||
|
||||
/**
|
||||
* 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('plc_datetime' => '날짜', 'plc_ip' => 'IP');
|
||||
$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']['list_delete_url'] = admin_url($this->pagedir . '/listdelete/?' . $param->output());
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$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));
|
||||
}
|
||||
|
||||
/**
|
||||
* 그래프 형식으로 보는 페이지입니다
|
||||
*/
|
||||
public function graph($export = '')
|
||||
{
|
||||
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_linkclick_graph';
|
||||
$this->load->event($eventname);
|
||||
|
||||
$view = array();
|
||||
$view['view'] = array();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before'] = Events::trigger('before', $eventname);
|
||||
|
||||
$param =& $this->querystring;
|
||||
$datetype = $this->input->get('datetype', null, 'd');
|
||||
if ($datetype !== 'm' && $datetype !== 'y') {
|
||||
$datetype = 'd';
|
||||
}
|
||||
$start_date = $this->input->get('start_date') ? $this->input->get('start_date') : cdate('Y-m-01');
|
||||
$end_date = $this->input->get('end_date') ? $this->input->get('end_date') : cdate('Y-m-d');
|
||||
if ($datetype === 'y' OR $datetype === 'm') {
|
||||
$start_year = substr($start_date, 0, 4);
|
||||
$end_year = substr($end_date, 0, 4);
|
||||
}
|
||||
if ($datetype === 'm') {
|
||||
$start_month = substr($start_date, 5, 2);
|
||||
$end_month = substr($end_date, 5, 2);
|
||||
$start_year_month = $start_year * 12 + $start_month;
|
||||
$end_year_month = $end_year * 12 + $end_month;
|
||||
}
|
||||
$orderby = (strtolower($this->input->get('orderby')) === 'desc') ? 'desc' : 'asc';
|
||||
|
||||
$brd_id = $this->input->get('brd_id', null, '');
|
||||
|
||||
$result = $this->{$this->modelname}->get_link_click_count($datetype, $start_date, $end_date, $brd_id, $orderby);
|
||||
$sum_count = 0;
|
||||
$arr = array();
|
||||
$max = 0;
|
||||
|
||||
if ($result && is_array($result)) {
|
||||
foreach ($result as $key => $value) {
|
||||
$s = element('day', $value);
|
||||
if ( ! isset($arr[$s])) {
|
||||
$arr[$s] = 0;
|
||||
}
|
||||
$arr[$s] += element('cnt', $value);
|
||||
|
||||
if ($arr[$s] > $max) {
|
||||
$max = $arr[$s];
|
||||
}
|
||||
$sum_count += element('cnt', $value);
|
||||
}
|
||||
}
|
||||
|
||||
$result = array();
|
||||
$i = 0;
|
||||
$save_count = -1;
|
||||
$tot_count = 0;
|
||||
|
||||
if (count($arr)) {
|
||||
foreach ($arr as $key => $value) {
|
||||
$count = (int) $arr[$key];
|
||||
$result[$key]['count'] = $count;
|
||||
$i++;
|
||||
if ($save_count !== $count) {
|
||||
$no = $i;
|
||||
$save_count = $count;
|
||||
}
|
||||
$result[$key]['no'] = $no;
|
||||
|
||||
$result[$key]['key'] = $key;
|
||||
$rate = ($count / $sum_count * 100);
|
||||
$result[$key]['rate'] = $rate;
|
||||
$s_rate = number_format($rate, 1);
|
||||
$result[$key]['s_rate'] = $s_rate;
|
||||
|
||||
$bar = (int)($count / $max * 100);
|
||||
$result[$key]['bar'] = $bar;
|
||||
}
|
||||
$view['view']['max_value'] = $max;
|
||||
$view['view']['sum_count'] = $sum_count;
|
||||
}
|
||||
|
||||
if ($datetype === 'y') {
|
||||
for ($i = $start_year; $i <= $end_year; $i++) {
|
||||
if( ! isset($result[$i])) $result[$i] = '';
|
||||
}
|
||||
} elseif ($datetype === 'm') {
|
||||
for ($i = $start_year_month; $i <= $end_year_month; $i++) {
|
||||
$year = floor($i / 12);
|
||||
if ($year * 12 == $i) $year--;
|
||||
$month = sprintf("%02d", ($i - ($year * 12)));
|
||||
$date = $year . '-' . $month;
|
||||
if( ! isset($result[$date])) $result[$date] = '';
|
||||
}
|
||||
} elseif ($datetype === 'd') {
|
||||
$date = $start_date;
|
||||
while ($date <= $end_date) {
|
||||
if( ! isset($result[$date])) $result[$date] = '';
|
||||
$date = cdate('Y-m-d', strtotime($date) + 86400);
|
||||
}
|
||||
}
|
||||
|
||||
if ($orderby === 'desc') {
|
||||
krsort($result);
|
||||
} else {
|
||||
ksort($result);
|
||||
}
|
||||
|
||||
$view['view']['list'] = $result;
|
||||
|
||||
$view['view']['start_date'] = $start_date;
|
||||
$view['view']['end_date'] = $end_date;
|
||||
$view['view']['datetype'] = $datetype;
|
||||
|
||||
$view['view']['boardlist'] = $this->Board_model->get_board_list();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
|
||||
|
||||
if ($export === 'excel') {
|
||||
|
||||
header('Content-type: application/vnd.ms-excel');
|
||||
header('Content-Disposition: attachment; filename=링크클릭_' . cdate('Y_m_d') . '.xls');
|
||||
echo $this->load->view('admin/' . ADMIN_SKIN . '/' . $this->pagedir . '/graph_excel', $view, true);
|
||||
|
||||
} else {
|
||||
/**
|
||||
* 어드민 레이아웃을 정의합니다
|
||||
*/
|
||||
$layoutconfig = array('layout' => 'layout', 'skin' => 'graph');
|
||||
$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));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록 페이지에서 선택삭제를 하는 경우 실행되는 메소드입니다
|
||||
*/
|
||||
public function listdelete()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_linkclick_listdelete';
|
||||
$this->load->event($eventname);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('before', $eventname);
|
||||
|
||||
/**
|
||||
* 체크한 게시물의 삭제를 실행합니다
|
||||
*/
|
||||
if ($this->input->post('chk') && is_array($this->input->post('chk'))) {
|
||||
foreach ($this->input->post('chk') as $val) {
|
||||
if ($val) {
|
||||
$this->{$this->modelname}->delete($val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after', $eventname);
|
||||
|
||||
/**
|
||||
* 삭제가 끝난 후 목록페이지로 이동합니다
|
||||
*/
|
||||
$this->session->set_flashdata(
|
||||
'message',
|
||||
'정상적으로 삭제되었습니다'
|
||||
);
|
||||
$param =& $this->querystring;
|
||||
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
|
||||
|
||||
redirect($redirecturl);
|
||||
}
|
||||
|
||||
/**
|
||||
* 오래된 링크클릭로그삭제 페이지입니다
|
||||
*/
|
||||
public function cleanlog()
|
||||
{
|
||||
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_linkclick_cleanlog';
|
||||
$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(
|
||||
'plc_datetime <=' => $this->input->post('criterion'),
|
||||
);
|
||||
$this->Post_link_click_log_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(
|
||||
'plc_datetime <=' => $criterion,
|
||||
);
|
||||
$log_count = $this->Post_link_click_log_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' => 'cleanlog');
|
||||
$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));
|
||||
}
|
||||
}
|
||||
281
application/controllers/admin/board/Naversyndilog.php
Normal file
281
application/controllers/admin/board/Naversyndilog.php
Normal file
@@ -0,0 +1,281 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Naversyndilog class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 관리자>게시판설정>네이버 신디케이션 핑전송로그 controller 입니다.
|
||||
*/
|
||||
class Naversyndilog extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 관리자 페이지 상의 현재 디렉토리입니다
|
||||
* 페이지 이동시 필요한 정보입니다
|
||||
*/
|
||||
public $pagedir = 'board/naversyndilog';
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array('Post_naver_syndi_log', 'Board');
|
||||
|
||||
/**
|
||||
* 이 컨트롤러의 메인 모델 이름입니다
|
||||
*/
|
||||
protected $modelname = 'Post_naver_syndi_log_model';
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/**
|
||||
* 라이브러리를 로딩합니다
|
||||
*/
|
||||
$this->load->library(array('pagination', 'querystring'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록을 가져오는 메소드입니다
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_naversyndilog_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;
|
||||
$findex = $this->input->get('findex') ? $this->input->get('findex') : $this->{$this->modelname}->primary_key;
|
||||
$forder = $this->input->get('forder', null, 'desc');
|
||||
$sfield = $this->input->get('sfield', null, '');
|
||||
$skeyword = $this->input->get('skeyword', null, '');
|
||||
|
||||
$per_page = admin_listnum();
|
||||
$offset = ($page - 1) * $per_page;
|
||||
|
||||
/**
|
||||
* 게시판 목록에 필요한 정보를 가져옵니다.
|
||||
*/
|
||||
$this->{$this->modelname}->allow_search_field = array('pns_id', 'post_naver_syndi_log.post_id', 'post_naver_syndi_log.mem_id', 'pns_status', 'pns_return_code', 'pns_return_message', 'pns_receipt_number', 'pns_datetime'); // 검색이 가능한 필드
|
||||
$this->{$this->modelname}->search_field_equal = array('pns_id', 'post_naver_syndi_log.post_id', 'post_naver_syndi_log.mem_id', 'pns_return_code'); // 검색중 like 가 아닌 = 검색을 하는 필드
|
||||
$this->{$this->modelname}->allow_order_field = array('pns_id', 'post_naver_syndi_log.post_id'); // 정렬이 가능한 필드
|
||||
|
||||
$where = array();
|
||||
if ($brdid = (int) $this->input->get('brd_id')) {
|
||||
$where['post.brd_id'] = $brdid;
|
||||
}
|
||||
$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) {
|
||||
$select = 'mem_id, mem_userid, mem_nickname, mem_icon';
|
||||
$result['list'][$key]['member'] = $dbmember = $this->Member_model->get_by_memid(element('mem_id', $val), $select);
|
||||
$result['list'][$key]['display_name'] = display_username(
|
||||
element('mem_userid', $dbmember),
|
||||
element('mem_nickname', $dbmember),
|
||||
element('mem_icon', $dbmember)
|
||||
);
|
||||
$result['list'][$key]['post_display_name'] = display_username(
|
||||
element('post_userid', $val),
|
||||
element('post_nickname', $val)
|
||||
);
|
||||
$brd_key = $this->board->item_id('brd_key', element('brd_id', $val));
|
||||
$result['list'][$key]['posturl'] = post_url($brd_key, element('post_id', $val));
|
||||
$result['list'][$key]['board'] = $board = $this->board->item_all(element('brd_id', $val));
|
||||
if ($board) {
|
||||
$result['list'][$key]['boardurl'] = board_url(element('brd_key', $board));
|
||||
}
|
||||
$result['list'][$key]['num'] = $list_num--;
|
||||
}
|
||||
}
|
||||
|
||||
$view['view']['data'] = $result;
|
||||
|
||||
$view['view']['boardlist'] = $this->Board_model->get_board_list();
|
||||
|
||||
/**
|
||||
* 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('pns_return_code' => 'Return Code', 'pns_return_message' => 'Return Message', 'pns_receipt_number' => 'Receipt Number', 'pns_datetime' => '날짜');
|
||||
$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']['list_delete_url'] = admin_url($this->pagedir . '/listdelete/?' . $param->output());
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$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));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 목록 페이지에서 선택삭제를 하는 경우 실행되는 메소드입니다
|
||||
*/
|
||||
public function listdelete()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_naversyndilog_listdelete';
|
||||
$this->load->event($eventname);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('before', $eventname);
|
||||
|
||||
/**
|
||||
* 체크한 게시물의 삭제를 실행합니다
|
||||
*/
|
||||
if ($this->input->post('chk') && is_array($this->input->post('chk'))) {
|
||||
foreach ($this->input->post('chk') as $val) {
|
||||
if ($val) {
|
||||
$this->{$this->modelname}->delete($val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after', $eventname);
|
||||
|
||||
/**
|
||||
* 삭제가 끝난 후 목록페이지로 이동합니다
|
||||
*/
|
||||
$this->session->set_flashdata(
|
||||
'message',
|
||||
'정상적으로 삭제되었습니다'
|
||||
);
|
||||
$param =& $this->querystring;
|
||||
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
|
||||
|
||||
redirect($redirecturl);
|
||||
}
|
||||
|
||||
/**
|
||||
* 오래된 링크클릭로그삭제 페이지입니다
|
||||
*/
|
||||
public function cleanlog()
|
||||
{
|
||||
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_naversyndilog_cleanlog';
|
||||
$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(
|
||||
'pns_datetime <=' => $this->input->post('criterion'),
|
||||
);
|
||||
$this->Post_naver_syndi_log_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(
|
||||
'pns_datetime <=' => $criterion,
|
||||
);
|
||||
$log_count = $this->Post_naver_syndi_log_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' => 'cleanlog');
|
||||
$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));
|
||||
}
|
||||
}
|
||||
248
application/controllers/admin/board/Post.php
Normal file
248
application/controllers/admin/board/Post.php
Normal file
@@ -0,0 +1,248 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Post class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 관리자>게시판설정>게시물관리 controller 입니다.
|
||||
*/
|
||||
class Post extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 관리자 페이지 상의 현재 디렉토리입니다
|
||||
* 페이지 이동시 필요한 정보입니다
|
||||
*/
|
||||
public $pagedir = 'board/post';
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array('Post', 'Board', 'Post_file', 'Post_meta', 'Board_category');
|
||||
|
||||
/**
|
||||
* 이 컨트롤러의 메인 모델 이름입니다
|
||||
*/
|
||||
protected $modelname = 'Post_model';
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/**
|
||||
* 라이브러리를 로딩합니다
|
||||
*/
|
||||
$this->load->library(array('pagination', 'querystring'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록을 가져오는 메소드입니다
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_post_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;
|
||||
$findex = 'post_id';
|
||||
$forder = 'desc';
|
||||
$sfield = $this->input->get('sfield', null, '');
|
||||
$skeyword = $this->input->get('skeyword', null, '');
|
||||
|
||||
$per_page = admin_listnum();
|
||||
$offset = ($page - 1) * $per_page;
|
||||
|
||||
/**
|
||||
* 게시판 목록에 필요한 정보를 가져옵니다.
|
||||
*/
|
||||
$this->{$this->modelname}->allow_search_field = array('post_id', 'post_title', 'post_content', 'mem_id', 'post_username', 'post_nickname', 'post_email', 'post_homepage', 'post_datetime', 'post_ip', 'post_device'); // 검색이 가능한 필드
|
||||
$this->{$this->modelname}->search_field_equal = array('post_id', 'mem_id'); // 검색중 like 가 아닌 = 검색을 하는 필드
|
||||
$this->{$this->modelname}->allow_order_field = array('post_id'); // 정렬이 가능한 필드
|
||||
$where = array(
|
||||
'post_del <>' => 2,
|
||||
);
|
||||
if ($brdid = (int) $this->input->get('brd_id')) {
|
||||
$where['brd_id'] = $brdid;
|
||||
}
|
||||
$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]['post_display_name'] = display_username(
|
||||
element('post_userid', $val),
|
||||
element('post_nickname', $val)
|
||||
);
|
||||
$result['list'][$key]['board'] = $board = $this->board->item_all(element('brd_id', $val));
|
||||
$result['list'][$key]['num'] = $list_num--;
|
||||
if ($board) {
|
||||
$result['list'][$key]['boardurl'] = board_url(element('brd_key', $board));
|
||||
$result['list'][$key]['posturl'] = post_url(element('brd_key', $board), element('post_id', $val));
|
||||
}
|
||||
$result['list'][$key]['category'] = '';
|
||||
if (element('post_category', $val)) {
|
||||
$result['list'][$key]['category'] = $this->Board_category_model->get_category_info(element('brd_id', $val), element('post_category', $val));
|
||||
}
|
||||
if (element('post_image', $val)) {
|
||||
$imagewhere = array(
|
||||
'post_id' => element('post_id', $val),
|
||||
'pfi_is_image' => 1,
|
||||
);
|
||||
$file = $this->Post_file_model->get_one('', '', $imagewhere, '', '', 'pfi_id', 'ASC');
|
||||
$result['list'][$key]['thumb_url'] = thumb_url('post', element('pfi_filename', $file), 80);
|
||||
} else {
|
||||
$result['list'][$key]['thumb_url'] = get_post_image_url(element('post_content', $val), 80);
|
||||
}
|
||||
}
|
||||
}
|
||||
$view['view']['data'] = $result;
|
||||
|
||||
$select = 'brd_id, brd_name';
|
||||
$view['view']['boardlist'] = $this->Board_model->get_board_list();
|
||||
|
||||
/**
|
||||
* 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('post_title' => '제목', 'post_content' => '내용', 'post_username' => '실명', 'post_nickname' => '닉네임', 'post_email' => '이메일', 'post_homepage' => '홈페이지', 'post_datetime' => '작성일', 'post_ip' => 'IP');
|
||||
$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']['list_delete_url'] = admin_url($this->pagedir . '/listdelete/?' . $param->output());
|
||||
$view['view']['list_trash_url'] = admin_url($this->pagedir . '/listtrash/?' . $param->output());
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$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));
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록 페이지에서 선택삭제를 하는 경우 실행되는 메소드입니다
|
||||
*/
|
||||
public function listdelete()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_post_listdelete';
|
||||
$this->load->event($eventname);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('before', $eventname);
|
||||
|
||||
/**
|
||||
* 체크한 게시물의 삭제를 실행합니다
|
||||
*/
|
||||
if ($this->input->post('chk') && is_array($this->input->post('chk'))) {
|
||||
foreach ($this->input->post('chk') as $val) {
|
||||
if ($val) {
|
||||
$this->board->delete_post($val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after', $eventname);
|
||||
|
||||
/**
|
||||
* 삭제가 끝난 후 목록페이지로 이동합니다
|
||||
*/
|
||||
$this->session->set_flashdata(
|
||||
'message',
|
||||
'정상적으로 삭제되었습니다'
|
||||
);
|
||||
$param =& $this->querystring;
|
||||
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
|
||||
redirect($redirecturl);
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록 페이지에서 휴지통을 클릭한 경우 실행되는 메소드입니다
|
||||
*/
|
||||
public function listtrash()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_post_listtrash';
|
||||
$this->load->event($eventname);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('before', $eventname);
|
||||
|
||||
/**
|
||||
* 체크한 게시물의 삭제를 실행합니다
|
||||
*/
|
||||
if ($this->input->post('chk') && is_array($this->input->post('chk'))) {
|
||||
foreach ($this->input->post('chk') as $val) {
|
||||
if ($val) {
|
||||
$updatedata = array(
|
||||
'post_del' => 2,
|
||||
);
|
||||
$this->Post_model->update($val, $updatedata);
|
||||
$metadata = array(
|
||||
'trash_mem_id' => $this->member->item('mem_id'),
|
||||
'trash_datetime' => cdate('Y-m-d H:i:s'),
|
||||
'trash_ip' => $this->input->ip_address(),
|
||||
);
|
||||
$board = $this->Post_model->get_one($val, 'brd_id');
|
||||
$this->Post_meta_model->save($val, element('brd_id', $board), $metadata);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after', $eventname);
|
||||
|
||||
/**
|
||||
* 삭제가 끝난 후 목록페이지로 이동합니다
|
||||
*/
|
||||
$this->session->set_flashdata(
|
||||
'message',
|
||||
'정상적으로 휴지통으로 이동되었습니다'
|
||||
);
|
||||
$param =& $this->querystring;
|
||||
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
|
||||
redirect($redirecturl);
|
||||
}
|
||||
}
|
||||
394
application/controllers/admin/board/Posthistory.php
Normal file
394
application/controllers/admin/board/Posthistory.php
Normal file
@@ -0,0 +1,394 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Posthistory class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 관리자>게시판설정>게시물변경로그 controller 입니다.
|
||||
*/
|
||||
class Posthistory extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 관리자 페이지 상의 현재 디렉토리입니다
|
||||
* 페이지 이동시 필요한 정보입니다
|
||||
*/
|
||||
public $pagedir = 'board/posthistory';
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array('Post_history', 'Post', 'Board');
|
||||
|
||||
/**
|
||||
* 이 컨트롤러의 메인 모델 이름입니다
|
||||
*/
|
||||
protected $modelname = 'Post_history_model';
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/**
|
||||
* 라이브러리를 로딩합니다
|
||||
*/
|
||||
$this->load->library(array('pagination', 'querystring'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록을 가져오는 함수입니다
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_posthistory_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;
|
||||
$findex = $this->input->get('findex') ? $this->input->get('findex') : $this->{$this->modelname}->primary_key;
|
||||
$forder = $this->input->get('forder', null, 'desc');
|
||||
$sfield = $this->input->get('sfield', null, '');
|
||||
$skeyword = $this->input->get('skeyword', null, '');
|
||||
|
||||
$per_page = admin_listnum();
|
||||
$offset = ($page - 1) * $per_page;
|
||||
|
||||
/**
|
||||
* 게시판 목록에 필요한 정보를 가져옵니다.
|
||||
*/
|
||||
$this->{$this->modelname}->allow_search_field = array('phi_id', 'post_history.post_id', 'post_history.mem_id', 'phi_title', 'phi_content', 'phi_ip', 'phi_datetime'); // 검색이 가능한 필드
|
||||
$this->{$this->modelname}->search_field_equal = array('phi_id', 'post_history.post_id', 'post_history.mem_id'); // 검색중 like 가 아닌 = 검색을 하는 필드
|
||||
$this->{$this->modelname}->allow_order_field = array('phi_id'); // 정렬이 가능한 필드
|
||||
$where = array(
|
||||
'post.post_del' => 0,
|
||||
);
|
||||
if ($brdid = (int) $this->input->get('brd_id')) {
|
||||
$where['post.brd_id'] = $brdid;
|
||||
}
|
||||
$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)
|
||||
);
|
||||
$result['list'][$key]['board'] = $board = $this->board->item_all(element('brd_id', $val));
|
||||
$result['list'][$key]['num'] = $list_num--;
|
||||
if ($board) {
|
||||
$result['list'][$key]['boardurl'] = board_url(element('brd_key', $board));
|
||||
$result['list'][$key]['posturl'] = post_url(element('brd_key', $board), element('post_id', $val));
|
||||
}
|
||||
$result['list'][$key]['post_display_name'] = display_username(
|
||||
element('post_userid', $val),
|
||||
element('post_nickname', $val)
|
||||
);
|
||||
}
|
||||
}
|
||||
$view['view']['data'] = $result;
|
||||
|
||||
$view['view']['boardlist'] = $this->Board_model->get_board_list();
|
||||
|
||||
/**
|
||||
* 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('phi_title' => '제목', 'phi_content' => '내용', 'phi_ip' => 'IP', 'phi_datetime' => '변경일');
|
||||
$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']['list_delete_url'] = admin_url($this->pagedir . '/listdelete/?' . $param->output());
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$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));
|
||||
}
|
||||
|
||||
/**
|
||||
* 상세보기 페이지를 가져오는 함수입니다
|
||||
*/
|
||||
public function view($phi_id = 0)
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_posthistory_view';
|
||||
$this->load->event($eventname);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before'] = Events::trigger('before', $eventname);
|
||||
|
||||
$phi_id = (int) $phi_id;
|
||||
if (empty($phi_id) OR $phi_id < 1) {
|
||||
show_404();
|
||||
}
|
||||
|
||||
$view = array();
|
||||
$view['view'] = array();
|
||||
|
||||
$param =& $this->querystring;
|
||||
|
||||
$result = $this->{$this->modelname}->get_one($phi_id);
|
||||
|
||||
if ( ! element('phi_id', $result)) {
|
||||
show_404();
|
||||
}
|
||||
|
||||
$select = 'mem_id, mem_userid, mem_nickname, mem_icon';
|
||||
$result['member'] = $dbmember = $this->Member_model->get_by_memid(element('mem_id', $result), $select);
|
||||
$result['display_name'] = display_username(
|
||||
element('mem_userid', $dbmember),
|
||||
element('mem_nickname', $dbmember),
|
||||
element('mem_icon', $dbmember)
|
||||
);
|
||||
$select = 'post_id, brd_id, post_title, post_userid, post_nickname, post_datetime, post_ip, post_hit, post_secret';
|
||||
$result['post'] = $post = $this->Post_model->get_one(element('post_id', $result), $select);
|
||||
if ($post) {
|
||||
$result['board'] = $board = $this->board->item_all(element('brd_id', $post));
|
||||
}
|
||||
$result['post_display_name'] = display_username(
|
||||
element('post_userid', $post),
|
||||
element('post_nickname', $post)
|
||||
);
|
||||
$image_width = ($this->cbconfig->get_device_view_type() === 'mobile') ? element('post_mobile_image_width', $board) : element('post_image_width', $board);
|
||||
$result['content'] = display_html_content(
|
||||
element('phi_content', $result),
|
||||
element('phi_content_html_type', $result),
|
||||
$image_width
|
||||
);
|
||||
|
||||
$where = array(
|
||||
'post_id' => element('post_id', $result),
|
||||
'phi_id <' => element('phi_id', $result),
|
||||
);
|
||||
$prev = $this->{$this->modelname}->get('', '', $where, 1, 0, 'phi_id', 'DESC');
|
||||
if ($prev && element(0, $prev)) {
|
||||
$prev[0]['content'] = display_html_content(
|
||||
$prev[0]['phi_content'],
|
||||
$prev[0]['phi_content_html_type'],
|
||||
$image_width
|
||||
);
|
||||
$result['prev'] = $prev[0];
|
||||
}
|
||||
|
||||
$view['view']['data'] = $result;
|
||||
|
||||
$view['view']['delete_url'] = admin_url($this->pagedir . '/delete/' . $phi_id . '?' . $param->output());
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
|
||||
|
||||
/**
|
||||
* 어드민 레이아웃을 정의합니다
|
||||
*/
|
||||
$layoutconfig = array('layout' => 'layout', 'skin' => 'view');
|
||||
$view['layout'] = $this->managelayout->admin($layoutconfig, $this->cbconfig->get_device_view_type());
|
||||
$this->data = $view;
|
||||
$this->layout = element('layout_skin_file', element('layout', $view));
|
||||
$this->view = element('view_skin_file', element('layout', $view));
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록 페이지에서 선택삭제를 하는 경우 실행되는 메소드입니다
|
||||
*/
|
||||
public function listdelete()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_posthistory_listdelete';
|
||||
$this->load->event($eventname);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('before', $eventname);
|
||||
|
||||
/**
|
||||
* 체크한 게시물의 삭제를 실행합니다
|
||||
*/
|
||||
if ($this->input->post('chk') && is_array($this->input->post('chk'))) {
|
||||
foreach ($this->input->post('chk') as $val) {
|
||||
if ($val) {
|
||||
$this->{$this->modelname}->delete($val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after', $eventname);
|
||||
|
||||
/**
|
||||
* 삭제가 끝난 후 목록페이지로 이동합니다
|
||||
*/
|
||||
$this->session->set_flashdata(
|
||||
'message',
|
||||
'정상적으로 삭제되었습니다'
|
||||
);
|
||||
$param =& $this->querystring;
|
||||
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
|
||||
|
||||
redirect($redirecturl);
|
||||
}
|
||||
|
||||
/**
|
||||
* 상세페이지에서 선택삭제를 하는 경우 실행되는 메소드입니다
|
||||
*/
|
||||
public function delete($phi_id = 0)
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_posthistory_delete';
|
||||
$this->load->event($eventname);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('before', $eventname);
|
||||
|
||||
$phi_id = (int) $phi_id;
|
||||
if (empty($phi_id) OR $phi_id < 1) {
|
||||
show_404();
|
||||
}
|
||||
|
||||
$this->{$this->modelname}->delete($phi_id);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after', $eventname);
|
||||
|
||||
/**
|
||||
* 삭제가 끝난 후 목록페이지로 이동합니다
|
||||
*/
|
||||
$this->session->set_flashdata(
|
||||
'message',
|
||||
'정상적으로 삭제되었습니다'
|
||||
);
|
||||
$param =& $this->querystring;
|
||||
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
|
||||
|
||||
redirect($redirecturl);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 오래된 게시물변경로그 페이지입니다
|
||||
*/
|
||||
public function cleanlog()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_posthistory_cleanlog';
|
||||
$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(
|
||||
'phi_datetime <=' => $this->input->post('criterion'),
|
||||
);
|
||||
$this->Post_history_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(
|
||||
'phi_datetime <=' => $criterion,
|
||||
);
|
||||
$log_count = $this->Post_history_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' => 'cleanlog');
|
||||
$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));
|
||||
}
|
||||
}
|
||||
293
application/controllers/admin/board/Tag.php
Normal file
293
application/controllers/admin/board/Tag.php
Normal file
@@ -0,0 +1,293 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Tag class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 관리자>게시판설정>태그관리 controller 입니다.
|
||||
*/
|
||||
class Tag extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 관리자 페이지 상의 현재 디렉토리입니다
|
||||
* 페이지 이동시 필요한 정보입니다
|
||||
*/
|
||||
public $pagedir = 'board/tag';
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array('Post_tag', 'Post', 'Board');
|
||||
|
||||
/**
|
||||
* 이 컨트롤러의 메인 모델 이름입니다
|
||||
*/
|
||||
protected $modelname = 'Post_tag_model';
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/**
|
||||
* 라이브러리를 로딩합니다
|
||||
*/
|
||||
$this->load->library(array('pagination', 'querystring'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록을 가져오는 메소드입니다
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_tag_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(
|
||||
'pta_id' => $param->sort('pta_id', 'asc'),
|
||||
'pta_tag' => $param->sort('pta_tag', 'asc'),
|
||||
);
|
||||
$findex = $this->input->get('findex') ? $this->input->get('findex') : $this->{$this->modelname}->primary_key;
|
||||
$forder = $this->input->get('forder', null, 'desc');
|
||||
$sfield = $this->input->get('sfield', null, '');
|
||||
$skeyword = $this->input->get('skeyword', null, '');
|
||||
|
||||
$per_page = admin_listnum();
|
||||
$offset = ($page - 1) * $per_page;
|
||||
|
||||
/**
|
||||
* 게시판 목록에 필요한 정보를 가져옵니다.
|
||||
*/
|
||||
$this->{$this->modelname}->allow_search_field = array('pta_id', 'post_tag.post_id', 'post_tag.mem_id', 'post.mem_id', 'pta_tag', 'pta_datetime', 'post_title'); // 검색이 가능한 필드
|
||||
$this->{$this->modelname}->search_field_equal = array('pta_id', 'post_tag.post_id', 'pta_tag', 'post_tag.mem_id', 'post.mem_id'); // 검색중 like 가 아닌 = 검색을 하는 필드
|
||||
$this->{$this->modelname}->allow_order_field = array('pta_id', 'pta_tag'); // 정렬이 가능한 필드
|
||||
$where = array(
|
||||
'post.post_del' => 0,
|
||||
);
|
||||
if ($brdid = (int) $this->input->get('brd_id')) {
|
||||
$where['post.brd_id'] = $brdid;
|
||||
}
|
||||
$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) {
|
||||
$brd_key = $this->board->item_id('brd_key', element('brd_id', $val));
|
||||
$result['list'][$key]['post_display_name'] = display_username(
|
||||
element('post_userid', $val),
|
||||
element('post_nickname', $val)
|
||||
);
|
||||
$result['list'][$key]['posturl'] = post_url($brd_key, element('post_id', $val));
|
||||
$result['list'][$key]['board'] = $board = $this->board->item_all(element('brd_id', $val));
|
||||
if ($board) {
|
||||
$result['list'][$key]['boardurl'] = board_url(element('brd_key', $board));
|
||||
}
|
||||
$result['list'][$key]['num'] = $list_num--;
|
||||
}
|
||||
}
|
||||
$view['view']['data'] = $result;
|
||||
$view['view']['boardlist'] = $this->Board_model->get_board_list();
|
||||
|
||||
/**
|
||||
* 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('pta_tag' => '태그명', 'post_title' => '게시물제목', 'pta_datetime' => '태그입력일');
|
||||
$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']['list_delete_url'] = admin_url($this->pagedir . '/listdelete/?' . $param->output());
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$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));
|
||||
}
|
||||
|
||||
/**
|
||||
* 그래프 형식으로 보는 페이지입니다
|
||||
*/
|
||||
public function graph($export = '')
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_tag_graph';
|
||||
$this->load->event($eventname);
|
||||
|
||||
$view = array();
|
||||
$view['view'] = array();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before'] = Events::trigger('before', $eventname);
|
||||
|
||||
$param =& $this->querystring;
|
||||
$datetype = $this->input->get('datetype', null, 'd');
|
||||
if ($datetype !== 'm' && $datetype !== 'y') {
|
||||
$datetype = 'd';
|
||||
}
|
||||
$start_date = $this->input->get('start_date') ? $this->input->get('start_date') : cdate('Y-m-01');
|
||||
$end_date = $this->input->get('end_date') ? $this->input->get('end_date') : cdate('Y-m-d');
|
||||
$brd_id = $this->input->get('brd_id', null, '');
|
||||
|
||||
$result = $this->{$this->modelname}->get_post_tag_count($datetype, $start_date, $end_date, $brd_id);
|
||||
|
||||
$sum_count = 0;
|
||||
$arr = array();
|
||||
$max = 0;
|
||||
|
||||
if ($result && is_array($result)) {
|
||||
foreach ($result as $key => $value) {
|
||||
$s = element('pta_tag', $value);
|
||||
if ( ! isset($arr[$s])) {
|
||||
$arr[$s] = 0;
|
||||
}
|
||||
$arr[$s] += element('cnt', $value);
|
||||
|
||||
if ($arr[$s] > $max) {
|
||||
$max = $arr[$s];
|
||||
}
|
||||
$sum_count += element('cnt', $value);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$view['view']['list'] = array();
|
||||
$i = 0;
|
||||
$k = 0;
|
||||
$save_count = -1;
|
||||
$tot_count = 0;
|
||||
|
||||
if (count($arr)) {
|
||||
foreach ($arr as $key => $value) {
|
||||
$count = (int) $arr[$key];
|
||||
$view['view']['list'][$k]['count'] = $count;
|
||||
$i++;
|
||||
if ($save_count !== $count) {
|
||||
$no = $i;
|
||||
$save_count = $count;
|
||||
}
|
||||
$view['view']['list'][$k]['no'] = $no;
|
||||
|
||||
$view['view']['list'][$k]['key'] = $key;
|
||||
$rate = ($count / $sum_count * 100);
|
||||
$view['view']['list'][$k]['rate'] = $rate;
|
||||
$s_rate = number_format($rate, 1);
|
||||
$view['view']['list'][$k]['s_rate'] = $s_rate;
|
||||
|
||||
$bar = (int)($count / $max * 100);
|
||||
$view['view']['list'][$k]['bar'] = $bar;
|
||||
$k++;
|
||||
}
|
||||
|
||||
$view['view']['max_value'] = $max;
|
||||
$view['view']['sum_count'] = $sum_count;
|
||||
}
|
||||
|
||||
$view['view']['start_date'] = $start_date;
|
||||
$view['view']['end_date'] = $end_date;
|
||||
|
||||
$view['view']['boardlist'] = $this->Board_model->get_board_list();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
|
||||
|
||||
if ($export === 'excel') {
|
||||
|
||||
header('Content-type: application/vnd.ms-excel');
|
||||
header('Content-Disposition: attachment; filename=태그_' . cdate('Y_m_d') . '.xls');
|
||||
echo $this->load->view('admin/' . ADMIN_SKIN . '/' . $this->pagedir . '/graph_excel', $view, true);
|
||||
|
||||
} else {
|
||||
/**
|
||||
* 어드민 레이아웃을 정의합니다
|
||||
*/
|
||||
$layoutconfig = array('layout' => 'layout', 'skin' => 'graph');
|
||||
$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));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록 페이지에서 선택삭제를 하는 경우 실행되는 메소드입니다
|
||||
*/
|
||||
public function listdelete()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_tag_listdelete';
|
||||
$this->load->event($eventname);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('before', $eventname);
|
||||
|
||||
/**
|
||||
* 체크한 게시물의 삭제를 실행합니다
|
||||
*/
|
||||
if ($this->input->post('chk') && is_array($this->input->post('chk'))) {
|
||||
foreach ($this->input->post('chk') as $val) {
|
||||
if ($val) {
|
||||
$this->{$this->modelname}->delete($val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after', $eventname);
|
||||
|
||||
/**
|
||||
* 삭제가 끝난 후 목록페이지로 이동합니다
|
||||
*/
|
||||
$this->session->set_flashdata(
|
||||
'message',
|
||||
'정상적으로 삭제되었습니다'
|
||||
);
|
||||
$param =& $this->querystring;
|
||||
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
|
||||
|
||||
redirect($redirecturl);
|
||||
}
|
||||
}
|
||||
466
application/controllers/admin/board/Trash.php
Normal file
466
application/controllers/admin/board/Trash.php
Normal file
@@ -0,0 +1,466 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Trash class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 관리자>게시판설정>휴지통 controller 입니다.
|
||||
*/
|
||||
class Trash extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 관리자 페이지 상의 현재 디렉토리입니다
|
||||
* 페이지 이동시 필요한 정보입니다
|
||||
*/
|
||||
public $pagedir = 'board/trash';
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array('Post', 'Comment', 'Board', 'Post_file', 'Post_meta', 'Comment_meta');
|
||||
|
||||
/**
|
||||
* 이 컨트롤러의 메인 모델 이름입니다
|
||||
*/
|
||||
protected $modelname = 'Post_model';
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/**
|
||||
* 라이브러리를 로딩합니다
|
||||
*/
|
||||
$this->load->library(array('pagination', 'querystring'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록을 가져오는 메소드입니다
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_trash_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;
|
||||
$findex = 'post_id';
|
||||
$forder = 'desc';
|
||||
$sfield = $this->input->get('sfield', null, '');
|
||||
$skeyword = $this->input->get('skeyword', null, '');
|
||||
|
||||
$per_page = admin_listnum();
|
||||
$offset = ($page - 1) * $per_page;
|
||||
|
||||
/**
|
||||
* 게시판 목록에 필요한 정보를 가져옵니다.
|
||||
*/
|
||||
$this->{$this->modelname}->allow_search_field = array('post_id', 'post_title', 'post_content', 'mem_id', 'post_username', 'post_nickname', 'post_email', 'post_homepage', 'post_datetime', 'post_ip', 'post_device'); // 검색이 가능한 필드
|
||||
$this->{$this->modelname}->search_field_equal = array('post_id', 'mem_id'); // 검색중 like 가 아닌 = 검색을 하는 필드
|
||||
$this->{$this->modelname}->allow_order_field = array('post_id desc'); // 정렬이 가능한 필드
|
||||
$where = array(
|
||||
'post_del' => 2,
|
||||
);
|
||||
if ($brdid = (int) $this->input->get('brd_id')) {
|
||||
$where['brd_id'] = $brdid;
|
||||
}
|
||||
$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]['meta'] = $meta = $this->Post_meta_model->get_all_meta(element('post_id', $val));
|
||||
if (element('trash_mem_id', $meta)) {
|
||||
$select = 'mem_id, mem_userid, mem_nickname, mem_icon';
|
||||
$result['list'][$key]['member'] = $dbmember = $this->Member_model->get_by_memid(element('trash_mem_id', $meta), $select);
|
||||
$result['list'][$key]['display_name'] = display_username(
|
||||
element('mem_userid', $dbmember),
|
||||
element('mem_nickname', $dbmember)
|
||||
);
|
||||
}
|
||||
$result['list'][$key]['board'] = $board = $this->board->item_all(element('brd_id', $val));
|
||||
$result['list'][$key]['num'] = $list_num--;
|
||||
if ($board) {
|
||||
$result['list'][$key]['boardurl'] = board_url(element('brd_key', $board));
|
||||
$result['list'][$key]['posturl'] = post_url(element('brd_key', $board), element('post_id', $val));
|
||||
$filewhere = array(
|
||||
'post_id' => element('post_id', $val),
|
||||
'pfi_is_image' => 1,
|
||||
);
|
||||
$file = $this->Post_file_model->get_one('', '', $filewhere, '', '', 'pfi_id', 'ASC');
|
||||
if (element('pfi_filename', $file)) {
|
||||
$result['list'][$key]['origin_image_url'] = thumb_url('post', element('pfi_filename', $file));
|
||||
$result['list'][$key]['thumb_url'] = thumb_url('post', element('pfi_filename', $file), '80');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$view['view']['data'] = $result;
|
||||
|
||||
$view['view']['boardlist'] = $this->Board_model->get_board_list();
|
||||
|
||||
/**
|
||||
* 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('post_title' => '제목', 'post_content' => '내용', 'post_username' => '실명', 'post_nickname' => '닉네임', 'post_email' => '이메일', 'post_homepage' => '홈페이지', 'post_datetime' => '작성일', 'post_ip' => 'IP');
|
||||
$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']['list_delete_url'] = admin_url($this->pagedir . '/listdelete/?' . $param->output());
|
||||
$view['view']['list_truncate_url'] = admin_url($this->pagedir . '/truncate/?' . $param->output());
|
||||
$view['view']['list_recover_url'] = admin_url($this->pagedir . '/listrecover/?' . $param->output());
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$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));
|
||||
}
|
||||
|
||||
/**
|
||||
* 상세 페이지입니다
|
||||
*/
|
||||
public function view($post_id = 0)
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_trash_view';
|
||||
$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();
|
||||
}
|
||||
|
||||
$param =& $this->querystring;
|
||||
|
||||
$result = $this->{$this->modelname}->get_one($post_id);
|
||||
$result['meta'] = $this->Post_meta_model->get_all_meta($post_id);
|
||||
|
||||
if ( ! element('post_id', $result)) {
|
||||
show_404();
|
||||
}
|
||||
if (element('post_del', $result) !== '2') {
|
||||
show_404();
|
||||
}
|
||||
|
||||
$result['post_display_name'] = display_username(
|
||||
element('post_userid', $result),
|
||||
element('post_nickname', $result)
|
||||
);
|
||||
$select = 'mem_id, mem_userid, mem_nickname, mem_icon';
|
||||
$result['member'] = $dbmember
|
||||
= $this->Member_model->get_by_memid($result['meta']['trash_mem_id'], $select);
|
||||
$result['display_name'] = display_username(
|
||||
element('mem_userid', $dbmember),
|
||||
element('mem_nickname', $dbmember),
|
||||
element('mem_icon', $dbmember)
|
||||
);
|
||||
$result['board'] = $board = $this->board->item_all($result['brd_id']);
|
||||
if ($board) {
|
||||
$result['boardurl'] = board_url(element('brd_key', $board));
|
||||
}
|
||||
$image_width = element('post_image_width', $board);
|
||||
$result['content'] = display_html_content(
|
||||
$result['post_content'],
|
||||
$result['post_html'],
|
||||
$image_width
|
||||
);
|
||||
|
||||
$view['view']['data'] = $result;
|
||||
|
||||
$view['view']['delete_url'] = admin_url($this->pagedir . '/delete/' . $post_id . '?' . $param->output());
|
||||
$view['view']['recover_url'] = admin_url($this->pagedir . '/recover/' . $post_id . '?' . $param->output());
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
|
||||
|
||||
/**
|
||||
* 어드민 레이아웃을 정의합니다
|
||||
*/
|
||||
$layoutconfig = array('layout' => 'layout', 'skin' => 'view');
|
||||
$view['layout'] = $this->managelayout->admin($layoutconfig, $this->cbconfig->get_device_view_type());
|
||||
$this->data = $view;
|
||||
$this->layout = element('layout_skin_file', element('layout', $view));
|
||||
$this->view = element('view_skin_file', element('layout', $view));
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록 페이지에서 선택삭제를 하는 경우 실행되는 메소드입니다
|
||||
*/
|
||||
public function listdelete()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_trash_listdelete';
|
||||
$this->load->event($eventname);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('before', $eventname);
|
||||
|
||||
/**
|
||||
* 체크한 게시물의 삭제를 실행합니다
|
||||
*/
|
||||
if ($this->input->post('chk') && is_array($this->input->post('chk'))) {
|
||||
foreach ($this->input->post('chk') as $val) {
|
||||
if ($val) {
|
||||
$this->board->delete_post($val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after', $eventname);
|
||||
|
||||
/**
|
||||
* 삭제가 끝난 후 목록페이지로 이동합니다
|
||||
*/
|
||||
$this->session->set_flashdata(
|
||||
'message',
|
||||
'정상적으로 삭제되었습니다'
|
||||
);
|
||||
$param =& $this->querystring;
|
||||
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
|
||||
redirect($redirecturl);
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록 페이지에서 복원을 하는 경우 실행되는 메소드입니다
|
||||
*/
|
||||
public function listrecover()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_trash_listrecover';
|
||||
$this->load->event($eventname);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('before', $eventname);
|
||||
|
||||
/**
|
||||
* 체크한 게시물의 삭제를 실행합니다
|
||||
*/
|
||||
if ($this->input->post('chk') && is_array($this->input->post('chk'))) {
|
||||
foreach ($this->input->post('chk') as $val) {
|
||||
if ($val) {
|
||||
$updatedata = array(
|
||||
'post_del' => 0,
|
||||
);
|
||||
$this->Post_model->update($val, $updatedata);
|
||||
$this->Post_meta_model->delete_meta_column('trash_ip');
|
||||
$this->Post_meta_model->delete_meta_column('trash_mem_id');
|
||||
$this->Post_meta_model->delete_meta_column('trash_datetime');
|
||||
|
||||
$where = array(
|
||||
'post_id' => $val,
|
||||
);
|
||||
$cmts = $this->Comment_model->get('', 'cmt_id', $where);
|
||||
if ($cmts && is_array($cmts)) {
|
||||
foreach ($cmts as $cmt) {
|
||||
$cmt_id = element('cmt_id', $cmt);
|
||||
$updatedata = array(
|
||||
'cmt_del' => 0,
|
||||
);
|
||||
$this->Comment_model->update($cmt_id, $updatedata);
|
||||
$this->Comment_meta_model->delete_meta_column('trash_ip');
|
||||
$this->Comment_meta_model->delete_meta_column('trash_mem_id');
|
||||
$this->Comment_meta_model->delete_meta_column('trash_datetime');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after', $eventname);
|
||||
|
||||
/**
|
||||
* 삭제가 끝난 후 목록페이지로 이동합니다
|
||||
*/
|
||||
$this->session->set_flashdata(
|
||||
'message',
|
||||
'정상적으로 복원되었습니다'
|
||||
);
|
||||
$param =& $this->querystring;
|
||||
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
|
||||
redirect($redirecturl);
|
||||
}
|
||||
|
||||
/**
|
||||
* 휴지통을 비웁니다
|
||||
*/
|
||||
public function truncate()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_trash_truncate';
|
||||
$this->load->event($eventname);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('before', $eventname);
|
||||
|
||||
$where = array(
|
||||
'post_del' => 2,
|
||||
);
|
||||
$result = $this->Post_model->get('', '', $where);
|
||||
|
||||
if ($result && is_array($result)) {
|
||||
foreach ($result as $val) {
|
||||
if (element('post_id', $val)) {
|
||||
$post_id = element('post_id', $val);
|
||||
$this->board->delete_post($post_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after', $eventname);
|
||||
|
||||
/**
|
||||
* 삭제가 끝난 후 목록페이지로 이동합니다
|
||||
*/
|
||||
$this->session->set_flashdata(
|
||||
'message',
|
||||
'정상적으로 삭제되었습니다'
|
||||
);
|
||||
$param =& $this->querystring;
|
||||
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
|
||||
redirect($redirecturl);
|
||||
}
|
||||
|
||||
/**
|
||||
* 뷰페이지에서 선택삭제를 하는 경우 실행되는 메소드입니다
|
||||
*/
|
||||
public function delete($post_id = 0)
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_trash_delete';
|
||||
$this->load->event($eventname);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('before', $eventname);
|
||||
|
||||
$post_id = (int) $post_id;
|
||||
if (empty($post_id) OR $post_id < 1) {
|
||||
show_404();
|
||||
}
|
||||
|
||||
$this->board->delete_post($post_id);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after', $eventname);
|
||||
|
||||
/**
|
||||
* 삭제가 끝난 후 목록페이지로 이동합니다
|
||||
*/
|
||||
$this->session->set_flashdata(
|
||||
'message',
|
||||
'정상적으로 삭제되었습니다'
|
||||
);
|
||||
$param =& $this->querystring;
|
||||
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
|
||||
redirect($redirecturl);
|
||||
}
|
||||
|
||||
/**
|
||||
* 뷰페이지에서 선택삭제를 하는 경우 실행되는 메소드입니다
|
||||
*/
|
||||
public function recover($post_id = 0)
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_trash_recover';
|
||||
$this->load->event($eventname);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('before', $eventname);
|
||||
|
||||
$post_id = (int) $post_id;
|
||||
if (empty($post_id) OR $post_id < 1) {
|
||||
show_404();
|
||||
}
|
||||
|
||||
$updatedata = array(
|
||||
'post_del' => 0,
|
||||
);
|
||||
$this->Post_model->update($post_id, $updatedata);
|
||||
$this->Post_meta_model->delete_meta_column('trash_ip');
|
||||
$this->Post_meta_model->delete_meta_column('trash_mem_id');
|
||||
$this->Post_meta_model->delete_meta_column('trash_datetime');
|
||||
|
||||
$where = array(
|
||||
'post_id' => $post_id,
|
||||
);
|
||||
$cmts = $this->Comment_model->get('', 'cmt_id', $where);
|
||||
if ($cmts && is_array($cmts)) {
|
||||
foreach ($cmts as $cmt) {
|
||||
$cmt_id = element('cmt_id', $cmt);
|
||||
$updatedata = array(
|
||||
'cmt_del' => 0,
|
||||
);
|
||||
$this->Comment_model->update($cmt_id, $updatedata);
|
||||
$this->Comment_meta_model->delete_meta_column('trash_ip');
|
||||
$this->Comment_meta_model->delete_meta_column('trash_mem_id');
|
||||
$this->Comment_meta_model->delete_meta_column('trash_datetime');
|
||||
}
|
||||
}
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after', $eventname);
|
||||
|
||||
/**
|
||||
* 삭제가 끝난 후 목록페이지로 이동합니다
|
||||
*/
|
||||
$this->session->set_flashdata(
|
||||
'message',
|
||||
'정상적으로 복원되었습니다'
|
||||
);
|
||||
$param =& $this->querystring;
|
||||
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
|
||||
redirect($redirecturl);
|
||||
}
|
||||
}
|
||||
429
application/controllers/admin/board/Trash_comment.php
Normal file
429
application/controllers/admin/board/Trash_comment.php
Normal file
@@ -0,0 +1,429 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Trash_comment class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 관리자>게시판설정>휴지통(댓글) controller 입니다.
|
||||
*/
|
||||
class Trash_comment extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 관리자 페이지 상의 현재 디렉토리입니다
|
||||
* 페이지 이동시 필요한 정보입니다
|
||||
*/
|
||||
public $pagedir = 'board/trash_comment';
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array('Post', 'Comment', 'Board', 'Comment_meta');
|
||||
|
||||
/**
|
||||
* 이 컨트롤러의 메인 모델 이름입니다
|
||||
*/
|
||||
protected $modelname = 'Comment_model';
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/**
|
||||
* 라이브러리를 로딩합니다
|
||||
*/
|
||||
$this->load->library(array('pagination', 'querystring'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록을 가져오는 메소드입니다
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_trash_comment_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;
|
||||
$findex = 'cmt_id';
|
||||
$forder = 'desc';
|
||||
$sfield = $this->input->get('sfield', null, '');
|
||||
$skeyword = $this->input->get('skeyword', null, '');
|
||||
|
||||
$per_page = admin_listnum();
|
||||
$offset = ($page - 1) * $per_page;
|
||||
|
||||
/**
|
||||
* 게시판 목록에 필요한 정보를 가져옵니다.
|
||||
*/
|
||||
$this->{$this->modelname}->allow_search_field = array('cmt_id', 'cmt_content', 'mem_id', 'cmt_username', 'cmt_nickname', 'cmt_email', 'cmt_datetime', 'cmt_ip', 'cmt_device'); // 검색이 가능한 필드
|
||||
$this->{$this->modelname}->search_field_equal = array('cmt_id', 'mem_id'); // 검색중 like 가 아닌 = 검색을 하는 필드
|
||||
$this->{$this->modelname}->allow_order_field = array('cmt_id desc'); // 정렬이 가능한 필드
|
||||
$where = array(
|
||||
'cmt_del' => 2,
|
||||
);
|
||||
if ($brdid = (int) $this->input->get('brd_id')) {
|
||||
$where['post.brd_id'] = $brdid;
|
||||
}
|
||||
$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]['meta'] = $meta = $this->Comment_meta_model->get_all_meta(element('cmt_id', $val));
|
||||
$result['list'][$key]['member'] = $dbmember = $this->Member_model->get_by_memid($meta['trash_mem_id'], 'mem_id, mem_userid, mem_nickname, mem_icon');
|
||||
|
||||
$result['list'][$key]['display_name'] = display_username(
|
||||
element('mem_userid', $dbmember),
|
||||
element('mem_nickname', $dbmember)
|
||||
);
|
||||
$result['list'][$key]['post'] = $post = $this->Post_model->get_one(element('post_id', $val));
|
||||
$result['list'][$key]['board'] = $board = $this->board->item_all(element('brd_id', $post));
|
||||
$result['list'][$key]['content'] = display_html_content(
|
||||
$val['cmt_content'],
|
||||
$val['cmt_html'],
|
||||
element('post_image_width', $board)
|
||||
);
|
||||
$result['list'][$key]['num'] = $list_num--;
|
||||
|
||||
if ($board) {
|
||||
$result['list'][$key]['boardurl'] = board_url(element('brd_key', $board));
|
||||
$result['list'][$key]['posturl'] = post_url(element('brd_key', $board), element('post_id', $val) . '#comment_id=' . element('cmt_id', $val));
|
||||
}
|
||||
}
|
||||
}
|
||||
$view['view']['data'] = $result;
|
||||
|
||||
$view['view']['boardlist'] = $this->Board_model->get_board_list();
|
||||
|
||||
/**
|
||||
* 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('cmt_content' => '내용', 'cmt_nickname' => '닉네임', 'cmt_email' => '이메일', 'cmt_datetime' => '작성일', 'cmt_ip' => 'IP');
|
||||
$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']['list_delete_url'] = admin_url($this->pagedir . '/listdelete/?' . $param->output());
|
||||
$view['view']['list_truncate_url'] = admin_url($this->pagedir . '/truncate/?' . $param->output());
|
||||
$view['view']['list_recover_url'] = admin_url($this->pagedir . '/listrecover/?' . $param->output());
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$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));
|
||||
}
|
||||
|
||||
/**
|
||||
* 상세 페이지입니다
|
||||
*/
|
||||
public function view($cmt_id = 0)
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_trash_comment_view';
|
||||
$this->load->event($eventname);
|
||||
|
||||
$view = array();
|
||||
$view['view'] = array();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before'] = Events::trigger('before', $eventname);
|
||||
|
||||
$cmt_id = (int) $cmt_id;
|
||||
if (empty($cmt_id) OR $cmt_id < 1) {
|
||||
show_404();
|
||||
}
|
||||
|
||||
$param =& $this->querystring;
|
||||
|
||||
$result = $this->{$this->modelname}->get_one($cmt_id);
|
||||
$result['meta'] = $this->Comment_meta_model->get_all_meta($cmt_id);
|
||||
|
||||
if ( ! element('cmt_id', $result)) {
|
||||
show_404();
|
||||
}
|
||||
if (element('cmt_del', $result) !== '2') {
|
||||
show_404();
|
||||
}
|
||||
|
||||
$result['cmt_display_name'] = display_username(
|
||||
element('cmt_userid', $result),
|
||||
element('cmt_nickname', $result)
|
||||
);
|
||||
$select = 'mem_id, mem_userid, mem_nickname, mem_icon';
|
||||
$result['member'] = $dbmember
|
||||
= $this->Member_model->get_by_memid($result['meta']['trash_mem_id'], $select);
|
||||
$result['display_name'] = display_username(
|
||||
element('mem_userid', $dbmember),
|
||||
element('mem_nickname', $dbmember),
|
||||
element('mem_icon', $dbmember)
|
||||
);
|
||||
$result['post'] = $post = $this->Post_model->get_one(element('post_id', $result));
|
||||
$result['board'] = $board = $this->board->item_all($post['brd_id']);
|
||||
if ($board) {
|
||||
$result['boardurl'] = board_url(element('brd_key', $board));
|
||||
$result['posturl'] = post_url(element('brd_key', $board), element('post_id', $result) . '#comment_id=' . element('cmt_id', $result));
|
||||
}
|
||||
$result['content'] = display_html_content(
|
||||
$result['cmt_content'],
|
||||
$result['cmt_html'],
|
||||
element('post_image_width', $board)
|
||||
);
|
||||
|
||||
$view['view']['data'] = $result;
|
||||
|
||||
$view['view']['delete_url'] = admin_url($this->pagedir . '/delete/' . $cmt_id . '?' . $param->output());
|
||||
$view['view']['recover_url'] = admin_url($this->pagedir . '/recover/' . $cmt_id . '?' . $param->output());
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
|
||||
|
||||
/**
|
||||
* 어드민 레이아웃을 정의합니다
|
||||
*/
|
||||
$layoutconfig = array('layout' => 'layout', 'skin' => 'view');
|
||||
$view['layout'] = $this->managelayout->admin($layoutconfig, $this->cbconfig->get_device_view_type());
|
||||
$this->data = $view;
|
||||
$this->layout = element('layout_skin_file', element('layout', $view));
|
||||
$this->view = element('view_skin_file', element('layout', $view));
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록 페이지에서 선택삭제를 하는 경우 실행되는 메소드입니다
|
||||
*/
|
||||
public function listdelete()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_trash_comment_listdelete';
|
||||
$this->load->event($eventname);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('before', $eventname);
|
||||
|
||||
/**
|
||||
* 체크한 게시물의 삭제를 실행합니다
|
||||
*/
|
||||
if ($this->input->post('chk') && is_array($this->input->post('chk'))) {
|
||||
foreach ($this->input->post('chk') as $val) {
|
||||
if ($val) {
|
||||
$this->board->delete_comment($val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after', $eventname);
|
||||
|
||||
/**
|
||||
* 삭제가 끝난 후 목록페이지로 이동합니다
|
||||
*/
|
||||
$this->session->set_flashdata(
|
||||
'message',
|
||||
'정상적으로 삭제되었습니다'
|
||||
);
|
||||
$param =& $this->querystring;
|
||||
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
|
||||
redirect($redirecturl);
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록 페이지에서 복원을 하는 경우 실행되는 메소드입니다
|
||||
*/
|
||||
public function listrecover()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_trash_comment_listrecover';
|
||||
$this->load->event($eventname);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('before', $eventname);
|
||||
|
||||
/**
|
||||
* 체크한 게시물의 삭제를 실행합니다
|
||||
*/
|
||||
if ($this->input->post('chk') && is_array($this->input->post('chk'))) {
|
||||
foreach ($this->input->post('chk') as $val) {
|
||||
if ($val) {
|
||||
$updatedata = array(
|
||||
'cmt_del' => 0,
|
||||
);
|
||||
$this->Comment_model->update($val, $updatedata);
|
||||
$this->Comment_meta_model->delete_meta_column('trash_ip');
|
||||
$this->Comment_meta_model->delete_meta_column('trash_mem_id');
|
||||
$this->Comment_meta_model->delete_meta_column('trash_datetime');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after', $eventname);
|
||||
|
||||
/**
|
||||
* 삭제가 끝난 후 목록페이지로 이동합니다
|
||||
*/
|
||||
$this->session->set_flashdata(
|
||||
'message',
|
||||
'정상적으로 복원되었습니다'
|
||||
);
|
||||
$param =& $this->querystring;
|
||||
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
|
||||
redirect($redirecturl);
|
||||
}
|
||||
|
||||
/**
|
||||
* 휴지통을 비웁니다
|
||||
*/
|
||||
public function truncate()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_trash_comment_truncate';
|
||||
$this->load->event($eventname);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('before', $eventname);
|
||||
|
||||
$where = array(
|
||||
'cmt_del' => 2,
|
||||
);
|
||||
$result = $this->Comment_model->get('', '', $where);
|
||||
|
||||
if ($result && is_array($result)) {
|
||||
foreach ($result as $val) {
|
||||
if (element('cmt_id', $val)) {
|
||||
$post_id = element('cmt_id', $val);
|
||||
$this->board->delete_comment($cmt_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after', $eventname);
|
||||
|
||||
/**
|
||||
* 삭제가 끝난 후 목록페이지로 이동합니다
|
||||
*/
|
||||
$this->session->set_flashdata(
|
||||
'message',
|
||||
'정상적으로 삭제되었습니다'
|
||||
);
|
||||
$param =& $this->querystring;
|
||||
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
|
||||
redirect($redirecturl);
|
||||
}
|
||||
|
||||
/**
|
||||
* 뷰페이지에서 선택삭제를 하는 경우 실행되는 메소드입니다
|
||||
*/
|
||||
public function delete($cmt_id = 0)
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_trash_comment_delete';
|
||||
$this->load->event($eventname);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('before', $eventname);
|
||||
|
||||
$cmt_id = (int) $cmt_id;
|
||||
if (empty($cmt_id) OR $cmt_id < 1) {
|
||||
show_404();
|
||||
}
|
||||
|
||||
$this->board->delete_comment($cmt_id);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after', $eventname);
|
||||
|
||||
/**
|
||||
* 삭제가 끝난 후 목록페이지로 이동합니다
|
||||
*/
|
||||
$this->session->set_flashdata(
|
||||
'message',
|
||||
'정상적으로 삭제되었습니다'
|
||||
);
|
||||
$param =& $this->querystring;
|
||||
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
|
||||
redirect($redirecturl);
|
||||
}
|
||||
|
||||
/**
|
||||
* 뷰페이지에서 선택삭제를 하는 경우 실행되는 메소드입니다
|
||||
*/
|
||||
public function recover($cmt_id = 0)
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_board_trash_comment_recover';
|
||||
$this->load->event($eventname);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('before', $eventname);
|
||||
|
||||
$cmt_id = (int) $cmt_id;
|
||||
if (empty($cmt_id) OR $cmt_id < 1) {
|
||||
show_404();
|
||||
}
|
||||
|
||||
$updatedata = array(
|
||||
'cmt_del' => 0,
|
||||
);
|
||||
$this->Comment_model->update($cmt_id, $updatedata);
|
||||
$this->Comment_meta_model->delete_meta_column('trash_ip');
|
||||
$this->Comment_meta_model->delete_meta_column('trash_mem_id');
|
||||
$this->Comment_meta_model->delete_meta_column('trash_datetime');
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after', $eventname);
|
||||
|
||||
/**
|
||||
* 삭제가 끝난 후 목록페이지로 이동합니다
|
||||
*/
|
||||
$this->session->set_flashdata(
|
||||
'message',
|
||||
'정상적으로 복원되었습니다'
|
||||
);
|
||||
$param =& $this->querystring;
|
||||
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
|
||||
redirect($redirecturl);
|
||||
}
|
||||
}
|
||||
101
application/controllers/admin/config/Browscapupdate.php
Normal file
101
application/controllers/admin/config/Browscapupdate.php
Normal file
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Browscapupdate class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 관리자>환경설정>Browscap 업데이트 controller 입니다.
|
||||
*/
|
||||
class Browscapupdate extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 관리자 페이지 상의 현재 디렉토리입니다
|
||||
* 페이지 이동시 필요한 정보입니다
|
||||
*/
|
||||
public $pagedir = 'config/browscapupdate';
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array();
|
||||
|
||||
/**
|
||||
* 이 컨트롤러의 메인 모델 이름입니다
|
||||
*/
|
||||
protected $modelname = '';
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/**
|
||||
* 라이브러리를 로딩합니다
|
||||
*/
|
||||
$this->load->library(array('querystring'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Browscap 업데이트 페이지입니다
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_config_browscapupdate_index';
|
||||
$this->load->event($eventname);
|
||||
|
||||
$view = array();
|
||||
$view['view'] = array();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before'] = Events::trigger('before', $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));
|
||||
}
|
||||
|
||||
public function update()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_config_browscapupdate_update';
|
||||
$this->load->event($eventname);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('before', $eventname);
|
||||
|
||||
$dir = FCPATH . 'plugin/browscap';
|
||||
if ( ! (is_readable($dir) && is_writeable($dir))) {
|
||||
exit(json_encode(array('success' => 'no', 'message' => 'plugin/browscap 경로가 파일쓰기가 금지되어있습니다. 퍼미션 확인 후에 다시 실행바랍니다')));
|
||||
}
|
||||
|
||||
ini_set('memory_limit', '-1');
|
||||
require_once FCPATH . 'plugin/browscap/Browscap.php';
|
||||
|
||||
$browscap = new phpbrowscap\Browscap($dir);
|
||||
$browscap->updateMethod = 'cURL';
|
||||
$browscap->cacheFilename = 'browscap_cache.php';
|
||||
$browscap->updateCache();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after', $eventname);
|
||||
|
||||
exit(json_encode(array('success' => 'ok', 'message' => 'Browscap 업데이트가 완료되었습니다')));
|
||||
}
|
||||
}
|
||||
1105
application/controllers/admin/config/Cbconfigs.php
Normal file
1105
application/controllers/admin/config/Cbconfigs.php
Normal file
File diff suppressed because it is too large
Load Diff
94
application/controllers/admin/config/Cbversion.php
Normal file
94
application/controllers/admin/config/Cbversion.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Cbversion class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 관리자>환경설정>버전정보 controller 입니다.
|
||||
*/
|
||||
class Cbversion extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 관리자 페이지 상의 현재 디렉토리입니다
|
||||
* 페이지 이동시 필요한 정보입니다
|
||||
*/
|
||||
public $pagedir = 'config/cbversion';
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array();
|
||||
|
||||
/**
|
||||
* 이 컨트롤러의 메인 모델 이름입니다
|
||||
*/
|
||||
protected $modelname = '';
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array', 'file');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/**
|
||||
* 라이브러리를 로딩합니다
|
||||
*/
|
||||
$this->load->library(array('requests'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 버전정보 페이지입니다
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_config_cbversion_index';
|
||||
$this->load->event($eventname);
|
||||
|
||||
$view = array();
|
||||
$view['view'] = array();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before'] = Events::trigger('before', $eventname);
|
||||
|
||||
Requests::register_autoloader();
|
||||
$headers = array('Accept' => 'application/json');
|
||||
$postdata = array('requesturl' => current_full_url(), 'package' => CB_PACKAGE, 'version' => CB_VERSION);
|
||||
|
||||
try {
|
||||
$request = Requests::post(config_item('ciboard_check_latest_version'), $headers, $postdata);
|
||||
$view['view']['latest_versions'] = json_decode($request->body, true);
|
||||
if (strtolower(CB_PACKAGE) === 'pro') {
|
||||
$view['view']['latest_version_name'] = $view['view']['latest_versions']['pro_version'];
|
||||
$view['view']['latest_download_url'] = $view['view']['latest_versions']['pro_downloadurl'];
|
||||
} else {
|
||||
$view['view']['latest_version_name'] = $view['view']['latest_versions']['lite_version'];
|
||||
$view['view']['latest_download_url'] = $view['view']['latest_versions']['lite_downloadurl'];
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
log_message('error', 'Caught exception: '.$e->getMessage());
|
||||
}
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$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));
|
||||
}
|
||||
}
|
||||
848
application/controllers/admin/config/Cleanlog.php
Normal file
848
application/controllers/admin/config/Cleanlog.php
Normal file
@@ -0,0 +1,848 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Cleanlog class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 관리자>환경설정>오래된로그삭제 controller 입니다.
|
||||
*/
|
||||
class Cleanlog extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 관리자 페이지 상의 현재 디렉토리입니다
|
||||
* 페이지 이동시 필요한 정보입니다
|
||||
*/
|
||||
public $pagedir = 'config/cleanlog';
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array();
|
||||
|
||||
/**
|
||||
* 이 컨트롤러의 메인 모델 이름입니다
|
||||
*/
|
||||
protected $modelname = '';
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array', 'file');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/**
|
||||
* 라이브러리를 로딩합니다
|
||||
*/
|
||||
$this->load->library(array('querystring'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 오래된로그 삭제>캐시삭제 페이지입니다
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
|
||||
$this->cache();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 오래된로그 삭제>캐시삭제 페이지입니다
|
||||
*/
|
||||
public function cache()
|
||||
{
|
||||
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_config_cleanlog_cache';
|
||||
$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' => 'execute',
|
||||
'label' => '실행',
|
||||
'rules' => 'trim',
|
||||
),
|
||||
);
|
||||
$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);
|
||||
|
||||
$result = $this->cache->clean();
|
||||
if ($result !== false) {
|
||||
$view['view']['alert_message'] = '캐시가 삭제되었습니다';
|
||||
} else {
|
||||
$view['view']['alert_message'] = '캐시 삭제에 실패했습니다';
|
||||
}
|
||||
}
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
|
||||
|
||||
/**
|
||||
* 어드민 레이아웃을 정의합니다
|
||||
*/
|
||||
$layoutconfig = array('layout' => 'layout', 'skin' => 'cache');
|
||||
$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));
|
||||
}
|
||||
|
||||
/**
|
||||
* 오래된로그 삭제>썸네일삭제 페이지입니다
|
||||
*/
|
||||
public function thumbnail()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_config_cleanlog_thumbnail';
|
||||
$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' => 'execute',
|
||||
'label' => '실행',
|
||||
'rules' => 'trim',
|
||||
),
|
||||
);
|
||||
$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);
|
||||
|
||||
$result = delete_files(config_item('uploads_dir') . '/cache/', true);
|
||||
if ($result !== false) {
|
||||
$view['view']['alert_message'] = '썸네일이 모두 삭제되었습니다';
|
||||
} else {
|
||||
$view['view']['alert_message'] = '썸네일 삭제에 실패했습니다';
|
||||
}
|
||||
}
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
|
||||
|
||||
/**
|
||||
* 어드민 레이아웃을 정의합니다
|
||||
*/
|
||||
$layoutconfig = array('layout' => 'layout', 'skin' => 'thumbnail');
|
||||
$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));
|
||||
}
|
||||
|
||||
/**
|
||||
* 오래된로그 삭제>방문자로그삭제 페이지입니다
|
||||
*/
|
||||
public function visitlog()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_config_cleanlog_visitlog';
|
||||
$this->load->event($eventname);
|
||||
|
||||
$view = array();
|
||||
$view['view'] = array();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before'] = Events::trigger('before', $eventname);
|
||||
|
||||
$this->load->model(array('Stat_count_model', 'Stat_count_date_model'));
|
||||
|
||||
/**
|
||||
* 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(
|
||||
'sco_date <=' => $this->input->post('criterion'),
|
||||
);
|
||||
$this->Stat_count_model->delete_where($deletewhere);
|
||||
|
||||
$deletewhere = array(
|
||||
'scd_date <=' => $this->input->post('criterion')
|
||||
);
|
||||
$this->Stat_count_date_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', ctimestamp() - $this->input->post('day') * 24 * 60 * 60);
|
||||
|
||||
$countwhere = array(
|
||||
'sco_date <=' => $criterion,
|
||||
);
|
||||
$log_count = $this->Stat_count_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' => 'visitlog');
|
||||
$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));
|
||||
}
|
||||
|
||||
/**
|
||||
* 오래된로그 삭제>로그인로그삭제 페이지입니다
|
||||
*/
|
||||
public function loginlog()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_config_cleanlog_loginlog';
|
||||
$this->load->event($eventname);
|
||||
|
||||
$view = array();
|
||||
$view['view'] = array();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before'] = Events::trigger('before', $eventname);
|
||||
|
||||
$this->load->model('Member_login_log_model');
|
||||
|
||||
/**
|
||||
* 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(
|
||||
'mll_datetime <=' => $this->input->post('criterion'),
|
||||
);
|
||||
$this->Member_login_log_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(
|
||||
'mll_datetime <=' => $criterion,
|
||||
);
|
||||
$log_count = $this->Member_login_log_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' => 'loginlog');
|
||||
$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));
|
||||
}
|
||||
|
||||
/**
|
||||
* 오래된로그 삭제>파일다운로드로그삭제 페이지입니다
|
||||
*/
|
||||
public function filedownloadlog()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_config_cleanlog_filedownloadlog';
|
||||
$this->load->event($eventname);
|
||||
|
||||
$view = array();
|
||||
$view['view'] = array();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before'] = Events::trigger('before', $eventname);
|
||||
|
||||
$this->load->model('Post_file_download_log_model');
|
||||
|
||||
/**
|
||||
* 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(
|
||||
'pfd_datetime <=' => $this->input->post('criterion'),
|
||||
);
|
||||
$this->Post_file_download_log_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(
|
||||
'pfd_datetime <=' => $criterion,
|
||||
);
|
||||
$log_count = $this->Post_file_download_log_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' => 'filedownloadlog');
|
||||
$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));
|
||||
}
|
||||
|
||||
/**
|
||||
* 오래된로그 삭제>게시물변경로그삭제 페이지입니다
|
||||
*/
|
||||
public function posthistory()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_config_cleanlog_posthistory';
|
||||
$this->load->event($eventname);
|
||||
|
||||
$view = array();
|
||||
$view['view'] = array();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before'] = Events::trigger('before', $eventname);
|
||||
|
||||
$this->load->model('Post_history_model');
|
||||
|
||||
/**
|
||||
* 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(
|
||||
'phi_datetime <=' => $this->input->post('criterion'),
|
||||
);
|
||||
$this->Post_history_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(
|
||||
'phi_datetime <=' => $criterion,
|
||||
);
|
||||
$log_count = $this->Post_history_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' => 'posthistory');
|
||||
$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));
|
||||
}
|
||||
|
||||
/**
|
||||
* 오래된로그 삭제>링크클릭로그 삭제 페이지입니다
|
||||
*/
|
||||
public function linkclicklog()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_config_cleanlog_linkclicklog';
|
||||
$this->load->event($eventname);
|
||||
|
||||
$view = array();
|
||||
$view['view'] = array();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before'] = Events::trigger('before', $eventname);
|
||||
|
||||
$this->load->model('Post_link_click_log_model');
|
||||
|
||||
/**
|
||||
* 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(
|
||||
'plc_datetime <=' => $this->input->post('criterion'),
|
||||
);
|
||||
$this->Post_link_click_log_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(
|
||||
'plc_datetime <=' => $criterion,
|
||||
);
|
||||
$log_count = $this->Post_link_click_log_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' => 'linkclicklog');
|
||||
$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));
|
||||
}
|
||||
|
||||
/**
|
||||
* 오래된로그 삭제>오래된쪽지삭제 페이지입니다
|
||||
*/
|
||||
public function note()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_config_cleanlog_note';
|
||||
$this->load->event($eventname);
|
||||
|
||||
$view = array();
|
||||
$view['view'] = array();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before'] = Events::trigger('before', $eventname);
|
||||
|
||||
$this->load->model('Note_model');
|
||||
|
||||
/**
|
||||
* 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(
|
||||
'nte_datetime <=' => $this->input->post('criterion')
|
||||
);
|
||||
$this->Note_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(
|
||||
'nte_datetime <=' => $criterion,
|
||||
);
|
||||
$log_count = $this->Note_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' => 'note');
|
||||
$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));
|
||||
}
|
||||
|
||||
/**
|
||||
* 오래된로그 삭제>자동로그인로그삭제 페이지입니다
|
||||
*/
|
||||
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);
|
||||
|
||||
$this->load->model('Autologin_model');
|
||||
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));
|
||||
}
|
||||
}
|
||||
130
application/controllers/admin/config/Dbupgrade.php
Normal file
130
application/controllers/admin/config/Dbupgrade.php
Normal file
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Dbupgrade class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 관리자>환경설정>DB 업그레이드 controller 입니다.
|
||||
*/
|
||||
class Dbupgrade extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 관리자 페이지 상의 현재 디렉토리입니다
|
||||
* 페이지 이동시 필요한 정보입니다
|
||||
*/
|
||||
public $pagedir = 'config/dbupgrade';
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array();
|
||||
|
||||
/**
|
||||
* 이 컨트롤러의 메인 모델 이름입니다
|
||||
*/
|
||||
protected $modelname = '';
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/**
|
||||
* 라이브러리를 로딩합니다
|
||||
*/
|
||||
$this->load->library(array('querystring'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 디비 업그레이드 페이지입니다
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_config_dbupgrade_index';
|
||||
$this->load->event($eventname);
|
||||
|
||||
$view = array();
|
||||
$view['view'] = array();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before'] = Events::trigger('before', $eventname);
|
||||
|
||||
/**
|
||||
* 마이그레이션 라이브러리를 가져옵니다
|
||||
*/
|
||||
$this->load->library('migration');
|
||||
$this->config->load('migration');
|
||||
$row = $this->db->get('migrations')->row();
|
||||
$view['view']['current_version'] = $row ? $row->version : 0;
|
||||
$view['view']['latest_version'] = $latest_version = config_item('migration_version');
|
||||
|
||||
/**
|
||||
* Validation 라이브러리를 가져옵니다
|
||||
*/
|
||||
$this->load->library('form_validation');
|
||||
|
||||
/**
|
||||
* 전송된 데이터의 유효성을 체크합니다
|
||||
*/
|
||||
$config = array(
|
||||
array(
|
||||
'field' => 'execute',
|
||||
'label' => '실행',
|
||||
'rules' => 'trim',
|
||||
),
|
||||
);
|
||||
$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->migration->version($latest_version) === false) {
|
||||
$view['view']['alert_message'] = $this->migration->error_string();
|
||||
} else {
|
||||
$row = $this->db->get('migrations')->row();
|
||||
$view['view']['current_version'] = $row ? $row->version : 0;
|
||||
$view['view']['latest_version'] = config_item('migration_version');
|
||||
$view['view']['alert_message'] = '최신버전으로 업그레이드가 완료되었습니다';
|
||||
}
|
||||
}
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$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));
|
||||
}
|
||||
}
|
||||
1333
application/controllers/admin/config/Emailform.php
Normal file
1333
application/controllers/admin/config/Emailform.php
Normal file
File diff suppressed because it is too large
Load Diff
1500
application/controllers/admin/config/Layoutskin.php
Normal file
1500
application/controllers/admin/config/Layoutskin.php
Normal file
File diff suppressed because it is too large
Load Diff
1014
application/controllers/admin/config/Memberconfig.php
Normal file
1014
application/controllers/admin/config/Memberconfig.php
Normal file
File diff suppressed because it is too large
Load Diff
124
application/controllers/admin/config/Optimize.php
Normal file
124
application/controllers/admin/config/Optimize.php
Normal file
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Optimize class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 관리자>환경설정>복구/최적화 controller 입니다.
|
||||
*/
|
||||
class Optimize extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 관리자 페이지 상의 현재 디렉토리입니다
|
||||
* 페이지 이동시 필요한 정보입니다
|
||||
*/
|
||||
public $pagedir = 'config/optimize';
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array();
|
||||
|
||||
/**
|
||||
* 이 컨트롤러의 메인 모델 이름입니다
|
||||
*/
|
||||
protected $modelname = '';
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/**
|
||||
* 라이브러리를 로딩합니다
|
||||
*/
|
||||
$this->load->library(array('querystring'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 복구/최적화 페이지입니다
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_config_optimize_index';
|
||||
$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' => 'execute',
|
||||
'label' => '실행',
|
||||
'rules' => 'trim',
|
||||
),
|
||||
);
|
||||
$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);
|
||||
|
||||
$view['view']['alert_message'] = '';
|
||||
$this->load->dbutil();
|
||||
$result = $this->dbutil->optimize_database();
|
||||
if ($result !== false) {
|
||||
foreach ($result as $key => $val) {
|
||||
$view['view']['alert_message'] .= $key . ' : ' . $val['Msg_text'] . '<br />';
|
||||
}
|
||||
$view['view']['alert_message'] .= '복구/ 최적화가 완료되었습니다';
|
||||
} else {
|
||||
$view['view']['alert_message'] .= '복구/ 최적화에 실패했습니다';
|
||||
}
|
||||
}
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$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));
|
||||
}
|
||||
}
|
||||
68
application/controllers/admin/config/Phpinfo.php
Normal file
68
application/controllers/admin/config/Phpinfo.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Phpinfo class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 관리자>환경설정>phpinfo controller 입니다.
|
||||
*/
|
||||
class Phpinfo extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 관리자 페이지 상의 현재 디렉토리입니다
|
||||
* 페이지 이동시 필요한 정보입니다
|
||||
*/
|
||||
public $pagedir = 'config/phpinfo';
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array();
|
||||
|
||||
/**
|
||||
* 이 컨트롤러의 메인 모델 이름입니다
|
||||
*/
|
||||
protected $modelname = '';
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* phpinfo 페이지입니다
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_config_phpinfo_index';
|
||||
$this->load->event($eventname);
|
||||
|
||||
$view = array();
|
||||
$view['view'] = array();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before'] = Events::trigger('before', $eventname);
|
||||
|
||||
/**
|
||||
* 어드민 레이아웃을 정의합니다
|
||||
*/
|
||||
$layoutconfig = array('skin' => 'index');
|
||||
$view['layout'] = $this->managelayout->admin($layoutconfig, $this->cbconfig->get_device_view_type());
|
||||
$this->data = $view;
|
||||
$this->layout = false;
|
||||
$this->view = element('view_skin_file', element('layout', $view));
|
||||
}
|
||||
}
|
||||
216
application/controllers/admin/config/Preview.php
Normal file
216
application/controllers/admin/config/Preview.php
Normal file
@@ -0,0 +1,216 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Preview class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 관리자>환경설정>Preview controller 입니다.
|
||||
*/
|
||||
class Preview extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 관리자 페이지 상의 현재 디렉토리입니다
|
||||
* 페이지 이동시 필요한 정보입니다
|
||||
*/
|
||||
public $pagedir = 'config/preview';
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array();
|
||||
|
||||
/**
|
||||
* 이 컨트롤러의 메인 모델 이름입니다
|
||||
*/
|
||||
protected $modelname = '';
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Preview 페이지입니다
|
||||
*/
|
||||
public function preview($pagetype)
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_config_preview_preview';
|
||||
$this->load->event($eventname);
|
||||
|
||||
$view = array();
|
||||
$view['view'] = array();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before'] = Events::trigger('before', $eventname);
|
||||
|
||||
$pagename = array(
|
||||
'main' => '메인페이지',
|
||||
'board' => '게시판',
|
||||
'group' => '게시판그룹',
|
||||
'document' => '일반문서페이지',
|
||||
'faq' => 'FAQ',
|
||||
'register' => '회원가입',
|
||||
'findaccount' => '아이디패스워드찾기',
|
||||
'login' => '로그인',
|
||||
'mypage' => '마이페이지',
|
||||
'currentvisitor' => '현재접속자',
|
||||
'search' => '검색페이지',
|
||||
'tag' => '태그페이지',
|
||||
'note' => '쪽지',
|
||||
'profile' => '프로필',
|
||||
'formmail' => '폼메일',
|
||||
'notification' => '알림페이지',
|
||||
'helptool' => '헬프툴',
|
||||
);
|
||||
|
||||
if ( ! element($pagetype, $pagename)) {
|
||||
alert('잘못된 접근입니다');
|
||||
}
|
||||
|
||||
$previewurl = '';
|
||||
$pageurl = '';
|
||||
$use_sidebar_option = true;
|
||||
|
||||
if ($pagetype === 'main'
|
||||
OR $pagetype === 'mypage'
|
||||
OR $pagetype === 'currentvisitor'
|
||||
OR $pagetype === 'notification'
|
||||
OR $pagetype === 'login'
|
||||
OR $pagetype === 'findaccount') {
|
||||
|
||||
$pageurl = $pagetype;
|
||||
|
||||
}
|
||||
if ($pagetype === 'board') {
|
||||
$this->load->model('Post_model');
|
||||
$where = array('post_del' => 0);
|
||||
$latest = $this->Post_model->get('', '', $where, 1, '', 'post_id', 'desc');
|
||||
$val = element(0, $latest);
|
||||
if (empty($val)) {
|
||||
alert_close('최소 1개 이상의 게시물이 작성된 후에 미리보기가 가능합니다');
|
||||
}
|
||||
$pageurl = 'board_post/post/' . element('post_id', $val);
|
||||
}
|
||||
if ($pagetype === 'group') {
|
||||
$this->load->model('Board_group_model');
|
||||
$val = $this->Board_group_model->get_one();
|
||||
|
||||
if (empty($val)) {
|
||||
alert_close('최소 1개 이상의 그룹이 생성된 후에 미리보기가 가능합니다');
|
||||
}
|
||||
$pageurl = 'group/index/' . element('bgr_key', $val);
|
||||
}
|
||||
if ($pagetype === 'document') {
|
||||
$this->load->model('Document_model');
|
||||
$latest = $this->Document_model->get('', '', '', 1, '', 'doc_id', 'desc');
|
||||
$val = element(0, $latest);
|
||||
if (empty($val)) {
|
||||
alert_close('최소 1개 이상의 일반문서가 작성된 후에 미리보기가 가능합니다');
|
||||
}
|
||||
$pageurl = 'document/index/' . element('doc_key', $val);
|
||||
}
|
||||
if ($pagetype === 'faq') {
|
||||
$this->load->model('Faq_group_model');
|
||||
$latest = $this->Faq_group_model->get('', '', '', 1, '', 'fgr_id', 'desc');
|
||||
$val = element(0, $latest);
|
||||
if (empty($val)) {
|
||||
alert_close('최소 1개 이상의 FAQ가 작성된 후에 미리보기가 가능합니다');
|
||||
}
|
||||
$pageurl = 'faq/index/' . element('fgr_key', $val);
|
||||
}
|
||||
if ($pagetype === 'search') {
|
||||
$pageurl = 'search/?skeyword=검색&';
|
||||
}
|
||||
if ($pagetype === 'tag') {
|
||||
$this->load->model('Post_tag_model');
|
||||
$latest = $this->Post_tag_model->get('', '', '', 1, '', 'pta_id', 'desc');
|
||||
$val = element(0, $latest);
|
||||
if (empty($val)) {
|
||||
alert_close('최소 1개 이상의 태그가 작성된 후에 미리보기가 가능합니다');
|
||||
}
|
||||
$pageurl = 'tags/?tag=' . element('pta_tag', $val) . '&';
|
||||
}
|
||||
if ($pagetype === 'note') {
|
||||
$use_sidebar_option = false;
|
||||
$this->load->model('Note_model');
|
||||
$where = array(
|
||||
'recv_mem_id' => $this->member->item('mem_id'),
|
||||
'nte_type' => 1,
|
||||
);
|
||||
$latest = $this->Note_model->get('', '', $where, 1, '', 'nte_id', 'desc');
|
||||
$val = element(0, $latest);
|
||||
if (empty($val)) {
|
||||
alert_close('최소 1개 이상의 쪽지를 수신한 후에 미리보기가 가능합니다');
|
||||
}
|
||||
$pageurl = 'note/view/recv/' . element('nte_id', $val);
|
||||
}
|
||||
if ($pagetype === 'profile') {
|
||||
$use_sidebar_option = false;
|
||||
$pageurl = 'profile/index/' . $this->member->item('mem_userid');
|
||||
}
|
||||
if ($pagetype === 'formmail') {
|
||||
$use_sidebar_option = false;
|
||||
$pageurl = 'formmail/write/' . $this->member->item('mem_userid');
|
||||
}
|
||||
if ($pagetype === 'helptool') {
|
||||
$use_sidebar_option = false;
|
||||
$pageurl = 'helptool/emoticon';
|
||||
}
|
||||
if ($pagetype === 'register') {
|
||||
$pageurl = 'register/form';
|
||||
}
|
||||
|
||||
$previewurl = admin_url('preview/adminshow/' . $pageurl);
|
||||
$previewurl .= '?layout=' . $this->input->get('layout', null, '') . '&sidebar=' . $this->input->get('sidebar', null, '') . '&skin=' . $this->input->get('skin', null, '') . '&is_mobile=' . $this->input->get('is_mobile', null, '');
|
||||
|
||||
$view['view']['pagetype'] = $pagetype;
|
||||
$view['view']['previewurl'] = $previewurl;
|
||||
$view['view']['use_sidebar_option'] = $use_sidebar_option;
|
||||
$view['view']['pagename'] = element($pagetype, $pagename);
|
||||
$view['view']['layout_option'] = get_skin_name(
|
||||
'_layout',
|
||||
$this->input->get('layout', null, ''),
|
||||
'기본설정따름'
|
||||
);
|
||||
$view['view']['skin_option'] = get_skin_name(
|
||||
$pagetype,
|
||||
$this->input->get('skin', null, ''),
|
||||
'기본설정따름'
|
||||
);
|
||||
$view['view']['mobile_layout_option'] = get_skin_name(
|
||||
'_layout',
|
||||
$this->input->get('mobile_layout', null, ''),
|
||||
'기본설정따름'
|
||||
);
|
||||
$view['view']['mobile_skin_option'] = get_skin_name(
|
||||
$pagetype,
|
||||
$this->input->get('mobile_skin', null, ''),
|
||||
'기본설정따름'
|
||||
);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
|
||||
|
||||
/**
|
||||
* 어드민 레이아웃을 정의합니다
|
||||
*/
|
||||
$layoutconfig = array('layout' => 'layout_popup', '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));
|
||||
}
|
||||
}
|
||||
416
application/controllers/admin/config/Rssconfig.php
Normal file
416
application/controllers/admin/config/Rssconfig.php
Normal file
@@ -0,0 +1,416 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Rssconfig class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 관리자>환경설정>RSS 피드 controller 입니다.
|
||||
*/
|
||||
class Rssconfig extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 관리자 페이지 상의 현재 디렉토리입니다
|
||||
* 페이지 이동시 필요한 정보입니다
|
||||
*/
|
||||
public $pagedir = 'config/rssconfig';
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array('Config', 'Board');
|
||||
|
||||
/**
|
||||
* 이 컨트롤러의 메인 모델 이름입니다
|
||||
*/
|
||||
protected $modelname = 'Config_model';
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* 환경설정>RSS 피드 페이지입니다
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_config_rssconfig_index';
|
||||
$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' => 'is_submit',
|
||||
'label' => '전송',
|
||||
'rules' => 'trim|numeric',
|
||||
),
|
||||
array(
|
||||
'field' => 'use_total_rss_feed',
|
||||
'label' => '통합 RSS 피드사용',
|
||||
'rules' => 'trim|numeric',
|
||||
),
|
||||
array(
|
||||
'field' => 'total_rss_feed_content',
|
||||
'label' => '통합 RSS 내용공개',
|
||||
'rules' => 'trim|numeric',
|
||||
),
|
||||
array(
|
||||
'field' => 'total_rss_feed_title',
|
||||
'label' => '통합 RSS 제목',
|
||||
'rules' => 'trim',
|
||||
),
|
||||
array(
|
||||
'field' => 'total_rss_feed_description',
|
||||
'label' => '통합 RSS 설명',
|
||||
'rules' => 'trim',
|
||||
),
|
||||
array(
|
||||
'field' => 'total_rss_feed_copyright',
|
||||
'label' => 'RSS 표시 저작권',
|
||||
'rules' => 'trim',
|
||||
),
|
||||
array(
|
||||
'field' => 'total_rss_feed_count',
|
||||
'label' => 'RSS 출력 게시물수',
|
||||
'rules' => 'trim|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);
|
||||
|
||||
$array = array(
|
||||
'use_total_rss_feed', 'total_rss_feed_content', 'total_rss_feed_title',
|
||||
'total_rss_feed_description', 'total_rss_feed_copyright', 'total_rss_feed_count'
|
||||
);
|
||||
foreach ($array as $value) {
|
||||
$savedata[$value] = $this->input->post($value, null, '');
|
||||
}
|
||||
$post_brd_id = $this->input->post('brd_id');
|
||||
$boardlist = $this->Board_model->get_board_list();
|
||||
if ($boardlist && is_array($boardlist)) {
|
||||
$this->load->model('Board_meta_model');
|
||||
foreach ($boardlist as $key => $val) {
|
||||
if (element(element('brd_id', $val), $post_brd_id)) {
|
||||
$metadata = array('use_rss_total_feed' => '1');
|
||||
} else {
|
||||
$metadata = array('use_rss_total_feed' => '');
|
||||
}
|
||||
$this->Board_meta_model->save(element('brd_id', $val), $metadata);
|
||||
}
|
||||
}
|
||||
|
||||
$this->Config_model->save($savedata);
|
||||
$view['view']['alert_message'] = 'RSS 피드설정이 저장되었습니다';
|
||||
}
|
||||
|
||||
$getdata = $this->Config_model->get_all_meta();
|
||||
$view['view']['data'] = $getdata;
|
||||
|
||||
$boardlist = $this->Board_model->get_board_list();
|
||||
if ($boardlist && is_array($boardlist)) {
|
||||
$this->load->model('Board_meta_model');
|
||||
foreach ($boardlist as $key => $val) {
|
||||
$whereboard = array(
|
||||
'brd_id' => element('brd_id', $val),
|
||||
'bmt_key' => 'use_rss_total_feed',
|
||||
);
|
||||
$userss = $this->Board_meta_model->get_one('', '', $whereboard);
|
||||
$boardlist[$key]['userss'] = element('bmt_value', $userss);
|
||||
}
|
||||
}
|
||||
$view['view']['boardlist'] = $boardlist;
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$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));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 환경설정>사이트맵 페이지입니다
|
||||
*/
|
||||
public function sitemap()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_config_rssconfig_sitemap';
|
||||
$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' => 'is_submit',
|
||||
'label' => '전송',
|
||||
'rules' => 'trim|numeric',
|
||||
),
|
||||
array(
|
||||
'field' => 'use_sitemap',
|
||||
'label' => '사이트맵 사용',
|
||||
'rules' => 'trim|numeric',
|
||||
),
|
||||
array(
|
||||
'field' => 'sitemap_count',
|
||||
'label' => '사이트맵 출력 게시물수',
|
||||
'rules' => 'trim|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);
|
||||
|
||||
$array = array(
|
||||
'use_sitemap', 'sitemap_count'
|
||||
);
|
||||
foreach ($array as $value) {
|
||||
$savedata[$value] = $this->input->post($value, null, '');
|
||||
}
|
||||
$post_brd_id = $this->input->post('brd_id');
|
||||
$boardlist = $this->Board_model->get_board_list();
|
||||
if ($boardlist && is_array($boardlist)) {
|
||||
$this->load->model('Board_meta_model');
|
||||
foreach ($boardlist as $key => $val) {
|
||||
if (element(element('brd_id', $val), $post_brd_id)) {
|
||||
$metadata = array('use_sitemap' => '1');
|
||||
} else {
|
||||
$metadata = array('use_sitemap' => '');
|
||||
}
|
||||
$this->Board_meta_model->save(element('brd_id', $val), $metadata);
|
||||
}
|
||||
}
|
||||
|
||||
$this->Config_model->save($savedata);
|
||||
$view['view']['alert_message'] = '사이트맵 설정이 저장되었습니다';
|
||||
}
|
||||
|
||||
$getdata = $this->Config_model->get_all_meta();
|
||||
if ( ! element('sitemap_count', $getdata)) {
|
||||
$getdata['sitemap_count'] = 100;
|
||||
}
|
||||
$view['view']['data'] = $getdata;
|
||||
|
||||
$boardlist = $this->Board_model->get_board_list();
|
||||
if ($boardlist && is_array($boardlist)) {
|
||||
$this->load->model('Board_meta_model');
|
||||
foreach ($boardlist as $key => $val) {
|
||||
$whereboard = array(
|
||||
'brd_id' => element('brd_id', $val),
|
||||
'bmt_key' => 'use_sitemap',
|
||||
);
|
||||
$usesitemap = $this->Board_meta_model->get_one('', '', $whereboard);
|
||||
$boardlist[$key]['usesitemap'] = element('bmt_value', $usesitemap);
|
||||
}
|
||||
}
|
||||
$view['view']['boardlist'] = $boardlist;
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
|
||||
|
||||
/**
|
||||
* 어드민 레이아웃을 정의합니다
|
||||
*/
|
||||
$layoutconfig = array('layout' => 'layout', 'skin' => 'sitemap');
|
||||
$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));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 환경설정>네이버 블로그 글쓰기 관리 페이지입니다
|
||||
*/
|
||||
public function naverblog()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_config_rssconfig_naverblog';
|
||||
$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' => 'is_submit',
|
||||
'label' => '전송',
|
||||
'rules' => 'trim|numeric',
|
||||
),
|
||||
array(
|
||||
'field' => 'use_naver_blog_post',
|
||||
'label' => '네이버 블로그 자동 글쓰기 기능 사용',
|
||||
'rules' => 'trim|numeric',
|
||||
),
|
||||
array(
|
||||
'field' => 'naver_blog_userid',
|
||||
'label' => '네이버 블로그 회원 아이디',
|
||||
'rules' => 'trim',
|
||||
),
|
||||
array(
|
||||
'field' => 'naver_blog_api_key',
|
||||
'label' => '네이버 블로그 글쓰기 API',
|
||||
'rules' => 'trim',
|
||||
),
|
||||
);
|
||||
$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);
|
||||
|
||||
$array = array(
|
||||
'use_naver_blog_post', 'naver_blog_userid', 'naver_blog_api_key'
|
||||
);
|
||||
foreach ($array as $value) {
|
||||
$savedata[$value] = $this->input->post($value, null, '');
|
||||
}
|
||||
$post_brd_id = $this->input->post('brd_id');
|
||||
$boardlist = $this->Board_model->get_board_list();
|
||||
if ($boardlist && is_array($boardlist)) {
|
||||
$this->load->model('Board_meta_model');
|
||||
foreach ($boardlist as $key => $val) {
|
||||
if (element(element('brd_id', $val), $post_brd_id)) {
|
||||
$metadata = array('use_naver_blog_post' => '1');
|
||||
} else {
|
||||
$metadata = array('use_naver_blog_post' => '');
|
||||
}
|
||||
$this->Board_meta_model->save(element('brd_id', $val), $metadata);
|
||||
}
|
||||
}
|
||||
|
||||
$this->Config_model->save($savedata);
|
||||
$view['view']['alert_message'] = '네이버 블로그 자동 글쓰기 설정이 저장되었습니다';
|
||||
}
|
||||
|
||||
$getdata = $this->Config_model->get_all_meta();
|
||||
$view['view']['data'] = $getdata;
|
||||
|
||||
$boardlist = $this->Board_model->get_board_list();
|
||||
if ($boardlist && is_array($boardlist)) {
|
||||
$this->load->model('Board_meta_model');
|
||||
foreach ($boardlist as $key => $val) {
|
||||
$whereboard = array(
|
||||
'brd_id' => element('brd_id', $val),
|
||||
'bmt_key' => 'use_naver_blog_post',
|
||||
);
|
||||
$usenaverblog = $this->Board_meta_model->get_one('', '', $whereboard);
|
||||
$boardlist[$key]['usenaverblog'] = element('bmt_value', $usenaverblog);
|
||||
}
|
||||
}
|
||||
$view['view']['boardlist'] = $boardlist;
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
|
||||
|
||||
/**
|
||||
* 어드민 레이아웃을 정의합니다
|
||||
*/
|
||||
$layoutconfig = array('layout' => 'layout', 'skin' => 'naverblog');
|
||||
$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));
|
||||
}
|
||||
}
|
||||
391
application/controllers/admin/config/Scheduler.php
Normal file
391
application/controllers/admin/config/Scheduler.php
Normal file
@@ -0,0 +1,391 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Scheduler class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 관리자>환경설정>스케쥴러 관리 controller 입니다.
|
||||
*/
|
||||
class Scheduler extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 관리자 페이지 상의 현재 디렉토리입니다
|
||||
* 페이지 이동시 필요한 정보입니다
|
||||
*/
|
||||
public $pagedir = 'config/scheduler';
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array('Config');
|
||||
|
||||
/**
|
||||
* 이 컨트롤러의 메인 모델 이름입니다
|
||||
*/
|
||||
protected $modelname = 'Config_model';
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 스케쥴러 관리 페이지입니다
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_config_scheduler_index';
|
||||
$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' => 's',
|
||||
'label' => '스케쥴러',
|
||||
'rules' => 'trim',
|
||||
),
|
||||
);
|
||||
$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);
|
||||
|
||||
$updatedata = $this->input->post();
|
||||
|
||||
if ( ! isset($updatedata['library_name']) OR ! is_array($updatedata['library_name'])) {
|
||||
$savedata = array(
|
||||
'scheduler' => '',
|
||||
);
|
||||
$this->Config_model->save($savedata);
|
||||
$view['view']['alert_message'] = '정상적으로 저장되었습니다';
|
||||
} else {
|
||||
$array_count_values = array_count_values($updatedata['library_name']);
|
||||
$fail = false;
|
||||
if ($fail === false) {
|
||||
foreach ($array_count_values as $akey => $aval) {
|
||||
if ($aval > 1) {
|
||||
$view['view']['warning_message'] = $akey . ' 값이 ' . $aval . ' 회 중복 입력되었습니다. 라이브러리명이 중복되지 않게 입력해주세요';
|
||||
$fail = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($fail === false) {
|
||||
foreach (element('library_name', $updatedata) as $fkey => $fval) {
|
||||
if (empty($fval)) {
|
||||
$view['view']['warning_message'] = '비어있는 라이브러리명이 있습니다. 라이브러리 값을 빠뜨리지 말고 입력해주세요';
|
||||
$fail = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($fail === false) {
|
||||
$order = 0;
|
||||
$update = array();
|
||||
|
||||
$alldata = $this->Config_model->get_all_meta();
|
||||
|
||||
$origindata = json_decode(element('scheduler', $alldata), true);
|
||||
|
||||
foreach (element('key', $updatedata) as $key => $value) {
|
||||
|
||||
if ($value) {
|
||||
$update[$value] = array(
|
||||
'library_name' => element($order, element('library_name', $updatedata)),
|
||||
'interval_field_name' => element($value, element('interval_field_name', $updatedata)),
|
||||
'lasttime' => element('lasttime', element(element($order, element('library_name', $updatedata)), $origindata)),
|
||||
|
||||
);
|
||||
} else {
|
||||
$update[$updatedata['library_name'][$order]] = array(
|
||||
'library_name' => element($order, element('library_name', $updatedata)),
|
||||
'interval_field_name' => element($key, element('interval_field_name', $updatedata)),
|
||||
);
|
||||
}
|
||||
$order++;
|
||||
}
|
||||
|
||||
$savedata = array(
|
||||
'scheduler' => json_encode($update),
|
||||
);
|
||||
$this->Config_model->save($savedata);
|
||||
$view['view']['alert_message'] = '정상적으로 저장되었습니다';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$getdata = $this->Config_model->get_all_meta();
|
||||
|
||||
$getdata['result'] = json_decode(element('scheduler', $getdata), true);
|
||||
$getdata['scheduler_interval'] = json_decode(element('scheduler_interval', $getdata), true);
|
||||
|
||||
if ( ! element('scheduler_interval', $getdata) ) {
|
||||
alert('스케쥴 주기명을 먼저 생성하신 후에 스케쥴러 등록이 가능합니다. 스케쥴 주기명 생성 페이지로 이동합니다', admin_url($this->pagedir . '/interval'));
|
||||
}
|
||||
|
||||
if ($getdata['result'] && is_array($getdata['result'])) {
|
||||
foreach ($getdata['result'] as $key => $value) {
|
||||
$getdata['result'][$key]['class_exists'] = '';
|
||||
if (file_exists(APPPATH . 'libraries/Scheduler/' . $key . '.php')) {
|
||||
$this->load->library('Scheduler/' . $key);
|
||||
if (class_exists($key)) {
|
||||
$getdata['result'][$key]['class_exists'] = '1';
|
||||
}
|
||||
}
|
||||
$getdata['result'][$key]['lastexecutetime'] = element('lasttime', $value) ? cdate("Y-m-d H:i:s", element('lasttime', $value)) : '-';
|
||||
$getdata['result'][$key]['nextexecutetime'] = '-';
|
||||
if (
|
||||
element('lasttime', $value)
|
||||
&& ($scheduler_interval = element('scheduler_interval', $getdata))
|
||||
&& ($field_name = element(element('interval_field_name', $value), $scheduler_interval))
|
||||
&& element('interval', $field_name)
|
||||
) {
|
||||
$nexttime = element('lasttime', $value) + element('interval', $field_name);
|
||||
$getdata['result'][$key]['nextexecutetime'] = $nexttime ? cdate("Y-m-d H:i:s", $nexttime) : '-';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$view['view']['data'] = $getdata;
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$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));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 스케쥴러 주기 관리 페이지입니다
|
||||
*/
|
||||
public function interval()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_config_scheduler_interval';
|
||||
$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' => 's',
|
||||
'label' => '스케쥴러',
|
||||
'rules' => 'trim',
|
||||
),
|
||||
);
|
||||
$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);
|
||||
|
||||
$updatedata = $this->input->post();
|
||||
|
||||
if ( ! isset($updatedata['field_name']) OR ! is_array($updatedata['field_name'])) {
|
||||
$savedata = array(
|
||||
'scheduler_interval' => '',
|
||||
);
|
||||
$this->Config_model->save($savedata);
|
||||
$view['view']['alert_message'] = '정상적으로 저장되었습니다';
|
||||
} else {
|
||||
$array_count_values = array_count_values($updatedata['field_name']);
|
||||
$fail = false;
|
||||
if ($fail === false) {
|
||||
foreach ($array_count_values as $akey => $aval) {
|
||||
if ($aval > 1) {
|
||||
$view['view']['warning_message'] = $akey . ' 값이 ' . $aval . ' 회 중복 입력되었습니다. ID 값이 중복되지 않게 입력해주세요';
|
||||
$fail = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($fail === false) {
|
||||
foreach (element('field_name', $updatedata) as $fkey => $fval) {
|
||||
if (empty($fval)) {
|
||||
$view['view']['warning_message'] = '비어있는 ID 값이 있습니다. ID 값을 빠뜨리지 말고 입력해주세요';
|
||||
$fail = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($fail === false) {
|
||||
foreach (element('display_name', $updatedata) as $fkey => $fval) {
|
||||
if (empty($fval)) {
|
||||
$view['view']['warning_message'] = '비어있는 주기명이 있습니다. 입력항목제목 값을 빠뜨리지 말고 입력해주세요';
|
||||
$fail = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($fail === false) {
|
||||
$order = 0;
|
||||
$update = array();
|
||||
|
||||
foreach (element('key', $updatedata) as $key => $value) {
|
||||
if ($value) {
|
||||
$update[$value] = array(
|
||||
'field_name' => element($order, element('field_name', $updatedata)),
|
||||
'interval' => element($order, element('interval', $updatedata)),
|
||||
'display_name' => element($order, element('display_name', $updatedata)),
|
||||
);
|
||||
} else {
|
||||
$update[$updatedata['field_name'][$order]] = array(
|
||||
'field_name' => element($order, element('field_name', $updatedata)),
|
||||
'interval' => element($order, element('interval', $updatedata)),
|
||||
'display_name' => element($order, element('display_name', $updatedata)),
|
||||
);
|
||||
}
|
||||
$order++;
|
||||
}
|
||||
|
||||
$savedata = array(
|
||||
'scheduler_interval' => json_encode($update),
|
||||
);
|
||||
$this->Config_model->save($savedata);
|
||||
$view['view']['alert_message'] = '정상적으로 저장되었습니다';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$getdata = $this->Config_model->get_all_meta();
|
||||
|
||||
$getdata['scheduler'] = json_decode(element('scheduler', $getdata), true);
|
||||
$getdata['result'] = json_decode(element('scheduler_interval', $getdata), true);
|
||||
|
||||
if ($getdata['scheduler'] && is_array($getdata['scheduler'])) {
|
||||
foreach ($getdata['scheduler'] as $key => $value) {
|
||||
if ( ! isset($getdata['result'][element('interval_field_name', $value)]['registered_scheduler'])) {
|
||||
$getdata['result'][element('interval_field_name', $value)]['registered_scheduler'] = 0;
|
||||
}
|
||||
$getdata['result'][element('interval_field_name', $value)]['registered_scheduler']++;
|
||||
}
|
||||
}
|
||||
|
||||
$view['view']['data'] = $getdata;
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
|
||||
|
||||
/**
|
||||
* 어드민 레이아웃을 정의합니다
|
||||
*/
|
||||
$layoutconfig = array('layout' => 'layout', 'skin' => 'interval');
|
||||
$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));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 스케쥴러 실행 페이지입니다
|
||||
*/
|
||||
public function execute($libraryname)
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_config_scheduler_execute';
|
||||
$this->load->event($eventname);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('before', $eventname);
|
||||
|
||||
if (file_exists(APPPATH . 'libraries/Scheduler/' . $libraryname . '.php')) {
|
||||
$this->load->library('Scheduler/' . $libraryname);
|
||||
$s = new $libraryname();
|
||||
if (method_exists($s, 'scheduler')) {
|
||||
$s->scheduler();
|
||||
|
||||
$scheduler_data = $this->cbconfig->item('scheduler');
|
||||
$scheduler_array = json_decode($scheduler_data, true);
|
||||
$interval_data = $this->cbconfig->item('scheduler_interval');
|
||||
$interval_array = json_decode($interval_data, true);
|
||||
|
||||
$scheduler_array[$libraryname]['lasttime'] = ctimestamp();
|
||||
|
||||
$savedata['scheduler'] = json_encode($scheduler_array);
|
||||
$this->load->model('Config_model');
|
||||
$this->Config_model->save($savedata);
|
||||
exit(json_encode(array('success' => 'ok', 'message' => $libraryname . ' 라이브러리가 실행되었습니다.')));
|
||||
} else {
|
||||
exit(json_encode(array('success' => 'fail', 'message' => $libraryname . ' 클래스 안에 scheduler 메소드가 존재하지 않습니다.')));
|
||||
}
|
||||
} else {
|
||||
exit(json_encode(array('success' => 'fail', 'message' => $libraryname . ' 라이브러리가 존재하지 않습니다.')));
|
||||
}
|
||||
}
|
||||
}
|
||||
135
application/controllers/admin/config/Testemail.php
Normal file
135
application/controllers/admin/config/Testemail.php
Normal file
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Testemail class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 관리자>환경설정>메일발송테스트 controller 입니다.
|
||||
*/
|
||||
class Testemail extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 관리자 페이지 상의 현재 디렉토리입니다
|
||||
* 페이지 이동시 필요한 정보입니다
|
||||
*/
|
||||
public $pagedir = 'config/testemail';
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array();
|
||||
|
||||
/**
|
||||
* 이 컨트롤러의 메인 모델 이름입니다
|
||||
*/
|
||||
protected $modelname = '';
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/**
|
||||
* 라이브러리를 로딩합니다
|
||||
*/
|
||||
$this->load->library(array('querystring'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 테스트 이메일을 보내는 페이지입니다
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_config_testemail_index';
|
||||
$this->load->event($eventname);
|
||||
|
||||
$view = array();
|
||||
$view['view'] = array();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before'] = Events::trigger('before', $eventname);
|
||||
|
||||
$getdata['webmaster_email'] = $this->cbconfig->item('webmaster_email');
|
||||
$getdata['webmaster_name'] = $this->cbconfig->item('webmaster_name');
|
||||
$getdata['site_title'] = $this->cbconfig->item('site_title');
|
||||
|
||||
/**
|
||||
* Validation 라이브러리를 가져옵니다
|
||||
*/
|
||||
$this->load->library('form_validation');
|
||||
|
||||
/**
|
||||
* 전송된 데이터의 유효성을 체크합니다
|
||||
*/
|
||||
$config = array(
|
||||
array(
|
||||
'field' => 'recv_email',
|
||||
'label' => '받는이 이메일 주소',
|
||||
'rules' => 'trim|required|valid_email',
|
||||
),
|
||||
);
|
||||
$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);
|
||||
|
||||
$this->load->library('email');
|
||||
$this->email->from(element('webmaster_email', $getdata), element('webmaster_name', $getdata));
|
||||
$this->email->to($this->input->post('recv_email'));
|
||||
|
||||
$this->email->subject('이메일 발송 테스트입니다');
|
||||
$emailform['emailform'] = $getdata;
|
||||
$message = $this->load->view('admin/' . ADMIN_SKIN . '/' . $this->pagedir . '/email_form', $emailform, true);
|
||||
$this->email->message($message);
|
||||
|
||||
if ($this->email->send() === false) {
|
||||
$view['view']['alert_message'] = '이메일을 발송하지 못하였습니다. 메일 설정을 확인하여주세요';
|
||||
} else {
|
||||
$view['view']['alert_message'] = '이메일을 발송하였습니다';
|
||||
}
|
||||
//echo $this->email->print_debugger();
|
||||
|
||||
}
|
||||
|
||||
$view['view']['data'] = $getdata;
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$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));
|
||||
}
|
||||
}
|
||||
1077
application/controllers/admin/member/Dormant.php
Normal file
1077
application/controllers/admin/member/Dormant.php
Normal file
File diff suppressed because it is too large
Load Diff
538
application/controllers/admin/member/Loginlog.php
Normal file
538
application/controllers/admin/member/Loginlog.php
Normal file
@@ -0,0 +1,538 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Loginlog class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 관리자>회원설정>로그인현황 controller 입니다.
|
||||
*/
|
||||
class Loginlog extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 관리자 페이지 상의 현재 디렉토리입니다
|
||||
* 페이지 이동시 필요한 정보입니다
|
||||
*/
|
||||
public $pagedir = 'member/loginlog';
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array('Member_login_log');
|
||||
|
||||
/**
|
||||
* 이 컨트롤러의 메인 모델 이름입니다
|
||||
*/
|
||||
protected $modelname = 'Member_login_log_model';
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/**
|
||||
* 라이브러리를 로딩합니다
|
||||
*/
|
||||
$this->load->library(array('pagination', 'querystring'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록을 가져오는 메소드입니다
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_member_loginlog_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;
|
||||
$findex = $this->input->get('findex') ? $this->input->get('findex') : $this->{$this->modelname}->primary_key;
|
||||
$forder = $this->input->get('forder', null, 'desc');
|
||||
$sfield = $this->input->get('sfield', null, '');
|
||||
$skeyword = $this->input->get('skeyword', null, '');
|
||||
|
||||
$per_page = admin_listnum();
|
||||
$offset = ($page - 1) * $per_page;
|
||||
|
||||
/**
|
||||
* 게시판 목록에 필요한 정보를 가져옵니다.
|
||||
*/
|
||||
$this->{$this->modelname}->allow_search_field = array('mll_id', 'mll_userid', 'mll_success', 'member_login_log.mem_id', 'mll_datetime', 'mll_ip', 'mll_reason', 'mll_log_agent', 'mll_url', 'mll_referer'); // 검색이 가능한 필드
|
||||
$this->{$this->modelname}->search_field_equal = array('mll_id', 'member_login_log.mem_id'); // 검색중 like 가 아닌 = 검색을 하는 필드
|
||||
$this->{$this->modelname}->allow_order_field = array('mll_id'); // 정렬이 가능한 필드
|
||||
$result = $this->{$this->modelname}
|
||||
->get_admin_list($per_page, $offset, '', '', $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('mll_useragent', $val)) {
|
||||
$userAgent = get_useragent_info(element('mll_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('mll_datetime' => '날짜', 'mll_ip' => 'IP', 'mll_reason' => '이유');
|
||||
$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']['list_delete_url'] = admin_url($this->pagedir . '/listdelete/?' . $param->output());
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$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));
|
||||
}
|
||||
|
||||
/**
|
||||
* 로그인 성공 기록을 그래프 형식으로 보는 페이지입니다
|
||||
*/
|
||||
public function graph($export = '')
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_member_loginlog_graph';
|
||||
$this->load->event($eventname);
|
||||
|
||||
$view = array();
|
||||
$view['view'] = array();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before'] = Events::trigger('before', $eventname);
|
||||
|
||||
$param =& $this->querystring;
|
||||
$datetype = $this->input->get('datetype', null, 'd');
|
||||
if ($datetype !== 'm' && $datetype !== 'y') {
|
||||
$datetype = 'd';
|
||||
}
|
||||
$start_date = $this->input->get('start_date') ? $this->input->get('start_date') : cdate('Y-m-01');
|
||||
$end_date = $this->input->get('end_date') ? $this->input->get('end_date') : cdate('Y-m-d');
|
||||
if ($datetype === 'y' OR $datetype === 'm') {
|
||||
$start_year = substr($start_date, 0, 4);
|
||||
$end_year = substr($end_date, 0, 4);
|
||||
}
|
||||
if ($datetype === 'm') {
|
||||
$start_month = substr($start_date, 5, 2);
|
||||
$end_month = substr($end_date, 5, 2);
|
||||
$start_year_month = $start_year * 12 + $start_month;
|
||||
$end_year_month = $end_year * 12 + $end_month;
|
||||
}
|
||||
$orderby = (strtolower($this->input->get('orderby')) === 'desc') ? 'desc' : 'asc';
|
||||
|
||||
$result = $this->{$this->modelname}->get_login_success_count($datetype, $start_date, $end_date, $orderby);
|
||||
$sum_count = 0;
|
||||
$arr = array();
|
||||
$max = 0;
|
||||
|
||||
if ($result && is_array($result)) {
|
||||
foreach ($result as $key => $value) {
|
||||
$s = element('day', $value);
|
||||
if ( ! isset($arr[$s])) {
|
||||
$arr[$s] = 0;
|
||||
}
|
||||
$arr[$s] += element('cnt', $value);
|
||||
|
||||
if ($arr[$s] > $max) {
|
||||
$max = $arr[$s];
|
||||
}
|
||||
$sum_count += element('cnt', $value);
|
||||
}
|
||||
}
|
||||
|
||||
$result = array();
|
||||
$i = 0;
|
||||
$save_count = -1;
|
||||
$tot_count = 0;
|
||||
|
||||
if (count($arr)) {
|
||||
foreach ($arr as $key => $value) {
|
||||
$count = (int) $arr[$key];
|
||||
$result[$key]['count'] = $count;
|
||||
$i++;
|
||||
if ($save_count !== $count) {
|
||||
$no = $i;
|
||||
$save_count = $count;
|
||||
}
|
||||
$result[$key]['no'] = $no;
|
||||
|
||||
$result[$key]['key'] = $key;
|
||||
$rate = ($count / $sum_count * 100);
|
||||
$result[$key]['rate'] = $rate;
|
||||
$s_rate = number_format($rate, 1);
|
||||
$result[$key]['s_rate'] = $s_rate;
|
||||
|
||||
$bar = (int)($count / $max * 100);
|
||||
$result[$key]['bar'] = $bar;
|
||||
}
|
||||
$view['view']['max_value'] = $max;
|
||||
$view['view']['sum_count'] = $sum_count;
|
||||
}
|
||||
|
||||
if ($datetype === 'y') {
|
||||
for ($i = $start_year; $i <= $end_year; $i++) {
|
||||
if( ! isset($result[$i])) $result[$i] = '';
|
||||
}
|
||||
} elseif ($datetype === 'm') {
|
||||
for ($i = $start_year_month; $i <= $end_year_month; $i++) {
|
||||
$year = floor($i / 12);
|
||||
if ($year * 12 == $i) $year--;
|
||||
$month = sprintf("%02d", ($i - ($year * 12)));
|
||||
$date = $year . '-' . $month;
|
||||
if( ! isset($result[$date])) $result[$date] = '';
|
||||
}
|
||||
} elseif ($datetype === 'd') {
|
||||
$date = $start_date;
|
||||
while ($date <= $end_date) {
|
||||
if( ! isset($result[$date])) $result[$date] = '';
|
||||
$date = cdate('Y-m-d', strtotime($date) + 86400);
|
||||
}
|
||||
}
|
||||
|
||||
if ($orderby === 'desc') {
|
||||
krsort($result);
|
||||
} else {
|
||||
ksort($result);
|
||||
}
|
||||
|
||||
$view['view']['list'] = $result;
|
||||
|
||||
$view['view']['start_date'] = $start_date;
|
||||
$view['view']['end_date'] = $end_date;
|
||||
$view['view']['datetype'] = $datetype;
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
|
||||
|
||||
if ($export === 'excel') {
|
||||
|
||||
header('Content-type: application/vnd.ms-excel');
|
||||
header('Content-Disposition: attachment; filename=로그인성공기록_' . cdate('Y_m_d') . '.xls');
|
||||
echo $this->load->view('admin/' . ADMIN_SKIN . '/' . $this->pagedir . '/graph_excel', $view, true);
|
||||
|
||||
} else {
|
||||
/**
|
||||
* 어드민 레이아웃을 정의합니다
|
||||
*/
|
||||
$layoutconfig = array('layout' => 'layout', 'skin' => 'graph');
|
||||
$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));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 로그인 실패 기록을 그래프 형식으로 보는 페이지입니다
|
||||
*/
|
||||
public function graph_fail($export = '')
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_member_loginlog_graph_fail';
|
||||
$this->load->event($eventname);
|
||||
|
||||
$view = array();
|
||||
$view['view'] = array();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before'] = Events::trigger('before', $eventname);
|
||||
|
||||
$param =& $this->querystring;
|
||||
$datetype = $this->input->get('datetype', null, 'd');
|
||||
if ($datetype !== 'm' && $datetype !== 'y') {
|
||||
$datetype = 'd';
|
||||
}
|
||||
$start_date = $this->input->get('start_date') ? $this->input->get('start_date') : cdate('Y-m-01');
|
||||
$end_date = $this->input->get('end_date') ? $this->input->get('end_date') : cdate('Y-m-d');
|
||||
if ($datetype === 'y' OR $datetype === 'm') {
|
||||
$start_year = substr($start_date, 0, 4);
|
||||
$end_year = substr($end_date, 0, 4);
|
||||
}
|
||||
if ($datetype === 'm') {
|
||||
$start_month = substr($start_date, 5, 2);
|
||||
$end_month = substr($end_date, 5, 2);
|
||||
$start_year_month = $start_year * 12 + $start_month;
|
||||
$end_year_month = $end_year * 12 + $end_month;
|
||||
}
|
||||
$orderby = (strtolower($this->input->get('orderby')) === 'desc') ? 'desc' : 'asc';
|
||||
|
||||
$result = $this->{$this->modelname}->get_login_fail_count($datetype, $start_date, $end_date, $orderby);
|
||||
$sum_count = 0;
|
||||
$arr = array();
|
||||
$max = 0;
|
||||
|
||||
if ($result && is_array($result)) {
|
||||
foreach ($result as $key => $value) {
|
||||
$s = element('day', $value);
|
||||
if ( ! isset($arr[$s])) {
|
||||
$arr[$s] = 0;
|
||||
}
|
||||
$arr[$s] += element('cnt', $value);
|
||||
|
||||
if ($arr[$s] > $max) {
|
||||
$max = $arr[$s];
|
||||
}
|
||||
$sum_count += element('cnt', $value);
|
||||
}
|
||||
}
|
||||
|
||||
$result = array();
|
||||
$i = 0;
|
||||
$save_count = -1;
|
||||
$tot_count = 0;
|
||||
|
||||
if (count($arr)) {
|
||||
foreach ($arr as $key => $value) {
|
||||
$count = (int) $arr[$key];
|
||||
$result[$key]['count'] = $count;
|
||||
$i++;
|
||||
if ($save_count !== $count) {
|
||||
$no = $i;
|
||||
$save_count = $count;
|
||||
}
|
||||
$result[$key]['no'] = $no;
|
||||
|
||||
$result[$key]['key'] = $key;
|
||||
$rate = ($count / $sum_count * 100);
|
||||
$result[$key]['rate'] = $rate;
|
||||
$s_rate = number_format($rate, 1);
|
||||
$result[$key]['s_rate'] = $s_rate;
|
||||
|
||||
$bar = (int)($count / $max * 100);
|
||||
$result[$key]['bar'] = $bar;
|
||||
}
|
||||
$view['view']['max_value'] = $max;
|
||||
$view['view']['sum_count'] = $sum_count;
|
||||
}
|
||||
|
||||
if ($datetype === 'y') {
|
||||
for ($i = $start_year; $i <= $end_year; $i++) {
|
||||
if( ! isset($result[$i])) $result[$i] = '';
|
||||
}
|
||||
} elseif ($datetype === 'm') {
|
||||
for ($i = $start_year_month; $i <= $end_year_month; $i++) {
|
||||
$year = floor($i / 12);
|
||||
if ($year * 12 == $i) $year--;
|
||||
$month = sprintf("%02d", ($i - ($year * 12)));
|
||||
$date = $year . '-' . $month;
|
||||
if( ! isset($result[$date])) $result[$date] = '';
|
||||
}
|
||||
} elseif ($datetype === 'd') {
|
||||
$date = $start_date;
|
||||
while ($date <= $end_date) {
|
||||
if( ! isset($result[$date])) $result[$date] = '';
|
||||
$date = cdate('Y-m-d', strtotime($date) + 86400);
|
||||
}
|
||||
}
|
||||
|
||||
if ($orderby === 'desc') {
|
||||
krsort($result);
|
||||
} else {
|
||||
ksort($result);
|
||||
}
|
||||
|
||||
$view['view']['list'] = $result;
|
||||
|
||||
$view['view']['start_date'] = $start_date;
|
||||
$view['view']['end_date'] = $end_date;
|
||||
$view['view']['datetype'] = $datetype;
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
|
||||
|
||||
if ($export === 'excel') {
|
||||
|
||||
header('Content-type: application/vnd.ms-excel');
|
||||
header('Content-Disposition: attachment; filename=로그인실패기록_' . cdate('Y_m_d') . '.xls');
|
||||
echo $this->load->view('admin/' . ADMIN_SKIN . '/' . $this->pagedir . '/graph_fail_excel', $view, true);
|
||||
|
||||
} else {
|
||||
/**
|
||||
* 어드민 레이아웃을 정의합니다
|
||||
*/
|
||||
$layoutconfig = array('layout' => 'layout', 'skin' => 'graph_fail');
|
||||
$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));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록 페이지에서 선택삭제를 하는 경우 실행되는 메소드입니다
|
||||
*/
|
||||
public function listdelete()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_member_loginlog_listdelete';
|
||||
$this->load->event($eventname);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('before', $eventname);
|
||||
|
||||
/**
|
||||
* 체크한 게시물의 삭제를 실행합니다
|
||||
*/
|
||||
if ($this->input->post('chk') && is_array($this->input->post('chk'))) {
|
||||
foreach ($this->input->post('chk') as $val) {
|
||||
if ($val) {
|
||||
$this->{$this->modelname}->delete($val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after', $eventname);
|
||||
|
||||
/**
|
||||
* 삭제가 끝난 후 목록페이지로 이동합니다
|
||||
*/
|
||||
$this->session->set_flashdata(
|
||||
'message',
|
||||
'정상적으로 삭제되었습니다'
|
||||
);
|
||||
$param =& $this->querystring;
|
||||
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
|
||||
|
||||
redirect($redirecturl);
|
||||
}
|
||||
|
||||
/**
|
||||
* 오래된 로그인로그삭제 페이지입니다
|
||||
*/
|
||||
public function cleanlog()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_member_loginlog_cleanlog';
|
||||
$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(
|
||||
'mll_datetime <=' => $this->input->post('criterion'),
|
||||
);
|
||||
$this->Member_login_log_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(
|
||||
'mll_datetime <=' => $criterion,
|
||||
);
|
||||
$log_count = $this->Member_login_log_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' => 'cleanlog');
|
||||
$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));
|
||||
}
|
||||
}
|
||||
143
application/controllers/admin/member/Memberfollow.php
Normal file
143
application/controllers/admin/member/Memberfollow.php
Normal file
@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Memberfollow class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 관리자>회원설정>팔로우현황 controller 입니다.
|
||||
*/
|
||||
class Memberfollow extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 관리자 페이지 상의 현재 디렉토리입니다
|
||||
* 페이지 이동시 필요한 정보입니다
|
||||
*/
|
||||
public $pagedir = 'member/memberfollow';
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array('Follow');
|
||||
|
||||
/**
|
||||
* 이 컨트롤러의 메인 모델 이름입니다
|
||||
*/
|
||||
protected $modelname = 'Follow_model';
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/**
|
||||
* 라이브러리를 로딩합니다
|
||||
*/
|
||||
$this->load->library(array('pagination', 'querystring'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록을 가져오는 메소드입니다
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_member_memberfollow_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;
|
||||
$findex = $this->input->get('findex') ? $this->input->get('findex') : $this->{$this->modelname}->primary_key;
|
||||
$forder = $this->input->get('forder', null, 'desc');
|
||||
$sfield = $this->input->get('sfield', null, '');
|
||||
$skeyword = $this->input->get('skeyword', null, '');
|
||||
|
||||
$per_page = admin_listnum();
|
||||
$offset = ($page - 1) * $per_page;
|
||||
|
||||
/**
|
||||
* 게시판 목록에 필요한 정보를 가져옵니다.
|
||||
*/
|
||||
$this->{$this->modelname}->allow_search_field = array('mfo_id', 'mfg_id', 'mem_id', 'target_mem_id', 'mfo_datetime'); // 검색이 가능한 필드
|
||||
$this->{$this->modelname}->search_field_equal = array('mfo_id', 'mfg_id', 'mem_id', 'target_mem_id'); // 검색중 like 가 아닌 = 검색을 하는 필드
|
||||
$this->{$this->modelname}->allow_order_field = array('mfo_id'); // 정렬이 가능한 필드
|
||||
$result = $this->{$this->modelname}
|
||||
->get_admin_list($per_page, $offset, '', '', $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]['member'] = $dbmember = $this->Member_model->get_by_memid(element('mem_id', $val), 'mem_id, mem_userid, mem_nickname, mem_icon');
|
||||
$result['list'][$key]['display_name'] = display_username(
|
||||
element('mem_userid', $dbmember),
|
||||
element('mem_nickname', $dbmember),
|
||||
element('mem_icon', $dbmember)
|
||||
);
|
||||
$result['list'][$key]['target_member'] = $target_member = $this->Member_model->get_by_memid(element('target_mem_id', $val), 'mem_id, mem_userid, mem_nickname, mem_icon');
|
||||
$result['list'][$key]['target_display_name'] = display_username(
|
||||
element('mem_userid', $target_member),
|
||||
element('mem_nickname', $target_member),
|
||||
element('mem_icon', $target_member)
|
||||
);
|
||||
$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('mfo_datetime' => '날짜');
|
||||
$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']['write_url'] = admin_url($this->pagedir . '/write');
|
||||
$view['view']['list_update_url'] = admin_url($this->pagedir . '/listupdate/?' . $param->output());
|
||||
$view['view']['list_delete_url'] = admin_url($this->pagedir . '/listdelete/?' . $param->output());
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$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));
|
||||
}
|
||||
}
|
||||
147
application/controllers/admin/member/Membergroup.php
Normal file
147
application/controllers/admin/member/Membergroup.php
Normal file
@@ -0,0 +1,147 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Membergroup class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 관리자>회원설정>회원그룹관리 controller 입니다.
|
||||
*/
|
||||
class Membergroup extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 관리자 페이지 상의 현재 디렉토리입니다
|
||||
* 페이지 이동시 필요한 정보입니다
|
||||
*/
|
||||
public $pagedir = 'member/membergroup';
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array('Member_group', 'Member_group_member');
|
||||
|
||||
/**
|
||||
* 이 컨트롤러의 메인 모델 이름입니다
|
||||
*/
|
||||
protected $modelname = 'Member_group_model';
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/**
|
||||
* 라이브러리를 로딩합니다
|
||||
*/
|
||||
$this->load->library(array('querystring'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 회원 그룹 목록을 가져오는 메소드입니다
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_member_membergroup_index';
|
||||
$this->load->event($eventname);
|
||||
|
||||
$view = array();
|
||||
$view['view'] = array();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before'] = Events::trigger('before', $eventname);
|
||||
|
||||
/**
|
||||
* 페이지에 숫자가 아닌 문자가 입력되거나 1보다 작은 숫자가 입력되면 에러 페이지를 보여줍니다.
|
||||
*/
|
||||
$param =& $this->querystring;
|
||||
$findex = 'mgr_order';
|
||||
$forder = 'asc';
|
||||
|
||||
|
||||
/**
|
||||
* Validation 라이브러리를 가져옵니다
|
||||
*/
|
||||
$this->load->library('form_validation');
|
||||
|
||||
/**
|
||||
* 전송된 데이터의 유효성을 체크합니다
|
||||
*/
|
||||
$config = array(
|
||||
array(
|
||||
'field' => 's',
|
||||
'label' => '그룹명',
|
||||
'rules' => 'trim',
|
||||
),
|
||||
);
|
||||
$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);
|
||||
|
||||
$updatedata = $this->input->post();
|
||||
|
||||
$this->{$this->modelname}->update_group($updatedata);
|
||||
$view['view']['alert_message'] = '정상적으로 저장되었습니다';
|
||||
}
|
||||
|
||||
/**
|
||||
* 게시판 목록에 필요한 정보를 가져옵니다.
|
||||
*/
|
||||
$this->{$this->modelname}->allow_order_field = array('mgr_order'); // 정렬이 가능한 필드
|
||||
$result = $this->{$this->modelname}
|
||||
->get_admin_list('', '', '', '', $findex, $forder);
|
||||
if (element('list', $result)) {
|
||||
foreach (element('list', $result) as $key => $val) {
|
||||
$countwhere = array(
|
||||
'mgr_id' => element('mgr_id', $val),
|
||||
);
|
||||
$result['list'][$key]['member_count'] = $this->Member_group_member_model->count_by($countwhere);
|
||||
}
|
||||
}
|
||||
$view['view']['data'] = $result;
|
||||
|
||||
/**
|
||||
* primary key 정보를 저장합니다
|
||||
*/
|
||||
$view['view']['primary_key'] = $this->{$this->modelname}->primary_key;
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$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));
|
||||
}
|
||||
}
|
||||
143
application/controllers/admin/member/Memberlevelhistory.php
Normal file
143
application/controllers/admin/member/Memberlevelhistory.php
Normal file
@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Memberlevelhistory class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 관리자>회원설정>레벨히스토리 controller 입니다.
|
||||
*/
|
||||
class Memberlevelhistory extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 관리자 페이지 상의 현재 디렉토리입니다
|
||||
* 페이지 이동시 필요한 정보입니다
|
||||
*/
|
||||
public $pagedir = 'member/memberlevelhistory';
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array('Member_level_history');
|
||||
|
||||
/**
|
||||
* 이 컨트롤러의 메인 모델 이름입니다
|
||||
*/
|
||||
protected $modelname = 'Member_level_history_model';
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/**
|
||||
* 라이브러리를 로딩합니다
|
||||
*/
|
||||
$this->load->library(array('pagination', 'querystring'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록을 가져오는 메소드입니다
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_member_memberlevelhistory_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;
|
||||
$findex = $this->input->get('findex') ? $this->input->get('findex') : $this->{$this->modelname}->primary_key;
|
||||
$forder = $this->input->get('forder', null, 'desc');
|
||||
$sfield = $this->input->get('sfield', null, '');
|
||||
$skeyword = $this->input->get('skeyword', null, '');
|
||||
|
||||
$per_page = admin_listnum();
|
||||
$offset = ($page - 1) * $per_page;
|
||||
|
||||
/**
|
||||
* 게시판 목록에 필요한 정보를 가져옵니다.
|
||||
*/
|
||||
$this->{$this->modelname}->allow_search_field = array('mlh_id', 'member_level_history.mem_id', 'member.mem_userid', 'member.mem_nickname', 'mlh_from', 'mlh_to', 'mll_datetime', 'mlh_reason', 'mlh_ip'); // 검색이 가능한 필드
|
||||
$this->{$this->modelname}->search_field_equal = array('mlh_id', 'member_level_history.mem_id', 'mlh_from', 'mlh_to'); // 검색중 like 가 아닌 = 검색을 하는 필드
|
||||
$this->{$this->modelname}->allow_order_field = array('mlh_id'); // 정렬이 가능한 필드
|
||||
|
||||
$where = array();
|
||||
if (is_numeric($this->input->get('mlh_from'))) {
|
||||
$where['mlh_from'] = $this->input->get('mlh_from');
|
||||
}
|
||||
if (is_numeric($this->input->get('mlh_to'))) {
|
||||
$where['mlh_to'] = $this->input->get('mlh_to');
|
||||
}
|
||||
|
||||
$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)
|
||||
);
|
||||
$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('member.mem_userid' => '회원아이디', 'member.mem_nickname' => '회원닉네임', 'mlh_datetime' => '날짜', 'mlh_reason' => '이유', 'mlh_ip' => 'IP');
|
||||
$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']['list_delete_url'] = admin_url($this->pagedir . '/listdelete/?' . $param->output());
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$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));
|
||||
}
|
||||
}
|
||||
1297
application/controllers/admin/member/Members.php
Normal file
1297
application/controllers/admin/member/Members.php
Normal file
File diff suppressed because it is too large
Load Diff
151
application/controllers/admin/member/Nickname.php
Normal file
151
application/controllers/admin/member/Nickname.php
Normal file
@@ -0,0 +1,151 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Nickname class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 관리자>회원설정>닉네임변경이력 controller 입니다.
|
||||
*/
|
||||
class Nickname extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 관리자 페이지 상의 현재 디렉토리입니다
|
||||
* 페이지 이동시 필요한 정보입니다
|
||||
*/
|
||||
public $pagedir = 'member/nickname';
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array('Member_nickname');
|
||||
|
||||
/**
|
||||
* 이 컨트롤러의 메인 모델 이름입니다
|
||||
*/
|
||||
protected $modelname = 'Member_nickname_model';
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/**
|
||||
* 라이브러리를 로딩합니다
|
||||
*/
|
||||
$this->load->library(array('pagination', 'querystring'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록을 가져오는 메소드입니다
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_member_nickname_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(
|
||||
'mni_nickname' => $param->sort('mni_nickname', 'asc'),
|
||||
'mni_start_datetime' => $param->sort('mni_start_datetime', 'asc'),
|
||||
'mni_end_datetime' => $param->sort('mni_end_datetime', 'asc'),
|
||||
);
|
||||
$findex = $this->input->get('findex') ? $this->input->get('findex') : $this->{$this->modelname}->primary_key;
|
||||
$forder = $this->input->get('forder', null, 'desc');
|
||||
$sfield = $this->input->get('sfield', null, '');
|
||||
$skeyword = $this->input->get('skeyword', null, '');
|
||||
|
||||
$per_page = admin_listnum();
|
||||
$offset = ($page - 1) * $per_page;
|
||||
|
||||
/**
|
||||
* 게시판 목록에 필요한 정보를 가져옵니다.
|
||||
*/
|
||||
$this->{$this->modelname}->allow_search_field = array('mni_id', 'member_nickname.mem_id', 'member.mem_userid', 'member.mem_nickname', 'mni_nickname'); // 검색이 가능한 필드
|
||||
$this->{$this->modelname}->search_field_equal = array('mni_id', 'member_nickname.mem_id'); // 검색중 like 가 아닌 = 검색을 하는 필드
|
||||
$this->{$this->modelname}->allow_order_field = array('mni_id', 'mni_nickname', 'mni_start_datetime', 'mni_end_datetime'); // 정렬이 가능한 필드
|
||||
|
||||
$where = array();
|
||||
if ($this->input->get('use') === 'Y') {
|
||||
$where['mni_end_datetime'] = null;
|
||||
}
|
||||
if ($this->input->get('use') === 'N') {
|
||||
$where['mni_end_datetime >'] = '0000-00-00 00:00:00';
|
||||
}
|
||||
|
||||
$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)
|
||||
);
|
||||
$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('member.mem_userid' => '회원아이디', 'member.mem_nickname' => '현재닉네임', 'mni_nickname' => '닉네임');
|
||||
$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']['write_url'] = admin_url($this->pagedir . '/write');
|
||||
$view['view']['list_update_url'] = admin_url($this->pagedir . '/listupdate/?' . $param->output());
|
||||
$view['view']['list_delete_url'] = admin_url($this->pagedir . '/listdelete/?' . $param->output());
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$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));
|
||||
}
|
||||
}
|
||||
461
application/controllers/admin/member/Points.php
Normal file
461
application/controllers/admin/member/Points.php
Normal file
@@ -0,0 +1,461 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Point class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 관리자>회원설정>포인트관리 controller 입니다.
|
||||
*/
|
||||
class Points extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 관리자 페이지 상의 현재 디렉토리입니다
|
||||
* 페이지 이동시 필요한 정보입니다
|
||||
*/
|
||||
public $pagedir = 'member/points';
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array('Point');
|
||||
|
||||
/**
|
||||
* 이 컨트롤러의 메인 모델 이름입니다
|
||||
*/
|
||||
protected $modelname = 'Point_model';
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/**
|
||||
* 라이브러리를 로딩합니다
|
||||
*/
|
||||
$this->load->library(array('pagination', 'querystring', 'point'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록을 가져오는 메소드입니다
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_member_points_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;
|
||||
$findex = $this->input->get('findex') ? $this->input->get('findex') : $this->{$this->modelname}->primary_key;
|
||||
$forder = $this->input->get('forder', null, 'desc');
|
||||
$sfield = $this->input->get('sfield', null, '');
|
||||
$skeyword = $this->input->get('skeyword', null, '');
|
||||
|
||||
$per_page = admin_listnum();
|
||||
$offset = ($page - 1) * $per_page;
|
||||
|
||||
/**
|
||||
* 게시판 목록에 필요한 정보를 가져옵니다.
|
||||
*/
|
||||
$this->{$this->modelname}->allow_search_field = array('poi_id', 'point.mem_id', 'poi_datetime', 'poi_content', 'poi_type', 'poi_action'); // 검색이 가능한 필드
|
||||
$this->{$this->modelname}->search_field_equal = array('poi_id', 'point.mem_id'); // 검색중 like 가 아닌 = 검색을 하는 필드
|
||||
$this->{$this->modelname}->allow_order_field = array('poi_id'); // 정렬이 가능한 필드
|
||||
$result = $this->{$this->modelname}
|
||||
->get_admin_list($per_page, $offset, '', '', $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)
|
||||
);
|
||||
$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('poi_datetime' => '날짜', 'poi_content' => '내용');
|
||||
$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']['write_url'] = admin_url($this->pagedir . '/write');
|
||||
$view['view']['list_delete_url'] = admin_url($this->pagedir . '/listdelete/?' . $param->output());
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$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));
|
||||
}
|
||||
|
||||
/**
|
||||
* 게시판 글쓰기 또는 수정 페이지를 가져오는 메소드입니다
|
||||
*/
|
||||
public function write()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_member_points_write';
|
||||
$this->load->event($eventname);
|
||||
|
||||
$view = array();
|
||||
$view['view'] = array();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before'] = Events::trigger('before', $eventname);
|
||||
|
||||
$primary_key = $this->{$this->modelname}->primary_key;
|
||||
|
||||
/**
|
||||
* Validation 라이브러리를 가져옵니다
|
||||
*/
|
||||
$this->load->library('form_validation');
|
||||
|
||||
/**
|
||||
* 전송된 데이터의 유효성을 체크합니다
|
||||
*/
|
||||
$config = array();
|
||||
if ($this->input->post('poi_type') === 'toall') {
|
||||
$config = array(
|
||||
array(
|
||||
'field' => 'poi_point_all',
|
||||
'label' => '포인트',
|
||||
'rules' => 'trim|required|numeric',
|
||||
),
|
||||
array(
|
||||
'field' => 'poi_content_all',
|
||||
'label' => '내용',
|
||||
'rules' => 'trim|required',
|
||||
),
|
||||
);
|
||||
} elseif ($this->input->post('poi_type') === 'toone') {
|
||||
$config = array(
|
||||
array(
|
||||
'field' => 'mem_userid',
|
||||
'label' => '회원아이디',
|
||||
'rules' => 'trim|required|callback__real_userid',
|
||||
),
|
||||
array(
|
||||
'field' => 'poi_point',
|
||||
'label' => '포인트',
|
||||
'rules' => 'trim|required|numeric',
|
||||
),
|
||||
array(
|
||||
'field' => 'poi_content',
|
||||
'label' => '내용',
|
||||
'rules' => 'trim|required',
|
||||
),
|
||||
);
|
||||
}
|
||||
$this->form_validation->set_rules($config);
|
||||
|
||||
|
||||
/**
|
||||
* 유효성 검사를 하지 않는 경우, 또는 유효성 검사에 실패한 경우입니다.
|
||||
* 즉 글쓰기나 수정 페이지를 보고 있는 경우입니다
|
||||
*/
|
||||
if ($this->form_validation->run() === false) {
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['formrunfalse'] = Events::trigger('formrunfalse', $eventname);
|
||||
|
||||
/**
|
||||
* primary key 정보를 저장합니다
|
||||
*/
|
||||
$view['view']['primary_key'] = $primary_key;
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
|
||||
|
||||
/**
|
||||
* 어드민 레이아웃을 정의합니다
|
||||
*/
|
||||
$layoutconfig = array('layout' => 'layout', 'skin' => 'write');
|
||||
$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));
|
||||
|
||||
} else {
|
||||
/**
|
||||
* 유효성 검사를 통과한 경우입니다.
|
||||
* 즉 데이터의 insert 나 update 의 process 처리가 필요한 상황입니다
|
||||
*/
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['formruntrue'] = Events::trigger('formruntrue', $eventname);
|
||||
|
||||
if ($this->input->post('poi_type') === 'toall') {
|
||||
$where = array(
|
||||
'mem_denied' => 0,
|
||||
);
|
||||
$mball = $this->Member_model->get('', 'mem_id', $where);
|
||||
if ($mball && is_array($mball)) {
|
||||
foreach ($mball as $mb) {
|
||||
if (element('mem_id', $mb)) {
|
||||
$this->point->insert_point(
|
||||
element('mem_id', $mb),
|
||||
$this->input->post('poi_point_all'),
|
||||
$this->input->post('poi_content_all'),
|
||||
'@byadmin',
|
||||
element('mem_id', $mb),
|
||||
$this->member->item('mem_id') . '-' . uniqid('')
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
} elseif ($this->input->post('poi_type') === 'toone') {
|
||||
$mb = $this->Member_model->get_by_userid($this->input->post('mem_userid'), 'mem_id');
|
||||
if (element('mem_id', $mb)) {
|
||||
$this->point->insert_point(
|
||||
element('mem_id', $mb),
|
||||
$this->input->post('poi_point'),
|
||||
$this->input->post('poi_content'),
|
||||
'@byadmin',
|
||||
element('mem_id', $mb),
|
||||
$this->member->item('mem_id') . '-' . uniqid('')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$this->session->set_flashdata(
|
||||
'message',
|
||||
'정상적으로 입력되었습니다'
|
||||
);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after', $eventname);
|
||||
|
||||
/**
|
||||
* 게시물의 신규입력 또는 수정작업이 끝난 후 목록 페이지로 이동합니다
|
||||
*/
|
||||
$param =& $this->querystring;
|
||||
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
|
||||
redirect($redirecturl);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록 페이지에서 선택삭제를 하는 경우 실행되는 메소드입니다
|
||||
*/
|
||||
public function listdelete()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_member_points_listdelete';
|
||||
$this->load->event($eventname);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('before', $eventname);
|
||||
|
||||
/**
|
||||
* 체크한 게시물의 삭제를 실행합니다
|
||||
*/
|
||||
$this->load->library('Point');
|
||||
if ($this->input->post('chk') && is_array($this->input->post('chk'))) {
|
||||
foreach ($this->input->post('chk') as $val) {
|
||||
if ($val) {
|
||||
$this->point->delete_point_by_pk($val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after', $eventname);
|
||||
|
||||
/**
|
||||
* 삭제가 끝난 후 목록페이지로 이동합니다
|
||||
*/
|
||||
$this->session->set_flashdata(
|
||||
'message',
|
||||
'정상적으로 삭제되었습니다'
|
||||
);
|
||||
$param =& $this->querystring;
|
||||
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
|
||||
|
||||
redirect($redirecturl);
|
||||
}
|
||||
|
||||
/**
|
||||
* 실제로 존재하는 회원인지를 체크합니다
|
||||
*/
|
||||
public function _real_userid($str)
|
||||
{
|
||||
$mb = $this->Member_model->get_by_userid($str, 'mem_id, mem_denied');
|
||||
if ( ! element('mem_id', $mb)) {
|
||||
$this->form_validation->set_message(
|
||||
'_real_userid',
|
||||
$str . ' 은 존재하지 않는 회원아이디입니다'
|
||||
);
|
||||
return false;
|
||||
}
|
||||
if (element('mem_denied', $mb)) {
|
||||
$this->form_validation->set_message(
|
||||
'_real_userid',
|
||||
$str . ' 은 탈퇴, 차단된 회원아이디입니다'
|
||||
);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 오래된 포인트로그 정리 페이지입니다
|
||||
*/
|
||||
public function cleanlog()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_member_point_cleanlog';
|
||||
$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')) {
|
||||
$criterion = $this->input->post('criterion');
|
||||
$result = $this->Point_model->member_list_by_point_count(10, $criterion);
|
||||
$mem_count = 0;
|
||||
$poi_count = 0;
|
||||
if ($result) {
|
||||
foreach ($result as $value) {
|
||||
$mem_count++;
|
||||
$poi_count += element('cnt', $value);
|
||||
$where = array(
|
||||
'mem_id' => element('mem_id', $value),
|
||||
'poi_datetime <=' => $criterion,
|
||||
);
|
||||
$this->Point_model->delete_where($where);
|
||||
|
||||
$this->point->insert_point(
|
||||
element('mem_id', $value),
|
||||
element('sum_point', $value),
|
||||
$criterion . ' 까지의 포인트 ' . number_format(element('cnt', $value)) . '건 정리',
|
||||
'@clean',
|
||||
element('mem_id', $value),
|
||||
element('mem_id', $value) . '-' . uniqid('')
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
$view['view']['alert_message'] = '총 ' . number_format($mem_count) . ' 명의 포인트 ' . number_format($poi_count) . ' 건이 정리되었습니다';
|
||||
} else {
|
||||
$criterion = cdate('Y-m-d H:i:s', ctimestamp() - $this->input->post('day') * 24 * 60 * 60);
|
||||
$view['view']['criterion'] = $criterion;
|
||||
$view['view']['day'] = $this->input->post('day');
|
||||
$result = $this->Point_model->member_count_by_point_count(1, $criterion);
|
||||
$member_count = count($result);
|
||||
$point_sum = 0;
|
||||
if ($result) {
|
||||
foreach ($result as $k => $v) {
|
||||
$point_sum += element('cnt', $v);
|
||||
}
|
||||
}
|
||||
if ($member_count > 0) {
|
||||
$view['view']['msg'] = '총 ' . number_format($member_count) . ' 명의 회원, ' . number_format($point_sum) . ' 건의 ' . $this->input->post('day') . '일 이상된 포인트 데이터가 발견되었습니다.<br />';
|
||||
if ($member_count > 100) {
|
||||
$view['view']['msg'] .= '이중 100명 회원의 포인트를 정리하시겠습니까?';
|
||||
} else {
|
||||
$view['view']['msg'] .= '이를 정리하시겠습니까?';
|
||||
}
|
||||
} else {
|
||||
$view['view']['alert_message'] = $this->input->post('day') . '일 이상된 포인트 데이터가 발견되지 않았습니다';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
|
||||
|
||||
/**
|
||||
* 어드민 레이아웃을 정의합니다
|
||||
*/
|
||||
$layoutconfig = array('layout' => 'layout', 'skin' => 'cleanlog');
|
||||
$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));
|
||||
}
|
||||
}
|
||||
616
application/controllers/admin/page/Banner.php
Normal file
616
application/controllers/admin/page/Banner.php
Normal file
@@ -0,0 +1,616 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Banner class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 관리자>페이지설정>팝업관리 controller 입니다.
|
||||
*/
|
||||
class Banner extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 관리자 페이지 상의 현재 디렉토리입니다
|
||||
* 페이지 이동시 필요한 정보입니다
|
||||
*/
|
||||
public $pagedir = 'page/banner';
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array('Banner', 'Banner_group');
|
||||
|
||||
/**
|
||||
* 이 컨트롤러의 메인 모델 이름입니다
|
||||
*/
|
||||
protected $modelname = 'Banner_model';
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/**
|
||||
* 라이브러리를 로딩합니다
|
||||
*/
|
||||
$this->load->library(array('pagination', 'querystring'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록을 가져오는 메소드입니다
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_page_banner_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(
|
||||
'ban_id' => $param->sort('ban_id', 'asc'),
|
||||
'ban_title' => $param->sort('ban_title', 'asc'),
|
||||
'ban_url' => $param->sort('ban_url', 'asc'),
|
||||
'ban_start_date' => $param->sort('ban_start_date', 'asc'),
|
||||
'ban_end_date' => $param->sort('ban_end_date', 'asc'),
|
||||
'ban_hit' => $param->sort('ban_hit', 'asc'),
|
||||
'ban_order' => $param->sort('ban_order', 'asc'),
|
||||
'ban_activated' => $param->sort('ban_activated', 'asc'),
|
||||
);
|
||||
$findex = $this->input->get('findex') ? $this->input->get('findex') : $this->{$this->modelname}->primary_key;
|
||||
$forder = $this->input->get('forder', null, 'desc');
|
||||
$sfield = $this->input->get('sfield', null, '');
|
||||
$skeyword = $this->input->get('skeyword', null, '');
|
||||
|
||||
$per_page = admin_listnum();
|
||||
$offset = ($page - 1) * $per_page;
|
||||
|
||||
/**
|
||||
* 게시판 목록에 필요한 정보를 가져옵니다.
|
||||
*/
|
||||
$this->{$this->modelname}->allow_search_field = array('ban_id', 'ban_title', 'ban_url'); // 검색이 가능한 필드
|
||||
$this->{$this->modelname}->search_field_equal = array('ban_id'); // 검색중 like 가 아닌 = 검색을 하는 필드
|
||||
$this->{$this->modelname}->allow_order_field = array('ban_id', 'ban_start_date', 'ban_end_date', 'ban_title', 'ban_url', 'ban_hit', 'ban_order', 'ban_activated'); // 정렬이 가능한 필드
|
||||
|
||||
$where = array();
|
||||
if ($this->input->get('ban_activated') === 'Y') {
|
||||
$where['ban_activated'] = '1';
|
||||
}
|
||||
if ($this->input->get('ban_activated') === 'N') {
|
||||
$where['ban_activated'] = '0';
|
||||
}
|
||||
|
||||
$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) {
|
||||
if (element('ban_image', $val)) {
|
||||
$result['list'][$key]['thumb_url'] = thumb_url('banner', element('ban_image', $val), '80');
|
||||
}
|
||||
if (empty($val['ban_start_date']) OR $val['ban_start_date'] === '0000-00-00') {
|
||||
$result['list'][$key]['ban_start_date'] = '미지정';
|
||||
}
|
||||
if (empty($val['ban_end_date']) OR $val['ban_end_date'] === '0000-00-00') {
|
||||
$result['list'][$key]['ban_end_date'] = '미지정';
|
||||
}
|
||||
$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('ban_title' => '이미지 설명', 'ban_url' => '이미지 URL');
|
||||
$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']['write_url'] = admin_url($this->pagedir . '/write');
|
||||
$view['view']['list_delete_url'] = admin_url($this->pagedir . '/listdelete/?' . $param->output());
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$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));
|
||||
}
|
||||
|
||||
/**
|
||||
* 게시판 글쓰기 또는 수정 페이지를 가져오는 메소드입니다
|
||||
*/
|
||||
public function write($pid = 0)
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_page_banner_write';
|
||||
$this->load->event($eventname);
|
||||
|
||||
$view = array();
|
||||
$view['view'] = array();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before'] = Events::trigger('before', $eventname);
|
||||
|
||||
/**
|
||||
* 프라이머리키에 숫자형이 입력되지 않으면 에러처리합니다
|
||||
*/
|
||||
if ($pid) {
|
||||
$pid = (int) $pid;
|
||||
if (empty($pid) OR $pid < 1) {
|
||||
show_404();
|
||||
}
|
||||
}
|
||||
$primary_key = $this->{$this->modelname}->primary_key;
|
||||
|
||||
/**
|
||||
* 수정 페이지일 경우 기존 데이터를 가져옵니다
|
||||
*/
|
||||
$getdata = array();
|
||||
if ($pid) {
|
||||
$getdata = $this->{$this->modelname}->get_one($pid);
|
||||
}
|
||||
|
||||
$group = $this->Banner_group_model->get_all_group();
|
||||
|
||||
if (empty($group)) {
|
||||
alert('배너 위치를 먼저 생성하신 후에 배너 추가가 가능합니다. 배너위치 생성 페이지로 이동합니다', admin_url($this->pagedir . '/group'));
|
||||
}
|
||||
|
||||
$view['view']['group'] = $group;
|
||||
|
||||
/**
|
||||
* Validation 라이브러리를 가져옵니다
|
||||
*/
|
||||
$this->load->library('form_validation');
|
||||
|
||||
/**
|
||||
* 전송된 데이터의 유효성을 체크합니다
|
||||
*/
|
||||
$config = array(
|
||||
array(
|
||||
'field' => 'bng_name',
|
||||
'label' => '배너위치',
|
||||
'rules' => 'trim|required',
|
||||
),
|
||||
array(
|
||||
'field' => 'ban_start_date',
|
||||
'label' => '배너시작일',
|
||||
'rules' => 'trim|alpha_dash|exact_length[10]',
|
||||
),
|
||||
array(
|
||||
'field' => 'ban_end_date',
|
||||
'label' => '배너종료일',
|
||||
'rules' => 'trim|alpha_dash|exact_length[10]',
|
||||
),
|
||||
array(
|
||||
'field' => 'ban_title',
|
||||
'label' => '이미지 설명',
|
||||
'rules' => 'trim|required',
|
||||
),
|
||||
array(
|
||||
'field' => 'ban_url',
|
||||
'label' => '이미지 URL',
|
||||
'rules' => 'trim|valid_url',
|
||||
),
|
||||
array(
|
||||
'field' => 'ban_target',
|
||||
'label' => '타겟',
|
||||
'rules' => 'trim',
|
||||
),
|
||||
array(
|
||||
'field' => 'ban_device',
|
||||
'label' => '배너표시기기',
|
||||
'rules' => 'trim|required',
|
||||
),
|
||||
array(
|
||||
'field' => 'ban_width',
|
||||
'label' => '이미지 가로값',
|
||||
'rules' => 'trim|required|numeric|is_natural',
|
||||
),
|
||||
array(
|
||||
'field' => 'ban_height',
|
||||
'label' => '이미지 세로값',
|
||||
'rules' => 'trim|required|numeric|is_natural',
|
||||
),
|
||||
array(
|
||||
'field' => 'ban_order',
|
||||
'label' => '정렬순서',
|
||||
'rules' => 'trim|required|numeric|is_natural',
|
||||
),
|
||||
array(
|
||||
'field' => 'ban_activated',
|
||||
'label' => '배너활성화',
|
||||
'rules' => 'trim',
|
||||
),
|
||||
);
|
||||
|
||||
$this->form_validation->set_rules($config);
|
||||
$form_validation = $this->form_validation->run();
|
||||
$file_error = '';
|
||||
$updatephoto = '';
|
||||
|
||||
if ($form_validation) {
|
||||
$this->load->library('upload');
|
||||
if (isset($_FILES) && isset($_FILES['ban_image']) && isset($_FILES['ban_image']['name']) && $_FILES['ban_image']['name']) {
|
||||
$upload_path = config_item('uploads_dir') . '/banner/';
|
||||
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 = array();
|
||||
$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('ban_image')) {
|
||||
$img = $this->upload->data();
|
||||
$updatephoto = cdate('Y') . '/' . cdate('m') . '/' . element('file_name', $img);
|
||||
} else {
|
||||
$file_error = $this->upload->display_errors();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 유효성 검사를 하지 않는 경우, 또는 유효성 검사에 실패한 경우입니다.
|
||||
* 즉 글쓰기나 수정 페이지를 보고 있는 경우입니다
|
||||
*/
|
||||
if ($form_validation === false OR $file_error !== '') {
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['formrunfalse'] = Events::trigger('formrunfalse', $eventname);
|
||||
$view['view']['message'] = $file_error;
|
||||
|
||||
if ($pid) {
|
||||
if (empty($getdata['ban_start_date']) OR $getdata['ban_start_date'] === '0000-00-00') {
|
||||
$getdata['ban_start_date'] = '';
|
||||
}
|
||||
if (empty($getdata['ban_end_date']) OR $getdata['ban_end_date'] === '0000-00-00') {
|
||||
$getdata['ban_end_date'] = '';
|
||||
}
|
||||
$view['view']['data'] = $getdata;
|
||||
}
|
||||
|
||||
/**
|
||||
* primary key 정보를 저장합니다
|
||||
*/
|
||||
$view['view']['primary_key'] = $primary_key;
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
|
||||
|
||||
/**
|
||||
* 어드민 레이아웃을 정의합니다
|
||||
*/
|
||||
$layoutconfig = array('layout' => 'layout', 'skin' => 'write');
|
||||
$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));
|
||||
|
||||
} else {
|
||||
/**
|
||||
* 유효성 검사를 통과한 경우입니다.
|
||||
* 즉 데이터의 insert 나 update 의 process 처리가 필요한 상황입니다
|
||||
*/
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['formruntrue'] = Events::trigger('formruntrue', $eventname);
|
||||
|
||||
$content_type = $this->cbconfig->item('use_popup_dhtml') ? 1 : 0;
|
||||
|
||||
$ban_start_date = $this->input->post('ban_start_date');
|
||||
if ( ! $ban_start_date) $ban_start_date = null;
|
||||
$ban_end_date = $this->input->post('ban_end_date');
|
||||
if ( ! $ban_end_date) $ban_end_date = null;
|
||||
$ban_width = $this->input->post('ban_width') ? $this->input->post('ban_width') : 0;
|
||||
$ban_height = $this->input->post('ban_height') ? $this->input->post('ban_height') : 0;
|
||||
$ban_order = $this->input->post('ban_order') ? $this->input->post('ban_order') : 0;
|
||||
$ban_activated = $this->input->post('ban_activated') ? 1 : 0;
|
||||
|
||||
$updatedata = array(
|
||||
'ban_start_date' => $ban_start_date,
|
||||
'ban_end_date' => $ban_end_date,
|
||||
'ban_title' => $this->input->post('ban_title', null, ''),
|
||||
'bng_name' => $this->input->post('bng_name', null, ''),
|
||||
'ban_url' => $this->input->post('ban_url', null, ''),
|
||||
'ban_target' => $this->input->post('ban_target', null, ''),
|
||||
'ban_device' => $this->input->post('ban_device', null, ''),
|
||||
'ban_width' => $ban_width,
|
||||
'ban_height' => $ban_height,
|
||||
'ban_order' => $ban_order,
|
||||
'ban_activated' => $ban_activated,
|
||||
);
|
||||
if ($this->input->post('ban_image_del')) {
|
||||
$updatedata['ban_image'] = '';
|
||||
} elseif ($updatephoto) {
|
||||
$updatedata['ban_image'] = $updatephoto;
|
||||
}
|
||||
if (element('ban_image', $getdata) && ($this->input->post('ban_image_del') OR $updatephoto)) {
|
||||
// 기존 파일 삭제
|
||||
@unlink(config_item('uploads_dir') . '/banner/' . element('ban_image', $getdata));
|
||||
}
|
||||
|
||||
/**
|
||||
* 게시물을 수정하는 경우입니다
|
||||
*/
|
||||
if ($this->input->post($primary_key)) {
|
||||
$this->cache->delete('banner/banner-' . element('bng_name', $getdata) . '-random-' . cdate('Y-m-d'));
|
||||
$this->cache->delete('banner/banner-' . element('bng_name', $getdata) . '-order-' . cdate('Y-m-d'));
|
||||
$this->{$this->modelname}->update($this->input->post($primary_key), $updatedata);
|
||||
$this->session->set_flashdata(
|
||||
'message',
|
||||
'정상적으로 수정되었습니다'
|
||||
);
|
||||
} else {
|
||||
/**
|
||||
* 게시물을 새로 입력하는 경우입니다
|
||||
*/
|
||||
$updatedata['ban_datetime'] = cdate('Y-m-d H:i:s');
|
||||
$updatedata['ban_ip'] = $this->input->ip_address();
|
||||
$updatedata['mem_id'] = $this->member->item('mem_id');
|
||||
$this->{$this->modelname}->insert($updatedata);
|
||||
$this->session->set_flashdata(
|
||||
'message',
|
||||
'정상적으로 입력되었습니다'
|
||||
);
|
||||
}
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after', $eventname);
|
||||
|
||||
/**
|
||||
* 게시물의 신규입력 또는 수정작업이 끝난 후 목록 페이지로 이동합니다
|
||||
*/
|
||||
$param =& $this->querystring;
|
||||
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
|
||||
|
||||
redirect($redirecturl);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 배너 위치관리 페이지를 가져오는 메소드입니다
|
||||
*/
|
||||
public function group()
|
||||
{
|
||||
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_page_banner_group';
|
||||
$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' => 'bng_name',
|
||||
'label' => '위치명',
|
||||
'rules' => 'trim|required|alpha_dash|is_unique[banner_group.bng_name]',
|
||||
),
|
||||
);
|
||||
$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);
|
||||
|
||||
$insertdata = array(
|
||||
'bng_name' => $this->input->post('bng_name', null, ''),
|
||||
);
|
||||
$this->Banner_group_model->insert($insertdata);
|
||||
}
|
||||
|
||||
/**
|
||||
* 페이지에 숫자가 아닌 문자가 입력되거나 1보다 작은 숫자가 입력되면 에러 페이지를 보여줍니다.
|
||||
*/
|
||||
$param =& $this->querystring;
|
||||
$findex = $this->input->get('findex', null, 'bng_group');
|
||||
$forder = $this->input->get('forder', null, 'asc');
|
||||
|
||||
$result = $this->Banner_group_model
|
||||
->get_admin_list(1000, 0, '', '', $findex, $forder);
|
||||
if (element('list', $result)) {
|
||||
foreach (element('list', $result) as $key => $val) {
|
||||
$countwhere = array(
|
||||
'bng_name' => element('bng_name', $val),
|
||||
);
|
||||
$result['list'][$key]['banner_count'] = $this->Banner_model->count_by($countwhere);
|
||||
}
|
||||
}
|
||||
|
||||
$view['view']['data'] = $result;
|
||||
|
||||
$primary_key = $this->Banner_group_model->primary_key;
|
||||
|
||||
$view['view']['list_delete_url'] = admin_url($this->pagedir . '/groupdelete/?' . $param->output());
|
||||
$view['view']['primary_key'] = $primary_key;
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
|
||||
|
||||
/**
|
||||
* 어드민 레이아웃을 정의합니다
|
||||
*/
|
||||
$layoutconfig = array('layout' => 'layout', 'skin' => 'group');
|
||||
$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));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록 페이지에서 선택삭제를 하는 경우 실행되는 메소드입니다
|
||||
*/
|
||||
public function listdelete()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_page_banner_listdelete';
|
||||
$this->load->event($eventname);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('before', $eventname);
|
||||
|
||||
/**
|
||||
* 체크한 게시물의 삭제를 실행합니다
|
||||
*/
|
||||
if ($this->input->post('chk') && is_array($this->input->post('chk'))) {
|
||||
foreach ($this->input->post('chk') as $val) {
|
||||
if ($val) {
|
||||
$getdata = $this->{$this->modelname}->get_one($val);
|
||||
$this->cache->delete('banner/banner-' . element('bng_name', $getdata) . '-random-' . cdate('Y-m-d'));
|
||||
$this->cache->delete('banner/banner-' . element('bng_name', $getdata) . '-order-' . cdate('Y-m-d'));
|
||||
$this->{$this->modelname}->delete($val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after', $eventname);
|
||||
|
||||
/**
|
||||
* 삭제가 끝난 후 목록페이지로 이동합니다
|
||||
*/
|
||||
$this->session->set_flashdata(
|
||||
'message',
|
||||
'정상적으로 삭제되었습니다'
|
||||
);
|
||||
$param =& $this->querystring;
|
||||
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
|
||||
redirect($redirecturl);
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록 페이지에서 선택삭제를 하는 경우 실행되는 메소드입니다
|
||||
*/
|
||||
public function groupdelete()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_page_banner_groupdelete';
|
||||
$this->load->event($eventname);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('before', $eventname);
|
||||
|
||||
/**
|
||||
* 체크한 게시물의 삭제를 실행합니다
|
||||
*/
|
||||
if ($this->input->post('chk') && is_array($this->input->post('chk'))) {
|
||||
foreach ($this->input->post('chk') as $val) {
|
||||
if ($val) {
|
||||
$this->Banner_group_model->delete($val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after', $eventname);
|
||||
|
||||
/**
|
||||
* 삭제가 끝난 후 목록페이지로 이동합니다
|
||||
*/
|
||||
$this->session->set_flashdata(
|
||||
'message',
|
||||
'정상적으로 삭제되었습니다'
|
||||
);
|
||||
$param =& $this->querystring;
|
||||
$redirecturl = admin_url($this->pagedir . '/group?' . $param->output());
|
||||
|
||||
redirect($redirecturl);
|
||||
}
|
||||
}
|
||||
407
application/controllers/admin/page/Bannerclick.php
Normal file
407
application/controllers/admin/page/Bannerclick.php
Normal file
@@ -0,0 +1,407 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Bannerclick class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 관리자>페이지설정>배너 클릭 controller 입니다.
|
||||
*/
|
||||
class Bannerclick extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 관리자 페이지 상의 현재 디렉토리입니다
|
||||
* 페이지 이동시 필요한 정보입니다
|
||||
*/
|
||||
public $pagedir = 'page/bannerclick';
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array('Banner_click_log');
|
||||
|
||||
/**
|
||||
* 이 컨트롤러의 메인 모델 이름입니다
|
||||
*/
|
||||
protected $modelname = 'Banner_click_log_model';
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/**
|
||||
* 라이브러리를 로딩합니다
|
||||
*/
|
||||
$this->load->library(array('pagination', 'querystring'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록을 가져오는 메소드입니다
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_page_bannerclick_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;
|
||||
$findex = $this->input->get('findex') ? $this->input->get('findex') : $this->{$this->modelname}->primary_key;
|
||||
$forder = $this->input->get('forder', null, 'desc');
|
||||
$sfield = $this->input->get('sfield', null, '');
|
||||
$skeyword = $this->input->get('skeyword', null, '');
|
||||
|
||||
$per_page = admin_listnum();
|
||||
$offset = ($page - 1) * $per_page;
|
||||
|
||||
/**
|
||||
* 게시판 목록에 필요한 정보를 가져옵니다.
|
||||
*/
|
||||
$this->{$this->modelname}->allow_search_field = array('bcl_id', 'ban_id', 'bng_name', 'banner.mem_id', 'banner_click_log.mem_id', 'bcl_datetime', 'bcl_ip'); // 검색이 가능한 필드
|
||||
$this->{$this->modelname}->search_field_equal = array('bcl_id', 'ban_id', 'banner.mem_id', 'banner_click_log.mem_id'); // 검색중 like 가 아닌 = 검색을 하는 필드
|
||||
$this->{$this->modelname}->allow_order_field = array('bcl_id'); // 정렬이 가능한 필드
|
||||
$result = $this->{$this->modelname}
|
||||
->get_admin_list($per_page, $offset, '', '', $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]['member'] = $dbmember = $this->Member_model->get_by_memid(element('mem_id', $val), 'mem_id, mem_userid, mem_nickname, mem_icon');
|
||||
$result['list'][$key]['display_name'] = display_username(
|
||||
element('mem_userid', $dbmember),
|
||||
element('mem_nickname', $dbmember),
|
||||
element('mem_icon', $dbmember)
|
||||
);
|
||||
if (element('ban_image', $val)) {
|
||||
$result['list'][$key]['thumb_url'] = thumb_url('banner', element('ban_image', $val), '80');
|
||||
}
|
||||
if (element('bcl_useragent', $val)) {
|
||||
$userAgent = get_useragent_info(element('bcl_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('bcl_datetime' => '날짜', 'bcl_ip' => 'IP');
|
||||
$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']['list_delete_url'] = admin_url($this->pagedir . '/listdelete/?' . $param->output());
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$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));
|
||||
}
|
||||
|
||||
/**
|
||||
* 그래프 형식으로 보는 페이지입니다
|
||||
*/
|
||||
public function graph($export = '')
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_page_bannerclick_graph';
|
||||
$this->load->event($eventname);
|
||||
|
||||
$view = array();
|
||||
$view['view'] = array();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before'] = Events::trigger('before', $eventname);
|
||||
|
||||
$param =& $this->querystring;
|
||||
$datetype = $this->input->get('datetype', null, 'd');
|
||||
if ($datetype !== 'm' && $datetype !== 'y') {
|
||||
$datetype = 'd';
|
||||
}
|
||||
$start_date = $this->input->get('start_date') ? $this->input->get('start_date') : cdate('Y-m-01');
|
||||
$end_date = $this->input->get('end_date') ? $this->input->get('end_date') : cdate('Y-m-d');
|
||||
if ($datetype === 'y' OR $datetype === 'm') {
|
||||
$start_year = substr($start_date, 0, 4);
|
||||
$end_year = substr($end_date, 0, 4);
|
||||
}
|
||||
if ($datetype === 'm') {
|
||||
$start_month = substr($start_date, 5, 2);
|
||||
$end_month = substr($end_date, 5, 2);
|
||||
$start_year_month = $start_year * 12 + $start_month;
|
||||
$end_year_month = $end_year * 12 + $end_month;
|
||||
}
|
||||
$orderby = (strtolower($this->input->get('orderby')) === 'desc') ? 'desc' : 'asc';
|
||||
|
||||
$result = $this->{$this->modelname}->get_banner_click_count($datetype, $start_date, $end_date, $orderby);
|
||||
$sum_count = 0;
|
||||
$arr = array();
|
||||
$max = 0;
|
||||
|
||||
if ($result && is_array($result)) {
|
||||
foreach ($result as $key => $value) {
|
||||
$s = element('day', $value);
|
||||
if ( ! isset($arr[$s])) {
|
||||
$arr[$s] = 0;
|
||||
}
|
||||
$arr[$s] += element('cnt', $value);
|
||||
|
||||
if ($arr[$s] > $max) {
|
||||
$max = $arr[$s];
|
||||
}
|
||||
$sum_count += element('cnt', $value);
|
||||
}
|
||||
}
|
||||
|
||||
$result = array();
|
||||
$i = 0;
|
||||
$save_count = -1;
|
||||
$tot_count = 0;
|
||||
|
||||
if (count($arr)) {
|
||||
foreach ($arr as $key => $value) {
|
||||
$count = (int) $arr[$key];
|
||||
$result[$key]['count'] = $count;
|
||||
$i++;
|
||||
if ($save_count !== $count) {
|
||||
$no = $i;
|
||||
$save_count = $count;
|
||||
}
|
||||
$result[$key]['no'] = $no;
|
||||
|
||||
$result[$key]['key'] = $key;
|
||||
$rate = ($count / $sum_count * 100);
|
||||
$result[$key]['rate'] = $rate;
|
||||
$s_rate = number_format($rate, 1);
|
||||
$result[$key]['s_rate'] = $s_rate;
|
||||
|
||||
$bar = (int)($count / $max * 100);
|
||||
$result[$key]['bar'] = $bar;
|
||||
}
|
||||
$view['view']['max_value'] = $max;
|
||||
$view['view']['sum_count'] = $sum_count;
|
||||
}
|
||||
|
||||
if ($datetype === 'y') {
|
||||
for ($i = $start_year; $i <= $end_year; $i++) {
|
||||
if( ! isset($result[$i])) $result[$i] = '';
|
||||
}
|
||||
} elseif ($datetype === 'm') {
|
||||
for ($i = $start_year_month; $i <= $end_year_month; $i++) {
|
||||
$year = floor($i / 12);
|
||||
if ($year * 12 == $i) $year--;
|
||||
$month = sprintf("%02d", ($i - ($year * 12)));
|
||||
$date = $year . '-' . $month;
|
||||
if( ! isset($result[$date])) $result[$date] = '';
|
||||
}
|
||||
} elseif ($datetype === 'd') {
|
||||
$date = $start_date;
|
||||
while ($date <= $end_date) {
|
||||
if( ! isset($result[$date])) $result[$date] = '';
|
||||
$date = cdate('Y-m-d', strtotime($date) + 86400);
|
||||
}
|
||||
}
|
||||
|
||||
if ($orderby === 'desc') {
|
||||
krsort($result);
|
||||
} else {
|
||||
ksort($result);
|
||||
}
|
||||
|
||||
$view['view']['list'] = $result;
|
||||
|
||||
$view['view']['start_date'] = $start_date;
|
||||
$view['view']['end_date'] = $end_date;
|
||||
$view['view']['datetype'] = $datetype;
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
|
||||
|
||||
if ($export === 'excel') {
|
||||
|
||||
header('Content-type: application/vnd.ms-excel');
|
||||
header('Content-Disposition: attachment; filename=배너클릭_' . cdate('Y_m_d') . '.xls');
|
||||
echo $this->load->view('admin/' . ADMIN_SKIN . '/' . $this->pagedir . '/graph_excel', $view, true);
|
||||
|
||||
} else {
|
||||
/**
|
||||
* 어드민 레이아웃을 정의합니다
|
||||
*/
|
||||
$layoutconfig = array('layout' => 'layout', 'skin' => 'graph');
|
||||
$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));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록 페이지에서 선택삭제를 하는 경우 실행되는 메소드입니다
|
||||
*/
|
||||
public function listdelete()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_page_bannerclick_listdelete';
|
||||
$this->load->event($eventname);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('before', $eventname);
|
||||
|
||||
/**
|
||||
* 체크한 게시물의 삭제를 실행합니다
|
||||
*/
|
||||
if ($this->input->post('chk') && is_array($this->input->post('chk'))) {
|
||||
foreach ($this->input->post('chk') as $val) {
|
||||
if ($val) {
|
||||
$this->{$this->modelname}->delete($val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after', $eventname);
|
||||
|
||||
/**
|
||||
* 삭제가 끝난 후 목록페이지로 이동합니다
|
||||
*/
|
||||
$this->session->set_flashdata(
|
||||
'message',
|
||||
'정상적으로 삭제되었습니다'
|
||||
);
|
||||
$param =& $this->querystring;
|
||||
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
|
||||
|
||||
redirect($redirecturl);
|
||||
}
|
||||
|
||||
/**
|
||||
* 오래된 배너클릭로그삭제 페이지입니다
|
||||
*/
|
||||
public function cleanlog()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_page_bannerclick_cleanlog';
|
||||
$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(
|
||||
'bcl_datetime <=' => $this->input->post('criterion'),
|
||||
);
|
||||
$this->Banner_click_log_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(
|
||||
'bcl_datetime <=' => $criterion,
|
||||
);
|
||||
$log_count = $this->Banner_click_log_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' => 'cleanlog');
|
||||
$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));
|
||||
}
|
||||
}
|
||||
424
application/controllers/admin/page/Document.php
Normal file
424
application/controllers/admin/page/Document.php
Normal file
@@ -0,0 +1,424 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Document class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 관리자>페이지설정>일반페이지 controller 입니다.
|
||||
*/
|
||||
class Document extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 관리자 페이지 상의 현재 디렉토리입니다
|
||||
* 페이지 이동시 필요한 정보입니다
|
||||
*/
|
||||
public $pagedir = 'page/document';
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array('Document');
|
||||
|
||||
/**
|
||||
* 이 컨트롤러의 메인 모델 이름입니다
|
||||
*/
|
||||
protected $modelname = 'Document_model';
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array', 'dhtml_editor');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/**
|
||||
* 라이브러리를 로딩합니다
|
||||
*/
|
||||
$this->load->library(array('pagination', 'querystring'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록을 가져오는 메소드입니다
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_page_document_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(
|
||||
'doc_id' => $param->sort('doc_id', 'asc'),
|
||||
'doc_key' => $param->sort('doc_key', 'asc'),
|
||||
'doc_title' => $param->sort('doc_title', 'asc'),
|
||||
'doc_layout' => $param->sort('doc_layout', 'asc'),
|
||||
'doc_mobile_layout' => $param->sort('doc_mobile_layout', 'asc'),
|
||||
'doc_skin' => $param->sort('doc_skin', 'asc'),
|
||||
'doc_mobile_skin' => $param->sort('doc_mobile_skin', 'asc'),
|
||||
'doc_updated_datetime' => $param->sort('doc_updated_datetime', 'asc'),
|
||||
'doc_hit' => $param->sort('doc_hit', 'asc'),
|
||||
);
|
||||
$findex = $this->input->get('findex') ? $this->input->get('findex') : $this->{$this->modelname}->primary_key;
|
||||
$forder = $this->input->get('forder', null, 'desc');
|
||||
$sfield = $this->input->get('sfield', null, '');
|
||||
$skeyword = $this->input->get('skeyword', null, '');
|
||||
|
||||
$per_page = admin_listnum();
|
||||
$offset = ($page - 1) * $per_page;
|
||||
|
||||
/**
|
||||
* 게시판 목록에 필요한 정보를 가져옵니다.
|
||||
*/
|
||||
$this->{$this->modelname}->allow_search_field = array('doc_id', 'doc_key', 'doc_title', 'doc_layout', 'doc_mobile_layout', 'doc_skin', 'doc_mobile_skin', 'doc_datetime', 'doc_updated_datetime', 'document.mem_id', 'doc_content', 'doc_mobile_content'); // 검색이 가능한 필드
|
||||
$this->{$this->modelname}->search_field_equal = array('doc_id', 'document.mem_id'); // 검색중 like 가 아닌 = 검색을 하는 필드
|
||||
$this->{$this->modelname}->allow_order_field = array('doc_id', 'doc_key', 'doc_title', 'doc_layout', 'doc_mobile_layout', 'doc_skin', 'doc_mobile_skin', 'doc_updated_datetime', 'doc_hit'); // 정렬이 가능한 필드
|
||||
$result = $this->{$this->modelname}
|
||||
->get_admin_list($per_page, $offset, '', '', $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)
|
||||
);
|
||||
$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('doc_key' => 'KEY', 'doc_title' => '제목', 'doc_content' => '내용', 'doc_mobile_content' => '모바일용내용', 'doc_datetime' => '입력일', 'doc_updated_datetime' => '최종수정일');
|
||||
$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']['write_url'] = admin_url($this->pagedir . '/write');
|
||||
$view['view']['list_delete_url'] = admin_url($this->pagedir . '/listdelete/?' . $param->output());
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$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));
|
||||
}
|
||||
|
||||
/**
|
||||
* 게시판 글쓰기 또는 수정 페이지를 가져오는 메소드입니다
|
||||
*/
|
||||
public function write($pid = 0)
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_page_document_write';
|
||||
$this->load->event($eventname);
|
||||
|
||||
$view = array();
|
||||
$view['view'] = array();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before'] = Events::trigger('before', $eventname);
|
||||
|
||||
/**
|
||||
* 프라이머리키에 숫자형이 입력되지 않으면 에러처리합니다
|
||||
*/
|
||||
if ($pid) {
|
||||
$pid = (int) $pid;
|
||||
if (empty($pid) OR $pid < 1) {
|
||||
show_404();
|
||||
}
|
||||
}
|
||||
$primary_key = $this->{$this->modelname}->primary_key;
|
||||
|
||||
/**
|
||||
* 수정 페이지일 경우 기존 데이터를 가져옵니다
|
||||
*/
|
||||
$getdata = array();
|
||||
if ($pid) {
|
||||
$getdata = $this->{$this->modelname}->get_one($pid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validation 라이브러리를 가져옵니다
|
||||
*/
|
||||
$this->load->library('form_validation');
|
||||
|
||||
/**
|
||||
* 전송된 데이터의 유효성을 체크합니다
|
||||
*/
|
||||
$config = array(
|
||||
array(
|
||||
'field' => 'doc_title',
|
||||
'label' => '제목',
|
||||
'rules' => 'trim|required',
|
||||
),
|
||||
array(
|
||||
'field' => 'doc_content',
|
||||
'label' => '내용',
|
||||
'rules' => 'trim|required',
|
||||
),
|
||||
array(
|
||||
'field' => 'doc_mobile_content',
|
||||
'label' => '모바일내용',
|
||||
'rules' => 'trim',
|
||||
),
|
||||
array(
|
||||
'field' => 'doc_layout',
|
||||
'label' => '레이아웃',
|
||||
'rules' => 'trim',
|
||||
),
|
||||
array(
|
||||
'field' => 'doc_sidebar',
|
||||
'label' => '사이드바',
|
||||
'rules' => 'trim',
|
||||
),
|
||||
array(
|
||||
'field' => 'doc_skin',
|
||||
'label' => '스킨',
|
||||
'rules' => 'trim',
|
||||
),
|
||||
array(
|
||||
'field' => 'doc_mobile_layout',
|
||||
'label' => '모바일레이아웃',
|
||||
'rules' => 'trim',
|
||||
),
|
||||
array(
|
||||
'field' => 'doc_mobile_sidebar',
|
||||
'label' => '모바일사이드바',
|
||||
'rules' => 'trim',
|
||||
),
|
||||
array(
|
||||
'field' => 'doc_mobile_skin',
|
||||
'label' => '모바일스킨',
|
||||
'rules' => 'trim',
|
||||
),
|
||||
);
|
||||
if ($this->input->post($primary_key)) {
|
||||
$config[] = array(
|
||||
'field' => 'doc_key',
|
||||
'label' => '페이지주소',
|
||||
'rules' => 'trim|required|alpha_dash|min_length[3]|max_length[50]|is_unique[document.doc_key.doc_id.' . $getdata['doc_id'] . ']',
|
||||
);
|
||||
} else {
|
||||
$config[] = array(
|
||||
'field' => 'doc_key',
|
||||
'label' => '페이지주소',
|
||||
'rules' => 'trim|required|alpha_dash|min_length[3]|max_length[50]|is_unique[document.doc_key]',
|
||||
);
|
||||
}
|
||||
$this->form_validation->set_rules($config);
|
||||
|
||||
|
||||
/**
|
||||
* 유효성 검사를 하지 않는 경우, 또는 유효성 검사에 실패한 경우입니다.
|
||||
* 즉 글쓰기나 수정 페이지를 보고 있는 경우입니다
|
||||
*/
|
||||
if ($this->form_validation->run() === false) {
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['formrunfalse'] = Events::trigger('formrunfalse', $eventname);
|
||||
|
||||
$view['view']['data'] = $getdata;
|
||||
$view['view']['data']['doc_layout_option'] = get_skin_name(
|
||||
'_layout',
|
||||
set_value('doc_layout', element('doc_layout', $getdata)),
|
||||
'기본설정따름'
|
||||
);
|
||||
$view['view']['data']['doc_mobile_layout_option'] = get_skin_name(
|
||||
'_layout',
|
||||
set_value('doc_mobile_layout', element('doc_mobile_layout', $getdata)),
|
||||
'기본설정따름'
|
||||
);
|
||||
$view['view']['data']['doc_skin_option'] = get_skin_name(
|
||||
'document',
|
||||
set_value('doc_skin', element('doc_skin', $getdata)),
|
||||
'기본설정따름'
|
||||
);
|
||||
$view['view']['data']['doc_mobile_skin_option'] = get_skin_name(
|
||||
'document',
|
||||
set_value('doc_mobile_skin', element('doc_mobile_skin', $getdata)),
|
||||
'기본설정따름'
|
||||
);
|
||||
|
||||
/**
|
||||
* primary key 정보를 저장합니다
|
||||
*/
|
||||
$view['view']['primary_key'] = $primary_key;
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
|
||||
|
||||
/**
|
||||
* 어드민 레이아웃을 정의합니다
|
||||
*/
|
||||
$layoutconfig = array('layout' => 'layout', 'skin' => 'write');
|
||||
$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));
|
||||
|
||||
} else {
|
||||
/**
|
||||
* 유효성 검사를 통과한 경우입니다.
|
||||
* 즉 데이터의 insert 나 update 의 process 처리가 필요한 상황입니다
|
||||
*/
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['formruntrue'] = Events::trigger('formruntrue', $eventname);
|
||||
|
||||
$content_type = $this->cbconfig->item('use_document_dhtml') ? 1 : 0;
|
||||
$doc_sidebar = $this->input->post('doc_sidebar') ? $this->input->post('doc_sidebar') : 0;
|
||||
$doc_mobile_sidebar = $this->input->post('doc_mobile_sidebar') ? $this->input->post('doc_mobile_sidebar') : 0;
|
||||
|
||||
$updatedata = array(
|
||||
'doc_key' => $this->input->post('doc_key', null, ''),
|
||||
'doc_title' => $this->input->post('doc_title', null, ''),
|
||||
'doc_content' => $this->input->post('doc_content', null, ''),
|
||||
'doc_mobile_content' => $this->input->post('doc_mobile_content', null, ''),
|
||||
'doc_content_html_type' => $content_type,
|
||||
'doc_layout' => $this->input->post('doc_layout', null, ''),
|
||||
'doc_mobile_layout' => $this->input->post('doc_mobile_layout', null, ''),
|
||||
'doc_sidebar' => $doc_sidebar,
|
||||
'doc_mobile_sidebar' => $doc_mobile_sidebar,
|
||||
'doc_skin' => $this->input->post('doc_skin', null, ''),
|
||||
'doc_mobile_skin' => $this->input->post('doc_mobile_skin', null, ''),
|
||||
'doc_updated_mem_id' => $this->member->item('mem_id'),
|
||||
'doc_updated_datetime' => cdate('Y-m-d H:i:s'),
|
||||
);
|
||||
|
||||
if ( $this->input->post($primary_key) != $pid ){
|
||||
}
|
||||
|
||||
/**
|
||||
* 게시물을 수정하는 경우입니다
|
||||
*/
|
||||
if ($pid) {
|
||||
$this->{$this->modelname}->update($pid, $updatedata);
|
||||
$this->session->set_flashdata(
|
||||
'message',
|
||||
'정상적으로 수정되었습니다'
|
||||
);
|
||||
} else {
|
||||
/**
|
||||
* 게시물을 새로 입력하는 경우입니다
|
||||
*/
|
||||
$updatedata['doc_datetime'] = cdate('Y-m-d H:i:s');
|
||||
$updatedata['mem_id'] = $this->member->item('mem_id');
|
||||
$this->{$this->modelname}->insert($updatedata);
|
||||
$this->session->set_flashdata(
|
||||
'message',
|
||||
'정상적으로 입력되었습니다'
|
||||
);
|
||||
}
|
||||
|
||||
$list = $this->{$this->modelname}->get('', 'doc_id, doc_key');
|
||||
$cachedata = '';
|
||||
if ($list && is_array($list)) {
|
||||
foreach ($list as $key => $val) {
|
||||
$cachedata[$val['doc_key']] = element('doc_id', $val);
|
||||
}
|
||||
}
|
||||
$this->cache->save('document-key-id-info', $cachedata, 86400*365);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['after'] = Events::trigger('after', $eventname);
|
||||
|
||||
/**
|
||||
* 게시물의 신규입력 또는 수정작업이 끝난 후 목록 페이지로 이동합니다
|
||||
*/
|
||||
$param =& $this->querystring;
|
||||
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
|
||||
|
||||
redirect($redirecturl);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록 페이지에서 선택삭제를 하는 경우 실행되는 메소드입니다
|
||||
*/
|
||||
public function listdelete()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_page_document_listdelete';
|
||||
$this->load->event($eventname);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('before', $eventname);
|
||||
|
||||
/**
|
||||
* 체크한 게시물의 삭제를 실행합니다
|
||||
*/
|
||||
if ($this->input->post('chk') && is_array($this->input->post('chk'))) {
|
||||
foreach ($this->input->post('chk') as $val) {
|
||||
if ($val) {
|
||||
$this->{$this->modelname}->delete($val);
|
||||
}
|
||||
}
|
||||
}
|
||||
$list = $this->{$this->modelname}->get('', 'doc_id, doc_key');
|
||||
$cachedata = '';
|
||||
if ($list && is_array($list)) {
|
||||
foreach ($list as $key => $val) {
|
||||
$cachedata[$val['doc_key']] = element('doc_id', $val);
|
||||
}
|
||||
}
|
||||
$this->cache->save('document-key-id-info', $cachedata, 86400*365);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after', $eventname);
|
||||
|
||||
/**
|
||||
* 삭제가 끝난 후 목록페이지로 이동합니다
|
||||
*/
|
||||
$this->session->set_flashdata(
|
||||
'message',
|
||||
'정상적으로 삭제되었습니다'
|
||||
);
|
||||
$param =& $this->querystring;
|
||||
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
|
||||
|
||||
redirect($redirecturl);
|
||||
}
|
||||
}
|
||||
349
application/controllers/admin/page/Faq.php
Normal file
349
application/controllers/admin/page/Faq.php
Normal file
@@ -0,0 +1,349 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Faq class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 관리자>페이지설정>FAQ관리 controller 입니다.
|
||||
*/
|
||||
class Faq extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 관리자 페이지 상의 현재 디렉토리입니다
|
||||
* 페이지 이동시 필요한 정보입니다
|
||||
*/
|
||||
public $pagedir = 'page/faq';
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array('Faq', 'Faq_group');
|
||||
|
||||
/**
|
||||
* 이 컨트롤러의 메인 모델 이름입니다
|
||||
*/
|
||||
protected $modelname = 'Faq_model';
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array', 'dhtml_editor');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/**
|
||||
* 라이브러리를 로딩합니다
|
||||
*/
|
||||
$this->load->library(array('pagination', 'querystring'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록을 가져오는 메소드입니다
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_page_faq_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(
|
||||
'faq_id' => $param->sort('faq_id', 'asc'),
|
||||
'faq_title' => $param->sort('faq_title', 'asc'),
|
||||
'faq_order' => $param->sort('faq_order', 'asc'),
|
||||
'faq_datetime' => $param->sort('faq_datetime', 'asc'),
|
||||
);
|
||||
$findex = $this->input->get('findex', null, 'faq_order');
|
||||
$forder = $this->input->get('forder', null, 'asc');
|
||||
$sfield = $this->input->get('sfield', null, '');
|
||||
$skeyword = $this->input->get('skeyword', null, '');
|
||||
$fgr_id = $this->input->get('fgr_id', null, '');
|
||||
|
||||
$per_page = admin_listnum();
|
||||
$offset = ($page - 1) * $per_page;
|
||||
|
||||
$where = array();
|
||||
if ($fgr_id) {
|
||||
$where = array('fgr_id' => $fgr_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 게시판 목록에 필요한 정보를 가져옵니다.
|
||||
*/
|
||||
$this->{$this->modelname}->allow_search_field = array('faq_id', 'fgr_id', 'faq_title', 'faq_content', 'faq_mobile_content', 'faq_datetime', 'faq.mem_id'); // 검색이 가능한 필드
|
||||
$this->{$this->modelname}->search_field_equal = array('faq_id', 'fgr_id', 'faq.mem_id'); // 검색중 like 가 아닌 = 검색을 하는 필드
|
||||
$this->{$this->modelname}->allow_order_field = array('faq_id', 'faq_title', 'faq_order', 'faq_datetime'); // 정렬이 가능한 필드
|
||||
$result = $this->{$this->modelname}
|
||||
->get_admin_list($per_page, $offset, $where, '', $findex, $forder, $sfield, $skeyword);
|
||||
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)
|
||||
);
|
||||
$result['list'][$key]['faqgroup'] = $this->Faq_group_model->get_one(element('fgr_id', $val));
|
||||
}
|
||||
}
|
||||
|
||||
$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('faq_title' => '제목', 'faq_content' => '내용', 'faq_mobile_content' => '모바일내용', 'faq_datetime' => '날짜');
|
||||
$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('page/faqgroup');
|
||||
$view['view']['write_url'] = admin_url($this->pagedir . '/write?fgr_id=' . $fgr_id);
|
||||
$view['view']['list_delete_url'] = admin_url($this->pagedir . '/listdelete/?' . $param->output());
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$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));
|
||||
}
|
||||
|
||||
/**
|
||||
* 게시판 글쓰기 또는 수정 페이지를 가져오는 메소드입니다
|
||||
*/
|
||||
public function write($pid = 0)
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_page_faq_write';
|
||||
$this->load->event($eventname);
|
||||
|
||||
$view = array();
|
||||
$view['view'] = array();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before'] = Events::trigger('before', $eventname);
|
||||
|
||||
/**
|
||||
* 프라이머리키에 숫자형이 입력되지 않으면 에러처리합니다
|
||||
*/
|
||||
if ($pid) {
|
||||
$pid = (int) $pid;
|
||||
if (empty($pid) OR $pid < 1) {
|
||||
show_404();
|
||||
}
|
||||
}
|
||||
|
||||
$fgr_id = (int) $this->input->get('fgr_id');
|
||||
if (empty($fgr_id) OR $fgr_id < 1) {
|
||||
show_404();
|
||||
}
|
||||
$primary_key = $this->{$this->modelname}->primary_key;
|
||||
|
||||
/**
|
||||
* 수정 페이지일 경우 기존 데이터를 가져옵니다
|
||||
*/
|
||||
if ($pid) {
|
||||
$getdata = $this->{$this->modelname}->get_one($pid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validation 라이브러리를 가져옵니다
|
||||
*/
|
||||
$this->load->library('form_validation');
|
||||
|
||||
/**
|
||||
* 전송된 데이터의 유효성을 체크합니다
|
||||
*/
|
||||
$config = array(
|
||||
array(
|
||||
'field' => 'fgr_id',
|
||||
'label' => 'FAQ그룹',
|
||||
'rules' => 'trim|required|numeric',
|
||||
),
|
||||
array(
|
||||
'field' => 'faq_order',
|
||||
'label' => '정렬순서',
|
||||
'rules' => 'trim|required|numeric',
|
||||
),
|
||||
array(
|
||||
'field' => 'faq_title',
|
||||
'label' => '질문',
|
||||
'rules' => 'trim|required',
|
||||
),
|
||||
array(
|
||||
'field' => 'faq_content',
|
||||
'label' => '답변',
|
||||
'rules' => 'trim|required',
|
||||
),
|
||||
array(
|
||||
'field' => 'faq_mobile_content',
|
||||
'label' => '모바일답변',
|
||||
'rules' => 'trim',
|
||||
),
|
||||
);
|
||||
|
||||
$this->form_validation->set_rules($config);
|
||||
|
||||
|
||||
/**
|
||||
* 유효성 검사를 하지 않는 경우, 또는 유효성 검사에 실패한 경우입니다.
|
||||
* 즉 글쓰기나 수정 페이지를 보고 있는 경우입니다
|
||||
*/
|
||||
if ($this->form_validation->run() === false) {
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['formrunfalse'] = Events::trigger('formrunfalse', $eventname);
|
||||
|
||||
if ($pid) {
|
||||
$view['view']['data'] = $getdata;
|
||||
}
|
||||
$view['view']['data']['faqgroup'] = $this->Faq_group_model->get_one($fgr_id);
|
||||
|
||||
/**
|
||||
* primary key 정보를 저장합니다
|
||||
*/
|
||||
$view['view']['primary_key'] = $primary_key;
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
|
||||
|
||||
/**
|
||||
* 어드민 레이아웃을 정의합니다
|
||||
*/
|
||||
$layoutconfig = array('layout' => 'layout', 'skin' => 'write');
|
||||
$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));
|
||||
|
||||
} else {
|
||||
/**
|
||||
* 유효성 검사를 통과한 경우입니다.
|
||||
* 즉 데이터의 insert 나 update 의 process 처리가 필요한 상황입니다
|
||||
*/
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['formruntrue'] = Events::trigger('formruntrue', $eventname);
|
||||
|
||||
$content_type = $this->cbconfig->item('use_faq_dhtml') ? 1 : 0;
|
||||
$faq_order = $this->input->post('faq_order') ? $this->input->post('faq_order') : 0;
|
||||
|
||||
$updatedata = array(
|
||||
'fgr_id' => $this->input->post('fgr_id', null, 0),
|
||||
'faq_title' => $this->input->post('faq_title', null, ''),
|
||||
'faq_content' => $this->input->post('faq_content', null, ''),
|
||||
'faq_mobile_content' => $this->input->post('faq_mobile_content', null, ''),
|
||||
'faq_content_html_type' => $content_type,
|
||||
'faq_order' => $faq_order,
|
||||
);
|
||||
|
||||
/**
|
||||
* 게시물을 수정하는 경우입니다
|
||||
*/
|
||||
if ($this->input->post($primary_key)) {
|
||||
$this->{$this->modelname}->update($this->input->post($primary_key), $updatedata);
|
||||
$this->session->set_flashdata(
|
||||
'message',
|
||||
'정상적으로 수정되었습니다'
|
||||
);
|
||||
} else {
|
||||
/**
|
||||
* 게시물을 새로 입력하는 경우입니다
|
||||
*/
|
||||
$updatedata['faq_datetime'] = cdate('Y-m-d H:i:s');
|
||||
$updatedata['faq_ip'] = $this->input->ip_address();
|
||||
$updatedata['mem_id'] = $this->member->item('mem_id');
|
||||
$this->{$this->modelname}->insert($updatedata);
|
||||
$this->session->set_flashdata(
|
||||
'message',
|
||||
'정상적으로 입력되었습니다'
|
||||
);
|
||||
}
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after', $eventname);
|
||||
|
||||
/**
|
||||
* 게시물의 신규입력 또는 수정작업이 끝난 후 목록 페이지로 이동합니다
|
||||
*/
|
||||
$param =& $this->querystring;
|
||||
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
|
||||
redirect($redirecturl);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록 페이지에서 선택삭제를 하는 경우 실행되는 메소드입니다
|
||||
*/
|
||||
public function listdelete()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_page_faq_listdelete';
|
||||
$this->load->event($eventname);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('before', $eventname);
|
||||
|
||||
/**
|
||||
* 체크한 게시물의 삭제를 실행합니다
|
||||
*/
|
||||
if ($this->input->post('chk') && is_array($this->input->post('chk'))) {
|
||||
foreach ($this->input->post('chk') as $val) {
|
||||
if ($val) {
|
||||
$this->{$this->modelname}->delete($val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after', $eventname);
|
||||
|
||||
/**
|
||||
* 삭제가 끝난 후 목록페이지로 이동합니다
|
||||
*/
|
||||
$this->session->set_flashdata(
|
||||
'message',
|
||||
'정상적으로 삭제되었습니다'
|
||||
);
|
||||
$param =& $this->querystring;
|
||||
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
|
||||
redirect($redirecturl);
|
||||
}
|
||||
}
|
||||
393
application/controllers/admin/page/Faqgroup.php
Normal file
393
application/controllers/admin/page/Faqgroup.php
Normal file
@@ -0,0 +1,393 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Faqgroup class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 관리자>페이지설정>FAQ관리 controller 입니다.
|
||||
*/
|
||||
class Faqgroup extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 관리자 페이지 상의 현재 디렉토리입니다
|
||||
* 페이지 이동시 필요한 정보입니다
|
||||
*/
|
||||
public $pagedir = 'page/faqgroup';
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array('Faq', 'Faq_group');
|
||||
|
||||
/**
|
||||
* 이 컨트롤러의 메인 모델 이름입니다
|
||||
*/
|
||||
protected $modelname = 'Faq_group_model';
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/**
|
||||
* 라이브러리를 로딩합니다
|
||||
*/
|
||||
$this->load->library(array('pagination', 'querystring'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록을 가져오는 메소드입니다
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_page_faqgroup_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(
|
||||
'fgr_id' => $param->sort('fgr_id', 'asc'),
|
||||
'fgr_title' => $param->sort('fgr_title', 'asc'),
|
||||
'fgr_key' => $param->sort('fgr_key', 'asc'),
|
||||
'fgr_layout' => $param->sort('fgr_layout', 'asc'),
|
||||
'fgr_mobile_layout' => $param->sort('fgr_mobile_layout', 'asc'),
|
||||
'fgr_skin' => $param->sort('fgr_skin', 'asc'),
|
||||
'fgr_mobile_skin' => $param->sort('fgr_mobile_skin', 'asc'),
|
||||
'fgr_datetime' => $param->sort('fgr_datetime', 'asc'),
|
||||
);
|
||||
$findex = $this->input->get('findex') ? $this->input->get('findex') : $this->{$this->modelname}->primary_key;
|
||||
$forder = $this->input->get('forder', null, 'desc');
|
||||
$sfield = $this->input->get('sfield', null, '');
|
||||
$skeyword = $this->input->get('skeyword', null, '');
|
||||
|
||||
$per_page = admin_listnum();
|
||||
$offset = ($page - 1) * $per_page;
|
||||
|
||||
/**
|
||||
* 게시판 목록에 필요한 정보를 가져옵니다.
|
||||
*/
|
||||
$this->{$this->modelname}->allow_search_field = array('fgr_id', 'fgr_key', 'fgr_layout', 'sfield', 'fgr_skin', 'fgr_mobile_skin', 'faq_group.mem_id', 'fgr_title'); // 검색이 가능한 필드
|
||||
$this->{$this->modelname}->search_field_equal = array('fgr_id', 'faq_group.mem_id'); // 검색중 like 가 아닌 = 검색을 하는 필드
|
||||
$this->{$this->modelname}->allow_order_field = array('fgr_id', 'fgr_key', 'fgr_layout', 'fgr_mobile_layout', 'fgr_skin', 'fgr_mobile_skin', 'fgr_datetime'); // 정렬이 가능한 필드
|
||||
$result = $this->{$this->modelname}
|
||||
->get_admin_list($per_page, $offset, '', '', $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)
|
||||
);
|
||||
$countwhere = array(
|
||||
'fgr_id' => element('fgr_id', $val),
|
||||
);
|
||||
$result['list'][$key]['faqcount'] = $this->Faq_model->count_by($countwhere);
|
||||
$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('fgr_title' => '제목', 'fgr_datetime' => '날짜');
|
||||
$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']['write_url'] = admin_url($this->pagedir . '/write');
|
||||
$view['view']['list_delete_url'] = admin_url($this->pagedir . '/listdelete/?' . $param->output());
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$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));
|
||||
}
|
||||
|
||||
/**
|
||||
* 게시판 글쓰기 또는 수정 페이지를 가져오는 메소드입니다
|
||||
*/
|
||||
public function write($pid = 0)
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_page_faqgroup_write';
|
||||
$this->load->event($eventname);
|
||||
|
||||
$view = array();
|
||||
$view['view'] = array();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before'] = Events::trigger('before', $eventname);
|
||||
|
||||
/**
|
||||
* 프라이머리키에 숫자형이 입력되지 않으면 에러처리합니다
|
||||
*/
|
||||
if ($pid) {
|
||||
$pid = (int) $pid;
|
||||
if (empty($pid) OR $pid < 1) {
|
||||
show_404();
|
||||
}
|
||||
}
|
||||
$primary_key = $this->{$this->modelname}->primary_key;
|
||||
|
||||
/**
|
||||
* 수정 페이지일 경우 기존 데이터를 가져옵니다
|
||||
*/
|
||||
$getdata = array();
|
||||
if ($pid) {
|
||||
$getdata = $this->{$this->modelname}->get_one($pid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validation 라이브러리를 가져옵니다
|
||||
*/
|
||||
$this->load->library('form_validation');
|
||||
|
||||
/**
|
||||
* 전송된 데이터의 유효성을 체크합니다
|
||||
*/
|
||||
$config = array(
|
||||
array(
|
||||
'field' => 'fgr_title',
|
||||
'label' => '제목',
|
||||
'rules' => 'trim|required',
|
||||
),
|
||||
array(
|
||||
'field' => 'fgr_layout',
|
||||
'label' => '레이아웃',
|
||||
'rules' => 'trim',
|
||||
),
|
||||
array(
|
||||
'field' => 'fgr_sidebar',
|
||||
'label' => '사이드바 사용',
|
||||
'rules' => 'trim',
|
||||
),
|
||||
array(
|
||||
'field' => 'fgr_skin',
|
||||
'label' => '스킨',
|
||||
'rules' => 'trim',
|
||||
),
|
||||
array(
|
||||
'field' => 'fgr_mobile_layout',
|
||||
'label' => '모바일레이아웃',
|
||||
'rules' => 'trim',
|
||||
),
|
||||
array(
|
||||
'field' => 'fgr_mobile_sidebar',
|
||||
'label' => '모바일사이드바사용',
|
||||
'rules' => 'trim',
|
||||
),
|
||||
array(
|
||||
'field' => 'fgr_mobile_skin',
|
||||
'label' => '모바일스킨',
|
||||
'rules' => 'trim',
|
||||
),
|
||||
);
|
||||
if ($this->input->post($primary_key)) {
|
||||
$config[] = array(
|
||||
'field' => 'fgr_key',
|
||||
'label' => 'FAQ 주소',
|
||||
'rules' => 'trim|required|alpha_dash|min_length[3]|max_length[50]|is_unique[faq_group.fgr_key.fgr_id.' . $getdata['fgr_id'] . ']',
|
||||
);
|
||||
} else {
|
||||
$config[] = array(
|
||||
'field' => 'fgr_key',
|
||||
'label' => 'FAQ 주소',
|
||||
'rules' => 'trim|required|alpha_dash|min_length[3]|max_length[50]|is_unique[faq_group.fgr_key]',
|
||||
);
|
||||
}
|
||||
|
||||
$this->form_validation->set_rules($config);
|
||||
|
||||
|
||||
/**
|
||||
* 유효성 검사를 하지 않는 경우, 또는 유효성 검사에 실패한 경우입니다.
|
||||
* 즉 글쓰기나 수정 페이지를 보고 있는 경우입니다
|
||||
*/
|
||||
if ($this->form_validation->run() === false) {
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['formrunfalse'] = Events::trigger('formrunfalse', $eventname);
|
||||
|
||||
$view['view']['data'] = $getdata;
|
||||
$view['view']['data']['fgr_layout_option'] = get_skin_name(
|
||||
'_layout',
|
||||
set_value('fgr_layout', element('fgr_layout', $getdata)),
|
||||
'기본설정따름'
|
||||
);
|
||||
$view['view']['data']['fgr_mobile_layout_option'] = get_skin_name(
|
||||
'_layout',
|
||||
set_value('fgr_mobile_layout', element('fgr_mobile_layout', $getdata)),
|
||||
'기본설정따름'
|
||||
);
|
||||
$view['view']['data']['fgr_skin_option'] = get_skin_name(
|
||||
'faq',
|
||||
set_value('fgr_skin', element('fgr_skin', $getdata)),
|
||||
'기본설정따름'
|
||||
);
|
||||
$view['view']['data']['fgr_mobile_skin_option'] = get_skin_name(
|
||||
'faq',
|
||||
set_value('fgr_mobile_skin', element('fgr_mobile_skin', $getdata)),
|
||||
'기본설정따름'
|
||||
);
|
||||
|
||||
/**
|
||||
* primary key 정보를 저장합니다
|
||||
*/
|
||||
$view['view']['primary_key'] = $primary_key;
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
|
||||
|
||||
/**
|
||||
* 어드민 레이아웃을 정의합니다
|
||||
*/
|
||||
$layoutconfig = array('layout' => 'layout', 'skin' => 'write');
|
||||
$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));
|
||||
|
||||
} else {
|
||||
/**
|
||||
* 유효성 검사를 통과한 경우입니다.
|
||||
* 즉 데이터의 insert 나 update 의 process 처리가 필요한 상황입니다
|
||||
*/
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['formruntrue'] = Events::trigger('formruntrue', $eventname);
|
||||
|
||||
$fgr_sidebar = $this->input->post('fgr_sidebar') ? $this->input->post('fgr_sidebar') : 0;
|
||||
$fgr_mobile_sidebar = $this->input->post('fgr_mobile_sidebar') ? $this->input->post('fgr_mobile_sidebar') : 0;
|
||||
$updatedata = array(
|
||||
'fgr_title' => $this->input->post('fgr_title', null, ''),
|
||||
'fgr_key' => $this->input->post('fgr_key', null, ''),
|
||||
'fgr_layout' => $this->input->post('fgr_layout', null, ''),
|
||||
'fgr_mobile_layout' => $this->input->post('fgr_mobile_layout', null, ''),
|
||||
'fgr_sidebar' => $fgr_sidebar,
|
||||
'fgr_mobile_sidebar' => $fgr_mobile_sidebar,
|
||||
'fgr_skin' => $this->input->post('fgr_skin', null, ''),
|
||||
'fgr_mobile_skin' => $this->input->post('fgr_mobile_skin', null, ''),
|
||||
);
|
||||
|
||||
/**
|
||||
* 게시물을 수정하는 경우입니다
|
||||
*/
|
||||
if ($this->input->post($primary_key)) {
|
||||
$this->{$this->modelname}->update($this->input->post($primary_key), $updatedata);
|
||||
$this->session->set_flashdata(
|
||||
'message',
|
||||
'정상적으로 수정되었습니다'
|
||||
);
|
||||
} else {
|
||||
/**
|
||||
* 게시물을 새로 입력하는 경우입니다
|
||||
*/
|
||||
$updatedata['fgr_datetime'] = cdate('Y-m-d H:i:s');
|
||||
$updatedata['fgr_ip'] = $this->input->ip_address();
|
||||
$updatedata['mem_id'] = $this->member->item('mem_id');
|
||||
$this->{$this->modelname}->insert($updatedata);
|
||||
$this->session->set_flashdata(
|
||||
'message',
|
||||
'정상적으로 입력되었습니다'
|
||||
);
|
||||
}
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after', $eventname);
|
||||
|
||||
/**
|
||||
* 게시물의 신규입력 또는 수정작업이 끝난 후 목록 페이지로 이동합니다
|
||||
*/
|
||||
$param =& $this->querystring;
|
||||
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
|
||||
redirect($redirecturl);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록 페이지에서 선택삭제를 하는 경우 실행되는 메소드입니다
|
||||
*/
|
||||
public function listdelete()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_page_faqgroup_listdelete';
|
||||
$this->load->event($eventname);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('before', $eventname);
|
||||
|
||||
/**
|
||||
* 체크한 게시물의 삭제를 실행합니다
|
||||
*/
|
||||
if ($this->input->post('chk') && is_array($this->input->post('chk'))) {
|
||||
foreach ($this->input->post('chk') as $val) {
|
||||
if ($val) {
|
||||
$this->{$this->modelname}->delete($val);
|
||||
$deletewhere = array(
|
||||
'fgr_id' => $val,
|
||||
);
|
||||
$this->Faq_model->delete_where($deletewhere);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after', $eventname);
|
||||
|
||||
/**
|
||||
* 삭제가 끝난 후 목록페이지로 이동합니다
|
||||
*/
|
||||
$this->session->set_flashdata(
|
||||
'message',
|
||||
'정상적으로 삭제되었습니다'
|
||||
);
|
||||
$param =& $this->querystring;
|
||||
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
|
||||
redirect($redirecturl);
|
||||
}
|
||||
}
|
||||
316
application/controllers/admin/page/Pagemenu.php
Normal file
316
application/controllers/admin/page/Pagemenu.php
Normal file
@@ -0,0 +1,316 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Pagemenu class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 관리자>페이지설정>메뉴관리 controller 입니다.
|
||||
*/
|
||||
class Pagemenu extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 관리자 페이지 상의 현재 디렉토리입니다
|
||||
* 페이지 이동시 필요한 정보입니다
|
||||
*/
|
||||
public $pagedir = 'page/pagemenu';
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array('Menu');
|
||||
|
||||
/**
|
||||
* 이 컨트롤러의 메인 모델 이름입니다
|
||||
*/
|
||||
protected $modelname = 'Menu_model';
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/**
|
||||
* 라이브러리를 로딩합니다
|
||||
*/
|
||||
$this->load->library(array('querystring'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록을 가져오는 메소드입니다
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_page_pagemenu_index';
|
||||
$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' => 'men_name',
|
||||
'label' => '메뉴명',
|
||||
'rules' => 'trim|required',
|
||||
),
|
||||
array(
|
||||
'field' => 'men_parent',
|
||||
'label' => '메뉴위치',
|
||||
'rules' => 'trim|numeric|is_natural',
|
||||
),
|
||||
array(
|
||||
'field' => 'men_target',
|
||||
'label' => '새창여부',
|
||||
'rules' => 'trim',
|
||||
),
|
||||
array(
|
||||
'field' => 'men_custom',
|
||||
'label' => '커스텀',
|
||||
'rules' => 'trim',
|
||||
),
|
||||
array(
|
||||
'field' => 'men_order',
|
||||
'label' => '순서',
|
||||
'rules' => 'trim|numeric|is_natural',
|
||||
),
|
||||
array(
|
||||
'field' => 'men_desktop',
|
||||
'label' => 'PC사용',
|
||||
'rules' => 'trim',
|
||||
),
|
||||
array(
|
||||
'field' => 'men_mobile',
|
||||
'label' => '모바일사용',
|
||||
'rules' => 'trim',
|
||||
),
|
||||
array(
|
||||
'field' => 'men_link',
|
||||
'label' => '링크주소',
|
||||
'rules' => 'trim|required|prep_url|valid_url',
|
||||
),
|
||||
);
|
||||
$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);
|
||||
|
||||
$men_parent = $this->input->post('men_parent') ? $this->input->post('men_parent') : 0;
|
||||
$men_desktop = $this->input->post('men_desktop') ? $this->input->post('men_desktop') : 0;
|
||||
$men_mobile = $this->input->post('men_mobile') ? $this->input->post('men_mobile') : 0;
|
||||
$men_order = $this->input->post('men_order') ? $this->input->post('men_order') : 0;
|
||||
$updatedata = array(
|
||||
'men_parent' => $men_parent,
|
||||
'men_name' => $this->input->post('men_name', null, ''),
|
||||
'men_link' => $this->input->post('men_link', null, ''),
|
||||
'men_target' => $this->input->post('men_target', null, ''),
|
||||
'men_desktop' => $men_desktop,
|
||||
'men_mobile' => $men_mobile,
|
||||
'men_custom' => $this->input->post('men_custom', null, ''),
|
||||
'men_order' => $men_order,
|
||||
);
|
||||
|
||||
$this->{$this->modelname}->insert($updatedata);
|
||||
$view['view']['alert_message'] = '메뉴가 추가되었습니다';
|
||||
$this->_delete_cache();
|
||||
|
||||
redirect(admin_url('page/pagemenu'), 'refresh');
|
||||
}
|
||||
|
||||
/**
|
||||
* 페이지에 숫자가 아닌 문자가 입력되거나 1보다 작은 숫자가 입력되면 에러 페이지를 보여줍니다.
|
||||
*/
|
||||
$param =& $this->querystring;
|
||||
|
||||
/**
|
||||
* 게시판 목록에 필요한 정보를 가져옵니다.
|
||||
*/
|
||||
$this->{$this->modelname}->allow_order_field = array('men_order'); // 정렬이 가능한 필드
|
||||
$where = array('men_parent' => 0);
|
||||
$result = $this->{$this->modelname}
|
||||
->get_admin_list($per_page = 1000, '', $where, '', $findex = 'men_order', $forder = 'ASC', '', '');
|
||||
if (element('list', $result)) {
|
||||
foreach (element('list', $result) as $key => $val) {
|
||||
$subwhere = array('men_parent' => element('men_id', $val));
|
||||
$subresult = $this->{$this->modelname}
|
||||
->get_admin_list($per_page = 1000, '', $subwhere, '', $findex = 'men_order', $forder = 'ASC', '', '');
|
||||
$result['list'][$key]['subresult'] = $subresult;
|
||||
}
|
||||
}
|
||||
|
||||
$view['view']['data'] = $result;
|
||||
|
||||
/**
|
||||
* primary key 정보를 저장합니다
|
||||
*/
|
||||
$view['view']['primary_key'] = $this->{$this->modelname}->primary_key;
|
||||
|
||||
/**
|
||||
* 쓰기 주소, 삭제 주소등 필요한 주소를 구합니다
|
||||
*/
|
||||
$view['view']['list_update_url'] = admin_url($this->pagedir . '/listupdate/?' . $param->output());
|
||||
$view['view']['list_delete_url'] = admin_url($this->pagedir . '/listdelete/?' . $param->output());
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$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));
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록 페이지에서 선택수정을 하는 경우 실행되는 메소드입니다
|
||||
*/
|
||||
public function listupdate()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_page_pagemenu_listupdate';
|
||||
$this->load->event($eventname);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('before', $eventname);
|
||||
|
||||
/**
|
||||
* 체크한 게시물의 업데이트를 실행합니다
|
||||
*/
|
||||
if ($this->input->post('chk') && is_array($this->input->post('chk'))) {
|
||||
|
||||
$men_name = $this->input->post('men_name');
|
||||
$men_target = $this->input->post('men_target');
|
||||
$men_custom = $this->input->post('men_custom');
|
||||
$men_order = $this->input->post('men_order');
|
||||
$men_desktop = $this->input->post('men_desktop');
|
||||
$men_mobile = $this->input->post('men_mobile');
|
||||
$men_link = $this->input->post('men_link');
|
||||
|
||||
foreach ($this->input->post('chk') as $val) {
|
||||
if ($val) {
|
||||
$men_order_update = element($val, $men_order) ? element($val, $men_order) : 0;
|
||||
$men_desktop_update = element($val, $men_desktop) ? element($val, $men_desktop) : 0;
|
||||
$men_mobile_update = element($val, $men_mobile) ? element($val, $men_mobile) : 0;
|
||||
$updatedata = array(
|
||||
'men_name' => element($val, $men_name),
|
||||
'men_target' => element($val, $men_target),
|
||||
'men_custom' => element($val, $men_custom),
|
||||
'men_order' => $men_order_update,
|
||||
'men_desktop' => $men_desktop_update,
|
||||
'men_mobile' => $men_mobile_update,
|
||||
'men_link' => element($val, $men_link),
|
||||
);
|
||||
$this->{$this->modelname}->update($val, $updatedata);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->_delete_cache();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after', $eventname);
|
||||
|
||||
/**
|
||||
* 업데이트가 끝난 후 목록페이지로 이동합니다
|
||||
*/
|
||||
$this->session->set_flashdata(
|
||||
'message',
|
||||
'정상적으로 수정되었습니다'
|
||||
);
|
||||
$param =& $this->querystring;
|
||||
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
|
||||
|
||||
redirect($redirecturl);
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록 페이지에서 선택삭제를 하는 경우 실행되는 메소드입니다
|
||||
*/
|
||||
public function listdelete()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_page_pagemenu_listdelete';
|
||||
$this->load->event($eventname);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('before', $eventname);
|
||||
|
||||
/**
|
||||
* 체크한 게시물의 삭제를 실행합니다
|
||||
*/
|
||||
if ($this->input->post('chk') && is_array($this->input->post('chk'))) {
|
||||
foreach ($this->input->post('chk') as $val) {
|
||||
if ($val) {
|
||||
$this->{$this->modelname}->delete($val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->_delete_cache();
|
||||
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after', $eventname);
|
||||
|
||||
/**
|
||||
* 삭제가 끝난 후 목록페이지로 이동합니다
|
||||
*/
|
||||
$this->session->set_flashdata(
|
||||
'message',
|
||||
'정상적으로 삭제되었습니다'
|
||||
);
|
||||
$param =& $this->querystring;
|
||||
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
|
||||
|
||||
redirect($redirecturl);
|
||||
}
|
||||
|
||||
/**
|
||||
* 메뉴관련 캐시를 삭제합니다
|
||||
*/
|
||||
public function _delete_cache()
|
||||
{
|
||||
$this->cache->delete('pagemenu-mobile');
|
||||
$this->cache->delete('pagemenu-desktop');
|
||||
}
|
||||
}
|
||||
420
application/controllers/admin/page/Popup.php
Normal file
420
application/controllers/admin/page/Popup.php
Normal file
@@ -0,0 +1,420 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Popup class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 관리자>페이지설정>팝업관리 controller 입니다.
|
||||
*/
|
||||
class Popup extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 관리자 페이지 상의 현재 디렉토리입니다
|
||||
* 페이지 이동시 필요한 정보입니다
|
||||
*/
|
||||
public $pagedir = 'page/popup';
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array('Popup');
|
||||
|
||||
/**
|
||||
* 이 컨트롤러의 메인 모델 이름입니다
|
||||
*/
|
||||
protected $modelname = 'Popup_model';
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array', 'dhtml_editor');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/**
|
||||
* 라이브러리를 로딩합니다
|
||||
*/
|
||||
$this->load->library(array('pagination', 'querystring'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록을 가져오는 메소드입니다
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_page_popup_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(
|
||||
'pop_title' => $param->sort('pop_title', 'asc'),
|
||||
'pop_device' => $param->sort('pop_device', 'asc'),
|
||||
'pop_start_date' => $param->sort('pop_start_date', 'asc'),
|
||||
'pop_end_date' => $param->sort('pop_end_date', 'asc'),
|
||||
'pop_activated' => $param->sort('pop_activated', 'asc'),
|
||||
);
|
||||
$findex = $this->input->get('findex') ? $this->input->get('findex') : $this->{$this->modelname}->primary_key;
|
||||
$forder = $this->input->get('forder', null, 'desc');
|
||||
$sfield = $this->input->get('sfield', null, '');
|
||||
$skeyword = $this->input->get('skeyword', null, '');
|
||||
|
||||
$per_page = admin_listnum();
|
||||
$offset = ($page - 1) * $per_page;
|
||||
|
||||
/**
|
||||
* 게시판 목록에 필요한 정보를 가져옵니다.
|
||||
*/
|
||||
$this->{$this->modelname}->allow_search_field = array('pop_id', 'pop_title', 'pop_content'); // 검색이 가능한 필드
|
||||
$this->{$this->modelname}->search_field_equal = array('pop_id'); // 검색중 like 가 아닌 = 검색을 하는 필드
|
||||
$this->{$this->modelname}->allow_order_field = array('pop_title', 'pop_device', 'pop_start_date', 'pop_end_date', 'pop_activated'); // 정렬이 가능한 필드
|
||||
|
||||
$where = array();
|
||||
if ($this->input->get('pop_activated') === 'Y') {
|
||||
$where['pop_activated'] = '1';
|
||||
}
|
||||
if ($this->input->get('pop_activated') === 'N') {
|
||||
$where['pop_activated'] = '0';
|
||||
}
|
||||
|
||||
$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) {
|
||||
if (empty($val['pop_start_date']) OR $val['pop_start_date'] === '0000-00-00') {
|
||||
$result['list'][$key]['pop_start_date'] = '미지정';
|
||||
}
|
||||
if (empty($val['pop_end_date']) OR $val['pop_end_date'] === '0000-00-00') {
|
||||
$result['list'][$key]['pop_end_date'] = '미지정';
|
||||
}
|
||||
$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('pop_title' => '제목', 'pop_content' => '내용');
|
||||
$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']['write_url'] = admin_url($this->pagedir . '/write');
|
||||
$view['view']['list_delete_url'] = admin_url($this->pagedir . '/listdelete/?' . $param->output());
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$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));
|
||||
}
|
||||
|
||||
/**
|
||||
* 게시판 글쓰기 또는 수정 페이지를 가져오는 메소드입니다
|
||||
*/
|
||||
public function write($pid = 0)
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_page_popup_write';
|
||||
$this->load->event($eventname);
|
||||
|
||||
$view = array();
|
||||
$view['view'] = array();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before'] = Events::trigger('before', $eventname);
|
||||
|
||||
/**
|
||||
* 프라이머리키에 숫자형이 입력되지 않으면 에러처리합니다
|
||||
*/
|
||||
if ($pid) {
|
||||
$pid = (int) $pid;
|
||||
if (empty($pid) OR $pid < 1) {
|
||||
show_404();
|
||||
}
|
||||
}
|
||||
$primary_key = $this->{$this->modelname}->primary_key;
|
||||
|
||||
/**
|
||||
* 수정 페이지일 경우 기존 데이터를 가져옵니다
|
||||
*/
|
||||
$getdata = array();
|
||||
if ($pid) {
|
||||
$getdata = $this->{$this->modelname}->get_one($pid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validation 라이브러리를 가져옵니다
|
||||
*/
|
||||
$this->load->library('form_validation');
|
||||
|
||||
/**
|
||||
* 전송된 데이터의 유효성을 체크합니다
|
||||
*/
|
||||
$config = array(
|
||||
array(
|
||||
'field' => 'pop_title',
|
||||
'label' => '팝업명',
|
||||
'rules' => 'trim|required',
|
||||
),
|
||||
array(
|
||||
'field' => 'pop_start_date',
|
||||
'label' => '팝업시작일',
|
||||
'rules' => 'trim|alpha_dash|exact_length[10]',
|
||||
),
|
||||
array(
|
||||
'field' => 'pop_end_date',
|
||||
'label' => '팝업종료일',
|
||||
'rules' => 'trim|alpha_dash|exact_length[10]',
|
||||
),
|
||||
array(
|
||||
'field' => 'pop_is_center',
|
||||
'label' => '팝업정렬',
|
||||
'rules' => 'trim|required|numeric',
|
||||
),
|
||||
array(
|
||||
'field' => 'pop_left',
|
||||
'label' => '좌측위치',
|
||||
'rules' => 'trim|numeric',
|
||||
),
|
||||
array(
|
||||
'field' => 'pop_top',
|
||||
'label' => '상단위치',
|
||||
'rules' => 'trim|required|numeric',
|
||||
),
|
||||
array(
|
||||
'field' => 'pop_width',
|
||||
'label' => '팝업가로길이',
|
||||
'rules' => 'trim|required|numeric',
|
||||
),
|
||||
array(
|
||||
'field' => 'pop_height',
|
||||
'label' => '팝업세로길이',
|
||||
'rules' => 'trim|required|numeric',
|
||||
),
|
||||
array(
|
||||
'field' => 'pop_device',
|
||||
'label' => '팝업표시기기',
|
||||
'rules' => 'trim|required',
|
||||
),
|
||||
array(
|
||||
'field' => 'pop_page',
|
||||
'label' => '팝업이뜨는페이지',
|
||||
'rules' => 'trim|required|numeric',
|
||||
),
|
||||
array(
|
||||
'field' => 'pop_disable_hours',
|
||||
'label' => '시간',
|
||||
'rules' => 'trim|required|numeric',
|
||||
),
|
||||
array(
|
||||
'field' => 'pop_activated',
|
||||
'label' => '팝업활성화',
|
||||
'rules' => 'trim|required|numeric',
|
||||
),
|
||||
array(
|
||||
'field' => 'pop_content',
|
||||
'label' => '팝업내용',
|
||||
'rules' => 'trim|required',
|
||||
),
|
||||
);
|
||||
|
||||
$this->form_validation->set_rules($config);
|
||||
|
||||
|
||||
/**
|
||||
* 유효성 검사를 하지 않는 경우, 또는 유효성 검사에 실패한 경우입니다.
|
||||
* 즉 글쓰기나 수정 페이지를 보고 있는 경우입니다
|
||||
*/
|
||||
if ($this->form_validation->run() === false) {
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['formrunfalse'] = Events::trigger('formrunfalse', $eventname);
|
||||
|
||||
if ($pid) {
|
||||
if (empty($getdata['pop_start_date']) OR $getdata['pop_start_date'] === '0000-00-00') {
|
||||
$getdata['pop_start_date'] = '';
|
||||
}
|
||||
if (empty($getdata['pop_end_date']) OR $getdata['pop_end_date'] === '0000-00-00') {
|
||||
$getdata['pop_end_date'] = '';
|
||||
}
|
||||
$view['view']['data'] = $getdata;
|
||||
}
|
||||
|
||||
/**
|
||||
* primary key 정보를 저장합니다
|
||||
*/
|
||||
$view['view']['primary_key'] = $primary_key;
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
|
||||
|
||||
/**
|
||||
* 어드민 레이아웃을 정의합니다
|
||||
*/
|
||||
$layoutconfig = array('layout' => 'layout', 'skin' => 'write');
|
||||
$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));
|
||||
|
||||
} else {
|
||||
/**
|
||||
* 유효성 검사를 통과한 경우입니다.
|
||||
* 즉 데이터의 insert 나 update 의 process 처리가 필요한 상황입니다
|
||||
*/
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['formruntrue'] = Events::trigger('formruntrue', $eventname);
|
||||
|
||||
$pop_start_date = $this->input->post('pop_start_date') ? $this->input->post('pop_start_date') : null;
|
||||
$pop_end_date = $this->input->post('pop_end_date') ? $this->input->post('pop_end_date') : null;
|
||||
$pop_is_center = $this->input->post('pop_is_center') ? $this->input->post('pop_is_center') : 0;
|
||||
$pop_left = $this->input->post('pop_left') ? $this->input->post('pop_left') : 0;
|
||||
$pop_top = $this->input->post('pop_top') ? $this->input->post('pop_top') : 0;
|
||||
$pop_width = $this->input->post('pop_width') ? $this->input->post('pop_width') : 0;
|
||||
$pop_height = $this->input->post('pop_height') ? $this->input->post('pop_height') : 0;
|
||||
$content_type = $this->cbconfig->item('use_popup_dhtml') ? 1 : 0;
|
||||
$pop_page = $this->input->post('pop_page') ? $this->input->post('pop_page') : 0;
|
||||
$pop_disable_hours = $this->input->post('pop_disable_hours') ? $this->input->post('pop_disable_hours') : 0;
|
||||
$pop_activated = $this->input->post('pop_activated') ? $this->input->post('pop_activated') : 0;
|
||||
|
||||
$updatedata = array(
|
||||
'pop_title' => $this->input->post('pop_title', null, ''),
|
||||
'pop_start_date' => $pop_start_date,
|
||||
'pop_end_date' => $pop_end_date,
|
||||
'pop_is_center' => $pop_is_center,
|
||||
'pop_left' => $pop_left,
|
||||
'pop_top' => $pop_top,
|
||||
'pop_width' => $pop_width,
|
||||
'pop_height' => $pop_height,
|
||||
'pop_device' => $this->input->post('pop_device', null, ''),
|
||||
'pop_page' => $pop_page,
|
||||
'pop_disable_hours' => $pop_disable_hours,
|
||||
'pop_activated' => $pop_activated,
|
||||
'pop_content' => $this->input->post('pop_content', null, ''),
|
||||
'pop_content_html_type' => $content_type,
|
||||
);
|
||||
|
||||
/**
|
||||
* 게시물을 수정하는 경우입니다
|
||||
*/
|
||||
if ($this->input->post($primary_key)) {
|
||||
$this->{$this->modelname}->update($this->input->post($primary_key), $updatedata);
|
||||
$this->session->set_flashdata(
|
||||
'message',
|
||||
'정상적으로 수정되었습니다'
|
||||
);
|
||||
} else {
|
||||
/**
|
||||
* 게시물을 새로 입력하는 경우입니다
|
||||
*/
|
||||
$updatedata['pop_datetime'] = cdate('Y-m-d H:i:s');
|
||||
$updatedata['pop_ip'] = $this->input->ip_address();
|
||||
$updatedata['mem_id'] = $this->member->item('mem_id');
|
||||
$this->{$this->modelname}->insert($updatedata);
|
||||
$this->session->set_flashdata(
|
||||
'message',
|
||||
'정상적으로 입력되었습니다'
|
||||
);
|
||||
}
|
||||
//오늘 생성된 팝업 캐시를 삭제합니다.
|
||||
$this->cache->delete('popup/popup-info-' . cdate('Y-m-d'));
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after', $eventname);
|
||||
|
||||
/**
|
||||
* 게시물의 신규입력 또는 수정작업이 끝난 후 목록 페이지로 이동합니다
|
||||
*/
|
||||
$param =& $this->querystring;
|
||||
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
|
||||
|
||||
redirect($redirecturl);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록 페이지에서 선택삭제를 하는 경우 실행되는 메소드입니다
|
||||
*/
|
||||
public function listdelete()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_page_popup_listdelete';
|
||||
$this->load->event($eventname);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('before', $eventname);
|
||||
|
||||
/**
|
||||
* 체크한 게시물의 삭제를 실행합니다
|
||||
*/
|
||||
if ($this->input->post('chk') && is_array($this->input->post('chk'))) {
|
||||
foreach ($this->input->post('chk') as $val) {
|
||||
if ($val) {
|
||||
$this->{$this->modelname}->delete($val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//오늘 생성된 팝업 캐시를 삭제합니다.
|
||||
$this->cache->delete('popup/popup-info-' . cdate('Y-m-d'));
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after', $eventname);
|
||||
|
||||
/**
|
||||
* 삭제가 끝난 후 목록페이지로 이동합니다
|
||||
*/
|
||||
$this->session->set_flashdata(
|
||||
'message',
|
||||
'정상적으로 삭제되었습니다'
|
||||
);
|
||||
$param =& $this->querystring;
|
||||
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
|
||||
|
||||
redirect($redirecturl);
|
||||
}
|
||||
}
|
||||
302
application/controllers/admin/stat/Boardcounter.php
Normal file
302
application/controllers/admin/stat/Boardcounter.php
Normal file
@@ -0,0 +1,302 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Boardcounter class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 관리자>통계관리>게시판별접속자 controller 입니다.
|
||||
*/
|
||||
class Boardcounter extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 관리자 페이지 상의 현재 디렉토리입니다
|
||||
* 페이지 이동시 필요한 정보입니다
|
||||
*/
|
||||
public $pagedir = 'stat/boardcounter';
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array('Stat_count_board', 'Board');
|
||||
|
||||
/**
|
||||
* 이 컨트롤러의 메인 모델 이름입니다
|
||||
*/
|
||||
protected $modelname = 'Stat_count_board_model';
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/**
|
||||
* 라이브러리를 로딩합니다
|
||||
*/
|
||||
$this->load->library(array('querystring'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록을 가져오는 메소드입니다
|
||||
*/
|
||||
public function index($export = '')
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_stat_boardcounter_index';
|
||||
$this->load->event($eventname);
|
||||
|
||||
$view = array();
|
||||
$view['view'] = array();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before'] = Events::trigger('before', $eventname);
|
||||
|
||||
$param =& $this->querystring;
|
||||
$datetype = $this->input->get('datetype', null, 'd');
|
||||
if ($datetype !== 'm' && $datetype !== 'y') {
|
||||
$datetype = 'd';
|
||||
}
|
||||
$start_date = $this->input->get('start_date') ? $this->input->get('start_date') : cdate('Y-m-01');
|
||||
$end_date = $this->input->get('end_date') ? $this->input->get('end_date') : cdate('Y-m-d');
|
||||
if ($datetype === 'y' OR $datetype === 'm') {
|
||||
$start_year = substr($start_date, 0, 4);
|
||||
$end_year = substr($end_date, 0, 4);
|
||||
}
|
||||
if ($datetype === 'm') {
|
||||
$start_month = substr($start_date, 5, 2);
|
||||
$end_month = substr($end_date, 5, 2);
|
||||
$start_year_month = $start_year * 12 + $start_month;
|
||||
$end_year_month = $end_year * 12 + $end_month;
|
||||
}
|
||||
|
||||
$orderby = (strtolower($this->input->get('orderby')) === 'desc') ? 'desc' : 'asc';
|
||||
|
||||
$brd_id = $this->input->get('brd_id', null, '');
|
||||
|
||||
$result = $this->{$this->modelname}->get_board_count($datetype, $start_date, $end_date, $brd_id, $orderby);
|
||||
|
||||
$sum_count = 0;
|
||||
$arr = array();
|
||||
$_day = array();
|
||||
$_brd = array();
|
||||
$max = 0;
|
||||
if ($result && is_array($result)) {
|
||||
foreach ($result as $key => $value) {
|
||||
$s = element('day', $value) . '_' . element('brd_id', $value);
|
||||
if ( ! isset($arr[$s])) {
|
||||
$arr[$s] = 0;
|
||||
}
|
||||
$arr[$s] += element('scb_count', $value);
|
||||
if ( ! isset($_day[$s])) {
|
||||
$_day[$s] = element('day', $value);
|
||||
}
|
||||
if ( ! isset($_brd[$s])) {
|
||||
$brdresult = $this->board->item_id('brd_name', element('brd_id', $value));
|
||||
$_brd[$s] = $brdresult ? $brdresult : '-';
|
||||
}
|
||||
if (element('scb_count', $value) > $max) {
|
||||
$max = element('scb_count', $value);
|
||||
}
|
||||
$sum_count += element('scb_count', $value);
|
||||
}
|
||||
}
|
||||
|
||||
$result = array();
|
||||
$result2 = array();
|
||||
$i = 0;
|
||||
$save_count = -1;
|
||||
$tot_count = 0;
|
||||
|
||||
if (count($arr)) {
|
||||
foreach ($arr as $key => $value) {
|
||||
$count = (int) $arr[$key];
|
||||
$result[$key]['count'] = $count;
|
||||
$i++;
|
||||
if ($save_count !== $count) {
|
||||
$no = $i;
|
||||
$save_count = $count;
|
||||
}
|
||||
$result[$key]['day'] = $_day[$key];
|
||||
$result[$key]['boardname'] = $_brd[$key];
|
||||
$rate = ($count / $sum_count * 100);
|
||||
$result[$key]['rate'] = $rate;
|
||||
$s_rate = number_format($rate, 1);
|
||||
$result[$key]['s_rate'] = $s_rate;
|
||||
|
||||
$bar = (int)($count / $max * 100);
|
||||
$result[$key]['bar'] = $bar;
|
||||
}
|
||||
$view['view']['max_value'] = $max;
|
||||
$view['view']['sum_count'] = $sum_count;
|
||||
}
|
||||
|
||||
$view['view']['boardlist'] = $boardlist = $this->Board_model->get_board_list();
|
||||
|
||||
$result2 = array();
|
||||
|
||||
if ($datetype === 'y') {
|
||||
for ($i = $start_year; $i <= $end_year; $i++) {
|
||||
if ($boardlist) {
|
||||
foreach ($boardlist as $bkey => $bval) {
|
||||
if( ! isset($result[$i . '_' . element('brd_id', $bval)])) $result[$i . '_' . element('brd_id', $bval)] = '';
|
||||
}
|
||||
}
|
||||
if( ! isset($result2[$i])) $result2[$i] = '1';
|
||||
}
|
||||
} elseif ($datetype === 'm') {
|
||||
for ($i = $start_year_month; $i <= $end_year_month; $i++) {
|
||||
$year = floor($i / 12);
|
||||
if ($year * 12 == $i) $year--;
|
||||
$month = sprintf("%02d", ($i - ($year * 12)));
|
||||
$date = $year . '-' . $month;
|
||||
if ($boardlist) {
|
||||
foreach ($boardlist as $bkey => $bval) {
|
||||
if( ! isset($result[$date . '_' . element('brd_id', $bval)])) $result[$date . '_' . element('brd_id', $bval)] = '';
|
||||
}
|
||||
}
|
||||
if( ! isset($result2[$date])) $result2[$date] = '1';
|
||||
}
|
||||
} elseif ($datetype === 'd') {
|
||||
$date = $start_date;
|
||||
while ($date <= $end_date) {
|
||||
if ($boardlist) {
|
||||
foreach ($boardlist as $bkey => $bval) {
|
||||
if( ! isset($result[$date . '_' . element('brd_id', $bval)])) $result[$date . '_' . element('brd_id', $bval)] = '';
|
||||
}
|
||||
}
|
||||
if( ! isset($result2[$date])) $result2[$date] = '1';
|
||||
$date = cdate('Y-m-d', strtotime($date) + 86400);
|
||||
}
|
||||
}
|
||||
|
||||
if ($orderby === 'desc') {
|
||||
krsort($result);
|
||||
} else {
|
||||
ksort($result);
|
||||
}
|
||||
|
||||
$view['view']['list'] = $result;
|
||||
$view['view']['list_date'] = $result2;
|
||||
|
||||
$view['view']['start_date'] = $start_date;
|
||||
$view['view']['end_date'] = $end_date;
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
|
||||
|
||||
if ($export === 'excel') {
|
||||
|
||||
header('Content-type: application/vnd.ms-excel');
|
||||
header('Content-Disposition: attachment; filename=게시판별접속자_' . cdate('Y_m_d') . '.xls');
|
||||
echo $this->load->view('admin/' . ADMIN_SKIN . '/' . $this->pagedir . '/index_excel', $view, true);
|
||||
|
||||
} else {
|
||||
/**
|
||||
* 어드민 레이아웃을 정의합니다
|
||||
*/
|
||||
$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));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 오래된 링크클릭로그삭제 페이지입니다
|
||||
*/
|
||||
public function cleanlog()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_stat_boardcounter_cleanlog';
|
||||
$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(
|
||||
'scb_date <=' => $this->input->post('criterion'),
|
||||
);
|
||||
$this->Stat_count_board_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', ctimestamp() - $this->input->post('day') * 24 * 60 * 60);
|
||||
$countwhere = array(
|
||||
'scb_date <=' => $criterion,
|
||||
);
|
||||
$log_count = $this->Stat_count_board_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' => 'cleanlog');
|
||||
$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));
|
||||
}
|
||||
}
|
||||
171
application/controllers/admin/stat/Currentvisitor.php
Normal file
171
application/controllers/admin/stat/Currentvisitor.php
Normal file
@@ -0,0 +1,171 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Currentvisitor class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 관리자>통계관리>현재접속자 controller 입니다.
|
||||
*/
|
||||
class Currentvisitor extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 관리자 페이지 상의 현재 디렉토리입니다
|
||||
* 페이지 이동시 필요한 정보입니다
|
||||
*/
|
||||
public $pagedir = 'stat/currentvisitor';
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array('Currentvisitor');
|
||||
|
||||
/**
|
||||
* 이 컨트롤러의 메인 모델 이름입니다
|
||||
*/
|
||||
protected $modelname = 'Currentvisitor_model';
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/**
|
||||
* 라이브러리를 로딩합니다
|
||||
*/
|
||||
$this->load->library(array('pagination', 'querystring'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록을 가져오는 메소드입니다
|
||||
*/
|
||||
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));
|
||||
}
|
||||
}
|
||||
184
application/controllers/admin/stat/Registercounter.php
Normal file
184
application/controllers/admin/stat/Registercounter.php
Normal file
@@ -0,0 +1,184 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Registercounter class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 관리자>통계관리>회원가입통계 controller 입니다.
|
||||
*/
|
||||
class Registercounter extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 관리자 페이지 상의 현재 디렉토리입니다
|
||||
* 페이지 이동시 필요한 정보입니다
|
||||
*/
|
||||
public $pagedir = 'stat/registercounter';
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array();
|
||||
|
||||
/**
|
||||
* 이 컨트롤러의 메인 모델 이름입니다
|
||||
*/
|
||||
protected $modelname = 'Member_model';
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/**
|
||||
* 라이브러리를 로딩합니다
|
||||
*/
|
||||
$this->load->library(array('querystring'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록을 가져오는 메소드입니다
|
||||
*/
|
||||
public function index($export = '')
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_stat_registercounter_index';
|
||||
$this->load->event($eventname);
|
||||
|
||||
$view = array();
|
||||
$view['view'] = array();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before'] = Events::trigger('before', $eventname);
|
||||
|
||||
$param =& $this->querystring;
|
||||
$datetype = $this->input->get('datetype', null, 'd');
|
||||
if ($datetype !== 'm' && $datetype !== 'y') {
|
||||
$datetype = 'd';
|
||||
}
|
||||
$start_date = $this->input->get('start_date') ? $this->input->get('start_date') : cdate('Y-m-01');
|
||||
$end_date = $this->input->get('end_date') ? $this->input->get('end_date') : cdate('Y-m-d');
|
||||
if ($datetype === 'y' OR $datetype === 'm') {
|
||||
$start_year = substr($start_date, 0, 4);
|
||||
$end_year = substr($end_date, 0, 4);
|
||||
}
|
||||
if ($datetype === 'm') {
|
||||
$start_month = substr($start_date, 5, 2);
|
||||
$end_month = substr($end_date, 5, 2);
|
||||
$start_year_month = $start_year * 12 + $start_month;
|
||||
$end_year_month = $end_year * 12 + $end_month;
|
||||
}
|
||||
$orderby = (strtolower($this->input->get('orderby')) === 'desc') ? 'desc' : 'asc';
|
||||
|
||||
$result = $this->{$this->modelname}->get_register_count($datetype, $start_date, $end_date, $orderby);
|
||||
$sum_count = 0;
|
||||
$arr = array();
|
||||
$max = 0;
|
||||
|
||||
if ($result && is_array($result)) {
|
||||
foreach ($result as $key => $value) {
|
||||
$s = element('day', $value);
|
||||
if ( ! isset($arr[$s])) {
|
||||
$arr[$s] = 0;
|
||||
}
|
||||
$arr[$s] += element('cnt', $value);
|
||||
|
||||
if ($arr[$s] > $max) {
|
||||
$max = $arr[$s];
|
||||
}
|
||||
$sum_count += element('cnt', $value);
|
||||
}
|
||||
}
|
||||
|
||||
$result = array();
|
||||
$i = 0;
|
||||
$save_count = -1;
|
||||
$tot_count = 0;
|
||||
|
||||
if (count($arr)) {
|
||||
foreach ($arr as $key => $value) {
|
||||
$count = (int) $arr[$key];
|
||||
$result[$key]['count'] = $count;
|
||||
$i++;
|
||||
if ($save_count !== $count) {
|
||||
$no = $i;
|
||||
$save_count = $count;
|
||||
}
|
||||
$result[$key]['no'] = $no;
|
||||
|
||||
$result[$key]['key'] = $key;
|
||||
$rate = ($count / $sum_count * 100);
|
||||
$result[$key]['rate'] = $rate;
|
||||
$s_rate = number_format($rate, 1);
|
||||
$result[$key]['s_rate'] = $s_rate;
|
||||
|
||||
$bar = (int)($count / $max * 100);
|
||||
$result[$key]['bar'] = $bar;
|
||||
}
|
||||
$view['view']['max_value'] = $max;
|
||||
$view['view']['sum_count'] = $sum_count;
|
||||
}
|
||||
|
||||
if ($datetype === 'y') {
|
||||
for ($i = $start_year; $i <= $end_year; $i++) {
|
||||
if( ! isset($result[$i])) $result[$i] = '';
|
||||
}
|
||||
} elseif ($datetype === 'm') {
|
||||
for ($i = $start_year_month; $i <= $end_year_month; $i++) {
|
||||
$year = floor($i / 12);
|
||||
if ($year * 12 == $i) $year--;
|
||||
$month = sprintf("%02d", ($i - ($year * 12)));
|
||||
$date = $year . '-' . $month;
|
||||
if( ! isset($result[$date])) $result[$date] = '';
|
||||
}
|
||||
} elseif ($datetype === 'd') {
|
||||
$date = $start_date;
|
||||
while ($date <= $end_date) {
|
||||
if( ! isset($result[$date])) $result[$date] = '';
|
||||
$date = cdate('Y-m-d', strtotime($date) + 86400);
|
||||
}
|
||||
}
|
||||
|
||||
if ($orderby === 'desc') {
|
||||
krsort($result);
|
||||
} else {
|
||||
ksort($result);
|
||||
}
|
||||
|
||||
$view['view']['list'] = $result;
|
||||
|
||||
$view['view']['start_date'] = $start_date;
|
||||
$view['view']['end_date'] = $end_date;
|
||||
$view['view']['datetype'] = $datetype;
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
|
||||
|
||||
if ($export === 'excel') {
|
||||
|
||||
header('Content-type: application/vnd.ms-excel');
|
||||
header('Content-Disposition: attachment; filename=회원가입통계_' . cdate('Y_m_d') . '.xls');
|
||||
echo $this->load->view('admin/' . ADMIN_SKIN . '/' . $this->pagedir . '/index_excel', $view, true);
|
||||
|
||||
} else {
|
||||
/**
|
||||
* 어드민 레이아웃을 정의합니다
|
||||
*/
|
||||
$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));
|
||||
}
|
||||
}
|
||||
}
|
||||
261
application/controllers/admin/stat/Registerlog.php
Normal file
261
application/controllers/admin/stat/Registerlog.php
Normal file
@@ -0,0 +1,261 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Registerlog class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 관리자>통계관리>회원가입경로 controller 입니다.
|
||||
*/
|
||||
class Registerlog extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 관리자 페이지 상의 현재 디렉토리입니다
|
||||
* 페이지 이동시 필요한 정보입니다
|
||||
*/
|
||||
public $pagedir = 'stat/registerlog';
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array('Member_register');
|
||||
|
||||
/**
|
||||
* 이 컨트롤러의 메인 모델 이름입니다
|
||||
*/
|
||||
protected $modelname = 'Member_register_model';
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/**
|
||||
* 라이브러리를 로딩합니다
|
||||
*/
|
||||
$this->load->library(array('pagination', 'querystring'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록을 가져오는 메소드입니다
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_stat_registerlog_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;
|
||||
$findex = $this->input->get('findex') ? $this->input->get('findex') : $this->{$this->modelname}->primary_key;
|
||||
$forder = $this->input->get('forder', null, 'desc');
|
||||
$sfield = $this->input->get('sfield', null, '');
|
||||
$skeyword = $this->input->get('skeyword', null, '');
|
||||
|
||||
$per_page = admin_listnum();
|
||||
$offset = ($page - 1) * $per_page;
|
||||
|
||||
/**
|
||||
* 게시판 목록에 필요한 정보를 가져옵니다.
|
||||
*/
|
||||
$this->{$this->modelname}->allow_search_field = array('mrg_id', 'member_register.mem_id', 'mrg_ip', 'mrg_datetime', 'mrg_recommend_mem_id', 'mrg_useragent', 'mrg_referer'); // 검색이 가능한 필드
|
||||
$this->{$this->modelname}->search_field_equal = array('mrg_id', 'member_register.mem_id', 'mrg_recommend_mem_id'); // 검색중 like 가 아닌 = 검색을 하는 필드
|
||||
$this->{$this->modelname}->allow_order_field = array('mrg_id'); // 정렬이 가능한 필드
|
||||
$result = $this->{$this->modelname}
|
||||
->get_admin_list($per_page, $offset, '', '', $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('mrg_recommend_mem_id', $val)) {
|
||||
$result['list'][$key]['recommend'] = $recommend
|
||||
= $this->Member_model->get_by_memid(element('mrg_recommend_mem_id', $val), 'mem_id, mem_userid, mem_nickname, mem_icon');
|
||||
$result['list'][$key]['recommend_display_name'] = display_username(
|
||||
element('mem_userid', $recommend),
|
||||
element('mem_nickname', $recommend),
|
||||
element('mem_icon', $recommend)
|
||||
);
|
||||
}
|
||||
if (element('mrg_useragent', $val)) {
|
||||
$userAgent = get_useragent_info(element('mrg_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('mrg_ip' => '아이피', 'mrg_datetime' => '날짜', 'mrg_useragent' => '운영체제/브라우저', 'mrg_referer' => '접속경로');
|
||||
$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));
|
||||
}
|
||||
|
||||
/**
|
||||
* 회원가입경로를을 그래프 형식으로 보는 페이지입니다
|
||||
*/
|
||||
public function graph($export = '')
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_stat_registerlog_graph';
|
||||
$this->load->event($eventname);
|
||||
|
||||
$view = array();
|
||||
$view['view'] = array();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before'] = Events::trigger('before', $eventname);
|
||||
|
||||
$param =& $this->querystring;
|
||||
$start_date = $this->input->get('start_date') ? $this->input->get('start_date') : cdate('Y-m-01');
|
||||
$end_date = $this->input->get('end_date') ? $this->input->get('end_date') : cdate('Y-m-d');
|
||||
|
||||
$result = $this->{$this->modelname}->get_graph($start_date, $end_date);
|
||||
$sum_count = 0;
|
||||
$arr = array();
|
||||
$max = 0;
|
||||
|
||||
if ($result && is_array($result)) {
|
||||
foreach ($result as $key => $value) {
|
||||
|
||||
preg_match(
|
||||
"/^http[s]*:\/\/([\.\-\_0-9a-zA-Z]*)\//",
|
||||
element('mrg_referer', $value),
|
||||
$match
|
||||
);
|
||||
|
||||
$s = $match ? $match[1] : '-';
|
||||
$s = preg_replace(
|
||||
"/^(www\.|search\.|dirsearch\.|dir\.search\.|dir\.|kr\.search\.|myhome\.)(.*)/",
|
||||
"\\2",
|
||||
$s
|
||||
);
|
||||
if ( ! isset($arr[$s])) {
|
||||
$arr[$s] = 0;
|
||||
}
|
||||
$arr[$s]++;
|
||||
|
||||
if ($arr[$s] > $max) {
|
||||
$max = $arr[$s];
|
||||
}
|
||||
$sum_count++;
|
||||
}
|
||||
}
|
||||
|
||||
$view['view']['list'] = array();
|
||||
$i = 0;
|
||||
$k = 0;
|
||||
$save_count = -1;
|
||||
|
||||
if (count($arr)) {
|
||||
arsort($arr);
|
||||
foreach ($arr as $key => $value) {
|
||||
$count = (int) $arr[$key];
|
||||
$view['view']['list'][$k]['count'] = $count;
|
||||
$i++;
|
||||
if ($save_count !== $count) {
|
||||
$no = $i;
|
||||
$save_count = $count;
|
||||
}
|
||||
$view['view']['list'][$k]['no'] = $no;
|
||||
|
||||
if ($key === '-') {
|
||||
$key = '직접';
|
||||
}
|
||||
$view['view']['list'][$k]['key'] = $key;
|
||||
$rate = ($count / $sum_count * 100);
|
||||
$view['view']['list'][$k]['rate'] = $rate;
|
||||
$s_rate = number_format($rate, 1);
|
||||
$view['view']['list'][$k]['s_rate'] = $s_rate;
|
||||
|
||||
$bar = (int)($count / $max * 100);
|
||||
$view['view']['list'][$k]['bar'] = $bar;
|
||||
|
||||
$k++;
|
||||
}
|
||||
$view['view']['max_value'] = $max;
|
||||
$view['view']['sum_count'] = $sum_count;
|
||||
}
|
||||
|
||||
$view['view']['start_date'] = $start_date;
|
||||
$view['view']['end_date'] = $end_date;
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
|
||||
|
||||
if ($export === 'excel') {
|
||||
|
||||
header('Content-type: application/vnd.ms-excel');
|
||||
header('Content-Disposition: attachment; filename=회원가입경로_' . cdate('Y_m_d') . '.xls');
|
||||
echo $this->load->view('admin/' . ADMIN_SKIN . '/' . $this->pagedir . '/graph_excel', $view, true);
|
||||
|
||||
} else {
|
||||
/**
|
||||
* 어드민 레이아웃을 정의합니다
|
||||
*/
|
||||
$layoutconfig = array('layout' => 'layout', 'skin' => 'graph');
|
||||
$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));
|
||||
}
|
||||
}
|
||||
}
|
||||
365
application/controllers/admin/stat/Searchkeyword.php
Normal file
365
application/controllers/admin/stat/Searchkeyword.php
Normal file
@@ -0,0 +1,365 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Searchkeyword class
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 관리자>통계관리>인기검색어현황 controller 입니다.
|
||||
*/
|
||||
class Searchkeyword extends CB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 관리자 페이지 상의 현재 디렉토리입니다
|
||||
* 페이지 이동시 필요한 정보입니다
|
||||
*/
|
||||
public $pagedir = 'stat/searchkeyword';
|
||||
|
||||
/**
|
||||
* 모델을 로딩합니다
|
||||
*/
|
||||
protected $models = array('Search_keyword');
|
||||
|
||||
/**
|
||||
* 이 컨트롤러의 메인 모델 이름입니다
|
||||
*/
|
||||
protected $modelname = 'Search_keyword_model';
|
||||
|
||||
/**
|
||||
* 헬퍼를 로딩합니다
|
||||
*/
|
||||
protected $helpers = array('form', 'array');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/**
|
||||
* 라이브러리를 로딩합니다
|
||||
*/
|
||||
$this->load->library(array('pagination', 'querystring'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록을 가져오는 메소드입니다
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_stat_searchkeyword_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(
|
||||
'sek_id' => $param->sort('sek_id', 'asc'),
|
||||
'sek_keyword' => $param->sort('sek_keyword', 'asc'),
|
||||
'sek_datetime' => $param->sort('sek_datetime', 'asc'),
|
||||
'sek_ip' => $param->sort('sek_ip', 'asc'),
|
||||
);
|
||||
$findex = $this->input->get('findex') ? $this->input->get('findex') : $this->{$this->modelname}->primary_key;
|
||||
$forder = $this->input->get('forder', null, 'desc');
|
||||
$sfield = $this->input->get('sfield', null, '');
|
||||
$skeyword = $this->input->get('skeyword', null, '');
|
||||
|
||||
$per_page = admin_listnum();
|
||||
$offset = ($page - 1) * $per_page;
|
||||
|
||||
/**
|
||||
* 게시판 목록에 필요한 정보를 가져옵니다.
|
||||
*/
|
||||
$this->{$this->modelname}->allow_search_field = array('sek_id', 'sek_keyword', 'sek_datetime', 'sek_ip', 'search_keyword.mem_id'); // 검색이 가능한 필드
|
||||
$this->{$this->modelname}->search_field_equal = array('sek_id', 'search_keyword.mem_id'); // 검색중 like 가 아닌 = 검색을 하는 필드
|
||||
$this->{$this->modelname}->allow_order_field = array('sek_id', 'sek_keyword', 'sek_datetime', 'sek_ip'); // 정렬이 가능한 필드
|
||||
$result = $this->{$this->modelname}
|
||||
->get_admin_list($per_page, $offset, '', '', $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)
|
||||
);
|
||||
$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('sek_keyword' => '검색어', 'sek_datetime' => '날짜', 'sek_ip' => '아이피');
|
||||
$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']['list_delete_url'] = admin_url($this->pagedir . '/listdelete/?' . $param->output());
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$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));
|
||||
}
|
||||
|
||||
/**
|
||||
* 인기검색어 현황을 그래프 형식으로 보는 페이지입니다
|
||||
*/
|
||||
public function rank($export = '')
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_stat_searchkeyword_rank';
|
||||
$this->load->event($eventname);
|
||||
|
||||
$view = array();
|
||||
$view['view'] = array();
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before'] = Events::trigger('before', $eventname);
|
||||
|
||||
$param =& $this->querystring;
|
||||
$start_date = $this->input->get('start_date') ? $this->input->get('start_date') : cdate('Y-m-01');
|
||||
$end_date = $this->input->get('end_date') ? $this->input->get('end_date') : cdate('Y-m-d');
|
||||
|
||||
$result = $this->{$this->modelname}->get_rank($start_date, $end_date);
|
||||
|
||||
$sum_count = 0;
|
||||
$arr = array();
|
||||
$max = 0;
|
||||
|
||||
if ($result && is_array($result)) {
|
||||
foreach ($result as $key => $value) {
|
||||
$s = element('sek_keyword', $value);
|
||||
if ( ! isset($arr[$s])) {
|
||||
$arr[$s] = 0;
|
||||
}
|
||||
$arr[$s]++;
|
||||
|
||||
if ($arr[$s] > $max) {
|
||||
$max = $arr[$s];
|
||||
}
|
||||
$sum_count++;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$view['view']['list'] = array();
|
||||
$i = 0;
|
||||
$k = 0;
|
||||
$save_count = -1;
|
||||
$tot_count = 0;
|
||||
|
||||
if (count($arr)) {
|
||||
arsort($arr);
|
||||
foreach ($arr as $key => $value) {
|
||||
$count = (int) $arr[$key];
|
||||
$view['view']['list'][$k]['count'] = $count;
|
||||
$i++;
|
||||
if ($save_count !== $count) {
|
||||
$no = $i;
|
||||
$save_count = $count;
|
||||
}
|
||||
$view['view']['list'][$k]['no'] = $no;
|
||||
|
||||
$view['view']['list'][$k]['key'] = $key;
|
||||
$rate = ($count / $sum_count * 100);
|
||||
$view['view']['list'][$k]['rate'] = $rate;
|
||||
$s_rate = number_format($rate, 1);
|
||||
$view['view']['list'][$k]['s_rate'] = $s_rate;
|
||||
|
||||
$bar = (int)($count / $max * 100);
|
||||
$view['view']['list'][$k]['bar'] = $bar;
|
||||
$k++;
|
||||
}
|
||||
|
||||
$view['view']['max_value'] = $max;
|
||||
$view['view']['sum_count'] = $sum_count;
|
||||
}
|
||||
|
||||
$view['view']['start_date'] = $start_date;
|
||||
$view['view']['end_date'] = $end_date;
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
$view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname);
|
||||
|
||||
if ($export === 'excel') {
|
||||
|
||||
header('Content-type: application/vnd.ms-excel');
|
||||
header('Content-Disposition: attachment; filename=인기검색어_' . cdate('Y_m_d') . '.xls');
|
||||
echo $this->load->view('admin/' . ADMIN_SKIN . '/' . $this->pagedir . '/rank_excel', $view, true);
|
||||
|
||||
} else {
|
||||
/**
|
||||
* 어드민 레이아웃을 정의합니다
|
||||
*/
|
||||
$layoutconfig = array('layout' => 'layout', 'skin' => 'rank');
|
||||
$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));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록 페이지에서 선택삭제를 하는 경우 실행되는 메소드입니다
|
||||
*/
|
||||
public function listdelete()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_stat_searchkeyword_listdelete';
|
||||
$this->load->event($eventname);
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('before', $eventname);
|
||||
|
||||
/**
|
||||
* 체크한 게시물의 삭제를 실행합니다
|
||||
*/
|
||||
if ($this->input->post('chk') && is_array($this->input->post('chk'))) {
|
||||
foreach ($this->input->post('chk') as $val) {
|
||||
if ($val) {
|
||||
$this->{$this->modelname}->delete($val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 이벤트가 존재하면 실행합니다
|
||||
Events::trigger('after', $eventname);
|
||||
|
||||
/**
|
||||
* 삭제가 끝난 후 목록페이지로 이동합니다
|
||||
*/
|
||||
$this->session->set_flashdata(
|
||||
'message',
|
||||
'정상적으로 삭제되었습니다'
|
||||
);
|
||||
$param =& $this->querystring;
|
||||
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
|
||||
redirect($redirecturl);
|
||||
}
|
||||
|
||||
/**
|
||||
* 오래된 링크클릭로그삭제 페이지입니다
|
||||
*/
|
||||
public function cleanlog()
|
||||
{
|
||||
// 이벤트 라이브러리를 로딩합니다
|
||||
$eventname = 'event_admin_stat_searchkeyword_cleanlog';
|
||||
$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(
|
||||
'sek_datetime <=' => $this->input->post('criterion'),
|
||||
);
|
||||
$this->Search_keyword_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(
|
||||
'sek_datetime <=' => $criterion,
|
||||
);
|
||||
$log_count = $this->Search_keyword_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' => 'cleanlog');
|
||||
$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));
|
||||
}
|
||||
}
|
||||
1132
application/controllers/admin/stat/Statcounter.php
Normal file
1132
application/controllers/admin/stat/Statcounter.php
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user