Edit File by line
/home/zeestwma/richards.../wp-inclu...
File: class-json.php
[500] Fix | Delete
// treat as a JSON object
[501] Fix | Delete
if (is_array($var) && count($var) && (array_keys($var) !== range(0, sizeof($var) - 1))) {
[502] Fix | Delete
$properties = array_map(array($this, 'name_value'),
[503] Fix | Delete
array_keys($var),
[504] Fix | Delete
array_values($var));
[505] Fix | Delete
[506] Fix | Delete
foreach($properties as $property) {
[507] Fix | Delete
if(Services_JSON::isError($property)) {
[508] Fix | Delete
return $property;
[509] Fix | Delete
}
[510] Fix | Delete
}
[511] Fix | Delete
[512] Fix | Delete
return '{' . join(',', $properties) . '}';
[513] Fix | Delete
}
[514] Fix | Delete
[515] Fix | Delete
// treat it like a regular array
[516] Fix | Delete
$elements = array_map(array($this, '_encode'), $var);
[517] Fix | Delete
[518] Fix | Delete
foreach($elements as $element) {
[519] Fix | Delete
if(Services_JSON::isError($element)) {
[520] Fix | Delete
return $element;
[521] Fix | Delete
}
[522] Fix | Delete
}
[523] Fix | Delete
[524] Fix | Delete
return '[' . join(',', $elements) . ']';
[525] Fix | Delete
[526] Fix | Delete
case 'object':
[527] Fix | Delete
[528] Fix | Delete
// support toJSON methods.
[529] Fix | Delete
if (($this->use & SERVICES_JSON_USE_TO_JSON) && method_exists($var, 'toJSON')) {
[530] Fix | Delete
// this may end up allowing unlimited recursion
[531] Fix | Delete
// so we check the return value to make sure it's not got the same method.
[532] Fix | Delete
$recode = $var->toJSON();
[533] Fix | Delete
[534] Fix | Delete
if (method_exists($recode, 'toJSON')) {
[535] Fix | Delete
[536] Fix | Delete
return ($this->use & SERVICES_JSON_SUPPRESS_ERRORS)
[537] Fix | Delete
? 'null'
[538] Fix | Delete
: new Services_JSON_Error(get_class($var).
[539] Fix | Delete
" toJSON returned an object with a toJSON method.");
[540] Fix | Delete
[541] Fix | Delete
}
[542] Fix | Delete
[543] Fix | Delete
return $this->_encode( $recode );
[544] Fix | Delete
}
[545] Fix | Delete
[546] Fix | Delete
$vars = get_object_vars($var);
[547] Fix | Delete
[548] Fix | Delete
$properties = array_map(array($this, 'name_value'),
[549] Fix | Delete
array_keys($vars),
[550] Fix | Delete
array_values($vars));
[551] Fix | Delete
[552] Fix | Delete
foreach($properties as $property) {
[553] Fix | Delete
if(Services_JSON::isError($property)) {
[554] Fix | Delete
return $property;
[555] Fix | Delete
}
[556] Fix | Delete
}
[557] Fix | Delete
[558] Fix | Delete
return '{' . join(',', $properties) . '}';
[559] Fix | Delete
[560] Fix | Delete
default:
[561] Fix | Delete
return ($this->use & SERVICES_JSON_SUPPRESS_ERRORS)
[562] Fix | Delete
? 'null'
[563] Fix | Delete
: new Services_JSON_Error(gettype($var)." can not be encoded as JSON string");
[564] Fix | Delete
}
[565] Fix | Delete
}
[566] Fix | Delete
[567] Fix | Delete
/**
[568] Fix | Delete
* array-walking function for use in generating JSON-formatted name-value pairs
[569] Fix | Delete
*
[570] Fix | Delete
* @deprecated 5.3.0 Use the PHP native JSON extension instead.
[571] Fix | Delete
*
[572] Fix | Delete
* @param string $name name of key to use
[573] Fix | Delete
* @param mixed $value reference to an array element to be encoded
[574] Fix | Delete
*
[575] Fix | Delete
* @return string JSON-formatted name-value pair, like '"name":value'
[576] Fix | Delete
* @access private
[577] Fix | Delete
*/
[578] Fix | Delete
function name_value($name, $value)
[579] Fix | Delete
{
[580] Fix | Delete
_deprecated_function( __METHOD__, '5.3.0', 'The PHP native JSON extension' );
[581] Fix | Delete
[582] Fix | Delete
$encoded_value = $this->_encode($value);
[583] Fix | Delete
[584] Fix | Delete
if(Services_JSON::isError($encoded_value)) {
[585] Fix | Delete
return $encoded_value;
[586] Fix | Delete
}
[587] Fix | Delete
[588] Fix | Delete
return $this->_encode((string) $name) . ':' . $encoded_value;
[589] Fix | Delete
}
[590] Fix | Delete
[591] Fix | Delete
/**
[592] Fix | Delete
* reduce a string by removing leading and trailing comments and whitespace
[593] Fix | Delete
*
[594] Fix | Delete
* @deprecated 5.3.0 Use the PHP native JSON extension instead.
[595] Fix | Delete
*
[596] Fix | Delete
* @param $str string string value to strip of comments and whitespace
[597] Fix | Delete
*
[598] Fix | Delete
* @return string string value stripped of comments and whitespace
[599] Fix | Delete
* @access private
[600] Fix | Delete
*/
[601] Fix | Delete
function reduce_string($str)
[602] Fix | Delete
{
[603] Fix | Delete
_deprecated_function( __METHOD__, '5.3.0', 'The PHP native JSON extension' );
[604] Fix | Delete
[605] Fix | Delete
$str = preg_replace(array(
[606] Fix | Delete
[607] Fix | Delete
// eliminate single line comments in '// ...' form
[608] Fix | Delete
'#^\s*//(.+)$#m',
[609] Fix | Delete
[610] Fix | Delete
// eliminate multi-line comments in '/* ... */' form, at start of string
[611] Fix | Delete
'#^\s*/\*(.+)\*/#Us',
[612] Fix | Delete
[613] Fix | Delete
// eliminate multi-line comments in '/* ... */' form, at end of string
[614] Fix | Delete
'#/\*(.+)\*/\s*$#Us'
[615] Fix | Delete
[616] Fix | Delete
), '', $str);
[617] Fix | Delete
[618] Fix | Delete
// eliminate extraneous space
[619] Fix | Delete
return trim($str);
[620] Fix | Delete
}
[621] Fix | Delete
[622] Fix | Delete
/**
[623] Fix | Delete
* decodes a JSON string into appropriate variable
[624] Fix | Delete
*
[625] Fix | Delete
* @deprecated 5.3.0 Use the PHP native JSON extension instead.
[626] Fix | Delete
*
[627] Fix | Delete
* @param string $str JSON-formatted string
[628] Fix | Delete
*
[629] Fix | Delete
* @return mixed number, boolean, string, array, or object
[630] Fix | Delete
* corresponding to given JSON input string.
[631] Fix | Delete
* See argument 1 to Services_JSON() above for object-output behavior.
[632] Fix | Delete
* Note that decode() always returns strings
[633] Fix | Delete
* in ASCII or UTF-8 format!
[634] Fix | Delete
* @access public
[635] Fix | Delete
*/
[636] Fix | Delete
function decode($str)
[637] Fix | Delete
{
[638] Fix | Delete
_deprecated_function( __METHOD__, '5.3.0', 'The PHP native JSON extension' );
[639] Fix | Delete
[640] Fix | Delete
$str = $this->reduce_string($str);
[641] Fix | Delete
[642] Fix | Delete
switch (strtolower($str)) {
[643] Fix | Delete
case 'true':
[644] Fix | Delete
return true;
[645] Fix | Delete
[646] Fix | Delete
case 'false':
[647] Fix | Delete
return false;
[648] Fix | Delete
[649] Fix | Delete
case 'null':
[650] Fix | Delete
return null;
[651] Fix | Delete
[652] Fix | Delete
default:
[653] Fix | Delete
$m = array();
[654] Fix | Delete
[655] Fix | Delete
if (is_numeric($str)) {
[656] Fix | Delete
// Lookie-loo, it's a number
[657] Fix | Delete
[658] Fix | Delete
// This would work on its own, but I'm trying to be
[659] Fix | Delete
// good about returning integers where appropriate:
[660] Fix | Delete
// return (float)$str;
[661] Fix | Delete
[662] Fix | Delete
// Return float or int, as appropriate
[663] Fix | Delete
return ((float)$str == (integer)$str)
[664] Fix | Delete
? (integer)$str
[665] Fix | Delete
: (float)$str;
[666] Fix | Delete
[667] Fix | Delete
} elseif (preg_match('/^("|\').*(\1)$/s', $str, $m) && $m[1] == $m[2]) {
[668] Fix | Delete
// STRINGS RETURNED IN UTF-8 FORMAT
[669] Fix | Delete
$delim = $this->substr8($str, 0, 1);
[670] Fix | Delete
$chrs = $this->substr8($str, 1, -1);
[671] Fix | Delete
$utf8 = '';
[672] Fix | Delete
$strlen_chrs = $this->strlen8($chrs);
[673] Fix | Delete
[674] Fix | Delete
for ($c = 0; $c < $strlen_chrs; ++$c) {
[675] Fix | Delete
[676] Fix | Delete
$substr_chrs_c_2 = $this->substr8($chrs, $c, 2);
[677] Fix | Delete
$ord_chrs_c = ord($chrs[$c]);
[678] Fix | Delete
[679] Fix | Delete
switch (true) {
[680] Fix | Delete
case $substr_chrs_c_2 == '\b':
[681] Fix | Delete
$utf8 .= chr(0x08);
[682] Fix | Delete
++$c;
[683] Fix | Delete
break;
[684] Fix | Delete
case $substr_chrs_c_2 == '\t':
[685] Fix | Delete
$utf8 .= chr(0x09);
[686] Fix | Delete
++$c;
[687] Fix | Delete
break;
[688] Fix | Delete
case $substr_chrs_c_2 == '\n':
[689] Fix | Delete
$utf8 .= chr(0x0A);
[690] Fix | Delete
++$c;
[691] Fix | Delete
break;
[692] Fix | Delete
case $substr_chrs_c_2 == '\f':
[693] Fix | Delete
$utf8 .= chr(0x0C);
[694] Fix | Delete
++$c;
[695] Fix | Delete
break;
[696] Fix | Delete
case $substr_chrs_c_2 == '\r':
[697] Fix | Delete
$utf8 .= chr(0x0D);
[698] Fix | Delete
++$c;
[699] Fix | Delete
break;
[700] Fix | Delete
[701] Fix | Delete
case $substr_chrs_c_2 == '\\"':
[702] Fix | Delete
case $substr_chrs_c_2 == '\\\'':
[703] Fix | Delete
case $substr_chrs_c_2 == '\\\\':
[704] Fix | Delete
case $substr_chrs_c_2 == '\\/':
[705] Fix | Delete
if (($delim == '"' && $substr_chrs_c_2 != '\\\'') ||
[706] Fix | Delete
($delim == "'" && $substr_chrs_c_2 != '\\"')) {
[707] Fix | Delete
$utf8 .= $chrs[++$c];
[708] Fix | Delete
}
[709] Fix | Delete
break;
[710] Fix | Delete
[711] Fix | Delete
case preg_match('/\\\u[0-9A-F]{4}/i', $this->substr8($chrs, $c, 6)):
[712] Fix | Delete
// single, escaped unicode character
[713] Fix | Delete
$utf16 = chr(hexdec($this->substr8($chrs, ($c + 2), 2)))
[714] Fix | Delete
. chr(hexdec($this->substr8($chrs, ($c + 4), 2)));
[715] Fix | Delete
$utf8 .= $this->utf162utf8($utf16);
[716] Fix | Delete
$c += 5;
[717] Fix | Delete
break;
[718] Fix | Delete
[719] Fix | Delete
case ($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F):
[720] Fix | Delete
$utf8 .= $chrs[$c];
[721] Fix | Delete
break;
[722] Fix | Delete
[723] Fix | Delete
case ($ord_chrs_c & 0xE0) == 0xC0:
[724] Fix | Delete
// characters U-00000080 - U-000007FF, mask 110XXXXX
[725] Fix | Delete
//see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
[726] Fix | Delete
$utf8 .= $this->substr8($chrs, $c, 2);
[727] Fix | Delete
++$c;
[728] Fix | Delete
break;
[729] Fix | Delete
[730] Fix | Delete
case ($ord_chrs_c & 0xF0) == 0xE0:
[731] Fix | Delete
// characters U-00000800 - U-0000FFFF, mask 1110XXXX
[732] Fix | Delete
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
[733] Fix | Delete
$utf8 .= $this->substr8($chrs, $c, 3);
[734] Fix | Delete
$c += 2;
[735] Fix | Delete
break;
[736] Fix | Delete
[737] Fix | Delete
case ($ord_chrs_c & 0xF8) == 0xF0:
[738] Fix | Delete
// characters U-00010000 - U-001FFFFF, mask 11110XXX
[739] Fix | Delete
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
[740] Fix | Delete
$utf8 .= $this->substr8($chrs, $c, 4);
[741] Fix | Delete
$c += 3;
[742] Fix | Delete
break;
[743] Fix | Delete
[744] Fix | Delete
case ($ord_chrs_c & 0xFC) == 0xF8:
[745] Fix | Delete
// characters U-00200000 - U-03FFFFFF, mask 111110XX
[746] Fix | Delete
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
[747] Fix | Delete
$utf8 .= $this->substr8($chrs, $c, 5);
[748] Fix | Delete
$c += 4;
[749] Fix | Delete
break;
[750] Fix | Delete
[751] Fix | Delete
case ($ord_chrs_c & 0xFE) == 0xFC:
[752] Fix | Delete
// characters U-04000000 - U-7FFFFFFF, mask 1111110X
[753] Fix | Delete
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
[754] Fix | Delete
$utf8 .= $this->substr8($chrs, $c, 6);
[755] Fix | Delete
$c += 5;
[756] Fix | Delete
break;
[757] Fix | Delete
[758] Fix | Delete
}
[759] Fix | Delete
[760] Fix | Delete
}
[761] Fix | Delete
[762] Fix | Delete
return $utf8;
[763] Fix | Delete
[764] Fix | Delete
} elseif (preg_match('/^\[.*\]$/s', $str) || preg_match('/^\{.*\}$/s', $str)) {
[765] Fix | Delete
// array, or object notation
[766] Fix | Delete
[767] Fix | Delete
if ($str[0] == '[') {
[768] Fix | Delete
$stk = array(SERVICES_JSON_IN_ARR);
[769] Fix | Delete
$arr = array();
[770] Fix | Delete
} else {
[771] Fix | Delete
if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
[772] Fix | Delete
$stk = array(SERVICES_JSON_IN_OBJ);
[773] Fix | Delete
$obj = array();
[774] Fix | Delete
} else {
[775] Fix | Delete
$stk = array(SERVICES_JSON_IN_OBJ);
[776] Fix | Delete
$obj = new stdClass();
[777] Fix | Delete
}
[778] Fix | Delete
}
[779] Fix | Delete
[780] Fix | Delete
array_push($stk, array('what' => SERVICES_JSON_SLICE,
[781] Fix | Delete
'where' => 0,
[782] Fix | Delete
'delim' => false));
[783] Fix | Delete
[784] Fix | Delete
$chrs = $this->substr8($str, 1, -1);
[785] Fix | Delete
$chrs = $this->reduce_string($chrs);
[786] Fix | Delete
[787] Fix | Delete
if ($chrs == '') {
[788] Fix | Delete
if (reset($stk) == SERVICES_JSON_IN_ARR) {
[789] Fix | Delete
return $arr;
[790] Fix | Delete
[791] Fix | Delete
} else {
[792] Fix | Delete
return $obj;
[793] Fix | Delete
[794] Fix | Delete
}
[795] Fix | Delete
}
[796] Fix | Delete
[797] Fix | Delete
//print("\nparsing {$chrs}\n");
[798] Fix | Delete
[799] Fix | Delete
$strlen_chrs = $this->strlen8($chrs);
[800] Fix | Delete
[801] Fix | Delete
for ($c = 0; $c <= $strlen_chrs; ++$c) {
[802] Fix | Delete
[803] Fix | Delete
$top = end($stk);
[804] Fix | Delete
$substr_chrs_c_2 = $this->substr8($chrs, $c, 2);
[805] Fix | Delete
[806] Fix | Delete
if (($c == $strlen_chrs) || (($chrs[$c] == ',') && ($top['what'] == SERVICES_JSON_SLICE))) {
[807] Fix | Delete
// found a comma that is not inside a string, array, etc.,
[808] Fix | Delete
// OR we've reached the end of the character list
[809] Fix | Delete
$slice = $this->substr8($chrs, $top['where'], ($c - $top['where']));
[810] Fix | Delete
array_push($stk, array('what' => SERVICES_JSON_SLICE, 'where' => ($c + 1), 'delim' => false));
[811] Fix | Delete
//print("Found split at {$c}: ".$this->substr8($chrs, $top['where'], (1 + $c - $top['where']))."\n");
[812] Fix | Delete
[813] Fix | Delete
if (reset($stk) == SERVICES_JSON_IN_ARR) {
[814] Fix | Delete
// we are in an array, so just push an element onto the stack
[815] Fix | Delete
array_push($arr, $this->decode($slice));
[816] Fix | Delete
[817] Fix | Delete
} elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
[818] Fix | Delete
// we are in an object, so figure
[819] Fix | Delete
// out the property name and set an
[820] Fix | Delete
// element in an associative array,
[821] Fix | Delete
// for now
[822] Fix | Delete
$parts = array();
[823] Fix | Delete
[824] Fix | Delete
if (preg_match('/^\s*(["\'].*[^\\\]["\'])\s*:/Uis', $slice, $parts)) {
[825] Fix | Delete
// "name":value pair
[826] Fix | Delete
$key = $this->decode($parts[1]);
[827] Fix | Delete
$val = $this->decode(trim(substr($slice, strlen($parts[0])), ", \t\n\r\0\x0B"));
[828] Fix | Delete
if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
[829] Fix | Delete
$obj[$key] = $val;
[830] Fix | Delete
} else {
[831] Fix | Delete
$obj->$key = $val;
[832] Fix | Delete
}
[833] Fix | Delete
} elseif (preg_match('/^\s*(\w+)\s*:/Uis', $slice, $parts)) {
[834] Fix | Delete
// name:value pair, where name is unquoted
[835] Fix | Delete
$key = $parts[1];
[836] Fix | Delete
$val = $this->decode(trim(substr($slice, strlen($parts[0])), ", \t\n\r\0\x0B"));
[837] Fix | Delete
[838] Fix | Delete
if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
[839] Fix | Delete
$obj[$key] = $val;
[840] Fix | Delete
} else {
[841] Fix | Delete
$obj->$key = $val;
[842] Fix | Delete
}
[843] Fix | Delete
}
[844] Fix | Delete
[845] Fix | Delete
}
[846] Fix | Delete
[847] Fix | Delete
} elseif ((($chrs[$c] == '"') || ($chrs[$c] == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) {
[848] Fix | Delete
// found a quote, and we are not inside a string
[849] Fix | Delete
array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs[$c]));
[850] Fix | Delete
//print("Found start of string at {$c}\n");
[851] Fix | Delete
[852] Fix | Delete
} elseif (($chrs[$c] == $top['delim']) &&
[853] Fix | Delete
($top['what'] == SERVICES_JSON_IN_STR) &&
[854] Fix | Delete
(($this->strlen8($this->substr8($chrs, 0, $c)) - $this->strlen8(rtrim($this->substr8($chrs, 0, $c), '\\'))) % 2 != 1)) {
[855] Fix | Delete
// found a quote, we're in a string, and it's not escaped
[856] Fix | Delete
// we know that it's not escaped because there is _not_ an
[857] Fix | Delete
// odd number of backslashes at the end of the string so far
[858] Fix | Delete
array_pop($stk);
[859] Fix | Delete
//print("Found end of string at {$c}: ".$this->substr8($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n");
[860] Fix | Delete
[861] Fix | Delete
} elseif (($chrs[$c] == '[') &&
[862] Fix | Delete
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
[863] Fix | Delete
// found a left-bracket, and we are in an array, object, or slice
[864] Fix | Delete
array_push($stk, array('what' => SERVICES_JSON_IN_ARR, 'where' => $c, 'delim' => false));
[865] Fix | Delete
//print("Found start of array at {$c}\n");
[866] Fix | Delete
[867] Fix | Delete
} elseif (($chrs[$c] == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) {
[868] Fix | Delete
// found a right-bracket, and we're in an array
[869] Fix | Delete
array_pop($stk);
[870] Fix | Delete
//print("Found end of array at {$c}: ".$this->substr8($chrs, $top['where'], (1 + $c - $top['where']))."\n");
[871] Fix | Delete
[872] Fix | Delete
} elseif (($chrs[$c] == '{') &&
[873] Fix | Delete
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
[874] Fix | Delete
// found a left-brace, and we are in an array, object, or slice
[875] Fix | Delete
array_push($stk, array('what' => SERVICES_JSON_IN_OBJ, 'where' => $c, 'delim' => false));
[876] Fix | Delete
//print("Found start of object at {$c}\n");
[877] Fix | Delete
[878] Fix | Delete
} elseif (($chrs[$c] == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) {
[879] Fix | Delete
// found a right-brace, and we're in an object
[880] Fix | Delete
array_pop($stk);
[881] Fix | Delete
//print("Found end of object at {$c}: ".$this->substr8($chrs, $top['where'], (1 + $c - $top['where']))."\n");
[882] Fix | Delete
[883] Fix | Delete
} elseif (($substr_chrs_c_2 == '/*') &&
[884] Fix | Delete
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
[885] Fix | Delete
// found a comment start, and we are in an array, object, or slice
[886] Fix | Delete
array_push($stk, array('what' => SERVICES_JSON_IN_CMT, 'where' => $c, 'delim' => false));
[887] Fix | Delete
$c++;
[888] Fix | Delete
//print("Found start of comment at {$c}\n");
[889] Fix | Delete
[890] Fix | Delete
} elseif (($substr_chrs_c_2 == '*/') && ($top['what'] == SERVICES_JSON_IN_CMT)) {
[891] Fix | Delete
// found a comment end, and we're in one now
[892] Fix | Delete
array_pop($stk);
[893] Fix | Delete
$c++;
[894] Fix | Delete
[895] Fix | Delete
for ($i = $top['where']; $i <= $c; ++$i)
[896] Fix | Delete
$chrs = substr_replace($chrs, ' ', $i, 1);
[897] Fix | Delete
[898] Fix | Delete
//print("Found end of comment at {$c}: ".$this->substr8($chrs, $top['where'], (1 + $c - $top['where']))."\n");
[899] Fix | Delete
[900] Fix | Delete
}
[901] Fix | Delete
[902] Fix | Delete
}
[903] Fix | Delete
[904] Fix | Delete
if (reset($stk) == SERVICES_JSON_IN_ARR) {
[905] Fix | Delete
return $arr;
[906] Fix | Delete
[907] Fix | Delete
} elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
[908] Fix | Delete
return $obj;
[909] Fix | Delete
[910] Fix | Delete
}
[911] Fix | Delete
[912] Fix | Delete
}
[913] Fix | Delete
}
[914] Fix | Delete
}
[915] Fix | Delete
[916] Fix | Delete
/**
[917] Fix | Delete
* @deprecated 5.3.0 Use the PHP native JSON extension instead.
[918] Fix | Delete
*
[919] Fix | Delete
* @todo Ultimately, this should just call PEAR::isError()
[920] Fix | Delete
*/
[921] Fix | Delete
function isError($data, $code = null)
[922] Fix | Delete
{
[923] Fix | Delete
_deprecated_function( __METHOD__, '5.3.0', 'The PHP native JSON extension' );
[924] Fix | Delete
[925] Fix | Delete
if (class_exists('pear')) {
[926] Fix | Delete
return PEAR::isError($data, $code);
[927] Fix | Delete
} elseif (is_object($data) && ($data instanceof services_json_error ||
[928] Fix | Delete
is_subclass_of($data, 'services_json_error'))) {
[929] Fix | Delete
return true;
[930] Fix | Delete
}
[931] Fix | Delete
[932] Fix | Delete
return false;
[933] Fix | Delete
}
[934] Fix | Delete
[935] Fix | Delete
/**
[936] Fix | Delete
* Calculates length of string in bytes
[937] Fix | Delete
*
[938] Fix | Delete
* @deprecated 5.3.0 Use the PHP native JSON extension instead.
[939] Fix | Delete
*
[940] Fix | Delete
* @param string
[941] Fix | Delete
* @return integer length
[942] Fix | Delete
*/
[943] Fix | Delete
function strlen8( $str )
[944] Fix | Delete
{
[945] Fix | Delete
_deprecated_function( __METHOD__, '5.3.0', 'The PHP native JSON extension' );
[946] Fix | Delete
[947] Fix | Delete
if ( $this->_mb_strlen ) {
[948] Fix | Delete
return mb_strlen( $str, "8bit" );
[949] Fix | Delete
}
[950] Fix | Delete
return strlen( $str );
[951] Fix | Delete
}
[952] Fix | Delete
[953] Fix | Delete
/**
[954] Fix | Delete
* Returns part of a string, interpreting $start and $length as number of bytes.
[955] Fix | Delete
*
[956] Fix | Delete
* @deprecated 5.3.0 Use the PHP native JSON extension instead.
[957] Fix | Delete
*
[958] Fix | Delete
* @param string
[959] Fix | Delete
* @param integer start
[960] Fix | Delete
* @param integer length
[961] Fix | Delete
* @return integer length
[962] Fix | Delete
*/
[963] Fix | Delete
function substr8( $string, $start, $length=false )
[964] Fix | Delete
{
[965] Fix | Delete
_deprecated_function( __METHOD__, '5.3.0', 'The PHP native JSON extension' );
[966] Fix | Delete
[967] Fix | Delete
if ( $length === false ) {
[968] Fix | Delete
$length = $this->strlen8( $string ) - $start;
[969] Fix | Delete
}
[970] Fix | Delete
if ( $this->_mb_substr ) {
[971] Fix | Delete
return mb_substr( $string, $start, $length, "8bit" );
[972] Fix | Delete
}
[973] Fix | Delete
return substr( $string, $start, $length );
[974] Fix | Delete
}
[975] Fix | Delete
[976] Fix | Delete
}
[977] Fix | Delete
[978] Fix | Delete
if (class_exists('PEAR_Error')) {
[979] Fix | Delete
[980] Fix | Delete
class Services_JSON_Error extends PEAR_Error
[981] Fix | Delete
{
[982] Fix | Delete
/**
[983] Fix | Delete
* PHP5 constructor.
[984] Fix | Delete
*
[985] Fix | Delete
* @deprecated 5.3.0 Use the PHP native JSON extension instead.
[986] Fix | Delete
*/
[987] Fix | Delete
function __construct($message = 'unknown error', $code = null,
[988] Fix | Delete
$mode = null, $options = null, $userinfo = null)
[989] Fix | Delete
{
[990] Fix | Delete
_deprecated_function( __METHOD__, '5.3.0', 'The PHP native JSON extension' );
[991] Fix | Delete
[992] Fix | Delete
parent::PEAR_Error($message, $code, $mode, $options, $userinfo);
[993] Fix | Delete
}
[994] Fix | Delete
[995] Fix | Delete
/**
[996] Fix | Delete
* PHP4 constructor.
[997] Fix | Delete
*
[998] Fix | Delete
* @deprecated 5.3.0 Use __construct() instead.
[999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function