first commit
This commit is contained in:
55
application/helpers/crossmap/exception_helper.php
Executable file
55
application/helpers/crossmap/exception_helper.php
Executable file
@@ -0,0 +1,55 @@
|
||||
<?
|
||||
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* -----------------------------------------------------------------------------
|
||||
* PURPOSE : alert 후 이동
|
||||
* CREATE : 2018-02-19 alert
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
if ( ! function_exists('gf_alert') ) {
|
||||
function gf_alert($msg, $url='') {
|
||||
|
||||
|
||||
echo '<script>';
|
||||
echo ' alert("'.$msg.'");';
|
||||
if($url!='') {
|
||||
if($url=='back') {
|
||||
echo 'history.back();';
|
||||
} else if($url=='self_close') {
|
||||
echo 'self.close();';
|
||||
} else {
|
||||
|
||||
|
||||
$a = @$_SERVER['HTTP_REFERER'];
|
||||
$a = @explode("//crossmap.co.kr/",$a);
|
||||
$flag = @(substr($a[1],0,2));
|
||||
|
||||
|
||||
if($flag == 'm' || $flag == 'm/'){
|
||||
$split_url = substr($url,0,4);
|
||||
switch($split_url){
|
||||
case "/":
|
||||
$url = "/m";
|
||||
break;
|
||||
default:
|
||||
$url = str_replace("/web/","/m/",$url);
|
||||
$url = str_replace("web/","m/",$url);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// echo $url;
|
||||
|
||||
echo 'location.href="'.$url.'";';
|
||||
}
|
||||
}
|
||||
echo '</script>';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
129
application/helpers/crossmap/tool_helper.php
Executable file
129
application/helpers/crossmap/tool_helper.php
Executable file
@@ -0,0 +1,129 @@
|
||||
<?
|
||||
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* -----------------------------------------------------------------------------
|
||||
* PURPOSE : 페이징
|
||||
* CREATE : 2018-04-11
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
if ( ! function_exists('gf_paging') ) {
|
||||
function gf_paging($write_pages, $cur_page, $total_page, $url) {
|
||||
$str = "";
|
||||
if ($cur_page > 1) {
|
||||
//$str .= "<a href='" . $url . "1'><img src='/img/web/mypage_arrow_left.gif'></a>";
|
||||
//$str .= "<a href='" . $url . ($cur_page-1) . "' class='btn_page prev'>이전</a>";
|
||||
}
|
||||
|
||||
|
||||
$start_page = ( ( (int)( ($cur_page - 1 ) / $write_pages ) ) * $write_pages ) + 1;
|
||||
$end_page = $start_page + $write_pages - 1;
|
||||
|
||||
if ($end_page >= $total_page) $end_page = $total_page;
|
||||
|
||||
if ($start_page > 1) $str .= "<a href='" . $url . ($start_page-1) . "'><img src='".imgSrc('/img/web/mypage_arrow_left.gif'). "'></a>";
|
||||
|
||||
if ($total_page >= 1) {
|
||||
for ($k=$start_page;$k<=$end_page;$k++) {
|
||||
if ($cur_page != $k)
|
||||
$str .= " <a href='$url$k'>$k</a> ";
|
||||
else
|
||||
$str .= " <a class='current'>$k</a> ";
|
||||
}
|
||||
}
|
||||
|
||||
if ($total_page > $end_page) $str .= "<a href='" . $url . ($end_page+1) . "'><img src='". imgSrc('/img/web/mypage_arrow_right.gif'). "'></a>";
|
||||
|
||||
if ($cur_page < $total_page) {
|
||||
//$str .= "[<a href='$url" . ($cur_page+1) . "'>다음</a>]";
|
||||
//$str .= "<a href='$url$total_page' class='btn_page last'>마지막</a>";
|
||||
}
|
||||
//$str .= "</ul>";
|
||||
|
||||
return $str;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* -----------------------------------------------------------------------------
|
||||
* PURPOSE : 기사 시간 계산
|
||||
* CREATE : 2018-05-03
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
if ( ! function_exists('gf_article_date_text') ) {
|
||||
function gf_article_date_text($article_reg_date) {
|
||||
$now_date = date("Y-m-d H:i:s");
|
||||
$total_time = strtotime($now_date) - strtotime($article_reg_date);
|
||||
|
||||
$year = floor($total_time/(86400*30*12));
|
||||
$month = floor($total_time/(86400*30));
|
||||
$days = floor($total_time/86400);
|
||||
$hours = floor($total_time/3600);
|
||||
$min = floor($total_time/60);
|
||||
|
||||
$show_time = '1분 전';
|
||||
if($year > 0) {
|
||||
$show_time = $year.'년 전';
|
||||
} else if($month > 0) {
|
||||
$show_time = $month.'개월 전';
|
||||
} else if($days > 0) {
|
||||
$show_time = $days.'일 전';
|
||||
if($days > 6) {
|
||||
$diff = ceil($days/7);
|
||||
$show_time = $diff.'주일 전';
|
||||
}
|
||||
} else if($hours > 0) {
|
||||
$show_time = $hours.'시간 전';
|
||||
} else if($min > 0) {
|
||||
$show_time = $min.'분 전';
|
||||
}
|
||||
|
||||
return $show_time;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* -----------------------------------------------------------------------------
|
||||
* PURPOSE : 검색어 fulltext string으로 변경
|
||||
* CREATE : 2018-05-03
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
if ( ! function_exists('gf_search_keyword_fulltext_string') ) {
|
||||
function gf_search_keyword_fulltext_string($search_keyword) {
|
||||
|
||||
$search_keyword_txt = $search_keyword;
|
||||
$arr_keyword = explode(" ", $search_keyword);
|
||||
if(count($arr_keyword) > 0) {
|
||||
if(count($arr_keyword) > 1) array_unshift($arr_keyword, $search_keyword);
|
||||
$arr_new_keyword = array();
|
||||
foreach ($arr_keyword as $key =>$val) {
|
||||
$arr_new_keyword[] = '*'.$val.'*';
|
||||
}
|
||||
$search_keyword_txt = implode(" ", $arr_new_keyword);
|
||||
}
|
||||
|
||||
return $search_keyword_txt;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* -----------------------------------------------------------------------------
|
||||
* PURPOSE : 랜덤문자 + 숫자
|
||||
* CREATE : 2018-05-30
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
if ( ! function_exists('gf_generate_random_string') ) {
|
||||
function gf_generate_random_string($length = 10) {
|
||||
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
$charactersLength = strlen($characters);
|
||||
$randomString = '';
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$randomString .= $characters[rand(0, $charactersLength - 1)];
|
||||
}
|
||||
return $randomString;
|
||||
}
|
||||
}
|
||||
172
application/helpers/general_helper.php
Executable file
172
application/helpers/general_helper.php
Executable file
@@ -0,0 +1,172 @@
|
||||
<?php
|
||||
|
||||
function encodeEmoji($match)
|
||||
{
|
||||
return str_replace(array('[', ']', '"'), '', json_encode($match));
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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', "encodeEmoji", $text);
|
||||
} else {
|
||||
return preg_replace_callback('/(\\\u[0-9a-f]{4})+/', "decodeEmoji", $text);
|
||||
}
|
||||
}
|
||||
|
||||
function getMetaDescription($viewVars)
|
||||
{
|
||||
if (is_array($viewVars)) {
|
||||
if (empty($viewVars['Skin_Content'])) {
|
||||
return '';
|
||||
} else {
|
||||
getClearText($viewVars['Skin_Content']);
|
||||
}
|
||||
} else {
|
||||
return getClearText($viewVars);
|
||||
}
|
||||
}
|
||||
|
||||
function getClearText($str)
|
||||
{
|
||||
$text = substr(strip_tags($str), 0, 10000);
|
||||
$splited = explode(' ', $text);
|
||||
$cut = array_slice($splited, ceil(count($splited) / 5), ceil(count($splited) / 5) + 170);
|
||||
foreach ($cut as $k => $c) {
|
||||
$pattern = '/[\x{1100}-\x{11FF}\x{3130}-\x{318F}\x{AC00}-\x{D7AF}]+/u';
|
||||
preg_match_all($pattern, $c, $match);
|
||||
$cut[$k] = is_array($match[0]) ? implode(' ', $match[0]) : $match[0];
|
||||
}
|
||||
return implode(' ', array_filter($cut));
|
||||
}
|
||||
|
||||
function getMetaTitle($translate)
|
||||
{
|
||||
$page = explode('/', uri_string());
|
||||
return $translate[$page[count($page) - 1]];
|
||||
}
|
||||
|
||||
function cleanUrl($string)
|
||||
{
|
||||
$string = preg_replace('/[^\x{1100}-\x{11FF}\x{3130}-\x{318F}\x{AC00}-\x{D7AF}\-a-zA-Z0-9]+/u', '', str_replace(' ', '-', trim($string)));
|
||||
$string = preg_replace('/(u[0-9a-f]{4})+/', "", $string);
|
||||
$string = stripall(['--', '--'], '-', trim($string));
|
||||
$string = substr($string, 0, 1) == '-' ? substr($string, 1) : $string;
|
||||
return substr($string, -1) == '-' ? substr($string, 0, -1) : $string;
|
||||
}
|
||||
|
||||
function stripall($values, $replace, $string)
|
||||
{
|
||||
foreach ($values as $value) {
|
||||
while (strpos($string, $value)) {
|
||||
$string = str_replace($value, $replace, $string);
|
||||
stripall($values, $replace, $string);
|
||||
}
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
|
||||
function imgSrc($img)
|
||||
{
|
||||
if (is_array($img)) {
|
||||
$path = $img[1];
|
||||
return '<img src=' . (strpos($img[0], '"') ? '"' : "'") . getPathWithHost($path, true);
|
||||
} else {
|
||||
return getPathWithHost($img, true);
|
||||
}
|
||||
}
|
||||
|
||||
function contentImgSrc($content)
|
||||
{
|
||||
$content = stripslashes(html_entity_decode($content));
|
||||
return preg_replace_callback("/<img[^>]*?src *= *[\"']?([^\"']*)/i", 'imgSrc', $content);
|
||||
}
|
||||
|
||||
function getPathWithHost($path, $https = true)
|
||||
{
|
||||
$path = trim($path);
|
||||
$host = ENVIRONMENT == 'development' ? 'crossmap.christiandaily.co.kr' : $_SERVER['HTTP_HOST'];
|
||||
if ($path) {
|
||||
return strpos($path, '://') ? $path : 'http' . ($https ? 's' : '') . '://' . $host . '/static' . (substr($path, 0, 1) != '/' ? '/' . $path : $path);
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
function array_flatten($array)
|
||||
{
|
||||
if (!is_array($array)) {
|
||||
return false;
|
||||
}
|
||||
$result = array();
|
||||
foreach ($array as $key => $value) {
|
||||
if (is_array($value)) {
|
||||
$result = array_merge($result, array_flatten($value));
|
||||
} else {
|
||||
$result[$key] = $value;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
function time_elapsed_string($datetime, $full = false)
|
||||
{
|
||||
$now = new DateTime;
|
||||
$ago = new DateTime($datetime);
|
||||
$diff = $now->diff($ago);
|
||||
|
||||
$diff->w = floor($diff->d / 7);
|
||||
$diff->d -= $diff->w * 7;
|
||||
|
||||
$string = array(
|
||||
'y' => '년',
|
||||
'm' => '개월',
|
||||
'w' => '주',
|
||||
'd' => '일',
|
||||
'h' => '시간',
|
||||
'i' => '분',
|
||||
's' => '초',
|
||||
);
|
||||
foreach ($string as $k => &$v) {
|
||||
if ($diff->$k) {
|
||||
$v = $diff->$k . ' ' . $v . ($diff->$k > 1 ? '' : '');
|
||||
} else {
|
||||
unset($string[$k]);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$full) {
|
||||
$string = array_slice($string, 0, 1);
|
||||
}
|
||||
|
||||
return $string ? implode(', ', $string) . ' 전' : '방금전';
|
||||
}
|
||||
|
||||
function param($key)
|
||||
{
|
||||
return get_instance()->param($key);
|
||||
}
|
||||
|
||||
function go($go, $msg = '')
|
||||
{
|
||||
echo '<script>' . ($msg ? 'alert("' . $msg . '");' : '') . 'location.href="' . $go . '"</script>';
|
||||
}
|
||||
11
application/helpers/index.html
Executable file
11
application/helpers/index.html
Executable file
@@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user