aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNicolas Danelon <nicolasdanelon@users.noreply.github.com>2015-11-24 12:29:26 -0300
committerNicolas Danelon <nicolasdanelon@gmail.com>2015-11-25 09:42:29 -0300
commit1e57f90200c14d0143cd17529cbc0e7dc29f8061 (patch)
treeb2e413c46da194bac31eb3340d2dee8069521fef
parent4409b9eb0fb318f205ce7311bc41f10cfc716675 (diff)
downloadShaarli-1e57f90200c14d0143cd17529cbc0e7dc29f8061.tar.gz
Shaarli-1e57f90200c14d0143cd17529cbc0e7dc29f8061.tar.zst
Shaarli-1e57f90200c14d0143cd17529cbc0e7dc29f8061.zip
cleanup: remove json_encode() (built-in since PHP 5.2)
See http://php.net/manual/en/function.json-encode.php Legacy since php 5.2.x . If php5.3 is required for the install script
-rw-r--r--index.php39
1 files changed, 0 insertions, 39 deletions
diff --git a/index.php b/index.php
index aae477bf..b4d9395f 100644
--- a/index.php
+++ b/index.php
@@ -2239,45 +2239,6 @@ function install()
2239 exit; 2239 exit;
2240} 2240}
2241 2241
2242if (!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.