Initial import from local backup (Documents-Playground/pakerpale)

This commit is contained in:
jeonghwa
2026-07-03 05:27:41 +09:00
commit 5b1bfe3390
2223 changed files with 561621 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Autologin model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Autologin_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'autologin';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'aul_id'; // 사용되는 테이블의 프라이머리키
function __construct()
{
parent::__construct();
}
}

View File

@@ -0,0 +1,58 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Banner Click Log model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Banner_click_log_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'banner_click_log';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'bcl_id'; // 사용되는 테이블의 프라이머리키
function __construct()
{
parent::__construct();
}
public function get_admin_list($limit = '', $offset = '', $where = '', $like = '', $findex = '', $forder = '', $sfield = '', $skeyword = '', $sop = 'OR')
{
$select = 'banner_click_log.*, banner.bng_name, banner.ban_title, banner.ban_datetime, banner.ban_hit, banner.ban_image, banner.ban_url';
$join[] = array('table' => 'banner', 'on' => 'banner_click_log.ban_id = banner.ban_id', 'type' => 'inner');
$result = $this->_get_list_common($select, $join, $limit, $offset, $where, $like, $findex, $forder, $sfield, $skeyword, $sop);
return $result;
}
public function get_banner_click_count($type = 'd', $start_date = '', $end_date = '', $orderby = 'asc')
{
if (empty($start_date) OR empty($end_date)) {
return false;
}
$left = ($type === 'y') ? 4 : ($type === 'm' ? 7 : 10);
if (strtolower($orderby) !== 'desc') $orderby = 'asc';
$this->db->select('count(*) as cnt, left(bcl_datetime, ' . $left . ') as day ', false);
$this->db->where('left(bcl_datetime, 10) >=', $start_date);
$this->db->where('left(bcl_datetime, 10) <=', $end_date);
$this->db->group_by('day');
$this->db->order_by('bcl_datetime', $orderby);
$qry = $this->db->get($this->_table);
$result = $qry->result_array();
return $result;
}
}

View File

@@ -0,0 +1,36 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Banner group model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Banner_group_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'banner_group';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'bng_id'; // 사용되는 테이블의 프라이머리키
function __construct()
{
parent::__construct();
}
public function get_all_group()
{
$result = $this->get('', '', '', '', '', 'bng_name', 'ASC');
return $result;
}
}

View File

@@ -0,0 +1,75 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Banner model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Banner_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'banner';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'ban_id'; // 사용되는 테이블의 프라이머리키
public $cache_time = 86400; // 캐시 저장시간
function __construct()
{
parent::__construct();
check_cache_dir('banner');
}
public function get_banner($position = '', $type = '', $limit = '')
{
if (empty($position)) {
return;
}
if (strtolower($type) !== 'order') {
$type = 'random';
}
$cachename = 'banner/banner-' . $position . '-' . $type . '-' . cdate('Y-m-d');
if ( ! $result = $this->cache->get($cachename)) {
$this->db->from($this->_table);
$this->db->where('bng_name', $position);
$this->db->where('ban_activated', 1);
$this->db->group_start();
$this->db->where(array('ban_start_date <=' => cdate('Y-m-d')));
$this->db->or_where(array('ban_start_date' => null));
$this->db->group_end();
$this->db->group_start();
$this->db->where('ban_end_date >=', cdate('Y-m-d'));
$this->db->or_where('ban_end_date', '0000-00-00');
$this->db->or_where(array('ban_end_date' => ''));
$this->db->or_where(array('ban_end_date' => null));
$this->db->group_end();
$this->db->order_by('ban_order', 'DESC');
$res = $this->db->get();
$result = $res->result_array();
$this->cache->save($cachename, $result, $this->cache_time);
}
if ($type === 'random') {
shuffle($result);
}
if ($limit) {
$result = array_slice($result, 0, $limit);
}
return $result;
}
}

View File

@@ -0,0 +1,83 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Blame model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Blame_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'blame';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'bla_id'; // 사용되는 테이블의 프라이머리키
function __construct()
{
parent::__construct();
}
public function get_admin_list($limit = '', $offset = '', $where = '', $like = '', $findex = '', $forder = '', $sfield = '', $skeyword = '', $sop = 'OR')
{
$select = 'blame.*, member.mem_id, member.mem_userid, member.mem_nickname, member.mem_is_admin, member.mem_icon';
$join[] = array('table' => 'member', 'on' => 'blame.mem_id = member.mem_id', 'type' => 'left');
$result = $this->_get_list_common($select, $join, $limit, $offset, $where, $like, $findex, $forder, $sfield, $skeyword, $sop);
return $result;
}
public function get_blame_count($type = 'd', $start_date = '', $end_date = '', $brd_id = 0, $orderby = 'asc')
{
if (empty($start_date) OR empty($end_date)) {
return false;
}
$left = ($type === 'y') ? 4 : ($type === 'm' ? 7 : 10);
if (strtolower($orderby) !== 'desc') $orderby = 'asc';
$this->db->select('count(*) as cnt, left(bla_datetime, ' . $left . ') as day ', false);
$this->db->where('left(bla_datetime, 10) >=', $start_date);
$this->db->where('left(bla_datetime, 10) <=', $end_date);
$brd_id = (int) $brd_id;
if ($brd_id) {
$this->db->where('brd_id', $brd_id);
}
$this->db->group_by('day');
$this->db->order_by('bla_datetime', $orderby);
$qry = $this->db->get($this->_table);
$result = $qry->result_array();
return $result;
}
public function get_blame_count_by_board($start_date = '', $end_date = '')
{
if (empty($start_date) OR empty($end_date)) {
return false;
}
$this->db->select('count(*) as cnt, brd_id', false);
$this->db->where('left(bla_datetime, 10) >=', $start_date);
$this->db->where('left(bla_datetime, 10) <=', $end_date);
$this->db->group_by('brd_id');
$this->db->order_by('cnt', 'desc');
$qry = $this->db->get($this->_table);
$result = $qry->result_array();
return $result;
}
}

View File

@@ -0,0 +1,48 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Board Admin model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Board_admin_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'board_admin';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'bam_id'; // 사용되는 테이블의 프라이머리키
function __construct()
{
parent::__construct();
}
public function get_board_admin_member($brd_id = 0)
{
$brd_id = (int) $brd_id;
if (empty($brd_id)) {
return false;
}
$this->db->select('member.mem_id, member.mem_nickname, member.mem_email, member.mem_phone ', false);
$this->db->from('member');
$this->db->join('board_admin', 'member.mem_id = board_admin.mem_id', 'left');
$this->db->where('member.mem_denied', 0);
$this->db->where('board_admin.brd_id', $brd_id);
$this->db->order_by('member.mem_id', 'asc');
$qry = $this->db->get();
$result = $qry->result_array();
return $result;
}
}

View File

@@ -0,0 +1,141 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Board Category model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Board_category_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'board_category';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'bca_id'; // 사용되는 테이블의 프라이머리키
function __construct()
{
parent::__construct();
}
public function get_all_category($brd_id = 0)
{
$brd_id = (int) $brd_id;
if (empty($brd_id)) {
return;
}
$cachename = 'category-all-' . $brd_id;
if ( ! $result = $this->cache->get($cachename)) {
$where = array('brd_id' => $brd_id);
$return = $this->get($primary_value = '', $select = '', $where, $limit = '', $offset = 0, $findex = 'bca_order', $forder = 'asc');
if ($return) {
foreach ($return as $key => $value) {
$result[$value['bca_parent']][] = $value;
}
$this->cache->save($cachename, $result);
}
}
return $result;
}
public function get_category_info($brd_id = 0, $bca_key = '')
{
$brd_id = (int) $brd_id;
if (empty($brd_id)) {
return;
}
if (empty($bca_key)) {
return;
}
$cachename = 'category-' . $brd_id;
if ( ! $result = $this->cache->get($cachename)) {
$where = array('brd_id' => $brd_id);
$return = $this->get($primary_value = '', $select = '', $where, $limit = '', $offset = 0, $findex = 'bca_order', $forder = 'asc');
if ($return) {
foreach ($return as $key => $value) {
$result[$value['bca_key']] = $value;
}
$this->cache->save($cachename, $result);
}
}
return isset($result[$bca_key]) ? $result[$bca_key] : '';
}
public function next_key($parent, $brd_id)
{
if ((string) $parent === '0') {
$this->db->select('bca_key');
$this->db->where(array('brd_id' => $brd_id));
$res = $this->db->get($this->_table);
$result = $res->result_array();
$max = 0;
foreach ($result as $key => $value) {
$float = floatval($value['bca_key']);
if ($float > $max) {
$max = $float;
}
}
return intval($max + 1);
}
if (strpos($parent, '.') === false) {
$this->db->select('bca_key');
$this->db->where(array('brd_id' => $brd_id));
$this->db->like('bca_key', $parent . '.', 'after');
$res = $this->db->get($this->_table);
$result = $res->result_array();
$max = 0;
foreach ($result as $key => $value) {
$float = $value['bca_key'];
if ($float > $max) {
$max = $float;
}
}
if ($max) {
$key_explode = explode('.', $max);
$digit = substr($key_explode[1], 0, 3) + 1;
$ret = sprintf("%03d", $digit);
return $key_explode[0] . '.' . $ret;
} else {
return $parent . '.001';
}
} else {
$this->db->select('bca_key');
$this->db->where(array('brd_id' => $brd_id));
$this->db->like('bca_key', $parent, 'after');
$res = $this->db->get($this->_table);
$result = $res->result_array();
$max = 0;
foreach ($result as $key => $value) {
$float = $value['bca_key'];
if ($float > $max) {
$max = $float;
}
}
if ((string) $max === (string) $parent) {
return $parent . '001';
} else {
$key_explode = explode('.', $max);
$parent_explode = explode('.', $parent);
$parentlen = strlen($parent_explode[1]);
$digit = substr($key_explode[1], 0, $parentlen + 3) + 1;
$res = sprintf("%0" . ($parentlen + 3) . "d", $digit);
return $key_explode[0] . '.' . $res;
}
}
}
}

View File

@@ -0,0 +1,48 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Board Group Admin model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Board_group_admin_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'board_group_admin';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'bga_id'; // 사용되는 테이블의 프라이머리키
function __construct()
{
parent::__construct();
}
public function get_board_group_admin_member($bgr_id = 0)
{
$bgr_id = (int) $bgr_id;
if (empty($bgr_id)) {
return false;
}
$this->db->select('member.mem_id, member.mem_nickname, member.mem_email, member.mem_phone ', false);
$this->db->from('member');
$this->db->join('board_group_admin', 'member.mem_id = board_group_admin.mem_id', 'left');
$this->db->where('member.mem_denied', 0);
$this->db->where('board_group_admin.bgr_id', $bgr_id);
$this->db->order_by('member.mem_id', 'asc');
$qry = $this->db->get();
$result = $qry->result_array();
return $result;
}
}

View File

@@ -0,0 +1,162 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Board Group Meta model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Board_group_meta_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'board_group_meta';
/**
* 사용되는 테이블의 프라이머리키
*/
public $parent_key = 'bgr_id';
public $meta_key = 'bgm_key';
public $meta_value = 'bgm_value';
public $cache_prefix= 'board_group_meta/board-group-meta-model-get-'; // 캐시 사용시 프리픽스
public $cache_time = 86400; // 캐시 저장시간
function __construct()
{
parent::__construct();
check_cache_dir('board_group_meta');
}
public function get_all_meta($bgr_id = 0)
{
if (empty($bgr_id)) {
return false;
}
$cachename = $this->cache_prefix . $bgr_id;
$data = array();
if ( ! $data = $this->cache->get($cachename)) {
$result = array();
$res = $this->get($primary_value = '', $select = '', array($this->parent_key => $bgr_id));
if ($res && is_array($res)) {
foreach ($res as $val) {
$result[$val[$this->meta_key]] = $val[$this->meta_value];
}
}
$data['result'] = $result;
$data['cached'] = '1';
$this->cache->save($cachename, $data, $this->cache_time);
}
return isset($data['result']) ? $data['result'] : false;
}
public function save($bgr_id = 0, $savedata = '')
{
if (empty($bgr_id)) {
return false;
}
if ($savedata && is_array($savedata)) {
foreach ($savedata as $column => $value) {
$this->meta_update($bgr_id, $column, $value);
}
}
$this->cache->delete($this->cache_prefix . $bgr_id);
}
public function deletemeta($bgr_id = 0)
{
if (empty($bgr_id)) {
return false;
}
$this->delete_where(array($this->parent_key => $bgr_id));
$this->cache->delete($this->cache_prefix . $bgr_id);
}
public function meta_update($bgr_id = 0, $column = '', $value = false)
{
if (empty($bgr_id)) {
return false;
}
$column = trim($column);
if (empty($column)) {
return false;
}
$old_value = $this->item($bgr_id, $column);
if (empty($value)) {
$value = '';
}
if ($value === $old_value) {
return false;
}
if (false === $old_value) {
return $this->add_meta($bgr_id, $column, $value);
}
return $this->update_meta($bgr_id, $column, $value);
}
public function item($bgr_id = 0, $column = '')
{
if (empty($bgr_id)) {
return false;
}
if (empty($column)) {
return false;
}
$result = $this->get_all_meta($bgr_id);
return isset($result[ $column ]) ? $result[ $column ] : false;
}
public function add_meta($bgr_id = 0, $column = '', $value = '')
{
if (empty($bgr_id)) {
return false;
}
$column = trim($column);
if (empty($column)) {
return false;
}
$updatedata = array(
'bgr_id' => $bgr_id,
'bgm_key' => $column,
'bgm_value' => $value,
);
$this->db->replace($this->_table, $updatedata);
return true;
}
public function update_meta($bgr_id = 0, $column = '', $value = '')
{
if (empty($bgr_id)) {
return false;
}
$column = trim($column);
if (empty($column)) {
return false;
}
$this->db->where($this->parent_key, $bgr_id);
$this->db->where($this->meta_key, $column);
$data = array($this->meta_value => $value);
$this->db->update($this->_table, $data);
return true;
}
}

View File

@@ -0,0 +1,87 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Board Group model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Board_group_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'board_group';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'bgr_id'; // 사용되는 테이블의 프라이머리키
public $cache_prefix = 'board_group/board-group-model-get-'; // 캐시 사용시 프리픽스
public $cache_time = 86400; // 캐시 저장시간
function __construct()
{
parent::__construct();
check_cache_dir('board_group');
}
public function get_group_list($where = '')
{
$result = $this->get('', '', $where, '', 0, 'bgr_order', 'ASC');
return $result;
}
public function get_one($bgr_id = 0, $select = '', $where = '')
{
$use_cache = false;
if ($bgr_id && empty($select) && empty($where)) {
$use_cache = true;
}
if ($use_cache) {
$cachename = $this->cache_prefix . $bgr_id;
if ( ! $result = $this->cache->get($cachename)) {
$result = parent::get_one($bgr_id);
$this->cache->save($cachename, $result, $this->cache_time);
}
} else {
$result = parent::get_one($bgr_id, $select, $where);
}
return $result;
}
public function delete($bgr_id = 0, $where= '')
{
if (empty($bgr_id)) {
return false;
}
$result = parent::delete($bgr_id);
$this->cache->delete($this->cache_prefix . $bgr_id);
return $result;
}
public function update($bgr_id = 0, $updatedata = '', $where = '')
{
if (empty($bgr_id)) {
return false;
}
$result = parent::update($bgr_id, $updatedata);
if ($result) {
$this->cache->delete($this->cache_prefix . $bgr_id);
}
return $result;
}
}

View File

