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

This commit is contained in:
jeonghwa
2026-07-03 05:27:47 +09:00
commit d8dab43237
1460 changed files with 134466 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Api_error_log model class
*/
class Api_error_log_model extends MY_Model
{
/**
* 테이블명
*/
public $_table = 'api_error_log';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'el_idx'; // 사용되는 테이블의 프라이머리키
function __construct()
{
parent::__construct();
}
}

View File

@@ -0,0 +1,49 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Api_input model class
*/
class Api_input_model extends MY_Model
{
/**
* 테이블명
*/
public $_table = 'api_input';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'ai_idx'; // 사용되는 테이블의 프라이머리키
function __construct()
{
parent::__construct();
}
public function get_admin_list($limit = '', $offset = '', $where = '', $like = '', $findex = '', $forder = '', $sfield = '', $skeyword = '', $sop = 'OR')
{
$result = $this->_get_list_common($select = '', $join = '', $limit, $offset, $where, $like, $findex, $forder, $sfield, $skeyword, $sop);
return $result;
}
public function select_max_sort($api_idx)
{
$this->db->select_max('ai_sort');
$this->db->where('api_idx', $api_idx);
$qry = $this->db->get($this->_table);
$result = $qry->row_array();
return $result['ai_sort'];
}
public function update_sort($api_idx, $ai_sort)
{
$this->db->where('api_idx', $api_idx);
$this->db->where('ai_sort >=', $ai_sort);
$this->db->set('ai_sort', 'ai_sort+1', false);
$result = $this->db->update($this->_table);
return $result;
}
}

View File

@@ -0,0 +1,32 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Api_list model class
*/
class Api_list_model extends MY_Model
{
/**
* 테이블명
*/
public $_table = 'api_list';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'api_idx'; // 사용되는 테이블의 프라이머리키
function __construct()
{
parent::__construct();
}
public function get_admin_list($limit = '', $offset = '', $where = '', $like = '', $findex = '', $forder = '', $sfield = '', $skeyword = '', $sop = 'OR')
{
$result = $this->_get_list_common($select = '', $join = '', $limit, $offset, $where, $like, $findex, $forder, $sfield, $skeyword, $sop);
return $result;
}
}

View File

@@ -0,0 +1,49 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Api_output model class
*/
class Api_output_model extends MY_Model
{
/**
* 테이블명
*/
public $_table = 'api_output';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'ai_idx'; // 사용되는 테이블의 프라이머리키
function __construct()
{
parent::__construct();
}
public function get_admin_list($limit = '', $offset = '', $where = '', $like = '', $findex = '', $forder = '', $sfield = '', $skeyword = '', $sop = 'OR')
{
$result = $this->_get_list_common($select = '', $join = '', $limit, $offset, $where, $like, $findex, $forder, $sfield, $skeyword, $sop);
return $result;
}
public function select_max_sort($api_idx)
{
$this->db->select_max('ai_sort');
$this->db->where('api_idx', $api_idx);
$qry = $this->db->get($this->_table);
$result = $qry->row_array();
return $result['ai_sort'];
}
public function update_sort($api_idx, $ai_sort)
{
$this->db->where('api_idx', $api_idx);
$this->db->where('ai_sort >=', $ai_sort);
$this->db->set('ai_sort', 'ai_sort+1', false);
$result = $this->db->update($this->_table);
return $result;
}
}

View File

@@ -0,0 +1,56 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Apps model class
*/
class Apps_model extends MY_Model
{
/**
* 테이블명
*/
public $_table = 'apps';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'app_id'; // 사용되는 테이블의 프라이머리키
function __construct()
{
parent::__construct();
}
public function get_admin_list($limit = '', $offset = '', $where = '', $like = '', $findex = '', $forder = '', $sfield = '', $skeyword = '', $sop = 'OR')
{
$result = $this->_get_list_common('', '', $limit, $offset, $where, $like, $findex, $forder, $sfield, $skeyword, $sop);
return $result;
}
public function select_max_sort()
{
$this->db->select_max('app_sort');
$qry = $this->db->get($this->_table);
$result = $qry->row_array();
return $result['app_sort'];
}
public function app_list()
{
$this->db->order_by('app_sort', 'desc');
$qry = $this->db->get($this->_table);
$result = $qry->result_array();
$data = array();
if ($result) {
foreach ($result as $value) {
$data[element('app_id', $value)] = $value;
}
}
return $data;
}
}

