From ab469a871832447959cbd160da89ff56dd80c631 Mon Sep 17 00:00:00 2001 From: whitedot Date: Fri, 29 Mar 2013 10:10:40 +0900 Subject: [PATCH 01/63] =?UTF-8?q?=EC=82=AC=EC=9A=A9=EC=9E=90,=EB=AA=A8?= =?UTF-8?q?=EB=B0=94=EC=9D=BC:=20#418=20=EC=97=90=20=EB=94=B0=EB=A5=B8=20s?= =?UTF-8?q?ide=5Fnb=20->=20aside=20=EB=B3=80=EA=B2=BD=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- css/default.css | 2 +- head.php | 4 ++-- mobile/head.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/css/default.css b/css/default.css index ed7de8713..9c8e38266 100644 --- a/css/default.css +++ b/css/default.css @@ -110,7 +110,7 @@ a:active {color:#000;text-decoration:underline} #wrapper:after {display:block;visibility:hidden;clear:both;content:""} #wrapper_title {margin-bottom:20px;font-size:1.2em} -#side_nb {float:right;width:209px;border:1px solid #cfded8;background:#fff} +#wrapper aside {float:right;width:209px;border:1px solid #cfded8;background:#fff} #container {z-index:4;position:relative;float:left;padding:25px 15px 15px;width:728px;min-height:500px;height:auto !important;height:500px;border:1px solid #cfded8;background:#fff;zoom:1} #container:after {display:block;visibility:hidden;clear:both;content:""} diff --git a/head.php b/head.php index 02ed55ba8..5a8094c32 100644 --- a/head.php +++ b/head.php @@ -155,10 +155,10 @@ if ($config['cf_include_head']) {
-
+
+

diff --git a/mobile/head.php b/mobile/head.php index 6d79e2ece..6f0d1d19b 100644 --- a/mobile/head.php +++ b/mobile/head.php @@ -94,9 +94,9 @@ include_once(G4_LIB_PATH.'/popular.lib.php');
-
+
+

From f5b91d5e4a72ab430995ebe79ba0c6d2bc8e7c7d Mon Sep 17 00:00:00 2001 From: whitedot Date: Fri, 29 Mar 2013 10:31:03 +0900 Subject: [PATCH 02/63] =?UTF-8?q?=EC=82=AC=EC=9A=A9=EC=9E=90,=EB=AA=A8?= =?UTF-8?q?=EB=B0=94=EC=9D=BC:=20aside=20id=20=EC=B2=98=EB=A6=AC=20?= =?UTF-8?q?=EB=B0=8F=20#416=20=EC=97=90=20=EB=94=B0=EB=A5=B8=20=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=A7=80=20=ED=83=80=EC=9D=B4=ED=8B=80=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bbs/board.php | 4 ++-- css/default.css | 2 +- head.php | 2 +- mobile/head.php | 2 +- skin/board/basic/list.skin.php | 2 +- skin/board/gallery/list.skin.php | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/bbs/board.php b/bbs/board.php index 9098c359c..40e98a31b 100644 --- a/bbs/board.php +++ b/bbs/board.php @@ -112,7 +112,7 @@ if (isset($wr_id) && $wr_id) { set_session($ss_name, TRUE); } - $g4['title'] = strip_tags(conv_subject($write['wr_subject'], 255)); + $g4['title'] = strip_tags(conv_subject($write['wr_subject'], 255))." > ".$board['bo_subject']; } else { if ($member['mb_level'] < $board['bo_list_level']) { if ($member['mb_id']) @@ -123,7 +123,7 @@ if (isset($wr_id) && $wr_id) { if (!isset($page) || (isset($page) && $page == 0)) $page = 1; - $g4['title'] = $board['bo_subject']; + $g4['title'] = $board['bo_subject']." ".$page." 페이지"; } include_once(G4_PATH.'/head.sub.php'); diff --git a/css/default.css b/css/default.css index 9c8e38266..d936b2055 100644 --- a/css/default.css +++ b/css/default.css @@ -110,7 +110,7 @@ a:active {color:#000;text-decoration:underline} #wrapper:after {display:block;visibility:hidden;clear:both;content:""} #wrapper_title {margin-bottom:20px;font-size:1.2em} -#wrapper aside {float:right;width:209px;border:1px solid #cfded8;background:#fff} +#wrapper #aside {float:right;width:209px;border:1px solid #cfded8;background:#fff} #container {z-index:4;position:relative;float:left;padding:25px 15px 15px;width:728px;min-height:500px;height:auto !important;height:500px;border:1px solid #cfded8;background:#fff;zoom:1} #container:after {display:block;visibility:hidden;clear:both;content:""} diff --git a/head.php b/head.php index 5a8094c32..9b3cc7460 100644 --- a/head.php +++ b/head.php @@ -155,7 +155,7 @@ if ($config['cf_include_head']) {
-
"; $content .= "
"; diff --git a/skin/member/basic/password_lost2.skin.php b/skin/member/basic/password_lost2.skin.php index a443bde1e..568d8b1fc 100644 --- a/skin/member/basic/password_lost2.skin.php +++ b/skin/member/basic/password_lost2.skin.php @@ -62,7 +62,7 @@ $content .= "

회원아이디 ".$mb['mb_id']."
"; $content .= "변경될 패스워드 ".$change_password.""; $content .= "