@@ -0,0 +1,165 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Board Meta model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Board_meta_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'board_meta';
/**
* 사용되는 테이블의 프라이머리키
*/
public $parent_key = 'brd_id';
public $meta_key = 'bmt_key';
public $meta_value = 'bmt_value';
public $cache_prefix= 'board_meta/board-meta-model-get-'; // 캐시 사용시 프리픽스
public $cache_time = 86400; // 캐시 저장시간
function __construct()
{
parent::__construct();
check_cache_dir('board_meta');
}
public function get_all_meta($brd_id = 0)
{
if (empty($brd_id)) {
return false;
}
$cachename = $this->cache_prefix . $brd_id;
$data = array();
if ( ! $data = $this->cache->get($cachename)) {
$result = array();
$res = $this->get($primary_value = '', $select = '', array($this->parent_key => $brd_id));
if ($res && is_array($res)) {
foreach ($res as $val) {
$result[$val[$this->meta_key]] = $val[$this->meta_value];
}
}
$data['result'] = $result;
$data['cached'] = '1';
$this->cache->save($cachename, $data, $this->cache_time);
}
return isset($data['result']) ? $data['result'] : false;
}
public function save($brd_id = 0, $savedata = '')
{
if (empty($brd_id)) {
return false;
}
if ($savedata && is_array($savedata)) {
foreach ($savedata as $column => $value) {
$this->meta_update($brd_id, $column, $value);
}
}
$this->cache->delete($this->cache_prefix . $brd_id);
}
public function deletemeta($brd_id = 0)
{
if (empty($brd_id)) {
return false;
}
$this->delete_where(array($this->parent_key => $brd_id));
$this->cache->delete($this->cache_prefix . $brd_id);
}
public function meta_update($brd_id = 0, $column = '', $value = false)
{
if (empty($brd_id)) {
return false;
}
$column = trim($column);
if (empty($column)) {
return false;
}
$old_value = $this->item($brd_id, $column);
if (empty($value)) {
$value = '';
}
if ($value === $old_value) {
return false;
}
if (false === $old_value) {
return $this->add_meta($brd_id, $column, $value);
}
return $this->update_meta($brd_id, $column, $value);
}
public function item($brd_id = 0, $column = '')
{
if (empty($brd_id)) {
return false;
}
if (empty($brd_id)) {
return false;
}
$result = $this->get_all_meta($brd_id);
return isset($result[ $column ]) ? $result[ $column ] : false;
}
public function add_meta($brd_id = 0, $column = '', $value = '')
{
if (empty($brd_id)) {
return false;
}
$column = trim($column);
if (empty($column)) {
return false;
}
$updatedata = array(
'brd_id' => $brd_id,
'bmt_key' => $column,
'bmt_value' => $value,
);
$this->db->replace($this->_table, $updatedata);
return true;
}
public function update_meta($brd_id = 0, $column = '', $value = '')
{
if (empty($brd_id)) {
return false;
}
$column = trim($column);
if (empty($column)) {
return false;
}
$this->db->where($this->parent_key, $brd_id);
$this->db->where($this->meta_key, $column);
$data = array($this->meta_value => $value);
$this->db->update($this->_table, $data);
return true;
}
}

View File

@@ -0,0 +1,106 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Board model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Board_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'board';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'brd_id'; // 사용되는 테이블의 프라이머리키
public $cache_prefix = 'board/board-model-get-'; // 캐시 사용시 프리픽스
public $cache_time = 86400; // 캐시 저장시간
function __construct()
{
parent::__construct();
check_cache_dir('board');
}
public function get_board_list($where = '')
{
$result = $this->get('', '', $where, '', 0, 'brd_order', 'ASC');
return $result;
}
public function get_one($primary_value = '', $select = '', $where = '')
{
$use_cache = false;
if ($primary_value && empty($select) && empty($where)) {
$use_cache = true;
}
if ($use_cache) {
$cachename = $this->cache_prefix . $primary_value;
if ( ! $result = $this->cache->get($cachename)) {
$result = parent::get_one($primary_value);
$this->cache->save($cachename, $result, $this->cache_time);
}
} else {
$result = parent::get_one($primary_value, $select, $where);
}
return $result;
}
public function delete($primary_value = '', $where = '')
{
if (empty($primary_value)) {
return false;
}
$result = parent::delete($primary_value);
$this->cache->delete($this->cache_prefix . $primary_value);
return $result;
}
public function update($primary_value = '', $updatedata = '', $where = '')
{
if (empty($primary_value)) {
return false;
}
$result = parent::update($primary_value, $updatedata);
if ($result) {
$this->cache->delete($this->cache_prefix . $primary_value);
}
return $result;
}
public function get_group_select($bgr_id = 0)
{
$bgr_id = (int) $bgr_id;
$option = '<option value="0">그룹선택</option>';
$this->db->order_by('bgr_order', 'ASC');
$this->db->select('bgr_id, bgr_name');
$qry = $this->db->get('board_group');
foreach ($qry->result_array() as $row) {
$option .= '<option value="' . $row['bgr_id'] . '"';
if ((int) $row['bgr_id'] === $bgr_id) {
$option .= ' selected="selected" ';
}
$option .= '>' . $row['bgr_name'] . '</option>';
}
return $option;
}
}

View File

@@ -0,0 +1,182 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Comment Meta model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Comment_meta_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'comment_meta';
/**
* 사용되는 테이블의 프라이머리키
*/
public $parent_key = 'cmt_id';
public $meta_key = 'cme_key';
public $meta_value = 'cme_value';
public $cache_prefix= 'comment_meta/comment-meta-model-get-'; // 캐시 사용시 프리픽스
public $cache_time = 86400; // 캐시 저장시간
function __construct()
{
parent::__construct();
check_cache_dir('comment_meta');
}
public function get_all_meta($cmt_id = 0)
{
if (empty($cmt_id)) {
return false;
}
$cachename = $this->cache_prefix . $cmt_id;
$data = array();
if ( ! $data = $this->cache->get($cachename)) {
$result = array();
$res = $this->get($primary_value = '', $select = '', array($this->parent_key => $cmt_id));
if ($res && is_array($res)) {
foreach ($res as $val) {
$result[$val[$this->meta_key]] = $val[$this->meta_value];
}
}
$data['result'] = $result;
$data['cached'] = '1';
$this->cache->save($cachename, $data, $this->cache_time);
}
return isset($data['result']) ? $data['result'] : false;
}
public function save($cmt_id = 0, $savedata = '')
{
if (empty($cmt_id)) {
return false;
}
if ($savedata && is_array($savedata)) {
foreach ($savedata as $column => $value) {
$this->meta_update($cmt_id, $column, $value);
}
}
$this->cache->delete($this->cache_prefix . $cmt_id);
}
public function deletemeta($cmt_id = 0)
{
if (empty($cmt_id)) {
return false;
}
$this->delete_where(array($this->parent_key => $cmt_id));
$this->cache->delete($this->cache_prefix . $cmt_id);
}
public function meta_update($cmt_id = 0, $column = '', $value = false)
{
if (empty($cmt_id)) {
return false;
}
$column = trim($column);
if (empty($column)) {
return false;
}
$old_value = $this->item($cmt_id, $column);
if (empty($value)) {
$value = '';
}
if ($value === $old_value) {
return false;
}
if (false === $old_value) {
return $this->add_meta($cmt_id, $column, $value);
}
return $this->update_meta($cmt_id, $column, $value);
}
public function item($cmt_id = 0, $column = '')
{
if (empty($cmt_id)) {
return false;
}
if (empty($column)) {
return false;
}
$result = $this->get_all_meta($cmt_id);
return isset($result[ $column ]) ? $result[ $column ] : false;
}
public function add_meta($cmt_id = 0, $column = '', $value = '')
{
if (empty($cmt_id)) {
return false;
}
$column = trim($column);
if (empty($column)) {
return false;
}
$updatedata = array(
'cmt_id' => $cmt_id,
'cme_key' => $column,
'cme_value' => $value,
);
$this->db->replace($this->_table, $updatedata);
return true;
}
public function update_meta($cmt_id = 0, $column = '', $value = '')
{
if (empty($cmt_id)) {
return false;
}
$column = trim($column);
if (empty($column)) {
return false;
}
$this->db->where($this->parent_key, $cmt_id);
$this->db->where($this->meta_key, $column);
$data = array($this->meta_value => $value);
$this->db->update($this->_table, $data);
return true;
}
public function delete_meta_column($cmt_id = 0, $column = '')
{
if (empty($cmt_id)) {
return false;
}
$column = trim($column);
if (empty($column)) {
return false;
}
$this->delete_where(array($this->parent_key, $cmt_id, $this->meta_key => $column));
return true;
}
}

View File

@@ -0,0 +1,274 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Comment model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Comment_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'comment';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'cmt_id'; // 사용되는 테이블의 프라이머리키
public $allow_order = array('cmt_num, cmt_reply', 'cmt_num desc, cmt_reply');
function __construct()
{
parent::__construct();
}
public function get_admin_list($limit = '', $offset = '', $where = '', $like = '', $findex = '', $forder = '', $sfield = '', $skeyword = '', $sop = 'OR')
{
$select = 'comment.*, post.mem_id as post_mem_id, post.post_userid, post.post_username, post.post_nickname,
post.brd_id, post.post_datetime, post.post_hit, post.post_secret, post.post_title';
$join[] = array('table' => 'post', 'on' => 'comment.post_id = post.post_id', 'type' => 'inner');
$result = $this->_get_list_common($select, $join, $limit, $offset, $where, $like, $findex, $forder, $sfield, $skeyword, $sop);
return $result;
}
/**
* List 페이지 커스테마이징 함수
*/
public function get_comment_list($limit = '', $offset = '', $where = '', $like = '', $orderby = '', $sfield = '', $skeyword = '', $sop = 'OR')
{
if ( ! in_array(strtolower($orderby), $this->allow_order)) {
$orderby = 'cmt_num, cmt_reply';
}
$sop = (strtoupper($sop) === 'AND') ? 'AND' : 'OR';
if (empty($sfield)) {
$sfield = 'cmt_content';
}
$search_where = array();
$search_like = array();
$search_or_like = array();
if ($sfield && is_array($sfield)) {
foreach ($sfield as $skey => $sval) {
$ssf = $sval;
if ($skeyword && $ssf && in_array($ssf, $this->allow_search_field)) {
if (in_array($ssf, $this->search_field_equal)) {
$search_where[$ssf] = $skeyword;
} else {
$swordarray = explode(' ', $skeyword);
foreach ($swordarray as $str) {
if (empty($ssf)) {
continue;
}
if ($sop === 'AND') {
$search_like[] = array($ssf => $str);
} else {
$search_or_like[] = array($ssf => $str);
}
}
}
}
}
} else {
$ssf = $sfield;
if ($skeyword && $ssf && in_array($ssf, $this->allow_search_field)) {
if (in_array($ssf, $this->search_field_equal)) {
$search_where[$ssf] = $skeyword;
} else {
$swordarray = explode(' ', $skeyword);
foreach ($swordarray as $str) {
if (empty($ssf)) {
continue;
}
if ($sop === 'AND') {
$search_like[] = array($ssf => $str);
} else {
$search_or_like[] = array($ssf => $str);
}
}
}
}
}
$this->db->select('comment.*, member.mem_id, member.mem_userid, member.mem_nickname, member.mem_icon, member.mem_photo, member.mem_point');
$this->db->from($this->_table);
$this->db->join('member', 'comment.mem_id = member.mem_id', 'left');
if ($where) {
$this->db->where($where);
}
if ($search_where) {
$this->db->where($search_where);
}
if ($like) {
$this->db->like($like);
}
if ($search_like) {
foreach ($search_like as $item) {
foreach ($item as $skey => $sval) {
$this->db->like($skey, $sval);
}
}
}
if ($search_or_like) {
$this->db->group_start();
foreach ($search_or_like as $item) {
foreach ($item as $skey => $sval) {
$this->db->or_like($skey, $sval);
}
}
$this->db->group_end();
}
$this->db->order_by($orderby);
if ($limit) {
$this->db->limit($limit, $offset);
}
$qry = $this->db->get();
$result['list'] = $qry->result_array();
$this->db->select('count(*) as rownum');
$this->db->from($this->_table);
$this->db->join('member', 'comment.mem_id = member.mem_id', 'left');
if ($where) {
$this->db->where($where);
}
if ($search_where) {
$this->db->where($search_where);
}
if ($like) {
$this->db->like($like);
}
if ($search_like) {
foreach ($search_like as $item) {
foreach ($item as $skey => $sval) {
$this->db->like($skey, $sval);
}
}
}
if ($search_or_like) {
$this->db->group_start();
foreach ($search_or_like as $item) {
foreach ($item as $skey => $sval) {
$this->db->or_like($skey, $sval);
}
}
$this->db->group_end();
}
$qry = $this->db->get();
$rows = $qry->row_array();
$result['total_rows'] = $rows['rownum'];
return $result;
}
public function get_latest($where = '', $like = '', $limit = '', $findex = 'cmt_id', $forder = 'DESC')
{
$this->db->select('comment.*, post.mem_id as post_mem_id, post.post_userid, post.post_username, post.post_nickname,
post.brd_id, post.post_datetime, post.post_hit, post.post_secret, post.post_title');
$this->db->join('post', 'comment.post_id = post.post_id AND post.post_secret= 0 AND post.post_del= 0', 'inner');
if ($where) {
$this->db->where($where);
}
if ($like) {
$this->db->like($like);
}
if ($limit) {
$this->db->limit($limit);
}
$this->db->order_by($findex, $forder);
$qry = $this->db->get($this->_table);
$result = $qry->result_array();
return $result;
}
/**
* List 페이지 커스테마이징 함수
*/
public function get_best_list($post_id = 0, $limit = 3, $like_num= 0)
{
$post_id = (int) $post_id;
if (empty($post_id) OR $post_id < 1) {
return false;
}
$like_num = (int) $like_num;
$where = array(
'post_id' => $post_id,
'cmt_del' => 0,
'cmt_secret' => 0,
'cmt_like >=' => $like_num,
);
$orderby = 'cmt_like desc';
$this->db->select('comment.*, member.mem_id, member.mem_userid, member.mem_nickname, member.mem_icon, member.mem_photo, member.mem_point');
$this->db->from($this->_table);
$this->db->join('member', 'comment.mem_id = member.mem_id', 'left');
if ($where) {
$this->db->where($where);
}
$this->db->order_by($orderby);
if ($limit) {
$this->db->limit($limit);
}
$qry = $this->db->get();
$result = $qry->result_array();
return $result;
}
public function next_comment_num()
{
$this->db->select_min('cmt_num');
$result = $this->db->get($this->_table);
$row = $result->row_array();
$row['cmt_num'] = (isset($row['cmt_num']) && is_numeric($row['cmt_num'])) ? $row['cmt_num'] : 0;
$cmt_num = $row['cmt_num'] - 1;
return $cmt_num;
}
public function count_reply_comment($cmt_id = 0, $post_id = 0, $cmt_num = 0, $cmt_reply = '')
{
$cmt_id = (int) $cmt_id;
if (empty($cmt_id) OR $cmt_id < 1) {
return;
}
$post_id = (int) $post_id;
if (empty($post_id) OR $post_id < 1) {
return;
}
$where = array(
'cmt_id <>' => $cmt_id,
'post_id' => $post_id,
'cmt_num' => $cmt_num,
);
$this->db->select('count(*) cnt');
$this->db->where($where);
$this->db->like('cmt_reply', $cmt_reply, 'after');
$result = $this->db->get($this->_table);
$row = $result->row_array();
$row['cnt'] = (isset($row['cnt'])) ? $row['cnt'] : 0;
return $row['cnt'];
}
}

View File

@@ -0,0 +1,129 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Config model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Config_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'config';
/**
* 사용되는 테이블의 프라이머리키
*/
public $meta_key = 'cfg_key';
public $meta_value = 'cfg_value';
public $cache_name= 'config-model-get'; // 캐시 사용시 프리픽스
public $cache_time = 86400; // 캐시 저장시간
function __construct()
{
parent::__construct();
}
public function get_all_meta()
{
$cachename = $this->cache_name;
if ( ! $result = $this->cache->get($cachename)) {
$result = array();
$res = $this->get();
if ($res && is_array($res)) {
foreach ($res as $val) {
$result[$val[$this->meta_key]] = $val[$this->meta_value];
}
}
$this->cache->save($cachename, $result, $this->cache_time);
}
return $result;
}
public function save($savedata = '')
{
if ($savedata && is_array($savedata)) {
foreach ($savedata as $column => $value) {
$this->meta_update($column, $value);
}
}
$this->cache->delete($this->cache_name);
}
public function meta_update($column = '', $value = false)
{
$column = trim($column);
if (empty($column)) {
return false;
}
$old_value = $this->item($column);
if (is_null($value)) {
$value = '';
}
if ($value === $old_value) {
return false;
}
if (false === $old_value) {
return $this->add_meta($column, $value);
}
return $this->update_meta($column, $value);
}
public function item($column = '')
{
if (empty($column)) {
return false;
}
$result = $this->get_all_meta();
return isset($result[ $column ]) ? $result[ $column ] : false;
}
public function add_meta($column = '', $value = '')
{
$column = trim($column);
if (empty($column)) {
return false;
}
$updatedata = array(
'cfg_key' => $column,
'cfg_value' => $value,
);
$this->db->replace($this->_table, $updatedata);
return true;
}
public function update_meta($column = '', $value = '')
{
$column = trim($column);
if (empty($column)) {
return false;
}
$this->db->where($this->meta_key, $column);
$data = array($this->meta_value => $value);
$this->db->update($this->_table, $data);
return true;
}
}

View File