View File

@@ -0,0 +1,125 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Config model class
*/
class Config_model extends MY_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 (empty($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,34 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Contents_bookmark model class
*/
class Contents_bookmark_model extends MY_Model
{
/**
* 테이블명
*/
public $_table = 'contents_bookmark';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'bookmark_id'; // 사용되는 테이블의 프라이머리키
function __construct()
{
parent::__construct();
}
public function get_admin_list($limit = '', $offset = '', $where = '', $like = '', $findex = '', $forder = '', $sfield = '', $skeyword = '', $sop = 'OR')
{
$select = 'contents_bookmark.*, contents.con_title, contents.cat1_id, contents.cat2_id, contents.con_created_at, user.user_id, user.user_username';
$join[] = array('table' => 'user', 'on' => 'contents_bookmark.user_id = user.user_id', 'type' => 'inner');
$join[] = array('table' => 'contents', 'on' => 'contents_bookmark.con_id = contents.con_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,120 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Contents_category model class
*/
class Contents_category_model extends MY_Model
{
/**
* 테이블명
*/
public $_table = 'contents_category';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'cat_id'; // 사용되는 테이블의 프라이머리키
function __construct()
{
parent::__construct();
}
public function get_admin_list($limit = '', $offset = '', $where = '', $like = '', $findex = '', $forder = '', $sfield = '', $skeyword = '', $sop = 'OR')
{
$result = $this->_get_list_common('', '', $limit, $offset, $where, $like, $findex, $forder, $sfield, $skeyword, $sop);
return $result;
}
public function select_max_sort($app_id = '')
{
$this->db->where('app_id', $app_id);
$this->db->select_max('cat_sort');
$qry = $this->db->get($this->_table);
$result = $qry->row_array();
return $result['cat_sort'];
}
public function cat_list($app_id = '')
{
$this->db->where('app_id', $app_id);
$this->db->where('cat_parent', '0');
$this->db->order_by('cat_sort', 'desc');
$qry = $this->db->get($this->_table);
$result = $qry->result_array();
$data = array();
if ($result) {
foreach ($result as $value) {
$data[element('cat_id', $value)] = $value;
}
}
return $data;
}
public function get_hierarchical_name($app_id, $category_id) {
$this->db->where('app_id', $app_id);
$this->db->where('cat_id', $category_id);
$this->db->from('contents_category');
$qry = $this->db->get();
$result = $qry->row_array();
$depth = element('cat_depth', $result);
if ($depth == '4') {
$this->db->select('t1.cat_id AS lev1_id, t1.cat_name AS lev1_name, t1.cat_code AS lev1_code, t2.cat_id AS lev2_id, t2.cat_name as lev2_name, t2.cat_code as lev2_code, t3.cat_id AS lev3_id, t3.cat_name as lev3_name, t3.cat_code as lev3_code, t4.cat_id AS lev4_id, t4.cat_name as lev4_name, t4.cat_code as lev4_code');
$this->db->from('contents_category as t1');
$this->db->join('contents_category as t2', 't2.cat_parent = t1.cat_id AND t2.app_id = t1.app_id', 'left');
$this->db->join('contents_category as t3', 't3.cat_parent = t2.cat_id AND t3.app_id = t2.app_id', 'left');
$this->db->join('contents_category as t4', 't4.cat_parent = t3.cat_id AND t4.app_id = t3.app_id', 'left');
$this->db->where('t4.cat_id', $category_id);
}
else if ($depth == '3') {
$this->db->select('t1.cat_id AS lev1_id, t1.cat_name AS lev1_name, t1.cat_code AS lev1_code, t2.cat_id AS lev2_id, t2.cat_name as lev2_name, t2.cat_code as lev2_code, t3.cat_id AS lev3_id, t3.cat_name as lev3_name, t3.cat_code as lev3_code');
$this->db->from('contents_category as t1');
$this->db->join('contents_category as t2', 't2.cat_parent = t1.cat_id AND t2.app_id = t1.app_id', 'left');
$this->db->join('contents_category as t3', 't3.cat_parent = t2.cat_id AND t3.app_id = t2.app_id', 'left');
$this->db->where('t3.cat_id', $category_id);
}
else if ($depth == '2') {
$this->db->select('t1.cat_id AS lev1_id, t1.cat_name AS lev1_name, t1.cat_code AS lev1_code, t2.cat_id AS lev2_id, t2.cat_name as lev2_name, t2.cat_code as lev2_code');
$this->db->from('contents_category as t1');
$this->db->join('contents_category as t2', 't2.cat_parent = t1.cat_id AND t2.app_id = t1.app_id', 'left');
$this->db->where('t2.cat_id', $category_id);
}
else if ($depth == '1') {
$this->db->select('t1.cat_id AS lev1_id, t1.cat_name AS lev1_name, t1.cat_code AS lev1_code');
$this->db->from('contents_category as t1');
$this->db->where('t1.cat_id', $category_id);
}
$qry = $this->db->get();
$result = $qry->row_array();
$id = array();
if (element('lev1_id', $result)) $id['1'] = element('lev1_id', $result);
if (element('lev2_id', $result)) $id['2'] = element('lev2_id', $result);
if (element('lev3_id', $result)) $id['3'] = element('lev3_id', $result);
if (element('lev4_id', $result)) $id['4'] = element('lev4_id', $result);
$name = array();
if (element('lev1_name', $result)) $name['1'] = element('lev1_name', $result);
if (element('lev2_name', $result)) $name['2'] = element('lev2_name', $result);
if (element('lev3_name', $result)) $name['3'] = element('lev3_name', $result);
if (element('lev4_name', $result)) $name['4'] = element('lev4_name', $result);
$code = array();
if (element('lev1_code', $result)) $code['1'] = element('lev1_code', $result);
if (element('lev2_code', $result)) $code['2'] = element('lev2_code', $result);
if (element('lev3_code', $result)) $code['3'] = element('lev3_code', $result);
if (element('lev4_code', $result)) $code['4'] = element('lev4_code', $result);
$return = array('id' => $id, 'name' => $name, 'code' => $code);
return $return;
}
}

View File

@@ -0,0 +1,68 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Contents_comment class
*/
class Contents_comment_model extends MY_Model
{
/**
* 테이블명
*/
public $_table = 'contents_comment';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'com_id'; // 사용되는 테이블의 프라이머리키
function __construct()
{
parent::__construct();
}
public function get_admin_list($limit = '', $offset = '', $where = '', $like = '', $findex = '', $forder = '', $sfield = '', $skeyword = '', $sop = 'OR')
{
$select = 'contents_comment.*, contents.con_title, contents.cat1_id, contents.cat2_id, contents.con_created_at, user.user_id, user.user_username';
$join[] = array('table' => 'user', 'on' => 'contents_comment.con_user_id = user.user_id', 'type' => 'inner');
$join[] = array('table' => 'contents', 'on' => 'contents_comment.con_id = contents.con_id', 'type' => 'inner');
$result = $this->_get_list_common($select, $join, $limit, $offset, $where, $like, $findex, $forder, $sfield, $skeyword, $sop);
return $result;
}
public function get_api_list($app_id= '', $con_id = '')
{
$select = 'contents_comment.com_id, contents_comment.con_id, com_content, contents_comment.user_id, com_created_at, com_updated_at, user.user_username, user.user_photo';
$this->db->select($select);
$this->db->join('user', 'contents_comment.user_id = user.user_id', 'left');
$this->db->where('contents_comment.con_id', $con_id);
$this->db->where('contents_comment.app_id', $app_id);
$this->db->order_by('com_num', 'asc');
$this->db->order_by('com_reply', 'asc');
$qry = $this->db->get($this->_table);
$result = $qry->result_array();
return $result;
}
public function get_count($con_id)
{
$this->db->where(array('con_id' => $con_id));
$this->db->join('user', 'contents_comment.user_id = user.user_id', 'inner');
$result = $this->db->count_all_results($this->_table);
return $result;
}
public function next_comment_num()
{
$this->db->select_min('com_num');
$result = $this->db->get($this->_table);
$row = $result->row_array();
$row['com_num'] = (isset($row['com_num']) && is_numeric($row['com_num'])) ? $row['com_num'] : 0;
$com_num = $row['com_num'] - 1;
return $com_num;
}
}

View File

@@ -0,0 +1,34 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Contents_like model class
*/
class Contents_like_model extends MY_Model
{
/**
* 테이블명
*/
public $_table = 'contents_like';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'like_id'; // 사용되는 테이블의 프라이머리키
function __construct()
{
parent::__construct();
}
public function get_admin_list($limit = '', $offset = '', $where = '', $like = '', $findex = '', $forder = '', $sfield = '', $skeyword = '', $sop = 'OR')
{
$select = 'contents_like.*, contents.con_title, contents.cat1_id, contents.cat2_id, contents.con_created_at, user.user_id, user.user_username';
$join[] = array('table' => 'contents', 'on' => 'contents_like.con_id = contents.con_id', 'type' => 'inner');
$join[] = array('table' => 'user', 'on' => 'contents_like.user_id = user.user_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,134 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Contents model class
*/
class Contents_model extends MY_Model
{
/**
* 테이블명
*/
public $_table = 'contents';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'con_id'; // 사용되는 테이블의 프라이머리키
function __construct()
{
parent::__construct();
}
public function get_admin_list($limit = '', $offset = '', $where = '', $like = '', $findex = '', $forder = '', $sfield = '', $skeyword = '', $sop = 'OR')
{
$select = 'contents.*, user.user_id, user.user_username, user.user_is_admin, user.user_icon, crawl_list.crawl_title, crawl_list.site_type, crawl_list.site_key';
$join[] = array('table' => 'user', 'on' => 'contents.user_id = user.user_id', 'type' => 'inner');
$join[] = array('table' => 'crawl_list', 'on' => 'contents.crawl_id = crawl_list.crawl_id', 'type' => 'left');
if (isset($where['contents_tag.tag_name']) && $where['contents_tag.tag_name']) {
$join[] = array('table' => 'contents_tag', 'on' => 'contents.con_id = contents_tag.con_id', 'type' => 'inner');
}
$result = $this->_get_list_common($select, $join, $limit, $offset, $where, $like, $findex, $forder, $sfield, $skeyword, $sop);
return $result;
}
public function get_api_list($app_id = '', $is_bookmark = '', $user_id = '', $tag = '', $cat1_id = '', $cat2_id = '', $for_push = '')
{
$this->db->where('contents.app_id', $app_id);
$this->db->where('contents.is_open', '1');
$this->db->where('contents.is_del', '0');
$this->db->where('con_published_at <=', cdate('Y-m-d H:i:s'));
$this->db->where('con_published_at is not null');
if ($for_push) {
$this->db->where('contents.is_push', '1');
$this->db->where('con_published_at >=', cdate('Y-m-d H:i:s', time()-86400));
}
if ($cat1_id) {
$this->db->where('cat1_id', $cat1_id);
}
if ($cat2_id) {
$this->db->where('cat2_id', $cat2_id);
}
//$this->db->order_by('con_sort', 'desc');
$this->db->order_by('con_published_at', 'desc');
if ($is_bookmark && $user_id) {
$this->db->join('contents_bookmark', 'contents.con_id = contents_bookmark.con_id', 'inner');
$this->db->where('contents_bookmark.user_id', $user_id);
}
if ($tag) {
$this->db->join('contents_tag', 'contents.con_id = contents_tag.con_id', 'inner');
$this->db->where('contents_tag.tag_name', $tag);
}
$qry = $this->db->get($this->_table);
$result = $qry->result_array();
return $result;
}
public function get_api_popular_list($app_id = '', $is_bookmark = '', $user_id = '', $tag = '', $cat1_id = '', $cat2_id = '')
{
//$this->db->select('contents.*, count(like_id) cnt');
$this->db->where('contents.app_id', $app_id);
$this->db->where('contents.is_open', '1');
$this->db->where('contents.is_del', '0');
$this->db->where('contents.con_like >', '0');
$this->db->where('con_published_at <=', cdate('Y-m-d H:i:s'));
$this->db->where('con_published_at is not null');
if ($cat1_id) {
$this->db->where('cat1_id', $cat1_id);
}
if ($cat2_id) {
$this->db->where('cat2_id', $cat2_id);
}
if ($is_bookmark && $user_id) {
$this->db->join('contents_bookmark', 'contents.con_id = contents_bookmark.con_id', 'inner');
$this->db->where('contents_bookmark.user_id', $user_id);
}
if ($tag) {
$this->db->join('contents_tag', 'contents.con_id = contents_tag.con_id', 'inner');
$this->db->where('contents_tag.tag_name', $tag);
}
// $this->db->join('contents_like', 'contents.con_id = contents_like.con_id', 'left');
// $this->db->where('contents.con_like >', '0');
// $this->db->where('contents_like.like_at >', cdate('Y-m-d H:i:s', time()-7*86400));
$this->db->group_by('con_id');
//$this->db->order_by('cnt', 'desc');
$this->db->order_by('con_like', 'desc');
$qry = $this->db->get($this->_table);
$result = $qry->result_array();
return $result;
}
public function select_max_sort($app_id = '')
{
$this->db->where('app_id', $app_id);
$this->db->select_max('con_sort');
$qry = $this->db->get($this->_table);
$result = $qry->row_array();
return $result['con_sort'];
}
public function update_share_count($con_id = '')
{
$this->db->query("UPDATE ci_contents SET con_share_count = con_share_count + 1 WHERE con_id='".$con_id."'");
return true;
}
public function plus_like_count($con_id = '')
{
$this->db->query("UPDATE ci_contents SET con_like = con_like + 1 WHERE con_id='".$con_id."'");
return true;
}
public function minus_like_count($con_id = '')
{
$this->db->query("UPDATE ci_contents SET con_like = con_like - 1 WHERE con_id='".$con_id."'");
return true;
}
}

View File

@@ -0,0 +1,171 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Contents_tag model class
*/
class Contents_tag_model extends MY_Model
{
/**
* 테이블명
*/
public $_table = 'contents_tag';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'tag_id'; // 사용되는 테이블의 프라이머리키
function __construct()
{
parent::__construct();
}
public function get_admin_list($limit = '', $offset = '', $where = '', $like = '', $findex = '', $forder = '', $sfield = '', $skeyword = '', $sop = 'OR')
{
if (empty($findex) OR ! in_array($findex, $this->allow_order_field)) {
$findex = $this->primary_key;
}
$this->db->select('app_id, tag_name, count(*) cnt', false);
$forder = (strtoupper($forder) === 'ASC') ? 'ASC' : 'DESC';
$sop = (strtoupper($sop) === 'AND') ? 'AND' : 'OR';
$count_by_where = array();
$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->from($this->_table);
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();
}
if ($count_by_where) {
$this->db->where($count_by_where);
}
$this->db->group_by('tag_name');
$this->db->order_by($findex, $forder);
if ($limit) {
$this->db->limit($limit, $offset);
}
$qry = $this->db->get();
$result['list'] = $qry->result_array();
$this->db->select('app_id, count(tag_name) as cnt', false);
$this->db->from('( select tag_name, count(tag_name), app_id from ci_contents_tag group by tag_name) as c', false);
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();
}
if ($count_by_where) {
$this->db->where($count_by_where);
}
$sql = $this->db->get();
//$sql = $this->db->query('select count(tag_name) as cnt from ( select tag_name,count(tag_name) from ci_contents_tag group by tag_name) as c');
$rows = $sql->row_array();
$result['total_rows'] = $rows['cnt'];
return $result;
}
public function get_contents_tags($app_id, $con_id)
{
$this->db->select('tag_name');
$this->db->where('app_id', $app_id);
$this->db->where('con_id', $con_id);
$this->db->order_by('tag_id', 'asc');
$qry = $this->db->get($this->_table);
$result = $qry->result_array();
return $result;
}
}

View File

@@ -0,0 +1,33 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Crawl_history model class
*/
class Crawl_history_model extends MY_Model
{
/**
* 테이블명
*/
public $_table = 'crawl_history';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'history_id'; // 사용되는 테이블의 프라이머리키
function __construct()
{
parent::__construct();
}
public function get_admin_list($limit = '', $offset = '', $where = '', $like = '', $findex = '', $forder = '', $sfield = '', $skeyword = '', $sop = 'OR')
{
$join[] = array('table' => 'crawl_list', 'on' => 'crawl_history.crawl_id = crawl_list.crawl_id', 'type' => 'inner');
$result = $this->_get_list_common('', $join, $limit, $offset, $where, $like, $findex, $forder, $sfield, $skeyword, $sop);
return $result;
}
}

View File

@@ -0,0 +1,52 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Crawl_list model class
*/
class Crawl_list_model extends MY_Model
{
/**
* 테이블명
*/
public $_table = 'crawl_list';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'crawl_id'; // 사용되는 테이블의 프라이머리키
function __construct()
{
parent::__construct();
}
public function get_admin_list($limit = '', $offset = '', $where = '', $like = '', $findex = '', $forder = '', $sfield = '', $skeyword = '', $sop = 'OR')
{
$result = $this->_get_list_common('', '', $limit, $offset, $where, $like, $findex, $forder, $sfield, $skeyword, $sop);
return $result;
}
public function get_by_site()
{
$this->db->select('crawl_title,site_key,site_type');
$this->db->group_by('site_type');
$this->db->group_by('site_key');
$this->db->order_by('crawl_title');
$qry = $this->db->get($this->_table);
return $qry->result_array();
}
public function get_by_category()
{
$this->db->select('crawl_category_name');
$this->db->where("crawl_category_name is not null AND crawl_category_name <> ''");
$this->db->group_by('crawl_category_name');
$this->db->order_by('crawl_category_name');
$qry = $this->db->get($this->_table);
return $qry->result_array();
}
}

View File

@@ -0,0 +1,54 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Editor image model class
*/
class Editor_image_model extends MY_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.*, user.user_id, user.user_username, user.user_is_admin, user.user_icon';
$join[] = array('table' => 'user', 'on' => 'editor_image.user_id = user.user_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,41 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Fcm_result model class
*/
class Fcm_result_model extends MY_Model
{
/**
* 테이블명
*/
public $_table = 'fcm_result';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'id'; // 사용되는 테이블의 프라이머리키
function __construct()
{
parent::__construct();
}
public function get_admin_list($limit = '', $offset = '', $where = '', $like = '', $findex = '', $forder = '', $sfield = '', $skeyword = '', $sop = 'OR')
{
$result = $this->_get_list_common('', '', $limit, $offset, $where, $like, $findex, $forder, $sfield, $skeyword, $sop);
return $result;
}
public function get_pushsend($company_id)
{
$this->db->where('company_id', $company_id);
$this->db->order_by('as_name', 'asc');
$qry = $this->db->get($this->_table);
$result = $qry->result_array();
return $result;
}
}

View File

@@ -0,0 +1,34 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Notice model class
*/
class Notice_model extends MY_Model
{
/**
* 테이블명
*/
public $_table = 'notice';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'notice_id'; // 사용되는 테이블의 프라이머리키
function __construct()
{
parent::__construct();
}
public function get_admin_list($limit = '', $offset = '', $where = '', $like = '', $findex = '', $forder = '', $sfield = '', $skeyword = '', $sop = 'OR')
{
$select = 'notice.*, user.user_id, user.user_username, user.user_is_admin, user.user_icon';
$join[] = array('table' => 'user', 'on' => 'notice.user_id = user.user_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,34 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Qna model class
*/
class Qna_model extends MY_Model
{
/**
* 테이블명
*/
public $_table = 'qna';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'qna_id'; // 사용되는 테이블의 프라이머리키
function __construct()
{
parent::__construct();
}
public function get_admin_list($limit = '', $offset = '', $where = '', $like = '', $findex = '', $forder = '', $sfield = '', $skeyword = '', $sop = 'OR')
{
$select = 'qna.*, user.user_id, user.user_username, user.user_is_admin, user.user_icon';
$join[] = array('table' => 'user', 'on' => 'qna.user_id = user.user_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,208 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Social Meta model class
*/
class Social_meta_model extends MY_Model
{
/**
* 테이블명
*/
public $_table = 'social_meta';
/**
* 사용되는 테이블의 프라이머리키
*/
public $parent_key = 'user_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($user_id = 0)
{
if (empty($user_id)) {
return false;
}
$cachename = $this->cache_prefix . $user_id;
$data = array();
if ( ! $data = $this->cache->get($cachename)) {
$result = array();
$res = $this->get($primary_value = '', $select = '', array($this->parent_key => $user_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($user_id = 0, $savedata = '')
{
if (empty($user_id)) {
return false;
}
if ($savedata && is_array($savedata)) {
foreach ($savedata as $column => $value) {
$this->meta_update($user_id, $column, $value);
}
}
$this->cache->delete($this->cache_prefix . $user_id);
}
public function deletemeta($user_id = 0)
{
if (empty($user_id)) {
return false;
}
$this->delete_where(array($this->parent_key => $user_id));
$this->cache->delete($this->cache_prefix . $user_id);
}
public function meta_update($user_id = 0, $column = '', $value = false)
{
if (empty($user_id)) {
return false;
}
$column = trim($column);
if (empty($column)) {
return false;
}
$old_value = $this->item($user_id, $column);
if (empty($value)) {
$value = '';
}
if ($value === $old_value) {
return false;
}
if (false === $old_value) {
return $this->add_meta($user_id, $column, $value);
}
return $this->update_meta($user_id, $column, $value);
}
public function item($user_id = 0, $column = '')
{
if (empty($user_id)) {
return false;
}
if (empty($column)) {
return false;
}
$result = $this->get_all_meta($user_id);
return isset($result[ $column ]) ? $result[ $column ] : false;
}
public function add_meta($user_id = 0, $column = '', $value = '')
{
if (empty($user_id)) {
return false;
}
$column = trim($column);
if (empty($column)) {
return false;
}
$updatedata = array(
'user_id' => $user_id,
'smt_key' => $column,
'smt_value' => $value,
);
$this->db->replace($this->_table, $updatedata);
return true;
}
public function update_meta($user_id = 0, $column = '', $value = '')
{
if (empty($user_id)) {
return false;
}
$column = trim($column);
if (empty($column)) {
return false;
}
$this->db->where($this->parent_key, $user_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_user_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['user_id']) ? $info['user_id'] : false;
}
public function get_social_id_by_user_id ($social_type = '', $user_id = 0)
{
if (empty($social_type)) {
return false;
}
$user_id = (int) $user_id;
if (empty($user_id) OR $user_id < 1) {
return false;
}
$key = $social_type . '_id';
$where = array(
'smt_key' => $key,
'user_id' => $user_id
);
$info = $this->get_one('', '', $where);
return isset($info['smt_value']) ? $info['smt_value'] : false;
}
}

View File

@@ -0,0 +1,191 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Social model class
*/
class Social_model extends MY_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,36 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Upload File model class
*/
class Upload_file_model extends MY_Model
{
/**
* 테이블명
*/
public $_table = 'upload_file';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'ufi_id'; // 사용되는 테이블의 프라이머리키
function __construct()
{
parent::__construct();
}
public function get_files($origin_table = '', $origin_id = '')
{
$this->db->where('origin_table', $origin_table);
$this->db->where('origin_id', $origin_id);
$this->db->order_by('ufi_id');
$qry = $this->db->get($this->_table);
$result = $qry->result_array();
return $result;
}
}

View File

@@ -0,0 +1,25 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* User Auth Email model class
*/
class User_auth_email_model extends MY_Model
{
/**
* 테이블명
*/
public $_table = 'user_auth_email';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'uae_id'; // 사용되는 테이블의 프라이머리키
function __construct()
{
parent::__construct();
}
}

View File

@@ -0,0 +1,165 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* User Meta model class
*/
class User_meta_model extends MY_Model
{
/**
* 테이블명
*/
public $_table = 'user_meta';
/**
* 사용되는 테이블의 프라이머리키
*/
public $parent_key = 'user_id';
public $meta_key = 'umt_key';
public $meta_value = 'umt_value';
public $cache_prefix= 'user_meta/user-meta-model-get-'; // 캐시 사용시 프리픽스
public $cache_time = 86400; // 캐시 저장시간
function __construct()
{
parent::__construct();
check_cache_dir('user_meta');
}
public function get_all_meta($user_id = 0)
{
if (empty($user_id)) {
return false;
}
$cachename = $this->cache_prefix . $user_id;
$data = array();
if ( ! $data = $this->cache->get($cachename)) {
$result = array();
$res = $this->get($primary_value = '', $select = '', array($this->parent_key => $user_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($user_id = 0, $savedata = '')
{
if (empty($user_id)) {
return false;
}
if ($savedata && is_array($savedata)) {
foreach ($savedata as $column => $value) {
$this->meta_update($user_id, $column, $value);
}
}
$this->cache->delete($this->cache_prefix . $user_id);
}
public function deletemeta($user_id = 0)
{
if (empty($user_id)) {
return false;
}
$this->delete_where(array($this->parent_key => $user_id));
$this->cache->delete($this->cache_prefix . $user_id);
}
public function meta_update($user_id = 0, $column = '', $value = false)
{
if (empty($user_id)) {
return false;
}
$column = trim($column);
if (empty($column)) {
return false;
}
$old_value = $this->item($user_id, $column);
if (empty($value)) {
$value = '';
}
if ($value === $old_value) {
return false;
}
if (false === $old_value) {
return $this->add_meta($user_id, $column, $value);
}
return $this->update_meta($user_id, $column, $value);
}
public function item($user_id = 0, $column = '')
{
if (empty($user_id)) {
return false;
}
if (empty($column)) {
return false;
}
$result = $this->get_all_meta($user_id);
return isset($result[ $column ]) ? $result[ $column ] : false;
}
public function add_meta($user_id = 0, $column = '', $value = '')
{
if (empty($user_id)) {
return false;
}
$column = trim($column);
if (empty($column)) {
return false;
}
$updatedata = array(
'user_id' => $user_id,
'umt_key' => $column,
'umt_value' => $value,
);
$this->db->replace($this->_table, $updatedata);
return true;
}
public function update_meta($user_id = 0, $column = '', $value = '')
{
if (empty($user_id)) {
return false;
}
$column = trim($column);
if (empty($column)) {
return false;
}
$this->db->where($this->parent_key, $user_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,111 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* User model class
*/
class User_model extends MY_Model
{
/**
* 테이블명
*/
public $_table = 'user';
/**
* 사용되는 테이블의 프라이머리키
*/
public $primary_key = 'user_id'; // 사용되는 테이블의 프라이머리키
public $search_sfield = '';
function __construct()
{
parent::__construct();
}
public function get_by_id($id = 0, $select = '')
{
$id = (int) $id;
if (empty($id) OR $id < 1) {
return false;
}
$where = array('user_id' => $id);
return $this->get_one('', $select, $where);
}
public function get_by_email($email = '', $select = '')
{
if (empty($email)) {
return false;
}
$where = array('user_email' => $email);
return $this->get_one('', $select, $where);
}
public function get_by_api_email($app_id = '', $email = '', $select = '')
{
if (empty($app_id)) {
return false;
}
if (empty($email)) {
return false;
}
$where = array('app_id' => $app_id, 'user_email' => $email);
return $this->get_one('', $select, $where);
}
public function get_by_token($app_id = '', $token = '', $select = '')
{
if (empty($token)) {
return false;
}
$where = array('app_id' => $app_id, 'user_token' => $token);
return $this->get_one('', $select, $where);
}
public function get_superadmin_list($select='')
{
$where = array(
'user_is_admin' => 1,
'user_denied' => 0,
);
$result = $this->get('', $select, $where);
return $result;
}
public function get_admin_list($limit = '', $offset = '', $where = '', $like = '', $findex = '', $forder = '', $sfield = '', $skeyword = '', $sop = 'OR')
{
$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(user_register_datetime, ' . $left . ') as day ', false);
$this->db->where('left(user_register_datetime, 10) >=', $start_date);
$this->db->where('left(user_register_datetime, 10) <=', $end_date);
$this->db->where('user_denied', 0);
$this->db->group_by('day');
$this->db->order_by('user_register_datetime', $orderby);
$qry = $this->db->get($this->_table);
$result = $qry->result_array();
return $result;
}
}

View File

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