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

This commit is contained in:
jeonghwa
2026-07-03 05:27:29 +09:00
commit d918e2eddc
2971 changed files with 264195 additions and 0 deletions

View File

@@ -0,0 +1,78 @@
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class ArticleModel extends MY_Model
{
private $categories;
const PRESS_ID = 29;
public function __construct()
{
parent::__construct();
$this->load->database();
}
public function save($articles)
{
$inserted = [];
$this->categories = $this->categoryModel->findAll();
log_message('info', count($articles). ' articles');
foreach ($articles as $a) {
$arTimestamp = date('Y-m-d H:i:s', $a->ar_timestamp);
$a = (object) array_map(function ($val) {
return is_null($val) ? "" : $val;
}, (array) $a);
$article = [
'category_code' => $this->categoryModel->findByName($a->categoryTitle),
'news_type' => 1,
'title' => $a->ar_title,
'sub_title' => $a->ar_subtitle,
'main_img' => 'https://images.christiantoday.co.kr/data/images/full/' . $a->im_id . '/image.'. $a->im_filetype,
'video_url' => '',
'video_playtime' => '',
'press_idx' => self::PRESS_ID,
'press_name' => '크리스천투데이',
'reporter_name' => $a->reporter,
'reporter_email' => $a->reporter_email,
'content' => $a->ar_content,
'org_url' => $a->ar_originlink,
'is_auto_setting' => 'Y',
'tag' => $a->ta_title,
'is_del' => 'N',
'is_display' => 'Y',
'display_date' => date('Y-m-d H:i:s'),
'review_count1' => 0,
'review_count2' => 0,
'review_count3' => 0,
'review_count4' => 0,
'review_count5' => 0,
'hit_count' => 0,
'like_count' => 0,
'comment_count' => 0,
'share_count' => 0,
'popular_count' => 0,
'write_id' => $a->mb_no,
'write_name' => $a->mb_name,
'reg_id' => 'bot.ctnews.' . $a->ar_id,
'reg_date' => $arTimestamp,
'update_id' => 'developer',
'update_date' => $arTimestamp
];
// $article['content'] = '<p style="line-height: 1.8;"><span style="font-family: 나눔고딕코딩, NanumGothicCoding, sans-serif; font-size: 9pt;"><img src="' . $article['main_img'] . '" /></span></p><br style="clear:both;">' . $article['content'];
if (!$this->db->where('reg_id', $article['reg_id'])->get('news')->num_rows()) {
$article['content'] = preg_replace("{<img\\s*(.*?)src=('.*?'|\".*?\"|[^\\s]+)(.*?)\\s*/?>}ims", '<div style="text-align:center"><img $1src=$2 $3/></div>', $article['content']);
$article['content'] = str_replace('class="dimg"', 'style="color: #666;font-size: 12px;line-height: 16px;padding: 10px 4px 4px;letter-spacing: 0px;"', $article['content']);
$article['content'] = str_replace('class="imgtbl"', 'style="max-width: 650px;margin-bottom: 20px;margin-right:auto;margin-left:auto;"', $article['content']);
$article['content'] = str_replace('class="imgtbl"', 'style="max-width: 650px;margin-bottom: 20px;margin-right:auto;margin-left:auto;"', $article['content']);
$article['content'] = str_replace('<p>', '<p style="margin-bottom:10px">', $article['content']);
$article['content'] .= '<p style="line-height: 1.8;"><span style="font-family: 나눔고딕코딩, NanumGothicCoding, sans-serif; font-size: 11pt; color: rgb(172, 172, 172);">&lt;저작권자 ⓒ \'종교 신문 1위\' 크리스천투데이(<a href="http://www.chtoday.co.kr">www.chtoday.co.kr</a>), 무단전재 및 재배포 금지&gt;</span><span style="font-family: 나눔고딕코딩, NanumGothicCoding, sans-serif; font-size: 11pt; color: rgb(172, 172, 172);"></span>&nbsp;</p>';
$article['content'] = '<div style="font-size: 16px;line-height: 28px;letter-spacing: -1px;font-family: 나눔고딕코딩, NanumGothicCoding, sans-serif;">' . $article['content'] . '</div>';
$this->db->insert('news', $article);
array_push($inserted, $this->db->insert_id());
}
}
return $inserted;
}
}

View File

