Example #1
0
 public static function getWarInfo($warID)
 {
     global $mdb;
     $warInfo = array();
     if ($warID == null) {
         return $warInfo;
     }
     $warInfo = $mdb->findDoc('information', ['type' => 'warID', 'id' => $warID]);
     if (!isset($warInfo['aggressor'])) {
         return [];
     }
     $warInfo['warID'] = $warID;
     $agr = $warInfo['aggressor']['id'];
     $agrIsAlliance = self::isAlliance($agr);
     $agrName = $agrIsAlliance ? Info::getInfoField('allianceID', $agr, 'name') : Info::getInfoField('corporationID', $agr, 'name');
     $warInfo['agrName'] = $agrName;
     $warInfo['agrLink'] = ($agrIsAlliance ? '/alliance/' : '/corporation/') . "{$agr}/";
     $dfd = $warInfo['defender']['id'];
     $dfdIsAlliance = self::isAlliance($dfd);
     $dfdName = $dfdIsAlliance ? Info::getInfoField('allianceID', $dfd, 'name') : Info::getInfoField('corporationID', $dfd, 'name');
     $warInfo['dfdName'] = $dfdName;
     $warInfo['dfdLink'] = ($dfdIsAlliance ? '/alliance/' : '/corporation/') . "{$dfd}/";
     $warInfo['dscr'] = "{$agrName} vs {$dfdName}";
     return $warInfo;
 }
Example #2
0
 private static function getInvolved(&$kills, $team)
 {
     $involved = array();
     foreach ($kills as $kill) {
         $kill = self::$killstorage[$kill['victim']['killID']];
         $attackers = $kill['involved'];
         array_shift($attackers);
         if (is_array($attackers)) {
             foreach ($attackers as $entry) {
                 $add = false;
                 if (in_array(@$entry['allianceID'], $team)) {
                     $add = true;
                 }
                 if (in_array(@$entry['corporationID'], $team)) {
                     $add = true;
                 }
                 if ($add) {
                     $key = @$entry['characterID'] . ':' . @$entry['corporationID'] . ':' . @$entry['allianceID'] . ':' . @$entry['shipTypeID'];
                     $entry['shipName'] = Info::getInfoField('typeID', @$entry['shipTypeID'], 'name');
                     if (!in_array($key, $involved)) {
                         $involved[$key] = $entry;
                     }
                 }
             }
         }
     }
     return $involved;
 }
Example #3
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;
 }
Example #4
0
 /**
  * [getGroupID description].
  *
  * @param int $id
  *
  * @return int
  */
 public static function getGroupID($id)
 {
     return Info::getInfoField('typeID', $id, 'groupID');
 }
Example #5
0
 public static function addItems(&$itemArray, $items, $killTime, $inContainer = 0, $parentFlag = 0)
 {
     if ($items == null) {
         return;
     }
     if (is_array($items)) {
         foreach ($items as $item) {
             $typeID = $item['itemType']['id'];
             $item['typeID'] = $typeID;
             $item['price'] = Price::getItemPrice($typeID, $killTime);
             $item['inContainer'] = $inContainer;
             if ($inContainer) {
                 $item['flag'] = $parentFlag;
             }
             if ($inContainer && strpos(Info::getInfoField('typeID', $typeID, 'name'), 'Blueprint')) {
                 $item['singleton'] = 2;
             }
             unset($item['_stringValue']);
             $itemArray[] = $item;
             $subItems = isset($item['items']) ? $item['items'] : null;
             unset($item['items']);
             if ($subItems != null) {
                 self::addItems($itemArray, $subItems, $killTime, 1, $item['flag']);
             }
         }
     }
 }
