/** * @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; }
function startElement($parser, $name, $attribs) { if ($name == "ROW") { global $tempdata; if (count($attribs)) { foreach ($attribs as $k => $v) { switch ($k) { case "TYPEID": $tempdata['typeID'] = $v; $tempdata['SkillName'] = API_Helpers::gettypeIDname($v); $tempdata['GroupID'] = API_Helpers::getgroupID($v); $tempdata['GroupName'] = API_Helpers::getgroupIDname($tempdata['GroupID']); $tempdata['Rank'] = API_Helpers::gettypeIDrank($v); break; case "SKILLPOINTS": $tempdata['SkillPoints'] = $v; break; case "LEVEL": $tempdata['Level'] = $v; $this->Skills_[] = $tempdata; $tempdata = array(); unset($tempdata); break; case "UNPUBLISHED": // unused skill eg. Black Market Trading $tempdata = array(); unset($tempdata); break; } } } } }
/** * Return the raw killmail for this kill. * * @return string */ function getRawMail() { if (!is_null($this->mail)) { return $this->mail; } if (config::get('km_cache_enabled') && file_exists(KB_PAGECACHEDIR . "/" . $this->getID() . ".txt")) { $this->mail = file_get_contents(KB_PAGECACHEDIR . "/" . $this->getID() . ".txt"); return $this->mail; } if (!$this->timestamp) { $this->execQuery(); } if (!$this->valid) { return "The specified kill ID is not valid."; } if ($this->isClassified()) { return 'Killmail not yet available, try again in ' . round($this->getClassifiedTime() / 3600, 2) . ' hrs.'; } static $locations; if (!isset($locations)) { $qry = DBFactory::getDBQuery(); $qry->execute("SELECT itl_flagID, itl_flagText FROM kb3_item_locations"); while ($row = $qry->getRow()) { $locations[$row['itl_flagID']] = $row['itl_flagText']; } } $ship = $this->getVictimShip(); $shipclass = $ship->getClass(); if (!$this->getVictimCorpName()) { $corp = new Corporation($this->victimcorpid); $this->victimcorpname = $corp->getName(); } if (!$this->getVictimAllianceName()) { $all = new Alliance($this->victimallianceid); $this->victimalliancename = $all->getName(); } if (!$this->getVictimName()) { throw new KillException("Invalid mail, victim name blank"); } else { if (!$this->getVictimCorpName()) { throw new KillException("Invalid mail, victim corporation blank"); } else { if (!$this->getVictimAllianceName() && !$this->getVictimFactionName()) { throw new KillException("Invalid mail, victim alliance blank"); } else { if (!$ship->getName()) { throw new KillException("Invalid mail, ship blank"); } else { if (!$this->getSystem()->getName()) { throw new KillException("Invalid mail, system blank", ´); } } } } } $mail = substr(str_replace('-', '.', $this->getTimeStamp()), 0, 19) . "\r\n\r\n"; // Starbase (so this is a POS mail) if (in_array($shipclass->getID(), array(35, 36, 37, 38))) { $mail .= "Corp: " . $this->getVictimCorpName() . "\r\n"; if ($this->getIsVictimFaction()) { $mail .= "Alliance: None\r\n"; } else { $mail .= "Alliance: " . $this->getVictimAllianceName() . "\r\n"; } $mail .= "Faction: " . $this->getVictimFactionName() . "\r\n"; //$ship = $this->getVictimShip(); $mail .= "Destroyed: " . $ship->getName() . "\r\n"; if ($this->getVictimName() == $this->getSystem()->getName()) { $mail .= "Moon: Unknown\r\n"; } else { // is the victim's name a moon? $moonID = API_Helpers::getMoonID($this->getVictimName()); if ($moonID) { $mail .= "Moon: " . $this->getVictimName() . "\r\n"; } else { // try parsing the victim's name in case it's the format // <corporationName> - <moonName> $namePieces = explode(" - ", $this->getVictimName()); if (is_array($namePieces) && count($namePieces) > 2) { // remove first part, which is the corp name array_splice($namePieces, 0, 1); $mail .= "Moon: " . implode(" - ", $namePieces) . "\r\n"; } } } $mail .= "System: " . $this->getSystem()->getName() . "\r\n"; $mail .= "Security: " . $this->getSystem()->getSecurity(true) . "\r\n"; $mail .= "Damage Taken: " . $this->dmgtaken . "\r\n\r\n"; $mail .= "Involved parties:\r\n\r\n"; } else { $mail .= "Victim: " . $this->getVictimName() . "\r\n"; $mail .= "Corp: " . $this->getVictimCorpName() . "\r\n"; if ($this->getIsVictimFaction()) { $mail .= "Alliance: None\r\n"; } else { $mail .= "Alliance: " . $this->getVictimAllianceName() . "\r\n"; } $mail .= "Faction: " . $this->getVictimFactionName() . "\r\n"; //$ship = $this->getVictimShip(); $mail .= "Destroyed: " . $ship->getName() . "\r\n"; $system = $this->getSystem(); $mail .= "System: " . $system->getName() . "\r\n"; $mail .= "Security: " . $system->getSecurity(true) . "\r\n"; $mail .= "Damage Taken: " . $this->dmgtaken . "\r\n\r\n"; $mail .= "Involved parties:\r\n\r\n"; } foreach ($this->involvedparties_ as $inv) { /* @var $inv InvolvedParty */ $pilot = new Pilot($inv->getPilotID()); $corp = new Corporation($inv->getCorpID()); $alliance = new Alliance($inv->getAllianceID()); $weapon = $inv->getWeapon(); $ship = $inv->getShip(); if ($ship->getID() != "9999") { // Split these into multiple ifs so the error tells us where the // problem was. if (!$pilot->getName()) { throw new KillException("Invalid mail, invalid involved pilot (ID: " . $pilot->getID() . ")"); } else { if (!$corp->getName()) { throw new KillException("Invalid mail, invalid involved corporation (ID: " . $corp->getID() . ")"); } else { if (!$alliance->getName()) { throw new KillException("Invalid mail, invalid involved alliance (ID: " . $alliance->getID() . ")"); } else { if (!$weapon->getName()) { throw new KillException("Invalid mail, invalid involved weapon (ID: " . $weapon->getID() . ")"); } else { if (!$ship->getName()) { throw new KillException("Invalid mail, invalid involved ship (ID: " . $ship->getID() . ")"); } } } } } if ($pilot->getName() == $weapon->getName()) { $name = $pilot->getName() . " / " . $corp->getName(); } else { $name = $pilot->getName(); } $mail .= "Name: " . $name; if ($pilot->getID() == $this->getFBPilotID()) { $mail .= " (laid the final blow)"; } $mail .= "\r\n"; if ($pilot->getName() != $weapon->getName()) { $mail .= "Security: " . $inv->getSecStatus() . "\r\n"; $mail .= "Corp: " . $corp->getName() . "\r\n"; if ($alliance->isFaction()) { $mail .= "Alliance: None\r\n"; $mail .= "Faction: " . $alliance->getName() . "\r\n"; } else { $mail .= "Alliance: " . $alliance->getName() . "\r\n"; $mail .= "Faction: None\r\n"; } $mail .= "Ship: " . $ship->getName() . "\r\n"; $mail .= "Weapon: " . $weapon->getName() . "\r\n"; $mail .= "Damage Done: " . $inv->getDamageDone() . "\r\n"; } else { $mail .= "Damage Done: " . $inv->getDamageDone() . "\r\n"; } $mail .= "\r\n"; } } if (count($this->destroyeditems_) > 0) { $mail .= "\r\nDestroyed items:\r\n\r\n"; foreach ($this->destroyeditems_ as $destroyed) { $item = $destroyed->getItem(); $mail .= $item->getName(); if ($destroyed->getQuantity() > 1) { $mail .= ", Qty: " . $destroyed->getQuantity(); } if ($destroyed->getSingleton() == InventoryFlag::$SINGLETON_COPY) { $mail .= " (Copy)"; } $flagID = InventoryFlag::collapse($destroyed->getLocationID()); if ($destroyed->getLocationID() == InventoryFlag::$CARGO) { $mail .= " (Cargo)"; } else { if ($destroyed->getLocationID() == InventoryFlag::$DRONE_BAY) { $mail .= " (Drone Bay)"; } else { if ($destroyed->getLocationID() == InventoryFlag::$IMPLANT) { $mail .= " (Implant)"; } else { if ($destroyed->getLocationID() == InventoryFlag::$OTHER) { $mail .= " (Other)"; } } } } $mail .= "\r\n"; } } if (count($this->droppeditems_) > 0) { $mail .= "\r\nDropped items:\r\n\r\n"; foreach ($this->droppeditems_ as $dropped) { $item = $dropped->getItem(); $mail .= $item->getName(); if ($dropped->getQuantity() > 1) { $mail .= ", Qty: " . $dropped->getQuantity(); } if ($dropped->getSingleton() == InventoryFlag::$SINGLETON_COPY) { $mail .= " (Copy)"; } if ($dropped->getLocationID() == InventoryFlag::$CARGO) { $mail .= " (Cargo)"; } else { if ($dropped->getLocationID() == InventoryFlag::$DRONE_BAY) { $mail .= " (Drone Bay)"; } else { if ($dropped->getLocationID() == InventoryFlag::$IMPLANT) { $mail .= " (Implant)"; } else { if ($dropped->getLocationID() == InventoryFlag::$OTHER) { $mail .= " (Other)"; } } } } $mail .= "\r\n"; } } if ($this->id && config::get('km_cache_enabled')) { file_put_contents(KB_MAILCACHEDIR . "/" . $this->getID() . ".txt", $mail); } $this->mail = $mail; return $mail; }