15 @date_default_timezone_set(@date_default_timezone_get());
17 require_once
'../inc/hce_cli_api.inc.php';
19 if(php_sapi_name()!==
'cli' || !
defined(
'STDIN')){
20 echo
'Only cli execution mode supported'.PHP_EOL;
29 ' --field=<field_path> [--base64=<0-not decode|1-decode>] [--unicode=<0-not decode|1-decode>] [--json=<json_file>] [--compact=<0-yes|1-not>] [--xml=0-output as json|1-output as xml]'.PHP_EOL;
42 if(file_exists(
$json)){
43 $input_json=trim(file_get_contents(
$json));
45 echo
'File '.$json.
' not found!'.PHP_EOL;
49 $input_json=file_get_contents(
"php://stdin");
55 $input_json=@json_decode($input_json,
true);
56 if(is_array($input_json)){
59 $dir=rawurldecode($dir);
60 if(isset($input_json[$dir])){
61 $input_json=$input_json[$dir];
77 $out=html_entity_decode(preg_replace(
"/U\+([0-9A-F]{4})/",
"&#x\\1;",
$out), ENT_NOQUOTES,
'UTF-8');
88 function array2Xml($data,
$xml = null){
90 $xml = simplexml_load_string(
'<' . key($data) .
'/>');
91 $data = current($data);
94 if (is_array($data)) {
95 foreach ($data as $name => $value) {
97 if( is_numeric($name)){
98 array2Xml($value,
$xml->addChild(
'item'.$name));
100 array2Xml($value,
$xml->addChild($name));
106 if (!empty($return)) {
107 return $xml->asXML();