@@ -0,0 +1,117 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Currentvisitor model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Currentvisitor_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'currentvisitor';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'cur_ip'; // 사용되는 테이블의 프라이머리키
function __construct()
{
parent::__construct();
}
public function add_visitor($cur_ip = '', $mem_id = 0, $cur_mem_name = '', $cur_datetime = '', $cur_page = '', $cur_url = '', $cur_referer = '', $cur_useragent = '')
{
$mem_id = (int) $mem_id;
if (empty($mem_id)) {
$mem_id = 0;
}
if (empty($cur_mem_name)) {
$cur_mem_name = '';
}
$updatedata = array(
'cur_ip' => $cur_ip,
'mem_id' => $mem_id,
'cur_mem_name' => $cur_mem_name,
'cur_datetime' => $cur_datetime,
'cur_page' => $cur_page,
'cur_url' => $cur_url,
'cur_referer' => $cur_referer,
'cur_useragent' => $cur_useragent,
);
$result = $this->db->replace($this->_table, $updatedata);
return $result;
}
public function get_admin_list($limit = '', $offset = '', $where = '', $like = '', $findex = '', $forder = '', $sfield = '', $skeyword = '', $sop = 'OR')
{
$select = 'currentvisitor.*, member.mem_id, member.mem_userid, member.mem_nickname, member.mem_is_admin, member.mem_icon';
$join[] = array('table' => 'member', 'on' => 'currentvisitor.mem_id = member.mem_id', 'type' => 'left');
$result = $this->_get_list_common($select, $join, $limit, $offset, $where, $like, $findex, $forder, $sfield, $skeyword, $sop);
return $result;
}
public function get_current_list($curdatetime = '', $limit = '', $offset = '')
{
$this->db->select('currentvisitor.*, member.mem_id, member.mem_userid, member.mem_nickname, member.mem_is_admin, member.mem_icon');
$this->db->from($this->_table);
$this->db->join('member', 'currentvisitor.mem_id = member.mem_id', 'left');
$this->db->where(array('cur_datetime >' => $curdatetime));
$this->db->group_start();
$this->db->where(array('member.mem_is_admin' => 0));
$this->db->or_where(array('member.mem_is_admin' => null));
$this->db->group_end();
$this->db->order_by('cur_datetime', 'desc');
if ($limit) {
$this->db->limit($limit, $offset);
}
$qry = $this->db->get();
$result['list'] = $qry->result_array();
$this->db->select('count(*) as rownum');
$this->db->from($this->_table);
$this->db->join('member', 'currentvisitor.mem_id = member.mem_id', 'left');
$this->db->where(array('cur_datetime >' => $curdatetime));
$this->db->group_start();
$this->db->where(array('member.mem_is_admin' => 0));
$this->db->or_where(array('member.mem_is_admin' => null));
$this->db->group_end();
$qry = $this->db->get();
$rows = $qry->row_array();
$result['total_rows'] = $rows['rownum'];
return $result;
}
public function get_current_count($curdatetime = '')
{
if (empty($curdatetime)) {
$curdatetime = cdate('Y-m-d H:i:s', ctimestamp() - 600);
}
$this->db->select('count(*) as rownum');
$this->db->join('member', 'currentvisitor.mem_id = member.mem_id', 'left');
$this->db->where(array('cur_datetime >' => $curdatetime));
$this->db->group_start();
$this->db->where(array('member.mem_is_admin' => 0));
$this->db->or_where(array('member.mem_is_admin' => null));
$this->db->group_end();
$qry = $this->db->get($this->_table);
$rows = $qry->row_array();
return $rows['rownum'];
}
}

View File

@@ -0,0 +1,52 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Document model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Document_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'document';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'doc_id'; // 사용되는 테이블의 프라이머리키
function __construct()
{
parent::__construct();
}
public function get_admin_list($limit = '', $offset = '', $where = '', $like = '', $findex = '', $forder = '', $sfield = '', $skeyword = '', $sop = 'OR')
{
$select = 'document.*, member.mem_id, member.mem_userid, member.mem_nickname, member.mem_is_admin, member.mem_icon';
$join[] = array('table' => 'member', 'on' => 'document.doc_updated_mem_id = member.mem_id', 'type' => 'left');
$result = $this->_get_list_common($select, $join, $limit, $offset, $where, $like, $findex, $forder, $sfield, $skeyword, $sop);
return $result;
}
public function update_hit($primary_value = '')
{
if (empty($primary_value)) {
return false;
}
$this->db->where($this->primary_key, $primary_value);
$this->db->set('doc_hit', 'doc_hit+1', false);
$result = $this->db->update($this->_table);
return $result;
}
}

View File

@@ -0,0 +1,58 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Editor image model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Editor_image_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'editor_image';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'eim_id'; // 사용되는 테이블의 프라이머리키
function __construct()
{
parent::__construct();
}
public function get_admin_list($limit = '', $offset = '', $where = '', $like = '', $findex = '', $forder = '', $sfield = '', $skeyword = '', $sop = 'OR')
{
$select = 'editor_image.*, member.mem_id, member.mem_userid, member.mem_nickname, member.mem_is_admin, member.mem_icon';
$join[] = array('table' => 'member', 'on' => 'editor_image.mem_id = member.mem_id', 'type' => 'left');
$result = $this->_get_list_common($select, $join, $limit, $offset, $where, $like, $findex, $forder, $sfield, $skeyword, $sop);
return $result;
}
public function get_editor_file_by_date($type = 'd', $start_date = '', $end_date = '', $orderby = 'asc')
{
if (empty($start_date) OR empty($end_date)) {
return false;
}
$left = ($type === 'y') ? 4 : ($type === 'm' ? 7 : 10);
if (strtolower($orderby) !== 'desc') $orderby = 'asc';
$this->db->select('count(*) as cnt, left(eim_datetime, ' . $left . ') as day ', false);
$this->db->where('left(eim_datetime, 10) >=', $start_date);
$this->db->where('left(eim_datetime, 10) <=', $end_date);
$this->db->group_by('day');
$this->db->order_by('eim_datetime', $orderby);
$qry = $this->db->get($this->_table);
$result = $qry->result_array();
return $result;
}
}

View File

@@ -0,0 +1,90 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Faq group model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Faq_group_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'faq_group';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'fgr_id'; // 사용되는 테이블의 프라이머리키
public $cache_prefix = 'faq_group/faq-group-model-get-'; // 캐시 사용시 프리픽스
public $cache_time = 86400; // 캐시 저장시간
function __construct()
{
parent::__construct();
check_cache_dir('faq_group');
}
public function get_one($primary_value = '', $select = '', $where = '')
{
$use_cache = false;
if ($primary_value && empty($select) && empty($where)) {
$use_cache = true;
}
if ($use_cache) {
$cachename = $this->cache_prefix . $primary_value;
if ( ! $result = $this->cache->get($cachename)) {
$result = parent::get_one($primary_value);
$this->cache->save($cachename, $result, $this->cache_time);
}
} else {
$result = parent::get_one($primary_value, $select, $where);
}
return $result;
}
public function get_admin_list($limit = '', $offset = '', $where = '', $like = '', $findex = '', $forder = '', $sfield = '', $skeyword = '', $sop = 'OR')
{
$select = 'faq_group.*, member.mem_id, member.mem_userid, member.mem_nickname, member.mem_is_admin, member.mem_icon';
$join[] = array('table' => 'member', 'on' => 'faq_group.mem_id = member.mem_id', 'type' => 'left');
$result = $this->_get_list_common($select, $join, $limit, $offset, $where, $like, $findex, $forder, $sfield, $skeyword, $sop);
return $result;
}
public function delete($primary_value = '', $where = '')
{
if (empty($primary_value)) {
return false;
}
$result = parent::delete($primary_value);
$this->cache->delete($this->cache_prefix . $primary_value);
return $result;
}
public function update($primary_value = '', $updatedata = '', $where = '')
{
if (empty($primary_value)) {
return false;
}
$result = parent::update($primary_value, $updatedata);
if ($result) {
$this->cache->delete($this->cache_prefix . $primary_value);
}
return $result;
}
}

View File

@@ -0,0 +1,38 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Faq model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Faq_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'faq';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'faq_id'; // 사용되는 테이블의 프라이머리키
function __construct()
{
parent::__construct();
}
public function get_admin_list($limit = '', $offset = '', $where = '', $like = '', $findex = '', $forder = '', $sfield = '', $skeyword = '', $sop = 'OR')
{
$select = 'faq.*, member.mem_id, member.mem_userid, member.mem_nickname, member.mem_is_admin, member.mem_icon';
$join[] = array('table' => 'member', 'on' => 'faq.mem_id = member.mem_id', 'type' => 'left');
$result = $this->_get_list_common($select, $join, $limit, $offset, $where, $like, $findex, $forder, $sfield, $skeyword, $sop);
return $result;
}
}

View File

@@ -0,0 +1,51 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Follow model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Follow_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'follow';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'fol_id'; // 사용되는 테이블의 프라이머리키
function __construct()
{
parent::__construct();
}
public function get_following_list($limit = '', $offset = '', $where = '', $like = '', $findex = '', $forder = '', $sfield = '', $skeyword = '', $sop = 'OR')
{
$select = 'follow.*, member.mem_id, member.mem_userid, member.mem_level, member.mem_nickname,
member.mem_is_admin, member.mem_icon, member.mem_lastlogin_datetime';
$join[] = array('table' => 'member', 'on' => 'follow.target_mem_id = member.mem_id', 'type' => 'left');
$result = $this->_get_list_common($select, $join, $limit, $offset, $where, $like, $findex, $forder, $sfield, $skeyword, $sop);
return $result;
}
public function get_followed_list($limit = '', $offset = '', $where = '', $like = '', $findex = '', $forder = '', $sfield = '', $skeyword = '', $sop = 'OR')
{
$select = 'follow.*, member.mem_id, member.mem_userid, member.mem_level, member.mem_nickname,
member.mem_is_admin, member.mem_icon, member.mem_lastlogin_datetime';
$join[] = array('table' => 'member', 'on' => 'follow.mem_id = member.mem_id', 'type' => 'left');
$result = $this->_get_list_common($select, $join, $limit, $offset, $where, $like, $findex, $forder, $sfield, $skeyword, $sop);
return $result;
}
}

View File

@@ -0,0 +1,111 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Like model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Like_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'like';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'lik_id'; // 사용되는 테이블의 프라이머리키
function __construct()
{
parent::__construct();
}
public function get_admin_list($limit = '', $offset = '', $where = '', $like = '', $findex = '', $forder = '', $sfield = '', $skeyword = '', $sop = 'OR')
{
$select = 'like.*, member.mem_id, member.mem_userid, member.mem_nickname, member.mem_is_admin, member.mem_icon';
$join[] = array('table' => 'member', 'on' => 'like.mem_id = member.mem_id', 'type' => 'left');
$result = $this->_get_list_common($select, $join, $limit, $offset, $where, $like, $findex, $forder, $sfield, $skeyword, $sop);
return $result;
}
public function get_post_like_list($limit = '', $offset = '', $where = '', $like = '', $findex = '', $forder = '', $sfield = '', $skeyword = '', $sop = 'OR')
{
$select = 'like.*, post.mem_id as post_mem_id, post.post_userid, post.post_username, post.post_nickname, post.post_id,
post.brd_id, post.post_datetime, post.post_hit, post.post_secret, post.post_title, post.post_like, post.post_dislike, post.post_image, post.post_del';
$join[] = array('table' => 'post', 'on' => 'like.target_id = post.post_id', 'type' => 'inner');
$result = $this->_get_list_common($select, $join, $limit, $offset, $where, $like, $findex, $forder, $sfield, $skeyword, $sop);
return $result;
}
public function get_comment_like_list($limit = '', $offset = '', $where = '', $like = '', $findex = '', $forder = '', $sfield = '', $skeyword = '', $sop = 'OR')
{
$select = 'like.*, comment.cmt_id, comment.mem_id as cmt_mem_id, comment.cmt_userid, comment.cmt_username,
comment.cmt_nickname, comment.post_id, comment.cmt_datetime, comment.cmt_secret, comment.cmt_content,
comment.cmt_content, comment.cmt_like, comment.cmt_dislike, comment.cmt_del';
$join[] = array('table' => 'comment', 'on' => 'like.target_id = comment.cmt_id', 'type' => 'inner');
$result = $this->_get_list_common($select, $join, $limit, $offset, $where, $like, $findex, $forder, $sfield, $skeyword, $sop);
return $result;
}
public function get_like_count($type = 'd', $start_date = '', $end_date = '', $brd_id = 0, $orderby = 'asc')
{
if (empty($start_date) OR empty($end_date)) {
return false;
}
$left = ($type === 'y') ? 4 : ($type === 'm' ? 7 : 10);
if (strtolower($orderby) !== 'desc') $orderby = 'asc';
$this->db->select('count(*) as cnt, left(lik_datetime, ' . $left . ') as day ', false);
$this->db->where('lik_type', 1);
$this->db->where('left(lik_datetime, 10) >=', $start_date);
$this->db->where('left(lik_datetime, 10) <=', $end_date);
$brd_id = (int) $brd_id;
if ($brd_id) {
$this->db->where('brd_id', $brd_id);
}
$this->db->group_by('day');
$this->db->order_by('lik_datetime', $orderby);
$qry = $this->db->get($this->_table);
$result = $qry->result_array();
return $result;
}
public function get_dislike_count($type = 'd', $start_date = '', $end_date = '', $brd_id = 0, $orderby = 'asc')
{
if (empty($start_date) OR empty($end_date)) {
return false;
}
$left = ($type === 'y') ? 4 : ($type === 'm' ? 7 : 10);
if (strtolower($orderby) !== 'desc') $orderby = 'asc';
$this->db->select('count(*) as cnt, left(lik_datetime, ' . $left . ') as day ', false);
$this->db->where('lik_type', 2);
$this->db->where('left(lik_datetime, 10) >=', $start_date);
$this->db->where('left(lik_datetime, 10) <=', $end_date);
$brd_id = (int) $brd_id;
if ($brd_id) {
$this->db->where('brd_id', $brd_id);
}
$this->db->group_by('day');
$this->db->order_by('lik_datetime', $orderby);
$qry = $this->db->get($this->_table);
$result = $qry->result_array();
return $result;
}
}

View File

@@ -0,0 +1,29 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Member Auth Email model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Member_auth_email_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'member_auth_email';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'mae_id'; // 사용되는 테이블의 프라이머리키
function __construct()
{
parent::__construct();
}
}

View File

@@ -0,0 +1,29 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Member Certify model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Member_certify_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'member_certify';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'mce_id'; // 사용되는 테이블의 프라이머리키
function __construct()
{
parent::__construct();
}
}

View File

@@ -0,0 +1,79 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Member Dormant model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Member_dormant_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'member_dormant';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'mem_id'; // 사용되는 테이블의 프라이머리키
public $search_sfield = '';
function __construct()
{
parent::__construct();
}
public function get_by_memid($memid = 0, $select = '')
{
$memid = (int) $memid;
if (empty($memid) OR $memid < 1) {
return false;
}
$where = array('mem_id' => $memid);
return $this->get_one('', $select, $where);
}
public function get_by_userid($userid = '', $select = '')
{
if (empty($userid)) {
return false;
}
$where = array('mem_userid' => $userid);
return $this->get_one('', $select, $where);
}
public function get_by_email($email = '', $select = '')
{
if (empty($email)) {
return false;
}
$where = array('mem_email' => $email);
return $this->get_one('', $select, $where);
}
public function get_by_both($str = '', $select = '')
{
if (empty($str)) {
return false;
}
if ($select) {
$this->db->select($select);
}
$this->db->from($this->_table);
$this->db->where('mem_userid', $str);
$this->db->or_where('mem_email', $str);
$result = $this->db->get();
return $result->row_array();
}
}

View File

@@ -0,0 +1,75 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Member Dormant Notify model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Member_dormant_notify_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'member_dormant_notify';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'mdn_id'; // 사용되는 테이블의 프라이머리키
function __construct()
{
parent::__construct();
}
/**
* 휴면회원으로 전환되기 전에 이메일을 보내야할 대상에 있는 회원 명단
*/
public function get_unsent_email_member($lastlogindatetime)
{
$this->db->select('member.*');
$this->db->from('member');
$this->db->join('member_dormant_notify', 'member.mem_id = member_dormant_notify.mem_id', 'left');
$this->db->where(array('member_dormant_notify.mem_id' => null));
$this->db->where(array('member.mem_lastlogin_datetime <=' => $lastlogindatetime));
$this->db->where(array('member.mem_register_datetime <=' => $lastlogindatetime));
$this->db->where(array('member.mem_email <>' => ''));
$this->db->limit(100);
$qry = $this->db->get();
$result = $qry->result_array();
return $result;
}
/**
* 휴면회원으로 전환되기 전에 이메일을 보내야할 대상에 있는 회원 수
*/
public function count_unsent_email_member($lastlogindatetime)
{
$this->db->select('count(*) as rownum');
$this->db->from('member');
$this->db->join('member_dormant_notify', 'member.mem_id = member_dormant_notify.mem_id', 'left');
$this->db->where(
array(
'member_dormant_notify.mem_id' => null,
'member.mem_lastlogin_datetime <=' => $lastlogindatetime,
'member.mem_register_datetime <=' => $lastlogindatetime,
'member.mem_email <>' => ''
)
);
$qry = $this->db->get();
$rows = $qry->row_array();
return $rows['rownum'];
}
}

