예제 #1
0
 private function updateChars()
 {
     if (empty($this->chars)) {
         return $this->chars;
     }
     foreach ($this->chars as $char) {
         // check if chars eveid exists in kb
         $sql = 'select plts.plt_id, plts.plt_externalid from kb3_pilots plts where plts.plt_name = "' . $char['Name'] . '"';
         $qry = DBFactory::getDBQuery();
         $qry->execute($sql);
         if ($qry->recordCount() != 0) {
             // pilot is in kb db, check he has his char id
             $row = $qry->getRow();
             $pilot_id = $row['plt_id'];
             $pilot_external_id = $row['plt_externalid'];
             if ($pilot_external_id == 0 && $pilot_id != 0) {
                 // update DB with ID
                 $qry->execute("UPDATE kb3_pilots SET plt_externalid = " . intval($char['charID']) . "\n                                     WHERE plt_id = " . $pilot_id);
             }
         } else {
             // pilot is not in DB
             // Set Corp
             $pilotscorp = Corporation::lookup($char['corpName']);
             // Check Corp was set, if not, add the Corp
             if (!$pilotscorp->getID()) {
                 $ialliance = Alliance::add('None');
                 $pilotscorp = Corporation::add($char['corpName'], $ialliance, gmdate("Y-m-d H:i:s"));
             }
             Pilot::add($char['Name'], $pilotscorp, gmdate("Y-m-d H:i:s"), intval($char['charID']));
         }
     }
     return;
 }
예제 #2
0
 public static function nameToId($type, $set, $value)
 {
     if ($type == 'nametoid') {
         $api = new API_NametoID();
         $api->setNames($value);
     } else {
         if ($type == 'idtoname') {
             $api = new API_IDtoName();
             $api->setIDs($value);
         }
     }
     $api->fetchXML();
     if ($type == 'nametoid') {
         $char_info = $api->getNameData();
     } else {
         if ($type == 'idtoname') {
             $char_info = $api->getIDData();
         }
     }
     if (isset($char_info[0]['characterID']) && strlen($char_info[0]['characterID']) > 0) {
         $timestamp = gmdate('%Y.%m.%d %H:%i:%s', time());
         if ($set == 'p') {
             $all = Alliance::add('Unknown');
             $crp = Corporation::add('Unknown', $all, $timestamp, 0, false);
             $plt = Pilot::add($char_info[0]['name'], $crp, $timestamp, $char_info[0]['characterID'], false);
             $_POST['option_cfg_pilotid'] = $value = $plt->getID();
             $pilots = config::get('cfg_pilotid');
             $pilots[] = intval($value);
             config::set('cfg_pilotid', $pilots);
             $html = '<input type="text" id="option_cfg_pilotid"' . ' name="option_cfg_pilotid" value="" size="40"' . ' maxlength="64" />';
         } else {
             if ($set == 'c') {
                 $all = Alliance::add('Unknown');
                 $crp = new Corporation();
                 $crp->add($char_info[0]['name'], $all, $timestamp, $char_info[0]['characterID'], false);
                 $_POST['option_cfg_corpid'] = $value = $crp->getID();
                 $corps = config::get('cfg_corpid');
                 $corps[] = intval($value);
                 config::set('cfg_pilotid', $corps);
                 $html = '<input type="text" id="option_cfg_corpid"' . ' name="option_cfg_corpid" value="" size="40"' . ' maxlength="64" />';
             } else {
                 if ($set == 'a') {
                     $all = Alliance::add('Unknown');
                     $_POST['option_cfg_allianceid'] = $value = $all->getID();
                     $alliances = config::get('option_cfg_allianceid');
                     $alliances[] = intval($value);
                     config::set('option_cfg_allianceid', $alliances);
                     $html = '<input type="text" id="option_cfg_allianceid"' . ' name="option_cfg_allianceid" value="" size="40"' . ' maxlength="64" />';
                 }
             }
         }
         return $html;
     } else {
         return $html;
     }
 }
