Compare commits

...
8 Commits
26 changed files with 28624 additions and 28411 deletions

No files matched your search

+13
View File
@@ -414,6 +414,12 @@ if (!isset($config['cf_cert_use_seed'])) {
ADD COLUMN `cf_cert_use_seed` TINYINT(4) NOT NULL DEFAULT '1' AFTER `cf_cert_kg_mid`; "; ADD COLUMN `cf_cert_use_seed` TINYINT(4) NOT NULL DEFAULT '1' AFTER `cf_cert_kg_mid`; ";
sql_query($sql, false); sql_query($sql, false);
} }
if (!isset($config['cf_cert_kcp_enckey'])) {
$sql = "ALTER TABLE `{$g5['config_table']}`
ADD COLUMN `cf_cert_kcp_enckey` VARCHAR(100) NOT NULL DEFAULT '' AFTER `cf_cert_kcp_cd`; ";
sql_query($sql, false);
}
if (!$config['cf_faq_skin']) { if (!$config['cf_faq_skin']) {
$config['cf_faq_skin'] = "basic"; $config['cf_faq_skin'] = "basic";
} }
@@ -1066,6 +1072,13 @@ if ($config['cf_sms_use'] && $config['cf_icode_id'] && $config['cf_icode_pw']) {
<input type="text" name="cf_cert_kcp_cd" value="<?php echo get_sanitize_input($config['cf_cert_kcp_cd']); ?>" id="cf_cert_kcp_cd" class="frm_input" size="3"> <a href="http://sir.kr/main/service/p_cert.php" target="_blank" class="btn_frmline">NHN KCP 휴대폰 본인확인 서비스 신청페이지</a> <input type="text" name="cf_cert_kcp_cd" value="<?php echo get_sanitize_input($config['cf_cert_kcp_cd']); ?>" id="cf_cert_kcp_cd" class="frm_input" size="3"> <a href="http://sir.kr/main/service/p_cert.php" target="_blank" class="btn_frmline">NHN KCP 휴대폰 본인확인 서비스 신청페이지</a>
</td> </td>
</tr> </tr>
<tr>
<th scope="row" class="cf_cert_service"><label for="cf_cert_kcp_enckey">NHN KCP 가맹점 인증키</label></th>
<td class="cf_cert_service">
<?php echo help('NHN_KCP 상점관리자 > 기술관리센터 > 인증센터 > 가맹점 인증키관리 에서 인증키 발급 후에 인증키 정보를 입력해 주세요.<br>입력하지 않거나 잘못 입력시 휴대폰 본인확인을 취소 하셨습니다. 라고 메시지가 나오면서 창이 닫히는 오류가 발생됩니다.') ?>
<input type="text" name="cf_cert_kcp_enckey" value="<?php echo get_sanitize_input($config['cf_cert_kcp_enckey']); ?>" id="cf_cert_kcp_enckey" class="frm_input" maxlength="100" size="40"> <a href="https://partner.kcp.co.kr" target="_blank" class="btn_frmline">NHN KCP 상점관리자</a>
</td>
</tr>
<tr> <tr>
<th scope="row" class="cf_cert_service"><label for="cf_cert_limit">본인확인 이용제한</label></th> <th scope="row" class="cf_cert_service"><label for="cf_cert_limit">본인확인 이용제한</label></th>
<td class="cf_cert_service"> <td class="cf_cert_service">
+2 -1
View File
@@ -23,7 +23,7 @@ check_admin_token();
$cf_social_servicelist = !empty($_POST['cf_social_servicelist']) ? implode(',', $_POST['cf_social_servicelist']) : ''; $cf_social_servicelist = !empty($_POST['cf_social_servicelist']) ? implode(',', $_POST['cf_social_servicelist']) : '';
$check_keys = array('cf_cert_kcb_cd', 'cf_cert_kcp_cd', 'cf_editor', 'cf_recaptcha_site_key', 'cf_recaptcha_secret_key', 'cf_naver_clientid', 'cf_naver_secret', 'cf_facebook_appid', 'cf_facebook_secret', 'cf_twitter_key', 'cf_twitter_secret', 'cf_google_clientid', 'cf_google_secret', 'cf_googl_shorturl_apikey', 'cf_kakao_rest_key', 'cf_kakao_client_secret', 'cf_kakao_js_apikey', 'cf_payco_clientid', 'cf_payco_secret', 'cf_cert_kg_cd', 'cf_cert_kg_mid'); $check_keys = array('cf_cert_kcb_cd', 'cf_cert_kcp_cd', 'cf_cert_kcp_enckey', 'cf_editor', 'cf_recaptcha_site_key', 'cf_recaptcha_secret_key', 'cf_naver_clientid', 'cf_naver_secret', 'cf_facebook_appid', 'cf_facebook_secret', 'cf_twitter_key', 'cf_twitter_secret', 'cf_google_clientid', 'cf_google_secret', 'cf_googl_shorturl_apikey', 'cf_kakao_rest_key', 'cf_kakao_client_secret', 'cf_kakao_js_apikey', 'cf_payco_clientid', 'cf_payco_secret', 'cf_cert_kg_cd', 'cf_cert_kg_mid');
foreach ($check_keys as $key) { foreach ($check_keys as $key) {
if (isset($_POST[$key]) && $_POST[$key]) { if (isset($_POST[$key]) && $_POST[$key]) {
@@ -289,6 +289,7 @@ $sql = " update {$g5['config_table']}
cf_cert_kg_mid = '" . trim($_POST['cf_cert_kg_mid']) . "', cf_cert_kg_mid = '" . trim($_POST['cf_cert_kg_mid']) . "',
cf_cert_kcb_cd = '{$_POST['cf_cert_kcb_cd']}', cf_cert_kcb_cd = '{$_POST['cf_cert_kcb_cd']}',
cf_cert_kcp_cd = '{$_POST['cf_cert_kcp_cd']}', cf_cert_kcp_cd = '{$_POST['cf_cert_kcp_cd']}',
cf_cert_kcp_enckey = '{$_POST['cf_cert_kcp_enckey']}',
cf_cert_limit = '{$_POST['cf_cert_limit']}', cf_cert_limit = '{$_POST['cf_cert_limit']}',
cf_cert_req = '{$_POST['cf_cert_req']}', cf_cert_req = '{$_POST['cf_cert_req']}',
cf_sms_use = '{$_POST['cf_sms_use']}', cf_sms_use = '{$_POST['cf_sms_use']}',
+3 -3
View File
@@ -49,7 +49,7 @@ if ($csv == 'csv')
$to_date = date_conv($to_date); $to_date = date_conv($to_date);
$sql = " SELECT a.od_id, od_b_zip1, od_b_zip2, od_b_addr1, od_b_addr2, od_b_addr3, od_b_addr_jibeon, od_b_name, od_b_tel, od_b_hp, b.it_name, ct_qty, b.it_id, a.od_id, od_memo, od_invoice, b.ct_option, b.ct_send_cost, b.it_sc_type $sql = " SELECT a.od_id, od_b_zip1, od_b_zip2, od_b_addr1, od_b_addr2, od_b_addr3, od_b_addr_jibeon, od_b_name, od_b_tel, od_b_hp, b.it_name, ct_qty, b.it_id, od_memo, od_invoice, b.ct_option, b.ct_send_cost, b.it_sc_type
FROM {$g5['g5_shop_order_table']} a, {$g5['g5_shop_cart_table']} b FROM {$g5['g5_shop_order_table']} a, {$g5['g5_shop_cart_table']} b
where a.od_id = b.od_id "; where a.od_id = b.od_id ";
if ($case == 1) // 출력기간 if ($case == 1) // 출력기간
@@ -65,7 +65,7 @@ if ($csv == 'csv')
alert("출력할 내역이 없습니다."); alert("출력할 내역이 없습니다.");
//header('Content-Type: text/x-csv'); //header('Content-Type: text/x-csv');
header("Content-charset=utf-8"); header("Content-Type: text/csv; charset=utf-8");
header('Content-Type: doesn/matter'); header('Content-Type: doesn/matter');
header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT'); header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Content-Disposition: attachment; filename="orderlist-' . date("ymd", time()) . '.csv"'); header('Content-Disposition: attachment; filename="orderlist-' . date("ymd", time()) . '.csv"');
@@ -153,7 +153,7 @@ if ($csv == 'xls')
$fr_date = date_conv($fr_date); $fr_date = date_conv($fr_date);
$to_date = date_conv($to_date); $to_date = date_conv($to_date);
$sql = " SELECT a.od_id, od_b_zip1, od_b_zip2, od_b_addr1, od_b_addr2, od_b_addr3, od_b_addr_jibeon, od_b_name, od_b_tel, od_b_hp, b.it_name, ct_qty, b.it_id, a.od_id, od_memo, od_invoice, b.ct_option, b.ct_send_cost, b.it_sc_type $sql = " SELECT a.od_id, od_b_zip1, od_b_zip2, od_b_addr1, od_b_addr2, od_b_addr3, od_b_addr_jibeon, od_b_name, od_b_tel, od_b_hp, b.it_name, ct_qty, b.it_id, od_memo, od_invoice, b.ct_option, b.ct_send_cost, b.it_sc_type
FROM {$g5['g5_shop_order_table']} a, {$g5['g5_shop_cart_table']} b FROM {$g5['g5_shop_order_table']} a, {$g5['g5_shop_cart_table']} b
where a.od_id = b.od_id "; where a.od_id = b.od_id ";
if ($case == 1) // 출력기간 if ($case == 1) // 출력기간
-10
View File
@@ -62,16 +62,6 @@ if (!isset($_SERVER['SERVER_ADDR'])) {
$_SERVER['SERVER_ADDR'] = isset($_SERVER['LOCAL_ADDR']) ? $_SERVER['LOCAL_ADDR'] : ''; $_SERVER['SERVER_ADDR'] = isset($_SERVER['LOCAL_ADDR']) ? $_SERVER['LOCAL_ADDR'] : '';
} }
// Cloudflare 환경을 고려한 https 사용여부
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === "https") {
$_SERVER['HTTPS'] = 'on';
}
// Cloudflare 사용시 REMOTE_ADDR 에 사용자 IP 적용
if (isset($_SERVER['HTTP_CF_CONNECTING_IP'])) {
$_SERVER['REMOTE_ADDR'] = preg_replace('/[^0-9.]/', '', $_SERVER['HTTP_CF_CONNECTING_IP']);
}
// multi-dimensional array에 사용자지정 함수적용 // multi-dimensional array에 사용자지정 함수적용
function array_map_deep($fn, $array) function array_map_deep($fn, $array)
{ {
+5
View File
@@ -234,5 +234,10 @@ define('G5_VISIT_BROWSCAP_USE', false);
*/ */
define('G5_IP_DISPLAY', '\\1.♡.\\3.\\4'); define('G5_IP_DISPLAY', '\\1.♡.\\3.\\4');
// Cloudflare 사용시 REMOTE_ADDR 에 사용자 IP 적용과 https 사용 여부
if (isset($_SERVER['HTTP_CF_CONNECTING_IP'])) {
include_once(G5_LIB_PATH.'/cloudflare.lib.php'); // cloudflare 의 ip 대역인지 체크
}
// KAKAO 우편번호 서비스 CDN // KAKAO 우편번호 서비스 CDN
define('G5_POSTCODE_JS', '<script src="//t1.daumcdn.net/mapjsapi/bundle/postcode/prod/postcode.v2.js" async></script>'); define('G5_POSTCODE_JS', '<script src="//t1.daumcdn.net/mapjsapi/bundle/postcode/prod/postcode.v2.js" async></script>');
+2 -1
View File
@@ -295,6 +295,7 @@ CREATE TABLE IF NOT EXISTS `g5_config` (
`cf_cert_use_seed` tinyint(4) NOT NULL DEFAULT '1', `cf_cert_use_seed` tinyint(4) NOT NULL DEFAULT '1',
`cf_cert_kcb_cd` varchar(255) NOT NULL DEFAULT '', `cf_cert_kcb_cd` varchar(255) NOT NULL DEFAULT '',
`cf_cert_kcp_cd` varchar(255) NOT NULL DEFAULT '', `cf_cert_kcp_cd` varchar(255) NOT NULL DEFAULT '',
`cf_cert_kcp_enckey` varchar(100) NOT NULL DEFAULT '',
`cf_lg_mid` varchar(100) NOT NULL DEFAULT '', `cf_lg_mid` varchar(100) NOT NULL DEFAULT '',
`cf_lg_mert_key` varchar(100) NOT NULL DEFAULT '', `cf_lg_mert_key` varchar(100) NOT NULL DEFAULT '',
`cf_cert_limit` int(11) NOT NULL DEFAULT '0', `cf_cert_limit` int(11) NOT NULL DEFAULT '0',
@@ -909,7 +910,7 @@ CREATE TABLE IF NOT EXISTS `g5_member_social_profiles` (
`description` varchar(255) NOT NULL DEFAULT '', `description` varchar(255) NOT NULL DEFAULT '',
`mp_register_day` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `mp_register_day` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`mp_latest_day` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `mp_latest_day` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
UNIQUE KEY `mp_no` (`mp_no`), PRIMARY KEY (`mp_no`),
KEY `mb_id` (`mb_id`), KEY `mb_id` (`mb_id`),
KEY `provider` (`provider`) KEY `provider` (`provider`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8; ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+1 -1
View File
@@ -134,7 +134,7 @@ function no_comma(data)
function del(href) function del(href)
{ {
if(confirm("한번 삭제한 자료는 복구할 방법이 없습니다.\n\n정말 삭제하시겠습니까?")) { if(confirm("한번 삭제한 자료는 복구할 방법이 없습니다.\n\n정말 삭제하시겠습니까?")) {
document.location.href = href; window.location.href = href;
} }
} }
+112
View File
@@ -0,0 +1,112 @@
<?php
if (!defined('_GNUBOARD_')) exit;
// CloudFlare를 사용시, 사용자 환경에 맞는 $_SERVER['REMOTE_ADDR']과 $_SERVER['HTTPS'] 사용 여부를 수정합니다.
class G5CheckCloudFlare {
public static function check_cloudflare_ips($user_ip){
// 클라우드플레어 IP, https://www.cloudflare.com/ips
$cloudflare_ips = array(
// IPv4
'173.245.48.0/20',
'103.21.244.0/22',
'103.22.200.0/22',
'103.31.4.0/22',
'141.101.64.0/18',
'108.162.192.0/18',
'190.93.240.0/20',
'188.114.96.0/20',
'197.234.240.0/22',
'198.41.128.0/17',
'162.158.0.0/15',
'104.16.0.0/12',
'104.24.0.0/14',
'172.64.0.0/13',
'131.0.72.0/22',
// IPv6
'2400:cb00::/32',
'2606:4700::/32',
'2803:f800::/32',
'2405:b500::/32',
'2405:8100::/32',
'2a06:98c0::/29',
'2c0f:f248::/32',
);
// 사용자 IP가 Cloudflare IP 대역 범위에 있는지 확인
$is_cloudflare_ip = false;
foreach ($cloudflare_ips as $cidr) {
if (self::ip_in_range($user_ip, $cidr)) {
$is_cloudflare_ip = true;
break;
}
}
return $is_cloudflare_ip;
}
// IP 주소가 CIDR 범위 내에 있는지 확인하는 함수 (IPv4, IPv6 모두 가능)
public static function ip_in_range($ip, $range) {
// IPv4와 IPv6를 구분
if (strpos($range, ':') === false && preg_match('/^([0-9]{1,3}\.){3}[0-9]{1,3}$/', $ip)) {
// IPv4 처리
return self::ipv4_in_range($ip, $range);
} elseif (strpos($range, ':') !== false && strpos($ip, ':') !== false) {
// IPv6 처리
return self::ipv6_in_range($ip, $range);
}
return false;
}
// IPv4 CIDR 범위 검사
public static function ipv4_in_range($ip, $range) {
list($range, $netmask) = explode('/', $range, 2);
$range_decimal = ip2long($range);
$ip_decimal = ip2long($ip);
$wildcard_decimal = pow(2, (32 - $netmask)) - 1;
$netmask_decimal = ~$wildcard_decimal;
return (($ip_decimal & $netmask_decimal) == ($range_decimal & $netmask_decimal));
}
// IPv6 CIDR 범위 검사
public static function ipv6_in_range($ip, $range) {
list($range_ip, $netmask) = explode('/', $range, 2);
$netmask = (int) $netmask;
$ip_bin = @inet_pton($ip);
$range_bin = @inet_pton($range_ip);
// IPv6 주소는 128비트이므로, 비트마스크를 적용
$unpacked = unpack('A16', $ip_bin);
$ip_bits = $unpacked[1];
$unpacked2 = unpack('A16', $range_bin);
$range_bits = $unpacked2[1];
for ($i = 0; $i < (int)($netmask / 8); $i++) {
if ($ip_bits[$i] !== $range_bits[$i]) {
return false;
}
}
$remainder = $netmask % 8;
if ($remainder) {
$mask = 0xFF << (8 - $remainder);
return (ord($ip_bits[$i]) & $mask) === (ord($range_bits[$i]) & $mask);
}
return true;
}
}
if ($_SERVER['HTTP_CF_CONNECTING_IP'] && G5CheckCloudFlare::check_cloudflare_ips($_SERVER['REMOTE_ADDR'])) {
$_SERVER['REMOTE_ADDR'] = preg_replace('/[^0-9a-fA-F:.]/', '', $_SERVER['HTTP_CF_CONNECTING_IP']);
// Cloudflare 환경을 고려한 https 사용여부
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === "https") {
$_SERVER['HTTPS'] = 'on';
} elseif (isset($_SERVER['HTTP_CF_VISITOR']) && stripos($_SERVER['HTTP_CF_VISITOR'], 'https') !== false) {
$_SERVER['HTTPS'] = 'on';
}
}
+1 -1
View File
@@ -4,7 +4,7 @@ if (!defined('_GNUBOARD_')) exit;
// 최신글 추출 // 최신글 추출
// $cache_time 캐시 갱신시간 // $cache_time 캐시 갱신시간
function latest($skin_dir='', $bo_table, $rows=10, $subject_len=40, $cache_time=1, $options='') function latest($skin_dir='', $bo_table='', $rows=10, $subject_len=40, $cache_time=1, $options='')
{ {
global $g5; global $g5;
File diff suppressed because it is too large. Load diff
@@ -1,15 +1,15 @@
AutoFormat.RemoveEmpty.RemoveNbsp AutoFormat.RemoveEmpty.RemoveNbsp
TYPE: bool TYPE: bool
VERSION: 4.0.0 VERSION: 4.0.0
DEFAULT: false DEFAULT: false
--DESCRIPTION-- --DESCRIPTION--
<p> <p>
When enabled, HTML Purifier will treat any elements that contain only When enabled, HTML Purifier will treat any elements that contain only
non-breaking spaces as well as regular whitespace as empty, and remove non-breaking spaces as well as regular whitespace as empty, and remove
them when %AutoFormat.RemoveEmpty is enabled. them when %AutoFormat.RemoveEmpty is enabled.
</p> </p>
<p> <p>
See %AutoFormat.RemoveEmpty.RemoveNbsp.Exceptions for a list of elements See %AutoFormat.RemoveEmpty.RemoveNbsp.Exceptions for a list of elements
that don't have this behavior applied to them. that don't have this behavior applied to them.
</p> </p>
--# vim: et sw=4 sts=4 --# vim: et sw=4 sts=4
@@ -1,12 +1,12 @@
Core.AllowParseManyTags Core.AllowParseManyTags
TYPE: bool TYPE: bool
DEFAULT: false DEFAULT: false
VERSION: 4.10.1 VERSION: 4.10.1
--DESCRIPTION-- --DESCRIPTION--
<p> <p>
This directive allows parsing of many nested tags. This directive allows parsing of many nested tags.
If you set true, relaxes any hardcoded limit from the parser. If you set true, relaxes any hardcoded limit from the parser.
However, in that case it may cause a Dos attack. However, in that case it may cause a Dos attack.
Be careful when enabling it. Be careful when enabling it.
</p> </p>
--# vim: et sw=4 sts=4 --# vim: et sw=4 sts=4
@@ -1,160 +1,160 @@
Core.ColorKeywords Core.ColorKeywords
TYPE: hash TYPE: hash
VERSION: 2.0.0 VERSION: 2.0.0
--DEFAULT-- --DEFAULT--
array ( array (
'aliceblue' => '#F0F8FF', 'aliceblue' => '#F0F8FF',
'antiquewhite' => '#FAEBD7', 'antiquewhite' => '#FAEBD7',
'aqua' => '#00FFFF', 'aqua' => '#00FFFF',
'aquamarine' => '#7FFFD4', 'aquamarine' => '#7FFFD4',
'azure' => '#F0FFFF', 'azure' => '#F0FFFF',
'beige' => '#F5F5DC', 'beige' => '#F5F5DC',
'bisque' => '#FFE4C4', 'bisque' => '#FFE4C4',
'black' => '#000000', 'black' => '#000000',
'blanchedalmond' => '#FFEBCD', 'blanchedalmond' => '#FFEBCD',
'blue' => '#0000FF', 'blue' => '#0000FF',
'blueviolet' => '#8A2BE2', 'blueviolet' => '#8A2BE2',
'brown' => '#A52A2A', 'brown' => '#A52A2A',
'burlywood' => '#DEB887', 'burlywood' => '#DEB887',
'cadetblue' => '#5F9EA0', 'cadetblue' => '#5F9EA0',
'chartreuse' => '#7FFF00', 'chartreuse' => '#7FFF00',
'chocolate' => '#D2691E', 'chocolate' => '#D2691E',
'coral' => '#FF7F50', 'coral' => '#FF7F50',
'cornflowerblue' => '#6495ED', 'cornflowerblue' => '#6495ED',
'cornsilk' => '#FFF8DC', 'cornsilk' => '#FFF8DC',
'crimson' => '#DC143C', 'crimson' => '#DC143C',
'cyan' => '#00FFFF', 'cyan' => '#00FFFF',
'darkblue' => '#00008B', 'darkblue' => '#00008B',
'darkcyan' => '#008B8B', 'darkcyan' => '#008B8B',
'darkgoldenrod' => '#B8860B', 'darkgoldenrod' => '#B8860B',
'darkgray' => '#A9A9A9', 'darkgray' => '#A9A9A9',
'darkgrey' => '#A9A9A9', 'darkgrey' => '#A9A9A9',
'darkgreen' => '#006400', 'darkgreen' => '#006400',
'darkkhaki' => '#BDB76B', 'darkkhaki' => '#BDB76B',
'darkmagenta' => '#8B008B', 'darkmagenta' => '#8B008B',
'darkolivegreen' => '#556B2F', 'darkolivegreen' => '#556B2F',
'darkorange' => '#FF8C00', 'darkorange' => '#FF8C00',
'darkorchid' => '#9932CC', 'darkorchid' => '#9932CC',
'darkred' => '#8B0000', 'darkred' => '#8B0000',
'darksalmon' => '#E9967A', 'darksalmon' => '#E9967A',
'darkseagreen' => '#8FBC8F', 'darkseagreen' => '#8FBC8F',
'darkslateblue' => '#483D8B', 'darkslateblue' => '#483D8B',
'darkslategray' => '#2F4F4F', 'darkslategray' => '#2F4F4F',
'darkslategrey' => '#2F4F4F', 'darkslategrey' => '#2F4F4F',
'darkturquoise' => '#00CED1', 'darkturquoise' => '#00CED1',
'darkviolet' => '#9400D3', 'darkviolet' => '#9400D3',
'deeppink' => '#FF1493', 'deeppink' => '#FF1493',
'deepskyblue' => '#00BFFF', 'deepskyblue' => '#00BFFF',
'dimgray' => '#696969', 'dimgray' => '#696969',
'dimgrey' => '#696969', 'dimgrey' => '#696969',
'dodgerblue' => '#1E90FF', 'dodgerblue' => '#1E90FF',
'firebrick' => '#B22222', 'firebrick' => '#B22222',
'floralwhite' => '#FFFAF0', 'floralwhite' => '#FFFAF0',
'forestgreen' => '#228B22', 'forestgreen' => '#228B22',
'fuchsia' => '#FF00FF', 'fuchsia' => '#FF00FF',
'gainsboro' => '#DCDCDC', 'gainsboro' => '#DCDCDC',
'ghostwhite' => '#F8F8FF', 'ghostwhite' => '#F8F8FF',
'gold' => '#FFD700', 'gold' => '#FFD700',
'goldenrod' => '#DAA520', 'goldenrod' => '#DAA520',
'gray' => '#808080', 'gray' => '#808080',
'grey' => '#808080', 'grey' => '#808080',
'green' => '#008000', 'green' => '#008000',
'greenyellow' => '#ADFF2F', 'greenyellow' => '#ADFF2F',
'honeydew' => '#F0FFF0', 'honeydew' => '#F0FFF0',
'hotpink' => '#FF69B4', 'hotpink' => '#FF69B4',
'indianred' => '#CD5C5C', 'indianred' => '#CD5C5C',
'indigo' => '#4B0082', 'indigo' => '#4B0082',
'ivory' => '#FFFFF0', 'ivory' => '#FFFFF0',
'khaki' => '#F0E68C', 'khaki' => '#F0E68C',
'lavender' => '#E6E6FA', 'lavender' => '#E6E6FA',
'lavenderblush' => '#FFF0F5', 'lavenderblush' => '#FFF0F5',
'lawngreen' => '#7CFC00', 'lawngreen' => '#7CFC00',
'lemonchiffon' => '#FFFACD', 'lemonchiffon' => '#FFFACD',
'lightblue' => '#ADD8E6', 'lightblue' => '#ADD8E6',
'lightcoral' => '#F08080', 'lightcoral' => '#F08080',
'lightcyan' => '#E0FFFF', 'lightcyan' => '#E0FFFF',
'lightgoldenrodyellow' => '#FAFAD2', 'lightgoldenrodyellow' => '#FAFAD2',
'lightgray' => '#D3D3D3', 'lightgray' => '#D3D3D3',
'lightgrey' => '#D3D3D3', 'lightgrey' => '#D3D3D3',
'lightgreen' => '#90EE90', 'lightgreen' => '#90EE90',
'lightpink' => '#FFB6C1', 'lightpink' => '#FFB6C1',
'lightsalmon' => '#FFA07A', 'lightsalmon' => '#FFA07A',
'lightseagreen' => '#20B2AA', 'lightseagreen' => '#20B2AA',
'lightskyblue' => '#87CEFA', 'lightskyblue' => '#87CEFA',
'lightslategray' => '#778899', 'lightslategray' => '#778899',
'lightslategrey' => '#778899', 'lightslategrey' => '#778899',
'lightsteelblue' => '#B0C4DE', 'lightsteelblue' => '#B0C4DE',
'lightyellow' => '#FFFFE0', 'lightyellow' => '#FFFFE0',
'lime' => '#00FF00', 'lime' => '#00FF00',
'limegreen' => '#32CD32', 'limegreen' => '#32CD32',
'linen' => '#FAF0E6', 'linen' => '#FAF0E6',
'magenta' => '#FF00FF', 'magenta' => '#FF00FF',
'maroon' => '#800000', 'maroon' => '#800000',
'mediumaquamarine' => '#66CDAA', 'mediumaquamarine' => '#66CDAA',
'mediumblue' => '#0000CD', 'mediumblue' => '#0000CD',
'mediumorchid' => '#BA55D3', 'mediumorchid' => '#BA55D3',
'mediumpurple' => '#9370DB', 'mediumpurple' => '#9370DB',
'mediumseagreen' => '#3CB371', 'mediumseagreen' => '#3CB371',
'mediumslateblue' => '#7B68EE', 'mediumslateblue' => '#7B68EE',
'mediumspringgreen' => '#00FA9A', 'mediumspringgreen' => '#00FA9A',
'mediumturquoise' => '#48D1CC', 'mediumturquoise' => '#48D1CC',
'mediumvioletred' => '#C71585', 'mediumvioletred' => '#C71585',
'midnightblue' => '#191970', 'midnightblue' => '#191970',
'mintcream' => '#F5FFFA', 'mintcream' => '#F5FFFA',
'mistyrose' => '#FFE4E1', 'mistyrose' => '#FFE4E1',
'moccasin' => '#FFE4B5', 'moccasin' => '#FFE4B5',
'navajowhite' => '#FFDEAD', 'navajowhite' => '#FFDEAD',
'navy' => '#000080', 'navy' => '#000080',
'oldlace' => '#FDF5E6', 'oldlace' => '#FDF5E6',
'olive' => '#808000', 'olive' => '#808000',
'olivedrab' => '#6B8E23', 'olivedrab' => '#6B8E23',
'orange' => '#FFA500', 'orange' => '#FFA500',
'orangered' => '#FF4500', 'orangered' => '#FF4500',
'orchid' => '#DA70D6', 'orchid' => '#DA70D6',
'palegoldenrod' => '#EEE8AA', 'palegoldenrod' => '#EEE8AA',
'palegreen' => '#98FB98', 'palegreen' => '#98FB98',
'paleturquoise' => '#AFEEEE', 'paleturquoise' => '#AFEEEE',
'palevioletred' => '#DB7093', 'palevioletred' => '#DB7093',
'papayawhip' => '#FFEFD5', 'papayawhip' => '#FFEFD5',
'peachpuff' => '#FFDAB9', 'peachpuff' => '#FFDAB9',
'peru' => '#CD853F', 'peru' => '#CD853F',
'pink' => '#FFC0CB', 'pink' => '#FFC0CB',
'plum' => '#DDA0DD', 'plum' => '#DDA0DD',
'powderblue' => '#B0E0E6', 'powderblue' => '#B0E0E6',
'purple' => '#800080', 'purple' => '#800080',
'rebeccapurple' => '#663399', 'rebeccapurple' => '#663399',
'red' => '#FF0000', 'red' => '#FF0000',
'rosybrown' => '#BC8F8F', 'rosybrown' => '#BC8F8F',
'royalblue' => '#4169E1', 'royalblue' => '#4169E1',
'saddlebrown' => '#8B4513', 'saddlebrown' => '#8B4513',
'salmon' => '#FA8072', 'salmon' => '#FA8072',
'sandybrown' => '#F4A460', 'sandybrown' => '#F4A460',
'seagreen' => '#2E8B57', 'seagreen' => '#2E8B57',
'seashell' => '#FFF5EE', 'seashell' => '#FFF5EE',
'sienna' => '#A0522D', 'sienna' => '#A0522D',
'silver' => '#C0C0C0', 'silver' => '#C0C0C0',
'skyblue' => '#87CEEB', 'skyblue' => '#87CEEB',
'slateblue' => '#6A5ACD', 'slateblue' => '#6A5ACD',
'slategray' => '#708090', 'slategray' => '#708090',
'slategrey' => '#708090', 'slategrey' => '#708090',
'snow' => '#FFFAFA', 'snow' => '#FFFAFA',
'springgreen' => '#00FF7F', 'springgreen' => '#00FF7F',
'steelblue' => '#4682B4', 'steelblue' => '#4682B4',
'tan' => '#D2B48C', 'tan' => '#D2B48C',
'teal' => '#008080', 'teal' => '#008080',
'thistle' => '#D8BFD8', 'thistle' => '#D8BFD8',
'tomato' => '#FF6347', 'tomato' => '#FF6347',
'turquoise' => '#40E0D0', 'turquoise' => '#40E0D0',
'violet' => '#EE82EE', 'violet' => '#EE82EE',
'wheat' => '#F5DEB3', 'wheat' => '#F5DEB3',
'white' => '#FFFFFF', 'white' => '#FFFFFF',
'whitesmoke' => '#F5F5F5', 'whitesmoke' => '#F5F5F5',
'yellow' => '#FFFF00', 'yellow' => '#FFFF00',
'yellowgreen' => '#9ACD32' 'yellowgreen' => '#9ACD32'
) )
--DESCRIPTION-- --DESCRIPTION--
Lookup array of color names to six digit hexadecimal number corresponding Lookup array of color names to six digit hexadecimal number corresponding
to color, with preceding hash mark. Used when parsing colors. The lookup to color, with preceding hash mark. Used when parsing colors. The lookup
is done in a case-insensitive manner. is done in a case-insensitive manner.
--# vim: et sw=4 sts=4 --# vim: et sw=4 sts=4
@@ -1,11 +1,11 @@
HTML.Forms HTML.Forms
TYPE: bool TYPE: bool
VERSION: 4.13.0 VERSION: 4.13.0
DEFAULT: false DEFAULT: false
--DESCRIPTION-- --DESCRIPTION--
<p> <p>
Whether or not to permit form elements in the user input, regardless of Whether or not to permit form elements in the user input, regardless of
%HTML.Trusted value. Please be very careful when using this functionality, as %HTML.Trusted value. Please be very careful when using this functionality, as
enabling forms in untrusted documents may allow for phishing attacks. enabling forms in untrusted documents may allow for phishing attacks.
</p> </p>
--# vim: et sw=4 sts=4 --# vim: et sw=4 sts=4
File diff suppressed because it is too large. Load diff
@@ -1,451 +1,451 @@
<?php <?php
/** /**
* @todo Rewrite to use Interchange objects * @todo Rewrite to use Interchange objects
*/ */
class HTMLPurifier_Printer_ConfigForm extends HTMLPurifier_Printer class HTMLPurifier_Printer_ConfigForm extends HTMLPurifier_Printer
{ {
/** /**
* Printers for specific fields. * Printers for specific fields.
* @type HTMLPurifier_Printer[] * @type HTMLPurifier_Printer[]
*/ */
protected $fields = array(); protected $fields = array();
/** /**
* Documentation URL, can have fragment tagged on end. * Documentation URL, can have fragment tagged on end.
* @type string * @type string
*/ */
protected $docURL; protected $docURL;
/** /**
* Name of form element to stuff config in. * Name of form element to stuff config in.
* @type string * @type string
*/ */
protected $name; protected $name;
/** /**
* Whether or not to compress directive names, clipping them off * Whether or not to compress directive names, clipping them off
* after a certain amount of letters. False to disable or integer letters * after a certain amount of letters. False to disable or integer letters
* before clipping. * before clipping.
* @type bool * @type bool
*/ */
protected $compress = false; protected $compress = false;
/** /**
* @param string $name Form element name for directives to be stuffed into * @param string $name Form element name for directives to be stuffed into
* @param string $doc_url String documentation URL, will have fragment tagged on * @param string $doc_url String documentation URL, will have fragment tagged on
* @param bool $compress Integer max length before compressing a directive name, set to false to turn off * @param bool $compress Integer max length before compressing a directive name, set to false to turn off
*/ */
public function __construct( public function __construct(
$name, $name,
$doc_url = null, $doc_url = null,
$compress = false $compress = false
) { ) {
parent::__construct(); parent::__construct();
$this->docURL = $doc_url; $this->docURL = $doc_url;
$this->name = $name; $this->name = $name;
$this->compress = $compress; $this->compress = $compress;
// initialize sub-printers // initialize sub-printers
$this->fields[0] = new HTMLPurifier_Printer_ConfigForm_default(); $this->fields[0] = new HTMLPurifier_Printer_ConfigForm_default();
$this->fields[HTMLPurifier_VarParser::C_BOOL] = new HTMLPurifier_Printer_ConfigForm_bool(); $this->fields[HTMLPurifier_VarParser::C_BOOL] = new HTMLPurifier_Printer_ConfigForm_bool();
} }
/** /**
* Sets default column and row size for textareas in sub-printers * Sets default column and row size for textareas in sub-printers
* @param $cols Integer columns of textarea, null to use default * @param $cols Integer columns of textarea, null to use default
* @param $rows Integer rows of textarea, null to use default * @param $rows Integer rows of textarea, null to use default
*/ */
public function setTextareaDimensions($cols = null, $rows = null) public function setTextareaDimensions($cols = null, $rows = null)
{ {
if ($cols) { if ($cols) {
$this->fields['default']->cols = $cols; $this->fields['default']->cols = $cols;
} }
if ($rows) { if ($rows) {
$this->fields['default']->rows = $rows; $this->fields['default']->rows = $rows;
} }
} }
/** /**
* Retrieves styling, in case it is not accessible by webserver * Retrieves styling, in case it is not accessible by webserver
*/ */
public static function getCSS() public static function getCSS()
{ {
return file_get_contents(HTMLPURIFIER_PREFIX . '/HTMLPurifier/Printer/ConfigForm.css'); return file_get_contents(HTMLPURIFIER_PREFIX . '/HTMLPurifier/Printer/ConfigForm.css');
} }
/** /**
* Retrieves JavaScript, in case it is not accessible by webserver * Retrieves JavaScript, in case it is not accessible by webserver
*/ */
public static function getJavaScript() public static function getJavaScript()
{ {
return file_get_contents(HTMLPURIFIER_PREFIX . '/HTMLPurifier/Printer/ConfigForm.js'); return file_get_contents(HTMLPURIFIER_PREFIX . '/HTMLPurifier/Printer/ConfigForm.js');
} }
/** /**
* Returns HTML output for a configuration form * Returns HTML output for a configuration form
* @param HTMLPurifier_Config|array $config Configuration object of current form state, or an array * @param HTMLPurifier_Config|array $config Configuration object of current form state, or an array
* where [0] has an HTML namespace and [1] is being rendered. * where [0] has an HTML namespace and [1] is being rendered.
* @param array|bool $allowed Optional namespace(s) and directives to restrict form to. * @param array|bool $allowed Optional namespace(s) and directives to restrict form to.
* @param bool $render_controls * @param bool $render_controls
* @return string * @return string
*/ */
public function render($config, $allowed = true, $render_controls = true) public function render($config, $allowed = true, $render_controls = true)
{ {
if (is_array($config) && isset($config[0])) { if (is_array($config) && isset($config[0])) {
$gen_config = $config[0]; $gen_config = $config[0];
$config = $config[1]; $config = $config[1];
} else { } else {
$gen_config = $config; $gen_config = $config;
} }
$this->config = $config; $this->config = $config;
$this->genConfig = $gen_config; $this->genConfig = $gen_config;
$this->prepareGenerator($gen_config); $this->prepareGenerator($gen_config);
$allowed = HTMLPurifier_Config::getAllowedDirectivesForForm($allowed, $config->def); $allowed = HTMLPurifier_Config::getAllowedDirectivesForForm($allowed, $config->def);
$all = array(); $all = array();
foreach ($allowed as $key) { foreach ($allowed as $key) {
list($ns, $directive) = $key; list($ns, $directive) = $key;
$all[$ns][$directive] = $config->get($ns . '.' . $directive); $all[$ns][$directive] = $config->get($ns . '.' . $directive);
} }
$ret = ''; $ret = '';
$ret .= $this->start('table', array('class' => 'hp-config')); $ret .= $this->start('table', array('class' => 'hp-config'));
$ret .= $this->start('thead'); $ret .= $this->start('thead');
$ret .= $this->start('tr'); $ret .= $this->start('tr');
$ret .= $this->element('th', 'Directive', array('class' => 'hp-directive')); $ret .= $this->element('th', 'Directive', array('class' => 'hp-directive'));
$ret .= $this->element('th', 'Value', array('class' => 'hp-value')); $ret .= $this->element('th', 'Value', array('class' => 'hp-value'));
$ret .= $this->end('tr'); $ret .= $this->end('tr');
$ret .= $this->end('thead'); $ret .= $this->end('thead');
foreach ($all as $ns => $directives) { foreach ($all as $ns => $directives) {
$ret .= $this->renderNamespace($ns, $directives); $ret .= $this->renderNamespace($ns, $directives);
} }
if ($render_controls) { if ($render_controls) {
$ret .= $this->start('tbody'); $ret .= $this->start('tbody');
$ret .= $this->start('tr'); $ret .= $this->start('tr');
$ret .= $this->start('td', array('colspan' => 2, 'class' => 'controls')); $ret .= $this->start('td', array('colspan' => 2, 'class' => 'controls'));
$ret .= $this->elementEmpty('input', array('type' => 'submit', 'value' => 'Submit')); $ret .= $this->elementEmpty('input', array('type' => 'submit', 'value' => 'Submit'));
$ret .= '[<a href="?">Reset</a>]'; $ret .= '[<a href="?">Reset</a>]';
$ret .= $this->end('td'); $ret .= $this->end('td');
$ret .= $this->end('tr'); $ret .= $this->end('tr');
$ret .= $this->end('tbody'); $ret .= $this->end('tbody');
} }
$ret .= $this->end('table'); $ret .= $this->end('table');
return $ret; return $ret;
} }
/** /**
* Renders a single namespace * Renders a single namespace
* @param $ns String namespace name * @param $ns String namespace name
* @param array $directives array of directives to values * @param array $directives array of directives to values
* @return string * @return string
*/ */
protected function renderNamespace($ns, $directives) protected function renderNamespace($ns, $directives)
{ {
$ret = ''; $ret = '';
$ret .= $this->start('tbody', array('class' => 'namespace')); $ret .= $this->start('tbody', array('class' => 'namespace'));
$ret .= $this->start('tr'); $ret .= $this->start('tr');
$ret .= $this->element('th', $ns, array('colspan' => 2)); $ret .= $this->element('th', $ns, array('colspan' => 2));
$ret .= $this->end('tr'); $ret .= $this->end('tr');
$ret .= $this->end('tbody'); $ret .= $this->end('tbody');
$ret .= $this->start('tbody'); $ret .= $this->start('tbody');
foreach ($directives as $directive => $value) { foreach ($directives as $directive => $value) {
$ret .= $this->start('tr'); $ret .= $this->start('tr');
$ret .= $this->start('th'); $ret .= $this->start('th');
if ($this->docURL) { if ($this->docURL) {
$url = str_replace('%s', urlencode("$ns.$directive"), $this->docURL); $url = str_replace('%s', urlencode("$ns.$directive"), $this->docURL);
$ret .= $this->start('a', array('href' => $url)); $ret .= $this->start('a', array('href' => $url));
} }
$attr = array('for' => "{$this->name}:$ns.$directive"); $attr = array('for' => "{$this->name}:$ns.$directive");
// crop directive name if it's too long // crop directive name if it's too long
if (!$this->compress || (strlen($directive) < $this->compress)) { if (!$this->compress || (strlen($directive) < $this->compress)) {
$directive_disp = $directive; $directive_disp = $directive;
} else { } else {
$directive_disp = substr($directive, 0, $this->compress - 2) . '...'; $directive_disp = substr($directive, 0, $this->compress - 2) . '...';
$attr['title'] = $directive; $attr['title'] = $directive;
} }
$ret .= $this->element( $ret .= $this->element(
'label', 'label',
$directive_disp, $directive_disp,
// component printers must create an element with this id // component printers must create an element with this id
$attr $attr
); );
if ($this->docURL) { if ($this->docURL) {
$ret .= $this->end('a'); $ret .= $this->end('a');
} }
$ret .= $this->end('th'); $ret .= $this->end('th');
$ret .= $this->start('td'); $ret .= $this->start('td');
$def = $this->config->def->info["$ns.$directive"]; $def = $this->config->def->info["$ns.$directive"];
if (is_int($def)) { if (is_int($def)) {
$allow_null = $def < 0; $allow_null = $def < 0;
$type = abs($def); $type = abs($def);
} else { } else {
$type = $def->type; $type = $def->type;
$allow_null = isset($def->allow_null); $allow_null = isset($def->allow_null);
} }
if (!isset($this->fields[$type])) { if (!isset($this->fields[$type])) {
$type = 0; $type = 0;
} // default } // default
$type_obj = $this->fields[$type]; $type_obj = $this->fields[$type];
if ($allow_null) { if ($allow_null) {
$type_obj = new HTMLPurifier_Printer_ConfigForm_NullDecorator($type_obj); $type_obj = new HTMLPurifier_Printer_ConfigForm_NullDecorator($type_obj);
} }
$ret .= $type_obj->render($ns, $directive, $value, $this->name, array($this->genConfig, $this->config)); $ret .= $type_obj->render($ns, $directive, $value, $this->name, array($this->genConfig, $this->config));
$ret .= $this->end('td'); $ret .= $this->end('td');
$ret .= $this->end('tr'); $ret .= $this->end('tr');
} }
$ret .= $this->end('tbody'); $ret .= $this->end('tbody');
return $ret; return $ret;
} }
} }
/** /**
* Printer decorator for directives that accept null * Printer decorator for directives that accept null
*/ */
class HTMLPurifier_Printer_ConfigForm_NullDecorator extends HTMLPurifier_Printer class HTMLPurifier_Printer_ConfigForm_NullDecorator extends HTMLPurifier_Printer
{ {
/** /**
* Printer being decorated * Printer being decorated
* @type HTMLPurifier_Printer * @type HTMLPurifier_Printer
*/ */
protected $obj; protected $obj;
/** /**
* @param HTMLPurifier_Printer $obj Printer to decorate * @param HTMLPurifier_Printer $obj Printer to decorate
*/ */
public function __construct($obj) public function __construct($obj)
{ {
parent::__construct(); parent::__construct();
$this->obj = $obj; $this->obj = $obj;
} }
/** /**
* @param string $ns * @param string $ns
* @param string $directive * @param string $directive
* @param string $value * @param string $value
* @param string $name * @param string $name
* @param HTMLPurifier_Config|array $config * @param HTMLPurifier_Config|array $config
* @return string * @return string
*/ */
public function render($ns, $directive, $value, $name, $config) public function render($ns, $directive, $value, $name, $config)
{ {
if (is_array($config) && isset($config[0])) { if (is_array($config) && isset($config[0])) {
$gen_config = $config[0]; $gen_config = $config[0];
$config = $config[1]; $config = $config[1];
} else { } else {
$gen_config = $config; $gen_config = $config;
} }
$this->prepareGenerator($gen_config); $this->prepareGenerator($gen_config);
$ret = ''; $ret = '';
$ret .= $this->start('label', array('for' => "$name:Null_$ns.$directive")); $ret .= $this->start('label', array('for' => "$name:Null_$ns.$directive"));
$ret .= $this->element('span', "$ns.$directive:", array('class' => 'verbose')); $ret .= $this->element('span', "$ns.$directive:", array('class' => 'verbose'));
$ret .= $this->text(' Null/Disabled'); $ret .= $this->text(' Null/Disabled');
$ret .= $this->end('label'); $ret .= $this->end('label');
$attr = array( $attr = array(
'type' => 'checkbox', 'type' => 'checkbox',
'value' => '1', 'value' => '1',
'class' => 'null-toggle', 'class' => 'null-toggle',
'name' => "$name" . "[Null_$ns.$directive]", 'name' => "$name" . "[Null_$ns.$directive]",
'id' => "$name:Null_$ns.$directive", 'id' => "$name:Null_$ns.$directive",
'onclick' => "toggleWriteability('$name:$ns.$directive',checked)" // INLINE JAVASCRIPT!!!! 'onclick' => "toggleWriteability('$name:$ns.$directive',checked)" // INLINE JAVASCRIPT!!!!
); );
if ($this->obj instanceof HTMLPurifier_Printer_ConfigForm_bool) { if ($this->obj instanceof HTMLPurifier_Printer_ConfigForm_bool) {
// modify inline javascript slightly // modify inline javascript slightly
$attr['onclick'] = $attr['onclick'] =
"toggleWriteability('$name:Yes_$ns.$directive',checked);" . "toggleWriteability('$name:Yes_$ns.$directive',checked);" .
"toggleWriteability('$name:No_$ns.$directive',checked)"; "toggleWriteability('$name:No_$ns.$directive',checked)";
} }
if ($value === null) { if ($value === null) {
$attr['checked'] = 'checked'; $attr['checked'] = 'checked';
} }
$ret .= $this->elementEmpty('input', $attr); $ret .= $this->elementEmpty('input', $attr);
$ret .= $this->text(' or '); $ret .= $this->text(' or ');
$ret .= $this->elementEmpty('br'); $ret .= $this->elementEmpty('br');
$ret .= $this->obj->render($ns, $directive, $value, $name, array($gen_config, $config)); $ret .= $this->obj->render($ns, $directive, $value, $name, array($gen_config, $config));
return $ret; return $ret;
} }
} }
/** /**
* Swiss-army knife configuration form field printer * Swiss-army knife configuration form field printer
*/ */
class HTMLPurifier_Printer_ConfigForm_default extends HTMLPurifier_Printer class HTMLPurifier_Printer_ConfigForm_default extends HTMLPurifier_Printer
{ {
/** /**
* @type int * @type int
*/ */
public $cols = 18; public $cols = 18;
/** /**
* @type int * @type int
*/ */
public $rows = 5; public $rows = 5;
/** /**
* @param string $ns * @param string $ns
* @param string $directive * @param string $directive
* @param string $value * @param string $value
* @param string $name * @param string $name
* @param HTMLPurifier_Config|array $config * @param HTMLPurifier_Config|array $config
* @return string * @return string
*/ */
public function render($ns, $directive, $value, $name, $config) public function render($ns, $directive, $value, $name, $config)
{ {
if (is_array($config) && isset($config[0])) { if (is_array($config) && isset($config[0])) {
$gen_config = $config[0]; $gen_config = $config[0];
$config = $config[1]; $config = $config[1];
} else { } else {
$gen_config = $config; $gen_config = $config;
} }
$this->prepareGenerator($gen_config); $this->prepareGenerator($gen_config);
// this should probably be split up a little // this should probably be split up a little
$ret = ''; $ret = '';
$def = $config->def->info["$ns.$directive"]; $def = $config->def->info["$ns.$directive"];
if (is_int($def)) { if (is_int($def)) {
$type = abs($def); $type = abs($def);
} else { } else {
$type = $def->type; $type = $def->type;
} }
if (is_array($value)) { if (is_array($value)) {
switch ($type) { switch ($type) {
case HTMLPurifier_VarParser::LOOKUP: case HTMLPurifier_VarParser::LOOKUP:
$array = $value; $array = $value;
$value = array(); $value = array();
foreach ($array as $val => $b) { foreach ($array as $val => $b) {
$value[] = $val; $value[] = $val;
} }
//TODO does this need a break? //TODO does this need a break?
case HTMLPurifier_VarParser::ALIST: case HTMLPurifier_VarParser::ALIST:
$value = implode(PHP_EOL, $value); $value = implode(PHP_EOL, $value);
break; break;
case HTMLPurifier_VarParser::HASH: case HTMLPurifier_VarParser::HASH:
$nvalue = ''; $nvalue = '';
foreach ($value as $i => $v) { foreach ($value as $i => $v) {
if (is_array($v)) { if (is_array($v)) {
// HACK // HACK
$v = implode(";", $v); $v = implode(";", $v);
} }
$nvalue .= "$i:$v" . PHP_EOL; $nvalue .= "$i:$v" . PHP_EOL;
} }
$value = $nvalue; $value = $nvalue;
break; break;
default: default:
$value = ''; $value = '';
} }
} }
if ($type === HTMLPurifier_VarParser::C_MIXED) { if ($type === HTMLPurifier_VarParser::C_MIXED) {
return 'Not supported'; return 'Not supported';
$value = serialize($value); $value = serialize($value);
} }
$attr = array( $attr = array(
'name' => "$name" . "[$ns.$directive]", 'name' => "$name" . "[$ns.$directive]",
'id' => "$name:$ns.$directive" 'id' => "$name:$ns.$directive"
); );
if ($value === null) { if ($value === null) {
$attr['disabled'] = 'disabled'; $attr['disabled'] = 'disabled';
} }
if (isset($def->allowed)) { if (isset($def->allowed)) {
$ret .= $this->start('select', $attr); $ret .= $this->start('select', $attr);
foreach ($def->allowed as $val => $b) { foreach ($def->allowed as $val => $b) {
$attr = array(); $attr = array();
if ($value == $val) { if ($value == $val) {
$attr['selected'] = 'selected'; $attr['selected'] = 'selected';
} }
$ret .= $this->element('option', $val, $attr); $ret .= $this->element('option', $val, $attr);
} }
$ret .= $this->end('select'); $ret .= $this->end('select');
} elseif ($type === HTMLPurifier_VarParser::TEXT || } elseif ($type === HTMLPurifier_VarParser::TEXT ||
$type === HTMLPurifier_VarParser::ITEXT || $type === HTMLPurifier_VarParser::ITEXT ||
$type === HTMLPurifier_VarParser::ALIST || $type === HTMLPurifier_VarParser::ALIST ||
$type === HTMLPurifier_VarParser::HASH || $type === HTMLPurifier_VarParser::HASH ||
$type === HTMLPurifier_VarParser::LOOKUP) { $type === HTMLPurifier_VarParser::LOOKUP) {
$attr['cols'] = $this->cols; $attr['cols'] = $this->cols;
$attr['rows'] = $this->rows; $attr['rows'] = $this->rows;
$ret .= $this->start('textarea', $attr); $ret .= $this->start('textarea', $attr);
$ret .= $this->text($value); $ret .= $this->text($value);
$ret .= $this->end('textarea'); $ret .= $this->end('textarea');
} else { } else {
$attr['value'] = $value; $attr['value'] = $value;
$attr['type'] = 'text'; $attr['type'] = 'text';
$ret .= $this->elementEmpty('input', $attr); $ret .= $this->elementEmpty('input', $attr);
} }
return $ret; return $ret;
} }
} }
/** /**
* Bool form field printer * Bool form field printer
*/ */
class HTMLPurifier_Printer_ConfigForm_bool extends HTMLPurifier_Printer class HTMLPurifier_Printer_ConfigForm_bool extends HTMLPurifier_Printer
{ {
/** /**
* @param string $ns * @param string $ns
* @param string $directive * @param string $directive
* @param string $value * @param string $value
* @param string $name * @param string $name
* @param HTMLPurifier_Config|array $config * @param HTMLPurifier_Config|array $config
* @return string * @return string
*/ */
public function render($ns, $directive, $value, $name, $config) public function render($ns, $directive, $value, $name, $config)
{ {
if (is_array($config) && isset($config[0])) { if (is_array($config) && isset($config[0])) {
$gen_config = $config[0]; $gen_config = $config[0];
$config = $config[1]; $config = $config[1];
} else { } else {
$gen_config = $config; $gen_config = $config;
} }
$this->prepareGenerator($gen_config); $this->prepareGenerator($gen_config);
$ret = ''; $ret = '';
$ret .= $this->start('div', array('id' => "$name:$ns.$directive")); $ret .= $this->start('div', array('id' => "$name:$ns.$directive"));
$ret .= $this->start('label', array('for' => "$name:Yes_$ns.$directive")); $ret .= $this->start('label', array('for' => "$name:Yes_$ns.$directive"));
$ret .= $this->element('span', "$ns.$directive:", array('class' => 'verbose')); $ret .= $this->element('span', "$ns.$directive:", array('class' => 'verbose'));
$ret .= $this->text(' Yes'); $ret .= $this->text(' Yes');
$ret .= $this->end('label'); $ret .= $this->end('label');
$attr = array( $attr = array(
'type' => 'radio', 'type' => 'radio',
'name' => "$name" . "[$ns.$directive]", 'name' => "$name" . "[$ns.$directive]",
'id' => "$name:Yes_$ns.$directive", 'id' => "$name:Yes_$ns.$directive",
'value' => '1' 'value' => '1'
); );
if ($value === true) { if ($value === true) {
$attr['checked'] = 'checked'; $attr['checked'] = 'checked';
} }
if ($value === null) { if ($value === null) {
$attr['disabled'] = 'disabled'; $attr['disabled'] = 'disabled';
} }
$ret .= $this->elementEmpty('input', $attr); $ret .= $this->elementEmpty('input', $attr);
$ret .= $this->start('label', array('for' => "$name:No_$ns.$directive")); $ret .= $this->start('label', array('for' => "$name:No_$ns.$directive"));
$ret .= $this->element('span', "$ns.$directive:", array('class' => 'verbose')); $ret .= $this->element('span', "$ns.$directive:", array('class' => 'verbose'));
$ret .= $this->text(' No'); $ret .= $this->text(' No');
$ret .= $this->end('label'); $ret .= $this->end('label');
$attr = array( $attr = array(
'type' => 'radio', 'type' => 'radio',
'name' => "$name" . "[$ns.$directive]", 'name' => "$name" . "[$ns.$directive]",
'id' => "$name:No_$ns.$directive", 'id' => "$name:No_$ns.$directive",
'value' => '0' 'value' => '0'
); );
if ($value === false) { if ($value === false) {
$attr['checked'] = 'checked'; $attr['checked'] = 'checked';
} }
if ($value === null) { if ($value === null) {
$attr['disabled'] = 'disabled'; $attr['disabled'] = 'disabled';
} }
$ret .= $this->elementEmpty('input', $attr); $ret .= $this->elementEmpty('input', $attr);
$ret .= $this->end('div'); $ret .= $this->end('div');
return $ret; return $ret;
} }
} }
// vim: et sw=4 sts=4 // vim: et sw=4 sts=4
@@ -1,324 +1,324 @@
<?php <?php
class HTMLPurifier_Printer_HTMLDefinition extends HTMLPurifier_Printer class HTMLPurifier_Printer_HTMLDefinition extends HTMLPurifier_Printer
{ {
/** /**
* @type HTMLPurifier_HTMLDefinition, for easy access * @type HTMLPurifier_HTMLDefinition, for easy access
*/ */
protected $def; protected $def;
/** /**
* @param HTMLPurifier_Config $config * @param HTMLPurifier_Config $config
* @return string * @return string
*/ */
public function render($config) public function render($config)
{ {
$ret = ''; $ret = '';
$this->config =& $config; $this->config =& $config;
$this->def = $config->getHTMLDefinition(); $this->def = $config->getHTMLDefinition();
$ret .= $this->start('div', array('class' => 'HTMLPurifier_Printer')); $ret .= $this->start('div', array('class' => 'HTMLPurifier_Printer'));
$ret .= $this->renderDoctype(); $ret .= $this->renderDoctype();
$ret .= $this->renderEnvironment(); $ret .= $this->renderEnvironment();
$ret .= $this->renderContentSets(); $ret .= $this->renderContentSets();
$ret .= $this->renderInfo(); $ret .= $this->renderInfo();
$ret .= $this->end('div'); $ret .= $this->end('div');
return $ret; return $ret;
} }
/** /**
* Renders the Doctype table * Renders the Doctype table
* @return string * @return string
*/ */
protected function renderDoctype() protected function renderDoctype()
{ {
$doctype = $this->def->doctype; $doctype = $this->def->doctype;
$ret = ''; $ret = '';
$ret .= $this->start('table'); $ret .= $this->start('table');
$ret .= $this->element('caption', 'Doctype'); $ret .= $this->element('caption', 'Doctype');
$ret .= $this->row('Name', $doctype->name); $ret .= $this->row('Name', $doctype->name);
$ret .= $this->row('XML', $doctype->xml ? 'Yes' : 'No'); $ret .= $this->row('XML', $doctype->xml ? 'Yes' : 'No');
$ret .= $this->row('Default Modules', implode(', ', $doctype->modules)); $ret .= $this->row('Default Modules', implode(', ', $doctype->modules));
$ret .= $this->row('Default Tidy Modules', implode(', ', $doctype->tidyModules)); $ret .= $this->row('Default Tidy Modules', implode(', ', $doctype->tidyModules));
$ret .= $this->end('table'); $ret .= $this->end('table');
return $ret; return $ret;
} }
/** /**
* Renders environment table, which is miscellaneous info * Renders environment table, which is miscellaneous info
* @return string * @return string
*/ */
protected function renderEnvironment() protected function renderEnvironment()
{ {
$def = $this->def; $def = $this->def;
$ret = ''; $ret = '';
$ret .= $this->start('table'); $ret .= $this->start('table');
$ret .= $this->element('caption', 'Environment'); $ret .= $this->element('caption', 'Environment');
$ret .= $this->row('Parent of fragment', $def->info_parent); $ret .= $this->row('Parent of fragment', $def->info_parent);
$ret .= $this->renderChildren($def->info_parent_def->child); $ret .= $this->renderChildren($def->info_parent_def->child);
$ret .= $this->row('Block wrap name', $def->info_block_wrapper); $ret .= $this->row('Block wrap name', $def->info_block_wrapper);
$ret .= $this->start('tr'); $ret .= $this->start('tr');
$ret .= $this->element('th', 'Global attributes'); $ret .= $this->element('th', 'Global attributes');
$ret .= $this->element('td', $this->listifyAttr($def->info_global_attr), null, 0); $ret .= $this->element('td', $this->listifyAttr($def->info_global_attr), null, 0);
$ret .= $this->end('tr'); $ret .= $this->end('tr');
$ret .= $this->start('tr'); $ret .= $this->start('tr');
$ret .= $this->element('th', 'Tag transforms'); $ret .= $this->element('th', 'Tag transforms');
$list = array(); $list = array();
foreach ($def->info_tag_transform as $old => $new) { foreach ($def->info_tag_transform as $old => $new) {
$new = $this->getClass($new, 'TagTransform_'); $new = $this->getClass($new, 'TagTransform_');
$list[] = "<$old> with $new"; $list[] = "<$old> with $new";
} }
$ret .= $this->element('td', $this->listify($list)); $ret .= $this->element('td', $this->listify($list));
$ret .= $this->end('tr'); $ret .= $this->end('tr');
$ret .= $this->start('tr'); $ret .= $this->start('tr');
$ret .= $this->element('th', 'Pre-AttrTransform'); $ret .= $this->element('th', 'Pre-AttrTransform');
$ret .= $this->element('td', $this->listifyObjectList($def->info_attr_transform_pre)); $ret .= $this->element('td', $this->listifyObjectList($def->info_attr_transform_pre));
$ret .= $this->end('tr'); $ret .= $this->end('tr');
$ret .= $this->start('tr'); $ret .= $this->start('tr');
$ret .= $this->element('th', 'Post-AttrTransform'); $ret .= $this->element('th', 'Post-AttrTransform');
$ret .= $this->element('td', $this->listifyObjectList($def->info_attr_transform_post)); $ret .= $this->element('td', $this->listifyObjectList($def->info_attr_transform_post));
$ret .= $this->end('tr'); $ret .= $this->end('tr');
$ret .= $this->end('table'); $ret .= $this->end('table');
return $ret; return $ret;
} }
/** /**
* Renders the Content Sets table * Renders the Content Sets table
* @return string * @return string
*/ */
protected function renderContentSets() protected function renderContentSets()
{ {
$ret = ''; $ret = '';
$ret .= $this->start('table'); $ret .= $this->start('table');
$ret .= $this->element('caption', 'Content Sets'); $ret .= $this->element('caption', 'Content Sets');
foreach ($this->def->info_content_sets as $name => $lookup) { foreach ($this->def->info_content_sets as $name => $lookup) {
$ret .= $this->heavyHeader($name); $ret .= $this->heavyHeader($name);
$ret .= $this->start('tr'); $ret .= $this->start('tr');
$ret .= $this->element('td', $this->listifyTagLookup($lookup)); $ret .= $this->element('td', $this->listifyTagLookup($lookup));
$ret .= $this->end('tr'); $ret .= $this->end('tr');
} }
$ret .= $this->end('table'); $ret .= $this->end('table');
return $ret; return $ret;
} }
/** /**
* Renders the Elements ($info) table * Renders the Elements ($info) table
* @return string * @return string
*/ */
protected function renderInfo() protected function renderInfo()
{ {
$ret = ''; $ret = '';
$ret .= $this->start('table'); $ret .= $this->start('table');
$ret .= $this->element('caption', 'Elements ($info)'); $ret .= $this->element('caption', 'Elements ($info)');
ksort($this->def->info); ksort($this->def->info);
$ret .= $this->heavyHeader('Allowed tags', 2); $ret .= $this->heavyHeader('Allowed tags', 2);
$ret .= $this->start('tr'); $ret .= $this->start('tr');
$ret .= $this->element('td', $this->listifyTagLookup($this->def->info), array('colspan' => 2)); $ret .= $this->element('td', $this->listifyTagLookup($this->def->info), array('colspan' => 2));
$ret .= $this->end('tr'); $ret .= $this->end('tr');
foreach ($this->def->info as $name => $def) { foreach ($this->def->info as $name => $def) {
$ret .= $this->start('tr'); $ret .= $this->start('tr');
$ret .= $this->element('th', "<$name>", array('class' => 'heavy', 'colspan' => 2)); $ret .= $this->element('th', "<$name>", array('class' => 'heavy', 'colspan' => 2));
$ret .= $this->end('tr'); $ret .= $this->end('tr');
$ret .= $this->start('tr'); $ret .= $this->start('tr');
$ret .= $this->element('th', 'Inline content'); $ret .= $this->element('th', 'Inline content');
$ret .= $this->element('td', $def->descendants_are_inline ? 'Yes' : 'No'); $ret .= $this->element('td', $def->descendants_are_inline ? 'Yes' : 'No');
$ret .= $this->end('tr'); $ret .= $this->end('tr');
if (!empty($def->excludes)) { if (!empty($def->excludes)) {
$ret .= $this->start('tr'); $ret .= $this->start('tr');
$ret .= $this->element('th', 'Excludes'); $ret .= $this->element('th', 'Excludes');
$ret .= $this->element('td', $this->listifyTagLookup($def->excludes)); $ret .= $this->element('td', $this->listifyTagLookup($def->excludes));
$ret .= $this->end('tr'); $ret .= $this->end('tr');
} }
if (!empty($def->attr_transform_pre)) { if (!empty($def->attr_transform_pre)) {
$ret .= $this->start('tr'); $ret .= $this->start('tr');
$ret .= $this->element('th', 'Pre-AttrTransform'); $ret .= $this->element('th', 'Pre-AttrTransform');
$ret .= $this->element('td', $this->listifyObjectList($def->attr_transform_pre)); $ret .= $this->element('td', $this->listifyObjectList($def->attr_transform_pre));
$ret .= $this->end('tr'); $ret .= $this->end('tr');
} }
if (!empty($def->attr_transform_post)) { if (!empty($def->attr_transform_post)) {
$ret .= $this->start('tr'); $ret .= $this->start('tr');
$ret .= $this->element('th', 'Post-AttrTransform'); $ret .= $this->element('th', 'Post-AttrTransform');
$ret .= $this->element('td', $this->listifyObjectList($def->attr_transform_post)); $ret .= $this->element('td', $this->listifyObjectList($def->attr_transform_post));
$ret .= $this->end('tr'); $ret .= $this->end('tr');
} }
if (!empty($def->auto_close)) { if (!empty($def->auto_close)) {
$ret .= $this->start('tr'); $ret .= $this->start('tr');
$ret .= $this->element('th', 'Auto closed by'); $ret .= $this->element('th', 'Auto closed by');
$ret .= $this->element('td', $this->listifyTagLookup($def->auto_close)); $ret .= $this->element('td', $this->listifyTagLookup($def->auto_close));
$ret .= $this->end('tr'); $ret .= $this->end('tr');
} }
$ret .= $this->start('tr'); $ret .= $this->start('tr');
$ret .= $this->element('th', 'Allowed attributes'); $ret .= $this->element('th', 'Allowed attributes');
$ret .= $this->element('td', $this->listifyAttr($def->attr), array(), 0); $ret .= $this->element('td', $this->listifyAttr($def->attr), array(), 0);
$ret .= $this->end('tr'); $ret .= $this->end('tr');
if (!empty($def->required_attr)) { if (!empty($def->required_attr)) {
$ret .= $this->row('Required attributes', $this->listify($def->required_attr)); $ret .= $this->row('Required attributes', $this->listify($def->required_attr));
} }
$ret .= $this->renderChildren($def->child); $ret .= $this->renderChildren($def->child);
} }
$ret .= $this->end('table'); $ret .= $this->end('table');
return $ret; return $ret;
} }
/** /**
* Renders a row describing the allowed children of an element * Renders a row describing the allowed children of an element
* @param HTMLPurifier_ChildDef $def HTMLPurifier_ChildDef of pertinent element * @param HTMLPurifier_ChildDef $def HTMLPurifier_ChildDef of pertinent element
* @return string * @return string
*/ */
protected function renderChildren($def) protected function renderChildren($def)
{ {
$context = new HTMLPurifier_Context(); $context = new HTMLPurifier_Context();
$ret = ''; $ret = '';
$ret .= $this->start('tr'); $ret .= $this->start('tr');
$elements = array(); $elements = array();
$attr = array(); $attr = array();
if (isset($def->elements)) { if (isset($def->elements)) {
if ($def->type == 'strictblockquote') { if ($def->type == 'strictblockquote') {
$def->validateChildren(array(), $this->config, $context); $def->validateChildren(array(), $this->config, $context);
} }
$elements = $def->elements; $elements = $def->elements;
} }
if ($def->type == 'chameleon') { if ($def->type == 'chameleon') {
$attr['rowspan'] = 2; $attr['rowspan'] = 2;
} elseif ($def->type == 'empty') { } elseif ($def->type == 'empty') {
$elements = array(); $elements = array();
} elseif ($def->type == 'table') { } elseif ($def->type == 'table') {
$elements = array_flip( $elements = array_flip(
array( array(
'col', 'col',
'caption', 'caption',
'colgroup', 'colgroup',
'thead', 'thead',
'tfoot', 'tfoot',
'tbody', 'tbody',
'tr' 'tr'
) )
); );
} }
$ret .= $this->element('th', 'Allowed children', $attr); $ret .= $this->element('th', 'Allowed children', $attr);
if ($def->type == 'chameleon') { if ($def->type == 'chameleon') {
$ret .= $this->element( $ret .= $this->element(
'td', 'td',
'<em>Block</em>: ' . '<em>Block</em>: ' .
$this->escape($this->listifyTagLookup($def->block->elements)), $this->escape($this->listifyTagLookup($def->block->elements)),
null, null,
0 0
); );
$ret .= $this->end('tr'); $ret .= $this->end('tr');
$ret .= $this->start('tr'); $ret .= $this->start('tr');
$ret .= $this->element( $ret .= $this->element(
'td', 'td',
'<em>Inline</em>: ' . '<em>Inline</em>: ' .
$this->escape($this->listifyTagLookup($def->inline->elements)), $this->escape($this->listifyTagLookup($def->inline->elements)),
null, null,
0 0
); );
} elseif ($def->type == 'custom') { } elseif ($def->type == 'custom') {
$ret .= $this->element( $ret .= $this->element(
'td', 'td',
'<em>' . ucfirst($def->type) . '</em>: ' . '<em>' . ucfirst($def->type) . '</em>: ' .
$def->dtd_regex $def->dtd_regex
); );
} else { } else {
$ret .= $this->element( $ret .= $this->element(
'td', 'td',
'<em>' . ucfirst($def->type) . '</em>: ' . '<em>' . ucfirst($def->type) . '</em>: ' .
$this->escape($this->listifyTagLookup($elements)), $this->escape($this->listifyTagLookup($elements)),
null, null,
0 0
); );
} }
$ret .= $this->end('tr'); $ret .= $this->end('tr');
return $ret; return $ret;
} }
/** /**
* Listifies a tag lookup table. * Listifies a tag lookup table.
* @param array $array Tag lookup array in form of array('tagname' => true) * @param array $array Tag lookup array in form of array('tagname' => true)
* @return string * @return string
*/ */
protected function listifyTagLookup($array) protected function listifyTagLookup($array)
{ {
ksort($array); ksort($array);
$list = array(); $list = array();
foreach ($array as $name => $discard) { foreach ($array as $name => $discard) {
if ($name !== '#PCDATA' && !isset($this->def->info[$name])) { if ($name !== '#PCDATA' && !isset($this->def->info[$name])) {
continue; continue;
} }
$list[] = $name; $list[] = $name;
} }
return $this->listify($list); return $this->listify($list);
} }
/** /**
* Listifies a list of objects by retrieving class names and internal state * Listifies a list of objects by retrieving class names and internal state
* @param array $array List of objects * @param array $array List of objects
* @return string * @return string
* @todo Also add information about internal state * @todo Also add information about internal state
*/ */
protected function listifyObjectList($array) protected function listifyObjectList($array)
{ {
ksort($array); ksort($array);
$list = array(); $list = array();
foreach ($array as $obj) { foreach ($array as $obj) {
$list[] = $this->getClass($obj, 'AttrTransform_'); $list[] = $this->getClass($obj, 'AttrTransform_');
} }
return $this->listify($list); return $this->listify($list);
} }
/** /**
* Listifies a hash of attributes to AttrDef classes * Listifies a hash of attributes to AttrDef classes
* @param array $array Array hash in form of array('attrname' => HTMLPurifier_AttrDef) * @param array $array Array hash in form of array('attrname' => HTMLPurifier_AttrDef)
* @return string * @return string
*/ */
protected function listifyAttr($array) protected function listifyAttr($array)
{ {
ksort($array); ksort($array);
$list = array(); $list = array();
foreach ($array as $name => $obj) { foreach ($array as $name => $obj) {
if ($obj === false) { if ($obj === false) {
continue; continue;
} }
$list[] = "$name&nbsp;=&nbsp;<i>" . $this->getClass($obj, 'AttrDef_') . '</i>'; $list[] = "$name&nbsp;=&nbsp;<i>" . $this->getClass($obj, 'AttrDef_') . '</i>';
} }
return $this->listify($list); return $this->listify($list);
} }
/** /**
* Creates a heavy header row * Creates a heavy header row
* @param string $text * @param string $text
* @param int $num * @param int $num
* @return string * @return string
*/ */
protected function heavyHeader($text, $num = 1) protected function heavyHeader($text, $num = 1)
{ {
$ret = ''; $ret = '';
$ret .= $this->start('tr'); $ret .= $this->start('tr');
$ret .= $this->element('th', $text, array('colspan' => $num, 'class' => 'heavy')); $ret .= $this->element('th', $text, array('colspan' => $num, 'class' => 'heavy'));
$ret .= $this->end('tr'); $ret .= $this->end('tr');
return $ret; return $ret;
} }
} }
// vim: et sw=4 sts=4 // vim: et sw=4 sts=4
Binary file not shown.
Binary file not shown.
Binary file not shown.
+3
View File
@@ -14,12 +14,15 @@ $web_siteid = '';
if ($config['cf_cert_use'] == 2) { // 실서비스 if ($config['cf_cert_use'] == 2) { // 실서비스
$site_cd = 'SM'.$config['cf_cert_kcp_cd']; $site_cd = 'SM'.$config['cf_cert_kcp_cd'];
$cert_url = 'https://cert.kcp.co.kr/kcp_cert/cert_view.jsp'; $cert_url = 'https://cert.kcp.co.kr/kcp_cert/cert_view.jsp';
$kcp_enc_key = $config['cf_cert_kcp_enckey'];
} else if ($config['cf_cert_use'] == 1) { // 테스트사용 } else if ($config['cf_cert_use'] == 1) { // 테스트사용
$site_cd = 'S6186'; $site_cd = 'S6186';
$cert_url = 'https://testcert.kcp.co.kr/kcp_cert/cert_view.jsp'; $cert_url = 'https://testcert.kcp.co.kr/kcp_cert/cert_view.jsp';
$kcp_enc_key = 'E66DCEB95BFBD45DF9DFAEEBCB092B5DC2EB3BF0';
} else { // 사용안함 } else { // 사용안함
$site_cd = ''; $site_cd = '';
$cert_url = ''; $cert_url = '';
$kcp_enc_key = '';
} }
if(!$site_cd) if(!$site_cd)
+11 -1
View File
@@ -27,6 +27,8 @@ if(!$ordr_idxx)
$ct_cert = new C_CT_CLI; $ct_cert = new C_CT_CLI;
$ct_cert->mf_clear(); $ct_cert->mf_clear();
$sbParam = '';
$year = "00"; $year = "00";
$month = "00"; $month = "00";
$day = "00"; $day = "00";
@@ -47,7 +49,7 @@ $hash_data = $site_cd .
$sex_code . $sex_code .
$local_code; $local_code;
$up_hash = $ct_cert->make_hash_data( $home_dir, $hash_data ); $up_hash = $ct_cert->make_hash_data( $home_dir, $kcp_enc_key, $hash_data );
$ct_cert->mf_clear(); $ct_cert->mf_clear();
?> ?>
@@ -88,6 +90,9 @@ $ct_cert->mf_clear();
<!-- cert_enc_use 필수 (고정값 : 메뉴얼 참고) --> <!-- cert_enc_use 필수 (고정값 : 메뉴얼 참고) -->
<input type="hidden" name="cert_enc_use" value="Y"/> <input type="hidden" name="cert_enc_use" value="Y"/>
<!-- 리턴 암호화 고도화 -->
<input type="hidden" name="cert_enc_use_ext" value="Y"/>
<?php if(is_mobile()) { ?> <?php if(is_mobile()) { ?>
<!-- cert_able_yn input 비활성화 설정 --> <!-- cert_able_yn input 비활성화 설정 -->
<input type="hidden" name="cert_able_yn" value=""/> <input type="hidden" name="cert_able_yn" value=""/>
@@ -101,10 +106,15 @@ $ct_cert->mf_clear();
<!-- up_hash 검증 을 위한 필드 --> <!-- up_hash 검증 을 위한 필드 -->
<input type="hidden" name="veri_up_hash" value=""/> <input type="hidden" name="veri_up_hash" value=""/>
<!-- web_siteid 을 위한 필드 -->
<input type="hidden" name="web_siteid_hashYN" value=""/>
<!-- 가맹점 사용 필드 (인증완료시 리턴)--> <!-- 가맹점 사용 필드 (인증완료시 리턴)-->
<input type="hidden" name="param_opt_1" value="opt1"/> <input type="hidden" name="param_opt_1" value="opt1"/>
<input type="hidden" name="param_opt_2" value="opt2"/> <input type="hidden" name="param_opt_2" value="opt2"/>
<input type="hidden" name="param_opt_3" value="opt3"/> <input type="hidden" name="param_opt_3" value="opt3"/>
<input type='hidden' name='kcp_cert_lib_ver' value="<?php echo $ct_cert->get_kcp_lib_ver( $home_dir ); ?>"/>
</form> </form>
<script> <script>
+8 -2
View File
@@ -12,6 +12,7 @@ $enc_data = "";
$req_tx = ""; $req_tx = "";
$enc_cert_data = ""; $enc_cert_data = "";
$enc_cert_data2 = "";
$cert_info = ""; $cert_info = "";
$tran_cd = ""; $tran_cd = "";
@@ -67,6 +68,11 @@ for($i=0; $i<count($key); $i++)
{ {
$enc_cert_data = f_get_parm_str ( $valParam ); $enc_cert_data = f_get_parm_str ( $valParam );
} }
if ( $nmParam == "enc_cert_data2" )
{
$enc_cert_data2 = f_get_parm_str ( $valParam );
}
if ( $nmParam == "dn_hash" ) if ( $nmParam == "dn_hash" )
{ {
@@ -98,7 +104,7 @@ if( $cert_enc_use == "Y" )
// 해당 데이터의 위변조를 방지합니다 // 해당 데이터의 위변조를 방지합니다
$veri_str = $site_cd.$ordr_idxx.$cert_no; // 사이트 코드 + 주문번호 + 인증거래번호 $veri_str = $site_cd.$ordr_idxx.$cert_no; // 사이트 코드 + 주문번호 + 인증거래번호
if ( $ct_cert->check_valid_hash ( $home_dir , $dn_hash , $veri_str ) != "1" ) if ( $ct_cert->check_valid_hash ( $home_dir , $kcp_enc_key, $dn_hash , $veri_str ) != "1" )
{ {
if(strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') { if(strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') {
// 검증 실패시 처리 영역 // 검증 실패시 처리 영역
@@ -122,7 +128,7 @@ if( $cert_enc_use == "Y" )
// site_cd 와 cert_no 를 가지고 복화화 하는 함수 입니다. // site_cd 와 cert_no 를 가지고 복화화 하는 함수 입니다.
// 정상적으로 복호화 된경우에만 인증데이터를 가져올수 있습니다. // 정상적으로 복호화 된경우에만 인증데이터를 가져올수 있습니다.
$opt = "1" ; // 복호화 인코딩 옵션 ( UTF - 8 사용시 "1" ) $opt = "1" ; // 복호화 인코딩 옵션 ( UTF - 8 사용시 "1" )
$ct_cert->decrypt_enc_cert( $home_dir , $site_cd , $cert_no , $enc_cert_data , $opt ); $ct_cert->decrypt_enc_cert( $home_dir , $kcp_enc_key, $site_cd , $cert_no , $enc_cert_data2 , $opt );
$comm_id = $ct_cert->mf_get_key_value("comm_id" ); // 이동통신사 코드 $comm_id = $ct_cert->mf_get_key_value("comm_id" ); // 이동통신사 코드
$phone_no = $ct_cert->mf_get_key_value("phone_no" ); // 전화번호 $phone_no = $ct_cert->mf_get_key_value("phone_no" ); // 전화번호
+27 -3
View File
@@ -20,7 +20,7 @@ class C_CT_CLI
} }
// hash 처리 영역 // hash 처리 영역
function make_hash_data( $home_dir , $str ) function make_hash_data( $home_dir , $key , $str )
{ {
if(strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') { if(strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') {
if(PHP_INT_MAX == 2147483647) // 32-bit if(PHP_INT_MAX == 2147483647) // 32-bit
@@ -32,6 +32,7 @@ class C_CT_CLI
} }
$hash_data = $this -> mf_exec( $bin_exe , $hash_data = $this -> mf_exec( $bin_exe ,
"lf_CT_CLI__make_hash_data", "lf_CT_CLI__make_hash_data",
$key,
$str $str
); );
@@ -41,7 +42,7 @@ class C_CT_CLI
} }
// dn_hash 체크 함수 // dn_hash 체크 함수
function check_valid_hash ($home_dir , $hash_data , $str ) function check_valid_hash ($home_dir , $key , $hash_data , $str )
{ {
if(strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') { if(strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') {
if(PHP_INT_MAX == 2147483647) // 32-bit if(PHP_INT_MAX == 2147483647) // 32-bit
@@ -53,6 +54,7 @@ class C_CT_CLI
} }
$ret_val = $this -> mf_exec( $bin_exe , $ret_val = $this -> mf_exec( $bin_exe ,
"lf_CT_CLI__check_valid_hash" , "lf_CT_CLI__check_valid_hash" ,
$key,
$hash_data , $hash_data ,
$str $str
); );
@@ -63,7 +65,7 @@ class C_CT_CLI
} }
// 암호화 인증데이터 복호화 // 암호화 인증데이터 복호화
function decrypt_enc_cert ( $home_dir, $site_cd , $cert_no , $enc_cert_data , $opt) function decrypt_enc_cert ( $home_dir, $key , $site_cd , $cert_no , $enc_cert_data , $opt)
{ {
if(strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') { if(strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') {
if(PHP_INT_MAX == 2147483647) // 32-bit if(PHP_INT_MAX == 2147483647) // 32-bit
@@ -73,6 +75,7 @@ class C_CT_CLI
$dec_data = $this -> mf_exec( $bin_exe , $dec_data = $this -> mf_exec( $bin_exe ,
"lf_CT_CLI__decrypt_enc_cert" , "lf_CT_CLI__decrypt_enc_cert" ,
$key,
$site_cd , $site_cd ,
$cert_no , $cert_no ,
$enc_cert_data , $enc_cert_data ,
@@ -84,6 +87,7 @@ class C_CT_CLI
$dec_data = $this -> mf_exec( $bin_exe , $dec_data = $this -> mf_exec( $bin_exe ,
"lf_CT_CLI__decrypt_enc_cert" , "lf_CT_CLI__decrypt_enc_cert" ,
$key,
$site_cd , $site_cd ,
$cert_no , $cert_no ,
$enc_cert_data $enc_cert_data
@@ -96,6 +100,26 @@ class C_CT_CLI
parse_str( str_replace( chr( 31 ), "&", $dec_data ), $this->m_dec_data ); parse_str( str_replace( chr( 31 ), "&", $dec_data ), $this->m_dec_data );
} }
function get_kcp_lib_ver( $home_dir )
{
if(strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') {
if(PHP_INT_MAX == 2147483647) // 32-bit
$bin_exe = $home_dir . '/bin/ct_cli';
else
$bin_exe = $home_dir . '/bin/ct_cli_x64';
} else {
$bin_exe = $home_dir . '/bin/ct_cli_exe.exe';
}
$ver_data = $this -> mf_exec( $bin_exe ,
"lf_CT_CLI__get_kcp_lib_ver"
);
if ( $ver_data == "" ) { $ver_data = "HS04"; }
return $ver_data;
}
// 인증데이터 get data // 인증데이터 get data
function mf_get_key_value( $name ) function mf_get_key_value( $name )
{ {
+6 -5
View File
@@ -148,7 +148,12 @@ else // 장바구니에 담기
$post_io_ids = (isset($_POST['io_id']) && is_array($_POST['io_id'])) ? $_POST['io_id'] : array(); $post_io_ids = (isset($_POST['io_id']) && is_array($_POST['io_id'])) ? $_POST['io_id'] : array();
$post_io_types = (isset($_POST['io_type']) && is_array($_POST['io_type'])) ? $_POST['io_type'] : array(); $post_io_types = (isset($_POST['io_type']) && is_array($_POST['io_type'])) ? $_POST['io_type'] : array();
$post_ct_qtys = (isset($_POST['ct_qty']) && is_array($_POST['ct_qty'])) ? $_POST['ct_qty'] : array(); $post_ct_qtys = (isset($_POST['ct_qty']) && is_array($_POST['ct_qty'])) ? $_POST['ct_qty'] : array();
if ($count && $sw_direct) {
// 바로구매에 있던 장바구니 자료를 지운다.
sql_query(" delete from {$g5['g5_shop_cart_table']} where od_id = '$tmp_cart_id' and ct_direct = 1 ", false);
}
for($i=0; $i<$count; $i++) { for($i=0; $i<$count; $i++) {
// 보관함의 상품을 담을 때 체크되지 않은 상품 건너뜀 // 보관함의 상품을 담을 때 체크되지 않은 상품 건너뜀
if($act == 'multi' && ! (isset($post_chk_it_id[$i]) && $post_chk_it_id[$i])) if($act == 'multi' && ! (isset($post_chk_it_id[$i]) && $post_chk_it_id[$i]))
@@ -180,10 +185,6 @@ else // 장바구니에 담기
if(!$it['it_id']) if(!$it['it_id'])
alert('상품정보가 존재하지 않습니다.'); alert('상품정보가 존재하지 않습니다.');
// 바로구매에 있던 장바구니 자료를 지운다.
if($i == 0 && $sw_direct)
sql_query(" delete from {$g5['g5_shop_cart_table']} where od_id = '$tmp_cart_id' and ct_direct = 1 ", false);
// 최소, 최대 수량 체크 // 최소, 최대 수량 체크
if($it['it_buy_min_qty'] || $it['it_buy_max_qty']) { if($it['it_buy_min_qty'] || $it['it_buy_max_qty']) {
$sum_qty = 0; $sum_qty = 0;
+1 -1
View File
@@ -2,7 +2,7 @@
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가 if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
define('G5_VERSION', '그누보드5'); define('G5_VERSION', '그누보드5');
define('G5_GNUBOARD_VER', '5.6.6'); define('G5_GNUBOARD_VER', '5.6.7');
// 그누보드5.4.5.5 버전과 영카트5.4.5.5.1 버전을 합쳐서 그누보드5.4.6 버전에서 시작함 (kagla-210617) // 그누보드5.4.5.5 버전과 영카트5.4.5.5.1 버전을 합쳐서 그누보드5.4.6 버전에서 시작함 (kagla-210617)
// G5_YOUNGCART_VER 이 상수를 사용하는 곳이 있으므로 주석 처리 해제함 // G5_YOUNGCART_VER 이 상수를 사용하는 곳이 있으므로 주석 처리 해제함
// 그누보드5.4.6 이상 버전 부터는 영카트를 그누보드에 포함하여 배포하므로 영카트5의 버전은 의미가 없습니다. // 그누보드5.4.6 이상 버전 부터는 영카트를 그누보드에 포함하여 배포하므로 영카트5의 버전은 의미가 없습니다.