View File

@@ -0,0 +1,180 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Member Extra Vars model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Member_extra_vars_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'member_extra_vars';
/**
* 사용되는 테이블의 프라이머리키
*/
public $parent_key = 'mem_id';
public $meta_key = 'mev_key';
public $meta_value = 'mev_value';
public $cache_prefix= 'member_extra_vars/member-extra-vars-model-get-'; // 캐시 사용시 프리픽스
public $cache_time = 86400; // 캐시 저장시간
function __construct()
{
parent::__construct();
check_cache_dir('member_extra_vars');
}
public function get_all_meta($mem_id = 0)
{
if (empty($mem_id)) {
return false;
}
$cachename = $this->cache_prefix . $mem_id;
$data = array();
if ( ! $data = $this->cache->get($cachename)) {
$result = array();
$res = $this->get($primary_value = '', $select = '', array($this->parent_key => $mem_id));
if ($res && is_array($res)) {
foreach ($res as $val) {
$result[$val[$this->meta_key]] = $val[$this->meta_value];
}
}
$data['result'] = $result;
$data['cached'] = '1';
$this->cache->save($cachename, $data, $this->cache_time);
}
return isset($data['result']) ? $data['result'] : false;
}
public function save($mem_id = 0, $savedata = '')
{
if (empty($mem_id)) {
return false;
}
if ($savedata && is_array($savedata)) {
foreach ($savedata as $column => $value) {
$this->meta_update($mem_id, $column, $value);
}
}
$this->cache->delete($this->cache_prefix . $mem_id);
}
public function deletemeta($mem_id = 0)
{
if (empty($mem_id)) {
return false;
}
$this->delete_where(array($this->parent_key => $mem_id));
$this->cache->delete($this->cache_prefix . $mem_id);
}
public function meta_update($mem_id = 0, $column = '', $value = false)
{
if (empty($mem_id)) {
return false;
}
$column = trim($column);
if (empty($column)) {
return false;
}
$old_value = $this->item($mem_id, $column);
if (empty($value)) {
$value = '';
}
if ($value === $old_value) {
return false;
}
if (is_array($value)) {
$value = json_encode($value);
}
if (false === $old_value) {
return $this->add_meta($mem_id, $column, $value);
}
return $this->update_meta($mem_id, $column, $value);
}
public function item($mem_id = 0, $column = '')
{
if (empty($mem_id)) {
return false;
}
if (empty($column)) {
return false;
}
$result = $this->get_all_meta($mem_id);
return isset($result[ $column ]) ? $result[ $column ] : false;
}
public function add_meta($mem_id = 0, $column = '', $value = '')
{
if (empty($mem_id)) {
return false;
}
$column = trim($column);
if (empty($column)) {
return false;
}
$updatedata = array(
'mem_id' => $mem_id,
'mev_key' => $column,
'mev_value' => $value,
);
$this->db->replace($this->_table, $updatedata);
return true;
}
public function deletemeta_item($column = '')
{
if (empty($column)) {
return false;
}
$this->delete_where(array($this->meta_key => $column));
}
public function update_meta($mem_id = 0, $column = '', $value = '')
{
if (empty($mem_id)) {
return false;
}
$column = trim($column);
if (empty($column)) {
return false;
}
$this->db->where($this->parent_key, $mem_id);
$this->db->where($this->meta_key, $column);
$data = array($this->meta_value => $value);
$this->db->update($this->_table, $data);
return true;
}
}

View File

@@ -0,0 +1,29 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Member Group Member model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Member_group_member_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'member_group_member';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'mgm_id'; // 사용되는 테이블의 프라이머리키
function __construct()
{
parent::__construct();
}
}

View File

@@ -0,0 +1,106 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Member Group model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Member_group_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'member_group';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'mgr_id'; // 사용되는 테이블의 프라이머리키
public $cache_name = 'member_group/member-group-model-get'; // 캐시 사용시 프리픽스
public $cache_time = 86400; // 캐시 저장시간
function __construct()
{
parent::__construct();
check_cache_dir('member_group');
}
public function get_all_group()
{
$cachename = $this->cache_name;
if ( ! $result = $this->cache->get($cachename)) {
$result = array();
$res = $this->get($primary_value = '', $select = '', $where = '', $limit = '', $offset = 0, $findex = 'mgr_order', $forder = 'ASC');
if ($res && is_array($res)) {
foreach ($res as $val) {
$result[$val['mgr_id']] = $val;
}
}
$this->cache->save($cachename, $result, $this->cache_time);
}
return $result;
}
public function item($groupid = 0)
{
$groupid = (int) $groupid;
if (empty($groupid) OR $groupid < 1) {
return false;
}
$data = $this->get_all_group();
$result = isset($data[ $groupid ]) ? $data[ $groupid ] : false;
return $result;
}
public function update_group($data = '')
{
$order = 1;
if (element('mgr_id', $data) && is_array(element('mgr_id', $data))) {
foreach (element('mgr_id', $data) as $key => $value) {
if ( ! element($key, element('mgr_title', $data))) {
continue;
}
if ($value) {
$is_default = isset($data['mgr_is_default'][$key]) && $data['mgr_is_default'][$key] ? 1 : 0;
$updatedata = array(
'mgr_title' => $data['mgr_title'][$key],
'mgr_is_default' => $is_default,
'mgr_datetime' => cdate('Y-m-d H:i:s'),
'mgr_order' => $order,
'mgr_description' => $data['mgr_description'][$key],
);
$this->update($value, $updatedata);
} else {
$is_default = isset($data['mgr_is_default'][$key]) && $data['mgr_is_default'][$key] ? 1 : 0;
$insertdata = array(
'mgr_title' => $data['mgr_title'][$key],
'mgr_is_default' => $is_default,
'mgr_datetime' => cdate('Y-m-d H:i:s'),
'mgr_order' => $order,
'mgr_description' => $data['mgr_description'][$key],
);
$this->insert($insertdata);
}
$order++;
}
}
$deletewhere = array(
'mgr_datetime !=' => cdate('Y-m-d H:i:s'),
);
$this->delete_where($deletewhere);
$this->cache->delete($this->cache_name);
}
}

View File

@@ -0,0 +1,38 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Member Level History model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Member_level_history_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'member_level_history';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'mlh_id'; // 사용되는 테이블의 프라이머리키
function __construct()
{
parent::__construct();
}
public function get_admin_list($limit = '', $offset = '', $where = '', $like = '', $findex = '', $forder = '', $sfield = '', $skeyword = '', $sop = 'OR')
{
$select = 'member_level_history.*, member.mem_id, member.mem_userid, member.mem_nickname, member.mem_is_admin, member.mem_icon';
$join[] = array('table' => 'member', 'on' => 'member_level_history.mem_id = member.mem_id', 'type' => 'left');
$result = $this->_get_list_common($select, $join, $limit, $offset, $where, $like, $findex, $forder, $sfield, $skeyword, $sop);
return $result;
}
}

View File

@@ -0,0 +1,80 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Member Login Log model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Member_login_log_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'member_login_log';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'mll_id'; // 사용되는 테이블의 프라이머리키
function __construct()
{
parent::__construct();
}
public function get_admin_list($limit = '', $offset = '', $where = '', $like = '', $findex = '', $forder = '', $sfield = '', $skeyword = '', $sop = 'OR')
{
$select = 'member_login_log.*, member.mem_id, member.mem_userid, member.mem_nickname, member.mem_is_admin, member.mem_icon';
$join[] = array('table' => 'member', 'on' => 'member_login_log.mem_id = member.mem_id', 'type' => 'left');
$result = $this->_get_list_common($select, $join, $limit, $offset, $where, $like, $findex, $forder, $sfield, $skeyword, $sop);
return $result;
}
public function get_login_success_count($type = 'd', $start_date = '', $end_date = '', $orderby = 'asc')
{
if (empty($start_date) OR empty($end_date)) {
return false;
}
$left = ($type === 'y') ? 4 : ($type === 'm' ? 7 : 10);
if (strtolower($orderby) !== 'desc') $orderby = 'asc';
$this->db->select('count(*) as cnt, left(mll_datetime, ' . $left . ') as day ', false);
$this->db->where('mll_success', 1);
$this->db->where('left(mll_datetime, 10) >=', $start_date);
$this->db->where('left(mll_datetime, 10) <=', $end_date);
$this->db->group_by('day');
$this->db->order_by('mll_datetime', $orderby);
$qry = $this->db->get($this->_table);
$result = $qry->result_array();
return $result;
}
public function get_login_fail_count($type = 'd', $start_date = '', $end_date = '', $orderby = 'asc')
{
if (empty($start_date) OR empty($end_date)) {
return false;
}
$left = ($type === 'y') ? 4 : ($type === 'm' ? 7 : 10);
if (strtolower($orderby) !== 'desc') $orderby = 'asc';
$this->db->select('count(*) as cnt, left(mll_datetime, ' . $left . ') as day ', false);
$this->db->where('mll_success', 0);
$this->db->where('left(mll_datetime, 10) >=', $start_date);
$this->db->where('left(mll_datetime, 10) <=', $end_date);
$this->db->group_by('day');
$this->db->order_by('mll_datetime', $orderby);
$qry = $this->db->get($this->_table);
$result = $qry->result_array();
return $result;
}
}

View File

@@ -0,0 +1,169 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Member Meta model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Member_meta_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'member_meta';
/**
* 사용되는 테이블의 프라이머리키
*/
public $parent_key = 'mem_id';
public $meta_key = 'mmt_key';
public $meta_value = 'mmt_value';
public $cache_prefix= 'member_meta/member-meta-model-get-'; // 캐시 사용시 프리픽스
public $cache_time = 86400; // 캐시 저장시간
function __construct()
{
parent::__construct();
check_cache_dir('member_meta');
}
public function get_all_meta($mem_id = 0)
{
if (empty($mem_id)) {
return false;
}
$cachename = $this->cache_prefix . $mem_id;
$data = array();
if ( ! $data = $this->cache->get($cachename)) {
$result = array();
$res = $this->get($primary_value = '', $select = '', array($this->parent_key => $mem_id));
if ($res && is_array($res)) {
foreach ($res as $val) {
$result[$val[$this->meta_key]] = $val[$this->meta_value];
}
}
$data['result'] = $result;
$data['cached'] = '1';
$this->cache->save($cachename, $data, $this->cache_time);
}
return isset($data['result']) ? $data['result'] : false;
}
public function save($mem_id = 0, $savedata = '')
{
if (empty($mem_id)) {
return false;
}
if ($savedata && is_array($savedata)) {
foreach ($savedata as $column => $value) {
$this->meta_update($mem_id, $column, $value);
}
}
$this->cache->delete($this->cache_prefix . $mem_id);
}
public function deletemeta($mem_id = 0)
{
if (empty($mem_id)) {
return false;
}
$this->delete_where(array($this->parent_key => $mem_id));
$this->cache->delete($this->cache_prefix . $mem_id);
}
public function meta_update($mem_id = 0, $column = '', $value = false)
{
if (empty($mem_id)) {
return false;
}
$column = trim($column);
if (empty($column)) {
return false;
}
$old_value = $this->item($mem_id, $column);
if (empty($value)) {
$value = '';
}
if ($value === $old_value) {
return false;
}
if (false === $old_value) {
return $this->add_meta($mem_id, $column, $value);
}
return $this->update_meta($mem_id, $column, $value);
}
public function item($mem_id = 0, $column = '')
{
if (empty($mem_id)) {
return false;
}
if (empty($column)) {
return false;
}
$result = $this->get_all_meta($mem_id);
return isset($result[ $column ]) ? $result[ $column ] : false;
}
public function add_meta($mem_id = 0, $column = '', $value = '')
{
if (empty($mem_id)) {
return false;
}
$column = trim($column);
if (empty($column)) {
return false;
}
$updatedata = array(
'mem_id' => $mem_id,
'mmt_key' => $column,
'mmt_value' => $value,
);
$this->db->replace($this->_table, $updatedata);
return true;
}
public function update_meta($mem_id = 0, $column = '', $value = '')
{
if (empty($mem_id)) {
return false;
}
$column = trim($column);
if (empty($column)) {
return false;
}
$this->db->where($this->parent_key, $mem_id);
$this->db->where($this->meta_key, $column);
$data = array($this->meta_value => $value);
$this->db->update($this->_table, $data);
return true;
}
}

View File

@@ -0,0 +1,124 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Member model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Member_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'member';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'mem_id'; // 사용되는 테이블의 프라이머리키
public $search_sfield = '';
function __construct()
{
parent::__construct();
}
public function get_by_memid($memid = 0, $select = '')
{
$memid = (int) $memid;
if (empty($memid) OR $memid < 1) {
return false;
}
$where = array('mem_id' => $memid);
return $this->get_one('', $select, $where);
}
public function get_by_userid($userid = '', $select = '')
{
if (empty($userid)) {
return false;
}
$where = array('mem_userid' => $userid);
return $this->get_one('', $select, $where);
}
public function get_by_email($email = '', $select = '')
{
if (empty($email)) {
return false;
}
$where = array('mem_email' => $email);
return $this->get_one('', $select, $where);
}
public function get_by_both($str = '', $select = '')
{
if (empty($str)) {
return false;
}
if ($select) {
$this->db->select($select);
}
$this->db->from($this->_table);
$this->db->where('mem_userid', $str);
$this->db->or_where('mem_email', $str);
$result = $this->db->get();
return $result->row_array();
}
public function get_superadmin_list($select='')
{
$where = array(
'mem_is_admin' => 1,
'mem_denied' => 0,
);
$result = $this->get('', $select, $where);
return $result;
}
public function get_admin_list($limit = '', $offset = '', $where = '', $like = '', $findex = '', $forder = '', $sfield = '', $skeyword = '', $sop = 'OR')
{
$join = array();
if (isset($where['mgr_id'])) {
$select = 'member.*';
$join[] = array('table' => 'member_group_member', 'on' => 'member.mem_id = member_group_member.mem_id', 'type' => 'left');
}
$result = $this->_get_list_common($select = '', $join, $limit, $offset, $where, $like, $findex, $forder, $sfield, $skeyword, $sop);
return $result;
}
public function get_register_count($type = 'd', $start_date = '', $end_date = '', $orderby = 'asc')
{
if (empty($start_date) OR empty($end_date)) {
return false;
}
$left = ($type === 'y') ? 4 : ($type === 'm' ? 7 : 10);
if (strtolower($orderby) !== 'desc') $orderby = 'asc';
$this->db->select('count(*) as cnt, left(mem_register_datetime, ' . $left . ') as day ', false);
$this->db->where('left(mem_register_datetime, 10) >=', $start_date);
$this->db->where('left(mem_register_datetime, 10) <=', $end_date);
$this->db->where('mem_denied', 0);
$this->db->group_by('day');
$this->db->order_by('mem_register_datetime', $orderby);
$qry = $this->db->get($this->_table);
$result = $qry->result_array();
return $result;
}
}

View File

@@ -0,0 +1,39 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Member Nickname model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Member_nickname_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'member_nickname';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'mni_id'; // 사용되는 테이블의 프라이머리키
function __construct()
{
parent::__construct();
}
public function get_admin_list($limit = '', $offset = '', $where = '', $like = '', $findex = '', $forder = '', $sfield = '', $skeyword = '', $sop = 'OR')
{
$select = 'member_nickname.*, member.mem_id, member.mem_userid, member.mem_username, member.mem_nickname, member.mem_is_admin, member.mem_icon';
$join[] = array('table' => 'member', 'on' => 'member_nickname.mem_id = member.mem_id', 'type' => 'left');
$result = $this->_get_list_common($select, $join, $limit, $offset, $where, $like, $findex, $forder, $sfield, $skeyword, $sop);
return $result;
}
}

View File

