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,81 @@
<?php
/**
* CodeIgniter
*
* An open source application development framework for PHP
*
* This content is released under the MIT License (MIT)
*
* Copyright (c) 2014 - 2015, British Columbia Institute of Technology
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @package CodeIgniter
* @author EllisLab Dev Team
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
* @copyright Copyright (c) 2014 - 2015, British Columbia Institute of Technology (http://bcit.ca/)
* @license http://opensource.org/licenses/MIT MIT License
* @link http://codeigniter.com
* @since Version 1.0.0
* @filesource
*/
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* CodeIgniter Array Helpers
*
* @package CodeIgniter
* @subpackage Helpers
* @category Helpers
* @author EllisLab Dev Team
* @link http://codeigniter.com/user_guide/helpers/array_helper.html
*/
// ------------------------------------------------------------------------
if ( ! function_exists('element'))
{
/**
* Element
*
* Lets you determine whether an array index is set and whether it has a value.
* If the element is empty it returns NULL (or whatever you specify as the default value.)
*
* @param string
* @param array
* @param mixed
* @return mixed depends on what the array contains
*/
function element($item, $array, $default = NULL)
{
return is_array($array) && array_key_exists($item, $array) ? $array[$item] : $default;
}
}
if ( ! function_exists('array_overlap')) {
function array_overlap($arr, $val) {
for ($i = 0, $m = count($arr); $i<$m; $i++) {
if ($arr[$i] === $val) {
return true;
}
}
return false;
}
}

View File

@@ -0,0 +1,192 @@
<?php
/**
* CodeIgniter
*
* An open source application development framework for PHP
*
* This content is released under the MIT License (MIT)
*
* Copyright (c) 2014 - 2016, British Columbia Institute of Technology
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @package CodeIgniter
* @author EllisLab Dev Team
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
* @copyright Copyright (c) 2014 - 2016, British Columbia Institute of Technology (http://bcit.ca/)
* @license http://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
* @since Version 1.0.0
* @filesource
*/
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* CodeIgniter Download Helpers
*
* @package CodeIgniter
* @subpackage Helpers
* @category Helpers
* @author EllisLab Dev Team
* @link https://codeigniter.com/user_guide/helpers/download_helper.html
*/
// ------------------------------------------------------------------------
if ( ! function_exists('force_download'))
{
/**
* Force Download
*
* Generates headers that force a download to happen
*
* @param string filename
* @param mixed the data to be downloaded
* @param bool whether to try and send the actual file MIME type
* @return void
*/
function force_download($filename = '', $data = '', $set_mime = FALSE)
{
if ($filename === '' OR $data === '')
{
return;
}
elseif ($data === NULL)
{
if ( ! @is_file($filename) OR ($filesize = @filesize($filename)) === FALSE)
{
return;
}
$filepath = $filename;
$filename = explode('/', str_replace(DIRECTORY_SEPARATOR, '/', $filename));
$filename = end($filename);
}
else
{
$filesize = strlen($data);
}
// Set the default MIME type to send
$mime = 'application/octet-stream';
$x = explode('.', $filename);
$extension = end($x);
if ($set_mime === TRUE)
{
if (count($x) === 1 OR $extension === '')
{
/* If we're going to detect the MIME type,
* we'll need a file extension.
*/
return;
}
// Load the mime types
$mimes =& get_mimes();
// Only change the default MIME if we can find one
if (isset($mimes[$extension]))
{
$mime = is_array($mimes[$extension]) ? $mimes[$extension][0] : $mimes[$extension];
}
}
/* It was reported that browsers on Android 2.1 (and possibly older as well)
* need to have the filename extension upper-cased in order to be able to
* download it.
*
* Reference: http://digiblog.de/2011/04/19/android-and-the-download-file-headers/
*/
if (count($x) !== 1 && isset($_SERVER['HTTP_USER_AGENT']) && preg_match('/Android\s(1|2\.[01])/', $_SERVER['HTTP_USER_AGENT']))
{
$x[count($x) - 1] = strtoupper($extension);
$filename = implode('.', $x);
}
if ($data === NULL && ($fp = @fopen($filepath, 'rb')) === FALSE)
{
return;
}
// Clean output buffer
if (ob_get_level() !== 0 && @ob_end_clean() === FALSE)
{
@ob_clean();
}
// IE인지 HTTP_USER_AGENT로 확인
$ie = isset($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'Trident') !== false);
// EDGE인지 HTTP_USER_AGENT로 확인
$edge = isset($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'], 'Edge') !== false);
if ($edge){
// edge인경우 파일명 rowurlencode로 인코딩시킴
$filename = rawurlencode($filename);
$filename = preg_replace('/\./', '%2e', $filename, substr_count($filename, '.') - 1);
// edge인 경우의 헤더 변경
$header_cachecontrol = 'private, no-transform, no-store, must-revalidate';
$header_pragma='no-cache';
}else{
if($ie) {
// UTF-8에서 EUC-KR로 캐릭터셋 변경
$filename = iconv('utf-8', 'euc-kr', $filename);
// IE인 경우 헤더 변경
$header_cachecontrol = 'must-revalidate, post-check=0, pre-check=0';
$header_pragma='public';
}else{
// IE가 아닌 경우 일반 헤더 적용
$header_cachecontrol = 'private, no-transform, no-store, must-revalidate';
$header_pragma='no-cache';
}
}
// Generate the server headers
header('Content-Type: '.$mime);
header('Expires: 0');
header('Content-Transfer-Encoding: binary');
header('Content-Length: '.$filesize);
header('Cache-Control: ' . $header_cachecontrol);
header('Content-Disposition: attachment; filename="'.$filename.'"');
header('Pragma: '. $header_pragma);
// If we have raw data - just dump it
if ($data !== NULL)
{
exit($data);
}
// Flush 1MB chunks of data
while ( ! feof($fp) && ($data = fread($fp, 1048576)) !== FALSE)
{
echo $data;
}
fclose($fp);
exit;
}
}

