Ejemplo n.º 1
0
 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;
 }
Ejemplo n.º 2
0
<?php

CrestSSO::login();
Ejemplo n.º 3
0
<?php

CrestSSO::callback();
die;
Ejemplo n.º 4
0
 public static function crestPost($url, $fields)
 {
     global $ccpClientID, $ccpSecret;
     $accessToken = CrestSSO::getAccessToken();
     $authHeader = "Authorization: Bearer {$accessToken}";
     $data = json_encode($fields);
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, "{$url}");
     curl_setopt($ch, CURLOPT_USERAGENT, CrestSSO::$userAgent);
     curl_setopt($ch, CURLOPT_HTTPHEADER, array($authHeader, 'Content-Type:application/json'));
     curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
     $result = curl_exec($ch);
     $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
     curl_close($ch);
     $json = json_decode($result, true);
     $json['httpCode'] = $httpCode;
     return $json;
 }