@@ -0,0 +1,55 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Member Register model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Member_register_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'member_register';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'mrg_id'; // 사용되는 테이블의 프라이머리키
function __construct()
{
parent::__construct();
}
public function get_admin_list($limit = '', $offset = '', $where = '', $like = '', $findex = '', $forder = '', $sfield = '', $skeyword = '', $sop = 'OR')
{
$select = 'member_register.*, member.mem_id, member.mem_userid, member.mem_username, member.mem_nickname, member.mem_is_admin, member.mem_icon';
$join[] = array('table' => 'member', 'on' => 'member_register.mem_id = member.mem_id', 'type' => 'left');
$result = $this->_get_list_common($select, $join, $limit, $offset, $where, $like, $findex, $forder, $sfield, $skeyword, $sop);
return $result;
}
public function get_graph($start_date = '', $end_date = '')
{
if (empty($start_date) OR empty($end_date)) {
return false;
}
$this->db->where('left(mrg_datetime, 10) >=', $start_date);
$this->db->where('left(mrg_datetime, 10) <=', $end_date);
$this->db->select('mrg_referer');
$qry = $this->db->get($this->_table);
$result = $qry->result_array();
return $result;
}
}

View File

@@ -0,0 +1,29 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Member Userid model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Member_userid_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'member_userid';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'mem_id'; // 사용되는 테이블의 프라이머리키
function __construct()
{
parent::__construct();
}
}

View File

@@ -0,0 +1,52 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Menu model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Menu_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'menu';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'men_id'; // 사용되는 테이블의 프라이머리키
function __construct()
{
parent::__construct();
}
public function get_all_menu($device_view_type = '')
{
$cachename = $device_view_type === 'mobile'
? 'pagemenu-mobile' : 'pagemenu-desktop';
if ( ! $result = $this->cache->get($cachename)) {
$where = $device_view_type === 'mobile'
? array('men_mobile' => 1) : array('men_desktop' => 1);
$return = $this->get('', '', $where, '', 0, 'men_order', 'asc');
if ($return) {
foreach ($return as $key => $value) {
$result[$value['men_parent']][$value['men_id']] = $value;
}
$this->cache->save($cachename, $result);
}
}
return $result;
}
}

View File

@@ -0,0 +1,69 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Note model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Note_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'note';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'nte_id'; // 사용되는 테이블의 프라이머리키
function __construct()
{
parent::__construct();
}
public function get_note($where = '')
{
if (empty($where)) {
return;
}
$select = 'note.*, member.mem_id, member.mem_userid, member.mem_nickname, member.mem_is_admin, member.mem_icon';
$this->db->select($select);
$this->db->from($this->_table);
if (isset($where['send_mem_id']) && $where['send_mem_id']) {
$this->db->join('member', 'note.recv_mem_id = member.mem_id', 'left');
} elseif (isset($where['recv_mem_id']) && $where['recv_mem_id']) {
$this->db->join('member', 'note.send_mem_id = member.mem_id', 'left');
}
$this->db->where($where);
$result = $this->db->get();
return $result->row_array();
}
public function get_send_list($limit = '', $offset = '', $where = '', $like = '', $findex = '', $forder = '', $sfield = '', $skeyword = '', $sop = 'OR')
{
$select = 'note.*, member.mem_id, member.mem_userid, member.mem_nickname, member.mem_is_admin, member.mem_icon';
$join[] = array('table' => 'member', 'on' => 'note.recv_mem_id = member.mem_id', 'type' => 'left');
$result = $this->_get_list_common($select, $join, $limit, $offset, $where, $like, $findex, $forder, $sfield, $skeyword, $sop);
return $result;
}
public function get_recv_list($limit = '', $offset = '', $where = '', $like = '', $findex = '', $forder = '', $sfield = '', $skeyword = '', $sop = 'OR')
{
$select = 'note.*, member.mem_id, member.mem_userid, member.mem_nickname, member.mem_is_admin, member.mem_icon';
$join[] = array('table' => 'member', 'on' => 'note.send_mem_id = member.mem_id', 'type' => 'left');
$result = $this->_get_list_common($select, $join, $limit, $offset, $where, $like, $findex, $forder, $sfield, $skeyword, $sop);
return $result;
}
}

View File

@@ -0,0 +1,135 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Notification model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Notification_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'notification';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'not_id'; // 사용되는 테이블의 프라이머리키
function __construct()
{
parent::__construct();
}
public function get_notification_list($limit = '', $offset = '', $mem_id = 0, $nottype = '')
{
$mem_id = (int) $mem_id;
if (empty($mem_id) OR $mem_id < 1) {
return;
}
$this->db->select('notification.*, member.mem_id, member.mem_userid, member.mem_nickname, member.mem_is_admin, member.mem_icon');
$this->db->from($this->_table);
$this->db->join('member', 'notification.target_mem_id = member.mem_id', 'left');
$this->db->where(array('notification.mem_id' => $mem_id));
if ($nottype === 'Y') {
$this->db->where(array('not_read_datetime >' => '0000-00-00 00:00:00'));
}
if ($nottype === 'N') {
$this->db->group_start();
$this->db->where(array('not_read_datetime <=' => '0000-00-00 00:00:00'));
$this->db->or_where(array('not_read_datetime' => null));
$this->db->group_end();
}
$this->db->order_by('not_id', 'desc');
if ($limit) {
$this->db->limit($limit, $offset);
}
$qry = $this->db->get();
$result['list'] = $qry->result_array();
$this->db->select('count(*) as rownum');
$this->db->from($this->_table);
$this->db->join('member', 'notification.target_mem_id = member.mem_id', 'left');
$this->db->where(array('notification.mem_id' => $mem_id));
if ($nottype === 'Y') {
$this->db->where(array('not_read_datetime >' => '0000-00-00 00:00:00'));
}
if ($nottype === 'N') {
$this->db->group_start();
$this->db->where(array('not_read_datetime <=' => '0000-00-00 00:00:00'));
$this->db->or_where(array('not_read_datetime' => null));
$this->db->group_end();
}
$qry = $this->db->get();
$rows = $qry->row_array();
$result['total_rows'] = $rows['rownum'];
return $result;
}
public function unread_notification_num($mem_id = 0)
{
$mem_id = (int) $mem_id;
if (empty($mem_id) OR $mem_id < 1) {
return;
}
$this->db->where(array('mem_id' => $mem_id ));
$this->db->group_start();
$this->db->where(array('not_read_datetime <=' => '0000-00-00 00:00:00'));
$this->db->or_where(array('not_read_datetime' => null));
$this->db->group_end();
return $this->db->count_all_results($this->_table);
}
public function mark_read($not_id, $mem_id)
{
$where = array(
'not_id' => $not_id,
'mem_id' => $mem_id,
);
$updatedata = array(
'not_read_datetime' => cdate('Y-m-d H:i:s'),
);
$this->db->where($where);
$this->db->group_start();
$this->db->where(array('not_read_datetime <=' => '0000-00-00 00:00:00'));
$this->db->or_where(array('not_read_datetime' => null));
$this->db->group_end();
$this->db->set($updatedata);
return $this->db->update($this->_table);
}
public function mark_allread($mem_id)
{
$where = array(
'mem_id' => $mem_id,
);
$updatedata = array(
'not_read_datetime' => cdate('Y-m-d H:i:s'),
);
$this->db->where($where);
$this->db->group_start();
$this->db->where(array('not_read_datetime <=' => '0000-00-00 00:00:00'));
$this->db->or_where(array('not_read_datetime' => null));
$this->db->group_end();
$this->db->set($updatedata);
return $this->db->update($this->_table);
}
}

View File

@@ -0,0 +1,148 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Point model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Point_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'point';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'poi_id'; // 사용되는 테이블의 프라이머리키
function __construct()
{
parent::__construct();
}
public function get_admin_list($limit = '', $offset = '', $where = '', $like = '', $findex = '', $forder = '', $sfield = '', $skeyword = '', $sop = 'OR')
{
$select = 'point.*, member.mem_userid, member.mem_nickname, member.mem_is_admin, member.mem_icon, member.mem_point';
$join[] = array('table' => 'member', 'on' => 'point.mem_id = member.mem_id', 'type' => 'left');
$result = $this->_get_list_common($select, $join, $limit, $offset, $where, $like, $findex, $forder, $sfield, $skeyword, $sop);
return $result;
}
public function get_point_sum($mem_id = 0)
{
$mem_id = (int) $mem_id;
if (empty($mem_id) OR $mem_id < 1) {
return 0;
}
$this->db->select_sum('poi_point');
$this->db->where(array('mem_id' => $mem_id));
$result = $this->db->get('point');
$result = $result->row_array();
return $result['poi_point'];
}
public function point_ranking_all($limit = '')
{
if (empty($limit)) {
$limit = 100;
}
$this->db->select_sum('poi_point');
$this->db->select('member.mem_id, member.mem_userid, member.mem_nickname, member.mem_is_admin, member.mem_icon');
$this->db->join('member', 'point.mem_id = member.mem_id', 'inner');
$this->db->where('member.mem_denied', 0);
$this->db->where('member.mem_is_admin', 0);
$this->db->where('poi_point >', 0);
$this->db->group_by('member.mem_id');
$this->db->order_by('poi_point', 'DESC');
$this->db->limit($limit);
$qry = $this->db->get('point');
$result = $qry->result_array();
return $result;
}
public function point_ranking_month($year = 0, $month = 0, $limit = 0)
{
$year = (int) $year;
if ($year<1000 OR $year > 2999) {
$year = cdate('Y');
}
$month = (int) $month;
if ($month < 1 OR $month > 12) {
$month = (int) cdate('m');
}
$month = sprintf("%02d", $month);
$start_datetime = $year . '-' . $month . '-01 00:00:00';
$end_datetime = $year . '-' . $month . '-31 23:59:59';
if (empty($limit)) {
$limit = 100;
}
$this->db->select_sum('poi_point');
$this->db->select('member.mem_id, member.mem_userid, member.mem_nickname, member.mem_is_admin, member.mem_icon');
$this->db->join('member', 'point.mem_id = member.mem_id', 'inner');
$this->db->where('member.mem_denied', 0);
$this->db->where('member.mem_is_admin', 0);
$this->db->where('point.poi_datetime >=', $start_datetime);
$this->db->where('point.poi_datetime <=', $end_datetime);
$this->db->where('poi_point >', 0);
$this->db->group_by('member.mem_id');
$this->db->order_by('poi_point', 'DESC');
$this->db->limit($limit);
$qry = $this->db->get('point');
$result = $qry->result_array();
return $result;
}
public function member_count_by_point_count($point_count = 10, $datetime = '')
{
if (empty($datetime)) {
$datetime = ctimestamp() - 30 * 24 * 60 * 60;
}
$this->db->select('count(*) as cnt');
$this->db->where('poi_datetime <=', $datetime);
$this->db->group_by('mem_id');
$this->db->having('cnt >', $point_count);
$qry = $this->db->get('point');
$result = $qry->result_array();
return $result;
}
public function member_list_by_point_count($point_count = 10, $datetime = '')
{
if (empty($datetime)) {
$datetime = ctimestamp() - 30 * 24 * 60 * 60;
}
$this->db->select('mem_id, count(*) as cnt, sum(poi_point) as sum_point');
$this->db->where('poi_datetime <=', $datetime);
$this->db->group_by('mem_id');
$this->db->having('cnt >', $point_count);
$this->db->order_by('cnt', 'DESC');
$this->db->limit(100);
$qry = $this->db->get('point');
$result = $qry->result_array();
return $result;
}
}

View File

@@ -0,0 +1,80 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Popup model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Popup_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'popup';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'pop_id'; // 사용되는 테이블의 프라이머리키
public $cache_time = 86400; // 캐시 저장시간
function __construct()
{
parent::__construct();
check_cache_dir('popup');
}
public function get_today_list()
{
$cachename = 'popup/popup-info-' . cdate('Y-m-d');
$data = array();
if ( ! $data = $this->cache->get($cachename)) {
$this->db->from($this->_table);
$this->db->where('pop_activated', 1);
$this->db->group_start();
$this->db->where(array('pop_start_date <=' => cdate('Y-m-d')));
$this->db->or_where(array('pop_start_date' => null));
$this->db->group_end();
$this->db->group_start();
$this->db->where('pop_end_date >=', cdate('Y-m-d'));
$this->db->or_where('pop_end_date', '0000-00-00');
$this->db->or_where(array('pop_end_date' => ''));
$this->db->or_where(array('pop_end_date' => null));
$this->db->group_end();
$res = $this->db->get();
$result['list'] = $res->result_array();
$data['result'] = $result;
$data['cached'] = '1';
$this->cache->save($cachename, $data, $this->cache_time);
}
return isset($data['result']) ? $data['result'] : false;
}
public function delete($primary_value = '', $where = '')
{
$result = parent::delete($primary_value, $where);
$this->cache->delete('popup/popup-info-' . cdate('Y-m-d'));
return $result;
}
public function update($primary_value = '', $updatedata = '', $where = '')
{
$result = parent::update($primary_value, $updatedata);
$this->cache->delete('popup/popup-info-' . cdate('Y-m-d'));
return $result;
}
}

View File

@@ -0,0 +1,194 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Post Extra Vars model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Post_extra_vars_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'post_extra_vars';
/**
* 사용되는 테이블의 프라이머리키
*/
public $parent_key = 'post_id';
public $meta_key = 'pev_key';
public $meta_value = 'pev_value';
public $cache_prefix= 'post_extra_vars/post-extra-vars-model-get-'; // 캐시 사용시 프리픽스
public $cache_time = 86400; // 캐시 저장시간
function __construct()
{
parent::__construct();
check_cache_dir('post_extra_vars');
}
public function get_all_meta($post_id = 0)
{
if (empty($post_id)) {
return false;
}
$cachename = $this->cache_prefix . $post_id;
$data = array();
if ( ! $data = $this->cache->get($cachename)) {
$result = array();
$res = $this->get($primary_value = '', $select = '', array($this->parent_key => $post_id));
if ($res && is_array($res)) {
foreach ($res as $val) {
$result[$val[$this->meta_key]] = $val[$this->meta_value];
}
}
$data['result'] = $result;
$data['cached'] = '1';
$this->cache->save($cachename, $data, $this->cache_time);
}
return isset($data['result']) ? $data['result'] : false;
}
public function save($post_id = 0, $brd_id = 0, $savedata = '')
{
if (empty($post_id)) {
return false;
}
$brd_id = (int) $brd_id;
if (empty($brd_id) OR $brd_id < 1) {
return false;
}
if ($savedata && is_array($savedata)) {
foreach ($savedata as $column => $value) {
$this->meta_update($post_id, $brd_id, $column, $value);
}
}
$this->cache->delete($this->cache_prefix . $post_id);
}
public function deletemeta($post_id = 0)
{
if (empty($post_id)) {
return false;
}
$this->delete_where(array($this->parent_key => $post_id));
$this->cache->delete($this->cache_prefix . $post_id);
}
public function meta_update($post_id = 0, $brd_id = 0, $column = '', $value = false)
{
if (empty($post_id)) {
return false;
}
$column = trim($column);
if (empty($column)) {
return false;
}
$brd_id = (int) $brd_id;
if (empty($brd_id) OR $brd_id < 1) {
return false;
}
$old_value = $this->item($post_id, $column);
if (empty($value)) {
$value = '';
}
if ($value === $old_value) {
return false;
}
if (is_array($value)) {
$value = json_encode($value);
}
if (false === $old_value) {
return $this->add_meta($post_id, $brd_id, $column, $value);
}
return $this->update_meta($post_id, $column, $value);
}
public function item($post_id = 0, $column = '')
{
if (empty($post_id)) {
return false;
}
if (empty($column)) {
return false;
}
$result = $this->get_all_meta($post_id);
return isset($result[ $column ]) ? $result[ $column ] : false;
}
public function add_meta($post_id = 0, $brd_id = 0, $column = '', $value = '')
{
if (empty($post_id)) {
return false;
}
$column = trim($column);
if (empty($column)) {
return false;
}
$brd_id = (int) $brd_id;
if (empty($brd_id) OR $brd_id < 1) {
return false;
}
$updatedata = array(
'post_id' => $post_id,
'brd_id' => $brd_id,
'pev_key' => $column,
'pev_value' => $value,
);
$this->db->replace($this->_table, $updatedata);
return true;
}
public function deletemeta_item($column = '')
{
if (empty($column)) {
return false;
}
$this->delete_where(array($this->meta_key => $column));
}
public function update_meta($post_id = 0, $column = '', $value = '')
{
if (empty($post_id)) {
return false;
}
$column = trim($column);
if (empty($column)) {
return false;
}
$this->db->where($this->parent_key, $post_id);
$this->db->where($this->meta_key, $column);
$data = array($this->meta_value => $value);
$this->db->update($this->_table, $data);
return true;
}
}

View File