Example #6
0
        case 'warID':
            continue;
        case 'corporationID':
            $flag = @$entity['ticker'];
            break;
        case 'allianceID':
            $flag = @$entity['ticker'];
            break;
        case 'typeID':
            if ($mdb->exists('killmails', ['involved.shipTypeID' => $id])) {
                $flag = strtolower($name);
            }
            if (@$entity['published'] != true && $flag == '') {
                continue;
            }
            $isShip = $flag != '';
            break;
        case 'solarSystemID':
            $regionID = Info::getInfoField('solarSystemID', $id, 'regionID');
            $regionName = Info::getInfoField('regionID', $regionID, 'name');
            $name = "{$name} ({$regionName})";
            break;
    }
    if (!$isShip) {
        $redis->zAdd("search:{$type}", 0, strtolower($name) . "{$id}");
    }
    if (strlen($flag) > 0) {
        $redis->zAdd("search:{$type}:flag", 0, strtolower("{$flag}{$id}"));
    }
}
$redis->setex($key, 3600, true);
Example #7
0
 public static function eftarray($md5, $items, $victimID = 0)
 {
     // EFT / Fitting Wheel
     $eftarray['high'] = array();
     // high
     $eftarray['mid'] = array();
     // mid
     $eftarray['low'] = array();
     // low
     $eftarray['rig'] = array();
     // rig
     $eftarray['drone'] = array();
     // drone
     $eftarray['sub'] = array();
     // sub
     $eftammo['high'] = array();
     // high ammo
     $eftammo['mid'] = array();
     // mid ammo
     foreach ($items as $itm) {
         if (!isset($itm['inContainer'])) {
             $itm['inContainer'] = 0;
         }
         if ($victimID >= 2100000000 && $victimID <= 2999999999) {
             $itm['flagName'] = Info::getInfoField('groupID', Info::getGroupID($itm['typeID']), 'name');
         } elseif (!isset($itm['flagName'])) {
             $itm['flagName'] = Info::getFlagName($itm['flag']);
         }
         if ($itm['flagName'] == 'Infantry Modules') {
             $itm['flagName'] = 'Mid Slots';
         }
         if ($itm['flagName'] == 'Infantry Weapons') {
             $itm['flagName'] = 'High Slots';
         }
         if ($itm['flagName'] == 'Infantry Equipment') {
             $itm['flagName'] = 'Low Slots';
         }
         if ($itm['flag'] == 89) {
             $slot = Db::queryField('select coalesce(valueInt, valueFloat) slot from ccp_dgmTypeAttributes where typeID = :typeID and attributeID = 331', 'slot', array(':typeID' => $itm['typeID']));
             if ($slot <= 5 && $slot >= 1) {
                 $itm['flagName'] = 'High Slots';
                 $itm['flag'] = 27 + ($slot - 1);
             } elseif ($slot > 5 && $slot <= 10) {
                 $itm['flagName'] = 'Low Slots';
                 $itm['flag'] = 11 + ($slot - 6);
             }
             $itm['fittable'] = 1;
         }
         if (!isset($itm['flag']) || $itm['flag'] == 0) {
             if ($itm['flagName'] == 'High Slots') {
                 $itm['flag'] = 27;
             }
             if ($itm['flagName'] == 'Mid Slots') {
                 $itm['flag'] = 19;
             }
             if ($itm['flagName'] == 'Low Slots') {
                 $itm['flag'] = 11;
             }
         }
         $key = $itm['typeName'] . '|' . $itm['flagName'];
         if (isset($itm['flagName'])) {
             if ($itm['flagName'] == 'SubSystems' || $itm['fittable'] && $itm['inContainer'] == 0) {
                 // not ammo or whatever
                 $repeats = @$itm['quantityDropped'] + @$itm['quantityDestroyed'];
                 $i = 0;
                 while ($i < $repeats) {
                     if ($itm['flagName'] == 'High Slots') {
                         high:
                         if (isset($eftarray['high'][$itm['flag']])) {
                             $itm['flag'] = $itm['flag'] + 1;
                             goto high;
                         }
                         $eftarray['high'][$itm['flag']][] = array('typeName' => $itm['typeName'], 'typeID' => $itm['typeID']);
                     }
                     if ($itm['flagName'] == 'Mid Slots') {
                         mid:
                         if (isset($eftarray['mid'][$itm['flag']])) {
                             $itm['flag'] = $itm['flag'] + 1;
                             goto mid;
                         }
                         $eftarray['mid'][$itm['flag']][] = array('typeName' => $itm['typeName'], 'typeID' => $itm['typeID']);
                     }
                     if ($itm['flagName'] == 'Low Slots') {
                         low:
                         if (isset($eftarray['low'][$itm['flag']])) {
                             $itm['flag'] = $itm['flag'] + 1;
                             goto low;
                         }
                         $eftarray['low'][$itm['flag']][] = array('typeName' => $itm['typeName'], 'typeID' => $itm['typeID']);
                     }
                     if ($itm['flagName'] == 'Rigs') {
                         rigs:
                         if (isset($eftarray['rig'][$itm['flag']])) {
                             $itm['flag'] = $itm['flag'] + 1;
                             goto rigs;
                         }
                         $eftarray['rig'][$itm['flag']][] = array('typeName' => $itm['typeName'], 'typeID' => $itm['typeID']);
                     }
                     if ($itm['flagName'] == 'SubSystems') {
                         subs:
                         if (isset($eftarray['sub'][$itm['flag']])) {
                             $itm['flag'] = $itm['flag'] + 1;
                             goto subs;
                         }
                         $eftarray['sub'][$itm['flag']][] = array('typeName' => $itm['typeName'], 'typeID' => $itm['typeID']);
                     }
                     ++$i;
                 }
             } else {
                 if ($itm['flagName'] == 'Drone Bay') {
                     $eftarray['drone'][$itm['flag']][] = array('typeName' => $itm['typeName'], 'typeID' => $itm['typeID'], 'qty' => @$itm['quantityDropped'] + @$itm['quantityDestroyed']);
                 }
             }
         }
     }
     // Ammo shit
     foreach ($items as $itm) {
         if (!isset($itm['inContainer'])) {
             $itm['inContainer'] = 0;
         }
         if ($itm['inContainer'] == 0 && !$itm['fittable'] && isset($itm['flagName'])) {
             // possibly ammo
             if ($itm['flagName'] == 'High Slots') {
                 // high slot ammo
                 $eftarray['high'][$itm['flag']][] = array('typeName' => $itm['typeName'], 'typeID' => $itm['typeID'], 'charge' => true);
             }
             if ($itm['flagName'] == 'Mid Slots') {
                 // mid slot ammo
                 $eftarray['mid'][$itm['flag']][] = array('typeName' => $itm['typeName'], 'typeID' => $itm['typeID'], 'charge' => true);
             }
             if ($itm['flagName'] == 'Low Slots') {
                 // mid slot ammo
                 $eftarray['low'][$itm['flag']][] = array('typeName' => $itm['typeName'], 'typeID' => $itm['typeID'], 'charge' => true);
             }
         }
     }
     foreach ($eftarray as $key => $value) {
         if (sizeof($value)) {
             asort($value);
             $eftarray[$key] = $value;
         } else {
             unset($eftarray[$key]);
         }
     }
     return $eftarray;
 }