@@ -0,0 +1,31 @@
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class CategoryModel extends MY_Model
{
public $ca_parent;
public $ca_title;
public $ca_slug;
public $ca_order;
public $ca_hide;
public $ca_trend;
public $ca_hide_section;
public function __construct()
{
parent::__construct();
$this->load->database();
}
public function findAll() {
return $this->db->get('news_section')->result();
}
public function findByName($name) {
$query = $this->db->where('category_name', $name)
->get('news_section');
return $query->num_rows() ? $query->row()->category_code : 12;
}
}

View File

@@ -0,0 +1,18 @@
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class ChannelModel extends MY_Model
{
private $table = 'cm_curation_yt_channel';
public function __construct()
{
parent::__construct();
$this->load->database();
}
public function get() {
return $this->db->get($this->table)->result();
}
}

View File

@@ -0,0 +1,69 @@
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class CurationModel extends MY_Model
{
public $thumbnail;
public $title;
public $description;
public $likes;
public $subscribes;
public $updatedAt;
public $category;
public $link;
private $table = 'cm_curation_raw_yt';
public function __construct()
{
parent::__construct();
$this->load->database();
}
public function save($data)
{
$inserted = [];
$updated = [];
foreach ($data->videos as $v) {
if (empty($data->action) || $data->action == 'insert') {
$publishedAt = date('Y-m-d H:i:s', strtotime($v->publishedAt));
$v = (object) array_map(function ($val) {
return is_null($val) ? "" : $val;
}, (array) $v);
$video = [
'Title' => $v->title,
'Thumbnail' => $v->thumbnails->high->url,
'Description' => $v->description,
'Category' => $data->categoryTitle,
'VideoId' => $v->id,
'UpdatedAt' => $publishedAt,
'CreatedAt' => date('Y-m-d H:i:s')
];
}else $video = (array)$v;
if (!$this->db->where('VideoId', $video['VideoId'])->get($this->table)->num_rows()) {
$this->db->insert($this->table, $video);
array_push($inserted, $this->db->insert_id());
} else {
$this->db->where('VideoId', $video['VideoId'])->update($this->table, $video);
array_push($updated, $video['VideoId']);
}
}
return ['inserted' => $inserted, 'updated' => $updated];
}
public function get($data)
{
return $this->db->offset($data->offset)->limit(empty($data->limit) ? 10 : $data->limit)->get($this->table)->result();
}
public function delete($data)
{
$deleted = [];
foreach($data->videos as $video) {
$this->db->where('VideoId', $video->VideoId)->delete($this->table);
array_push($deleted, $video->VideoId);
}
return $deleted;
}
}

View File

