first commit

This commit is contained in:
pakerpale
2020-06-10 06:21:34 +09:00
commit 20c9739ba9
1913 changed files with 266257 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Admincontrol_helper{
static function is_logged_in($userName)
{
if(($userName=="")):
$redirect= BASE_URL.'/admin/login';
header("Location: $redirect");
exit;
endif;
}
}

View File

@@ -0,0 +1,174 @@
<?php
require_once(__DIR__ . '/hoosk_page_helper.php');
function lq($result = '')
{
echo get_instance()->db->last_query();
print_r($result);
exit;
}
function getPostLink($post, $sn)
{
$post = is_object($post) ? $post : (object) $post;
$contentSection = ($sn == 'opinions' ? 'channel' : 'news');
return BASE_URL . '/' . $contentSection . '/' . ($sn == 'opinions' ? $post->pageID : $sn) . '/' . (empty($post->postSeq) ? $post->postID : $post->postSeq);
}
function getChildrenByParentId($parentId)
{
$sql = "SELECT
categoryID
FROM
(SELECT
categoryID
FROM
cm_category
WHERE
parentID = $parentId) a
UNION SELECT
categoryID
FROM
cm_category
WHERE
parentID IN (SELECT
categoryID
FROM
cm_category
WHERE
parentID = $parentId)";
return array_column(get_instance()->db->query($sql)->result(), 'categoryID');
}
function getNewsArticleURL($data, $sn = null)
{
$articles = [];
if (is_null($sn)) {
$subcategories = [];
foreach (NEWS_SECTION_CATEGORY as $sn => $sc) {
$subcategories[$sn] = getChildrenByParentId($sc);
array_push($subcategories[$sn], $sc);
}
foreach (NEWS_SECTION_CATEGORY as $sn => $sc) {
foreach ($data as $post) {
if (array_search($post->categoryID, $subcategories[$sn]) !== false) {
$post->articleURL = getPostLink($post, $sn);
array_push($articles, $post);
}
}
}
} else if (is_numeric($sn)) {
get_instance()->load->model('category_model');
$subcategories = get_instance()->category_model->getSubcategoriesByCategoryId($sn);
} else {
foreach ($data as $k => $p) {
$data[$k]->articleURL = getPostLink($p, $sn);
}
}
return $articles;
}
function getResultWithAuthor(&$data)
{
$userIds = array_column($data, 'userID');
if (count($userIds)) {
$users = get_instance()->db->where_in('cm_user.userID', $userIds)
->get('cm_user')
->result();
}
foreach ($data as $k => $t) {
$data[$k]->author = '';
foreach ($users as $u) {
if ($t->userID == $u->userID) {
$data[$k]->author = $u->name;
}
}
}
}
function r(callable $fn, $cache)
{
if (is_null($cache) || !$data = get_instance()->cache->get($cache['n'])) {
$data = $fn();
if (!is_null($cache) && !is_null($data)) {
$this->cache->save($cache['n'], $data, $cache['t']);
}
}
return $data;
}
function s($task, $duration, $cache)
{
$cache = 'task-' . $cache;
$lastExecutionTime = get_instance()->cache->get($cache);
if (time() - $lastExecutionTime >= $duration) {
get_instance()->cache->save($cache, time(), 60 * 60);
$task();
}
}
function getSessionUser()
{
$user = (object) ['is' => false];
get_instance()->load->library('session');
if (get_instance()->session->userdata('auth')) {
$user = json_decode(get_instance()->session->userdata('auth'));
$user->is = true;
};
return $user;
}
function getSearchTerm()
{
return get_instance()->input->get('term') ? get_instance()->input->get('term') : get_instance()->input->post('term');
}
function getPostComments($postId)
{
get_instance()->load->mode('comment_model');
$comments = get_instance()->comment_model->getByPostId($postId);
return $comments;
}
function getImageUrl($imagePath)
{
// return 'https://crossmap.co.kr' . $imagePath;
return strpos($imagePath, 'thumbs/') === false && strpos($imagePath, 'images/') === false ? 'https://crossmap.co.kr' . $imagePath : $imagePath;
}
function getThumbUrl($imagePath, $postThumb)
{
return 'https://crossmap.co.kr' . str_replace('files/', 'thumbs/', $imagePath);
return $postThumb ? $postThumb : 'https://crossmap.co.kr' . str_replace('files/', 'thumbs/', $imagePath);
}
function isAdminSite()
{
return defined('HOOSK_ADMIN') && HOOSK_ADMIN == 1;
}
function getPostsImageUrl(&$posts)
{
if (is_array($posts)) {
foreach ($posts as $k => $v) {
if (is_array($v)) {
if(isset($posts[$k]['postImage'])){
strpos($posts[$k]['postImage'], '://') === false ? ($posts[$k]['postImage'] = getImageUrl($posts[$k]['postImage'])) : '';
$posts[$k]['postImage'] = str_replace('http://', 'https://', $posts[$k]['postImage']);
}
} else {
if(isset($posts[$k]->postImage)) {
strpos($posts[$k]->postImage, '://') === false ? ($posts[$k]->postImage = getImageUrl($posts[$k]->postImage)) : '';
$posts[$k]->postImage = str_replace('http://', 'https://', $posts[$k]->postImage);
}
}
}
}
}
function getPrayPostUrl($post) {
return implode('/', ['/pray', $post->categorySlug, $post->postSeq]);
}

