Skip to content

Commit

Permalink
Fixed issue: Json_decode error for PHP versions < 5.2
Browse files Browse the repository at this point in the history
git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey@8000 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
c-schmitz committed Nov 28, 2009
1 parent 9a1b0ee commit cf1f656
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
18 changes: 18 additions & 0 deletions classes/core/startup.php
Expand Up @@ -60,6 +60,24 @@ function deregister_globals()
unset($input);
}

/**
* This function converts a standard # array to a PHP array without having to resort to JSON_decode which is available from 5.2x and up only
*
* @param string $json String with JSON data
* @return array
*/
if ( !function_exists('json_decode') ){
function json_decode($content, $assoc=false){
global $homedir;
require_once($homedir."/classes/json/JSON.php");
if ( $assoc ){
$json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
} else {
$json = new Services_JSON;
}
return $json->decode($content);
}
}


?>
21 changes: 3 additions & 18 deletions common.php
Expand Up @@ -303,6 +303,8 @@
$setfont = "<font size='2' face='verdana'>";
$singleborderstyle = "style='border: 1px solid #111111'";



/**
* showadminmenu() function returns html text for the administration button bar
*
Expand Down Expand Up @@ -7118,24 +7120,7 @@ function GetUpdateInfo()
return $updateinfo;
}

/**
* This function converts a standard JSON array to a PHP array without having to resort to JSON_decode which is available from 5.2x and up only
*
* @param string $json String with JSON data
* @return array
*/
if ( !function_exists('json_decode') ){
function json_decode($content, $assoc=false){
global $homedir;
require_once($homedir."/classes/json/JSON.php");
if ( $assoc ){
$json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
} else {
$json = new Services_JSON;
}
return $json->decode($content);
}
}


/**
* This function updates the actual global variables if an update is available after using GetUpdateInfo
Expand Down

0 comments on commit cf1f656

Please sign in to comment.