Update catsplit.format.php

This commit is contained in:
Namhyeon Go 2019-06-06 12:57:40 +09:00 committed by GitHub
parent 61876c7566
commit f84f194709
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,6 +7,18 @@
* @documentation https://github.com/gnh1201/catsplit-format
*/
if(!check_function_exists("catsplit_unescape")) {
function catsplit_unescape($data) {
return trim($data);
}
}
if(!check_function_exists("casplit_escape")) {
function casplit_escape($data) {
return htmlspecialchars($data);
}
}
if(!check_function_exists("catsplit_encode")) {
function catsplit_encode($data) {
$_ks = array();
@ -15,6 +27,8 @@ if(!check_function_exists("catsplit_encode")) {
$_ks[] = $k;
$_vs[] = make_safe_argument($v);
}
$_ks = array_map("casplit_escape", $_ks);
$_vs = array_map("casplit_escape", $_vs);
return sprintf("('%s')<=(%s)", implode("','", $_vs), implode(",", $_ks));
}
}
@ -27,8 +41,8 @@ if(!check_function_exists("catsplit_decode")) {
$s1 = explode(")<=(", substr($data, 1, -1));
// step 2
$s2a = array_map("trim", explode(",", $s1[0]));
$s2b = array_map("trim", explode(",", $s1[1]));
$s2a = array_map("catsplit_unescape", explode(",", $s1[0]));
$s2b = array_map("catsplit_unescape", explode(",", $s1[1]));
// step 3
$s3 = array_combine($s2b, $s2a);