불필요한 PHP 5.1 이하 코드 삭제

json_encode, json_decode 는 PHP 5.2 부터 PHP 코어에 내장되어있습니다.
https://php-legacy-docs.zend.com/manual/php5/en/json.requirements
https://php-legacy-docs.zend.com/manual/php5/en/book.json
This commit is contained in:
kit rio
2022-06-03 11:00:02 +09:00
committed by thisgun
parent 068c8818f8
commit fc43e26c14
12 changed files with 58 additions and 145 deletions

View File

@ -1,6 +1,5 @@
<?php
require_once './_common.php';
require_once G5_LIB_PATH . '/json.lib.php';
set_session('ss_admin_token', '');

View File

@ -1,7 +1,6 @@
<?php
$sub_menu = "100280";
include_once('./_common.php');
include_once(G5_LIB_PATH.'/json.lib.php');
$data = array();
$data['error'] = '';
@ -182,4 +181,4 @@ if($type == 'board') {
$data['error'] = '적용할 테마 설정이 없습니다.';
}
die(json_encode($data));
die(json_encode($data));

View File

@ -1,6 +1,5 @@
<?php
include_once('./_common.php');
include_once(G5_LIB_PATH.'/json.lib.php');
$ss_name = 'ss_comment_token';
@ -10,4 +9,4 @@ $token = _token();
set_session($ss_name, $token);
die(json_encode(array('token'=>$token)));
die(json_encode(array('token'=>$token)));

View File

@ -1,11 +1,10 @@
<?php
include_once('./_common.php');
include_once(G5_LIB_PATH.'/json.lib.php');
$token_case = isset($_POST['token_case']) ? preg_replace('/[^0-9a-z_]/i', '', $_POST['token_case']) : '';
if( $token_case ){
$token = _token();
set_session('ss_'.$token_case.'_token', $token);
die(json_encode(array('error'=>'', 'token'=>$token, 'url'=>'')));
}
<?php
include_once('./_common.php');
$token_case = isset($_POST['token_case']) ? preg_replace('/[^0-9a-z_]/i', '', $_POST['token_case']) : '';
if( $token_case ){
$token = _token();
set_session('ss_'.$token_case.'_token', $token);
die(json_encode(array('error'=>'', 'token'=>$token, 'url'=>'')));
}

View File

@ -1,6 +1,5 @@
<?php
include_once('./_common.php');
include_once(G5_LIB_PATH.'/json.lib.php');
if(!$bo_table)
die(json_encode(array('error'=>'게시판 정보가 올바르지 않습니다.', 'url'=>G5_URL)));
@ -9,4 +8,4 @@ set_session('ss_write_'.$bo_table.'_token', '');
$token = get_write_token($bo_table);
die(json_encode(array('error'=>'', 'token'=>$token, 'url'=>'')));
die(json_encode(array('error'=>'', 'token'=>$token, 'url'=>'')));

View File

@ -1,12 +1,10 @@
<?php
$g5_path['path'] = '..';
include_once ('../config.php');
include_once('../lib/json.lib.php');
include_once('../lib/common.lib.php'); // 공통 라이브러리
include_once('../config.php');
include_once('./install.function.php'); // 인스톨 과정 함수 모음
include_once('../lib/common.lib.php'); // 공통 라이브러리
include_once('../lib/hook.lib.php'); // hook 함수 파일
include_once('../lib/get_data.lib.php'); // 데이 가져오는 함수 모음
include_once('../lib/get_data.lib.php'); // 데이 가져오는 함수 모음
$data_path = '../'.G5_DATA_DIR;

View File

@ -1,78 +0,0 @@
<?php
if (!defined('_GNUBOARD_')) exit;
// http://tinsology.net/2011/04/php-json_encode-and-json_decode-alternatives/
if(!function_exists('json_encode'))
{
function json_encode($a=false)
{
// Some basic debugging to ensure we have something returned
if (is_null($a)) return 'null';
if ($a === false) return 'false';
if ($a === true) return 'true';
if (is_scalar($a))
{
if (is_float($a))
{
// Always use '.' for floats.
return floatval(str_replace(',', '.', strval($a)));
}
if (is_string($a))
{
static $jsonReplaces = array(array('\\', '/', "\n", "\t", "\r", "\b", "\f", '"'), array('\\\\', '\\/', '\\n', '\\t', '\\r', '\\b', '\\f', '\"'));
return '"' . str_replace($jsonReplaces[0], $jsonReplaces[1], $a) . '"';
}
else
return $a;
}
$isList = true;
for ($i = 0, reset($a); true; $i++) {
if (key($a) !== $i)
{
$isList = false;
break;
}
}
$result = array();
if ($isList)
{
foreach ($a as $v) $result[] = json_encode($v);
return '[' . join(',', $result) . ']';
}
else
{
foreach ($a as $k => $v) $result[] = json_encode($k).':'.json_encode($v);
return '{' . join(',', $result) . '}';
}
}
}
if(!function_exists('json_decode'))
{
function json_decode($json)
{
$comment = false;
$out = '$x=';
for ($i=0; $i<strlen($json); $i++)
{
if (!$comment)
{
if (($json[$i] == '{') || ($json[$i] == '['))
$out .= ' array(';
else if (($json[$i] == '}') || ($json[$i] == ']'))
$out .= ')';
else if ($json[$i] == ':')
$out .= '=>';
else
$out .= $json[$i];
}
else
$out .= $json[$i];
if ($json[$i] == '"' && $json[($i-1)]!="\\")
$comment = !$comment;
}
eval($out . ';');
return $x;
}
}

View File

