Update catsplit.format.php

This commit is contained in:
Namhyeon Go 2019-07-16 16:16:05 +09:00 committed by GitHub
parent 96eef131e1
commit ba21f4e5cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,15 +8,15 @@
*/ */
if(!check_function_exists("catsplit_unescape")) { if(!check_function_exists("catsplit_unescape")) {
function catsplit_unescape($data) { function catsplit_unescape($data) {
return trim($data); return trim($data);
} }
} }
if(!check_function_exists("casplit_escape")) { if(!check_function_exists("casplit_escape")) {
function casplit_escape($data) { function casplit_escape($data) {
return htmlspecialchars($data); return htmlspecialchars($data);
} }
} }
if(!check_function_exists("catsplit_encode")) { if(!check_function_exists("catsplit_encode")) {
@ -27,31 +27,32 @@ if(!check_function_exists("catsplit_encode")) {
$_ks[] = $k; $_ks[] = $k;
$_vs[] = make_safe_argument($v); $_vs[] = make_safe_argument($v);
} }
$_ks = array_map("casplit_escape", $_ks); $_ks = array_map("casplit_escape", $_ks);
$_vs = array_map("casplit_escape", $_vs); $_vs = array_map("casplit_escape", $_vs);
return sprintf("('%s')<=(%s)", implode("','", $_vs), implode(",", $_ks)); return sprintf("('%s')<=(%s)", implode("','", $_vs), implode(",", $_ks));
} }
} }
if(!check_function_exists("catsplit_decode")) { if(!check_function_exists("catsplit_decode")) {
function catsplit_decode($data) { function catsplit_decode($data) {
$s_final = array(); $s_final = array();
// step 1 // step 1
$s1 = explode(")<=(", substr($data, 1, -1)); $s1 = explode(")<=(", substr($data, 1, -1));
// step 2 // step 2
$s2a = array_map("catsplit_unescape", explode(",", $s1[0])); $s2a = array_map("catsplit_unescape", explode(",", $s1[0]));
$s2b = array_map("catsplit_unescape", explode(",", $s1[1])); $s2b = array_map("catsplit_unescape", explode(",", $s1[1]));
// step 3 // step 3
$s3 = array_combine($s2b, $s2a); $s3 = array_combine($s2b, $s2a);
// step 4 // step 4
foreach($s3 as $k=>$v) { foreach($s3 as $k=>$v) {
$s_final[$k] = substr(stripslashes($v), 1, -1); $s_final[$k] = substr(stripslashes($v), 1, -1);
} }
return $s_final; return $s_final;
} }
} }