@@ -0,0 +1,79 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Post File Download Log model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Post_file_download_log_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'post_file_download_log';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'pfd_id'; // 사용되는 테이블의 프라이머리키
function __construct()
{
parent::__construct();
}
public function get_admin_list($limit = '', $offset = '', $where = '', $like = '', $findex = '', $forder = '', $sfield = '', $skeyword = '', $sop = 'OR')
{
$select = 'post_file_download_log.*, post.mem_id as post_mem_id, post.post_userid, post.post_nickname, post.brd_id, post.post_datetime,
post.post_hit, post.post_secret, post.post_title, post_file.pfi_id, post_file.pfi_originname, post_file.pfi_filename, post_file.pfi_download,
post_file.pfi_filesize, post_file.pfi_width, post_file.pfi_height, post_file.pfi_type, post_file.pfi_is_image, post_file.pfi_datetime, post_file.pfi_ip';
$join[] = array('table' => 'post_file', 'on' => 'post_file_download_log.pfi_id = post_file.pfi_id', 'type' => 'inner');
$join[] = array('table' => 'post', 'on' => 'post_file.post_id = post.post_id', 'type' => 'inner');
$result = $this->_get_list_common($select, $join, $limit, $offset, $where, $like, $findex, $forder, $sfield, $skeyword, $sop);
return $result;
}
public function get_list($limit = '', $offset = '', $where = '', $like = '', $findex = '', $forder = '', $sfield = '', $skeyword = '', $sop = 'OR')
{
$select = 'post_file_download_log.*, post.mem_id as post_mem_id, post.post_userid, post.post_nickname, post.brd_id, post.post_datetime,
post.post_hit, post.post_secret, post.post_title, post_file.pfi_id, post_file.pfi_originname, post_file.pfi_filename, post_file.pfi_download,
post_file.pfi_filesize, post_file.pfi_width, post_file.pfi_height, post_file.pfi_type, post_file.pfi_is_image, post_file.pfi_datetime, post_file.pfi_ip';
$join[] = array('table' => 'post_file', 'on' => 'post_file_download_log.pfi_id = post_file.pfi_id', 'type' => 'inner');
$join[] = array('table' => 'post', 'on' => 'post_file.post_id = post.post_id', 'type' => 'inner');
$result = $this->_get_list_common($select, $join, $limit, $offset, $where, $like, $findex, $forder, $sfield, $skeyword, $sop);
return $result;
}
public function get_post_file_download_count($type = 'd', $start_date = '', $end_date = '', $brd_id = 0, $orderby = 'asc')
{
if (empty($start_date) OR empty($end_date)) {
return false;
}
$left = ($type === 'y') ? 4 : ($type === 'm' ? 7 : 10);
if (strtolower($orderby) !== 'desc') $orderby = 'asc';
$this->db->select('count(*) as cnt, left(pfd_datetime, ' . $left . ') as day ', false);
$this->db->where('left(pfd_datetime, 10) >=', $start_date);
$this->db->where('left(pfd_datetime, 10) <=', $end_date);
$brd_id = (int) $brd_id;
if ($brd_id) {
$this->db->where('brd_id', $brd_id);
}
$this->db->group_by('day');
$this->db->order_by('pfd_datetime', $orderby);
$qry = $this->db->get($this->_table);
$result = $qry->result_array();
return $result;
}
}

View File

@@ -0,0 +1,80 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Post File model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Post_file_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'post_file';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'pfi_id'; // 사용되는 테이블의 프라이머리키
function __construct()
{
parent::__construct();
}
public function get_admin_list($limit = '', $offset = '', $where = '', $like = '', $findex = '', $forder = '', $sfield = '', $skeyword = '', $sop = 'OR')
{
$select = 'post_file.*, post.mem_id as post_mem_id, post.post_userid, post.post_nickname, post.brd_id, post.post_datetime, post.post_hit, post.post_secret, post.post_title';
$join[] = array('table' => 'post', 'on' => 'post_file.post_id = post.post_id', 'type' => 'inner');
$result = $this->_get_list_common($select, $join, $limit, $offset, $where, $like, $findex, $forder, $sfield, $skeyword, $sop);
return $result;
}
public function get_post_file_by_date($type = 'd', $start_date = '', $end_date = '', $brd_id = 0, $orderby = 'asc')
{
if (empty($start_date) OR empty($end_date)) {
return false;
}
$left = ($type === 'y') ? 4 : ($type === 'm' ? 7 : 10);
if (strtolower($orderby) !== 'desc') $orderby = 'asc';
$this->db->select('count(*) as cnt, left(pfi_datetime, ' . $left . ') as day ', false);
$this->db->where('left(pfi_datetime, 10) >=', $start_date);
$this->db->where('left(pfi_datetime, 10) <=', $end_date);
$brd_id = (int) $brd_id;
if ($brd_id) {
$this->db->where('brd_id', $brd_id);
}
$this->db->group_by('day');
$this->db->order_by('pfi_datetime', $orderby);
$qry = $this->db->get($this->_table);
$result = $qry->result_array();
return $result;
}
public function get_post_file_count($post_id = 0)
{
$post_id = (int) $post_id;
if (empty($post_id) OR $post_id < 1) {
return false;
}
$this->db->select('count(*) as cnt, pfi_is_image ', false);
$this->db->where('post_id', $post_id);
$this->db->group_by('pfi_is_image');
$qry = $this->db->get($this->_table);
$result = $qry->result_array();
return $result;
}
}

View File

@@ -0,0 +1,55 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Post History model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Post_history_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'post_history';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'phi_id'; // 사용되는 테이블의 프라이머리키
function __construct()
{
parent::__construct();
}
public function get_admin_list($limit = '', $offset = '', $where = '', $like = '', $findex = '', $forder = '', $sfield = '', $skeyword = '', $sop = 'OR')
{
$select = 'post_history.*, post.mem_id as post_mem_id, post.post_userid, post.post_nickname,
post.brd_id, post.post_datetime, post.post_hit, post.post_secret, member.mem_id, member.mem_userid,
member.mem_username, member.mem_nickname, member.mem_is_admin, member.mem_icon';
$join[] = array('table' => 'post', 'on' => 'post_history.post_id = post.post_id', 'type' => 'inner');
$join[] = array('table' => 'member', 'on' => 'post_history.mem_id = member.mem_id', 'type' => 'left');
$result = $this->_get_list_common($select, $join, $limit, $offset, $where, $like, $findex, $forder, $sfield, $skeyword, $sop);
return $result;
}
public function get_list($limit = '', $offset = '', $where = '', $like = '', $findex = '', $forder = '', $sfield = '', $skeyword = '', $sop = 'OR')
{
$select = 'post_history.*, post.mem_id as post_mem_id, post.post_userid, post.post_nickname,
post.brd_id, post.post_datetime, post.post_hit, post.post_secret, member.mem_id, member.mem_userid,
member.mem_username, member.mem_nickname, member.mem_is_admin, member.mem_icon';
$join[] = array('table' => 'post', 'on' => 'post_history.post_id = post.post_id', 'type' => 'inner');
$join[] = array('table' => 'member', 'on' => 'post_history.mem_id = member.mem_id', 'type' => 'left');
$result = $this->_get_list_common($select, $join, $limit, $offset, $where, $like, $findex, $forder, $sfield, $skeyword, $sop);
return $result;
}
}

View File

@@ -0,0 +1,77 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Post Link Click Log model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Post_link_click_log_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'post_link_click_log';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'plc_id'; // 사용되는 테이블의 프라이머리키
function __construct()
{
parent::__construct();
}
public function get_admin_list($limit = '', $offset = '', $where = '', $like = '', $findex = '', $forder = '', $sfield = '', $skeyword = '', $sop = 'OR')
{
$select = 'post_link_click_log.*, post.mem_id as post_mem_id, post.post_userid, post.post_nickname,
post.brd_id, post.post_datetime, post.post_hit, post.post_secret, post.post_title, post_link.*';
$join[] = array('table' => 'post_link', 'on' => 'post_link_click_log.pln_id = post_link.pln_id', 'type' => 'inner');
$join[] = array('table' => 'post', 'on' => 'post_link.post_id = post.post_id', 'type' => 'inner');
$result = $this->_get_list_common($select, $join, $limit, $offset, $where, $like, $findex, $forder, $sfield, $skeyword, $sop);
return $result;
}
public function get_list($limit = '', $offset = '', $where = '', $like = '', $findex = '', $forder = '', $sfield = '', $skeyword = '', $sop = 'OR')
{
$select = 'post_link_click_log.*, post.mem_id as post_mem_id, post.post_userid, post.post_nickname,
post.brd_id, post.post_datetime, post.post_hit, post.post_secret, post.post_title, post_link.*';
$join[] = array('table' => 'post_link', 'on' => 'post_link_click_log.pln_id = post_link.pln_id', 'type' => 'inner');
$join[] = array('table' => 'post', 'on' => 'post_link.post_id = post.post_id', 'type' => 'inner');
$result = $this->_get_list_common($select, $join, $limit, $offset, $where, $like, $findex, $forder, $sfield, $skeyword, $sop);
return $result;
}
public function get_link_click_count($type = 'd', $start_date = '', $end_date = '', $brd_id = 0, $orderby = 'asc')
{
if (empty($start_date) OR empty($end_date)) {
return false;
}
$left = ($type === 'y') ? 4 : ($type === 'm' ? 7 : 10);
if (strtolower($orderby) !== 'desc') $orderby = 'asc';
$this->db->select('count(*) as cnt, left(plc_datetime, ' . $left . ') as day ', false);
$this->db->where('left(plc_datetime, 10) >=', $start_date);
$this->db->where('left(plc_datetime, 10) <=', $end_date);
$brd_id = (int) $brd_id;
if ($brd_id) {
$this->db->where('brd_id', $brd_id);
}
$this->db->group_by('day');
$this->db->order_by('plc_datetime', $orderby);
$qry = $this->db->get($this->_table);
$result = $qry->result_array();
return $result;
}
}

View File

@@ -0,0 +1,29 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Post Link model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Post_link_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'post_link';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'pln_id'; // 사용되는 테이블의 프라이머리키
function __construct()
{
parent::__construct();
}
}

View File

@@ -0,0 +1,203 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Post Meta model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Post_meta_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'post_meta';
/**
* 사용되는 테이블의 프라이머리키
*/
public $parent_key = 'post_id';
public $meta_key = 'pmt_key';
public $meta_value = 'pmt_value';
public $cache_prefix= 'post_meta/post-meta-model-get-'; // 캐시 사용시 프리픽스
public $cache_time = 86400; // 캐시 저장시간
function __construct()
{
parent::__construct();
check_cache_dir('post_meta');
}
public function get_all_meta($post_id = 0)
{
$post_id = (int) $post_id;
if (empty($post_id) OR $post_id < 1) {
return false;
}
$cachename = $this->cache_prefix . $post_id;
$data = array();
if ( ! $data = $this->cache->get($cachename)) {
$result = array();
$res = $this->get($primary_value = '', $select = '', array($this->parent_key => $post_id));
if ($res && is_array($res)) {
foreach ($res as $val) {
$result[$val[$this->meta_key]] = $val[$this->meta_value];
}
}
$data['result'] = $result;
$data['cached'] = '1';
$this->cache->save($cachename, $data, $this->cache_time);
}
return isset($data['result']) ? $data['result'] : false;
}
public function save($post_id = 0, $brd_id = 0, $savedata = '')
{
$post_id = (int) $post_id;
if (empty($post_id) OR $post_id < 1) {
return false;
}
if ($savedata && is_array($savedata)) {
foreach ($savedata as $column => $value) {
$this->meta_update($post_id, $brd_id, $column, $value);
}
}
$this->cache->delete($this->cache_prefix . $post_id);
}
public function deletemeta($post_id = 0)
{
$post_id = (int) $post_id;
if (empty($post_id) OR $post_id < 1) {
return false;
}
$this->delete_where(array($this->parent_key => $post_id));
$this->cache->delete($this->cache_prefix . $post_id);
}
public function meta_update($post_id = 0, $brd_id = 0, $column = '', $value = false)
{
$post_id = (int) $post_id;
if (empty($post_id) OR $post_id < 1) {
return false;
}
$brd_id = (int) $brd_id;
if (empty($brd_id) OR $brd_id < 1) {
return false;
}
$column = trim($column);
if (empty($column)) {
return false;
}
$old_value = $this->item($post_id, $column);
if (empty($value)) {
$value = '';
}
if ($value === $old_value) {
return false;
}
if (false === $old_value) {
return $this->add_meta($post_id, $brd_id, $column, $value);
}
return $this->update_meta($post_id, $column, $value);
}
public function item($post_id = 0, $column = '')
{
$post_id = (int) $post_id;
if (empty($post_id) OR $post_id < 1) {
return false;
}
if (empty($column)) {
return false;
}
$result = $this->get_all_meta($post_id);
return isset($result[ $column ]) ? $result[ $column ] : false;
}
public function add_meta($post_id = 0, $brd_id = 0, $column = '', $value = '')
{
$post_id = (int) $post_id;
if (empty($post_id) OR $post_id < 1) {
return false;
}
$brd_id = (int) $brd_id;
if (empty($brd_id) OR $brd_id < 1) {
return false;
}
$column = trim($column);
if (empty($column)) {
return false;
}
$updatedata = array(
'post_id' => $post_id,
'brd_id' => $brd_id,
'pmt_key' => $column,
'pmt_value' => $value,
);
$this->db->replace($this->_table, $updatedata);
return true;
}
public function update_meta($post_id = 0, $column = '', $value = '')
{
$post_id = (int) $post_id;
if (empty($post_id) OR $post_id < 1) {
return false;
}
$column = trim($column);
if (empty($column)) {
return false;
}
$this->db->where($this->parent_key, $post_id);
$this->db->where($this->meta_key, $column);
$data = array($this->meta_value => $value);
$this->db->update($this->_table, $data);
return true;
}
public function delete_meta_column($post_id = 0, $column = '')
{
$post_id = (int) $post_id;
if (empty($post_id) OR $post_id < 1) {
return false;
}
$column = trim($column);
if (empty($column)) {
return false;
}
$this->delete_where(array($this->parent_key, $post_id, $this->meta_key => $column));
return true;
}
}

View File