예제 #3
0
 /**
  * Fetch the pilot name from CCP using the stored external ID.
  *
  * Corporation will be set to Unknown.
  */
 private function fetchPilot()
 {
     if (!$this->externalid) {
         return false;
     }
     $apiInfo = new API_CharacterInfo();
     $apiInfo->setID($this->externalid);
     $result .= $apiInfo->fetchXML();
     if ($result == "") {
         $data = $apiInfo->getData();
         $this->alliance = Alliance::add($data['alliance'], $data['allianceID']);
         $this->corp = Corporation::add($data['corporation'], $this->alliance, $apiInfo->getCurrentTime(), $data['corporationID']);
         $this->name = $data['characterName'];
         Pilot::add($data['characterName'], $this->corp, $apiInfo->getCurrentTime(), $data['characterID']);
     } else {
         return false;
     }
 }
예제 #4
0
 /**
  * @param SimpleXMLElement $inv
  * @param Kill $kill
  * @param string $time YYYY-mm-dd hh:ss
  * @return boolean false on error
  */
 private function processInvolved($inv, &$kill, $time)
 {
     if (!(int) $inv['shipTypeID'] && !(int) $inv['weaponTypeID'] && !(int) $inv['characterID'] && !(string) $inv['characterName']) {
         $this->parsemsg[] = "Involved party blank.";
         return false;
     }
     $npc = false;
     $ship = Ship::getByID((int) $inv['shipTypeID']);
     $weapon = Cacheable::factory('Item', (int) $inv['weaponTypeID']);
     $alliance = new Alliance();
     if ((int) $inv['allianceID']) {
         $alliance = Alliance::add(strval($inv['allianceName']), (int) $inv['allianceID']);
     } else {
         if ((int) $inv['factionID']) {
             $alliance = Alliance::add(strval($inv['factionName']), (int) $inv['factionID']);
         } else {
             $alliance = Alliance::add("None");
         }
     }
     // get alliance from corp if ship is any kind of tower
     $shipClassID = $ship->getClass()->getID();
     if ($shipClassID == 35 || $shipClassID == 36 || $shipClassID == 37) {
         $corpByName = Corporation::lookup(strval($inv['corporationName']));
         if ($corpByName) {
             $alliance = $corpByName->getAlliance();
         }
     }
     $corp = Corporation::add(strval($inv['corporationName']), $alliance, $time, (int) $inv['corporationID']);
     $charid = (int) $inv['characterID'];
     $charname = (string) $inv['characterName'];
     // Allow for blank names for consistency with CCP API.
     if (preg_match("/(Mobile (Large|Medium|Small) Warp Disruptor I?I?|\\w+ Control Tower( \\w+)?)/", $charname)) {
         $charname = $inv['corporationName'] . ' - ' . $charname;
         $charid = 0;
     } else {
         if ($charname == "" && preg_match("/(Mobile \\w+ Warp|\\w+ Control Tower( \\w+)?)/", $weapon->getName())) {
             $charname = $inv['corporationName'] . ' - ' . $weapon->getName();
             $charid = 0;
         } else {
             if ($charname == "" && !$charid) {
                 // NPC ship
                 $ship = Ship::lookup("Unknown");
                 $weapon = Item::getByID((int) $inv['shipTypeID']);
                 $charname = $weapon->getName();
                 $npc = true;
                 $charid = $weapon->getID();
             } else {
                 if ($charname == "" && $charid) {
                     // Bugged kill
                     $this->parsemsg[] = "Involved party has blank pilot name.";
                     return false;
                 }
             }
         }
     }
     $pilot = Pilot::add((string) $charname, $corp, $time, $charid);
     $iparty = new InvolvedParty($pilot->getID(), $corp->getID(), $alliance->getID(), (double) $inv['securityStatus'], $ship->getID(), $weapon->getID(), (int) $inv['damageDone']);
     $kill->addInvolvedParty($iparty);
     if ((int) $inv['finalBlow'] == 1) {
         $kill->setFBPilotID($pilot->getID());
     }
     $this->npcOnly = $this->npcOnly && $npc;
     return true;
 }
