63 $this->namespace = $db->escape($namespace); |
63 $this->namespace = $db->escape($namespace); |
64 } |
64 } |
65 |
65 |
66 /** |
66 /** |
67 * Processes a command in JSON format. |
67 * Processes a command in JSON format. |
68 * @param string The JSON-encoded input, probably something sent from the Javascript/AJAX frontend |
68 * @param mixed Either the JSON-encoded input string, probably something sent from the Javascript/AJAX frontend, or an equivalent array |
69 */ |
69 */ |
70 |
70 |
71 function process_json($json) |
71 function process_json($json) |
72 { |
72 { |
73 global $db, $session, $paths, $template, $plugins; // Common objects |
73 global $db, $session, $paths, $template, $plugins; // Common objects |
74 global $lang; |
74 global $lang; |
75 |
75 |
76 $data = enano_json_decode($json); |
76 $is_json = !is_array($json); |
77 $data = decode_unicode_array($data); |
77 |
|
78 if ( $is_json ) |
|
79 { |
|
80 $data = enano_json_decode($json); |
|
81 $data = decode_unicode_array($data); |
|
82 } |
|
83 else |
|
84 { |
|
85 $data =& $json; |
|
86 } |
78 if ( !isset($data['mode']) ) |
87 if ( !isset($data['mode']) ) |
79 { |
88 { |
80 $ret = Array('mode'=>'error','error'=>'No mode defined!'); |
89 $ret = Array('mode'=>'error','error'=>'No mode defined!'); |
81 echo enano_json_encode($ret); |
90 echo enano_json_encode($ret); |
82 return $ret; |
91 return $ret; |