"; -$content .= "패스워드 변경"; +$content .= "패스워드 변경"; $content .= "
"; $content .= "
"; From b22733033740fe3b7c5cc6726ccd50965d33ee7a Mon Sep 17 00:00:00 2001 From: chicpro Date: Mon, 1 Apr 2013 13:40:16 +0900 Subject: [PATCH 09/63] =?UTF-8?q?=EB=B9=84=EB=B0=80=EA=B8=80=20=EC=97=B4?= =?UTF-8?q?=EB=9E=8C=EC=8B=9C=20=EB=8F=8C=EC=95=84=EA=B0=80=EA=B8=B0=20?= =?UTF-8?q?=EB=A7=81=ED=81=AC=20=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bbs/password.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bbs/password.php b/bbs/password.php index 532d8e0d2..2751d8cc4 100644 --- a/bbs/password.php +++ b/bbs/password.php @@ -21,8 +21,10 @@ switch ($w) { // 패스워드 창에서 로그인 하는 경우 관리자 또는 자신의 글이면 바로 글보기로 감 if ($is_admin || ($member['mb_id'] == $write['mb_id'] && $write['mb_id'])) goto_url('./board.php?bo_table='.$bo_table.'&wr_id='.$wr_id); - else + else { $action = './password_check.php'; + $return_url = $_SERVER['HTTP_REFERER']; + } break; default : alert('w 값이 제대로 넘어오지 않았습니다.'); From 44f84631453ce04893b48ce8bc1a0571a2098701 Mon Sep 17 00:00:00 2001 From: chicpro Date: Mon, 1 Apr 2013 14:09:38 +0900 Subject: [PATCH 10/63] =?UTF-8?q?=EB=AA=A8=EB=B0=94=EC=9D=BC=EC=97=90?= =?UTF-8?q?=EC=84=9C=20pc=20=EB=AA=A8=EB=B0=94=EC=9D=BC=EA=B0=84=20?= =?UTF-8?q?=EC=9D=B4=EB=8F=99=20=EB=A7=81=ED=81=AC=20=EC=98=A4=EB=A5=98=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tail.php b/tail.php index 467927911..79713c5c9 100644 --- a/tail.php +++ b/tail.php @@ -32,7 +32,7 @@ if ($config['cf_include_tail']) {
- + 모바일 버전으로 보기 From a16d0ec13a6f6b369db70e2c1827d689be30ab40 Mon Sep 17 00:00:00 2001 From: chicpro Date: Mon, 1 Apr 2013 14:55:27 +0900 Subject: [PATCH 11/63] =?UTF-8?q?=EB=A1=9C=EA=B7=B8=EC=9D=B8=20url?= =?UTF-8?q?=EC=97=90=20qstr=20=EB=B3=80=EC=88=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bbs/board.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bbs/board.php b/bbs/board.php index 231338f36..34c8c7b88 100644 --- a/bbs/board.php +++ b/bbs/board.php @@ -28,7 +28,7 @@ if (isset($wr_id) && $wr_id) { if (isset($group['gr_use_access']) && $group['gr_use_access']) { if ($is_guest) { $msg = "비회원은 이 게시판에 접근할 권한이 없습니다.\\n\\n회원이시라면 로그인 후 이용해 보십시오."; - alert($msg, './login.php?wr_id='.$wr_id.$qstr.'&url='.urlencode(G4_BBS_URL.'/board.php?bo_table='.$bo_table.'&wr_id='.$wr_id)); + alert($msg, './login.php?wr_id='.$wr_id.$qstr.'&url='.urlencode(G4_BBS_URL.'/board.php?bo_table='.$bo_table.'&wr_id='.$wr_id.$qstr)); } // 그룹관리자 이상이라면 통과 @@ -49,7 +49,7 @@ if (isset($wr_id) && $wr_id) { if ($is_member) alert('글을 읽을 권한이 없습니다.', G4_URL); else - alert('글을 읽을 권한이 없습니다.\\n\\n회원이시라면 로그인 후 이용해 보십시오.', './login.php?wr_id='.$wr_id.$qstr.'&url='.urlencode(G4_BBS_URL.'/board.php?bo_table='.$bo_table.'&wr_id='.$wr_id)); + alert('글을 읽을 권한이 없습니다.\\n\\n회원이시라면 로그인 후 이용해 보십시오.', './login.php?wr_id='.$wr_id.$qstr.'&url='.urlencode(G4_BBS_URL.'/board.php?bo_table='.$bo_table.'&wr_id='.$wr_id.$qstr)); } // 자신의 글이거나 관리자라면 통과 @@ -118,7 +118,7 @@ if (isset($wr_id) && $wr_id) { if ($member['mb_id']) alert('목록을 볼 권한이 없습니다.', G4_URL); else - alert('목록을 볼 권한이 없습니다.\\n\\n회원이시라면 로그인 후 이용해 보십시오.', './login.php?wr_id='.$wr_id.$qstr.'&url='.urlencode(G4_BBS_URL.'/board.php?bo_table='.$bo_table.'&wr_id='.$wr_id)); + alert('목록을 볼 권한이 없습니다.\\n\\n회원이시라면 로그인 후 이용해 보십시오.', './login.php?wr_id='.$wr_id.$qstr.'&url='.urlencode(G4_BBS_URL.'/board.php?bo_table='.$bo_table.'&wr_id='.$wr_id.$qstr)); } if (!isset($page) || (isset($page) && $page == 0)) $page = 1; From 46010a03042936b62d064b0ee129ffb749f47801 Mon Sep 17 00:00:00 2001 From: chicpro Date: Mon, 1 Apr 2013 15:34:50 +0900 Subject: [PATCH 12/63] =?UTF-8?q?goto=5Furl=20=ED=95=A8=EC=88=98=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/common.lib.php | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/lib/common.lib.php b/lib/common.lib.php index 6b571e669..3da1f3716 100644 --- a/lib/common.lib.php +++ b/lib/common.lib.php @@ -87,7 +87,17 @@ function goto_url($url) { $url = str_replace("&", "&", $url); //echo ""; - @header("Location:$url"); + + if (!headers_sent()) + header('Location: '.$url); + else { + echo ''; + echo ''; + } exit; } @@ -510,13 +520,13 @@ function conv_content($content, $html) $content .= ""; } - $content = preg_replace_callback("/<([^>]+)>/s", 'bad130128', $content); + $content = preg_replace_callback("/<([^>]+)>/s", 'bad130128', $content); $content = preg_replace($source, $target, $content); // XSS (Cross Site Script) 막기 // 완벽한 XSS 방지는 없다. - + // 이런 경우를 방지함 //$content = preg_replace("#\/\*.*\*\/#iU", "", $content); // 위의 정규식이 아래와 같은 내용을 통과시키므로 not greedy(비탐욕수량자?) 옵션을 제거함. ignore case 옵션도 필요 없으므로 제거 @@ -560,9 +570,9 @@ function conv_content($content, $html) $pattern .= "(o|&#(x6f|111);?)"; $pattern .= "(n|&#(x6e|110);?)"; //$content = preg_replace("/".$pattern."/i", "__EXPRESSION__", $content); - $content = preg_replace("/<[^>]*".$pattern."/i", "__EXPRESSION__", $content); + $content = preg_replace("/<[^>]*".$pattern."/i", "__EXPRESSION__", $content); // 와 같은 코드에 취약점이 있어 수정함. 121213 - $content = preg_replace("/(?<=style)(\s*=\s*[\"\']?xss\:)/i", '="__XSS__', $content); + $content = preg_replace("/(?<=style)(\s*=\s*[\"\']?xss\:)/i", '="__XSS__', $content); $content = bad_tag_convert($content); } else // text 이면 From c817f62fea60b9e0dbdd75b7cf840152e6a46374 Mon Sep 17 00:00:00 2001 From: gnuboard Date: Wed, 3 Apr 2013 19:19:58 +0900 Subject: [PATCH 13/63] =?UTF-8?q?=EC=BA=A1=EC=B1=A0=ED=82=A4=EA=B0=80=20?= =?UTF-8?q?=EB=84=98=EC=96=B4=EC=98=A4=EC=A7=80=20=EC=95=8A=EB=8A=94=20?= =?UTF-8?q?=EA=B2=BD=EC=9A=B0=20return=20false;=20=EC=8B=9C=ED=82=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bbs/gcaptcha/gcaptcha.lib.php | 1 + 1 file changed, 1 insertion(+) diff --git a/bbs/gcaptcha/gcaptcha.lib.php b/bbs/gcaptcha/gcaptcha.lib.php index d59b41007..4fdd5da7d 100644 --- a/bbs/gcaptcha/gcaptcha.lib.php +++ b/bbs/gcaptcha/gcaptcha.lib.php @@ -198,6 +198,7 @@ function chk_captcha() $captcha_cnt = (int)$_SESSION['ss_captcha_cnt']; if ($captcha_cnt > 5) return false; + if (!trim($_POST['captcha_key'])) return false; if (!isset($_POST['captcha_key'])) return false; if ($_POST['captcha_key'] != $_SESSION['ss_captcha_key']) { $_SESSION['ss_captcha_cnt'] = $captcha_cnt + 1; From a4fb0490947e4f606f30513fefa695055b73d105 Mon Sep 17 00:00:00 2001 From: chicpro Date: Thu, 4 Apr 2013 09:13:43 +0900 Subject: [PATCH 14/63] =?UTF-8?q?outlogin,=20poll=20=EC=B6=9C=EB=A0=A5?= =?UTF-8?q?=EB=B6=80=EB=B6=84=20=20=EB=AA=A8=EB=B0=94=EC=9D=BC=20=EC=B2=B4?= =?UTF-8?q?=ED=81=AC=20=EC=BD=94=EB=93=9C=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- head.php | 4 ++-- mobile/head.php | 2 +- mobile/tail.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/head.php b/head.php index 9b3cc7460..441cd5f7d 100644 --- a/head.php +++ b/head.php @@ -156,8 +156,8 @@ if ($config['cf_include_head']) {

diff --git a/mobile/head.php b/mobile/head.php index a9f0004a5..58e1248a1 100644 --- a/mobile/head.php +++ b/mobile/head.php @@ -95,7 +95,7 @@ include_once(G4_LIB_PATH.'/popular.lib.php');

diff --git a/mobile/tail.php b/mobile/tail.php index 1d7302527..a61bcb183 100644 --- a/mobile/tail.php +++ b/mobile/tail.php @@ -13,7 +13,7 @@ if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
  • @@ -23,7 +23,7 @@ if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
    - +
    From f584996cfc4a51fe14899e69a1ba4775f0c3ab13 Mon Sep 17 00:00:00 2001 From: gnuboard Date: Thu, 4 Apr 2013 17:38:07 +0900 Subject: [PATCH 15/63] =?UTF-8?q?=ED=9A=8C=EC=9B=90=EC=A0=95=EB=B3=B4=20?= =?UTF-8?q?=EB=B6=84=EC=8B=A4=EC=8B=9C=20=EC=B0=BE=EC=9D=84=20=EC=88=98=20?= =?UTF-8?q?=EC=9E=88=EB=8A=94=20=EB=AC=B8=EA=B5=AC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- skin/member/basic/register_result.skin.php | 2 +- skin/member/kcpcert/register_result.skin.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/skin/member/basic/register_result.skin.php b/skin/member/basic/register_result.skin.php index 383393a40..76e2774ad 100644 --- a/skin/member/basic/register_result.skin.php +++ b/skin/member/basic/register_result.skin.php @@ -28,7 +28,7 @@ if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가

    회원님의 패스워드는 아무도 알 수 없는 암호화 코드로 저장되므로 안심하셔도 좋습니다.
    - 아이디, 패스워드 분실시에는 회원가입시 입력하신 패스워드 분실시 질문, 답변을 이용하여 찾을 수 있습니다. + 아이디, 패스워드 분실시에는 회원가입시 입력하신 이메일 주소를 이용하여 찾을 수 있습니다.

    diff --git a/skin/member/kcpcert/register_result.skin.php b/skin/member/kcpcert/register_result.skin.php index 383393a40..76e2774ad 100644 --- a/skin/member/kcpcert/register_result.skin.php +++ b/skin/member/kcpcert/register_result.skin.php @@ -28,7 +28,7 @@ if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가

    회원님의 패스워드는 아무도 알 수 없는 암호화 코드로 저장되므로 안심하셔도 좋습니다.
    - 아이디, 패스워드 분실시에는 회원가입시 입력하신 패스워드 분실시 질문, 답변을 이용하여 찾을 수 있습니다. + 아이디, 패스워드 분실시에는 회원가입시 입력하신 이메일 주소를 이용하여 찾을 수 있습니다.

    From 922c30786de6a328b07a6878c0bd1602fc7b92d1 Mon Sep 17 00:00:00 2001 From: gnuboard Date: Thu, 4 Apr 2013 18:45:27 +0900 Subject: [PATCH 16/63] =?UTF-8?q?=EC=BA=A1=EC=B1=A0=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EC=9D=BC=EA=B4=84=EC=82=AD=EC=A0=9C=20=EB=A9=94=EB=89=B4?= =?UTF-8?q?=EC=97=90=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- adm/admin.menu100.php | 1 + 1 file changed, 1 insertion(+) diff --git a/adm/admin.menu100.php b/adm/admin.menu100.php index dca04e108..34b39bbe1 100644 --- a/adm/admin.menu100.php +++ b/adm/admin.menu100.php @@ -10,6 +10,7 @@ $menu['menu100'] = array ( //array('100700', '복구/최적화', G4_ADMIN_URL.'/repair.php', 'cf_repair'), array('100800', '세션파일 일괄삭제',G4_ADMIN_URL.'/session_file_delete.php', 'cf_session'), array('100900', '캐쉬파일 일괄삭제',G4_ADMIN_URL.'/cache_file_delete.php', 'cf_cache'), + array('100910', '캡챠파일 일괄삭제',G4_ADMIN_URL.'/gcaptcha_file_delete.php', 'cf_gcaptcha'), //array('', 'phpMyAdmin', ''.$g4['path'].'/'.$g4['phpmyadmin_dir'].'', 'cf_phpmyadmin') ); ?> \ No newline at end of file From b14c6b484498301163bc5972843d9770cf0deb54 Mon Sep 17 00:00:00 2001 From: gnuboard Date: Thu, 4 Apr 2013 18:45:43 +0900 Subject: [PATCH 17/63] =?UTF-8?q?=EC=BA=A1=EC=B1=A0=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EC=9D=BC=EA=B4=84=EC=82=AD=EC=A0=9C=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- adm/gcaptcha_file_delete.php | 52 ++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 adm/gcaptcha_file_delete.php diff --git a/adm/gcaptcha_file_delete.php b/adm/gcaptcha_file_delete.php new file mode 100644 index 000000000..35d193cc8 --- /dev/null +++ b/adm/gcaptcha_file_delete.php @@ -0,0 +1,52 @@ + + +

    +

    + 완료 메세지가 나오기 전에 프로그램의 실행을 중지하지 마십시오. +

    + 캐시디렉토리를 열지못했습니다.

    '; + } + + $cnt=0; + echo '
      '.PHP_EOL; + + $files = glob(G4_DATA_PATH.'/cache/gcaptcha-*'); + if (is_array($files)) { + $before_time = date('ymdHis', G4_SERVER_TIME - 3600); // 한시간전 + foreach ($files as $gcaptcha_file) { + $access_time = date('ymdHis', fileatime($gcaptcha_file)); // 파일접근시간 + + if ($access_time > $before_time) continue; + + $cnt++; + unlink($gcaptcha_file); + echo '
    • '.$gcaptcha_file.'
    • '.PHP_EOL; + + flush(); + + if ($cnt%10==0) + echo PHP_EOL; + } + } + + echo '
    • 완료됨
    '.PHP_EOL; + echo '

    캡챠파일 '.$cnt.'건의 삭제가 완료됐습니다.
    프로그램의 실행을 끝마치셔도 좋습니다.

    '.PHP_EOL; + ?> +
    + + \ No newline at end of file From 07ea1631454ab4c2347b1810021c8be3c9dbc7be Mon Sep 17 00:00:00 2001 From: gnuboard Date: Thu, 4 Apr 2013 18:45:59 +0900 Subject: [PATCH 18/63] =?UTF-8?q?=EC=BA=90=EC=8B=9C=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EC=9D=BC=EA=B4=84=EC=82=AD=EC=A0=9C=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- adm/cache_file_delete.php | 53 ++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 29 deletions(-) diff --git a/adm/cache_file_delete.php b/adm/cache_file_delete.php index 854923d4c..fd8738a76 100644 --- a/adm/cache_file_delete.php +++ b/adm/cache_file_delete.php @@ -1,52 +1,47 @@ -

    완료 메세지가 나오기 전에 프로그램의 실행을 중지하지 마십시오.

    - 최신글 캐시디렉토리를 열지못했습니다.

    "; + echo '

    캐시디렉토리를 열지못했습니다.

    '; } $cnt=0; - echo "
      \n"; - while($file=readdir($dir)) { - if ($file=='.' || $file=='..') continue; + echo '
        '.PHP_EOL; - $cache_file = G4_DATA_PATH.'/cache/'.$file; + $files = glob(G4_DATA_PATH.'/cache/latest-*'); + if (is_array($files)) { + foreach ($files as $cache_file) { + $cnt++; + unlink($cache_file); + echo '
      • '.$cache_file.'
      • '.PHP_EOL; - if (!$atime=@fileatime($cache_file)) - continue; + flush(); - $cnt++; - $return = unlink($cache_file); - //echo "\n"; - echo "
      • {$cache_file}
      • \n"; - - flush(); - - if ($cnt%10==0) - //echo "\n"; - echo "\n"; + if ($cnt%10==0) + echo PHP_EOL; + } } - echo "
      • 완료됨
      • \n
      \n"; - //echo "\n"; - echo "

      최신글 캐시파일 {$cnt}건 삭제가 완료됐습니다.
      프로그램의 실행을 끝마치셔도 좋습니다.

      \n"; + + echo '
    • 완료됨
    '.PHP_EOL; + echo '

    최신글 캐시파일 '.$cnt.'건 삭제가 완료됐습니다.
    프로그램의 실행을 끝마치셔도 좋습니다.

    '.PHP_EOL; ?>
    \ No newline at end of file From 880766aa8e081f57ef98524b050818bad8a414af Mon Sep 17 00:00:00 2001 From: gnuboard Date: Thu, 4 Apr 2013 18:46:15 +0900 Subject: [PATCH 19/63] =?UTF-8?q?=EB=94=B0=EC=98=B4=ED=91=9C=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.php b/config.php index 6373a15e1..8c27e698e 100644 --- a/config.php +++ b/config.php @@ -95,7 +95,7 @@ define('G4_USE_CACHE', true); // 최신글등에 cache 기능 사용 여부 // 6시간이 빠른 경우 time() + (3600 * 6); // 6시간이 느린 경우 time() - (3600 * 6); define('G4_SERVER_TIME', time()); -define('G4_TIME_YMDHIS', date("Y-m-d H:i:s", G4_SERVER_TIME)); +define('G4_TIME_YMDHIS', date('Y-m-d H:i:s', G4_SERVER_TIME)); define('G4_TIME_YMD', substr(G4_TIME_YMDHIS, 0, 10)); define('G4_TIME_HIS', substr(G4_TIME_YMDHIS, 11, 8)); From 5fce104a839c3dd739decae7c523441a06951919 Mon Sep 17 00:00:00 2001 From: whitedot Date: Thu, 4 Apr 2013 19:01:01 +0900 Subject: [PATCH 20/63] =?UTF-8?q?skin/board/Rankiss=20=EC=8A=A4=ED=82=A8?= =?UTF-8?q?=20=ED=8F=AC=ED=95=A8=EB=90=98=EC=A7=80=20=EC=95=8A=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=ED=95=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 08de4d7e1..afaf71ac6 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ test sirgle sr_* google* +Rankiss* From 31d4a89191cf4913951f767ebf16c547da065aaa Mon Sep 17 00:00:00 2001 From: whitedot Date: Thu, 4 Apr 2013 19:01:36 +0900 Subject: [PATCH 21/63] =?UTF-8?q?=ED=95=9C=EC=8B=9C=EA=B0=84=20=EC=9D=B4?= =?UTF-8?q?=EB=82=B4=EC=97=90=20=EC=83=9D=EC=84=B1,=20=EC=A0=91=EA=B7=BC?= =?UTF-8?q?=EB=90=9C=20=EC=BA=A1=EC=B1=A0=EB=8A=94=20=EC=82=AD=EC=A0=9C?= =?UTF-8?q?=EB=90=98=EC=A7=80=20=EC=95=8A=EB=8F=84=EB=A1=9D=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- adm/gcaptcha_file_delete.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/adm/gcaptcha_file_delete.php b/adm/gcaptcha_file_delete.php index 35d193cc8..8c6db74a0 100644 --- a/adm/gcaptcha_file_delete.php +++ b/adm/gcaptcha_file_delete.php @@ -25,9 +25,9 @@ include_once('./admin.head.php'); $files = glob(G4_DATA_PATH.'/cache/gcaptcha-*'); if (is_array($files)) { - $before_time = date('ymdHis', G4_SERVER_TIME - 3600); // 한시간전 + $before_time = G4_SERVER_TIME - 3600; // 한시간전 foreach ($files as $gcaptcha_file) { - $access_time = date('ymdHis', fileatime($gcaptcha_file)); // 파일접근시간 + $access_time = fileatime($gcaptcha_file); // 파일접근시간 if ($access_time > $before_time) continue; From ee349774c4f72602c81112c4fa0263812dbf112b Mon Sep 17 00:00:00 2001 From: whitedot Date: Thu, 4 Apr 2013 19:06:40 +0900 Subject: [PATCH 22/63] . --- .gitignore | 1 + config.php | 2 +- lib/thumb.lib.php | 1284 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 1286 insertions(+), 1 deletion(-) create mode 100644 lib/thumb.lib.php diff --git a/.gitignore b/.gitignore index afaf71ac6..969aa26c9 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ sirgle sr_* google* Rankiss* +thumb.lib.php diff --git a/config.php b/config.php index 6373a15e1..8c27e698e 100644 --- a/config.php +++ b/config.php @@ -95,7 +95,7 @@ define('G4_USE_CACHE', true); // 최신글등에 cache 기능 사용 여부 // 6시간이 빠른 경우 time() + (3600 * 6); // 6시간이 느린 경우 time() - (3600 * 6); define('G4_SERVER_TIME', time()); -define('G4_TIME_YMDHIS', date("Y-m-d H:i:s", G4_SERVER_TIME)); +define('G4_TIME_YMDHIS', date('Y-m-d H:i:s', G4_SERVER_TIME)); define('G4_TIME_YMD', substr(G4_TIME_YMDHIS, 0, 10)); define('G4_TIME_HIS', substr(G4_TIME_YMDHIS, 11, 8)); diff --git a/lib/thumb.lib.php b/lib/thumb.lib.php new file mode 100644 index 000000000..f81b6c01f --- /dev/null +++ b/lib/thumb.lib.php @@ -0,0 +1,1284 @@ + ̹ũ + - $height > ̹ũ : ̹ ũ + - else + - $is_crop : ũ + - else : + - else + $ratio $height ؼ, + - $height > $tmp_y : (̰ մϴ) <-- ̺κп ̸ ߰ б⸦ cropڴ ǰߵ ־ + - else : ̹ ̸ crop + - $height (crop ʽϴ) + - $width ̹ ũ⺸ ũ : ̹ ũ + - else : + +$width (̷θ ϴ ) + - $height ̹ ũ⺸ ũ : ̹ ũ + - else + - $is_crop : crop + - else : +*/ +function thumbnail($file_name, $width=0, $height=0, $is_create=false, $is_crop=2, $quality=90, $small_thumb=1, $watermark="", $filter="", $noimg="", $thumb_type="") +{ + //if (!$file_name) + // return; + + // memory limit + @ini_set("memory_limit", -1); + + // 丮 + $real_dir = dirname($_SERVER['DOCUMENT_ROOT'] . "/nothing"); + $dir = dirname(file_path($file_name)); + $file = basename($file_name); + + $thumb_dir = $dir . "/thumb"; + + // 丮 + $thumb_path = $thumb_dir . "/" . $width . "x" . $height . "_" . $quality; + + if (!file_exists($thumb_dir)) { + @mkdir($thumb_dir, 0707); + @chmod($thumb_dir, 0707); + } + + if (!file_exists($thumb_path)) { + @mkdir($thumb_path, 0707); + @chmod($thumb_path, 0707); + } + + $source_file = $dir . "/" . $file; + + $size = @getimagesize($source_file); + $size_org = $size; + + // animated gif ؼ ڸƮ Ǯּ. Ʒڵ cpu disk access ũ ֽϴ + //if ($size[2] == IMG_GIF && is_ani_gif($file_name)) return; + + // ̹ + if (!$size[0]) { + + // $nomimg ̹ + if ($noimg) + return $noimg; + else + { + if (!$width) + $width = 30; + if (!$height) + $height = $width; + $thumb_file = $thumb_dir . "/" . $width . "x" . $height . "_noimg.gif"; + + if (@file_exists($thumb_file)) + ; + else + { + $target = imagecreate($width, $height); + + $bg_color = imagecolorallocate($target, 250, 250, 250); + $font_color = imagecolorallocate($target, 0, 0, 0); + $font_size = 12; + $ttf = "$real_dir/img/han.ttf"; + $text = "no image..."; + $size = imagettfbbox($font_size, 0, $ttf, $text); + $xsize = abs($size[0]) + abs($size[2])+($padding*2); + $ysize = abs($size[5]) + abs($size[1])+($padding*2); + $xloc = $width/2-$xsize/2; + $yloc = $height/2-$ysize/2; + imagefttext($target, $font_size, 0, $xloc, $yloc, $font_color, $ttf, $text); + //imagecopy($target, $target, 0, 0, 0, 0, $width, $height); + imagegif($target, $thumb_file, $quality); + @chmod($thumb_file, 0606); // Ͽ ϸ + } + return str_replace($real_dir, "", $thumb_file); + } + } + + $thumb_file = $thumb_path . "/" . $file; + + // 鼭 ҽϺ ¥ ֱ + if (@file_exists($thumb_file)) { + $thumb_time = @filemtime($thumb_file); + $source_time = @filemtime($source_file); + if ($is_create == false && $source_time < $thumb_time) { + return str_replace($real_dir, "", $thumb_file); + } + } + + // $width, $height ״ thumb + if (!$width && !$height) + $width = $size[0]; + + // ̹ 쿡 ϴ ɼ , ̹ size thumb ʴ´ (̰ pass~!) + if (!$small_thumb && $width >= $size[0] && $height && $height >= $size[1]) + return str_replace($real_dir, "", $source_file); + + $is_imagecopyresampled = false; + $is_large = false; + + if ($size[2] == 1) + $source = imagecreatefromgif($source_file); + else if ($size[2] == 2) { + // php.net - As of PHP 5.1.3, if you are dealing with corrupted JPEG images + // you should set the 'gd.jpeg_ignore_warning' directive to 1 to ignore warnings that could mess up your code. + // ϴµ, ޸ ׳ ϴ. ƹ ̳ . Ȳ + @ini_set('gd.jpeg_ignore_warning', 1); + + // $msize=php Ҵ޸, $isize=24bit plain ʿ ޸ + // ޸𸮰 ϸ ̰ ׳ Ƿ, . + $msize = memory_get_usage(); + $isize = $size['bits'] / 8 * $size[0] * $size[1]; + if ($isize > $msize) + return $file_name; + + $source = imagecreatefromjpeg($source_file); + // jpeg , ͸ũ ? - ͸ũ ׳ (󵵰 ϱ) + if (!$source) { + if (trim($watermark) && count($watermark) > 0) + ; + else + return $file_name; + } + } + else if ($size[2] == 3) + $source = imagecreatefrompng($source_file); + else if ($size[2] == 6) + { + // bmp gif + $source = ImageCreateFromBMP($source_file); + $size[2] = 1; + } + else if ($size[2] == 5) { + // psd + $source = imagecreatefrompsd($source_file); + $size[2] = 1; + } else { + return str_replace($real_dir, "", $source_file); + } + + // Ȯ + if ($small_thumb == 2) { + $size0 = $size[0]; + $size1 = $size[1]; + + if ($width) { + $size[0] = $width; + $size[1] = (int) $width * ($size1/$size0); + } else if ($height) + { + $size[1] = $height; + $size[0] = (int) $height * ($size0/$size1); + } + else + return str_replace($real_dir, "", $source_file); + + + /* + if ($height && $height > $size[1]) { + $size[1] = $height; + $size[0] = (int) $width*($size[0]/$size[1]); + } + */ + + $target = imagecreatetruecolor($size[0], $size[1]); + imagecopyresampled($target, $source, 0, 0, 0, 0, $size[0], $size[1], $size0, $size1); + $source = $target; + unset($target); + } + + if ($width) { + $x = $width; + if ($height) { + + if ($width > $size[0]) { // $width ̹ Ŭ ($width resize ʿ) + if ($height > $size[1]) { + $x = $size[0]; + $tmp_y = $size[1]; + $target = imagecreatetruecolor($x, $tmp_y); + imagecopyresampled($target, $source, 0, 0, 0, 0, $x, $tmp_y, $size[0], $size[1]); + } else { + if ($is_crop) { // ġ ̸ ߶ մϴ + $x = $size[0]; + $y = $size[1]; + $tmp_y = $height; + $target = imagecreatetruecolor($x, $tmp_y); + $tmp_target = imagecreatetruecolor($x, $tmp_y); + imagecopyresampled($tmp_target, $source, 0, 0, 0, 0, $x, $y, $size[0], $size[1]); + imagecopy($target, $tmp_target, 0, 0, 0, 0, $x, $tmp_y); + } else { + $y = $height; + $rate = $y / $size[1]; + $x = (int)($size[0] * $rate); + $target = imagecreatetruecolor($x, $y); + imagecopyresampled($target, $source, 0, 0, 0, 0, $x, $y, $size[0], $size[1]); + } + } + } else { // $width ̹ ( resize ʿ) + $y = $height; + $rate = $x / $size[0]; + $tmp_y = (int)($size[1] * $rate); + if ($height > $tmp_y) { + if ($height < $size[1]) { + if ($is_crop) { // ̰ Ƿ ̹ crop + $rate = $y / $size[1]; + $tmp_x = (int)($size[0] * $rate); + $target = imagecreatetruecolor($x, $y); + $tmp_target = imagecreatetruecolor($tmp_x, $y); + imagecopyresampled($tmp_target, $source, 0, 0, 0, 0, $tmp_x, $y, $size[0], $size[1]); + // copyϴ ġ ̹ ߽ ǰ + $src_x = (int)(($tmp_x - $x)/2); + imagecopy($target, $tmp_target, 0, 0, $src_x, 0, $x, $y); + } else { + $target = imagecreatetruecolor($x, $tmp_y); + imagecopyresampled($target, $source, 0, 0, 0, 0, $x, $tmp_y, $size[0], $size[1]); + } + } else { + // ̰ ̺ Ƿ ̹ crop + if ($is_crop == 1) { // + $tmp_x = (int)$size[0]; + $tmp_y = (int)$size[1]; + $target = imagecreatetruecolor($x, $tmp_y); + imagecopyresampled($target, $source, 0, 0, 0, 0, $x, $tmp_y, $x, $tmp_y); + } else if ($is_crop == 2) { // ߰ + $tmp_x = (int)($size[0]/2) - (int)($x/2); + $tmp_y = (int)$size[1]; + $target = imagecreatetruecolor($x, $tmp_y); + imagecopyresampled($target, $source, 0, 0, $tmp_x, 0, $x, $tmp_y, $x, $tmp_y); + } else { // + $target = imagecreatetruecolor($x, $tmp_y); + imagecopyresampled($target, $source, 0, 0, 0, 0, $x, $tmp_y, $size[0], $size[1]); + } + } + } else { + if ($is_crop) { + $target = imagecreatetruecolor($x, $y); + $tmp_target = imagecreatetruecolor($x, $tmp_y); + imagecopyresampled($tmp_target, $source, 0, 0, 0, 0, $x, $tmp_y, $size[0], $size[1]); + imagecopy($target, $tmp_target, 0, 0, 0, 0, $x, $y); + } else { + $rate = $y / $size[1]; + $tmp_x = (int)($size[0] * $rate); + $target = imagecreatetruecolor($tmp_x, $y); + imagecopyresampled($target, $source, 0, 0, 0, 0, $tmp_x, $y, $size[0], $size[1]); + } + } + } + } + else + { // $height (crop ش ? ^^) + if ($width >= $size[0]) { // $width ũ, ̹ 濡 ϴ (Ȯ ) + $x = $size[0]; + $tmp_y = $size[1]; + } else { + $rate = $x / $size[0]; + $tmp_y = (int)($size[1] * $rate); + } + + $target = imagecreatetruecolor($x, $tmp_y); + imagecopyresampled($target, $source, 0, 0, 0, 0, $x, $tmp_y, $size[0], $size[1]); + } + } + else // $width $height ִ + { + if ($height > $size[1]) { // ̺ $height ũ, ̹ ̷ ϴ (Ȯ ) + $y = $size[1]; + $tmp_x = $size[0]; + $target = imagecreatetruecolor($tmp_x, $y); + imagecopyresampled($target, $source, 0, 0, 0, 0, $tmp_x, $y, $size[0], $size[1]); + } else { + $x = $size[0]; + $y = $height; + $tmp_y = $size[1]; + if ($is_crop) { + $target = imagecreatetruecolor($x, $y); + $tmp_target = imagecreatetruecolor($x, $tmp_y); + imagecopyresampled($tmp_target, $source, 0, 0, 0, 0, $x, $tmp_y, $size[0], $size[1]); + imagecopy($target, $tmp_target, 0, 0, 0, 0, $x, $tmp_y); + } else { + $rate = $y / $size[1]; + $tmp_x = (int)($size[0] * $rate); + $target = imagecreatetruecolor($tmp_x, $y); + imagecopyresampled($target, $source, 0, 0, 0, 0, $tmp_x, $y, $size[0], $size[1]); + } + } + } + + // ̹ Ƽ + ob_start(); + if ($size[2] == 1) + imagegif($target, "", $quality); + else if ($size[2] == 2) + imagejpeg($target, "", $quality); + else if ($size[2] == 3) + imagepng($target, "", round(10 - ($quality / 10))); //imagepng Ƽ 0~9 մϴ (Lusia). 0(no compression) Դϴ + $tmp_image_str = ob_get_contents(); + ob_end_clean(); + $target = imagecreatefromstring($tmp_image_str); + unset($tmp_image_str); + + // watermark ̹ ־ֱ + if (trim($watermark) && count($watermark) > 0) { + foreach ($watermark as $w1) { + // ̸ 丮 + $w1_file = $w1['filename']; + if (!$w1_file) continue; + + $w_dir = dirname(file_path($w1_file)); + $w_file = basename($w1_file); + + $w1_file = $w_dir . "/" . $w_file; + + // ͸ũ ͸ũ ʽϴ + if (!file_exists($w1_file)) + break; + + // ͸ũ ̹ width, height + $sizew = getimagesize($w1_file); + $wx = $sizew[0]; + $wy = $sizew[1]; + // watermark ̹ о̱ + if ($sizew[2] == 1) + $w1_source = imagecreatefromgif($w1_file); + else if ($sizew[2] == 2) + $w1_source = imagecreatefromjpeg($w1_file); + else if ($sizew[2] == 3) + $w1_source = imagecreatefrompng($w1_file); + + // $target ̹ width, height + $sx = imagesx($target); + $sy = imagesy($target); + + switch ($w1[location]) { + case "center" : + $tx = (int)($sx/2 - $wx/2) + $w1[x]; + $ty = (int)($sy/2 - $wy/2) + $w1[y]; + break; + case "top" : + $tx = (int)($sx/2 - $wx/2) + $w1[x]; + $ty = $w1[y]; + break; + case "top_left" : + $tx = $w1[x]; + $ty = $w1[y]; + break; + case "top_right" : + $tx = $sx - $wx - $w1[x]; + $ty = $w1[y]; + break; + case "bottom" : + $tx = (int)($sx/2 - $wx/2) + $w1[x]; + $ty = $sy - $w1[y] - $wy; + break; + case "bottom_left" : + $tx = $w1[x]; + $ty = $sy - $w1[y] - $wy; + break; + case "bottom_right" : + default : + $tx = $sx - $w1[x] - $wx; + $ty = $sy - $w1[y] - $wy; + } + imagecopyresampled($target, $w1_source, $tx, $ty, 0, 0, $wx, $wy, $wx, $wy); + } + } + + // php imagefilter + //if ($filter and $size[2] == 2) { //$size[2] == 2 , jpg + if ($filter) { + $filter_type = $filter[type]; + switch($filter_type) { + case IMG_FILTER_COLORIZE : imagefilter($target, $filter_type, $filter[arg1], $filter[arg2], $filter[arg3], $filter[arg4]); + break; + case IMG_FILTER_PIXELATE : imagefilter($target, $filter_type, $filter[arg1], $filter[arg2]); + break; + case IMG_FILTER_BRIGHTNESS : + case IMG_FILTER_CONTRAST : + case IMG_FILTER_SMOOTH : imagefilter($target, $filter_type, $filter[arg1]); + break; + case IMG_FILTER_NEGATE : + case IMG_FILTER_GRAYSCALE: + case IMG_FILTER_EDGEDETECT: + case IMG_FILTER_EMBOSS : + case IMG_FILTER_GAUSSIAN_BLUR : + case IMG_FILTER_SELECTIVE_BLUR: + case IMG_FILTER_MEAN_REMOVAL: imagefilter($target, $filter_type); + break; + case 99: UnsharpMask4($target, $filter[arg1], $filter[arg2], $filter[arg3]); + break; + default : ; // Ÿ Ʋ ƹ͵ մϴ + } + } + + $quality=100; + if ($size[2] == 1 || $thumb_type=="gif") + imagegif($target, $thumb_file, 100); // gif + else if ($size[2] == 2 || $thumb_type=="jpg") + imagejpeg($target, $thumb_file, 100); // jpeg + else if ($size[2] == 3 || $thumb_type=="png") { + // Turn off alpha blending and set alpha flag + imagealphablending($target, false); + imagesavealpha($target, true); + + imagepng($target, $thumb_file, 0); //imagepng Ƽ 0~9 մϴ (Lusia). 0(no compression) Դϴ + } + else + imagegif($target, $thumb_file, 100); + + @chmod($thumb_file, 0606); // Ͽ ϸ + + // ޸𸮸 νݴϴ - http://kr2.php.net/manual/kr/function.imagedestroy.php + if ($target) + imagedestroy($target); + if ($source) + imagedestroy($source); + if ($tmp_target) + imagedestroy($tmp_target); + + return str_replace($real_dir, "", $thumb_file); +} + +// php imagefilter for PHP4 - http://mgccl.com/2007/03/02/imagefilter-function-for-php-user-without-bundled-gd +// +//include this file whenever you have to use imageconvolution... +//you can use in your project, but keep the comment below :) +//great for any image manipulation library +//Made by Chao Xu(Mgccl) 3/1/07 +//www.webdevlogs.com +//V 1.0 +if(!function_exists('imagefilter')){ + function imagefilter($source, $var, $arg1 = null, $arg2 = null, $arg3 = null){ + #define('IMAGE_FILTER_NEGATE',0); + #define('IMAGE_FILTER_GRAYSCALE',0); + #define('IMAGE_FILTER_BRIGHTNESS',2); + #define('IMAGE_FILTER_CONTRAST',3); + #define('IMAGE_FILTER_COLORIZE',4); + #define('IMAGE_FILTER_EDGEDETECT',5); + #define('IMAGE_FILTER_EMBOSS',6); + #define('IMAGE_FILTER_GAUSSIAN_BLUR',7); + #define('IMAGE_FILTER_SELECTIVE_BLUR',8); + #define('IMAGE_FILTER_MEAN_REMOVAL',9); + #define('IMAGE_FILTER_SMOOTH',10); + $max_y = imagesy($source); + $max_x = imagesx($source); + switch ($var){ + case 0: + $y = 0; + while($y<$max_y) { + $x = 0; + while($x<$max_x){ + $rgb = imagecolorat($source,$x,$y); + $r = 255 - (($rgb >> 16) & 0xFF); + $g = 255 - (($rgb >> 8) & 0xFF); + $b = 255 - ($rgb & 0xFF); + $a = $rgb >> 24; + $new_pxl = imagecolorallocatealpha($source, $r, $g, $b, $a); + if ($new_pxl == false){ + $new_pxl = imagecolorclosestalpha($source, $r, $g, $b, $a); + } + imagesetpixel($source,$x,$y,$new_pxl); + ++$x; + } + ++$y; + } + return true; + break; + case 1: + $y = 0; + while($y<$max_y) { + $x = 0; + while($x<$max_x){ + $rgb = imagecolorat($source,$x,$y); + $a = $rgb >> 24; + $r = ((($rgb >> 16) & 0xFF)*0.299)+((($rgb >> 8) & 0xFF)*0.587)+(($rgb & 0xFF)*0.114); + $new_pxl = imagecolorallocatealpha($source, $r, $r, $r, $a); + if ($new_pxl == false){ + $new_pxl = imagecolorclosestalpha($source, $r, $r, $r, $a); + } + imagesetpixel($source,$x,$y,$new_pxl); + ++$x; + } + ++$y; + } + return true; + break; + case 2: + $y = 0; + while($y<$max_y) { + $x = 0; + while($x<$max_x){ + $rgb = imagecolorat($source,$x,$y); + $r = (($rgb >> 16) & 0xFF) + $arg1; + $g = (($rgb >> 8) & 0xFF) + $arg1; + $b = ($rgb & 0xFF) + $arg1; + $a = $rgb >> 24; + $r = ($r > 255)? 255 : (($r < 0)? 0:$r); + $g = ($g > 255)? 255 : (($g < 0)? 0:$g); + $b = ($b > 255)? 255 : (($b < 0)? 0:$b); + $new_pxl = imagecolorallocatealpha($source, $r, $g, $b, $a); + if ($new_pxl == false){ + $new_pxl = imagecolorclosestalpha($source, $r, $g, $b, $a); + } + imagesetpixel($source,$x,$y,$new_pxl); + ++$x; + } + ++$y; + } + return true; + break; + case 3: + $contrast = pow((100-$arg1)/100,2); + $y = 0; + while($y<$max_y) { + $x = 0; + while($x<$max_x){ + $rgb = imagecolorat($source,$x,$y); + $a = $rgb >> 24; + $r = (((((($rgb >> 16) & 0xFF)/255)-0.5)*$contrast)+0.5)*255; + $g = (((((($rgb >> 8) & 0xFF)/255)-0.5)*$contrast)+0.5)*255; + $b = ((((($rgb & 0xFF)/255)-0.5)*$contrast)+0.5)*255; + $r = ($r > 255)? 255 : (($r < 0)? 0:$r); + $g = ($g > 255)? 255 : (($g < 0)? 0:$g); + $b = ($b > 255)? 255 : (($b < 0)? 0:$b); + $new_pxl = imagecolorallocatealpha($source, $r, $g, $b, $a); + if ($new_pxl == false){ + $new_pxl = imagecolorclosestalpha($source, $r, $g, $b, $a); + } + imagesetpixel($source,$x,$y,$new_pxl); + ++$x; + } + ++$y; + } + return true; + break; + case 4: + $x = 0; + while($x<$max_x){ + $y = 0; + while($y<$max_y){ + $rgb = imagecolorat($source, $x, $y); + $r = (($rgb >> 16) & 0xFF) + $arg1; + $g = (($rgb >> 8) & 0xFF) + $arg2; + $b = ($rgb & 0xFF) + $arg3; + $a = $rgb >> 24; + $r = ($r > 255)? 255 : (($r < 0)? 0:$r); + $g = ($g > 255)? 255 : (($g < 0)? 0:$g); + $b = ($b > 255)? 255 : (($b < 0)? 0:$b); + $new_pxl = imagecolorallocatealpha($source, $r, $g, $b, $a); + if ($new_pxl == false){ + $new_pxl = imagecolorclosestalpha($source, $r, $g, $b, $a); + } + imagesetpixel($source,$x,$y,$new_pxl); + ++$y; + } + ++$x; + } + return true; + break; + case 5: + return imageconvolution($source, array(array(-1,0,-1), array(0,4,0), array(-1,0,-1)), 1, 127); + break; + case 6: + return imageconvolution($source, array(array(1.5, 0, 0), array(0, 0, 0), array(0, 0, -1.5)), 1, 127); + break; + case 7: + return imageconvolution($source, array(array(1, 2, 1), array(2, 4, 2), array(1, 2, 1)), 16, 0); + break; + case 8: + for($y = 0; $y<$max_y; $y++) { + for ($x = 0; $x<$max_x; $x++) { + $flt_r_sum = $flt_g_sum = $flt_b_sum = 0; + $cpxl = imagecolorat($source, $x, $y); + for ($j=0; $j<3; $j++) { + for ($i=0; $i<3; $i++) { + if (($j == 1) && ($i == 1)) { + $flt_r[1][1] = $flt_g[1][1] = $flt_b[1][1] = 0.5; + } else { + $pxl = imagecolorat($source, $x-(3>>1)+$i, $y-(3>>1)+$j); + + $new_a = $pxl >> 24; + //$r = (($pxl >> 16) & 0xFF); + //$g = (($pxl >> 8) & 0xFF); + //$b = ($pxl & 0xFF); + $new_r = abs((($cpxl >> 16) & 0xFF) - (($pxl >> 16) & 0xFF)); + if ($new_r != 0) { + $flt_r[$j][$i] = 1/$new_r; + } else { + $flt_r[$j][$i] = 1; + } + + $new_g = abs((($cpxl >> 8) & 0xFF) - (($pxl >> 8) & 0xFF)); + if ($new_g != 0) { + $flt_g[$j][$i] = 1/$new_g; + } else { + $flt_g[$j][$i] = 1; + } + + $new_b = abs(($cpxl & 0xFF) - ($pxl & 0xFF)); + if ($new_b != 0) { + $flt_b[$j][$i] = 1/$new_b; + } else { + $flt_b[$j][$i] = 1; + } + } + + $flt_r_sum += $flt_r[$j][$i]; + $flt_g_sum += $flt_g[$j][$i]; + $flt_b_sum += $flt_b[$j][$i]; + } + } + + for ($j=0; $j<3; $j++) { + for ($i=0; $i<3; $i++) { + if ($flt_r_sum != 0) { + $flt_r[$j][$i] /= $flt_r_sum; + } + if ($flt_g_sum != 0) { + $flt_g[$j][$i] /= $flt_g_sum; + } + if ($flt_b_sum != 0) { + $flt_b[$j][$i] /= $flt_b_sum; + } + } + } + + $new_r = $new_g = $new_b = 0; + + for ($j=0; $j<3; $j++) { + for ($i=0; $i<3; $i++) { + $pxl = imagecolorat($source, $x-(3>>1)+$i, $y-(3>>1)+$j); + $new_r += (($pxl >> 16) & 0xFF) * $flt_r[$j][$i]; + $new_g += (($pxl >> 8) & 0xFF) * $flt_g[$j][$i]; + $new_b += ($pxl & 0xFF) * $flt_b[$j][$i]; + } + } + + $new_r = ($new_r > 255)? 255 : (($new_r < 0)? 0:$new_r); + $new_g = ($new_g > 255)? 255 : (($new_g < 0)? 0:$new_g); + $new_b = ($new_b > 255)? 255 : (($new_b < 0)? 0:$new_b); + $new_pxl = ImageColorAllocateAlpha($source, (int)$new_r, (int)$new_g, (int)$new_b, $new_a); + if ($new_pxl == false) { + $new_pxl = ImageColorClosestAlpha($source, (int)$new_r, (int)$new_g, (int)$new_b, $new_a); + } + imagesetpixel($source,$x,$y,$new_pxl); + } + } + return true; + break; + case 9: + return imageconvolution($source, array(array(-1,-1,-1),array(-1,9,-1),array(-1,-1,-1)), 1, 0); + break; + case 10: + return imageconvolution($source, array(array(1,1,1),array(1,$arg1,1),array(1,1,1)), $arg1+8, 0); + break; + } + } +} + +if(!function_exists('file_path')){ +// θ ɴϴ (Ҵ, /lib/common.lib.php ǵ Լ) +function file_path($path) { + + $dir = dirname($path); + $file = basename($path); + + if (substr($dir,0,1) == "/") { + $real_dir = dirname($_SERVER['DOCUMENT_ROOT'] . "/nothing"); + $dir = $real_dir . $dir; + } + + return $dir . "/" . $file; +} +} + +//////////////////////////////////////////////////////////////////////////////////////////////// +//// +//// Unsharp Mask for PHP - version 2.1.1 +//// +//// Unsharp mask algorithm by Torstein Hnsi 2003-07. +//// thoensi_at_netcom_dot_no. +//// Please leave this notice. +//// +//// http://vikjavev.no/computing/ump.php +//// +/////////////////////////////////////////////////////////////////////////////////////////////// +if(!function_exists('UnsharpMask4')){ +function UnsharpMask4($img, $amount, $radius, $threshold) +{ + + // $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); break; } + $w = imagesx($img); $h = imagesy($img); + $imgCanvas = $img; + $imgCanvas2 = $img; + $imgBlur = imagecreatetruecolor($w, $h); + + // Gaussian blur matrix: + // 1 2 1 + // 2 4 2 + // 1 2 1 + + // 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, $imgCanvas, 0, 0, 1, 1, $w - 1, $h - 1); // up left + imagecopymerge ($imgBlur, $imgCanvas, 1, 1, 0, 0, $w, $h, 50); // down right + imagecopymerge ($imgBlur, $imgCanvas, 0, 1, 1, 0, $w - 1, $h, 33.33333); // down left + imagecopymerge ($imgBlur, $imgCanvas, 1, 0, 0, 1, $w, $h - 1, 25); // up right + imagecopymerge ($imgBlur, $imgCanvas, 0, 0, 1, 0, $w - 1, $h, 33.33333); // left + imagecopymerge ($imgBlur, $imgCanvas, 1, 0, 0, 0, $w, $h, 25); // right + imagecopymerge ($imgBlur, $imgCanvas, 0, 0, 0, 1, $w, $h - 1, 20 ); // up + imagecopymerge ($imgBlur, $imgCanvas, 0, 1, 0, 0, $w, $h, 16.666667); // down + imagecopymerge ($imgBlur, $imgCanvas, 0, 0, 0, 0, $w, $h, 50); // center + } + $imgCanvas = $imgBlur; + + // Calculate the difference between the blurred pixels and the original + // and set the pixels + for ($x = 0; $x < $w; $x++) + { // each row + for ($y = 0; $y < $h; $y++) + { // each pixel + $rgbOrig = ImageColorAt($imgCanvas2, $x, $y); + $rOrig = (($rgbOrig >> 16) & 0xFF); + $gOrig = (($rgbOrig >> 8) & 0xFF); + $bOrig = ($rgbOrig & 0xFF); + $rgbBlur = ImageColorAt($imgCanvas, $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); + } + } + } + return $img; +} +} + +/*********************************************/ +/* Fonction: ImageCreateFromBMP */ +/* Author: DHKold */ +/* Contact: admin@dhkold.com */ +/* Date: The 15th of June 2005 */ +/* Version: 2.0B */ +/*********************************************/ + +if(!function_exists('ImageCreateFromBMP')){ +function ImageCreateFromBMP($filename) +{ + //Ouverture du fichier en mode binaire + if (! $f1 = fopen($filename,"rb")) return FALSE; +echo $filename; + //1 : Chargement des ent?tes FICHIER + $FILE = unpack("vfile_type/Vfile_size/Vreserved/Vbitmap_offset", fread($f1,14)); + if ($FILE['file_type'] != 19778) return FALSE; + + //2 : Chargement des ent?tes BMP + $BMP = unpack('Vheader_size/Vwidth/Vheight/vplanes/vbits_per_pixel'. + '/Vcompression/Vsize_bitmap/Vhoriz_resolution'. + '/Vvert_resolution/Vcolors_used/Vcolors_important', fread($f1,40)); + $BMP['colors'] = pow(2,$BMP['bits_per_pixel']); + if ($BMP['size_bitmap'] == 0) $BMP['size_bitmap'] = $FILE['file_size'] - $FILE['bitmap_offset']; + $BMP['bytes_per_pixel'] = $BMP['bits_per_pixel']/8; + $BMP['bytes_per_pixel2'] = ceil($BMP['bytes_per_pixel']); + $BMP['decal'] = ($BMP['width']*$BMP['bytes_per_pixel']/4); + $BMP['decal'] -= floor($BMP['width']*$BMP['bytes_per_pixel']/4); + $BMP['decal'] = 4-(4*$BMP['decal']); + if ($BMP['decal'] == 4) $BMP['decal'] = 0; + + //3 : Chargement des couleurs de la palette + $PALETTE = array(); + if ($BMP['colors'] < 16777216) + { + $PALETTE = unpack('V'.$BMP['colors'], fread($f1,$BMP['colors']*4)); + } + + //4 : Cr?ation de l'image + $IMG = fread($f1,$BMP['size_bitmap']); + $VIDE = chr(0); + + $res = imagecreatetruecolor($BMP['width'],$BMP['height']); + $P = 0; + $Y = $BMP['height']-1; + while ($Y >= 0) + { + $X=0; + while ($X < $BMP['width']) + { + if ($BMP['bits_per_pixel'] == 24) + $COLOR = unpack("V",substr($IMG,$P,3).$VIDE); + elseif ($BMP['bits_per_pixel'] == 16) + { + $COLOR = unpack("v",substr($IMG,$P,2)); + $blue = (($COLOR[1] & 0x001f) << 3) + 7; + $green = (($COLOR[1] & 0x03e0) >> 2) + 7; + $red = (($COLOR[1] & 0xfc00) >> 7) + 7; + $COLOR[1] = $red * 65536 + $green * 256 + $blue; + } + elseif ($BMP['bits_per_pixel'] == 8) + { + $COLOR = unpack("n",$VIDE.substr($IMG,$P,1)); + $COLOR[1] = $PALETTE[$COLOR[1]+1]; + } + elseif ($BMP['bits_per_pixel'] == 4) + { + $COLOR = unpack("n",$VIDE.substr($IMG,floor($P),1)); + if (($P*2)%2 == 0) $COLOR[1] = ($COLOR[1] >> 4) ; else $COLOR[1] = ($COLOR[1] & 0x0F); + $COLOR[1] = $PALETTE[$COLOR[1]+1]; + } + elseif ($BMP['bits_per_pixel'] == 1) + { + $COLOR = unpack("n",$VIDE.substr($IMG,floor($P),1)); + if (($P*8)%8 == 0) $COLOR[1] = $COLOR[1] >>7; + elseif (($P*8)%8 == 1) $COLOR[1] = ($COLOR[1] & 0x40)>>6; + elseif (($P*8)%8 == 2) $COLOR[1] = ($COLOR[1] & 0x20)>>5; + elseif (($P*8)%8 == 3) $COLOR[1] = ($COLOR[1] & 0x10)>>4; + elseif (($P*8)%8 == 4) $COLOR[1] = ($COLOR[1] & 0x8)>>3; + elseif (($P*8)%8 == 5) $COLOR[1] = ($COLOR[1] & 0x4)>>2; + elseif (($P*8)%8 == 6) $COLOR[1] = ($COLOR[1] & 0x2)>>1; + elseif (($P*8)%8 == 7) $COLOR[1] = ($COLOR[1] & 0x1); + $COLOR[1] = $PALETTE[$COLOR[1]+1]; + } + else + return FALSE; + imagesetpixel($res,$X,$Y,$COLOR[1]); + $X++; + $P += $BMP['bytes_per_pixel']; + } + $Y--; + $P+=$BMP['decal']; + } + + //Fermeture du fichier + fclose($f1); + + return $res; +} +} + +// animated gif Ȯ +// http://kr2.php.net/imagecreatefromgif +/* +function is_ani_gif($filename) +{ + $filecontents=file_get_contents($filename); + + $str_loc=0; + $count=0; + while ($count < 2) # There is no point in continuing after we find a 2nd frame + { + + $where1=strpos($filecontents,"\x00\x21\xF9\x04",$str_loc); + if ($where1 === FALSE) + { + break; + } + else + { + $str_loc=$where1+1; + $where2=strpos($filecontents,"\x00\x2C",$str_loc); + if ($where2 === FALSE) + { + break; + } + else + { + if ($where1+8 == $where2) + { + $count++; + } + $str_loc=$where2+1; + } + } + } + + if ($count > 1) + { + return(true); + } + else + { + return(false); + } +} +*/ + +// psd - http://www.phpclasses.org/browse/file/17603.html + +/* This file is released under the GPL, any version you like +* PHP PSD reader class, v1.3 +* By Tim de Koning +* Kingsquare Information Services, 22 jan 2007 +* +* example use: +* ------------ +* +* +* More info, bugs or requests, contact info@kingsquare.nl +* +* Latest version and demo: http://www.kingsquare.nl/phppsdreader +* +* TODO +* ---- +* - read color values for "multichannel data" PSD files +* - find and implement (hunter)lab to RGB algorithm +* - fix 32 bit colors... has something to do with gamma and exposure available since CS2, but dunno how to read them... +*/ + + +class PhpPsdReader { + var $infoArray; + var $fp; + var $fileName; + var $tempFileName; + var $colorBytesLength; + + function PhpPsdReader($fileName) { + set_time_limit(0); + $this->infoArray = array(); + $this->fileName = $fileName; + $this->fp = fopen($this->fileName,'r'); + + if (fread($this->fp,4)=='8BPS') { + $this->infoArray['version id'] = $this->_getInteger(2); + fseek($this->fp,6,SEEK_CUR); // 6 bytes of 0's + $this->infoArray['channels'] = $this->_getInteger(2); + $this->infoArray['rows'] = $this->_getInteger(4); + $this->infoArray['columns'] = $this->_getInteger(4); + $this->infoArray['colorDepth'] = $this->_getInteger(2); + $this->infoArray['colorMode'] = $this->_getInteger(2); + + + /* COLOR MODE DATA SECTION */ //4bytes Length The length of the following color data. + $this->infoArray['colorModeDataSectionLength'] = $this->_getInteger(4); + fseek($this->fp,$this->infoArray['colorModeDataSectionLength'],SEEK_CUR); // ignore this snizzle + + /* IMAGE RESOURCES */ + $this->infoArray['imageResourcesSectionLength'] = $this->_getInteger(4); + fseek($this->fp,$this->infoArray['imageResourcesSectionLength'],SEEK_CUR); // ignore this snizzle + + /* LAYER AND MASK */ + $this->infoArray['layerMaskDataSectionLength'] = $this->_getInteger(4); + fseek($this->fp,$this->infoArray['layerMaskDataSectionLength'],SEEK_CUR); // ignore this snizzle + + + /* IMAGE DATA */ + $this->infoArray['compressionType'] = $this->_getInteger(2); + $this->infoArray['oneColorChannelPixelBytes'] = $this->infoArray['colorDepth']/8; + $this->colorBytesLength = $this->infoArray['rows']*$this->infoArray['columns']*$this->infoArray['oneColorChannelPixelBytes']; + + if ($this->infoArray['colorMode']==2) { + $this->infoArray['error'] = 'images with indexed colours are not supported yet'; + return false; + } + } else { + $this->infoArray['error'] = 'invalid or unsupported psd'; + return false; + } + } + + + function getImage() { + // decompress image data if required + switch($this->infoArray['compressionType']) { + // case 2:, case 3: zip not supported yet.. + case 1: + // packed bits + $this->infoArray['scanLinesByteCounts'] = array(); + for ($i=0; $i<($this->infoArray['rows']*$this->infoArray['channels']); $i++) $this->infoArray['scanLinesByteCounts'][] = $this->_getInteger(2); + $this->tempFileName = tempnam(realpath('/tmp'),'decompressedImageData'); + $tfp = fopen($this->tempFileName,'wb'); + foreach ($this->infoArray['scanLinesByteCounts'] as $scanLinesByteCount) { + fwrite($tfp,$this->_getPackedBitsDecoded(fread($this->fp,$scanLinesByteCount))); + } + fclose($tfp); + fclose($this->fp); + $this->fp = fopen($this->tempFileName,'r'); + default: + // continue with current file handle; + break; + } + + // let's write pixel by pixel.... + $image = imagecreatetruecolor($this->infoArray['columns'],$this->infoArray['rows']); + + for ($rowPointer = 0; ($rowPointer < $this->infoArray['rows']); $rowPointer++) { + for ($columnPointer = 0; ($columnPointer < $this->infoArray['columns']); $columnPointer++) { + /* The color mode of the file. Supported values are: Bitmap=0; + Grayscale=1; Indexed=2; RGB=3; CMYK=4; Multichannel=7; + Duotone=8; Lab=9. + */ + switch ($this->infoArray['colorMode']) { + case 2: // indexed... info should be able to extract from color mode data section. not implemented yet, so is grayscale + exit; + break; + case 0: + // bit by bit + if ($columnPointer == 0) $bitPointer = 0; + if ($bitPointer==0) $currentByteBits = str_pad(base_convert(bin2hex(fread($this->fp,1)), 16, 2),8,'0',STR_PAD_LEFT); + $r = $g = $b = (($currentByteBits[$bitPointer]=='1')?0:255); + $bitPointer++; + if ($bitPointer==8) $bitPointer = 0; + break; + + case 1: + case 8: // 8 is indexed with 1 color..., so grayscale + $r = $g = $b = $this->_getInteger($this->infoArray['oneColorChannelPixelBytes']); + break; + + case 4: // CMYK + $c = $this->_getInteger($this->infoArray['oneColorChannelPixelBytes']); + $currentPointerPos = ftell($this->fp); + fseek($this->fp,$this->colorBytesLength-1,SEEK_CUR); + $m = $this->_getInteger($this->infoArray['oneColorChannelPixelBytes']); + fseek($this->fp,$this->colorBytesLength-1,SEEK_CUR); + $y = $this->_getInteger($this->infoArray['oneColorChannelPixelBytes']); + fseek($this->fp,$this->colorBytesLength-1,SEEK_CUR); + $k = $this->_getInteger($this->infoArray['oneColorChannelPixelBytes']); + fseek($this->fp,$currentPointerPos); + $r = round(($c * $k) / (pow(2,$this->infoArray['colorDepth'])-1)); + $g = round(($m * $k) / (pow(2,$this->infoArray['colorDepth'])-1)); + $b = round(($y * $k) / (pow(2,$this->infoArray['colorDepth'])-1)); + + break; + + case 9: // hunter Lab + // i still need an understandable lab2rgb convert algorithm... if you have one, please let me know! + $l = $this->_getInteger($this->infoArray['oneColorChannelPixelBytes']); + $currentPointerPos = ftell($this->fp); + fseek($this->fp,$this->colorBytesLength-1,SEEK_CUR); + $a = $this->_getInteger($this->infoArray['oneColorChannelPixelBytes']); + fseek($this->fp,$this->colorBytesLength-1,SEEK_CUR); + $b = $this->_getInteger($this->infoArray['oneColorChannelPixelBytes']); + fseek($this->fp,$currentPointerPos); + + $r = $l; + $g = $a; + $b = $b; + + break; + default: + $r = $this->_getInteger($this->infoArray['oneColorChannelPixelBytes']); + $currentPointerPos = ftell($this->fp); + fseek($this->fp,$this->colorBytesLength-1,SEEK_CUR); + $g = $this->_getInteger($this->infoArray['oneColorChannelPixelBytes']); + fseek($this->fp,$this->colorBytesLength-1,SEEK_CUR); + $b = $this->_getInteger($this->infoArray['oneColorChannelPixelBytes']); + fseek($this->fp,$currentPointerPos); + break; + + } + + if (($this->infoArray['oneColorChannelPixelBytes']==2)) { + $r = $r >> 8; + $g = $g >> 8; + $b = $b >> 8; + } elseif (($this->infoArray['oneColorChannelPixelBytes']==4)) { + $r = $r >> 24; + $g = $g >> 24; + $b = $b >> 24; + } + + $pixelColor = imagecolorallocate($image,$r,$g,$b); + imagesetpixel($image,$columnPointer,$rowPointer,$pixelColor); + } + } + fclose($this->fp); + if (isset($this->tempFileName)) unlink($this->tempFileName); + return $image; + } + + /** + * + * PRIVATE FUNCTIONS + * + */ + + function _getPackedBitsDecoded($string) { + /* + The PackBits algorithm will precede a block of data with a one byte header n, where n is interpreted as follows: + n Meaning + 0 to 127 Copy the next n + 1 symbols verbatim + -127 to -1 Repeat the next symbol 1 - n times + -128 Do nothing + + Decoding: + Step 1. Read the block header (n). + Step 2. If the header is an EOF exit. + Step 3. If n is non-negative, copy the next n + 1 symbols to the output stream and go to step 1. + Step 4. If n is negative, write 1 - n copies of the next symbol to the output stream and go to step 1. + + */ + + $stringPointer = 0; + $returnString = ''; + + while (1) { + if (isset($string[$stringPointer])) $headerByteValue = $this->_unsignedToSigned(hexdec(bin2hex($string[$stringPointer])),1); + else return $returnString; + $stringPointer++; + + if ($headerByteValue >= 0) { + for ($i=0; $i <= $headerByteValue; $i++) { + $returnString .= $string[$stringPointer]; + $stringPointer++; + } + } else { + if ($headerByteValue != -128) { + $copyByte = $string[$stringPointer]; + $stringPointer++; + + for ($i=0; $i < (1-$headerByteValue); $i++) { + $returnString .= $copyByte; + } + } + } + } + } + + function _unsignedToSigned($int,$byteSize=1) { + switch($byteSize) { + case 1: + if ($int<128) return $int; + else return -256+$int; + break; + + case 2: + if ($int<32768) return $int; + else return -65536+$int; + + case 4: + if ($int<2147483648) return $int; + else return -4294967296+$int; + + default: + return $int; + } + } + + function _hexReverse($hex) { + $output = ''; + if (strlen($hex)%2) return false; + for ($pointer = strlen($hex);$pointer>=0;$pointer-=2) $output .= substr($hex,$pointer,2); + return $output; + } + + function _getInteger($byteCount=1) { + switch ($byteCount) { + case 4: + // for some strange reason this is still broken... + return @reset(unpack('N',fread($this->fp,4))); + break; + + case 2: + return @reset(unpack('n',fread($this->fp,2))); + break; + + default: + return hexdec($this->_hexReverse(bin2hex(fread($this->fp,$byteCount)))); + } + } +} + +/** + * Returns an image identifier representing the image obtained from the given filename, using only GD, returns an empty string on failure + * + * @param string $fileName + * @return image identifier + */ + +function imagecreatefrompsd($fileName) { + $psdReader = new PhpPsdReader($fileName); + if (isset($psdReader->infoArray['error'])) return ''; + else return $psdReader->getImage(); +} +?> From 42140c1408b8c6734b67a1751b75c4e5a99ca6a4 Mon Sep 17 00:00:00 2001 From: whitedot Date: Fri, 5 Apr 2013 13:35:35 +0900 Subject: [PATCH 23/63] =?UTF-8?q?=EC=82=AC=EC=9A=A9=EC=9E=90:=20=EC=9D=B5?= =?UTF-8?q?=EC=8A=A46.7=20=EC=97=90=EC=84=9C=20=EC=9E=90=EB=8F=99=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=EC=9D=B8=20label=20=EC=A4=84=20=EB=B0=94=EB=80=9C=20?= =?UTF-8?q?=ED=98=84=EC=83=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- skin/outlogin/basic/style.css | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/skin/outlogin/basic/style.css b/skin/outlogin/basic/style.css index 92b4e2b78..214de0913 100644 --- a/skin/outlogin/basic/style.css +++ b/skin/outlogin/basic/style.css @@ -14,11 +14,7 @@ #auto_login {} #auto_login_label {letter-spacing:-0.1em} #ol_submit {display:inline-block;width:60px;height:24px;border:0;background:#333;color:#fff;font-size:0.9em;font-weight:bold;vertical-align:top} -#ol_before ul {float:right;margin:7px 0 13px;zoom:1} -#ol_before ul:after {display:block;visibility:hidden;clear:both;content:""} -#ol_before li {float:left;margin-left:5px;padding-top:2px} -#ol_before #ol_auto {float:left;margin:4px 0 0;padding:0} -#ol_before a {letter-spacing:-0.1em} +#ol_before a {letter-spacing:-0.15em} #ol_svc {padding-top:8px;text-align:right} #ol_after {} From 194e2926aed151e51db524eb9e98a8961c242f50 Mon Sep 17 00:00:00 2001 From: gnuboard Date: Fri, 5 Apr 2013 14:22:12 +0900 Subject: [PATCH 24/63] =?UTF-8?q?thumb.lib.php=20=EC=82=AC=EC=9A=A9=20?= =?UTF-8?q?=EC=95=88=ED=95=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/thumb.lib.php | 1284 --------------------------------------------- 1 file changed, 1284 deletions(-) delete mode 100644 lib/thumb.lib.php diff --git a/lib/thumb.lib.php b/lib/thumb.lib.php deleted file mode 100644 index f81b6c01f..000000000 --- a/lib/thumb.lib.php +++ /dev/null @@ -1,1284 +0,0 @@ - ̹ũ - - $height > ̹ũ : ̹ ũ - - else - - $is_crop : ũ - - else : - - else - $ratio $height ؼ, - - $height > $tmp_y : (̰ մϴ) <-- ̺κп ̸ ߰ б⸦ cropڴ ǰߵ ־ - - else : ̹ ̸ crop - - $height (crop ʽϴ) - - $width ̹ ũ⺸ ũ : ̹ ũ - - else : - -$width (̷θ ϴ ) - - $height ̹ ũ⺸ ũ : ̹ ũ - - else - - $is_crop : crop - - else : -*/ -function thumbnail($file_name, $width=0, $height=0, $is_create=false, $is_crop=2, $quality=90, $small_thumb=1, $watermark="", $filter="", $noimg="", $thumb_type="") -{ - //if (!$file_name) - // return; - - // memory limit - @ini_set("memory_limit", -1); - - // 丮 - $real_dir = dirname($_SERVER['DOCUMENT_ROOT'] . "/nothing"); - $dir = dirname(file_path($file_name)); - $file = basename($file_name); - - $thumb_dir = $dir . "/thumb"; - - // 丮 - $thumb_path = $thumb_dir . "/" . $width . "x" . $height . "_" . $quality; - - if (!file_exists($thumb_dir)) { - @mkdir($thumb_dir, 0707); - @chmod($thumb_dir, 0707); - } - - if (!file_exists($thumb_path)) { - @mkdir($thumb_path, 0707); - @chmod($thumb_path, 0707); - } - - $source_file = $dir . "/" . $file; - - $size = @getimagesize($source_file); - $size_org = $size; - - // animated gif ؼ ڸƮ Ǯּ. Ʒڵ cpu disk access ũ ֽϴ - //if ($size[2] == IMG_GIF && is_ani_gif($file_name)) return; - - // ̹ - if (!$size[0]) { - - // $nomimg ̹ - if ($noimg) - return $noimg; - else - { - if (!$width) - $width = 30; - if (!$height) - $height = $width; - $thumb_file = $thumb_dir . "/" . $width . "x" . $height . "_noimg.gif"; - - if (@file_exists($thumb_file)) - ; - else - { - $target = imagecreate($width, $height); - - $bg_color = imagecolorallocate($target, 250, 250, 250); - $font_color = imagecolorallocate($target, 0, 0, 0); - $font_size = 12; - $ttf = "$real_dir/img/han.ttf"; - $text = "no image..."; - $size = imagettfbbox($font_size, 0, $ttf, $text); - $xsize = abs($size[0]) + abs($size[2])+($padding*2); - $ysize = abs($size[5]) + abs($size[1])+($padding*2); - $xloc = $width/2-$xsize/2; - $yloc = $height/2-$ysize/2; - imagefttext($target, $font_size, 0, $xloc, $yloc, $font_color, $ttf, $text); - //imagecopy($target, $target, 0, 0, 0, 0, $width, $height); - imagegif($target, $thumb_file, $quality); - @chmod($thumb_file, 0606); // Ͽ ϸ - } - return str_replace($real_dir, "", $thumb_file); - } - } - - $thumb_file = $thumb_path . "/" . $file; - - // 鼭 ҽϺ ¥ ֱ - if (@file_exists($thumb_file)) { - $thumb_time = @filemtime($thumb_file); - $source_time = @filemtime($source_file); - if ($is_create == false && $source_time < $thumb_time) { - return str_replace($real_dir, "", $thumb_file); - } - } - - // $width, $height ״ thumb - if (!$width && !$height) - $width = $size[0]; - - // ̹ 쿡 ϴ ɼ , ̹ size thumb ʴ´ (̰ pass~!) - if (!$small_thumb && $width >= $size[0] && $height && $height >= $size[1]) - return str_replace($real_dir, "", $source_file); - - $is_imagecopyresampled = false; - $is_large = false; - - if ($size[2] == 1) - $source = imagecreatefromgif($source_file); - else if ($size[2] == 2) { - // php.net - As of PHP 5.1.3, if you are dealing with corrupted JPEG images - // you should set the 'gd.jpeg_ignore_warning' directive to 1 to ignore warnings that could mess up your code. - // ϴµ, ޸ ׳ ϴ. ƹ ̳ . Ȳ - @ini_set('gd.jpeg_ignore_warning', 1); - - // $msize=php Ҵ޸, $isize=24bit plain ʿ ޸ - // ޸𸮰 ϸ ̰ ׳ Ƿ, . - $msize = memory_get_usage(); - $isize = $size['bits'] / 8 * $size[0] * $size[1]; - if ($isize > $msize) - return $file_name; - - $source = imagecreatefromjpeg($source_file); - // jpeg , ͸ũ ? - ͸ũ ׳ (󵵰 ϱ) - if (!$source) { - if (trim($watermark) && count($watermark) > 0) - ; - else - return $file_name; - } - } - else if ($size[2] == 3) - $source = imagecreatefrompng($source_file); - else if ($size[2] == 6) - { - // bmp gif - $source = ImageCreateFromBMP($source_file); - $size[2] = 1; - } - else if ($size[2] == 5) { - // psd - $source = imagecreatefrompsd($source_file); - $size[2] = 1; - } else { - return str_replace($real_dir, "", $source_file); - } - - // Ȯ - if ($small_thumb == 2) { - $size0 = $size[0]; - $size1 = $size[1]; - - if ($width) { - $size[0] = $width; - $size[1] = (int) $width * ($size1/$size0); - } else if ($height) - { - $size[1] = $height; - $size[0] = (int) $height * ($size0/$size1); - } - else - return str_replace($real_dir, "", $source_file); - - - /* - if ($height && $height > $size[1]) { - $size[1] = $height; - $size[0] = (int) $width*($size[0]/$size[1]); - } - */ - - $target = imagecreatetruecolor($size[0], $size[1]); - imagecopyresampled($target, $source, 0, 0, 0, 0, $size[0], $size[1], $size0, $size1); - $source = $target; - unset($target); - } - - if ($width) { - $x = $width; - if ($height) { - - if ($width > $size[0]) { // $width ̹ Ŭ ($width resize ʿ) - if ($height > $size[1]) { - $x = $size[0]; - $tmp_y = $size[1]; - $target = imagecreatetruecolor($x, $tmp_y); - imagecopyresampled($target, $source, 0, 0, 0, 0, $x, $tmp_y, $size[0], $size[1]); - } else { - if ($is_crop) { // ġ ̸ ߶ մϴ - $x = $size[0]; - $y = $size[1]; - $tmp_y = $height; - $target = imagecreatetruecolor($x, $tmp_y); - $tmp_target = imagecreatetruecolor($x, $tmp_y); - imagecopyresampled($tmp_target, $source, 0, 0, 0, 0, $x, $y, $size[0], $size[1]); - imagecopy($target, $tmp_target, 0, 0, 0, 0, $x, $tmp_y); - } else { - $y = $height; - $rate = $y / $size[1]; - $x = (int)($size[0] * $rate); - $target = imagecreatetruecolor($x, $y); - imagecopyresampled($target, $source, 0, 0, 0, 0, $x, $y, $size[0], $size[1]); - } - } - } else { // $width ̹ ( resize ʿ) - $y = $height; - $rate = $x / $size[0]; - $tmp_y = (int)($size[1] * $rate); - if ($height > $tmp_y) { - if ($height < $size[1]) { - if ($is_crop) { // ̰ Ƿ ̹ crop - $rate = $y / $size[1]; - $tmp_x = (int)($size[0] * $rate); - $target = imagecreatetruecolor($x, $y); - $tmp_target = imagecreatetruecolor($tmp_x, $y); - imagecopyresampled($tmp_target, $source, 0, 0, 0, 0, $tmp_x, $y, $size[0], $size[1]); - // copyϴ ġ ̹ ߽ ǰ - $src_x = (int)(($tmp_x - $x)/2); - imagecopy($target, $tmp_target, 0, 0, $src_x, 0, $x, $y); - } else { - $target = imagecreatetruecolor($x, $tmp_y); - imagecopyresampled($target, $source, 0, 0, 0, 0, $x, $tmp_y, $size[0], $size[1]); - } - } else { - // ̰ ̺ Ƿ ̹ crop - if ($is_crop == 1) { // - $tmp_x = (int)$size[0]; - $tmp_y = (int)$size[1]; - $target = imagecreatetruecolor($x, $tmp_y); - imagecopyresampled($target, $source, 0, 0, 0, 0, $x, $tmp_y, $x, $tmp_y); - } else if ($is_crop == 2) { // ߰ - $tmp_x = (int)($size[0]/2) - (int)($x/2); - $tmp_y = (int)$size[1]; - $target = imagecreatetruecolor($x, $tmp_y); - imagecopyresampled($target, $source, 0, 0, $tmp_x, 0, $x, $tmp_y, $x, $tmp_y); - } else { // - $target = imagecreatetruecolor($x, $tmp_y); - imagecopyresampled($target, $source, 0, 0, 0, 0, $x, $tmp_y, $size[0], $size[1]); - } - } - } else { - if ($is_crop) { - $target = imagecreatetruecolor($x, $y); - $tmp_target = imagecreatetruecolor($x, $tmp_y); - imagecopyresampled($tmp_target, $source, 0, 0, 0, 0, $x, $tmp_y, $size[0], $size[1]); - imagecopy($target, $tmp_target, 0, 0, 0, 0, $x, $y); - } else { - $rate = $y / $size[1]; - $tmp_x = (int)($size[0] * $rate); - $target = imagecreatetruecolor($tmp_x, $y); - imagecopyresampled($target, $source, 0, 0, 0, 0, $tmp_x, $y, $size[0], $size[1]); - } - } - } - } - else - { // $height (crop ش ? ^^) - if ($width >= $size[0]) { // $width ũ, ̹ 濡 ϴ (Ȯ ) - $x = $size[0]; - $tmp_y = $size[1]; - } else { - $rate = $x / $size[0]; - $tmp_y = (int)($size[1] * $rate); - } - - $target = imagecreatetruecolor($x, $tmp_y); - imagecopyresampled($target, $source, 0, 0, 0, 0, $x, $tmp_y, $size[0], $size[1]); - } - } - else // $width $height ִ - { - if ($height > $size[1]) { // ̺ $height ũ, ̹ ̷ ϴ (Ȯ ) - $y = $size[1]; - $tmp_x = $size[0]; - $target = imagecreatetruecolor($tmp_x, $y); - imagecopyresampled($target, $source, 0, 0, 0, 0, $tmp_x, $y, $size[0], $size[1]); - } else { - $x = $size[0]; - $y = $height; - $tmp_y = $size[1]; - if ($is_crop) { - $target = imagecreatetruecolor($x, $y); - $tmp_target = imagecreatetruecolor($x, $tmp_y); - imagecopyresampled($tmp_target, $source, 0, 0, 0, 0, $x, $tmp_y, $size[0], $size[1]); - imagecopy($target, $tmp_target, 0, 0, 0, 0, $x, $tmp_y); - } else { - $rate = $y / $size[1]; - $tmp_x = (int)($size[0] * $rate); - $target = imagecreatetruecolor($tmp_x, $y); - imagecopyresampled($target, $source, 0, 0, 0, 0, $tmp_x, $y, $size[0], $size[1]); - } - } - } - - // ̹ Ƽ - ob_start(); - if ($size[2] == 1) - imagegif($target, "", $quality); - else if ($size[2] == 2) - imagejpeg($target, "", $quality); - else if ($size[2] == 3) - imagepng($target, "", round(10 - ($quality / 10))); //imagepng Ƽ 0~9 մϴ (Lusia). 0(no compression) Դϴ - $tmp_image_str = ob_get_contents(); - ob_end_clean(); - $target = imagecreatefromstring($tmp_image_str); - unset($tmp_image_str); - - // watermark ̹ ־ֱ - if (trim($watermark) && count($watermark) > 0) { - foreach ($watermark as $w1) { - // ̸ 丮 - $w1_file = $w1['filename']; - if (!$w1_file) continue; - - $w_dir = dirname(file_path($w1_file)); - $w_file = basename($w1_file); - - $w1_file = $w_dir . "/" . $w_file; - - // ͸ũ ͸ũ ʽϴ - if (!file_exists($w1_file)) - break; - - // ͸ũ ̹ width, height - $sizew = getimagesize($w1_file); - $wx = $sizew[0]; - $wy = $sizew[1]; - // watermark ̹ о̱ - if ($sizew[2] == 1) - $w1_source = imagecreatefromgif($w1_file); - else if ($sizew[2] == 2) - $w1_source = imagecreatefromjpeg($w1_file); - else if ($sizew[2] == 3) - $w1_source = imagecreatefrompng($w1_file); - - // $target ̹ width, height - $sx = imagesx($target); - $sy = imagesy($target); - - switch ($w1[location]) { - case "center" : - $tx = (int)($sx/2 - $wx/2) + $w1[x]; - $ty = (int)($sy/2 - $wy/2) + $w1[y]; - break; - case "top" : - $tx = (int)($sx/2 - $wx/2) + $w1[x]; - $ty = $w1[y]; - break; - case "top_left" : - $tx = $w1[x]; - $ty = $w1[y]; - break; - case "top_right" : - $tx = $sx - $wx - $w1[x]; - $ty = $w1[y]; - break; - case "bottom" : - $tx = (int)($sx/2 - $wx/2) + $w1[x]; - $ty = $sy - $w1[y] - $wy; - break; - case "bottom_left" : - $tx = $w1[x]; - $ty = $sy - $w1[y] - $wy; - break; - case "bottom_right" : - default : - $tx = $sx - $w1[x] - $wx; - $ty = $sy - $w1[y] - $wy; - } - imagecopyresampled($target, $w1_source, $tx, $ty, 0, 0, $wx, $wy, $wx, $wy); - } - } - - // php imagefilter - //if ($filter and $size[2] == 2) { //$size[2] == 2 , jpg - if ($filter) { - $filter_type = $filter[type]; - switch($filter_type) { - case IMG_FILTER_COLORIZE : imagefilter($target, $filter_type, $filter[arg1], $filter[arg2], $filter[arg3], $filter[arg4]); - break; - case IMG_FILTER_PIXELATE : imagefilter($target, $filter_type, $filter[arg1], $filter[arg2]); - break; - case IMG_FILTER_BRIGHTNESS : - case IMG_FILTER_CONTRAST : - case IMG_FILTER_SMOOTH : imagefilter($target, $filter_type, $filter[arg1]); - break; - case IMG_FILTER_NEGATE : - case IMG_FILTER_GRAYSCALE: - case IMG_FILTER_EDGEDETECT: - case IMG_FILTER_EMBOSS : - case IMG_FILTER_GAUSSIAN_BLUR : - case IMG_FILTER_SELECTIVE_BLUR: - case IMG_FILTER_MEAN_REMOVAL: imagefilter($target, $filter_type); - break; - case 99: UnsharpMask4($target, $filter[arg1], $filter[arg2], $filter[arg3]); - break; - default : ; // Ÿ Ʋ ƹ͵ մϴ - } - } - - $quality=100; - if ($size[2] == 1 || $thumb_type=="gif") - imagegif($target, $thumb_file, 100); // gif - else if ($size[2] == 2 || $thumb_type=="jpg") - imagejpeg($target, $thumb_file, 100); // jpeg - else if ($size[2] == 3 || $thumb_type=="png") { - // Turn off alpha blending and set alpha flag - imagealphablending($target, false); - imagesavealpha($target, true); - - imagepng($target, $thumb_file, 0); //imagepng Ƽ 0~9 մϴ (Lusia). 0(no compression) Դϴ - } - else - imagegif($target, $thumb_file, 100); - - @chmod($thumb_file, 0606); // Ͽ ϸ - - // ޸𸮸 νݴϴ - http://kr2.php.net/manual/kr/function.imagedestroy.php - if ($target) - imagedestroy($target); - if ($source) - imagedestroy($source); - if ($tmp_target) - imagedestroy($tmp_target); - - return str_replace($real_dir, "", $thumb_file); -} - -// php imagefilter for PHP4 - http://mgccl.com/2007/03/02/imagefilter-function-for-php-user-without-bundled-gd -// -//include this file whenever you have to use imageconvolution... -//you can use in your project, but keep the comment below :) -//great for any image manipulation library -//Made by Chao Xu(Mgccl) 3/1/07 -//www.webdevlogs.com -//V 1.0 -if(!function_exists('imagefilter')){ - function imagefilter($source, $var, $arg1 = null, $arg2 = null, $arg3 = null){ - #define('IMAGE_FILTER_NEGATE',0); - #define('IMAGE_FILTER_GRAYSCALE',0); - #define('IMAGE_FILTER_BRIGHTNESS',2); - #define('IMAGE_FILTER_CONTRAST',3); - #define('IMAGE_FILTER_COLORIZE',4); - #define('IMAGE_FILTER_EDGEDETECT',5); - #define('IMAGE_FILTER_EMBOSS',6); - #define('IMAGE_FILTER_GAUSSIAN_BLUR',7); - #define('IMAGE_FILTER_SELECTIVE_BLUR',8); - #define('IMAGE_FILTER_MEAN_REMOVAL',9); - #define('IMAGE_FILTER_SMOOTH',10); - $max_y = imagesy($source); - $max_x = imagesx($source); - switch ($var){ - case 0: - $y = 0; - while($y<$max_y) { - $x = 0; - while($x<$max_x){ - $rgb = imagecolorat($source,$x,$y); - $r = 255 - (($rgb >> 16) & 0xFF); - $g = 255 - (($rgb >> 8) & 0xFF); - $b = 255 - ($rgb & 0xFF); - $a = $rgb >> 24; - $new_pxl = imagecolorallocatealpha($source, $r, $g, $b, $a); - if ($new_pxl == false){ - $new_pxl = imagecolorclosestalpha($source, $r, $g, $b, $a); - } - imagesetpixel($source,$x,$y,$new_pxl); - ++$x; - } - ++$y; - } - return true; - break; - case 1: - $y = 0; - while($y<$max_y) { - $x = 0; - while($x<$max_x){ - $rgb = imagecolorat($source,$x,$y); - $a = $rgb >> 24; - $r = ((($rgb >> 16) & 0xFF)*0.299)+((($rgb >> 8) & 0xFF)*0.587)+(($rgb & 0xFF)*0.114); - $new_pxl = imagecolorallocatealpha($source, $r, $r, $r, $a); - if ($new_pxl == false){ - $new_pxl = imagecolorclosestalpha($source, $r, $r, $r, $a); - } - imagesetpixel($source,$x,$y,$new_pxl); - ++$x; - } - ++$y; - } - return true; - break; - case 2: - $y = 0; - while($y<$max_y) { - $x = 0; - while($x<$max_x){ - $rgb = imagecolorat($source,$x,$y); - $r = (($rgb >> 16) & 0xFF) + $arg1; - $g = (($rgb >> 8) & 0xFF) + $arg1; - $b = ($rgb & 0xFF) + $arg1; - $a = $rgb >> 24; - $r = ($r > 255)? 255 : (($r < 0)? 0:$r); - $g = ($g > 255)? 255 : (($g < 0)? 0:$g); - $b = ($b > 255)? 255 : (($b < 0)? 0:$b); - $new_pxl = imagecolorallocatealpha($source, $r, $g, $b, $a); - if ($new_pxl == false){ - $new_pxl = imagecolorclosestalpha($source, $r, $g, $b, $a); - } - imagesetpixel($source,$x,$y,$new_pxl); - ++$x; - } - ++$y; - } - return true; - break; - case 3: - $contrast = pow((100-$arg1)/100,2); - $y = 0; - while($y<$max_y) { - $x = 0; - while($x<$max_x){ - $rgb = imagecolorat($source,$x,$y); - $a = $rgb >> 24; - $r = (((((($rgb >> 16) & 0xFF)/255)-0.5)*$contrast)+0.5)*255; - $g = (((((($rgb >> 8) & 0xFF)/255)-0.5)*$contrast)+0.5)*255; - $b = ((((($rgb & 0xFF)/255)-0.5)*$contrast)+0.5)*255; - $r = ($r > 255)? 255 : (($r < 0)? 0:$r); - $g = ($g > 255)? 255 : (($g < 0)? 0:$g); - $b = ($b > 255)? 255 : (($b < 0)? 0:$b); - $new_pxl = imagecolorallocatealpha($source, $r, $g, $b, $a); - if ($new_pxl == false){ - $new_pxl = imagecolorclosestalpha($source, $r, $g, $b, $a); - } - imagesetpixel($source,$x,$y,$new_pxl); - ++$x; - } - ++$y; - } - return true; - break; - case 4: - $x = 0; - while($x<$max_x){ - $y = 0; - while($y<$max_y){ - $rgb = imagecolorat($source, $x, $y); - $r = (($rgb >> 16) & 0xFF) + $arg1; - $g = (($rgb >> 8) & 0xFF) + $arg2; - $b = ($rgb & 0xFF) + $arg3; - $a = $rgb >> 24; - $r = ($r > 255)? 255 : (($r < 0)? 0:$r); - $g = ($g > 255)? 255 : (($g < 0)? 0:$g); - $b = ($b > 255)? 255 : (($b < 0)? 0:$b); - $new_pxl = imagecolorallocatealpha($source, $r, $g, $b, $a); - if ($new_pxl == false){ - $new_pxl = imagecolorclosestalpha($source, $r, $g, $b, $a); - } - imagesetpixel($source,$x,$y,$new_pxl); - ++$y; - } - ++$x; - } - return true; - break; - case 5: - return imageconvolution($source, array(array(-1,0,-1), array(0,4,0), array(-1,0,-1)), 1, 127); - break; - case 6: - return imageconvolution($source, array(array(1.5, 0, 0), array(0, 0, 0), array(0, 0, -1.5)), 1, 127); - break; - case 7: - return imageconvolution($source, array(array(1, 2, 1), array(2, 4, 2), array(1, 2, 1)), 16, 0); - break; - case 8: - for($y = 0; $y<$max_y; $y++) { - for ($x = 0; $x<$max_x; $x++) { - $flt_r_sum = $flt_g_sum = $flt_b_sum = 0; - $cpxl = imagecolorat($source, $x, $y); - for ($j=0; $j<3; $j++) { - for ($i=0; $i<3; $i++) { - if (($j == 1) && ($i == 1)) { - $flt_r[1][1] = $flt_g[1][1] = $flt_b[1][1] = 0.5; - } else { - $pxl = imagecolorat($source, $x-(3>>1)+$i, $y-(3>>1)+$j); - - $new_a = $pxl >> 24; - //$r = (($pxl >> 16) & 0xFF); - //$g = (($pxl >> 8) & 0xFF); - //$b = ($pxl & 0xFF); - $new_r = abs((($cpxl >> 16) & 0xFF) - (($pxl >> 16) & 0xFF)); - if ($new_r != 0) { - $flt_r[$j][$i] = 1/$new_r; - } else { - $flt_r[$j][$i] = 1; - } - - $new_g = abs((($cpxl >> 8) & 0xFF) - (($pxl >> 8) & 0xFF)); - if ($new_g != 0) { - $flt_g[$j][$i] = 1/$new_g; - } else { - $flt_g[$j][$i] = 1; - } - - $new_b = abs(($cpxl & 0xFF) - ($pxl & 0xFF)); - if ($new_b != 0) { - $flt_b[$j][$i] = 1/$new_b; - } else { - $flt_b[$j][$i] = 1; - } - } - - $flt_r_sum += $flt_r[$j][$i]; - $flt_g_sum += $flt_g[$j][$i]; - $flt_b_sum += $flt_b[$j][$i]; - } - } - - for ($j=0; $j<3; $j++) { - for ($i=0; $i<3; $i++) { - if ($flt_r_sum != 0) { - $flt_r[$j][$i] /= $flt_r_sum; - } - if ($flt_g_sum != 0) { - $flt_g[$j][$i] /= $flt_g_sum; - } - if ($flt_b_sum != 0) { - $flt_b[$j][$i] /= $flt_b_sum; - } - } - } - - $new_r = $new_g = $new_b = 0; - - for ($j=0; $j<3; $j++) { - for ($i=0; $i<3; $i++) { - $pxl = imagecolorat($source, $x-(3>>1)+$i, $y-(3>>1)+$j); - $new_r += (($pxl >> 16) & 0xFF) * $flt_r[$j][$i]; - $new_g += (($pxl >> 8) & 0xFF) * $flt_g[$j][$i]; - $new_b += ($pxl & 0xFF) * $flt_b[$j][$i]; - } - } - - $new_r = ($new_r > 255)? 255 : (($new_r < 0)? 0:$new_r); - $new_g = ($new_g > 255)? 255 : (($new_g < 0)? 0:$new_g); - $new_b = ($new_b > 255)? 255 : (($new_b < 0)? 0:$new_b); - $new_pxl = ImageColorAllocateAlpha($source, (int)$new_r, (int)$new_g, (int)$new_b, $new_a); - if ($new_pxl == false) { - $new_pxl = ImageColorClosestAlpha($source, (int)$new_r, (int)$new_g, (int)$new_b, $new_a); - } - imagesetpixel($source,$x,$y,$new_pxl); - } - } - return true; - break; - case 9: - return imageconvolution($source, array(array(-1,-1,-1),array(-1,9,-1),array(-1,-1,-1)), 1, 0); - break; - case 10: - return imageconvolution($source, array(array(1,1,1),array(1,$arg1,1),array(1,1,1)), $arg1+8, 0); - break; - } - } -} - -if(!function_exists('file_path')){ -// θ ɴϴ (Ҵ, /lib/common.lib.php ǵ Լ) -function file_path($path) { - - $dir = dirname($path); - $file = basename($path); - - if (substr($dir,0,1) == "/") { - $real_dir = dirname($_SERVER['DOCUMENT_ROOT'] . "/nothing"); - $dir = $real_dir . $dir; - } - - return $dir . "/" . $file; -} -} - -//////////////////////////////////////////////////////////////////////////////////////////////// -//// -//// Unsharp Mask for PHP - version 2.1.1 -//// -//// Unsharp mask algorithm by Torstein Hnsi 2003-07. -//// thoensi_at_netcom_dot_no. -//// Please leave this notice. -//// -//// http://vikjavev.no/computing/ump.php -//// -/////////////////////////////////////////////////////////////////////////////////////////////// -if(!function_exists('UnsharpMask4')){ -function UnsharpMask4($img, $amount, $radius, $threshold) -{ - - // $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); break; } - $w = imagesx($img); $h = imagesy($img); - $imgCanvas = $img; - $imgCanvas2 = $img; - $imgBlur = imagecreatetruecolor($w, $h); - - // Gaussian blur matrix: - // 1 2 1 - // 2 4 2 - // 1 2 1 - - // 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, $imgCanvas, 0, 0, 1, 1, $w - 1, $h - 1); // up left - imagecopymerge ($imgBlur, $imgCanvas, 1, 1, 0, 0, $w, $h, 50); // down right - imagecopymerge ($imgBlur, $imgCanvas, 0, 1, 1, 0, $w - 1, $h, 33.33333); // down left - imagecopymerge ($imgBlur, $imgCanvas, 1, 0, 0, 1, $w, $h - 1, 25); // up right - imagecopymerge ($imgBlur, $imgCanvas, 0, 0, 1, 0, $w - 1, $h, 33.33333); // left - imagecopymerge ($imgBlur, $imgCanvas, 1, 0, 0, 0, $w, $h, 25); // right - imagecopymerge ($imgBlur, $imgCanvas, 0, 0, 0, 1, $w, $h - 1, 20 ); // up - imagecopymerge ($imgBlur, $imgCanvas, 0, 1, 0, 0, $w, $h, 16.666667); // down - imagecopymerge ($imgBlur, $imgCanvas, 0, 0, 0, 0, $w, $h, 50); // center - } - $imgCanvas = $imgBlur; - - // Calculate the difference between the blurred pixels and the original - // and set the pixels - for ($x = 0; $x < $w; $x++) - { // each row - for ($y = 0; $y < $h; $y++) - { // each pixel - $rgbOrig = ImageColorAt($imgCanvas2, $x, $y); - $rOrig = (($rgbOrig >> 16) & 0xFF); - $gOrig = (($rgbOrig >> 8) & 0xFF); - $bOrig = ($rgbOrig & 0xFF); - $rgbBlur = ImageColorAt($imgCanvas, $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); - } - } - } - return $img; -} -} - -/*********************************************/ -/* Fonction: ImageCreateFromBMP */ -/* Author: DHKold */ -/* Contact: admin@dhkold.com */ -/* Date: The 15th of June 2005 */ -/* Version: 2.0B */ -/*********************************************/ - -if(!function_exists('ImageCreateFromBMP')){ -function ImageCreateFromBMP($filename) -{ - //Ouverture du fichier en mode binaire - if (! $f1 = fopen($filename,"rb")) return FALSE; -echo $filename; - //1 : Chargement des ent?tes FICHIER - $FILE = unpack("vfile_type/Vfile_size/Vreserved/Vbitmap_offset", fread($f1,14)); - if ($FILE['file_type'] != 19778) return FALSE; - - //2 : Chargement des ent?tes BMP - $BMP = unpack('Vheader_size/Vwidth/Vheight/vplanes/vbits_per_pixel'. - '/Vcompression/Vsize_bitmap/Vhoriz_resolution'. - '/Vvert_resolution/Vcolors_used/Vcolors_important', fread($f1,40)); - $BMP['colors'] = pow(2,$BMP['bits_per_pixel']); - if ($BMP['size_bitmap'] == 0) $BMP['size_bitmap'] = $FILE['file_size'] - $FILE['bitmap_offset']; - $BMP['bytes_per_pixel'] = $BMP['bits_per_pixel']/8; - $BMP['bytes_per_pixel2'] = ceil($BMP['bytes_per_pixel']); - $BMP['decal'] = ($BMP['width']*$BMP['bytes_per_pixel']/4); - $BMP['decal'] -= floor($BMP['width']*$BMP['bytes_per_pixel']/4); - $BMP['decal'] = 4-(4*$BMP['decal']); - if ($BMP['decal'] == 4) $BMP['decal'] = 0; - - //3 : Chargement des couleurs de la palette - $PALETTE = array(); - if ($BMP['colors'] < 16777216) - { - $PALETTE = unpack('V'.$BMP['colors'], fread($f1,$BMP['colors']*4)); - } - - //4 : Cr?ation de l'image - $IMG = fread($f1,$BMP['size_bitmap']); - $VIDE = chr(0); - - $res = imagecreatetruecolor($BMP['width'],$BMP['height']); - $P = 0; - $Y = $BMP['height']-1; - while ($Y >= 0) - { - $X=0; - while ($X < $BMP['width']) - { - if ($BMP['bits_per_pixel'] == 24) - $COLOR = unpack("V",substr($IMG,$P,3).$VIDE); - elseif ($BMP['bits_per_pixel'] == 16) - { - $COLOR = unpack("v",substr($IMG,$P,2)); - $blue = (($COLOR[1] & 0x001f) << 3) + 7; - $green = (($COLOR[1] & 0x03e0) >> 2) + 7; - $red = (($COLOR[1] & 0xfc00) >> 7) + 7; - $COLOR[1] = $red * 65536 + $green * 256 + $blue; - } - elseif ($BMP['bits_per_pixel'] == 8) - { - $COLOR = unpack("n",$VIDE.substr($IMG,$P,1)); - $COLOR[1] = $PALETTE[$COLOR[1]+1]; - } - elseif ($BMP['bits_per_pixel'] == 4) - { - $COLOR = unpack("n",$VIDE.substr($IMG,floor($P),1)); - if (($P*2)%2 == 0) $COLOR[1] = ($COLOR[1] >> 4) ; else $COLOR[1] = ($COLOR[1] & 0x0F); - $COLOR[1] = $PALETTE[$COLOR[1]+1]; - } - elseif ($BMP['bits_per_pixel'] == 1) - { - $COLOR = unpack("n",$VIDE.substr($IMG,floor($P),1)); - if (($P*8)%8 == 0) $COLOR[1] = $COLOR[1] >>7; - elseif (($P*8)%8 == 1) $COLOR[1] = ($COLOR[1] & 0x40)>>6; - elseif (($P*8)%8 == 2) $COLOR[1] = ($COLOR[1] & 0x20)>>5; - elseif (($P*8)%8 == 3) $COLOR[1] = ($COLOR[1] & 0x10)>>4; - elseif (($P*8)%8 == 4) $COLOR[1] = ($COLOR[1] & 0x8)>>3; - elseif (($P*8)%8 == 5) $COLOR[1] = ($COLOR[1] & 0x4)>>2; - elseif (($P*8)%8 == 6) $COLOR[1] = ($COLOR[1] & 0x2)>>1; - elseif (($P*8)%8 == 7) $COLOR[1] = ($COLOR[1] & 0x1); - $COLOR[1] = $PALETTE[$COLOR[1]+1]; - } - else - return FALSE; - imagesetpixel($res,$X,$Y,$COLOR[1]); - $X++; - $P += $BMP['bytes_per_pixel']; - } - $Y--; - $P+=$BMP['decal']; - } - - //Fermeture du fichier - fclose($f1); - - return $res; -} -} - -// animated gif Ȯ -// http://kr2.php.net/imagecreatefromgif -/* -function is_ani_gif($filename) -{ - $filecontents=file_get_contents($filename); - - $str_loc=0; - $count=0; - while ($count < 2) # There is no point in continuing after we find a 2nd frame - { - - $where1=strpos($filecontents,"\x00\x21\xF9\x04",$str_loc); - if ($where1 === FALSE) - { - break; - } - else - { - $str_loc=$where1+1; - $where2=strpos($filecontents,"\x00\x2C",$str_loc); - if ($where2 === FALSE) - { - break; - } - else - { - if ($where1+8 == $where2) - { - $count++; - } - $str_loc=$where2+1; - } - } - } - - if ($count > 1) - { - return(true); - } - else - { - return(false); - } -} -*/ - -// psd - http://www.phpclasses.org/browse/file/17603.html - -/* This file is released under the GPL, any version you like -* PHP PSD reader class, v1.3 -* By Tim de Koning -* Kingsquare Information Services, 22 jan 2007 -* -* example use: -* ------------ -* -* -* More info, bugs or requests, contact info@kingsquare.nl -* -* Latest version and demo: http://www.kingsquare.nl/phppsdreader -* -* TODO -* ---- -* - read color values for "multichannel data" PSD files -* - find and implement (hunter)lab to RGB algorithm -* - fix 32 bit colors... has something to do with gamma and exposure available since CS2, but dunno how to read them... -*/ - - -class PhpPsdReader { - var $infoArray; - var $fp; - var $fileName; - var $tempFileName; - var $colorBytesLength; - - function PhpPsdReader($fileName) { - set_time_limit(0); - $this->infoArray = array(); - $this->fileName = $fileName; - $this->fp = fopen($this->fileName,'r'); - - if (fread($this->fp,4)=='8BPS') { - $this->infoArray['version id'] = $this->_getInteger(2); - fseek($this->fp,6,SEEK_CUR); // 6 bytes of 0's - $this->infoArray['channels'] = $this->_getInteger(2); - $this->infoArray['rows'] = $this->_getInteger(4); - $this->infoArray['columns'] = $this->_getInteger(4); - $this->infoArray['colorDepth'] = $this->_getInteger(2); - $this->infoArray['colorMode'] = $this->_getInteger(2); - - - /* COLOR MODE DATA SECTION */ //4bytes Length The length of the following color data. - $this->infoArray['colorModeDataSectionLength'] = $this->_getInteger(4); - fseek($this->fp,$this->infoArray['colorModeDataSectionLength'],SEEK_CUR); // ignore this snizzle - - /* IMAGE RESOURCES */ - $this->infoArray['imageResourcesSectionLength'] = $this->_getInteger(4); - fseek($this->fp,$this->infoArray['imageResourcesSectionLength'],SEEK_CUR); // ignore this snizzle - - /* LAYER AND MASK */ - $this->infoArray['layerMaskDataSectionLength'] = $this->_getInteger(4); - fseek($this->fp,$this->infoArray['layerMaskDataSectionLength'],SEEK_CUR); // ignore this snizzle - - - /* IMAGE DATA */ - $this->infoArray['compressionType'] = $this->_getInteger(2); - $this->infoArray['oneColorChannelPixelBytes'] = $this->infoArray['colorDepth']/8; - $this->colorBytesLength = $this->infoArray['rows']*$this->infoArray['columns']*$this->infoArray['oneColorChannelPixelBytes']; - - if ($this->infoArray['colorMode']==2) { - $this->infoArray['error'] = 'images with indexed colours are not supported yet'; - return false; - } - } else { - $this->infoArray['error'] = 'invalid or unsupported psd'; - return false; - } - } - - - function getImage() { - // decompress image data if required - switch($this->infoArray['compressionType']) { - // case 2:, case 3: zip not supported yet.. - case 1: - // packed bits - $this->infoArray['scanLinesByteCounts'] = array(); - for ($i=0; $i<($this->infoArray['rows']*$this->infoArray['channels']); $i++) $this->infoArray['scanLinesByteCounts'][] = $this->_getInteger(2); - $this->tempFileName = tempnam(realpath('/tmp'),'decompressedImageData'); - $tfp = fopen($this->tempFileName,'wb'); - foreach ($this->infoArray['scanLinesByteCounts'] as $scanLinesByteCount) { - fwrite($tfp,$this->_getPackedBitsDecoded(fread($this->fp,$scanLinesByteCount))); - } - fclose($tfp); - fclose($this->fp); - $this->fp = fopen($this->tempFileName,'r'); - default: - // continue with current file handle; - break; - } - - // let's write pixel by pixel.... - $image = imagecreatetruecolor($this->infoArray['columns'],$this->infoArray['rows']); - - for ($rowPointer = 0; ($rowPointer < $this->infoArray['rows']); $rowPointer++) { - for ($columnPointer = 0; ($columnPointer < $this->infoArray['columns']); $columnPointer++) { - /* The color mode of the file. Supported values are: Bitmap=0; - Grayscale=1; Indexed=2; RGB=3; CMYK=4; Multichannel=7; - Duotone=8; Lab=9. - */ - switch ($this->infoArray['colorMode']) { - case 2: // indexed... info should be able to extract from color mode data section. not implemented yet, so is grayscale - exit; - break; - case 0: - // bit by bit - if ($columnPointer == 0) $bitPointer = 0; - if ($bitPointer==0) $currentByteBits = str_pad(base_convert(bin2hex(fread($this->fp,1)), 16, 2),8,'0',STR_PAD_LEFT); - $r = $g = $b = (($currentByteBits[$bitPointer]=='1')?0:255); - $bitPointer++; - if ($bitPointer==8) $bitPointer = 0; - break; - - case 1: - case 8: // 8 is indexed with 1 color..., so grayscale - $r = $g = $b = $this->_getInteger($this->infoArray['oneColorChannelPixelBytes']); - break; - - case 4: // CMYK - $c = $this->_getInteger($this->infoArray['oneColorChannelPixelBytes']); - $currentPointerPos = ftell($this->fp); - fseek($this->fp,$this->colorBytesLength-1,SEEK_CUR); - $m = $this->_getInteger($this->infoArray['oneColorChannelPixelBytes']); - fseek($this->fp,$this->colorBytesLength-1,SEEK_CUR); - $y = $this->_getInteger($this->infoArray['oneColorChannelPixelBytes']); - fseek($this->fp,$this->colorBytesLength-1,SEEK_CUR); - $k = $this->_getInteger($this->infoArray['oneColorChannelPixelBytes']); - fseek($this->fp,$currentPointerPos); - $r = round(($c * $k) / (pow(2,$this->infoArray['colorDepth'])-1)); - $g = round(($m * $k) / (pow(2,$this->infoArray['colorDepth'])-1)); - $b = round(($y * $k) / (pow(2,$this->infoArray['colorDepth'])-1)); - - break; - - case 9: // hunter Lab - // i still need an understandable lab2rgb convert algorithm... if you have one, please let me know! - $l = $this->_getInteger($this->infoArray['oneColorChannelPixelBytes']); - $currentPointerPos = ftell($this->fp); - fseek($this->fp,$this->colorBytesLength-1,SEEK_CUR); - $a = $this->_getInteger($this->infoArray['oneColorChannelPixelBytes']); - fseek($this->fp,$this->colorBytesLength-1,SEEK_CUR); - $b = $this->_getInteger($this->infoArray['oneColorChannelPixelBytes']); - fseek($this->fp,$currentPointerPos); - - $r = $l; - $g = $a; - $b = $b; - - break; - default: - $r = $this->_getInteger($this->infoArray['oneColorChannelPixelBytes']); - $currentPointerPos = ftell($this->fp); - fseek($this->fp,$this->colorBytesLength-1,SEEK_CUR); - $g = $this->_getInteger($this->infoArray['oneColorChannelPixelBytes']); - fseek($this->fp,$this->colorBytesLength-1,SEEK_CUR); - $b = $this->_getInteger($this->infoArray['oneColorChannelPixelBytes']); - fseek($this->fp,$currentPointerPos); - break; - - } - - if (($this->infoArray['oneColorChannelPixelBytes']==2)) { - $r = $r >> 8; - $g = $g >> 8; - $b = $b >> 8; - } elseif (($this->infoArray['oneColorChannelPixelBytes']==4)) { - $r = $r >> 24; - $g = $g >> 24; - $b = $b >> 24; - } - - $pixelColor = imagecolorallocate($image,$r,$g,$b); - imagesetpixel($image,$columnPointer,$rowPointer,$pixelColor); - } - } - fclose($this->fp); - if (isset($this->tempFileName)) unlink($this->tempFileName); - return $image; - } - - /** - * - * PRIVATE FUNCTIONS - * - */ - - function _getPackedBitsDecoded($string) { - /* - The PackBits algorithm will precede a block of data with a one byte header n, where n is interpreted as follows: - n Meaning - 0 to 127 Copy the next n + 1 symbols verbatim - -127 to -1 Repeat the next symbol 1 - n times - -128 Do nothing - - Decoding: - Step 1. Read the block header (n). - Step 2. If the header is an EOF exit. - Step 3. If n is non-negative, copy the next n + 1 symbols to the output stream and go to step 1. - Step 4. If n is negative, write 1 - n copies of the next symbol to the output stream and go to step 1. - - */ - - $stringPointer = 0; - $returnString = ''; - - while (1) { - if (isset($string[$stringPointer])) $headerByteValue = $this->_unsignedToSigned(hexdec(bin2hex($string[$stringPointer])),1); - else return $returnString; - $stringPointer++; - - if ($headerByteValue >= 0) { - for ($i=0; $i <= $headerByteValue; $i++) { - $returnString .= $string[$stringPointer]; - $stringPointer++; - } - } else { - if ($headerByteValue != -128) { - $copyByte = $string[$stringPointer]; - $stringPointer++; - - for ($i=0; $i < (1-$headerByteValue); $i++) { - $returnString .= $copyByte; - } - } - } - } - } - - function _unsignedToSigned($int,$byteSize=1) { - switch($byteSize) { - case 1: - if ($int<128) return $int; - else return -256+$int; - break; - - case 2: - if ($int<32768) return $int; - else return -65536+$int; - - case 4: - if ($int<2147483648) return $int; - else return -4294967296+$int; - - default: - return $int; - } - } - - function _hexReverse($hex) { - $output = ''; - if (strlen($hex)%2) return false; - for ($pointer = strlen($hex);$pointer>=0;$pointer-=2) $output .= substr($hex,$pointer,2); - return $output; - } - - function _getInteger($byteCount=1) { - switch ($byteCount) { - case 4: - // for some strange reason this is still broken... - return @reset(unpack('N',fread($this->fp,4))); - break; - - case 2: - return @reset(unpack('n',fread($this->fp,2))); - break; - - default: - return hexdec($this->_hexReverse(bin2hex(fread($this->fp,$byteCount)))); - } - } -} - -/** - * Returns an image identifier representing the image obtained from the given filename, using only GD, returns an empty string on failure - * - * @param string $fileName - * @return image identifier - */ - -function imagecreatefrompsd($fileName) { - $psdReader = new PhpPsdReader($fileName); - if (isset($psdReader->infoArray['error'])) return ''; - else return $psdReader->getImage(); -} -?> From 30a3c51ba23bd2e7f885de8320c148a635c982f5 Mon Sep 17 00:00:00 2001 From: whitedot Date: Sat, 6 Apr 2013 23:05:45 +0900 Subject: [PATCH 25/63] =?UTF-8?q?=EC=8A=A4=ED=82=A8=EB=B3=80=ED=99=98?= =?UTF-8?q?=EC=8B=A0=EC=B2=AD=20=EC=B2=98=EB=A6=AC=20=EC=9E=91=EC=97=85=20?= =?UTF-8?q?=EC=A4=91=20lib=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/thumb.lib.php | 1284 --------------------------------------------- tail.sub.php | 2 - 2 files changed, 1286 deletions(-) delete mode 100644 lib/thumb.lib.php diff --git a/lib/thumb.lib.php b/lib/thumb.lib.php deleted file mode 100644 index f81b6c01f..000000000 --- a/lib/thumb.lib.php +++ /dev/null @@ -1,1284 +0,0 @@ - ̹ũ - - $height > ̹ũ : ̹ ũ - - else - - $is_crop : ũ - - else : - - else - $ratio $height ؼ, - - $height > $tmp_y : (̰ մϴ) <-- ̺κп ̸ ߰ б⸦ cropڴ ǰߵ ־ - - else : ̹ ̸ crop - - $height (crop ʽϴ) - - $width ̹ ũ⺸ ũ : ̹ ũ - - else : - -$width (̷θ ϴ ) - - $height ̹ ũ⺸ ũ : ̹ ũ - - else - - $is_crop : crop - - else : -*/ -function thumbnail($file_name, $width=0, $height=0, $is_create=false, $is_crop=2, $quality=90, $small_thumb=1, $watermark="", $filter="", $noimg="", $thumb_type="") -{ - //if (!$file_name) - // return; - - // memory limit - @ini_set("memory_limit", -1); - - // 丮 - $real_dir = dirname($_SERVER['DOCUMENT_ROOT'] . "/nothing"); - $dir = dirname(file_path($file_name)); - $file = basename($file_name); - - $thumb_dir = $dir . "/thumb"; - - // 丮 - $thumb_path = $thumb_dir . "/" . $width . "x" . $height . "_" . $quality; - - if (!file_exists($thumb_dir)) { - @mkdir($thumb_dir, 0707); - @chmod($thumb_dir, 0707); - } - - if (!file_exists($thumb_path)) { - @mkdir($thumb_path, 0707); - @chmod($thumb_path, 0707); - } - - $source_file = $dir . "/" . $file; - - $size = @getimagesize($source_file); - $size_org = $size; - - // animated gif ؼ ڸƮ Ǯּ. Ʒڵ cpu disk access ũ ֽϴ - //if ($size[2] == IMG_GIF && is_ani_gif($file_name)) return; - - // ̹ - if (!$size[0]) { - - // $nomimg ̹ - if ($noimg) - return $noimg; - else - { - if (!$width) - $width = 30; - if (!$height) - $height = $width; - $thumb_file = $thumb_dir . "/" . $width . "x" . $height . "_noimg.gif"; - - if (@file_exists($thumb_file)) - ; - else - { - $target = imagecreate($width, $height); - - $bg_color = imagecolorallocate($target, 250, 250, 250); - $font_color = imagecolorallocate($target, 0, 0, 0); - $font_size = 12; - $ttf = "$real_dir/img/han.ttf"; - $text = "no image..."; - $size = imagettfbbox($font_size, 0, $ttf, $text); - $xsize = abs($size[0]) + abs($size[2])+($padding*2); - $ysize = abs($size[5]) + abs($size[1])+($padding*2); - $xloc = $width/2-$xsize/2; - $yloc = $height/2-$ysize/2; - imagefttext($target, $font_size, 0, $xloc, $yloc, $font_color, $ttf, $text); - //imagecopy($target, $target, 0, 0, 0, 0, $width, $height); - imagegif($target, $thumb_file, $quality); - @chmod($thumb_file, 0606); // Ͽ ϸ - } - return str_replace($real_dir, "", $thumb_file); - } - } - - $thumb_file = $thumb_path . "/" . $file; - - // 鼭 ҽϺ ¥ ֱ - if (@file_exists($thumb_file)) { - $thumb_time = @filemtime($thumb_file); - $source_time = @filemtime($source_file); - if ($is_create == false && $source_time < $thumb_time) { - return str_replace($real_dir, "", $thumb_file); - } - } - - // $width, $height ״ thumb - if (!$width && !$height) - $width = $size[0]; - - // ̹ 쿡 ϴ ɼ , ̹ size thumb ʴ´ (̰ pass~!) - if (!$small_thumb && $width >= $size[0] && $height && $height >= $size[1]) - return str_replace($real_dir, "", $source_file); - - $is_imagecopyresampled = false; - $is_large = false; - - if ($size[2] == 1) - $source = imagecreatefromgif($source_file); - else if ($size[2] == 2) { - // php.net - As of PHP 5.1.3, if you are dealing with corrupted JPEG images - // you should set the 'gd.jpeg_ignore_warning' directive to 1 to ignore warnings that could mess up your code. - // ϴµ, ޸ ׳ ϴ. ƹ ̳ . Ȳ - @ini_set('gd.jpeg_ignore_warning', 1); - - // $msize=php Ҵ޸, $isize=24bit plain ʿ ޸ - // ޸𸮰 ϸ ̰ ׳ Ƿ, . - $msize = memory_get_usage(); - $isize = $size['bits'] / 8 * $size[0] * $size[1]; - if ($isize > $msize) - return $file_name; - - $source = imagecreatefromjpeg($source_file); - // jpeg , ͸ũ ? - ͸ũ ׳ (󵵰 ϱ) - if (!$source) { - if (trim($watermark) && count($watermark) > 0) - ; - else - return $file_name; - } - } - else if ($size[2] == 3) - $source = imagecreatefrompng($source_file); - else if ($size[2] == 6) - { - // bmp gif - $source = ImageCreateFromBMP($source_file); - $size[2] = 1; - } - else if ($size[2] == 5) { - // psd - $source = imagecreatefrompsd($source_file); - $size[2] = 1; - } else { - return str_replace($real_dir, "", $source_file); - } - - // Ȯ - if ($small_thumb == 2) { - $size0 = $size[0]; - $size1 = $size[1]; - - if ($width) { - $size[0] = $width; - $size[1] = (int) $width * ($size1/$size0); - } else if ($height) - { - $size[1] = $height; - $size[0] = (int) $height * ($size0/$size1); - } - else - return str_replace($real_dir, "", $source_file); - - - /* - if ($height && $height > $size[1]) { - $size[1] = $height; - $size[0] = (int) $width*($size[0]/$size[1]); - } - */ - - $target = imagecreatetruecolor($size[0], $size[1]); - imagecopyresampled($target, $source, 0, 0, 0, 0, $size[0], $size[1], $size0, $size1); - $source = $target; - unset($target); - } - - if ($width) { - $x = $width; - if ($height) { - - if ($width > $size[0]) { // $width ̹ Ŭ ($width resize ʿ) - if ($height > $size[1]) { - $x = $size[0]; - $tmp_y = $size[1]; - $target = imagecreatetruecolor($x, $tmp_y); - imagecopyresampled($target, $source, 0, 0, 0, 0, $x, $tmp_y, $size[0], $size[1]); - } else { - if ($is_crop) { // ġ ̸ ߶ մϴ - $x = $size[0]; - $y = $size[1]; - $tmp_y = $height; - $target = imagecreatetruecolor($x, $tmp_y); - $tmp_target = imagecreatetruecolor($x, $tmp_y); - imagecopyresampled($tmp_target, $source, 0, 0, 0, 0, $x, $y, $size[0], $size[1]); - imagecopy($target, $tmp_target, 0, 0, 0, 0, $x, $tmp_y); - } else { - $y = $height; - $rate = $y / $size[1]; - $x = (int)($size[0] * $rate); - $target = imagecreatetruecolor($x, $y); - imagecopyresampled($target, $source, 0, 0, 0, 0, $x, $y, $size[0], $size[1]); - } - } - } else { // $width ̹ ( resize ʿ) - $y = $height; - $rate = $x / $size[0]; - $tmp_y = (int)($size[1] * $rate); - if ($height > $tmp_y) { - if ($height < $size[1]) { - if ($is_crop) { // ̰ Ƿ ̹ crop - $rate = $y / $size[1]; - $tmp_x = (int)($size[0] * $rate); - $target = imagecreatetruecolor($x, $y); - $tmp_target = imagecreatetruecolor($tmp_x, $y); - imagecopyresampled($tmp_target, $source, 0, 0, 0, 0, $tmp_x, $y, $size[0], $size[1]); - // copyϴ ġ ̹ ߽ ǰ - $src_x = (int)(($tmp_x - $x)/2); - imagecopy($target, $tmp_target, 0, 0, $src_x, 0, $x, $y); - } else { - $target = imagecreatetruecolor($x, $tmp_y); - imagecopyresampled($target, $source, 0, 0, 0, 0, $x, $tmp_y, $size[0], $size[1]); - } - } else { - // ̰ ̺ Ƿ ̹ crop - if ($is_crop == 1) { // - $tmp_x = (int)$size[0]; - $tmp_y = (int)$size[1]; - $target = imagecreatetruecolor($x, $tmp_y); - imagecopyresampled($target, $source, 0, 0, 0, 0, $x, $tmp_y, $x, $tmp_y); - } else if ($is_crop == 2) { // ߰ - $tmp_x = (int)($size[0]/2) - (int)($x/2); - $tmp_y = (int)$size[1]; - $target = imagecreatetruecolor($x, $tmp_y); - imagecopyresampled($target, $source, 0, 0, $tmp_x, 0, $x, $tmp_y, $x, $tmp_y); - } else { // - $target = imagecreatetruecolor($x, $tmp_y); - imagecopyresampled($target, $source, 0, 0, 0, 0, $x, $tmp_y, $size[0], $size[1]); - } - } - } else { - if ($is_crop) { - $target = imagecreatetruecolor($x, $y); - $tmp_target = imagecreatetruecolor($x, $tmp_y); - imagecopyresampled($tmp_target, $source, 0, 0, 0, 0, $x, $tmp_y, $size[0], $size[1]); - imagecopy($target, $tmp_target, 0, 0, 0, 0, $x, $y); - } else { - $rate = $y / $size[1]; - $tmp_x = (int)($size[0] * $rate); - $target = imagecreatetruecolor($tmp_x, $y); - imagecopyresampled($target, $source, 0, 0, 0, 0, $tmp_x, $y, $size[0], $size[1]); - } - } - } - } - else - { // $height (crop ش ? ^^) - if ($width >= $size[0]) { // $width ũ, ̹ 濡 ϴ (Ȯ ) - $x = $size[0]; - $tmp_y = $size[1]; - } else { - $rate = $x / $size[0]; - $tmp_y = (int)($size[1] * $rate); - } - - $target = imagecreatetruecolor($x, $tmp_y); - imagecopyresampled($target, $source, 0, 0, 0, 0, $x, $tmp_y, $size[0], $size[1]); - } - } - else // $width $height ִ - { - if ($height > $size[1]) { // ̺ $height ũ, ̹ ̷ ϴ (Ȯ ) - $y = $size[1]; - $tmp_x = $size[0]; - $target = imagecreatetruecolor($tmp_x, $y); - imagecopyresampled($target, $source, 0, 0, 0, 0, $tmp_x, $y, $size[0], $size[1]); - } else { - $x = $size[0]; - $y = $height; - $tmp_y = $size[1]; - if ($is_crop) { - $target = imagecreatetruecolor($x, $y); - $tmp_target = imagecreatetruecolor($x, $tmp_y); - imagecopyresampled($tmp_target, $source, 0, 0, 0, 0, $x, $tmp_y, $size[0], $size[1]); - imagecopy($target, $tmp_target, 0, 0, 0, 0, $x, $tmp_y); - } else { - $rate = $y / $size[1]; - $tmp_x = (int)($size[0] * $rate); - $target = imagecreatetruecolor($tmp_x, $y); - imagecopyresampled($target, $source, 0, 0, 0, 0, $tmp_x, $y, $size[0], $size[1]); - } - } - } - - // ̹ Ƽ - ob_start(); - if ($size[2] == 1) - imagegif($target, "", $quality); - else if ($size[2] == 2) - imagejpeg($target, "", $quality); - else if ($size[2] == 3) - imagepng($target, "", round(10 - ($quality / 10))); //imagepng Ƽ 0~9 մϴ (Lusia). 0(no compression) Դϴ - $tmp_image_str = ob_get_contents(); - ob_end_clean(); - $target = imagecreatefromstring($tmp_image_str); - unset($tmp_image_str); - - // watermark ̹ ־ֱ - if (trim($watermark) && count($watermark) > 0) { - foreach ($watermark as $w1) { - // ̸ 丮 - $w1_file = $w1['filename']; - if (!$w1_file) continue; - - $w_dir = dirname(file_path($w1_file)); - $w_file = basename($w1_file); - - $w1_file = $w_dir . "/" . $w_file; - - // ͸ũ ͸ũ ʽϴ - if (!file_exists($w1_file)) - break; - - // ͸ũ ̹ width, height - $sizew = getimagesize($w1_file); - $wx = $sizew[0]; - $wy = $sizew[1]; - // watermark ̹ о̱ - if ($sizew[2] == 1) - $w1_source = imagecreatefromgif($w1_file); - else if ($sizew[2] == 2) - $w1_source = imagecreatefromjpeg($w1_file); - else if ($sizew[2] == 3) - $w1_source = imagecreatefrompng($w1_file); - - // $target ̹ width, height - $sx = imagesx($target); - $sy = imagesy($target); - - switch ($w1[location]) { - case "center" : - $tx = (int)($sx/2 - $wx/2) + $w1[x]; - $ty = (int)($sy/2 - $wy/2) + $w1[y]; - break; - case "top" : - $tx = (int)($sx/2 - $wx/2) + $w1[x]; - $ty = $w1[y]; - break; - case "top_left" : - $tx = $w1[x]; - $ty = $w1[y]; - break; - case "top_right" : - $tx = $sx - $wx - $w1[x]; - $ty = $w1[y]; - break; - case "bottom" : - $tx = (int)($sx/2 - $wx/2) + $w1[x]; - $ty = $sy - $w1[y] - $wy; - break; - case "bottom_left" : - $tx = $w1[x]; - $ty = $sy - $w1[y] - $wy; - break; - case "bottom_right" : - default : - $tx = $sx - $w1[x] - $wx; - $ty = $sy - $w1[y] - $wy; - } - imagecopyresampled($target, $w1_source, $tx, $ty, 0, 0, $wx, $wy, $wx, $wy); - } - } - - // php imagefilter - //if ($filter and $size[2] == 2) { //$size[2] == 2 , jpg - if ($filter) { - $filter_type = $filter[type]; - switch($filter_type) { - case IMG_FILTER_COLORIZE : imagefilter($target, $filter_type, $filter[arg1], $filter[arg2], $filter[arg3], $filter[arg4]); - break; - case IMG_FILTER_PIXELATE : imagefilter($target, $filter_type, $filter[arg1], $filter[arg2]); - break; - case IMG_FILTER_BRIGHTNESS : - case IMG_FILTER_CONTRAST : - case IMG_FILTER_SMOOTH : imagefilter($target, $filter_type, $filter[arg1]); - break; - case IMG_FILTER_NEGATE : - case IMG_FILTER_GRAYSCALE: - case IMG_FILTER_EDGEDETECT: - case IMG_FILTER_EMBOSS : - case IMG_FILTER_GAUSSIAN_BLUR : - case IMG_FILTER_SELECTIVE_BLUR: - case IMG_FILTER_MEAN_REMOVAL: imagefilter($target, $filter_type); - break; - case 99: UnsharpMask4($target, $filter[arg1], $filter[arg2], $filter[arg3]); - break; - default : ; // Ÿ Ʋ ƹ͵ մϴ - } - } - - $quality=100; - if ($size[2] == 1 || $thumb_type=="gif") - imagegif($target, $thumb_file, 100); // gif - else if ($size[2] == 2 || $thumb_type=="jpg") - imagejpeg($target, $thumb_file, 100); // jpeg - else if ($size[2] == 3 || $thumb_type=="png") { - // Turn off alpha blending and set alpha flag - imagealphablending($target, false); - imagesavealpha($target, true); - - imagepng($target, $thumb_file, 0); //imagepng Ƽ 0~9 մϴ (Lusia). 0(no compression) Դϴ - } - else - imagegif($target, $thumb_file, 100); - - @chmod($thumb_file, 0606); // Ͽ ϸ - - // ޸𸮸 νݴϴ - http://kr2.php.net/manual/kr/function.imagedestroy.php - if ($target) - imagedestroy($target); - if ($source) - imagedestroy($source); - if ($tmp_target) - imagedestroy($tmp_target); - - return str_replace($real_dir, "", $thumb_file); -} - -// php imagefilter for PHP4 - http://mgccl.com/2007/03/02/imagefilter-function-for-php-user-without-bundled-gd -// -//include this file whenever you have to use imageconvolution... -//you can use in your project, but keep the comment below :) -//great for any image manipulation library -//Made by Chao Xu(Mgccl) 3/1/07 -//www.webdevlogs.com -//V 1.0 -if(!function_exists('imagefilter')){ - function imagefilter($source, $var, $arg1 = null, $arg2 = null, $arg3 = null){ - #define('IMAGE_FILTER_NEGATE',0); - #define('IMAGE_FILTER_GRAYSCALE',0); - #define('IMAGE_FILTER_BRIGHTNESS',2); - #define('IMAGE_FILTER_CONTRAST',3); - #define('IMAGE_FILTER_COLORIZE',4); - #define('IMAGE_FILTER_EDGEDETECT',5); - #define('IMAGE_FILTER_EMBOSS',6); - #define('IMAGE_FILTER_GAUSSIAN_BLUR',7); - #define('IMAGE_FILTER_SELECTIVE_BLUR',8); - #define('IMAGE_FILTER_MEAN_REMOVAL',9); - #define('IMAGE_FILTER_SMOOTH',10); - $max_y = imagesy($source); - $max_x = imagesx($source); - switch ($var){ - case 0: - $y = 0; - while($y<$max_y) { - $x = 0; - while($x<$max_x){ - $rgb = imagecolorat($source,$x,$y); - $r = 255 - (($rgb >> 16) & 0xFF); - $g = 255 - (($rgb >> 8) & 0xFF); - $b = 255 - ($rgb & 0xFF); - $a = $rgb >> 24; - $new_pxl = imagecolorallocatealpha($source, $r, $g, $b, $a); - if ($new_pxl == false){ - $new_pxl = imagecolorclosestalpha($source, $r, $g, $b, $a); - } - imagesetpixel($source,$x,$y,$new_pxl); - ++$x; - } - ++$y; - } - return true; - break; - case 1: - $y = 0; - while($y<$max_y) { - $x = 0; - while($x<$max_x){ - $rgb = imagecolorat($source,$x,$y); - $a = $rgb >> 24; - $r = ((($rgb >> 16) & 0xFF)*0.299)+((($rgb >> 8) & 0xFF)*0.587)+(($rgb & 0xFF)*0.114); - $new_pxl = imagecolorallocatealpha($source, $r, $r, $r, $a); - if ($new_pxl == false){ - $new_pxl = imagecolorclosestalpha($source, $r, $r, $r, $a); - } - imagesetpixel($source,$x,$y,$new_pxl); - ++$x; - } - ++$y; - } - return true; - break; - case 2: - $y = 0; - while($y<$max_y) { - $x = 0; - while($x<$max_x){ - $rgb = imagecolorat($source,$x,$y); - $r = (($rgb >> 16) & 0xFF) + $arg1; - $g = (($rgb >> 8) & 0xFF) + $arg1; - $b = ($rgb & 0xFF) + $arg1; - $a = $rgb >> 24; - $r = ($r > 255)? 255 : (($r < 0)? 0:$r); - $g = ($g > 255)? 255 : (($g < 0)? 0:$g); - $b = ($b > 255)? 255 : (($b < 0)? 0:$b); - $new_pxl = imagecolorallocatealpha($source, $r, $g, $b, $a); - if ($new_pxl == false){ - $new_pxl = imagecolorclosestalpha($source, $r, $g, $b, $a); - } - imagesetpixel($source,$x,$y,$new_pxl); - ++$x; - } - ++$y; - } - return true; - break; - case 3: - $contrast = pow((100-$arg1)/100,2); - $y = 0; - while($y<$max_y) { - $x = 0; - while($x<$max_x){ - $rgb = imagecolorat($source,$x,$y); - $a = $rgb >> 24; - $r = (((((($rgb >> 16) & 0xFF)/255)-0.5)*$contrast)+0.5)*255; - $g = (((((($rgb >> 8) & 0xFF)/255)-0.5)*$contrast)+0.5)*255; - $b = ((((($rgb & 0xFF)/255)-0.5)*$contrast)+0.5)*255; - $r = ($r > 255)? 255 : (($r < 0)? 0:$r); - $g = ($g > 255)? 255 : (($g < 0)? 0:$g); - $b = ($b > 255)? 255 : (($b < 0)? 0:$b); - $new_pxl = imagecolorallocatealpha($source, $r, $g, $b, $a); - if ($new_pxl == false){ - $new_pxl = imagecolorclosestalpha($source, $r, $g, $b, $a); - } - imagesetpixel($source,$x,$y,$new_pxl); - ++$x; - } - ++$y; - } - return true; - break; - case 4: - $x = 0; - while($x<$max_x){ - $y = 0; - while($y<$max_y){ - $rgb = imagecolorat($source, $x, $y); - $r = (($rgb >> 16) & 0xFF) + $arg1; - $g = (($rgb >> 8) & 0xFF) + $arg2; - $b = ($rgb & 0xFF) + $arg3; - $a = $rgb >> 24; - $r = ($r > 255)? 255 : (($r < 0)? 0:$r); - $g = ($g > 255)? 255 : (($g < 0)? 0:$g); - $b = ($b > 255)? 255 : (($b < 0)? 0:$b); - $new_pxl = imagecolorallocatealpha($source, $r, $g, $b, $a); - if ($new_pxl == false){ - $new_pxl = imagecolorclosestalpha($source, $r, $g, $b, $a); - } - imagesetpixel($source,$x,$y,$new_pxl); - ++$y; - } - ++$x; - } - return true; - break; - case 5: - return imageconvolution($source, array(array(-1,0,-1), array(0,4,0), array(-1,0,-1)), 1, 127); - break; - case 6: - return imageconvolution($source, array(array(1.5, 0, 0), array(0, 0, 0), array(0, 0, -1.5)), 1, 127); - break; - case 7: - return imageconvolution($source, array(array(1, 2, 1), array(2, 4, 2), array(1, 2, 1)), 16, 0); - break; - case 8: - for($y = 0; $y<$max_y; $y++) { - for ($x = 0; $x<$max_x; $x++) { - $flt_r_sum = $flt_g_sum = $flt_b_sum = 0; - $cpxl = imagecolorat($source, $x, $y); - for ($j=0; $j<3; $j++) { - for ($i=0; $i<3; $i++) { - if (($j == 1) && ($i == 1)) { - $flt_r[1][1] = $flt_g[1][1] = $flt_b[1][1] = 0.5; - } else { - $pxl = imagecolorat($source, $x-(3>>1)+$i, $y-(3>>1)+$j); - - $new_a = $pxl >> 24; - //$r = (($pxl >> 16) & 0xFF); - //$g = (($pxl >> 8) & 0xFF); - //$b = ($pxl & 0xFF); - $new_r = abs((($cpxl >> 16) & 0xFF) - (($pxl >> 16) & 0xFF)); - if ($new_r != 0) { - $flt_r[$j][$i] = 1/$new_r; - } else { - $flt_r[$j][$i] = 1; - } - - $new_g = abs((($cpxl >> 8) & 0xFF) - (($pxl >> 8) & 0xFF)); - if ($new_g != 0) { - $flt_g[$j][$i] = 1/$new_g; - } else { - $flt_g[$j][$i] = 1; - } - - $new_b = abs(($cpxl & 0xFF) - ($pxl & 0xFF)); - if ($new_b != 0) { - $flt_b[$j][$i] = 1/$new_b; - } else { - $flt_b[$j][$i] = 1; - } - } - - $flt_r_sum += $flt_r[$j][$i]; - $flt_g_sum += $flt_g[$j][$i]; - $flt_b_sum += $flt_b[$j][$i]; - } - } - - for ($j=0; $j<3; $j++) { - for ($i=0; $i<3; $i++) { - if ($flt_r_sum != 0) { - $flt_r[$j][$i] /= $flt_r_sum; - } - if ($flt_g_sum != 0) { - $flt_g[$j][$i] /= $flt_g_sum; - } - if ($flt_b_sum != 0) { - $flt_b[$j][$i] /= $flt_b_sum; - } - } - } - - $new_r = $new_g = $new_b = 0; - - for ($j=0; $j<3; $j++) { - for ($i=0; $i<3; $i++) { - $pxl = imagecolorat($source, $x-(3>>1)+$i, $y-(3>>1)+$j); - $new_r += (($pxl >> 16) & 0xFF) * $flt_r[$j][$i]; - $new_g += (($pxl >> 8) & 0xFF) * $flt_g[$j][$i]; - $new_b += ($pxl & 0xFF) * $flt_b[$j][$i]; - } - } - - $new_r = ($new_r > 255)? 255 : (($new_r < 0)? 0:$new_r); - $new_g = ($new_g > 255)? 255 : (($new_g < 0)? 0:$new_g); - $new_b = ($new_b > 255)? 255 : (($new_b < 0)? 0:$new_b); - $new_pxl = ImageColorAllocateAlpha($source, (int)$new_r, (int)$new_g, (int)$new_b, $new_a); - if ($new_pxl == false) { - $new_pxl = ImageColorClosestAlpha($source, (int)$new_r, (int)$new_g, (int)$new_b, $new_a); - } - imagesetpixel($source,$x,$y,$new_pxl); - } - } - return true; - break; - case 9: - return imageconvolution($source, array(array(-1,-1,-1),array(-1,9,-1),array(-1,-1,-1)), 1, 0); - break; - case 10: - return imageconvolution($source, array(array(1,1,1),array(1,$arg1,1),array(1,1,1)), $arg1+8, 0); - break; - } - } -} - -if(!function_exists('file_path')){ -// θ ɴϴ (Ҵ, /lib/common.lib.php ǵ Լ) -function file_path($path) { - - $dir = dirname($path); - $file = basename($path); - - if (substr($dir,0,1) == "/") { - $real_dir = dirname($_SERVER['DOCUMENT_ROOT'] . "/nothing"); - $dir = $real_dir . $dir; - } - - return $dir . "/" . $file; -} -} - -//////////////////////////////////////////////////////////////////////////////////////////////// -//// -//// Unsharp Mask for PHP - version 2.1.1 -//// -//// Unsharp mask algorithm by Torstein Hnsi 2003-07. -//// thoensi_at_netcom_dot_no. -//// Please leave this notice. -//// -//// http://vikjavev.no/computing/ump.php -//// -/////////////////////////////////////////////////////////////////////////////////////////////// -if(!function_exists('UnsharpMask4')){ -function UnsharpMask4($img, $amount, $radius, $threshold) -{ - - // $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); break; } - $w = imagesx($img); $h = imagesy($img); - $imgCanvas = $img; - $imgCanvas2 = $img; - $imgBlur = imagecreatetruecolor($w, $h); - - // Gaussian blur matrix: - // 1 2 1 - // 2 4 2 - // 1 2 1 - - // 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, $imgCanvas, 0, 0, 1, 1, $w - 1, $h - 1); // up left - imagecopymerge ($imgBlur, $imgCanvas, 1, 1, 0, 0, $w, $h, 50); // down right - imagecopymerge ($imgBlur, $imgCanvas, 0, 1, 1, 0, $w - 1, $h, 33.33333); // down left - imagecopymerge ($imgBlur, $imgCanvas, 1, 0, 0, 1, $w, $h - 1, 25); // up right - imagecopymerge ($imgBlur, $imgCanvas, 0, 0, 1, 0, $w - 1, $h, 33.33333); // left - imagecopymerge ($imgBlur, $imgCanvas, 1, 0, 0, 0, $w, $h, 25); // right - imagecopymerge ($imgBlur, $imgCanvas, 0, 0, 0, 1, $w, $h - 1, 20 ); // up - imagecopymerge ($imgBlur, $imgCanvas, 0, 1, 0, 0, $w, $h, 16.666667); // down - imagecopymerge ($imgBlur, $imgCanvas, 0, 0, 0, 0, $w, $h, 50); // center - } - $imgCanvas = $imgBlur; - - // Calculate the difference between the blurred pixels and the original - // and set the pixels - for ($x = 0; $x < $w; $x++) - { // each row - for ($y = 0; $y < $h; $y++) - { // each pixel - $rgbOrig = ImageColorAt($imgCanvas2, $x, $y); - $rOrig = (($rgbOrig >> 16) & 0xFF); - $gOrig = (($rgbOrig >> 8) & 0xFF); - $bOrig = ($rgbOrig & 0xFF); - $rgbBlur = ImageColorAt($imgCanvas, $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); - } - } - } - return $img; -} -} - -/*********************************************/ -/* Fonction: ImageCreateFromBMP */ -/* Author: DHKold */ -/* Contact: admin@dhkold.com */ -/* Date: The 15th of June 2005 */ -/* Version: 2.0B */ -/*********************************************/ - -if(!function_exists('ImageCreateFromBMP')){ -function ImageCreateFromBMP($filename) -{ - //Ouverture du fichier en mode binaire - if (! $f1 = fopen($filename,"rb")) return FALSE; -echo $filename; - //1 : Chargement des ent?tes FICHIER - $FILE = unpack("vfile_type/Vfile_size/Vreserved/Vbitmap_offset", fread($f1,14)); - if ($FILE['file_type'] != 19778) return FALSE; - - //2 : Chargement des ent?tes BMP - $BMP = unpack('Vheader_size/Vwidth/Vheight/vplanes/vbits_per_pixel'. - '/Vcompression/Vsize_bitmap/Vhoriz_resolution'. - '/Vvert_resolution/Vcolors_used/Vcolors_important', fread($f1,40)); - $BMP['colors'] = pow(2,$BMP['bits_per_pixel']); - if ($BMP['size_bitmap'] == 0) $BMP['size_bitmap'] = $FILE['file_size'] - $FILE['bitmap_offset']; - $BMP['bytes_per_pixel'] = $BMP['bits_per_pixel']/8; - $BMP['bytes_per_pixel2'] = ceil($BMP['bytes_per_pixel']); - $BMP['decal'] = ($BMP['width']*$BMP['bytes_per_pixel']/4); - $BMP['decal'] -= floor($BMP['width']*$BMP['bytes_per_pixel']/4); - $BMP['decal'] = 4-(4*$BMP['decal']); - if ($BMP['decal'] == 4) $BMP['decal'] = 0; - - //3 : Chargement des couleurs de la palette - $PALETTE = array(); - if ($BMP['colors'] < 16777216) - { - $PALETTE = unpack('V'.$BMP['colors'], fread($f1,$BMP['colors']*4)); - } - - //4 : Cr?ation de l'image - $IMG = fread($f1,$BMP['size_bitmap']); - $VIDE = chr(0); - - $res = imagecreatetruecolor($BMP['width'],$BMP['height']); - $P = 0; - $Y = $BMP['height']-1; - while ($Y >= 0) - { - $X=0; - while ($X < $BMP['width']) - { - if ($BMP['bits_per_pixel'] == 24) - $COLOR = unpack("V",substr($IMG,$P,3).$VIDE); - elseif ($BMP['bits_per_pixel'] == 16) - { - $COLOR = unpack("v",substr($IMG,$P,2)); - $blue = (($COLOR[1] & 0x001f) << 3) + 7; - $green = (($COLOR[1] & 0x03e0) >> 2) + 7; - $red = (($COLOR[1] & 0xfc00) >> 7) + 7; - $COLOR[1] = $red * 65536 + $green * 256 + $blue; - } - elseif ($BMP['bits_per_pixel'] == 8) - { - $COLOR = unpack("n",$VIDE.substr($IMG,$P,1)); - $COLOR[1] = $PALETTE[$COLOR[1]+1]; - } - elseif ($BMP['bits_per_pixel'] == 4) - { - $COLOR = unpack("n",$VIDE.substr($IMG,floor($P),1)); - if (($P*2)%2 == 0) $COLOR[1] = ($COLOR[1] >> 4) ; else $COLOR[1] = ($COLOR[1] & 0x0F); - $COLOR[1] = $PALETTE[$COLOR[1]+1]; - } - elseif ($BMP['bits_per_pixel'] == 1) - { - $COLOR = unpack("n",$VIDE.substr($IMG,floor($P),1)); - if (($P*8)%8 == 0) $COLOR[1] = $COLOR[1] >>7; - elseif (($P*8)%8 == 1) $COLOR[1] = ($COLOR[1] & 0x40)>>6; - elseif (($P*8)%8 == 2) $COLOR[1] = ($COLOR[1] & 0x20)>>5; - elseif (($P*8)%8 == 3) $COLOR[1] = ($COLOR[1] & 0x10)>>4; - elseif (($P*8)%8 == 4) $COLOR[1] = ($COLOR[1] & 0x8)>>3; - elseif (($P*8)%8 == 5) $COLOR[1] = ($COLOR[1] & 0x4)>>2; - elseif (($P*8)%8 == 6) $COLOR[1] = ($COLOR[1] & 0x2)>>1; - elseif (($P*8)%8 == 7) $COLOR[1] = ($COLOR[1] & 0x1); - $COLOR[1] = $PALETTE[$COLOR[1]+1]; - } - else - return FALSE; - imagesetpixel($res,$X,$Y,$COLOR[1]); - $X++; - $P += $BMP['bytes_per_pixel']; - } - $Y--; - $P+=$BMP['decal']; - } - - //Fermeture du fichier - fclose($f1); - - return $res; -} -} - -// animated gif Ȯ -// http://kr2.php.net/imagecreatefromgif -/* -function is_ani_gif($filename) -{ - $filecontents=file_get_contents($filename); - - $str_loc=0; - $count=0; - while ($count < 2) # There is no point in continuing after we find a 2nd frame - { - - $where1=strpos($filecontents,"\x00\x21\xF9\x04",$str_loc); - if ($where1 === FALSE) - { - break; - } - else - { - $str_loc=$where1+1; - $where2=strpos($filecontents,"\x00\x2C",$str_loc); - if ($where2 === FALSE) - { - break; - } - else - { - if ($where1+8 == $where2) - { - $count++; - } - $str_loc=$where2+1; - } - } - } - - if ($count > 1) - { - return(true); - } - else - { - return(false); - } -} -*/ - -// psd - http://www.phpclasses.org/browse/file/17603.html - -/* This file is released under the GPL, any version you like -* PHP PSD reader class, v1.3 -* By Tim de Koning -* Kingsquare Information Services, 22 jan 2007 -* -* example use: -* ------------ -* -* -* More info, bugs or requests, contact info@kingsquare.nl -* -* Latest version and demo: http://www.kingsquare.nl/phppsdreader -* -* TODO -* ---- -* - read color values for "multichannel data" PSD files -* - find and implement (hunter)lab to RGB algorithm -* - fix 32 bit colors... has something to do with gamma and exposure available since CS2, but dunno how to read them... -*/ - - -class PhpPsdReader { - var $infoArray; - var $fp; - var $fileName; - var $tempFileName; - var $colorBytesLength; - - function PhpPsdReader($fileName) { - set_time_limit(0); - $this->infoArray = array(); - $this->fileName = $fileName; - $this->fp = fopen($this->fileName,'r'); - - if (fread($this->fp,4)=='8BPS') { - $this->infoArray['version id'] = $this->_getInteger(2); - fseek($this->fp,6,SEEK_CUR); // 6 bytes of 0's - $this->infoArray['channels'] = $this->_getInteger(2); - $this->infoArray['rows'] = $this->_getInteger(4); - $this->infoArray['columns'] = $this->_getInteger(4); - $this->infoArray['colorDepth'] = $this->_getInteger(2); - $this->infoArray['colorMode'] = $this->_getInteger(2); - - - /* COLOR MODE DATA SECTION */ //4bytes Length The length of the following color data. - $this->infoArray['colorModeDataSectionLength'] = $this->_getInteger(4); - fseek($this->fp,$this->infoArray['colorModeDataSectionLength'],SEEK_CUR); // ignore this snizzle - - /* IMAGE RESOURCES */ - $this->infoArray['imageResourcesSectionLength'] = $this->_getInteger(4); - fseek($this->fp,$this->infoArray['imageResourcesSectionLength'],SEEK_CUR); // ignore this snizzle - - /* LAYER AND MASK */ - $this->infoArray['layerMaskDataSectionLength'] = $this->_getInteger(4); - fseek($this->fp,$this->infoArray['layerMaskDataSectionLength'],SEEK_CUR); // ignore this snizzle - - - /* IMAGE DATA */ - $this->infoArray['compressionType'] = $this->_getInteger(2); - $this->infoArray['oneColorChannelPixelBytes'] = $this->infoArray['colorDepth']/8; - $this->colorBytesLength = $this->infoArray['rows']*$this->infoArray['columns']*$this->infoArray['oneColorChannelPixelBytes']; - - if ($this->infoArray['colorMode']==2) { - $this->infoArray['error'] = 'images with indexed colours are not supported yet'; - return false; - } - } else { - $this->infoArray['error'] = 'invalid or unsupported psd'; - return false; - } - } - - - function getImage() { - // decompress image data if required - switch($this->infoArray['compressionType']) { - // case 2:, case 3: zip not supported yet.. - case 1: - // packed bits - $this->infoArray['scanLinesByteCounts'] = array(); - for ($i=0; $i<($this->infoArray['rows']*$this->infoArray['channels']); $i++) $this->infoArray['scanLinesByteCounts'][] = $this->_getInteger(2); - $this->tempFileName = tempnam(realpath('/tmp'),'decompressedImageData'); - $tfp = fopen($this->tempFileName,'wb'); - foreach ($this->infoArray['scanLinesByteCounts'] as $scanLinesByteCount) { - fwrite($tfp,$this->_getPackedBitsDecoded(fread($this->fp,$scanLinesByteCount))); - } - fclose($tfp); - fclose($this->fp); - $this->fp = fopen($this->tempFileName,'r'); - default: - // continue with current file handle; - break; - } - - // let's write pixel by pixel.... - $image = imagecreatetruecolor($this->infoArray['columns'],$this->infoArray['rows']); - - for ($rowPointer = 0; ($rowPointer < $this->infoArray['rows']); $rowPointer++) { - for ($columnPointer = 0; ($columnPointer < $this->infoArray['columns']); $columnPointer++) { - /* The color mode of the file. Supported values are: Bitmap=0; - Grayscale=1; Indexed=2; RGB=3; CMYK=4; Multichannel=7; - Duotone=8; Lab=9. - */ - switch ($this->infoArray['colorMode']) { - case 2: // indexed... info should be able to extract from color mode data section. not implemented yet, so is grayscale - exit; - break; - case 0: - // bit by bit - if ($columnPointer == 0) $bitPointer = 0; - if ($bitPointer==0) $currentByteBits = str_pad(base_convert(bin2hex(fread($this->fp,1)), 16, 2),8,'0',STR_PAD_LEFT); - $r = $g = $b = (($currentByteBits[$bitPointer]=='1')?0:255); - $bitPointer++; - if ($bitPointer==8) $bitPointer = 0; - break; - - case 1: - case 8: // 8 is indexed with 1 color..., so grayscale - $r = $g = $b = $this->_getInteger($this->infoArray['oneColorChannelPixelBytes']); - break; - - case 4: // CMYK - $c = $this->_getInteger($this->infoArray['oneColorChannelPixelBytes']); - $currentPointerPos = ftell($this->fp); - fseek($this->fp,$this->colorBytesLength-1,SEEK_CUR); - $m = $this->_getInteger($this->infoArray['oneColorChannelPixelBytes']); - fseek($this->fp,$this->colorBytesLength-1,SEEK_CUR); - $y = $this->_getInteger($this->infoArray['oneColorChannelPixelBytes']); - fseek($this->fp,$this->colorBytesLength-1,SEEK_CUR); - $k = $this->_getInteger($this->infoArray['oneColorChannelPixelBytes']); - fseek($this->fp,$currentPointerPos); - $r = round(($c * $k) / (pow(2,$this->infoArray['colorDepth'])-1)); - $g = round(($m * $k) / (pow(2,$this->infoArray['colorDepth'])-1)); - $b = round(($y * $k) / (pow(2,$this->infoArray['colorDepth'])-1)); - - break; - - case 9: // hunter Lab - // i still need an understandable lab2rgb convert algorithm... if you have one, please let me know! - $l = $this->_getInteger($this->infoArray['oneColorChannelPixelBytes']); - $currentPointerPos = ftell($this->fp); - fseek($this->fp,$this->colorBytesLength-1,SEEK_CUR); - $a = $this->_getInteger($this->infoArray['oneColorChannelPixelBytes']); - fseek($this->fp,$this->colorBytesLength-1,SEEK_CUR); - $b = $this->_getInteger($this->infoArray['oneColorChannelPixelBytes']); - fseek($this->fp,$currentPointerPos); - - $r = $l; - $g = $a; - $b = $b; - - break; - default: - $r = $this->_getInteger($this->infoArray['oneColorChannelPixelBytes']); - $currentPointerPos = ftell($this->fp); - fseek($this->fp,$this->colorBytesLength-1,SEEK_CUR); - $g = $this->_getInteger($this->infoArray['oneColorChannelPixelBytes']); - fseek($this->fp,$this->colorBytesLength-1,SEEK_CUR); - $b = $this->_getInteger($this->infoArray['oneColorChannelPixelBytes']); - fseek($this->fp,$currentPointerPos); - break; - - } - - if (($this->infoArray['oneColorChannelPixelBytes']==2)) { - $r = $r >> 8; - $g = $g >> 8; - $b = $b >> 8; - } elseif (($this->infoArray['oneColorChannelPixelBytes']==4)) { - $r = $r >> 24; - $g = $g >> 24; - $b = $b >> 24; - } - - $pixelColor = imagecolorallocate($image,$r,$g,$b); - imagesetpixel($image,$columnPointer,$rowPointer,$pixelColor); - } - } - fclose($this->fp); - if (isset($this->tempFileName)) unlink($this->tempFileName); - return $image; - } - - /** - * - * PRIVATE FUNCTIONS - * - */ - - function _getPackedBitsDecoded($string) { - /* - The PackBits algorithm will precede a block of data with a one byte header n, where n is interpreted as follows: - n Meaning - 0 to 127 Copy the next n + 1 symbols verbatim - -127 to -1 Repeat the next symbol 1 - n times - -128 Do nothing - - Decoding: - Step 1. Read the block header (n). - Step 2. If the header is an EOF exit. - Step 3. If n is non-negative, copy the next n + 1 symbols to the output stream and go to step 1. - Step 4. If n is negative, write 1 - n copies of the next symbol to the output stream and go to step 1. - - */ - - $stringPointer = 0; - $returnString = ''; - - while (1) { - if (isset($string[$stringPointer])) $headerByteValue = $this->_unsignedToSigned(hexdec(bin2hex($string[$stringPointer])),1); - else return $returnString; - $stringPointer++; - - if ($headerByteValue >= 0) { - for ($i=0; $i <= $headerByteValue; $i++) { - $returnString .= $string[$stringPointer]; - $stringPointer++; - } - } else { - if ($headerByteValue != -128) { - $copyByte = $string[$stringPointer]; - $stringPointer++; - - for ($i=0; $i < (1-$headerByteValue); $i++) { - $returnString .= $copyByte; - } - } - } - } - } - - function _unsignedToSigned($int,$byteSize=1) { - switch($byteSize) { - case 1: - if ($int<128) return $int; - else return -256+$int; - break; - - case 2: - if ($int<32768) return $int; - else return -65536+$int; - - case 4: - if ($int<2147483648) return $int; - else return -4294967296+$int; - - default: - return $int; - } - } - - function _hexReverse($hex) { - $output = ''; - if (strlen($hex)%2) return false; - for ($pointer = strlen($hex);$pointer>=0;$pointer-=2) $output .= substr($hex,$pointer,2); - return $output; - } - - function _getInteger($byteCount=1) { - switch ($byteCount) { - case 4: - // for some strange reason this is still broken... - return @reset(unpack('N',fread($this->fp,4))); - break; - - case 2: - return @reset(unpack('n',fread($this->fp,2))); - break; - - default: - return hexdec($this->_hexReverse(bin2hex(fread($this->fp,$byteCount)))); - } - } -} - -/** - * Returns an image identifier representing the image obtained from the given filename, using only GD, returns an empty string on failure - * - * @param string $fileName - * @return image identifier - */ - -function imagecreatefrompsd($fileName) { - $psdReader = new PhpPsdReader($fileName); - if (isset($psdReader->infoArray['error'])) return ''; - else return $psdReader->getImage(); -} -?> diff --git a/tail.sub.php b/tail.sub.php index d343e9d15..af5d419c8 100644 --- a/tail.sub.php +++ b/tail.sub.php @@ -21,8 +21,6 @@ $(function() { -
    + @@ -20,18 +20,18 @@ if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가 - class="frm_input minlength_3 " maxlength="20"> + > 영문자, 숫자, _ 만 입력 가능. 최소 3자이상 입력하세요. - class="frm_input minlength_3 " maxlength="20"> + > - class="frm_input minlength_3 " maxlength="20"> + > @@ -40,7 +40,7 @@ if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가 - class="frm_input hangul nospace " size="10"> + > 공백없이 한글만 입력하세요."; } ?> @@ -49,7 +49,7 @@ if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가 - + 공백없이 한글,영문,숫자만 입력 가능 (한글2자, 영문4자 이상)
    @@ -60,10 +60,10 @@ if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가 - + - ' id="reg_mb_email" required class="frm_input email required" size="50" maxlength="100"> + " maxlength="100" size="50" value='' > @@ -76,14 +76,14 @@ if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가 - " size="50" maxlength="255"> + " maxlength="255" size="50" value=""> - " maxlength="20" > + " maxlength="20" value=""> @@ -93,8 +93,8 @@ if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가 - - + + @@ -108,12 +108,12 @@ if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가 필수 - " size="2" maxlength="3" > - - - " size="2" maxlength="3" > - 주소찾기 - " size="50" > - " size="50" > + " size="2" maxlength="3" value="" title="우편번호 앞자리"> + - + " size="2" maxlength="3" value="" title="우편번호 뒷자리"> + 주소찾기 + " size="50" value="" title="행정구역주소"> + " size="50" value="" title="상세주소"> @@ -124,24 +124,24 @@ if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가 - + - + -= $config['cf_icon_level']) { ?> += $config['cf_icon_level']) { ?> - + - + @@ -155,7 +155,7 @@ if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가 - > + > 정보 메일을 받겠습니다. @@ -164,7 +164,7 @@ if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가 - > + > 핸드폰 문자메세지를 받겠습니다. @@ -175,7 +175,7 @@ if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가 - > + > 다른분들이 나의 정보를 볼 수 있도록 합니다. 정보공개를 바꾸시면 앞으로 일 이내에는 변경이 안됩니다. @@ -198,7 +198,7 @@ if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가 - + @@ -209,8 +209,8 @@ if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
    - - 취소 + + 취소
    diff --git a/skin/member/kcpcert/register_form_update.tail.skin.php b/skin/member/kcpcert/register_form_update.tail.skin.php index 414359db4..922a1a2f6 100644 --- a/skin/member/kcpcert/register_form_update.tail.skin.php +++ b/skin/member/kcpcert/register_form_update.tail.skin.php @@ -1,5 +1,28 @@ From 9eb20840ce9bf3796dd9fe38bd795f1bb2309830 Mon Sep 17 00:00:00 2001 From: chicpro Date: Tue, 9 Apr 2013 13:06:17 +0900 Subject: [PATCH 48/63] =?UTF-8?q?=ED=9C=B4=EB=8C=80=ED=8F=B0=EC=9D=B8?= =?UTF-8?q?=EC=A6=9D=20=ED=9B=84=20=ED=8F=B0=EB=84=98=EB=B2=84=20=ED=8F=AC?= =?UTF-8?q?=EB=A7=B7=20=EB=B3=80=EA=B2=BD=20=ED=9B=84=20=EC=A0=80=EC=9E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bbs/kcp/kcpcert_result.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/bbs/kcp/kcpcert_result.php b/bbs/kcp/kcpcert_result.php index f32f6598b..8fbe2143b 100644 --- a/bbs/kcp/kcpcert_result.php +++ b/bbs/kcp/kcpcert_result.php @@ -153,6 +153,15 @@ else if( $cert_enc_use != "Y" ) } $ct_cert->mf_clear(); + +// 휴대폰번호 포맷변경 +$phone_no = preg_replace("/[^0-9]/", "", $phone_no); +$hp_len = strlen($phone_no); + +if($hp_len == 10) + $phone_no = preg_replace("/([0-9]{3})([0-9]{3})([0-9]{4})/", "\\1-\\2-\\3", $phone_no); +else if($hp_len == 11) + $phone_no = preg_replace("/([0-9]{3})([0-9]{4})([0-9]{4})/", "\\1-\\2-\\3", $phone_no); ?> diff --git a/skin/member/basic/register_form.skin.php b/skin/member/basic/register_form.skin.php index e67e37a0c..aca692bc9 100644 --- a/skin/member/basic/register_form.skin.php +++ b/skin/member/basic/register_form.skin.php @@ -94,9 +94,7 @@ if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가 - + 주소 @@ -106,9 +104,15 @@ if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가 title="우편번호 앞자리" class="frm_input " size="2" maxlength="3"> - title="우편번호 뒷자리" class="frm_input " size="2" maxlength="3"> - 주소찾기 + title="행정구역주소" class="frm_input frm_address " size="50"> title="상세주소" class="frm_input frm_address " size="50"> + @@ -213,11 +217,6 @@ if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가 From b95ec2b1774260c8d045f62ba9836672983d6459 Mon Sep 17 00:00:00 2001 From: whitedot Date: Wed, 10 Apr 2013 10:36:48 +0900 Subject: [PATCH 57/63] =?UTF-8?q?=EC=9A=B0=ED=8E=B8=EB=B2=88=ED=98=B8:=20?= =?UTF-8?q?=EC=9E=90=EB=B0=94=EC=8A=A4=ED=81=AC=EB=A6=BD=ED=8A=B8=20?= =?UTF-8?q?=EB=B9=84=ED=99=9C=EC=84=B1=ED=99=94=20=EB=8C=80=EC=9D=91,=20kc?= =?UTF-8?q?pcert=20=ED=8F=AC=ED=95=A82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- skin/member/kcpcert/register_form.skin.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/skin/member/kcpcert/register_form.skin.php b/skin/member/kcpcert/register_form.skin.php index 8d367bc22..adc197a67 100644 --- a/skin/member/kcpcert/register_form.skin.php +++ b/skin/member/kcpcert/register_form.skin.php @@ -99,9 +99,7 @@ if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가 - + 주소 From 7f32e1ea507773b003fb2e03a3b4b2194a5f9538 Mon Sep 17 00:00:00 2001 From: gnuboard Date: Wed, 10 Apr 2013 10:53:37 +0900 Subject: [PATCH 58/63] =?UTF-8?q?bbs/img=20=EB=94=94=EB=A0=89=ED=86=A0?= =?UTF-8?q?=EB=A6=AC=EA=B0=80=20=EC=97=86=EC=9C=BC=EB=AF=80=EB=A1=9C=20g4?= =?UTF-8?q?=5Fimg=5Furl=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- head.sub.php | 1 - 1 file changed, 1 deletion(-) diff --git a/head.sub.php b/head.sub.php index d6706e991..27ea33d45 100644 --- a/head.sub.php +++ b/head.sub.php @@ -68,7 +68,6 @@ if (!defined('G4_IS_ADMIN')) { // 자바스크립트에서 사용하는 전역변수 선언 var g4_url = ""; var g4_bbs_url = ""; -var g4_img_url = ""; var g4_is_member = ""; var g4_is_admin = ""; var g4_is_mobile = ""; From 4a3d12992d0505c0b7d79aba03cdeea334258aa5 Mon Sep 17 00:00:00 2001 From: whitedot Date: Wed, 10 Apr 2013 11:17:17 +0900 Subject: [PATCH 59/63] =?UTF-8?q?=EC=9A=B0=ED=8E=B8=EB=B2=88=ED=98=B8:=20?= =?UTF-8?q?=EB=AA=A8=EB=B0=94=EC=9D=BC=20=EC=9E=90=EB=B0=94=EC=8A=A4?= =?UTF-8?q?=ED=81=AC=EB=A6=BD=ED=8A=B8=20=EB=B9=84=ED=99=9C=EC=84=B1?= =?UTF-8?q?=ED=99=94=20=EB=8C=80=EC=9D=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../skin/member/basic/register_form.skin.php | 20 +++++++++++-------- .../member/kcpcert/register_form.skin.php | 16 ++++++++++----- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/mobile/skin/member/basic/register_form.skin.php b/mobile/skin/member/basic/register_form.skin.php index f3e42cb3a..325228568 100644 --- a/mobile/skin/member/basic/register_form.skin.php +++ b/mobile/skin/member/basic/register_form.skin.php @@ -94,21 +94,25 @@ if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가 - + 주소 필수 - " maxlength="3" > + title="우편번호 앞자리" class="frm_input " size="2" maxlength="3"> - - " maxlength="3" > - 주소찾기 - " > - " > + title="우편번호 뒷자리" class="frm_input " size="2" maxlength="3"> + + title="행정구역주소" class="frm_input frm_address " size="50"> + title="상세주소" class="frm_input frm_address " size="50"> + diff --git a/mobile/skin/member/kcpcert/register_form.skin.php b/mobile/skin/member/kcpcert/register_form.skin.php index 2a24f5f52..cb112d511 100644 --- a/mobile/skin/member/kcpcert/register_form.skin.php +++ b/mobile/skin/member/kcpcert/register_form.skin.php @@ -108,12 +108,18 @@ if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가 필수 - " size="2" maxlength="3" > + title="우편번호 앞자리" class="frm_input " size="2" maxlength="3"> - - " size="2" maxlength="3" > - 주소찾기 - " size="50" > - " size="50" > + title="우편번호 뒷자리" class="frm_input " size="2" maxlength="3"> + + title="행정구역주소" class="frm_input frm_address " size="50"> + title="상세주소" class="frm_input frm_address " size="50"> + From 072276da8bfb8949d1238d6981c140246e961194 Mon Sep 17 00:00:00 2001 From: gnuboard Date: Wed, 10 Apr 2013 11:21:04 +0900 Subject: [PATCH 60/63] =?UTF-8?q?=EA=B2=BD=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.php | 13 +++++++++---- skin/member/kcpcert/register_form.skin.php | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/config.php b/config.php index 8c27e698e..4e00f4d99 100644 --- a/config.php +++ b/config.php @@ -41,10 +41,13 @@ define('G4_EXTEND_DIR', 'extend'); define('G4_IMG_DIR', 'img'); define('G4_JS_DIR', 'js'); define('G4_LIB_DIR', 'lib'); +define('G4_PLUGIN_DIR', 'plugin'); define('G4_SKIN_DIR', 'skin'); define('G4_GCAPTCHA_DIR', 'gcaptcha'); define('G4_CKEDITOR_DIR', 'ckeditor'); define('G4_MOBILE_DIR', 'mobile'); +define('G4_KCP_DIR', 'kcp'); +define('G4_OKNAME_DIR', 'okname'); // URL 은 브라우저상에서의 경로 (도메인으로 부터의) if (G4_DOMAIN) { @@ -69,8 +72,9 @@ define('G4_DATA_URL', G4_URL.'/'.G4_DATA_DIR); define('G4_IMG_URL', G4_URL.'/'.G4_IMG_DIR); define('G4_JS_URL', G4_URL.'/'.G4_JS_DIR); define('G4_SKIN_URL', G4_URL.'/'.G4_SKIN_DIR); -define('G4_GCAPTCHA_URL', G4_BBS_URL.'/'.G4_GCAPTCHA_DIR); -define('G4_CKEDITOR_URL', G4_BBS_URL.'/'.G4_CKEDITOR_DIR); // CKEDITOR 의 라이브러리 경로 +define('G4_PLUGIN_URL', G4_URL.'/'.G4_PLUGIN_DIR); +define('G4_GCAPTCHA_URL', G4_PLUGIN_URL.'/'.G4_GCAPTCHA_DIR); +define('G4_CKEDITOR_URL', G4_PLUGIN_URL.'/'.G4_CKEDITOR_DIR); // CKEDITOR 의 라이브러리 경로 define('G4_MOBILE_URL', G4_URL.'/'.G4_MOBILE_DIR); // PATH 는 서버상에서의 절대경로 @@ -79,9 +83,10 @@ define('G4_BBS_PATH', G4_PATH.'/'.G4_BBS_DIR); define('G4_DATA_PATH', G4_PATH.'/'.G4_DATA_DIR); define('G4_EXTEND_PATH', G4_PATH.'/'.G4_EXTEND_DIR); define('G4_LIB_PATH', G4_PATH.'/'.G4_LIB_DIR); +define('G4_PLUGIN_PATH', G4_PATH.'/'.G4_PLUGIN_DIR); define('G4_SKIN_PATH', G4_PATH.'/'.G4_SKIN_DIR); -define('G4_GCAPTCHA_PATH', G4_BBS_PATH.'/'.G4_GCAPTCHA_DIR); -define('G4_CKEDITOR_PATH', G4_BBS_PATH.'/'.G4_CKEDITOR_DIR); +define('G4_GCAPTCHA_PATH', G4_PLUGIN_PATH.'/'.G4_GCAPTCHA_DIR); +define('G4_CKEDITOR_PATH', G4_PLUGIN_PATH.'/'.G4_CKEDITOR_DIR); define('G4_MOBILE_PATH', G4_PATH.'/'.G4_MOBILE_DIR); //============================================================================== diff --git a/skin/member/kcpcert/register_form.skin.php b/skin/member/kcpcert/register_form.skin.php index adc197a67..2f6e2e68e 100644 --- a/skin/member/kcpcert/register_form.skin.php +++ b/skin/member/kcpcert/register_form.skin.php @@ -219,7 +219,7 @@ if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가