@@ -0,0 +1,576 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Post model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Post_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'post';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'post_id'; // 사용되는 테이블의 프라이머리키
public $allow_order = array('post_num, post_reply', 'post_datetime desc', 'post_datetime asc', 'post_hit desc', 'post_hit asc', 'post_comment_count desc', 'post_comment_count asc', 'post_comment_updated_datetime desc', 'post_comment_updated_datetime asc', 'post_like desc', 'post_like asc', 'post_id desc');
function __construct()
{
parent::__construct();
}
/**
* List 페이지 커스테마이징 함수
*/
public function get_post_list($limit = '', $offset = '', $where = '', $category_id = '', $orderby = '', $sfield = '', $skeyword = '', $sop = 'OR')
{
if ( ! in_array(strtolower($orderby), $this->allow_order)) {
$orderby = 'post_num, post_reply';
}
$sop = (strtoupper($sop) === 'AND') ? 'AND' : 'OR';
if (empty($sfield)) {
$sfield = array('post_title', 'post_content');
}
$search_where = array();
$search_like = array();
$search_or_like = array();
if ($sfield && is_array($sfield)) {
foreach ($sfield as $skey => $sval) {
$ssf = $sval;
if ($skeyword && $ssf && in_array($ssf, $this->allow_search_field)) {
if (in_array($ssf, $this->search_field_equal)) {
$search_where[$ssf] = $skeyword;
} else {
$swordarray = explode(' ', $skeyword);
foreach ($swordarray as $str) {
if (empty($ssf)) {
continue;
}
if ($sop === 'AND') {
$search_like[] = array($ssf => $str);
} else {
$search_or_like[] = array($ssf => $str);
}
}
}
}
}
} else {
$ssf = $sfield;
if ($skeyword && $ssf && in_array($ssf, $this->allow_search_field)) {
if (in_array($ssf, $this->search_field_equal)) {
$search_where[$ssf] = $skeyword;
} else {
$swordarray = explode(' ', $skeyword);
foreach ($swordarray as $str) {
if (empty($ssf)) {
continue;
}
if ($sop === 'AND') {
$search_like[] = array($ssf => $str);
} else {
$search_or_like[] = array($ssf => $str);
}
}
}
}
}
$this->db->select('post.*, member.mem_id, member.mem_userid, member.mem_nickname, member.mem_icon, member.mem_photo, member.mem_point');
$this->db->from($this->_table);
$this->db->join('member', 'post.mem_id = member.mem_id', 'left');
if ($where) {
$this->db->where($where);
}
if ($search_where) {
$this->db->where($search_where);
}
if ($category_id) {
if (strpos($category_id, '.')) {
$this->db->like('post_category', $category_id . '', 'after');
} else {
$this->db->group_start();
$this->db->where('post_category', $category_id);
$this->db->or_like('post_category', $category_id . '.', 'after');
$this->db->group_end();
}
}
if ($search_like) {
foreach ($search_like as $item) {
foreach ($item as $skey => $sval) {
$this->db->like($skey, $sval);
}
}
}
if ($search_or_like) {
$this->db->group_start();
foreach ($search_or_like as $item) {
foreach ($item as $skey => $sval) {
$this->db->or_like($skey, $sval);
}
}
$this->db->group_end();
}
$this->db->order_by($orderby);
if ($limit) {
$this->db->limit($limit, $offset);
}
$qry = $this->db->get();
$result['list'] = $qry->result_array();
$this->db->select('count(*) as rownum');
$this->db->from($this->_table);
$this->db->join('member', 'post.mem_id = member.mem_id', 'left');
if ($where) {
$this->db->where($where);
}
if ($search_where) {
$this->db->where($search_where);
}
if ($category_id) {
if (strpos($category_id, '.')) {
$this->db->like('post_category', $category_id . '', 'after');
} else {
$this->db->group_start();
$this->db->where('post_category', $category_id);
$this->db->or_like('post_category', $category_id . '.', 'after');
$this->db->group_end();
}
}
if ($search_like) {
foreach ($search_like as $item) {
foreach ($item as $skey => $sval) {
$this->db->like($skey, $sval);
}
}
}
if ($search_or_like) {
$this->db->group_start();
foreach ($search_or_like as $item) {
foreach ($item as $skey => $sval) {
$this->db->or_like($skey, $sval);
}
}
$this->db->group_end();
}
$qry = $this->db->get();
$rows = $qry->row_array();
$result['total_rows'] = $rows['rownum'];
return $result;
}
public function get_notice_list($brd_id = 0, $except_all_notice = '', $sfield = '', $skeyword = '', $sop = 'OR')
{
$brd_id = (int) $brd_id;
if (empty($brd_id) OR $brd_id < 1) {
return;
}
$sop = (strtoupper($sop) === 'AND') ? 'AND' : 'OR';
if (empty($sfield)) {
$sfield = array('post_title', 'post_content');
}
$search_where = array();
$search_like = array();
$search_or_like = array();
if ($sfield && is_array($sfield)) {
foreach ($sfield as $skey => $sval) {
$ssf = $sval;
if ($skeyword && $ssf && in_array($ssf, $this->allow_search_field)) {
if (in_array($ssf, $this->search_field_equal)) {
$search_where[$ssf] = $skeyword;
} else {
$swordarray = explode(' ', $skeyword);
foreach ($swordarray as $str) {
if (empty($ssf)) {
continue;
}
if ($sop === 'AND') {
$search_like[] = array($ssf => $str);
} else {
$search_or_like[] = array($ssf => $str);
}
}
}
}
}
} else {
$ssf = $sfield;
if ($skeyword && $ssf && in_array($ssf, $this->allow_search_field)) {
if (in_array($ssf, $this->search_field_equal)) {
$search_where[$ssf] = $skeyword;
} else {
$swordarray = explode(' ', $skeyword);
foreach ($swordarray as $str) {
if (empty($ssf)) {
continue;
}
if ($sop === 'AND') {
$search_like[] = array($ssf => $str);
} else {
$search_or_like[] = array($ssf => $str);
}
}
}
}
}
$this->db->select('post.*, member.mem_id, member.mem_userid, member.mem_nickname, member.mem_icon, member.mem_photo, member.mem_point');
$this->db->from($this->_table);
$this->db->join('member', 'post.mem_id = member.mem_id', 'left');
if ($except_all_notice) {
$this->db->where('brd_id', $brd_id);
$this->db->where('post_notice', 1);
} else {
$this->db->where('(( brd_id = ' . $brd_id . ' AND post_notice = 1) OR post_notice = 2) ', null, false);
}
$this->db->where('post_del <>', 2);
if ($search_like) {
foreach ($search_like as $item) {
foreach ($item as $skey => $sval) {
$this->db->like($skey, $sval);
}
}
}
if ($search_or_like) {
$this->db->group_start();
foreach ($search_or_like as $item) {
foreach ($item as $skey => $sval) {
$this->db->or_like($skey, $sval);
}
}
$this->db->group_end();
}
$this->db->order_by('post_num, post_reply');
$qry = $this->db->get();
$result = $qry->result_array();
return $result;
}
/**
* List 페이지 커스테마이징 함수
*/
public function get_prev_next_post($post_id = 0, $post_num = 0, $type = '', $where = '', $sfield = '', $skeyword = '', $sop = 'OR')
{
$post_id = (int) $post_id;
if (empty($post_id) OR $post_id < 1) {
return false;
}
$sop = (strtoupper($sop) === 'AND') ? 'AND' : 'OR';
if (empty($sfield)) {
$sfield = array('post_title', 'post_content');
}
$search_where = array();
$search_like = array();
$search_or_like = array();
if ($sfield && is_array($sfield)) {
foreach ($sfield as $skey => $sval) {
$ssf = $sval;
if ($skeyword && $ssf && in_array($ssf, $this->allow_search_field)) {
if (in_array($ssf, $this->search_field_equal)) {
$search_where[$ssf] = $skeyword;
} else {
$swordarray = explode(' ', $skeyword);
foreach ($swordarray as $str) {
if (empty($ssf)) {
continue;
}
if ($sop === 'AND') {
$search_like[] = array($ssf => $str);
} else {
$search_or_like[] = array($ssf => $str);
}
}
}
}
}
} else {
$ssf = $sfield;
if ($skeyword && $ssf && in_array($ssf, $this->allow_search_field)) {
if (in_array($ssf, $this->search_field_equal)) {
$search_where[$ssf] = $skeyword;
} else {
$swordarray = explode(' ', $skeyword);
foreach ($swordarray as $str) {
if (empty($ssf)) {
continue;
}
if ($sop === 'AND') {
$search_like[] = array($ssf => $str);
} else {
$search_or_like[] = array($ssf => $str);
}
}
}
}
}
$this->db->select('post.*, member.mem_id, member.mem_userid, member.mem_nickname, member.mem_icon, member.mem_photo, member.mem_point');
$this->db->from($this->_table);
$this->db->join('member', 'post.mem_id = member.mem_id', 'left');
if ($type === 'next') {
$where['post_num >'] = $post_num;
} else {
$where['post_num <'] = $post_num;
}
if ($where) {
$this->db->where($where);
}
if ($search_where) {
$this->db->where($search_where);
}
if ($search_like) {
foreach ($search_like as $item) {
foreach ($item as $skey => $sval) {
$this->db->like($skey, $sval);
}
}
}
if ($search_or_like) {
$this->db->group_start();
foreach ($search_or_like as $item) {
foreach ($item as $skey => $sval) {
$this->db->or_like($skey, $sval);
}
}
$this->db->group_end();
}
$orderby = $type === 'next'
? 'post_num, post_reply' : 'post_num desc, post_reply desc';
$this->db->order_by($orderby);
$this->db->limit(1);
$qry = $this->db->get();
$result = $qry->row_array();
return $result;
}
/**
* List 페이지 커스테마이징 함수
*/
public function get_search_list($limit = '', $offset = '', $where = '', $like = '', $board_id = 0, $orderby = '', $sfield = '', $skeyword = '', $sop = 'OR')
{
if ( ! in_array(strtolower($orderby), $this->allow_order)) {
$orderby = 'post_num, post_reply';
}
$sop = (strtoupper($sop) === 'AND') ? 'AND' : 'OR';
if (empty($sfield)) {
$sfield = array('post_title', 'post_content');
}
$search_where = array();
$search_like = array();
$search_or_like = array();
if ($sfield && is_array($sfield)) {
foreach ($sfield as $skey => $sval) {
$ssf = $sval;
if ($skeyword && $ssf && in_array($ssf, $this->allow_search_field)) {
if (in_array($ssf, $this->search_field_equal)) {
$search_where[$ssf] = $skeyword;
} else {
$swordarray = explode(' ', $skeyword);
foreach ($swordarray as $str) {
if (empty($ssf)) {
continue;
}
if ($sop === 'AND') {
$search_like[] = array($ssf => $str);
} else {
$search_or_like[] = array($ssf => $str);
}
}
}
}
}
} else {
$ssf = $sfield;
if ($skeyword && $ssf && in_array($ssf, $this->allow_search_field)) {
if (in_array($ssf, $this->search_field_equal)) {
$search_where[$ssf] = $skeyword;
} else {
$swordarray = explode(' ', $skeyword);
foreach ($swordarray as $str) {
if (empty($ssf)) {
continue;
}
if ($sop === 'AND') {
$search_like[] = array($ssf => $str);
} else {
$search_or_like[] = array($ssf => $str);
}
}
}
}
}
$this->db->select('post.*, board.brd_key, board.brd_name, board.brd_mobile_name, board.brd_order, board.brd_search,
member.mem_id, member.mem_userid, member.mem_nickname, member.mem_icon, member.mem_photo, member.mem_point ');
$this->db->from('post');
$this->db->join('board', 'post.brd_id = board.brd_id', 'inner');
$this->db->join('member', 'post.mem_id = member.mem_id', 'left');
if ($where) {
$this->db->where($where);
}
if ($search_where) {
$this->db->where($search_where);
}
if ($like) {
$this->db->like($like);
}
if ($search_like) {
foreach ($search_like as $item) {
foreach ($item as $skey => $sval) {
$this->db->like($skey, $sval);
}
}
}
if ($search_or_like) {
$this->db->group_start();
foreach ($search_or_like as $item) {
foreach ($item as $skey => $sval) {
$this->db->or_like($skey, $sval);
}
}
$this->db->group_end();
}
$this->db->where( array('brd_search' => 1));
$board_id = (int) $board_id;
if ($board_id) {
$this->db->where( array('b.brd_id' => $board_id));
}
$this->db->order_by($orderby);
if ($limit) {
$this->db->limit($limit, $offset);
}
$qry = $this->db->get();
$result['list'] = $qry->result_array();
$this->db->select('count(*) cnt, board.brd_id');
$this->db->from('post');
$this->db->join('board', 'post.brd_id = board.brd_id', 'inner');
if ($where) {
$this->db->where($where);
}
if ($search_where) {
$this->db->where($search_where);
}
if ($like) {
$this->db->like($like);
}
if ($search_like) {
foreach ($search_like as $item) {
foreach ($item as $skey => $sval) {
$this->db->like($skey, $sval);
}
}
}
if ($search_or_like) {
$this->db->group_start();
foreach ($search_or_like as $item) {
foreach ($item as $skey => $sval) {
$this->db->or_like($skey, $sval);
}
}
$this->db->group_end();
}
$this->db->where( array('brd_search' => 1));
$this->db->group_by('board.brd_id');
$qry = $this->db->get();
$cnt = $qry->result_array();
$result['total_rows'] = 0;
if ($cnt) {
foreach ($cnt as $key => $value) {
if (element('brd_id', $value)) {
$result['board_rows'][$value['brd_id']] = element('cnt', $value);
}
}
if ($board_id) {
$result['total_rows'] = $result['board_rows'][$board_id];
} else {
$result['total_rows'] = array_sum($result['board_rows']);
}
}
return $result;
}
public function get_rss_list($where = '', $where_in = '', $limit = '', $offset = '')
{
if ($where) {
$this->db->where($where);
}
if ($where_in) {
$this->db->where_in('brd_id', $where_in);
}
$this->db->order_by('post_num, post_reply');
if ($limit) {
$this->db->limit($limit, $offset);
}
$qry = $this->db->get($this->_table);
$result['list'] = $qry->result_array();
return $result;
}
public function comment_updated($primary_value = '', $datetime = '')
{
if (empty($primary_value)) {
return false;
}
$this->db->where($this->primary_key, $primary_value);
$this->db->set('post_comment_count', 'post_comment_count+1', false);
$this->db->set('post_comment_updated_datetime', $datetime);
$result = $this->db->update($this->_table);
return $result;
}
public function next_post_num()
{
$this->db->select_min('post_num');
$result = $this->db->get($this->_table);
$row = $result->row_array();
$row['post_num'] = (isset($row['post_num'])) ? $row['post_num'] : 0;
$post_num = $row['post_num'] - 1;
return $post_num;
}
}

View File

@@ -0,0 +1,41 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Post naver syndi log model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Post_naver_syndi_log_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'post_naver_syndi_log';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'pns_id'; // 사용되는 테이블의 프라이머리키
function __construct()
{
parent::__construct();
}
public function get_admin_list($limit = '', $offset = '', $where = '', $like = '', $findex = '', $forder = '', $sfield = '', $skeyword = '', $sop = 'OR')
{
$select = 'post_naver_syndi_log.*, post.mem_id as post_mem_id, post.post_userid, post.post_nickname,
post.brd_id, post.post_datetime, post.post_hit, post.post_secret, post.post_title';
$join[] = array('table' => 'post', 'on' => 'post_naver_syndi_log.post_id = post.post_id', 'type' => 'inner');
$result = $this->_get_list_common($select, $join, $limit, $offset, $where, $like, $findex, $forder, $sfield, $skeyword, $sop);
return $result;
}
}

View File

@@ -0,0 +1,127 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Post Tag model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Post_tag_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'post_tag';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'pta_id'; // 사용되는 테이블의 프라이머리키
function __construct()
{
parent::__construct();
}
public function get_post_tag_count($type = 'd', $start_date = '', $end_date = '', $brd_id = 0)
{
if (empty($start_date) OR empty($end_date)) {
return false;
}
$left = ($type === 'y') ? 4 : ($type === 'm' ? 7 : 10);
$this->db->select('count(*) as cnt, pta_tag ', false);
$this->db->from('post_tag');
$this->db->join('post', 'post.post_id = post_tag.post_id', 'left');
$this->db->where('left(post_datetime, 10) >=', $start_date);
$this->db->where('left(post_datetime, 10) <=', $end_date);
$this->db->where('post_del', 0);
$brd_id = (int) $brd_id;
if ($brd_id) {
$this->db->where('post.brd_id', $brd_id);
}
$this->db->group_by('pta_tag');
$this->db->order_by('cnt', 'desc');
$qry = $this->db->get();
$result = $qry->result_array();
return $result;
}
public function get_admin_list($limit = '', $offset = '', $where = '', $like = '', $findex = '', $forder = '', $sfield = '', $skeyword = '', $sop = 'OR')
{
$select = 'post_tag.*, post.mem_id as post_mem_id, post.post_userid, post.post_nickname, post.brd_id, post.post_datetime, post.post_hit, post.post_secret, post.post_title';
$join[] = array('table' => 'post', 'on' => 'post_tag.post_id = post.post_id', 'type' => 'inner');
$result = $this->_get_list_common($select, $join, $limit, $offset, $where, $like, $findex, $forder, $sfield, $skeyword, $sop);
return $result;
}
/**
* List 페이지 커스테마이징 함수
*/
public function get_tag_list ($limit = '', $offset = '', $tag = '')
{
if (empty($tag)) {
return false;
}
$this->db->select('post.*, board.brd_key, board.brd_name, board.brd_mobile_name, board.brd_order, board.brd_search ');
$this->db->from('post ');
$this->db->join('board', 'post.brd_id = board.brd_id', 'inner');
$this->db->join('post_tag', 'post.post_id = post_tag.post_id', 'inner');
$where = array(
'board.brd_search' => 1,
'post.post_secret' => 0,
'post_tag.pta_tag' => $tag,
'post.post_del' => 0,
);
$this->db->where($where);
$this->db->order_by('post.post_num, post.post_reply');
if ($limit) {
$this->db->limit($limit, $offset);
}
$qry = $this->db->get();
$result['list'] = $qry->result_array();
$this->db->select('count(*) cnt');
$this->db->from('post');
$this->db->join('board', 'post.brd_id = board.brd_id', 'inner');
$this->db->join('post_tag', 'post.post_id = post_tag.post_id', 'inner');
$this->db->where($where);
$qry = $this->db->get();
$cnt = $qry->row_array();
$result['total_rows'] = element('cnt', $cnt);
return $result;
}
public function get_popular_tags($start_date = '', $limit = '')
{
$this->db->select('count(*) as cnt, pta_tag ', false);
$this->db->from('post_tag');
$this->db->join('post', 'post.post_id = post_tag.post_id', 'left');
$this->db->where('left(post_datetime, 10) >=', $start_date);
$this->db->where('post_del', 0);
$this->db->group_by('pta_tag');
$this->db->order_by('cnt', 'desc');
if ($limit) {
$this->db->limit($limit);
}
$qry = $this->db->get();
$result = $qry->result_array();
return $result;
}
}

View File