View File

@@ -0,0 +1,172 @@
<?php
/**
* CodeIgniter
*
* An open source application development framework for PHP
*
* This content is released under the MIT License (MIT)
*
* Copyright (c) 2014 - 2015, British Columbia Institute of Technology
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @package CodeIgniter
* @author EllisLab Dev Team
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
* @copyright Copyright (c) 2014 - 2015, British Columbia Institute of Technology (http://bcit.ca/)
* @license http://opensource.org/licenses/MIT MIT License
* @link http://codeigniter.com
* @since Version 1.0.0
* @filesource
*/
defined('BASEPATH') OR exit('No direct script access allowed');
if ( ! function_exists('set_value'))
{
/**
* Form Value
*
* Grabs a value from the POST array for the specified field so you can
* re-populate an input field or textarea. If Form Validation
* is active it retrieves the info from the validation class
*
* @param string $field Field name
* @param string $default Default value
* @param bool $html_escape Whether to escape HTML special characters or not
* @return string
*/
function set_value($field, $default = '', $html_escape = TRUE)
{
if (isset($_POST[$field])) {
return ($html_escape) ? html_escape($_POST[$field]) : $_POST[$field];
} else {
return ($html_escape) ? html_escape($default) : $default;
}
}
}
if ( ! function_exists('set_select'))
{
/**
* Set Select
*
* Let's you set the selected value of a <select> menu via data in the POST array.
* If Form Validation is active it retrieves the info from the validation class
*
* @param string
* @param string
* @param bool
* @return string
*/
function set_select($field, $value = '', $default = FALSE)
{
$CI =& get_instance();
if (isset($CI->form_validation) && is_object($CI->form_validation) && $CI->form_validation->has_rule($field)) {
return $CI->form_validation->set_select($field, $value, $default);
} else if (($input = $CI->input->post($field, FALSE)) === NULL) {
return ($default === TRUE) ? ' selected="selected"' : '';
}
$value = (string) $value;
if (is_array($input)) {
// Note: in_array('', array(0)) returns TRUE, do not use it
foreach ($input as &$v) {
if ($value === $v) {
return ' selected="selected"';
}
}
return '';
}
return ($input === $value) ? ' selected="selected"' : '';
}
}
// ------------------------------------------------------------------------
if ( ! function_exists('set_checkbox'))
{
/**
* Set Checkbox
*
* Let's you set the selected value of a checkbox via the value in the POST array.
* If Form Validation is active it retrieves the info from the validation class
*
* @param string
* @param string
* @param bool
* @return string
*/
function set_checkbox($field, $value = '', $default = FALSE)
{
$CI =& get_instance();
if (isset($CI->form_validation) && is_object($CI->form_validation) && $CI->form_validation->has_rule($field)) {
return $CI->form_validation->set_checkbox($field, $value, $default);
} else if (($input = $CI->input->post($field, FALSE)) === NULL) {
return ($default === TRUE) ? ' checked="checked"' : '';
}
$value = (string) $value;
if (is_array($input)) {
// Note: in_array('', array(0)) returns TRUE, do not use it
foreach ($input as &$v) {
if ($value === $v) {
return ' checked="checked"';
}
}
return '';
}
return ($input === $value) ? ' checked="checked"' : '';
}
}
// ------------------------------------------------------------------------
if ( ! function_exists('set_radio'))
{
/**
* Set Radio
*
* Let's you set the selected value of a radio field via info in the POST array.
* If Form Validation is active it retrieves the info from the validation class
*
* @param string $field
* @param string $value
* @param bool $default
* @return string
*/
function set_radio($field, $value = '', $default = FALSE)
{
$CI =& get_instance();
if (isset($CI->form_validation) && is_object($CI->form_validation) && $CI->form_validation->has_rule($field)) {
return $CI->form_validation->set_radio($field, $value, $default);
} else if (($input = $CI->input->post($field, FALSE)) === NULL) {
return ($default === TRUE) ? ' checked="checked"' : '';
}
return ($input === (string) $value) ? ' checked="checked"' : '';
}
}