예제 #5
0
 /**
  *  Show the overall statistics for this alliance.
  */
 function stats()
 {
     $this->summary->generate();
     if ($this->pilot->getExternalID()) {
         $apiInfo = new API_CharacterInfo();
         $apiInfo->setID($this->pilot->getExternalID());
         $result .= $apiInfo->fetchXML();
         // Update the name if it has changed.
         if ($result == "") {
             $data = $apiInfo->getData();
             $this->alliance = Alliance::add($data['alliance'], $data['allianceID']);
             $this->corp = Corporation::add($data['corporation'], $this->alliance, $apiInfo->getCurrentTime(), $data['corporationID']);
             $this->pilot = Pilot::add($data['characterName'], $this->corp, $apiInfo->getCurrentTime(), $data['characterID']);
         }
     }
     global $smarty;
     $smarty->assign('portrait_URL', $this->pilot->getPortraitURL(128));
     $smarty->assign('corp_id', $this->corp->getID());
     $smarty->assign('corp_name', $this->corp->getName());
     $smarty->assign('all_name', $this->alliance->getName());
     $smarty->assign('all_id', $this->alliance->getID());
     $smarty->assign('klist_count', $this->summary->getTotalKills());
     $smarty->assign('klist_real_count', $this->summary->getTotalRealKills());
     //$this->klist->getRealCount());
     $smarty->assign('llist_count', $this->summary->getTotalLosses());
     $smarty->assign('klist_isk_B', round($this->summary->getTotalKillISK() / 1000000000, 2));
     $smarty->assign('llist_isk_B', round($this->summary->getTotalLossISK() / 1000000000, 2));
     //Pilot Efficiency Mod Begin (K Austin)
     if ($this->summary->getTotalKills() == 0) {
         $pilot_survival = 100;
         $pilot_efficiency = 0;
     } else {
         if ($this->summary->getTotalKills() + $this->summary->getTotalLosses()) {
             $pilot_survival = round($this->summary->getTotalLosses() / ($this->summary->getTotalKills() + $this->summary->getTotalLosses()) * 100, 2);
         } else {
             $pilot_survival = 0;
         }
         if ($this->summary->getTotalKillISK() + $this->summary->getTotalLossISK()) {
             $pilot_efficiency = round($this->summary->getTotalKillISK() / ($this->summary->getTotalKillISK() + $this->summary->getTotalLossISK()) * 100, 2);
         } else {
             $pilot_efficiency = 0;
         }
     }
     $smarty->assign('pilot_survival', $pilot_survival);
     $smarty->assign('pilot_efficiency', $pilot_efficiency);
     $smarty->assign('akey', session::isAdmin() ? session::makeKey() : false);
     $this->lpoints = $this->summary->getTotalLossPoints();
     $this->points = $this->summary->getTotalKillPoints();
     return $smarty->fetch(get_tpl('pilot_detail_stats'));
 }
예제 #6
0
 /**
  * Fetch corporation name and alliance from CCP using the stored external ID.
  *
  * @return boolean TRUE on success, FALSE on failure.
  */
 public function fetchCorp()
 {
     if (!$this->externalid) {
         $this->execQuery();
     }
     if (!$this->externalid) {
         return false;
     }
     $myAPI = new API_CorporationSheet();
     $myAPI->setCorpID($this->externalid);
     $result = $myAPI->fetchXML();
     if ($result == false) {
         return false;
     }
     $alliance = Alliance::add($myAPI->getAllianceName(), $myAPI->getAllianceID());
     if (!$alliance) {
         return false;
     }
     $crp = Corporation::add(slashfix($myAPI->getCorporationName()), $alliance, $myAPI->getCurrentTime(), intval($myAPI->getCorporationID()));
     $this->name = $crp->name;
     $this->alliance = $crp->alliance;
     $this->updated = $crp->updated;
     return true;
 }
예제 #7
0
 /**
  * Return corporation from cached list or look up a new name.
  *
  * @param string $corpname Alliance name to look up.
  * @return Corporation Corporation object matching input name.
  */
 private static function fetchCorp($corpname, $alliance = null, $timestamp = null)
 {
     if (isset(self::$corps[$corpname])) {
         if (!is_null($timestamp) && self::$corps[$corpname]->isUpdatable($timestamp)) {
             self::$corps[$corpname]->add($corpname, $alliance, $timestamp, 0, self::$loadExternals);
         }
         $corp = self::$corps[$corpname];
     } else {
         if ($alliance == null) {
             $corp = Corporation::lookup($corpname);
             // If the corporation is new and the alliance unknown (structure)
             // fetch the alliance from the API.
             if (!$corp) {
                 $corp = Corporation::add($corpname, Alliance::add("None"), $timestamp);
                 if (!$corp->getExternalID()) {
                     $corp = false;
                 } else {
                     $corp->execQuery();
                 }
             }
         } else {
             $corp = Corporation::add($corpname, $alliance, $timestamp, 0, self::$loadExternals);
             self::$corps[$corpname] = $corp;
         }
     }
     return $corp;
 }