UPGRADE NOTE: Do not edit or add to this file if you wish to upgrade AbanteCart to newer versions in the future. If you wish to customize AbanteCart for your needs please refer to http://www.AbanteCart.com for more information. ------------------------------------------------------------------------------*/ if (!defined('DIR_CORE')) { header('Location: static_pages/'); } final class AJson { static public function encode($data) { if (function_exists('json_encode')) { return json_encode($data); } else { switch (gettype($data)) { case 'boolean': return $data ? 'true' : 'false'; case 'integer': case 'double': return $data; case 'resource': case 'string': return '"' . str_replace(array( "\r", "\n", "<", ">", "&" ), array( '\r', '\n', '\x3c', '\x3e', '\x26' ), addslashes($data)) . '"'; case 'array': if (empty($data) || array_keys($data) === range(0, sizeof($data) - 1)) { $stdout = array(); foreach ($data as $value) { $stdout[ ] = AJson::encode($value); } return '[ ' . implode(', ', $stdout) . ' ]'; } case 'object': $stdout = array(); foreach ($data as $key => $value) { $stdout[ ] = AJson::encode(strval($key)) . ': ' . AJson::encode($value); } return '{ ' . implode(', ', $stdout) . ' }'; default: return 'null'; } } } static public function decode($json, $assoc = FALSE) { if (function_exists('json_decode')) { return json_decode($json, $assoc); } else { $match = '/".*?(? '=>', '[' => 'array(', '{' => "{$a}array(", ']' => ')', '}' => ')' ); $json = strtr($json, $data); $json = preg_replace('~([\s\(,>])(-?)0~', '$1$2', $json); $json = strtr($json, $m2s); $function = @create_function('', "return {$json};"); $return = ($function) ? $function() : NULL; unset($s2m); unset($m2s); unset($function); return $return; } } } ?>