/**
  *  Show the overall statistics for this alliance.
  *
  * @global Smarty $smarty
  * @return string
  */
 function stats()
 {
     global $smarty;
     if ($this->alliance->isFaction()) {
         $this->page->setTitle(Language::get('page_faction_det') . ' - ' . $this->alliance->getName() . " [" . $this->alliance->getshortName() . "]");
     } else {
         $this->page->setTitle(Language::get('page_all_det') . ' - ' . $this->alliance->getName() . " [" . $this->alliance->getshortName() . "]");
     }
     $sql = "select crp_id from kb3_corps WHERE crp_all_id=" . $this->alliance->getID();
     $qry = DBFactory::getDBQuery();
     $qry->execute($sql);
     while ($row = $qry->getRow()) {
         $this->allianceCorps[] = Corporation::getByID((int) $row['crp_id']);
     }
     if (!isset($this->kill_summary)) {
         $this->kill_summary = new KillSummaryTable();
         $this->kill_summary->addInvolvedAlliance($this->alliance);
         $this->kill_summary->generate();
     }
     $execcrp = Corporation::lookupByExternalID($this->alliance->GetExecutorID());
     if ($execcrp !== false) {
         $smarty->assign('ExecutorName', $execcrp->getName());
     } else {
         $smarty->assign('ExecutorName', '');
     }
     $smarty->registerObject('Alliance', $this->alliance);
     $smarty->assign('memberCorpCount', count($this->allianceCorps));
     if ($this->kill_summary->getTotalKillISK()) {
         $efficiency = round($this->kill_summary->getTotalKillISK() / ($this->kill_summary->getTotalKillISK() + $this->kill_summary->getTotalLossISK()) * 100, 2);
     } else {
         $efficiency = 0;
     }
     // The summary table is also used by the stats. Whichever is called
     // first generates the table.
     $smarty->assign('all_img', $this->alliance->getPortraitURL(128));
     $smarty->assign('totalkills', $this->kill_summary->getTotalKills());
     $smarty->assign('totallosses', $this->kill_summary->getTotalLosses());
     $smarty->assign('totalkisk', round($this->kill_summary->getTotalKillISK() / 1000000000, 2));
     $smarty->assign('totallisk', round($this->kill_summary->getTotalLossISK() / 1000000000, 2));
     if ($this->kill_summary->getTotalKillISK()) {
         $smarty->assign('efficiency', round($this->kill_summary->getTotalKillISK() / ($this->kill_summary->getTotalKillISK() + $this->kill_summary->getTotalLossISK()) * 100, 2));
     } else {
         $smarty->assign('efficiency', '0');
     }
     return $smarty->fetch(get_tpl('alliance_detail_stats'));
 }
 /**
  * Check if the victim is in a Faction.
  *
  * @return boolean
  */
 function getIsVictimFaction()
 {
     $alliance = new Alliance($this->getVictimAllianceID());
     return $alliance->isFaction();
 }
Exemple #3
0
 /**
  * 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_id, itl_location FROM kb3_item_locations");
         while ($row = $qry->getRow()) {
             $locations[$row['itl_id']] = $row['itl_location'];
         }
     }
     $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()) {
         trigger_error("Invalid mail, victim name blank", E_USER_ERROR);
         return "";
     } else {
         if (!$this->getVictimCorpName()) {
             trigger_error("Invalid mail, victim corporation blank", E_USER_ERROR);
             return "";
         } else {
             if (!$this->getVictimAllianceName() && !$this->getVictimFactionName()) {
                 trigger_error("Invalid mail, victim alliance blank", E_USER_ERROR);
                 return "";
             } else {
                 if (!$ship->getName()) {
                     trigger_error("Invalid mail, ship blank", E_USER_ERROR);
                     return "";
                 } else {
                     if (!$this->getSystem()->getName()) {
                         trigger_error("Invalid mail, system blank", E_USER_ERROR);
                         return "";
                     }
                 }
             }
         }
     }
     $mail = substr(str_replace('-', '.', $this->getTimeStamp()), 0, 16) . "\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 {
             $mail .= "Moon: " . $this->getVictimName() . "\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();
         // Split these into multiple ifs so the error tells us where the
         // problem was.
         if (!$pilot->getName()) {
             trigger_error("Invalid mail, invalid involved pilot", E_USER_ERROR);
             var_dump($pilot);
             return "";
         } else {
             if (!$corp->getName()) {
                 trigger_error("Invalid mail, invalid involved corporation", E_USER_ERROR);
                 return "";
             } else {
                 if (!$alliance->getName()) {
                     trigger_error("Invalid mail, invalid involved alliance", E_USER_ERROR);
                     return "";
                 } else {
                     if (!$weapon->getName()) {
                         trigger_error("Invalid mail, invalid involved weapon", E_USER_ERROR);
                         return "";
                     } else {
                         if (!$ship->getName()) {
                             trigger_error("Invalid mail, invalid involved ship", E_USER_ERROR);
                             return "";
                         }
                     }
                 }
             }
         }
         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->getLocationID() == 5) {
                 $mail .= " (Cargo)";
             } else {
                 if ($destroyed->getLocationID() == 87) {
                     $mail .= " (Drone Bay)";
                 } else {
                     if ($destroyed->getLocationID() == 89) {
                         $mail .= " (Implant)";
                     } else {
                         if ($destroyed->getLocationID() == -1) {
                             $mail .= " (Copy)";
                         }
                     }
                 }
             }
             $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->getLocationID() == 5) {
                 $mail .= " (Cargo)";
             } else {
                 if ($dropped->getLocationID() == 87) {
                     $mail .= " (Drone Bay)";
                 } else {
                     if ($dropped->getLocationID() == 89) {
                         $mail .= " (Implant)";
                     } else {
                         if ($dropped->getLocationID() == -1) {
                             $mail .= " (Copy) (Cargo)";
                         }
                     }
                 }
             }
             $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;
 }
Exemple #4
0
 /**
  * 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;
 }