View File

@@ -0,0 +1,14 @@
<?php
if(!function_exists('wordlimit')) {
function wordlimit($string, $length = 40, $ellipsis = "...")
{
$string = strip_tags($string, '<div>');
$string = strip_tags($string, '<p>');
$words = explode(' ', $string);
if (count($words) > $length)
return implode(' ', array_slice($words, 0, $length)) . $ellipsis;
else
return $string.$ellipsis;
}
}

View File

@@ -0,0 +1,362 @@
<?php
if (!function_exists('wordlimit')) {
function wordlimit($string, $length = 40, $ellipsis = "...")
{
$string = strip_tags($string, '<div>');
$string = strip_tags($string, '<p>');
$words = explode(' ', $string);
if (count($words) > $length) {
return implode(' ', array_slice($words, 0, $length)) . $ellipsis;
} else {
return $string.$ellipsis;
}
}
}
//Get the navigation bar
function hooskNav($slug, $leadingPath = '', $segmentIdx = 0)
{
$navHtml = '';
$CI =& get_instance();
$CI->db->where('navSlug', $slug);
$query=$CI->db->get('cm_navigation');
foreach ($query->result_array() as $n):
$totSegments = $CI->uri->total_segments();
if (!is_numeric($CI->uri->segment($totSegments))) {
$current = "/".$CI->uri->segment($totSegments-(strpos($CI->uri->segment($totSegments), 'page-') === false ? 0:1));
} elseif (is_numeric($CI->uri->segment($totSegments))) {
$current = "/".$CI->uri->segment($totSegments-1);
}
if ($current == "/") {
$current = BASE_URL;
};
if($segmentIdx) $current = '/'.$CI->uri->segment($segmentIdx);
$current = $leadingPath. $current;
$navHtml .= str_replace('<li><a href="'.$current.'">', '<li class="current"><a href="'.$current.'" class="current">', $n['navHTML']);
endforeach;
return $navHtml;
}
function getLastUriSegment() {
return get_instance()->uri->segment(get_instance()->uri->total_segments());
}
function getFeedPosts()
{
$CI =& get_instance();
$CI->db->order_by("unixStamp", "desc");
$CI->db->where('published', 1);
$query=$CI->db->get('cm_post');
return $query->result_array();
}
//Get the Latest 5 news posts
function getLatestNewsSidebar()
{
$CI =& get_instance();
$CI->db->order_by("unixStamp", "desc");
$CI->db->where('published', 1);
$CI->db->limit(5, 0);
$query=$CI->db->get('cm_post');
$posts = '<ul class="list-group">';
foreach ($query->result_array() as $c):
$posts .= '<li class="list-group-item"><a href="'.BASE_URL.'/article/'.$c['postURL'].'">'.$c['postTitle'].'</a></li>';
endforeach;
$posts .= "</ul>";
echo $posts;
}
//Get the Latest news for the main column
function getLatestNews($limit=10, $offset=0)
{
$CI =& get_instance();
$CI->db->order_by("unixStamp", "desc");
$CI->db->where('published', 1);
$CI->db->limit($limit, $offset);
$query=$CI->db->get('cm_post');
$posts = '';
foreach ($query->result_array() as $c):
$date = new DateTime($c['datePosted']);
$posts .= '<div class="row">';
if ($c['postImage'] != "") {
$posts .= '<div class="col-md-3"><a href="'.BASE_URL.'/article/'.$c['postURL'].'"><img class="img-responsive" src="'.BASE_URL.'/images/'.$c['postImage'].'" alt="'.$c['postTitle'].'"/></a></div>';
$posts .= '<div class="col-md-9"><h3><a href="'.BASE_URL.'/article/'.$c['postURL'].'">'.$c['postTitle'].'</a></h3>';
$posts .= '<p class="meta">'.date_format($date, 'd/m/Y').'</p>';
$posts .= '<p>'.$c['postExcerpt'].'</p>';
$posts .= '<p><a class="btn btn-primary" href="'.BASE_URL.'/article/'.$c['postURL'].'">Read More</a></p>';
} else {
$posts .= '<div class="col-md-12"><h3><a href="'.BASE_URL.'/article/'.$c['postURL'].'">'.$c['postTitle'].'</a></h3>';
$posts .= '<p class="meta">'.date_format($date, 'd/m/Y').'</p>';
$posts .= '<p>'.$c['postExcerpt'].'</p>';
$posts .= '<p><a class="btn btn-primary" href="'.BASE_URL.'/article/'.$c['postURL'].'">Read More</a></p>';
}
$posts .= '</div>';
$posts .= "</div><hr />";
endforeach;
echo $posts;
}
//Get the categories
function getCategories()
{
$CI =& get_instance();
$CI->db->order_by("categoryTitle", "asc");
$query=$CI->db->get('cm_post_category');
$categories = '<ul class="list-group">';
foreach ($query->result_array() as $c):
$CI->db->where('categoryID', $c['categoryID']);
$CI->db->where('published', 1);
$CI->db->from('cm_post');
$query = $CI->db->get();
$totPosts = $query->num_rows();
if ($totPosts > 0) {
$categories .= '<li class="list-group-item"><a href="'.BASE_URL.'/category/'.$c['categorySlug'].'"><span class="badge">'.$totPosts.'</span>'.$c['categoryTitle'].'</a></li>';
}
endforeach;
$categories .= "</ul>";
echo $categories;
}
//Get the total posts
function countPosts($limit=10, $offset=0)
{
$CI =& get_instance();
$CI->db->from('cm_post');
$CI->db->where('published', 1);
$query = $CI->db->get();
$totPosts = $query->num_rows();
$showing = $offset+$limit;
if ($showing > $totPosts) {
$showing = $totPosts;
}
$offset++;
echo "Showing posts ".$offset." - ".$showing." of ".$totPosts;
}
function countCategoryPosts($categoryID, $limit=10, $offset=0)
{
$CI =& get_instance();
$CI->db->from('cm_post');
$CI->db->where('categoryID', $categoryID);
$CI->db->where('published', 1);
$query = $CI->db->get();
$totPosts = $query->num_rows();
$showing = $offset+$limit;
if ($showing > $totPosts) {
$showing = $totPosts;
}
$offset++;
echo "Showing posts ".$offset." - ".$showing." of ".$totPosts;
}
function getPrevBtnCategory($categoryID, $limit=10, $offset=0)
{
$CI =& get_instance();
$totSegments = $CI->uri->total_segments();
$i=1;
$pagURL = "";
while ($i <= $totSegments) {
if (!is_numeric($CI->uri->segment($i))) {
$pagURL .= "/".$CI->uri->segment($i);
}
$i++;
}
$CI->db->from('cm_post');
$CI->db->where('categoryID', $categoryID);
$CI->db->where('published', 1);
$query = $CI->db->get();
$totPosts = $query->num_rows();
$showing = $offset+$limit;
if ($showing > $totPosts) {
$showing = $totPosts;
}
$prevNum = $offset-$limit;
if ($prevNum < 0) {
$prevNum = 0;
}
if ($prevNum < $offset) {
echo '<a href="'.BASE_URL.$pagURL.'/'.$prevNum.'" class="btn btn-success float-left">Previous</a>';
}
}
function getNextBtnCategory($categoryID, $limit=10, $offset=0)
{
$CI =& get_instance();
$totSegments = $CI->uri->total_segments();
$i=1;
$pagURL = "";
while ($i <= $totSegments) {
if (!is_numeric($CI->uri->segment($i))) {
$pagURL .= "/".$CI->uri->segment($i);
}
$i++;
}
$CI->db->from('cm_post');
$CI->db->where('published', 1);
$CI->db->where('categoryID', $categoryID);
$query = $CI->db->get();
$totPosts = $query->num_rows();
$showing = $offset+$limit;
if ($showing > $totPosts) {
$showing = $totPosts;
}
$offset++;
$nextNum = $offset+$limit;
if ($nextNum > $totPosts) {
} elseif ($nextNum <= $totPosts) {
$nextNum--;
echo '<a href="'.BASE_URL.$pagURL.'/'.$nextNum.'" class="btn btn-success float-right">Next</a>';
}
}
function getPrevBtn($limit=10, $offset=0)
{
$CI =& get_instance();
$totSegments = $CI->uri->total_segments();
$i=1;
$pagURL = "";
while ($i <= $totSegments) {
if (!is_numeric($CI->uri->segment($i))) {
$pagURL .= "/".$CI->uri->segment($i);
}
$i++;
}
$CI->db->where('published', 1);
$CI->db->from('cm_post');
$query = $CI->db->get();
$totPosts = $query->num_rows();
$showing = $offset+$limit;
if ($showing > $totPosts) {
$showing = $totPosts;
}
$prevNum = $offset-$limit;
if ($prevNum < 0) {
$prevNum = 0;
}
if ($prevNum < $offset) {
echo '<a href="'.BASE_URL.$pagURL.'/'.$prevNum.'" class="btn btn-success float-left">Previous</a>';
}
}
function getNextBtn($limit=10, $offset=0)
{
$CI =& get_instance();
$totSegments = $CI->uri->total_segments();
$i=1;
$pagURL = "";
while ($i <= $totSegments) {
if (!is_numeric($CI->uri->segment($i))) {
$pagURL .= "/".$CI->uri->segment($i);
}
$i++;
}
$CI->db->where('published', 1);
$CI->db->from('cm_post');
$query = $CI->db->get();
$totPosts = $query->num_rows();
$showing = $offset+$limit;
if ($showing > $totPosts) {
$showing = $totPosts;
}
$offset++;
$nextNum = $offset+$limit;
if ($nextNum > $totPosts) {
} elseif ($nextNum <= $totPosts) {
$nextNum--;
echo '<a href="'.BASE_URL.$pagURL.'/'.$nextNum.'" class="btn btn-success float-right">Next</a>';
}
}
//Get the Latest news for the main column
function getCategoryNews($categoryID, $limit=10, $offset=0)
{
$CI =& get_instance();
$CI->db->order_by("unixStamp", "desc");
$CI->db->limit($limit, $offset);
$CI->db->where('categoryID', $categoryID);
$CI->db->where('published', 1);
$query=$CI->db->get('cm_post');
$posts = '';
foreach ($query->result_array() as $c):
$date = new DateTime($c['datePosted']);
$posts .= '<div class="row">';
if ($c['postImage'] != "") {
$posts .= '<div class="col-md-3"><a href="'.BASE_URL.'/article/'.$c['postURL'].'"><img class="img-responsive" src="'.BASE_URL.'/images/'.$c['postImage'].'" alt="'.$c['postTitle'].'"/></a></div>';
$posts .= '<div class="col-md-9"><h3><a href="'.BASE_URL.'/article/'.$c['postURL'].'">'.$c['postTitle'].'</a></h3>';
$posts .= '<p class="meta">'.date_format($date, 'd/m/Y').'</p>';
$posts .= '<p>'.$c['postExcerpt'].'</p>';
$posts .= '<p><a class="btn btn-primary" href="'.BASE_URL.'/article/'.$c['postURL'].'">Read More</a></p>';
} else {
$posts .= '<div class="col-md-12"><h3><a href="'.BASE_URL.'/article/'.$c['postURL'].'">'.$c['postTitle'].'</a></h3>';
$posts .= '<p class="meta">'.date_format($date, 'd/m/Y').'</p>';
$posts .= '<p>'.$c['postExcerpt'].'</p>';
$posts .= '<p><a class="btn btn-primary" href="'.BASE_URL.'/article/'.$c['postURL'].'">Read More</a></p>';
}
$posts .= '</div>';
$posts .= "</div><hr />";
endforeach;
echo $posts;
}
//Get the carousel
function getCarousel($id)
{
$CI =& get_instance();
$CI->db->order_by("slideOrder", "asc");
$CI->db->where("pageID", $id);
$query=$CI->db->get('cm_banner');
$carousel = '<ol class="carousel-indicators">'."\r\n";
$s = 0;
foreach ($query->result_array() as $c):
if ($s == 0) {
$carousel .= '<li data-target="#carousel" data-slide-to="'.$s.'" class="active"></li>'."\r\n";
} else {
$carousel .= '<li data-target="#carousel" data-slide-to="'.$s.'"></li>'."\r\n";
}
$s++;
endforeach;
$s = 0;
$carousel .= '</ol><div class="carousel-inner" role="listbox">'."\r\n";
foreach ($query->result_array() as $c):
if ($s == 0) {
$carousel .= '<div class="item active">'."\r\n";
if ($c['slideLink'] != "") {
$carousel .= '<a target="_blank" href="'.$c['slideLink'].'">'."\r\n";
}
$carousel .= '<img src="'.BASE_URL."/uploads/".$c['slideImage'].'" alt="'.$c['slideAlt'].'">'."\r\n";
if ($c['slideLink'] != "") {
$carousel .= '</a>'."\r\n";
}
$carousel .= '</div>'."\r\n";
} else {
$carousel .= '<div class="item">'."\r\n";
if ($c['slideLink'] != "") {
$carousel .= '<a target="_blank" href="'.$c['slideLink'].'">'."\r\n";
}
$carousel .= '<img src="'.BASE_URL."/uploads/".$c['slideImage'].'" alt="'.$c['slideAlt'].'">'."\r\n";
if ($c['slideLink'] != "") {
$carousel .= '</a>'."\r\n";
}
$carousel .= '</div>'."\r\n";
}
$s++;
endforeach;
$carousel .= "</div>"."\r\n";
echo $carousel;
}
//Get social
function getSocial()
{
$CI =& get_instance();
$CI->db->where("socialEnabled", 1);
$query=$CI->db->get('cm_social');
$social = '';
foreach ($query->result_array() as $c):
$social .= '<a href="'.$c['socialLink'].'" target="_blank"><span class="socicon socicon-'.$c['socialName'].'"></span></a>';
endforeach;
echo $social;
}

