diff options
-rw-r--r-- | index.php | 39 |
1 files changed, 0 insertions, 39 deletions
@@ -2239,45 +2239,6 @@ function install() | |||
2239 | exit; | 2239 | exit; |
2240 | } | 2240 | } |
2241 | 2241 | ||
2242 | if (!function_exists('json_encode')) { | ||
2243 | function json_encode($data) { | ||
2244 | switch ($type = gettype($data)) { | ||
2245 | case 'NULL': | ||
2246 | return 'null'; | ||
2247 | case 'boolean': | ||
2248 | return ($data ? 'true' : 'false'); | ||
2249 | case 'integer': | ||
2250 | case 'double': | ||
2251 | case 'float': | ||
2252 | return $data; | ||
2253 | case 'string': | ||
2254 | return '"' . addslashes($data) . '"'; | ||
2255 | case 'object': | ||
2256 | $data = get_object_vars($data); | ||
2257 | case 'array': | ||
2258 | $output_index_count = 0; | ||
2259 | $output_indexed = array(); | ||
2260 | $output_associative = array(); | ||
2261 | foreach ($data as $key => $value) { | ||
2262 | $output_indexed[] = json_encode($value); | ||
2263 | $output_associative[] = json_encode($key) . ':' . json_encode($value); | ||
2264 | if ($output_index_count !== NULL && $output_index_count++ !== $key) { | ||
2265 | $output_index_count = NULL; | ||
2266 | } | ||
2267 | } | ||
2268 | if ($output_index_count !== NULL) { | ||
2269 | return '[' . implode(',', $output_indexed) . ']'; | ||
2270 | } else { | ||
2271 | return '{' . implode(',', $output_associative) . '}'; | ||
2272 | } | ||
2273 | default: | ||
2274 | return ''; // Not supported | ||
2275 | } | ||
2276 | } | ||
2277 | } | ||
2278 | |||
2279 | |||
2280 | |||
2281 | /* Because some f*cking services like flickr require an extra HTTP request to get the thumbnail URL, | 2242 | /* Because some f*cking services like flickr require an extra HTTP request to get the thumbnail URL, |
2282 | I have deported the thumbnail URL code generation here, otherwise this would slow down page generation. | 2243 | I have deported the thumbnail URL code generation here, otherwise this would slow down page generation. |
2283 | The following function takes the URL a link (e.g. a flickr page) and return the proper thumbnail. | 2244 | The following function takes the URL a link (e.g. a flickr page) and return the proper thumbnail. |