@ -1,6 +1,5 @@
<?php
include_once('./_common.php');
include_once(G5_LIB_PATH.'/json.lib.php');
if(!$member['mb_id'])
die(json_encode(array('error' => '회원 로그인 후 이용해 주십시오.')));
@ -66,4 +65,4 @@ if($result && $cp['cz_type'])
// 다운로드 증가
sql_query(" update {$g5['g5_shop_coupon_zone_table']} set cz_download = cz_download + 1 where cz_id = '$cz_id' ");
die(json_encode(array('error' => '')));
die(json_encode(array('error' => '')));

View File

@ -1,6 +1,5 @@
<?php
include_once('./_common.php');
include_once(G5_LIB_PATH.'/json.lib.php');
define('G5_IS_SHOP_AJAX_LIST', true);
@ -76,4 +75,4 @@ $data['item'] = $content;
$data['error'] = '';
$data['page'] = $page;
die(json_encode($data));
die(json_encode($data));

View File

@ -1,6 +1,5 @@
<?php
include_once('./_common.php');
include_once(G5_LIB_PATH.'/json.lib.php');
include_once(G5_SHOP_PATH.'/settle_inicis.inc.php');
if($default['de_pg_service'] != 'inicis' && ! ($default['de_inicis_lpay_use'] || $default['de_inicis_kakaopay_use']) )
@ -29,4 +28,4 @@ $mKey = hash("sha256", $signKey);
$params = "oid=" . $orderNumber . "&price=" . $price . "&timestamp=" . $timestamp;
$sign = hash("sha256", $params);
die(json_encode(array('error'=>'', 'mKey'=>$mKey, 'timestamp'=>$timestamp, 'sign'=>$sign)));
die(json_encode(array('error'=>'', 'mKey'=>$mKey, 'timestamp'=>$timestamp, 'sign'=>$sign)));

View File

@ -1,36 +1,38 @@
<?php
include_once('./_common.php');
include_once(G5_LIB_PATH.'/json.lib.php');
include(G5_SHOP_PATH.'/kakaopay/incKakaopayCommon.php');
// 카카오페이를 사용하지 않을 경우
if( ! $default['de_kakaopay_enckey'] ) die('카카오페이를 사용하지 않습니다.');
if( ! ($default['de_kakaopay_mid'] && $default['de_kakaopay_key']) ){
die(json_encode(array('error'=>'올바른 방법으로 이용해 주십시오.')));
}
$orderNumber = get_session('ss_order_id');
$price = preg_replace('#[^0-9]#', '', $_POST['price']);
if(strlen($price) < 1)
die(json_encode(array('error'=>'가격이 올바르지 않습니다.')));
//
//###################################
// 2. 가맹점 확인을 위한 signKey를 해시값으로 변경 (SHA-256방식 사용)
//###################################
$mKey = hash("sha256", $default['de_kakaopay_key']);
/*
//*** 위변조 방지체크를 signature 생성 ***
oid, price, timestamp 3개의 키와 값을
key=value 형식으로 하여 '&'로 연결한 하여 SHA-256 Hash로 생성 된값
ex) oid=INIpayTest_1432813606995&price=819000&timestamp=2012-02-01 09:19:04.004
* key기준 알파벳 정렬
* timestamp는 반드시 signature생성에 사용한 timestamp 값을 timestamp input에 그대로 사용하여야함
*/
$params = "oid=" . $orderNumber . "&price=" . $price . "&timestamp=" . $timestamp;
$sign = hash("sha256", $params);
die(json_encode(array('error'=>'', 'mKey'=>$mKey, 'timestamp'=>$timestamp, 'sign'=>$sign)));
<?php
include_once('./_common.php');
include(G5_SHOP_PATH.'/kakaopay/incKakaopayCommon.php');
// 카카오페이를 사용하지 않을 경우
if (!$default['de_kakaopay_enckey']) {
die('카카오페이를 사용하지 않습니다.');
}
if (!($default['de_kakaopay_mid'] && $default['de_kakaopay_key'])) {
die(json_encode(array('error' => '올바른 방법으로 이용해 주십시오.')));
}
$orderNumber = get_session('ss_order_id');
$price = preg_replace('#[^0-9]#', '', $_POST['price']);
if (strlen($price) < 1) {
die(json_encode(array('error' => '가격이 올바르지 않습니다.')));
}
//
//###################################
// 2. 가맹점 확인을 위한 signKey를 해시값으로 변경 (SHA-256방식 사용)
//###################################
$mKey = hash("sha256", $default['de_kakaopay_key']);
/*
//*** 위변조 방지체크를 signature 생성 ***
oid, price, timestamp 3개의 키와 값을
key=value 형식으로 하여 '&'로 연결한 하여 SHA-256 Hash로 생성 된값
ex) oid=INIpayTest_1432813606995&price=819000&timestamp=2012-02-01 09:19:04.004
* key기준 알파벳 정렬
* timestamp는 반드시 signature생성에 사용한 timestamp 값을 timestamp input에 그대로 사용하여야함
*/
$params = "oid=" . $orderNumber . "&price=" . $price . "&timestamp=" . $timestamp;
$sign = hash("sha256", $params);
die(json_encode(array('error'=>'', 'mKey'=>$mKey, 'timestamp'=>$timestamp, 'sign'=>$sign)));

View File

@ -1,6 +1,5 @@
<?php
include_once('./_common.php');
include_once(G5_LIB_PATH.'/json.lib.php');
// LG유플러스 공통 설정
require_once(G5_SHOP_PATH.'/settle_lg.inc.php');
@ -88,4 +87,4 @@ $payReqMap['LGD_PAYKEY'] = '';
$_SESSION['PAYREQ_MAP'] = $payReqMap;
die(json_encode(array('LGD_HASHDATA' => $LGD_HASHDATA, 'error' => '')));
die(json_encode(array('LGD_HASHDATA' => $LGD_HASHDATA, 'error' => '')));