public static function saveFitting($killID) { global $mdb; $killmail = $mdb->findDoc('rawmails', ['killID' => (int) $killID]); $victim = $killmail['victim']; header('Content-Type: application/json'); $export = []; $export['name'] = @$victim['character']['name'] . "'s " . $victim['shipType']['name']; $export['description'] = "Imported from https://zkillboard.com/kill/{$killID}/"; $export['ship'] = ['id' => $victim['shipType']['id']]; $export['ship']['name'] = Info::getInfoField('typeID', $victim['shipType']['id'], 'name'); $export['ship']['href'] = "https://public-crest.eveonline.com/types/" . $victim['shipType']['id'] . "/"; $items = $victim['items']; $export['items'] = []; foreach ($items as $item) { $flag = $item['flag']; if (!self::isFit($flag)) { continue; } $nextItem = []; $nextItem['flag'] = $flag; $nextItem['quantity'] = @$item['quantityDropped'] + @$item['quantityDestroyed']; $nextItem['type']['id'] = $item['itemType']['id']; $nextItem['type']['name'] = Info::getInfoField('typeID', $item['itemType']['id'], 'name'); $nextItem['type']['href'] = "https://public-crest.eveonline.com/types/" . $item['itemType']['id'] . "/"; $export['items'][] = $nextItem; } if (sizeof($export['items']) == 0) { return ['message' => 'Cannot save this fit, no hardware.']; } $decode = CrestSSO::crestGet("https://crest-tq.eveonline.com/decode/"); if (isset($decode['message'])) { return $decode; } $character = CrestSSO::crestGet($decode['character']['href']); $result = CrestSSO::crestPost($character['fittings']['href'], $export); if ($result['httpCode'] == 201) { return ['message' => "Fit successfully saved to your character's fittings."]; } return $result; }