コード例 #1
0
ファイル: class.helpers.php プロジェクト: biow0lf/evedev-kb
 public static function gettypeIDname($id, $update = false)
 {
     $id = intval($id);
     $sql = 'select inv.typeName from kb3_invtypes inv where inv.typeID = ' . $id;
     $qry = DBFactory::getDBQuery();
     $qry->execute($sql);
     if ($qry->recordCount()) {
         $row = $qry->getRow();
         return $row['typeName'];
     } else {
         $info = new API_IDtoName();
         $info->setIDs($id);
         $result = $info->fetchXML();
         if ($result == "") {
             $data = $info->getIDData();
             if ($update && $data[0]['characterID'] > 0 && $data[0]['name']) {
                 $sql = "INSERT INTO kb3_invtypes (typeID, typeName, description) values({$id}, '" . $qry->escape($data[0]['name']) . "', '')";
                 $qry->execute($sql);
             }
             return $data[0]['name'];
         }
         return null;
     }
 }
コード例 #2
0
ファイル: class.alliance.php プロジェクト: biow0lf/evedev-kb
 /**
  * Fetch the alliance name from CCP using the stored external ID.
  */
 private function fetchAlliance()
 {
     if (!$this->getExternalID()) {
         return false;
     }
     $myID = new API_IDtoName();
     $myID->setIDs($this->externalid);
     $myID->fetchXML();
     if ($myID != "") {
         return false;
     }
     $myNames = $myID->getIDData();
     // Use ::add to make sure names are updated in the db and clashes are fixed.
     $alliance = Alliance::add($myNames[0]['name'], (int) $myNames[0]['characterID']);
     $this->name = $alliance->name;
 }
コード例 #3
0
ファイル: option_config.php プロジェクト: biow0lf/evedev-kb
 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;
     }
 }
コード例 #4
0
ファイル: class.idfeed.php プロジェクト: biow0lf/evedev-kb
 /**
  * @param SimpleXMLElement $row
  * @param Kill $kill
  * @param string $time YYYY-mm-dd hh:ss
  * @return boolean false on error
  */
 private function processVictim($row, &$kill, $time)
 {
     // If we have a character ID but no name then we give up - the needed
     // info is gone.
     // If we have no character ID and no name then it's a structure or NPC
     //	- if we have a moonID (anchored at a moon) call it corpname - moonname
     //	- if we don't have a moonID call it corpname - systemname
     $victim = $row->victim;
     if (!strval($victim['characterName']) && (int) $victim['characterID']) {
         return false;
     } else {
         if (!strval($victim['corporationName'])) {
             return false;
         }
     }
     if ((int) $victim['allianceID']) {
         $alliance = Alliance::add(strval($victim['allianceName']), (int) $victim['allianceID']);
     } else {
         if ((int) $victim['factionID']) {
             $alliance = Alliance::add(strval($victim['factionName']), (int) $victim['factionID']);
         } else {
             $alliance = Alliance::add("None");
         }
     }
     $corp = Corporation::add(strval($victim['corporationName']), $alliance, $time, (int) $victim['corporationID']);
     if (!strval($victim['characterName'])) {
         if ((int) $row['moonID']) {
             $name = API_Helpers::getMoonName((int) $row['moonID']);
             if (!$name) {
                 $idtoname = new API_IDtoName();
                 $idtoname->setIDs((int) $row['moonID']);
                 if ($idtoname->fetchXML()) {
                     return false;
                 }
                 $namedata = $idtoname->getIDData();
                 $name = $namedata[0]['name'];
             }
             $name = strval($victim['corporationName']) . " - " . $name;
         } else {
             $name = strval($victim['corporationName']) . " - " . $kill->getSystem()->getName();
         }
     } else {
         if (!(int) $victim['shipTypeID']) {
             return false;
         } else {
             $name = strval($victim['characterName']);
         }
     }
     $pilot = Pilot::add($name, $corp, $time, (int) $victim['characterID']);
     $ship = Ship::getByID((int) $victim['shipTypeID']);
     $kill->setVictim($pilot);
     $kill->setVictimID($pilot->getID());
     $kill->setVictimCorpID($corp->getID());
     $kill->setVictimAllianceID($alliance->getID());
     $kill->setVictimShip($ship);
     $kill->set('dmgtaken', (int) $victim['damageTaken']);
     return true;
 }