View File

@@ -0,0 +1,50 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Url libraries helper
*/
/**
* query string 을 포함한 현재페이지 주소 전체를 return 합니다
*/
if ( ! function_exists('current_full_url')) {
function current_full_url()
{
$CI =& get_instance();
$url = $CI->config->site_url($CI->uri->uri_string());
$return = ($CI->input->server('QUERY_STRING'))
? $url . '?' . $CI->input->server('QUERY_STRING') : $url;
return $return;
}
}
/**
* 페이지 이동시 이 함수를 이용하면, gotourl 페이지를 거쳐가므로 referer 를 숨길 수 있습니다
*/
if ( ! function_exists('goto_url')) {
function goto_url($url = '')
{
if (empty($url)) {
return false;
}
$result = site_url('gotourl/?url=' . urlencode($url));
return $result;
}
}
/**
* Admin 페이지 주소를 return 합니다
*/
if ( ! function_exists('admin_url')) {
function admin_url($url = '')
{
$url = trim($url, '/');
return site_url(config_item('uri_segment_admin') . '/' . $url);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,169 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Chkstring libraries helper
*/
/**
* 입력값 검사 상수
*/
defined('_ALPHAUPPER_') or define('_ALPHAUPPER_', 1); // 영대문자
defined('_ALPHALOWER_') or define('_ALPHALOWER_', 2); // 영소문자
defined('_ALPHABETIC_') or define('_ALPHABETIC_', 4); // 영대,소문자
defined('_NUMERIC_') or define('_NUMERIC_', 8); // 숫자
defined('_HANGUL_') or define('_HANGUL_', 16); // 한글
defined('_SPACE_') or define('_SPACE_', 32); // 공백
defined('_SPECIAL_') or define('_SPECIAL_', 64); // 특수문자
/**
* 문자열이 한글, 영문, 숫자, 특수문자로 구성되어 있는지 검사
*/
if ( ! function_exists('chkstring')) {
function chkstring($str = '', $options = '')
{
$CI =& get_instance();
if (empty($str)) {
return false;
}
$s = '';
for ($i = 0; $i < strlen($str); $i++) {
$c = $str[$i];
$oc = ord($c);
// 한글
if ($oc >= 0xA0 && $oc <= 0xFF) {
if (strtoupper(config_item('charset')) === 'UTF-8') {
if ($options & _HANGUL_) {
$s .= $c . $str[$i+1] . $str[$i+2];
}
$i+= 2;
} else {
// 한글은 2바이트 이므로 문자하나를 건너뜀
$i++;
if ($options & _HANGUL_) {
$s .= $c . $str[$i];
}
}
} elseif ($oc >= 0x30 && $oc <= 0x39) {
// 숫자
if ($options & _NUMERIC_) {
$s .= $c;
}
} elseif ($oc >= 0x41 && $oc <= 0x5A) {
// 영대문자
if (($options & _ALPHABETIC_) OR ($options & _ALPHAUPPER_)) {
$s .= $c;
}
} elseif ($oc >= 0x61 && $oc <= 0x7A) {
// 영소문자
if (($options & _ALPHABETIC_) OR ($options & _ALPHALOWER_)) {
$s .= $c;
}
} elseif ($oc >= 0x20) {
// 공백
if ($options & _SPACE_) {
$s .= $c;
}
} else {
if ($options & _SPECIAL_) {
$s .= $c;
}
}
}
// 넘어온 값과 비교하여 같으면 참, 틀리면 거짓
return ($str === $s);
}
}
/**
* count the number of times an expression appears in a string
*
* @access private
*
* @param String $str
* @param String $exp
*
* @return int
*/
if ( ! function_exists('count_occurrences')) {
function count_occurrences($str, $exp)
{
$match = array();
preg_match_all($exp, $str, $match);
return count($match[0]);
}
}
/**
* count the number of lowercase characters in a string
*
* @access private
*
* @param String $str
*
* @return int
*/
if ( ! function_exists('count_lowercase')) {
function count_lowercase($str)
{
return count_occurrences($str, '/[a-z]/');
}
}
/**
* count the number of uppercase characters in a string
*
* @access private
*
* @param String $str
*
* @return int
*/
if ( ! function_exists('count_uppercase')) {
function count_uppercase($str)
{
return count_occurrences($str, '/[A-Z]/');
}
}
/**
* count the number of numbers characters in a string
*
* @access private
*
* @param String $str
*
* @return int
*/
if ( ! function_exists('count_numbers')) {
function count_numbers($str)
{
return count_occurrences($str, '/[0-9]/');
}
}
/**
* count the number of special characters in a string
*
* @access private
*
* @param String $str
*
* @return int
*/
if ( ! function_exists('count_specialchars')) {
function count_specialchars($str)
{
return count_occurrences($str, '/[!@#$%^&*()]/');
}
}

View File

@@ -0,0 +1,113 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
if ( ! function_exists('curl_data')) {
function curl_data($opt, $cookie_file ='') {
if ( ! element('url', $opt)) return;
if ($cookie_file) {
$fake_cookie_file = FCPATH . "uploads/" . $cookie_file;
}
$headers = array();
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, element('url', $opt));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//쿠키설정
if (isset($opt['cookie'])) {
$headers[] = 'Cookie: ' . $opt['cookie'];
curl_setopt($ch, CURLOPT_COOKIE, $opt['cookie']);
}
if ($cookie_file) {
curl_setopt($ch, CURLOPT_COOKIEJAR, $fake_cookie_file);
curl_setopt($ch, CURLOPT_COOKIEFILE, $fake_cookie_file);
}
curl_setopt($ch, CURLOPT_COOKIESESSION, true);
if(element('header', $opt)) {
curl_setopt($ch, CURLOPT_HEADER, TRUE);
}
if(element('httpheader', $opt)) {
curl_setopt($ch, CURLOPT_HTTPHEADER, element('httpheader', $opt));
}
if(element('post', $opt)) {
curl_setopt($ch, CURLOPT_POST, true);
}
if(element('postfields', $opt) && is_array($opt['postfields'])) {
if (element('no_http_build_query', $opt)) {
curl_setopt($ch, CURLOPT_POSTFIELDS, $opt['postfields']);
} else {
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($opt['postfields']));
}
}
if(element('postfields', $opt) && is_string($opt['postfields'])) {
curl_setopt($ch, CURLOPT_POSTFIELDS, $opt['postfields']);
}
if(element('followlocation', $opt)) {
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
}
if(element('referer', $opt)) {
curl_setopt($ch, CURLOPT_REFERER, element('referer', $opt));
}
if(element('nobody', $opt)) {
curl_setopt($ch, CURLOPT_NOBODY, true);
}
if(element('patch', $opt)) {
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PATCH');
}
if(element('useragent', $opt)) {
curl_setopt($ch, CURLOPT_USERAGENT, element('useragent', $opt));
}
if(element('ret_string', $opt)) {
$output = (string) curl_exec($ch);
} else {
$output = curl_exec($ch);
}
curl_close($ch);
return $output;
}
}
if ( ! function_exists('get_file_txt')) {
function get_file_txt($filename) {
$fp = fopen($filename, "r") or die("파일열기에 실패하였습니다");
$buffer = fread($fp, filesize($filename));
fclose($fp);
return $buffer;
}
}
if ( ! function_exists('isJson')) {
function isJson($string) {
return ((is_string($string) &&
(is_object(json_decode($string)) ||
is_array(json_decode($string))))) ? true : false;
}
}
if ( ! function_exists('is_url_exist')) {
function is_url_exist($url){
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_exec($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if($code == 200){
$status = true;
}else{
$status = false;
}
curl_close($ch);
return $status;
}
}

View File

@@ -0,0 +1,48 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Dhtml Editor helper
*/
if ( ! function_exists('display_dhtml_editor')) {
// Dhtml Editor 띄우기
function display_dhtml_editor($name = '', $content = '', $classname = '', $is_dhtml_editor = true, $editor_type = 'smarteditor')
{
$editorclassname = '';
$style = '';
if ($editor_type === 'smarteditor' && $is_dhtml_editor) {
$editor_url = site_url('plugin/editor/smarteditor');
$editorclassname = 'smarteditor';
$style = 'style="width:98%;"';
}
if ($editor_type === 'ckeditor' && $is_dhtml_editor) {
$editor_url = site_url('plugin/editor/ckeditor');
$editorclassname = 'ckeditor';
$style = 'style="width:98%;"';
}
$html = '';
if ($editor_type === 'smarteditor' && $is_dhtml_editor
&& ! defined('LOAD_DHTML_EDITOR_JS')) {
$html .= "\n" . '<script src="' . $editor_url . '/js/HuskyEZCreator.js"></script>';
$html .= "\n" . '<script type="text/javascript">var editor_url = "' . $editor_url . '", oEditors = [];</script>';
$html .= "\n" . '<script src="' . $editor_url . '/editor_config.js"></script>';
define('LOAD_DHTML_EDITOR_JS', true);
}
if ($editor_type === 'ckeditor' && $is_dhtml_editor
&& ! defined('LOAD_DHTML_EDITOR_JS')) {
$html .= "\n" . '<script src="' . $editor_url . '/ckeditor.js"></script>';
$html .= "\n" . '<script type="text/javascript">var editor_url = "' . $editor_url . '";</script>';
$html .= "\n" . '<script src="' . $editor_url . '/config.js"></script>';
define('LOAD_DHTML_EDITOR_JS', true);
}
$html .= "\n<textarea id=\"" . $name . "\" name=\"" . $name . "\" class=\"" . $editorclassname . ' ' . $classname . "\" " . $style . ">" . $content . "</textarea>";
return $html;
}
}

View File

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

View File

@@ -0,0 +1,41 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Password helper
*/
if ( ! function_exists('password_hash')) {
function password_hash($password = '', $key = '1')
{
if (empty($password)) {
return false;
}
include_once(APPPATH . 'libraries/PasswordHash.php');
$hasher = new PasswordHash();
$hash = $hasher->HashPassword($password);
return $hash;
}
}
if ( ! function_exists('password_verify')) {
function password_verify($password = '', $hash = '')
{
if (empty($password)) {
return false;
}
if (empty($hash)) {
return false;
}
include_once(APPPATH . 'libraries/PasswordHash.php');
$hasher = new PasswordHash();
return $hasher->CheckPassword($password, $hash);
}
}

View File

@@ -0,0 +1,535 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Thumbnail helper
*/
if ( ! function_exists('thumb_url')) {
function thumb_url($type = '', $filename = '', $thumb_width = 0, $thumb_height = 0, $is_create = false, $is_crop = true, $crop_mode = 'center', $is_sharpen = false, $um_value = '80/0.5/3', $create_animate_thumb = false)
{
if (empty($type) OR empty($filename)) {
$filename = 'noimage.gif';
$thumb = thumbnail(
'',
$filename,
$thumb_width,
$thumb_height,
$is_create,
$is_crop,
$crop_mode,
$is_sharpen,
$um_value,
$create_animate_thumb
);
return site_url($thumb);
}
$thumb = thumbnail(
$type,
$filename,
$thumb_width,
$thumb_height,
$is_create,
$is_crop,
$crop_mode,
$is_sharpen,
$um_value,
$create_animate_thumb
);
return site_url($thumb);
}
}
// 출처 : http://www.amina.co.kr
if ( ! function_exists('thumbnail')) {
function thumbnail($type = '', $filename = '', $thumb_width = 0, $thumb_height = 0, $is_create = false, $is_crop = true, $crop_mode = 'center', $is_sharpen = false, $um_value = '80/0.5/3', $create_animate_thumb = false)
{
$source_file = config_item('uploads_dir') . '/';
if ($type) {
$source_file .= $type . '/';
}
$source_file .= $filename;
if (is_file($source_file) === false) { // 원본 파일이 없다면
return;
}
if (empty($thumb_width) && empty($thumb_height)) {
return $source_file;
}
$size = @getimagesize($source_file);
if ($size[2] < 1 OR $size[2] > 3) { // gif, jpg, png 에 대해서만 적용
return;
}
$uploadDir = config_item('uploads_dir') . '/cache/';
if (is_dir($uploadDir) === false) {
@mkdir($uploadDir, 0755);
@chmod($uploadDir, 0755);
$file = $uploadDir . 'index.php';
$f = @fopen($file, 'w');
@fwrite($f, '');
@fclose($f);
@chmod($file, 0644);
}
if ($type) {
$uploadDir .= $type . '/';
if (is_dir($uploadDir) === false) {
@mkdir($uploadDir, 0755);
@chmod($uploadDir, 0755);
$file = $uploadDir . 'index.php';
$f = @fopen($file, 'w');
@fwrite($f, '');
@fclose($f);
@chmod($file, 0644);
}
}
$exp = explode('/', $filename);
$filepos = count($exp) - 1;
for ($k = 0; $k < $filepos; $k++) {
$uploadDir .= $exp[$k] . '/';
if (is_dir($uploadDir) === false) {
@mkdir($uploadDir, 0755);
@chmod($uploadDir, 0755);
$file = $uploadDir . 'index.php';
$f = @fopen($file, 'w');
@fwrite($f, '');
@fclose($f);
@chmod($file, 0644);
}
}
$realfilename = $exp[$filepos];
$target_path = $uploadDir;
// 디렉토리가 존재하지 않거나 쓰기 권한이 없으면 썸네일 생성하지 않음
if ( ! (is_dir($target_path) && is_writable($target_path))) {
return '';
}
// Animated GIF는 썸네일 생성하지 않음
if ($size[2] === 1) {
if (is_animated_gif ($source_file) && $create_animate_thumb === false) {
return $source_file;
}
}
$ext = array(1 => 'gif', 2 => 'jpg', 3 => 'png');
$thumb_filename = preg_replace("/\.[^\.]+$/i", '', $realfilename); // 확장자제거
$thumb_file = $target_path . 'thumb-' . $thumb_filename . '_' . $thumb_width . 'x' . $thumb_height . '.' . $ext[$size[2]];
$thumb_time = @filemtime($thumb_file);
$source_time = @filemtime($source_file);
if (file_exists($thumb_file)) {
if ($is_create === false && $source_time < $thumb_time) {
return $thumb_file;
}
}
// 원본파일의 GD 이미지 생성
$src = null;
$degree = 0;
if ($size[2] === 1) {
$src = imagecreatefromgif ($source_file);
$src_transparency = imagecolortransparent($src);
} elseif ($size[2] === 2) {
$src = imagecreatefromjpeg($source_file);
if (function_exists('exif_read_data')) {
// exif 정보를 기준으로 회전각도 구함
$exif = @exif_read_data($source_file);
if ( ! empty($exif['Orientation'])) {
switch ($exif['Orientation']) {
case 8:
$degree = 90;
break;
case 3:
$degree = 180;
break;
case 6:
$degree = -90;
break;
}
// 회전각도 있으면 이미지 회전
if ($degree) {
$src = imagerotate($src, $degree, 0);
// 세로사진의 경우 가로, 세로 값 바꿈
if ($degree === 90 || $degree === -90) {
$tmp = $size;
$size[0] = $tmp[1];
$size[1] = $tmp[0];
}
}
}
}
} elseif ($size[2] === 3) {
$src = imagecreatefrompng($source_file);
imagealphablending($src, true);
} else {
return;
}
if (empty($src)) {
return;
}
$is_large = true;
$keep_origin = false;
// width, height 설정
if ($thumb_width) {
if (empty($thumb_height)) {
$thumb_height = round(($thumb_width * $size[1]) / $size[0]);
if ($thumb_width > $size[0]) {
$keep_origin = true;
}
} else {
if ($size[0] < $thumb_width || $size[1] < $thumb_height) {
$is_large = false;
}
}
} else {
if ($thumb_height) {
$thumb_width = round(($thumb_height * $size[0]) / $size[1]);
}
}
$dst_x = 0;
$dst_y = 0;
$src_x = 0;
$src_y = 0;
$src_w = $size[0];
$src_h = $size[1];
$dst_w = $keep_origin ? $src_w : $thumb_width;
$dst_h = $keep_origin ? $src_h : $thumb_height;
$ratio = $dst_h / $dst_w;
if ($is_large) {
// 크롭처리
if ($is_crop) {
switch ($crop_mode) {
case 'center':
if ($size[1] / $size[0] >= $ratio) {
$src_h = round($src_w * $ratio);
$src_y = round(($size[1] - $src_h) / 2);
} else {
$src_w = round($size[1] / $ratio);
$src_x = round(($size[0] - $src_w) / 2);
}
break;
default:
if ($size[1] / $size[0] >= $ratio) {
$src_h = round($src_w * $ratio);
} else {
$src_w = round($size[1] / $ratio);
}
break;
}
}
$dst = imagecreatetruecolor($dst_w, $dst_h);
if ($size[2] === 3) {
imagealphablending($dst, false);
imagesavealpha($dst, true);
} elseif ($size[2] === 1) {
$palletsize = imagecolorstotal($src);
if ($src_transparency >= 0 && $src_transparency < $palletsize) {
$transparent_color = imagecolorsforindex($src, $src_transparency);
$current_transparent = imagecolorallocate($dst, $transparent_color['red'], $transparent_color['green'], $transparent_color['blue']);
imagefill($dst, 0, 0, $current_transparent);
imagecolortransparent($dst, $current_transparent);
}
}
} else {
$dst = imagecreatetruecolor($dst_w, $dst_h);
$bgcolor = imagecolorallocate($dst, 255, 255, 255); // 배경색
if ($src_w < $dst_w) {
if ($src_h >= $dst_h) {
$dst_x = round(($dst_w - $src_w) / 2);
$src_h = $dst_h;
} else {
$dst_x = round(($dst_w - $src_w) / 2);
$dst_y = round(($dst_h - $src_h) / 2);
$dst_w = $src_w;
$dst_h = $src_h;
}
} else {
if ($src_h < $dst_h) {
$dst_y = round(($dst_h - $src_h) / 2);
$dst_h = $src_h;
$src_w = $dst_w;
}
}
if ($size[2] === 3) {
$bgcolor = imagecolorallocatealpha($dst, 0, 0, 0, 127);
imagefill($dst, 0, 0, $bgcolor);
imagealphablending($dst, false);
imagesavealpha($dst, true);
} elseif ($size[2] === 1) {
$palletsize = imagecolorstotal($src);
if ($src_transparency >= 0 && $src_transparency < $palletsize) {
$transparent_color = imagecolorsforindex($src, $src_transparency);
$current_transparent = imagecolorallocate($dst, $transparent_color['red'], $transparent_color['green'], $transparent_color['blue']);
imagefill($dst, 0, 0, $current_transparent);
imagecolortransparent($dst, $current_transparent);
} else {
imagefill($dst, 0, 0, $bgcolor);
}
} else {
imagefill($dst, 0, 0, $bgcolor);
}
}
imagecopyresampled($dst, $src, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
// sharpen 적용
if ($is_sharpen && $is_large) {
$val = explode('/', $um_value);
UnsharpMask($dst, $val[0], $val[1], $val[2]);
}
if ($size[2] === 1) {
imagegif ($dst, $thumb_file);
} elseif ($size[2] === 3) {
$png_compress = 5;
imagepng($dst, $thumb_file, $png_compress);
} else {
$jpg_quality = 90;
imagejpeg($dst, $thumb_file, $jpg_quality);
}
chmod($thumb_file, 0644); // 추후 삭제를 위하여 파일모드 변경
imagedestroy($src);
imagedestroy($dst);
return $thumb_file;
}
}
// 출처 : http://vikjavev.no/computing/ump.php
if ( ! function_exists('UnsharpMask')) {
function UnsharpMask($img, $amount, $radius, $threshold)
{
/*
New:
- In version 2.1 (February 26 2007) Tom Bishop has done some important speed enhancements.
- From version 2 (July 17 2006) the script uses the imageconvolution function in PHP
version >= 5.1, which improves the performance considerably.
Unsharp masking is a traditional darkroom technique that has proven very suitable for
digital imaging. The principle of unsharp masking is to create a blurred copy of the image
and compare it to the underlying original. The difference in colour values
between the two images is greatest for the pixels near sharp edges. When this
difference is subtracted from the original image, the edges will be
accentuated.
The Amount parameter simply says how much of the effect you want. 100 is 'normal'.
Radius is the radius of the blurring circle of the mask. 'Threshold' is the least
difference in colour values that is allowed between the original and the mask. In practice
this means that low-contrast areas of the picture are left unrendered whereas edges
are treated normally. This is good for pictures of e.g. skin or blue skies.
Any suggenstions for improvement of the algorithm, expecially regarding the speed
and the roundoff errors in the Gaussian blur process, are welcome.
*/
////////////////////////////////////////////////////////////////////////////////////////////////
////
//// Unsharp Mask for PHP - version 2.1.1
////
//// Unsharp mask algorithm by Torstein Hønsi 2003-07.
//// thoensi_at_netcom_dot_no.
//// Please leave this notice.
////
///////////////////////////////////////////////////////////////////////////////////////////////
// $img is an image that is already created within php using
// imgcreatetruecolor. No url! $img must be a truecolor image.
// Attempt to calibrate the parameters to Photoshop:
if ($amount > 500) {
$amount = 500;
}
$amount = $amount * 0.016;
if ($radius > 50) {
$radius = 50;
}
$radius = $radius * 2;
if ($threshold > 255) {
$threshold = 255;
}
$radius = abs(round($radius)); // Only integers make sense.
if ($radius === 0) {
return $img; imagedestroy($img);
}
$w = imagesx($img); $h = imagesy($img);
$imgCanvas = imagecreatetruecolor($w, $h);
$imgBlur = imagecreatetruecolor($w, $h);
// Gaussian blur matrix:
//
// 1 2 1
// 2 4 2
// 1 2 1
//
//////////////////////////////////////////////////
if (function_exists('imageconvolution')) { // PHP >= 5.1
$matrix = array(
array( 1, 2, 1 ),
array( 2, 4, 2 ),
array( 1, 2, 1 ),
);
$divisor = array_sum(array_map('array_sum', $matrix));
$offset = 0;
imagecopy ($imgBlur, $img, 0, 0, 0, 0, $w, $h);
imageconvolution($imgBlur, $matrix, $divisor, $offset);
} else {
// Move copies of the image around one pixel at the time and merge them with weight
// according to the matrix. The same matrix is simply repeated for higher radii.
for ($i = 0; $i < $radius; $i++) {
imagecopy ($imgBlur, $img, 0, 0, 1, 0, $w - 1, $h); // left
imagecopymerge ($imgBlur, $img, 1, 0, 0, 0, $w, $h, 50); // right
imagecopymerge ($imgBlur, $img, 0, 0, 0, 0, $w, $h, 50); // center
imagecopy ($imgCanvas, $imgBlur, 0, 0, 0, 0, $w, $h);
imagecopymerge ($imgBlur, $imgCanvas, 0, 0, 0, 1, $w, $h - 1, 33.33333 ); // up
imagecopymerge ($imgBlur, $imgCanvas, 0, 1, 0, 0, $w, $h, 25); // down
}
}
if ($threshold> 0) {
// Calculate the difference between the blurred pixels and the original
// and set the pixels
for ($x = 0; $x < $w-1; $x++) { // each row
for ($y = 0; $y < $h; $y++) { // each pixel
$rgbOrig = ImageColorAt($img, $x, $y);
$rOrig = (($rgbOrig >> 16) & 0xFF);
$gOrig = (($rgbOrig >> 8) & 0xFF);
$bOrig = ($rgbOrig & 0xFF);
$rgbBlur = ImageColorAt($imgBlur, $x, $y);
$rBlur = (($rgbBlur >> 16) & 0xFF);
$gBlur = (($rgbBlur >> 8) & 0xFF);
$bBlur = ($rgbBlur & 0xFF);
// When the masked pixels differ less from the original
// than the threshold specifies, they are set to their original value.
$rNew = (abs($rOrig - $rBlur) >= $threshold)
? max(0, min(255, ($amount * ($rOrig - $rBlur)) + $rOrig))
: $rOrig;
$gNew = (abs($gOrig - $gBlur) >= $threshold)
? max(0, min(255, ($amount * ($gOrig - $gBlur)) + $gOrig))
: $gOrig;
$bNew = (abs($bOrig - $bBlur) >= $threshold)
? max(0, min(255, ($amount * ($bOrig - $bBlur)) + $bOrig))
: $bOrig;
if (($rOrig !== $rNew) || ($gOrig !== $gNew) || ($bOrig !== $bNew)) {
$pixCol = ImageColorAllocate($img, $rNew, $gNew, $bNew);
ImageSetPixel($img, $x, $y, $pixCol);
}
}
}
} else {
for ($x = 0; $x < $w; $x++) { // each row
for ($y = 0; $y < $h; $y++) { // each pixel
$rgbOrig = ImageColorAt($img, $x, $y);
$rOrig = (($rgbOrig >> 16) & 0xFF);
$gOrig = (($rgbOrig >> 8) & 0xFF);
$bOrig = ($rgbOrig & 0xFF);
$rgbBlur = ImageColorAt($imgBlur, $x, $y);
$rBlur = (($rgbBlur >> 16) & 0xFF);
$gBlur = (($rgbBlur >> 8) & 0xFF);
$bBlur = ($rgbBlur & 0xFF);
$rNew = ($amount * ($rOrig - $rBlur)) + $rOrig;
if ($rNew > 255) {
$rNew= 255;
} elseif ($rNew < 0) {
$rNew= 0;
}
$gNew = ($amount * ($gOrig - $gBlur)) + $gOrig;
if ($gNew > 255) {
$gNew= 255;
} elseif ($gNew < 0) {
$gNew= 0;
}
$bNew = ($amount * ($bOrig - $bBlur)) + $bOrig;
if ($bNew>255) {
$bNew= 255;
} elseif ($bNew < 0) {
$bNew= 0;
}
$rgbNew = ($rNew << 16) + ($gNew <<8) + $bNew;
ImageSetPixel($img, $x, $y, $rgbNew);
}
}
}
imagedestroy($imgCanvas);
imagedestroy($imgBlur);
return true;
}
}
// 출처 : http://www.php.net/manual/en/function.imagecreatefromgif.php#104473
if ( ! function_exists('is_animated_gif')) {
function is_animated_gif ($filename)
{
if ( ! ($fh = @fopen($filename, 'rb'))) {
return false;
}
$count = 0;
// an animated gif contains multiple "frames", with each frame having a
// header made up of:
// * a static 4-byte sequence (\x00\x21\xF9\x04)
// * 4 variable bytes
// * a static 2-byte sequence (\x00\x2C) (some variants may use \x00\x21 ?)
// We read through the file til we reach the end of the file, or we've found
// at least 2 frame headers
while ( ! feof($fh) && $count < 2) {
$chunk = fread($fh, 1024 * 100); //read 100kb at a time
$count += preg_match_all(
'#\x00\x21\xF9\x04.{4}\x00(\x2C|\x21)#s',
$chunk,
$matches
);
}
fclose($fh);
return $count > 1;
}
}