static public function encode($decode) { $result = ''; switch(gettype($decode)) { case 'array': if(!count($decode) ||array_keys($decode) === range(0,count($decode) -1)) { $keys = array(); foreach($decode as $value) { if(($value = FastJSON::encode($value)) !== '') array_push($keys,$value); } $result = '['.implode(',',$keys).']'; } else $result = FastJSON::convert($decode); break; case 'string': $replacement = FastJSON::__getStaticReplacement(); $result = '"'.str_replace($replacement['find'],$replacement['replace'],$decode).'"'; break; default: if(!is_callable($decode)) $result = FastJSON::convert($decode); break; } return $result; }
$result['User_id'] = $user_id; if (!empty($user_id)) { $balance = tools::readCache('bids_balance_' . $user_id); if (empty($balance)) { $balance = database::getInstance()->getRow("SELECT SUM(credit) - SUM(debit) AS balance FROM " . DB_PREFIX . "bids WHERE user_id = {$user_id}"); tools::writeCache('bids_balance_' . $user_id, $balance); } $result['Balance'] = $balance['balance']; } $result['Auction']['price'] = $result['Auction']['price']; $result['Auction']['serverTimestamp'] = time(); $result['Auction']['serverTimeString'] = date('d-m-Y, H:i:s'); $result['Auction']['time_left'] = strtotime($result['Auction']['end_time']) - time(); if ($result['Auction']['time_left'] <= 0 && $result['Auction']['closed'] == 0) { $result['Auction']['time_left'] = 1; } if ($site_online == 'no') { $result['Auction']['isPeakNow'] = 0; $result['Auction']['peak_only'] = 1; } else { $result['Auction']['isPeakNow'] = $isPeakNow; } $result['Auction']['start_time_string'] = tools::getStringTime($result['Auction']['start_time']); $result['Auction']['end_time_string'] = tools::getStringTime($result['Auction']['end_time']); $result['Auction']['end_time'] = strtotime($result['Auction']['end_time']); $results[] = $result; } header('Content-type: text/json'); $json = new FastJSON(); echo $json->convert($results);