Initial import from local backup (Documents-Playground/pakerpale)
This commit is contained in:
81
application/helpers/CB_array_helper.php
Normal file
81
application/helpers/CB_array_helper.php
Normal 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;
|
||||
}
|
||||
}
|
||||
192
application/helpers/CB_download_helper.php
Normal file
192
application/helpers/CB_download_helper.php
Normal 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;
|
||||
}
|
||||
}
|
||||
194
application/helpers/CB_form_helper.php
Normal file
194
application/helpers/CB_form_helper.php
Normal file
@@ -0,0 +1,194 @@
|
||||
<?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"' : '';
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists('check_use_captcha'))
|
||||
{
|
||||
function check_use_captcha($member, $board=array(), $mode=''){
|
||||
|
||||
$use_captcha = false;
|
||||
|
||||
if( $member->is_admin() !== false ){ //관리자면 캡챠 사용 안함
|
||||
return false;
|
||||
}
|
||||
|
||||
if( $member->is_member() === false ){ //비회원은 캡챠 사용
|
||||
$use_captcha = true;
|
||||
}
|
||||
|
||||
if( element('board_use_captcha', $board) && $mode !== 'cu' ){ //글쓰기일때만
|
||||
$use_captcha = true;
|
||||
}
|
||||
|
||||
return $use_captcha;
|
||||
}
|
||||
}
|
||||
171
application/helpers/CB_url_helper.php
Normal file
171
application/helpers/CB_url_helper.php
Normal file
@@ -0,0 +1,171 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Url libraries helper
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 게시판 목록 주소를 return 합니다
|
||||
*/
|
||||
if ( ! function_exists('board_url')) {
|
||||
function board_url($key = '')
|
||||
{
|
||||
$key = trim($key, '/');
|
||||
return site_url(config_item('uri_segment_board') . '/' . $key);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 게시물 열람 페이지 주소를 return 합니다
|
||||
*/
|
||||
if ( ! function_exists('post_url')) {
|
||||
function post_url($key = '', $post_id = '')
|
||||
{
|
||||
$key = trim($key, '/');
|
||||
$post_id = trim($post_id, '/');
|
||||
|
||||
$post_url = '';
|
||||
if (strtoupper(config_item('uri_segment_post_type')) === 'B') {
|
||||
$post_url = site_url($key . '/' . config_item('uri_segment_post') . '/' . $post_id);
|
||||
} elseif (strtoupper(config_item('uri_segment_post_type')) === 'C') {
|
||||
$post_url = site_url(config_item('uri_segment_post') . '/' . $key . '/' . $post_id);
|
||||
} else {
|
||||
$post_url = site_url(config_item('uri_segment_post') . '/' . $post_id);
|
||||
}
|
||||
return $post_url;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 게시물 작성 페이지 주소를 return 합니다
|
||||
*/
|
||||
if ( ! function_exists('write_url')) {
|
||||
function write_url($key = '')
|
||||
{
|
||||
$key = trim($key, '/');
|
||||
return site_url(config_item('uri_segment_write') . '/' . $key);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 게시물 답변 페이지 주소를 return 합니다
|
||||
*/
|
||||
if ( ! function_exists('reply_url')) {
|
||||
function reply_url($key = '')
|
||||
{
|
||||
$key = trim($key, '/');
|
||||
return site_url(config_item('uri_segment_reply') . '/' . $key);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 게시물 수정 페이지 주소를 return 합니다
|
||||
*/
|
||||
if ( ! function_exists('modify_url')) {
|
||||
function modify_url($key = '')
|
||||
{
|
||||
$key = trim($key, '/');
|
||||
return site_url(config_item('uri_segment_modify') . '/' . $key);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 게시물 그룹 페이지 주소를 return 합니다
|
||||
*/
|
||||
if ( ! function_exists('group_url')) {
|
||||
function group_url($key = '')
|
||||
{
|
||||
$key = trim($key, '/');
|
||||
return site_url(config_item('uri_segment_group') . '/' . $key);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* RSS 페이지 주소를 return 합니다
|
||||
*/
|
||||
if ( ! function_exists('rss_url')) {
|
||||
function rss_url($key = '')
|
||||
{
|
||||
$key = trim($key, '/');
|
||||
return site_url(config_item('uri_segment_rss') . '/' . $key);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* FAQ 페이지 주소를 return 합니다
|
||||
*/
|
||||
if ( ! function_exists('faq_url')) {
|
||||
function faq_url($key = '')
|
||||
{
|
||||
$key = trim($key, '/');
|
||||
return site_url(config_item('uri_segment_faq') . '/' . $key);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 일반문서 페이지 주소를 return 합니다
|
||||
*/
|
||||
if ( ! function_exists('document_url')) {
|
||||
function document_url($key = '')
|
||||
{
|
||||
$key = trim($key, '/');
|
||||
return site_url(config_item('uri_segment_document') . '/' . $key);
|
||||
}
|
||||
}
|
||||
1542
application/helpers/basic_helper.php
Normal file
1542
application/helpers/basic_helper.php
Normal file
File diff suppressed because it is too large
Load Diff
224
application/helpers/bitly_helper.php
Normal file
224
application/helpers/bitly_helper.php
Normal file
@@ -0,0 +1,224 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Simple PHP library for interacting with the v3 bit.ly api (only deals with
|
||||
* JSON format, but supports new OAuth endpoints).
|
||||
* REQUIREMENTS: PHP, Curl, JSON
|
||||
*
|
||||
* @link https://github.com/Falicon/BitlyPHP
|
||||
* @author Kevin Marshall <info@falicon.com>
|
||||
*/
|
||||
|
||||
/**
|
||||
* The URI of the standard bitly v3 API.
|
||||
*/
|
||||
define('bitly_api', 'http://api.bit.ly/v3/');
|
||||
|
||||
/**
|
||||
* The URI of the bitly OAuth endpoints.
|
||||
*/
|
||||
define('bitly_oauth_api', 'https://api-ssl.bit.ly/v3/');
|
||||
|
||||
/**
|
||||
* The URI for OAuth access token requests.
|
||||
*/
|
||||
define('bitly_oauth_access_token', 'https://api-ssl.bit.ly/oauth/');
|
||||
|
||||
/**
|
||||
* Returns an OAuth access token as well as API users for a given code.
|
||||
*
|
||||
* @param $code
|
||||
* The OAuth verification code acquired via OAuth’s web authentication
|
||||
* protocol.
|
||||
* @param $redirect
|
||||
* The page to which a user was redirected upon successfully authenticating.
|
||||
* @param $client_id
|
||||
* The client_id assigned to your OAuth app. (http://bit.ly/a/account)
|
||||
* @param $client_secret
|
||||
* The client_secret assigned to your OAuth app. (http://bit.ly/a/account)
|
||||
*
|
||||
* @return
|
||||
* An associative array containing:
|
||||
* - login: The corresponding bit.ly users username.
|
||||
* - api_key: The corresponding bit.ly users API key.
|
||||
* - access_token: The OAuth access token for specified user.
|
||||
*
|
||||
* @see http://code.google.com/p/bitly-api/wiki/ApiDocumentation#/oauth/access_token
|
||||
*/
|
||||
function bitly_oauth_access_token($code, $redirect, $client_id, $client_secret) {
|
||||
$results = array();
|
||||
$url = bitly_oauth_access_token . "access_token";
|
||||
$params = array();
|
||||
$params['client_id'] = $client_id;
|
||||
$params['client_secret'] = $client_secret;
|
||||
$params['code'] = $code;
|
||||
$params['redirect_uri'] = $redirect;
|
||||
$output = bitly_post_curl($url, $params);
|
||||
$parts = explode('&', $output);
|
||||
foreach ($parts as $part) {
|
||||
$bits = explode('=', $part);
|
||||
$results[$bits[0]] = $bits[1];
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an OAuth access token via the user's bit.ly login Username and Password
|
||||
*
|
||||
* @param $username
|
||||
* The user's Bitly username
|
||||
* @param $password
|
||||
* The user's Bitly password
|
||||
* @param $client_id
|
||||
* The client_id assigned to your OAuth app. (http://bit.ly/a/account)
|
||||
* @param $client_secret
|
||||
* The client_secret assigned to your OAuth app. (http://bit.ly/a/account)
|
||||
*
|
||||
* @return
|
||||
* An associative array containing:
|
||||
* - access_token: The OAuth access token for specified user.
|
||||
*
|
||||
*/
|
||||
|
||||
function bitly_oauth_access_token_via_password($username, $password, $client_id, $client_secret) {
|
||||
$results = array();
|
||||
$url = bitly_oauth_access_token . "access_token";
|
||||
|
||||
$headers = array();
|
||||
$headers[] = 'Authorization: Basic '.base64_encode($client_id . ":" . $client_secret);
|
||||
|
||||
$params = array();
|
||||
$params['grant_type'] = "password";
|
||||
$params['username'] = $username;
|
||||
$params['password'] = $password;
|
||||
|
||||
$output = bitly_post_curl($url, $params, $headers);
|
||||
|
||||
$decoded_output = json_decode($output,1);
|
||||
|
||||
$results = array(
|
||||
"access_token" => $decoded_output['access_token']
|
||||
);
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format a GET call to the bit.ly API.
|
||||
*
|
||||
* @param $endpoint
|
||||
* bit.ly API endpoint to call.
|
||||
* @param $params
|
||||
* associative array of params related to this call.
|
||||
* @param $complex
|
||||
* set to true if params includes associative arrays itself (or using <php5)
|
||||
*
|
||||
* @return
|
||||
* associative array of bit.ly response
|
||||
*
|
||||
* @see http://code.google.com/p/bitly-api/wiki/ApiDocumentation#/v3/validate
|
||||
*/
|
||||
function bitly_get($endpoint, $params, $complex=false) {
|
||||
$result = array();
|
||||
if ($complex) {
|
||||
$url_params = "";
|
||||
foreach ($params as $key => $val) {
|
||||
if (is_array($val)) {
|
||||
// we need to flatten this into one proper command
|
||||
$recs = array();
|
||||
foreach ($val as $rec) {
|
||||
$tmp = explode('/', $rec);
|
||||
$tmp = array_reverse($tmp);
|
||||
array_push($recs, $tmp[0]);
|
||||
}
|
||||
$val = implode('&' . $key . '=', $recs);
|
||||
}
|
||||
$url_params .= '&' . $key . "=" . $val;
|
||||
}
|
||||
$url = bitly_oauth_api . $endpoint . "?" . substr($url_params, 1);
|
||||
} else {
|
||||
$url = bitly_oauth_api . $endpoint . "?" . http_build_query($params);
|
||||
}
|
||||
|
||||
//echo $url . "\n";
|
||||
|
||||
$result = json_decode(bitly_get_curl($url), true);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format a POST call to the bit.ly API.
|
||||
*
|
||||
* @param $uri
|
||||
* URI to call.
|
||||
* @param $fields
|
||||
* Array of fields to send.
|
||||
*/
|
||||
function bitly_post($endpoint, $params) {
|
||||
$result = array();
|
||||
$url = bitly_oauth_api . $api_endpoint;
|
||||
$output = json_decode(bitly_post_curl($url, $params), true);
|
||||
$result = $output['data'][str_replace('/', '_', $api_endpoint)];
|
||||
$result['status_code'] = $output['status_code'];
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a GET call to the bit.ly API.
|
||||
*
|
||||
* @param $uri
|
||||
* URI to call.
|
||||
*/
|
||||
function bitly_get_curl($uri) {
|
||||
$output = "";
|
||||
try {
|
||||
$ch = curl_init($uri);
|
||||
curl_setopt($ch, CURLOPT_HEADER, 0);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 4);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
|
||||
$output = curl_exec($ch);
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a POST call to the bit.ly API.
|
||||
*
|
||||
* @param $uri
|
||||
* URI to call.
|
||||
* @param $fields
|
||||
* Array of fields to send.
|
||||
*/
|
||||
function bitly_post_curl($uri, $fields, $header_array = array()) {
|
||||
$output = "";
|
||||
$fields_string = "";
|
||||
foreach($fields as $key=>$value) { $fields_string .= $key.'='.urlencode($value).'&'; }
|
||||
rtrim($fields_string,'&');
|
||||
try {
|
||||
$ch = curl_init($uri);
|
||||
|
||||
if(is_array($header_array) && !empty($header_array)){
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $header_array);
|
||||
}
|
||||
|
||||
curl_setopt($ch, CURLOPT_HEADER, 0);
|
||||
curl_setopt($ch,CURLOPT_POST,count($fields));
|
||||
curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 2);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
|
||||
$output = curl_exec($ch);
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
173
application/helpers/chkstring_helper.php
Normal file
173
application/helpers/chkstring_helper.php
Normal file
@@ -0,0 +1,173 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Chkstring libraries helper
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* 입력값 검사 상수
|
||||
*/
|
||||
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, '/[!@#$%^&*()]/');
|
||||
}
|
||||
}
|
||||
156
application/helpers/dhtml_editor_helper.php
Normal file
156
application/helpers/dhtml_editor_helper.php
Normal file
@@ -0,0 +1,156 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Dhtml Editor helper
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
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/service/HuskyEZCreator.js"></script>';
|
||||
$html .= "\n" . '<script type="text/javascript">var editor_url = "' . $editor_url . '", oEditors = [], ed_nonce = "'.ft_nonce_create('smarteditor').'";</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;
|
||||
}
|
||||
}
|
||||
|
||||
// This method creates a key / value pair for a url string
|
||||
if(!function_exists('ft_nonce_create_query_string')){
|
||||
function ft_nonce_create_query_string( $action = '', $user = '' ){
|
||||
return "_nonce=".ft_nonce_create( $action , $user );
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists('ft_nonce_get_unique_key')){
|
||||
function ft_nonce_get_unique_key(){
|
||||
|
||||
static $cache = null;
|
||||
|
||||
if( $cache !== null ){
|
||||
return $cache;
|
||||
}
|
||||
|
||||
$CI = & get_instance();
|
||||
|
||||
$cache = sha1($CI->config->item('encryption_key').session_id());
|
||||
|
||||
return $cache;
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists('ft_get_secret_key')){
|
||||
function ft_get_secret_key($secret){
|
||||
return md5(ft_nonce_get_unique_key().$secret);
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists('ft_nonce_get_session_key')){
|
||||
function ft_nonce_get_session_key(){
|
||||
return substr(md5(ft_nonce_get_unique_key()), 5);
|
||||
}
|
||||
}
|
||||
|
||||
// This method creates an nonce. It should be called by one of the previous two functions.
|
||||
if(!function_exists('ft_nonce_create')){
|
||||
function ft_nonce_create( $action = '',$user='', $timeoutSeconds=3600 ){
|
||||
|
||||
$CI = & get_instance();
|
||||
|
||||
$secret = ft_get_secret_key($action.$user);
|
||||
|
||||
$CI->session->set_userdata('token_'.ft_nonce_get_session_key(), $secret);
|
||||
|
||||
$salt = ft_nonce_generate_hash();
|
||||
$time = time();
|
||||
$maxTime = $time + $timeoutSeconds;
|
||||
$nonce = $salt . "|" . $maxTime . "|" . sha1( $salt . $secret . $maxTime );
|
||||
return $nonce;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// This method validates an nonce
|
||||
if(!function_exists('ft_nonce_is_valid')){
|
||||
function ft_nonce_is_valid( $nonce, $action = '', $user='' ){
|
||||
|
||||
$CI = & get_instance();
|
||||
|
||||
$secret = ft_get_secret_key($action.$user);
|
||||
|
||||
$token = $CI->session->userdata('token_'.ft_nonce_get_session_key());
|
||||
|
||||
if ($secret != $token){
|
||||
return false;
|
||||
}
|
||||
|
||||
if (is_string($nonce) == false) {
|
||||
return false;
|
||||
}
|
||||
$a = explode('|', $nonce);
|
||||
if (count($a) != 3) {
|
||||
return false;
|
||||
}
|
||||
$salt = $a[0];
|
||||
$maxTime = intval($a[1]);
|
||||
$hash = $a[2];
|
||||
$back = sha1( $salt . $secret . $maxTime );
|
||||
if ($back != $hash) {
|
||||
return false;
|
||||
}
|
||||
if (time() > $maxTime) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// This method generates the nonce timestamp
|
||||
if(!function_exists('ft_nonce_generate_hash')){
|
||||
function ft_nonce_generate_hash(){
|
||||
$length = 10;
|
||||
$chars='1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM';
|
||||
$ll = strlen($chars)-1;
|
||||
$o = '';
|
||||
while (strlen($o) < $length) {
|
||||
$o .= $chars[ rand(0, $ll) ];
|
||||
}
|
||||
return $o;
|
||||
}
|
||||
}
|
||||
10
application/helpers/index.html
Normal file
10
application/helpers/index.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
71
application/helpers/naver_blog_post_helper.php
Normal file
71
application/helpers/naver_blog_post_helper.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Baisc helper
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 네이버 블로그에 포스팅하기
|
||||
*/
|
||||
if ( ! function_exists('naver_blog_post')) {
|
||||
|
||||
function naver_blog_post($title, $description, $board)
|
||||
{
|
||||
|
||||
$CI =& get_instance();
|
||||
|
||||
if ( ! $CI->cbconfig->item('use_naver_blog_post')) {
|
||||
return;
|
||||
}
|
||||
if ( ! $CI->cbconfig->item('naver_blog_userid')) {
|
||||
return;
|
||||
}
|
||||
if ( ! $CI->cbconfig->item('naver_blog_api_key')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 이 게시판은 네이버 블로그 자동등록 기능을 사용하지 않습니다
|
||||
if ( ! element('use_naver_blog_post', $board)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$blog_api_url = "https://api.blog.naver.com/xmlrpc";
|
||||
$user_id = $CI->cbconfig->item('naver_blog_userid');
|
||||
$blogid = $CI->cbconfig->item('naver_blog_userid');
|
||||
$password = $CI->cbconfig->item('naver_blog_api_key');
|
||||
$publish = true;
|
||||
|
||||
include_once(FCPATH . 'plugin/xmlrpc/xmlrpc.lib.php');
|
||||
|
||||
$client = new xmlrpc_client($blog_api_url);
|
||||
|
||||
|
||||
$client->setSSLVerifyPeer(false); // 기본값은 true인데, false로 설정하지 않으면 SSL 에러남.
|
||||
$GLOBALS['xmlrpc_internalencoding']='UTF-8'; // 기본값은 ISO-8859-1, 기본값 사용시 한글 깨짐.
|
||||
|
||||
$struct = array(
|
||||
'title' => new xmlrpcval($title, "string"),
|
||||
'description' => new xmlrpcval($description, "string")
|
||||
);
|
||||
|
||||
$f = new xmlrpcmsg("metaWeblog.newPost",
|
||||
array(
|
||||
new xmlrpcval($blogid, "string"),
|
||||
new xmlrpcval($user_id, "string"),
|
||||
new xmlrpcval($password, "string"),
|
||||
new xmlrpcval($struct , "struct"),
|
||||
new xmlrpcval($publish, "boolean")
|
||||
)
|
||||
);
|
||||
$f->request_charset_encoding = 'UTF-8';
|
||||
|
||||
//echo '<pre>'; print_r($f); exit;
|
||||
|
||||
return $response = $client->send($f);
|
||||
}
|
||||
}
|
||||
45
application/helpers/password_helper.php
Normal file
45
application/helpers/password_helper.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Password helper
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
539
application/helpers/thumbnail_helper.php
Normal file
539
application/helpers/thumbnail_helper.php
Normal file
@@ -0,0 +1,539 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Thumbnail helper
|
||||
*
|
||||
* Copyright (c) CIBoard <www.ciboard.co.kr>
|
||||
*
|
||||
* @author CIBoard (develop@ciboard.co.kr)
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user