@@ -0,0 +1,40 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Scrap model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Scrap_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'scrap';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'scr_id'; // 사용되는 테이블의 프라이머리키
function __construct()
{
parent::__construct();
}
public function get_list($limit = '', $offset = '', $where = '', $like = '', $findex = '', $forder = '', $sfield = '', $skeyword = '', $sop = 'OR')
{
$select = 'scrap.*, post.mem_id as post_mem_id, post.post_userid, post.post_nickname, post.post_id, post.brd_id,
post.post_datetime, post.post_hit, post.post_secret, post.post_title, post.post_like, post.post_dislike, post.post_image';
$join[] = array('table' => 'post', 'on' => 'scrap.post_id = post.post_id', 'type' => 'inner');
$result = $this->_get_list_common($select, $join, $limit, $offset, $where, $like, $findex, $forder, $sfield, $skeyword, $sop);
return $result;
}
}

View File

@@ -0,0 +1,54 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Search Keyword model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Search_keyword_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'search_keyword';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'sek_id'; // 사용되는 테이블의 프라이머리키
function __construct()
{
parent::__construct();
}
public function get_admin_list($limit = '', $offset = '', $where = '', $like = '', $findex = '', $forder = '', $sfield = '', $skeyword = '', $sop = 'OR')
{
$select = 'search_keyword.*, member.mem_id, member.mem_userid, member.mem_nickname, member.mem_is_admin, member.mem_icon';
$join[] = array('table' => 'member', 'on' => 'search_keyword.mem_id = member.mem_id', 'type' => 'left');
$result = $this->_get_list_common($select, $join, $limit, $offset, $where, $like, $findex, $forder, $sfield, $skeyword, $sop);
return $result;
}
public function get_rank($start_date = '', $end_date = '')
{
if (empty($start_date) OR empty($end_date)) {
return false;
}
$this->db->where('left(sek_datetime, 10) >=', $start_date);
$this->db->where('left(sek_datetime, 10) <=', $end_date);
$this->db->select('sek_keyword');
$qry = $this->db->get($this->_table);
$result = $qry->result_array();
return $result;
}
}

View File

@@ -0,0 +1,212 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Social Meta model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Social_meta_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'social_meta';
/**
* 사용되는 테이블의 프라이머리키
*/
public $parent_key = 'mem_id';
public $meta_key = 'smt_key';
public $meta_value = 'smt_value';
public $cache_prefix= 'social_meta/social-meta-model-get-'; // 캐시 사용시 프리픽스
public $cache_time = 86400; // 캐시 저장시간
function __construct()
{
parent::__construct();
check_cache_dir('social_meta');
}
public function get_all_meta($mem_id = 0)
{
if (empty($mem_id)) {
return false;
}
$cachename = $this->cache_prefix . $mem_id;
$data = array();
if ( ! $data = $this->cache->get($cachename)) {
$result = array();
$res = $this->get($primary_value = '', $select = '', array($this->parent_key => $mem_id));
if ($res && is_array($res)) {
foreach ($res as $val) {
$result[$val[$this->meta_key]] = $val[$this->meta_value];
}
}
$data['result'] = $result;
$data['cached'] = '1';
$this->cache->save($cachename, $data, $this->cache_time);
}
return isset($data['result']) ? $data['result'] : false;
}
public function save($mem_id = 0, $savedata = '')
{
if (empty($mem_id)) {
return false;
}
if ($savedata && is_array($savedata)) {
foreach ($savedata as $column => $value) {
$this->meta_update($mem_id, $column, $value);
}
}
$this->cache->delete($this->cache_prefix . $mem_id);
}
public function deletemeta($mem_id = 0)
{
if (empty($mem_id)) {
return false;
}
$this->delete_where(array($this->parent_key => $mem_id));
$this->cache->delete($this->cache_prefix . $mem_id);
}
public function meta_update($mem_id = 0, $column = '', $value = false)
{
if (empty($mem_id)) {
return false;
}
$column = trim($column);
if (empty($column)) {
return false;
}
$old_value = $this->item($mem_id, $column);
if (empty($value)) {
$value = '';
}
if ($value === $old_value) {
return false;
}
if (false === $old_value) {
return $this->add_meta($mem_id, $column, $value);
}
return $this->update_meta($mem_id, $column, $value);
}
public function item($mem_id = 0, $column = '')
{
if (empty($mem_id)) {
return false;
}
if (empty($column)) {
return false;
}
$result = $this->get_all_meta($mem_id);
return isset($result[ $column ]) ? $result[ $column ] : false;
}
public function add_meta($mem_id = 0, $column = '', $value = '')
{
if (empty($mem_id)) {
return false;
}
$column = trim($column);
if (empty($column)) {
return false;
}
$updatedata = array(
'mem_id' => $mem_id,
'smt_key' => $column,
'smt_value' => $value,
);
$this->db->replace($this->_table, $updatedata);
return true;
}
public function update_meta($mem_id = 0, $column = '', $value = '')
{
if (empty($mem_id)) {
return false;
}
$column = trim($column);
if (empty($column)) {
return false;
}
$this->db->where($this->parent_key, $mem_id);
$this->db->where($this->meta_key, $column);
$data = array($this->meta_value => $value);
$this->db->update($this->_table, $data);
return true;
}
public function get_mem_id_by_social ($social_type = '', $social_id = '')
{
if (empty($social_type)) {
return false;
}
if (empty($social_id)) {
return false;
}
$key = $social_type . '_id';
$where = array(
'smt_key' => $key,
'smt_value' => $social_id
);
$info = $this->get_one('', '', $where);
return isset($info['mem_id']) ? $info['mem_id'] : false;
}
public function get_social_id_by_mem_id ($social_type = '', $mem_id = 0)
{
if (empty($social_type)) {
return false;
}
$mem_id = (int) $mem_id;
if (empty($mem_id) OR $mem_id < 1) {
return false;
}
$key = $social_type . '_id';
$where = array(
'smt_key' => $key,
'mem_id' => $mem_id
);
$info = $this->get_one('', '', $where);
return isset($info['smt_value']) ? $info['smt_value'] : false;
}
}

View File

@@ -0,0 +1,195 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Social model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Social_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'social';
/**
* 사용되는 테이블의 프라이머리키
*/
public $parent_key1 = 'soc_type';
public $parent_key2 = 'soc_account_id';
public $meta_key = 'soc_key';
public $meta_value = 'soc_value';
public $cache_prefix= 'social/social-model-get-'; // 캐시 사용시 프리픽스
public $cache_time = 86400; // 캐시 저장시간
function __construct()
{
parent::__construct();
check_cache_dir('social');
}
public function get_all_meta($soc_type = '', $soc_account_id = '')
{
if (empty($soc_type)) {
return false;
}
if (empty($soc_account_id)) {
return false;
}
$cachename = $this->cache_prefix . $soc_type . $soc_account_id;
$data = array();
if ( ! $data = $this->cache->get($cachename)) {
$result = array();
$res = $this->get('', $select = '', array('soc_type' => $soc_type, 'soc_account_id' => $soc_account_id));
if ($res && is_array($res)) {
foreach ($res as $val) {
$result[$val[$this->meta_key]] = $val[$this->meta_value];
}
}
$data['result'] = $result;
$data['cached'] = '1';
$this->cache->save($cachename, $data, $this->cache_time);
}
return isset($data['result']) ? $data['result'] : false;
}
public function save($soc_type = '', $soc_account_id = '', $savedata = '')
{
if (empty($soc_type)) {
return false;
}
if (empty($soc_account_id)) {
return false;
}
if ($savedata && is_array($savedata)) {
foreach ($savedata as $column => $value) {
$this->meta_update($soc_type, $soc_account_id, $column, $value);
}
}
$this->cache->delete($this->cache_prefix . $soc_type . $soc_account_id);
}
public function deletemeta($soc_type = '', $soc_account_id = '')
{
if (empty($soc_type)) {
return false;
}
if (empty($soc_account_id)) {
return false;
}
$this->delete_where(array('soc_type' => $soc_type, 'soc_account_id' => $soc_account_id));
$this->cache->delete($this->cache_prefix . $soc_type . $soc_account_id);
}
public function meta_update($soc_type = '', $soc_account_id = '', $column = '', $value = false)
{
if (empty($soc_type)) {
return false;
}
if (empty($soc_account_id)) {
return false;
}
$column = trim($column);
if (empty($column)) {
return false;
}
$old_value = $this->item($soc_type, $soc_account_id, $column);
if (empty($value)) {
$value = '';
}
if ($value === $old_value) {
return false;
}
if (false === $old_value) {
return $this->add_meta($soc_type, $soc_account_id, $column, $value);
}
return $this->update_meta($soc_type, $soc_account_id, $column, $value);
}
public function item($soc_type = '', $soc_account_id = '', $column = '')
{
if (empty($soc_type)) {
return false;
}
if (empty($soc_account_id)) {
return false;
}
if (empty($column)) {
return false;
}
$result = $this->get_all_meta($soc_type, $soc_account_id);
return isset($result[ $column ]) ? $result[ $column ] : false;
}
public function add_meta($soc_type = '', $soc_account_id = '', $column = '', $value = '')
{
if (empty($soc_type)) {
return false;
}
if (empty($soc_account_id)) {
return false;
}
$column = trim($column);
if (empty($column)) {
return false;
}
$updatedata = array(
'soc_type' => $soc_type,
'soc_account_id' => $soc_account_id,
'soc_key' => $column,
'soc_value' => $value,
);
$this->db->insert($this->_table, $updatedata);
return true;
}
public function update_meta($soc_type = '', $soc_account_id = '', $column = '', $value = '')
{
if (empty($soc_type)) {
return false;
}
if (empty($soc_account_id)) {
return false;
}
$column = trim($column);
if (empty($column)) {
return false;
}
$this->db->where('soc_type', $soc_type);
$this->db->where('soc_account_id', $soc_account_id);
$this->db->where($this->meta_key, $column);
$data = array($this->meta_value => $value);
$this->db->update($this->_table, $data);
return true;
}
}

View File

@@ -0,0 +1,77 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Stat Count Board model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Stat_count_board_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'stat_count_board';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'scb_id'; // 사용되는 테이블의 프라이머리키
function __construct()
{
parent::__construct();
}
public function get_board_count($type = 'd', $start_date = '', $end_date = '', $brd_id = 0, $orderby = 'asc')
{
if (empty($start_date) OR empty($end_date)) {
return false;
}
$left = ($type === 'y') ? 4 : ($type === 'm' ? 7 : 10);
if (strtolower($orderby) !== 'desc') $orderby = 'asc';
if ($type === 'y' OR $type === 'm') {
$this->db->select_sum('scb_count');
$this->db->select('left(scb_date, ' . $left . ') as day, brd_id ', false);
} else {
$this->db->select_sum('scb_count');
$this->db->select('scb_date as day, brd_id ', false);
}
$this->db->where('scb_date >=', $start_date);
$this->db->where('scb_date <=', $end_date);
$brd_id = (int) $brd_id;
if ($brd_id) {
$this->db->where('brd_id', $brd_id);
$this->db->group_by(array('day'));
} else {
$this->db->group_by(array('day', 'brd_id'));
}
$this->db->order_by('scb_id', $orderby);
$qry = $this->db->get($this->_table);
$result = $qry->result_array();
return $result;
}
public function add_visit_board($brd_id = 0)
{
$brd_id = (int) $brd_id;
if (empty($brd_id) OR $brd_id < 1) {
return false;
}
$sql = 'INSERT INTO ' . $this->db->dbprefix($this->_table);
$sql .= " (scb_date, brd_id, scb_count) VALUES ('" . cdate('Y-m-d') . "', '" . $brd_id . "', 1) ";
$sql .= " ON DUPLICATE KEY UPDATE scb_count= scb_count + 1 ";
return $this->db->query($sql);
}
}

View File

@@ -0,0 +1,116 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Stat Count Date model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Stat_count_date_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'stat_count_date';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'scd_date'; // 사용되는 테이블의 프라이머리키
function __construct()
{
parent::__construct();
}
public function add_visit_date()
{
$sql = 'INSERT INTO ' . $this->db->dbprefix($this->_table);
$sql .= " (scd_date, scd_count) VALUES ('" . cdate('Y-m-d') . "', 1) ";
$sql .= " ON DUPLICATE KEY UPDATE scd_count= scd_count + 1 ";
return $this->db->query($sql);
}
public function get_by_time_day($start_date = '', $end_date = '', $orderby = 'asc')
{
if (empty($start_date) OR empty($end_date)) {
return false;
}
if (strtolower($orderby) !== 'desc') $orderby = 'asc';
$this->db->where('scd_date >=', $start_date);
$this->db->where('scd_date <=', $end_date);
$this->db->order_by('scd_date', $orderby);
$qry = $this->db->get($this->_table);
$result = $qry->result_array();
return $result;
}
public function get_by_time_month($start_date = '', $end_date = '', $orderby = 'asc')
{
if (empty($start_date) OR empty($end_date)) {
return false;
}
if (strtolower($orderby) !== 'desc') $orderby = 'asc';
$this->db->select_sum('scd_count');
$this->db->select('SUBSTRING(scd_date,1,7) as date', false);
$this->db->where('scd_date >=', $start_date);
$this->db->where('scd_date <=', $end_date);
$this->db->group_by('date');
$this->db->order_by('scd_date', $orderby);
$qry = $this->db->get($this->_table);
$result = $qry->result_array();
return $result;
}
public function get_by_time_year($start_date = '', $end_date = '', $orderby = 'asc')
{
if (empty($start_date) OR empty($end_date)) {
return false;
}
if (strtolower($orderby) !== 'desc') $orderby = 'asc';
$this->db->select_sum('scd_count');
$this->db->select('SUBSTRING(scd_date,1,4) as date', false);
$this->db->where('scd_date >=', $start_date);
$this->db->where('scd_date <=', $end_date);
$this->db->group_by('date');
$this->db->order_by('scd_date', $orderby);
$qry = $this->db->get($this->_table);
$result = $qry->result_array();
return $result;
}
public function get_by_time_week($start_date = '', $end_date = '', $orderby = 'asc')
{
if (empty($start_date) OR empty($end_date)) {
return false;
}
if (strtolower($orderby) !== 'desc') $orderby = 'asc';
$this->db->select_sum('scd_count');
$this->db->select('WEEKDAY(scd_date) as date', false);
$this->db->where('scd_date >=', $start_date);
$this->db->where('scd_date <=', $end_date);
$this->db->group_by('date');
$this->db->order_by('date', $orderby);
$qry = $this->db->get($this->_table);
$result = $qry->result_array();
return $result;
}
}

View File

@@ -0,0 +1,63 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Stat Count model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Stat_count_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'stat_count';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'sco_id'; // 사용되는 테이블의 프라이머리키
function __construct()
{
parent::__construct();
}
public function get_by_date($start_date = '', $end_date = '')
{
if (empty($start_date) OR empty($end_date)) {
return false;
}
$this->db->where('sco_date >=', $start_date);
$this->db->where('sco_date <=', $end_date);
$qry = $this->db->get($this->_table);
$result = $qry->result_array();
return $result;
}
public function get_by_time_hour($start_date = '', $end_date = '', $orderby = 'asc')
{
if (empty($start_date) OR empty($end_date)) {
return false;
}
if (strtolower($orderby) !== 'desc') $orderby = 'asc';
$this->db->select('SUBSTRING(sco_time,1,2) as time, count(sco_id) as cnt ', false);
$this->db->where('sco_date >=', $start_date);
$this->db->where('sco_date <=', $end_date);
$this->db->group_by('time');
$this->db->order_by('time', $orderby);
$qry = $this->db->get($this->_table);
$result = $qry->result_array();
return $result;
}
}

View File

@@ -0,0 +1,29 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Tempsave model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Tempsave_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'tempsave';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'tmp_id'; // 사용되는 테이블의 프라이머리키
function __construct()
{
parent::__construct();
}
}

View File

@@ -0,0 +1,53 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Unique id model class
*
* Copyright (c) CIBoard <www.ciboard.co.kr>
*
* @author CIBoard (develop@ciboard.co.kr)
*/
class Unique_id_model extends CB_Model
{
/**
* 테이블명
*/
public $_table = 'unique_id';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'unq_id'; // 사용되는 테이블의 프라이머리키
function __construct()
{
parent::__construct();
}
public function get_id($ip)
{
$this->db->query('LOCK TABLE ' . $this->db->dbprefix . $this->_table . ' WRITE');
while (true) {
$mt_arr = explode(' ', microtime());
$key = cdate('YmdHis') . str_pad((int)($mt_arr[0]*10000), 4, "0", STR_PAD_LEFT);
$insertdata = array(
'unq_id' => $key,
'unq_ip' => $ip,
);
$result = $this->db->insert($this->_table, $insertdata);
if ($result) {
break; // 쿼리가 정상이면 빠진다.
}
usleep(100); // 10000분의 1초를 쉰다
}
$this->db->query('UNLOCK TABLES');
return $key;
}
}

View File

@@ -0,0 +1,10 @@
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html>