function initialize($json_file = false) { global $db, $settings, $schema; $player = $this->player; $this->equipped = $this->default_loadout(); $id = $player->id(); $id64 = $player->id64(); $key = 'BACKPACK_' . $id64; if (!$json_file) { global $_CACHE_ITEMS, $_CACHE_EQUIPPED; $cache = Cache::Memcached()->get($key); $this->items = $cache['items']; $this->equipped = $cache['equipped']; //var_dump($_CACHE_EQUIPPED); return; } $this->equipped = backpack::default_loadout(); $json = json_decode($json_file, true); /*?><pre><?php var_dump($json); ?></pre><?php*/ if (!$json) { // Try forcing UTF8 $response = utf8_encode($json_file); $json = json_decode($response, true); } $json_items = $json['result']['items']; if (!$json_items) { $this->error = true; $this->message = "Backpack is empty."; } else { foreach ($json_items as $i) { $items[] = $this->get_item($i); } } // create cache file $cache = array('items' => $items, 'equipped' => $this->equipped); $this->items = $items; //$this->equipped = $equipped; cache::Memcached()->set($key, $cache); //cache::clean('backpack'); }