From b9f00b0b39111ac3efd5213e7cfa0bb5736e1211 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 27 Nov 2024 12:37:49 +0100 Subject: [PATCH] json_decode file content --- functions.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/functions.php b/functions.php index e5fd1da..20aa62d 100644 --- a/functions.php +++ b/functions.php @@ -300,11 +300,19 @@ function check_files($dir,$key) { global $SHARED_DIR; if (file_exists($SHARED_DIR."/{$dir}/".$key)) { - $arr[$key] = file_get_contents($SHARED_DIR."/{$dir}/".$key); + $json_data = file_get_contents($SHARED_DIR."/{$dir}/".$key); + $data = json_decode($json_data,true); + if ($data === null) { + echo "JSON read error..."; + // TODO json error + } + else { + $result["$key"] = $data; + } } - else $arr = ""; + else $result = ""; - return $arr; + return $result; } function check_request($key="") {