@@ -0,0 +1,118 @@
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class LifeModel extends MY_Model
{
public $ca_parent;
public $ca_title;
public $ca_slug;
public $ca_order;
public $ca_hide;
public $ca_trend;
public $ca_hide_section;
public function __construct()
{
parent::__construct();
$this->load->database();
}
public function saveCmTv($data)
{
$inserted = [];
foreach ($data->videos as $v) {
$publishedAt = date('Y-m-d H:i:s', strtotime($v->publishedAt));
$v = (object) array_map(function ($val) {
return is_null($val) ? "" : $val;
}, (array) $v);
$video = [
'category_idx' => $data->categoryId,
'channel_idx' => 0,
'life_type' => 3,
'head_title' => '',
'title' => $this->encode($v->title),
'sub_title' => '',
'main_img' => $v->thumbnails->medium->url,
'video_url' => 'https://www.youtube.com/embed/' . $v->id,
'video_playtime' => '',
'content' => $this->encode(nl2br($v->description)),
'org_url' => 'https://youtu.be/' . $v->id,
'tag' => $v->title,
'partner_idx' => $data->editorId,
'editor_name' => $data->categoryTitle,
'hit_count' => 0,
'like_count' => 0,
'comment_count' => 0,
'share_count' => 0,
'popular_count' => 0,
'write_id' => 'developer',
'write_name' => $data->categoryTitle,
'reg_id' => 'bot.yt.' . $v->id,
'reg_date' => $publishedAt,
'update_id' => $publishedAt,
'update_date' => $publishedAt,
'is_display' => 'Y',
'display_date' => $publishedAt,
'is_del' => 'N',
];
$video['content'] = '<p style="line-height: 1.8;margin-top:30px"><span style="font-family: 나눔고딕코딩, NanumGothicCoding, sans-serif; font-size: 11pt;">' . $video['content'] . '</span></p>';
$lifeExists = $this->db->where('reg_id', $video['reg_id'])->where('category_idx', $video['category_idx'])->get('life');
if (!$lifeExists->num_rows()) {
$this->db->insert('life', $video);
array_push($inserted, $this->db->insert_id());
} else {
$this->db->where('reg_id', $video['reg_id'])->update('life', $video);
array_push($inserted, $lifeExists->row()->idx);
}
}
return $inserted;
}
/**
* Encode emoji in text
* @param string $text text to encode
*/
public static function encode($text)
{
return self::convertEmoji($text, "ENCODE");
}
/**
* Decode emoji in text
* @param string $text text to decode
*/
public static function decode($text)
{
return self::convertEmoji($text, "DECODE");
}
private static function convertEmoji($text, $op)
{
if ($op == "ENCODE") {
return preg_replace_callback('/([0-9|#][\x{20E3}])|[\x{00ae}|\x{00a9}|\x{203C}|\x{2047}|\x{2048}|\x{2049}|\x{3030}|\x{303D}|\x{2139}|\x{2122}|\x{3297}|\x{3299}][\x{FE00}-\x{FEFF}]?|[\x{2190}-\x{21FF}][\x{FE00}-\x{FEFF}]?|[\x{2300}-\x{23FF}][\x{FE00}-\x{FEFF}]?|[\x{2460}-\x{24FF}][\x{FE00}-\x{FEFF}]?|[\x{25A0}-\x{25FF}][\x{FE00}-\x{FEFF}]?|[\x{2600}-\x{27BF}][\x{FE00}-\x{FEFF}]?|[\x{2600}-\x{27BF}][\x{1F000}-\x{1FEFF}]?|[\x{2900}-\x{297F}][\x{FE00}-\x{FEFF}]?|[\x{2B00}-\x{2BF0}][\x{FE00}-\x{FEFF}]?|[\x{1F000}-\x{1F9FF}][\x{FE00}-\x{FEFF}]?|[\x{1F000}-\x{1F9FF}][\x{1F000}-\x{1FEFF}]?/u', array('self', "encodeEmoji"), $text);
} else {
return preg_replace_callback('/(\\\u[0-9a-f]{4})+/', array('self', "decodeEmoji"), $text);
}
}
private static function encodeEmoji($match)
{
return str_replace(array('[', ']', '"'), '', json_encode($match));
}
private static function decodeEmoji($text)
{
if (!$text) return '';
$text = $text[0];
$decode = json_decode($text, true);
if ($decode) return $decode;
$text = '["' . $text . '"]';
$decode = json_decode($text);
if (count($decode) == 1) {
return $decode[0];
}
return $text;
}
}

View File

@@ -0,0 +1,36 @@
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class PlaceModel extends MY_Model
{
private $table = 'cm_naver_place';
public function __construct()
{
parent::__construct();
$this->load->database();
}
public function save($places)
{
$inserted = array();
foreach($places[0]->data->places->items as $place) {
if($this->db->where('NId', $place->id)->from($this->table)->count_all_results() == 0) {
if($this->db->insert($this->table, array(
'NId' => $place->id,
'Category' => $place->category,
'Name' => $place->name,
'RoadAddress' => $place->roadAddress,
'Address' => $place->address,
'CommonAddress' => $place->commonAddress,
'Phone' => $place->phone,
'X' => $place->x,
'Y' => $place->y,
'CreatedAt' => date('Y-m-d H:i:s'),
)))
array_push($inserted, $this->db->insert_id());
}
}
return ['inserted' => $inserted];
}
}

View File

@@ -0,0 +1,42 @@
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class StationModel extends MY_Model
{
private $table = 'cm_station';
public function __construct()
{
parent::__construct();
$this->load->database();
}
private function findByCategoryConfigured()
{
return $this->db->where('Category >', 0)->select('Id, Category, Title')->get('cm_station')->result();
}
public function save($stations)
{
$categorizedStations = $this->findByCategoryConfigured();
$this->db->where('Category <=', 0)->delete($this->table);
$inserted = array();
$updated = array();
foreach ($stations as $key => $station) {
$upd = false;
foreach ($categorizedStations as $c) {
if ($c->Title == $station->Title) {
$stations[$key]->Category = $c->Category;
$upd = true;
$this->db->where($c->Id)->update($this->table, $station);
array_push($updated, $c->Id);
}
}
if (!$upd) {
$this->db->insert($this->table, $station);
array_push($inserted, $this->db->insert_id());
}
}
return ['inserted' => $inserted, 'updated' => $updated];;
}
}

View File

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