Home of the facelift image replacement forums
You are not logged in.
It looks like recaptcha is easily thwarted either by cheap labor or some other means, because I am still getting tons of spam signups.
I'm closing registrations again, if you would like to register, please email me at cory.mawhorter@ephective.com and use the subject line "Forum Registration". Give me your name and all the standard stuff in that email.
I will just have to do manual registrations until I have more time to spend on this problem.
-Cory, 2010-03-15
Thanks for bringing FLIR to us. Flash is not needed anymore.
Though I am having hard time installing it on our web server. The generate.php-file uses the function "json_decode" which don't seems to be supported on PHP versionens older than 5.2.0. (using 5.1.x)
Are there any other function that we could use instead of json_decode?
Many thanks in advance.
Cheers!
--
Fatal error: Call to undefined function json_decode() in XXXX/generate.php on line XX
Line XX: $FStyle = preg_match('#^\{("[\w]+":"[^"]*",?)*\}$#i', $_GET['fstyle'])?json_decode($_GET['fstyle'], true):array();
--
Offline
I did actually solve this problem.
People who don't uses PHP 5.2.0+ might be interested in this solution.
1. Download JSON.php and put in i same folder as FLIR generate.php. --> http://mike.teczno.com/JSON.tar.gz
2. Add these lines at the bottom of JSON.php, but before "?>"
// Future-friendly json_encode
// Cred: http://abeautifulsite.net/notebook/71
if( !function_exists('json_encode') ) {
function json_encode($data) {
$json = new Services_JSON();
return( $json->encode($data) );
}
}
// Future-friendly json_decode
if( !function_exists('json_decode') ) {
function json_decode($data, $bool) {
if ($bool) {
$json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
} else {
$json = new Services_JSON();
}
return( $json->decode($data) );
}
}
4. Import the new JSON library by adding this line at the top of generate.php:
include("JSON.php");
//F
Offline
Yaaa... that's what I was going to recommend. Thanks for reporting it here and posting a solution. I'm making legacy PHP support a priority for the next release.
Offline
For any searchers finding this page, if you don't want to use the above library you could use this function:
if(!function_exists('json_decode')) {
// very plain json_decode
function json_decode($str, $ignore=true) {
$str = trim($str);
if(!preg_match('#^\{(("[\w]+":"[^"]*",?)*)\}$#i', $str, $m)) return array();
$data = explode('","', substr($m[1], 1, -1));
$ret = array();
for($i=0; $i<count($data);$i++) {
list($k,$v) = explode(':', $data[$i], 2);
$ret[substr($k, 0, -1)] = substr($v, 1);
}
return $ret;
}
}It will only convert single dimensional json objects but that is all I ever need to do anyway. Otherwise, you could use the above library. This code comes from Facelift Image Replacement's inc-flir.php file.
Offline
Wow i'm happy i found this thread. :)
Cory, we tried your json_decode but didnt have any luck with it.
This was our final implementation. very similar to Fippe's but using a require inside. That way it plays nicely in both 5.1 and 5.2.
// PHP Compat stuff
if (!function_exists('json_encode')) {
require_once 'JSON/JSON.php';
function json_encode($arg)
{
global $services_json;
if (!isset($services_json)) {
$services_json = new Services_JSON();
}
return $services_json->encode($arg);
}
}
if( !function_exists('json_decode') ) {
require_once 'JSON/JSON.php';
function json_decode($data, $bool) {
if ($bool) {
$json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
} else {
$json = new Services_JSON();
}
return( $json->decode($data) );
}
}Offline
Yeah... that function only works in limited circumstances. Mainly... single dimensional arrays with pretty vanilla keys and values. You could modify the regex to allow for more characters and to check for escaped quotes but I haven't because there was no need for it with FLIR.
Offline