11
application/helpers/index.html Executable file
View File

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

View File

@@ -0,0 +1,57 @@
<?php
function getCho($col, $idx, $f_word)
{
// echo "getCho:" . $idx . "," . $f_word . "<br>";
if($f_word == 'ㄱ')
return " substr({$col},{$idx},1) between '가' and '낗'";
else if($f_word == 'ㄴ')
return " substr({$col},{$idx},1) between '나' and '닣'";
else if($f_word == 'ㄷ')
return " substr({$col},{$idx},1) between '다' and '띻'";
else if($f_word == 'ㄹ')
return " substr({$col},{$idx},1) between '라' and '맇'";
else if($f_word == 'ㅁ')
return " substr({$col},{$idx},1) between '마' and '밓'";
else if($f_word == 'ㅂ')
return " substr({$col},{$idx},1) between '바' and '삫'";
else if($f_word == 'ㅅ')
return " substr({$col},{$idx},1) between '사' and '앃'";
else if($f_word == 'ㅇ')
return " substr({$col},{$idx},1) between '아' and '잏'";
else if($f_word == 'ㅈ')
return " substr({$col},{$idx},1) between '자' and '찧'";
else if($f_word == 'ㅊ')
return " substr({$col},{$idx},1) between '차' and '칳'";
else if($f_word == 'ㅋ')
return " substr({$col},{$idx},1) between '카' and '킿'";
else if($f_word == 'ㅌ')
return " substr({$col},{$idx},1) between '타' and '팋'";
else if($f_word == 'ㅍ')
return " substr({$col},{$idx},1) between '파' and '핗'";
else if($f_word == 'ㅎ')
return " substr({$col},{$idx},1) between '하' and '힣'";
else
return " substr({$col},{$idx},1) = '{$f_word}'";
}
function splitCho($term) {
$i = 0;
$chos = array();
for ($i = 0; $i < mb_strlen($term,"UTF-8"); $i++) {
$char = mb_substr($term, $i, 1, 'UTF-8');
array_push($chos, $char);
}
return $chos;
}
function getSqlCho($colume, $term) {
$sql = "";
$i = 1;
foreach (splitCho($term) as $ch) {
$sql .= ($i == 1 ? "" : " AND ") . getCho($colume, $i++, $ch);
}
return $sql;
}