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; }
/** * Show the overall statistics for this corporation. */ function stats() { global $smarty; // The summary table is also used by the stats. Whichever is called // first generates the table. $this->page->setTitle('Corporation details - ' . $this->corp->getName() . " [" . $this->corp->getShortName() . "]"); $smarty->registerObject('Corp', $this->corp); $smarty->assign('portrait_url', $this->corp->getPortraitURL(128)); if ($this->alliance->getName() == "None") { $smarty->assign('alliance_url', false); } else { if ($this->alliance->getExternalID()) { $smarty->assign('alliance_url', edkURI::build(array('a', 'alliance_detail', true), array('all_ext_id', $this->alliance->getExternalID(), true))); } else { $smarty->assign('alliance_url', edkURI::build(array('a', 'alliance_detail', true), array('all_id', $this->alliance->getID(), true))); } } $smarty->assign('alliance_name', $this->alliance->getName()); $smarty->assign('kill_count', $this->kill_summary->getTotalKills()); $smarty->assign('loss_count', $this->kill_summary->getTotalLosses()); $smarty->assign('damage_done', number_format($this->kill_summary->getTotalKillISK() / 1000000000, 2)); $smarty->assign('damage_received', number_format($this->kill_summary->getTotalLossISK() / 1000000000, 2)); if ($this->kill_summary->getTotalKillISK()) { $smarty->assign('efficiency', number_format(100 * $this->kill_summary->getTotalKillISK() / ($this->kill_summary->getTotalKillISK() + $this->kill_summary->getTotalLossISK()), 2)); } else { $smarty->assign('efficiency', 0); } $smarty->assign('ceo_url', edkURI::build(array('a', 'pilot_detail', true), array('plt_ext_id', $this->corp->getCeoID(), true))); $pilot = new Pilot(0, $this->corp->getCeoID()); $smarty->assign('ceo_name', $pilot->getName()); return $smarty->fetch(get_tpl('corp_detail_stats')); }
/** * Resets all references to other model objects or collections of model objects. * * This method is a user-space workaround for PHP's inability to garbage collect * objects with circular references (even in PHP 5.3). This is currently necessary * when using Propel in certain daemon or large-volume/high-memory operations. * * @param boolean $deep Whether to also clear the references on all referrer objects. */ public function clearAllReferences($deep = false) { if ($deep && !$this->alreadyInClearAllReferencesDeep) { $this->alreadyInClearAllReferencesDeep = true; if ($this->collPlayerCourts) { foreach ($this->collPlayerCourts as $o) { $o->clearAllReferences($deep); } } if ($this->collPlayers) { foreach ($this->collPlayers as $o) { $o->clearAllReferences($deep); } } if ($this->aCorporation instanceof Persistent) { $this->aCorporation->clearAllReferences($deep); } $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) if ($this->collPlayerCourts instanceof PropelCollection) { $this->collPlayerCourts->clearIterator(); } $this->collPlayerCourts = null; if ($this->collPlayers instanceof PropelCollection) { $this->collPlayers->clearIterator(); } $this->collPlayers = null; $this->aCorporation = null; }
/** * Fetch the board owners. * @return array Array of id strings to add to URLS */ function getOwners() { $myids = array(); if (!defined('MASTER') || !MASTER) { foreach (config::get('cfg_pilotid') as $entity) { $pilot = new Pilot($entity); $myids[] = '&pilot=' . urlencode($pilot->getName()); } foreach (config::get('cfg_corpid') as $entity) { $corp = new Corporation($entity); $myids[] = '&corp=' . urlencode($corp->getName()); } foreach (config::get('cfg_allianceid') as $entity) { $alli = new Alliance($entity); $myids[] = '&alli=' . urlencode($alli->getName()); } } return $myids; }
function display() { global $smarty; $alls = $corps = $pilots = false; if (config::get('cfg_allianceid')) { $alls = array(); foreach (config::get('cfg_allianceid') as $entity) { $alliance = new Alliance($entity); if ($alliance->getExternalID()) { $url = edkURI::page('alliance_detail', $alliance->getExternalID(), 'all_ext_id'); } else { $url = edkURI::page('alliance_detail', $alliance->getID(), 'all_id'); } $alls[] = array('id' => $alliance->getID(), 'extid' => $alliance->getExternalID(), 'name' => $alliance->getName(), 'portrait' => $alliance->getPortraitURL(128), 'url' => $url); } } if (config::get('cfg_corpid')) { $corps = array(); foreach (config::get('cfg_corpid') as $entity) { $corp = new Corporation($entity); if ($corp->getExternalID()) { $url = edkURI::page('corp_detail', $corp->getExternalID(), 'crp_ext_id'); } else { $url = edkURI::page('corp_detail', $corp->getID(), 'crp_id'); } $corps[] = array('id' => $corp->getID(), 'extid' => $corp->getExternalID(), 'name' => $corp->getName(), 'portrait' => $corp->getPortraitURL(128), 'url' => $url); } } if (config::get('cfg_pilotid')) { $pilots = array(); foreach (config::get('cfg_pilotid') as $entity) { $pilot = new Pilot($entity); if ($pilot->getExternalID()) { $url = edkURI::page('pilot_detail', $pilot->getExternalID(), 'plt_ext_id'); } else { $url = edkURI::page('pilot_detail', $pilot->getID(), 'plt_id'); } $pilots[] = array('id' => $pilot->getID(), 'extid' => $pilot->getExternalID(), 'name' => $pilot->getName(), 'portrait' => $pilot->getPortraitURL(128), 'url' => $url); } } $smarty->assignByRef('alliances', $alls); $smarty->assignByRef('corps', $corps); $smarty->assignByRef('pilots', $pilots); return $smarty->fetch(get_tpl('self')); }
/** * Extracts attribute contents FROM a parent tree object * * @param array $tree an array containing an array FROM which the * object data should be extracted * @param string $ver represents the version of the GEDCOM standard * data is being extracted from * * @return void * * @access public * @since Method available since Release 0.0.1 */ public function parse_tree($tree, $ver) { if (($i1 = parent::find_tag($tree, Rp_Tags::SOURCE)) !== false) { $this->system_id = parent::parse_text($tree[$i1], Rp_Tags::SOURCE); if (isset($tree[$i1][1])) { $sub2 = $tree[$i1][1]; if (($i2 = parent::find_tag($sub2, Rp_Tags::VERSION)) !== false) { $this->ver_nbr = parent::parse_text($sub2[$i2], Rp_Tags::VERSION); } if (($i2 = parent::find_tag($sub2, Rp_Tags::NAME)) !== false) { $this->product_name = parent::parse_text($sub2[$i2], Rp_Tags::NAME); } $this->corporation->parse_tree($sub2, $ver); $this->rp_data->parse_tree($sub2, $ver); } } }
function generate() { global $smarty; $prevdate = ""; $this->kill_list_->rewind(); $smarty->assign('daybreak', $this->daybreak_); $smarty->assign('comments_count', config::get('comments_count')); // evil hardcode-hack, don't do this at home kids ! ;) if (config::get('style_name') == 'revelations') { $smarty->assign('comment_white', '_white'); } $c = 0; $kdpage = array('a', 'kill_detail', true); $krpage = array('a', 'kill_related', true); $kills = array(); while ($kill = $this->kill_list_->getKill()) { if ($this->limit_ && $c >= $this->limit_) { break; } else { $c++; } $curdate = substr($kill->getTimeStamp(), 0, 10); if ($curdate != $prevdate) { if (count($kills) && $this->daybreak_) { $kl[] = array('kills' => $kills, 'date' => strtotime($prevdate)); $kills = array(); } $prevdate = $curdate; } $kll = array(); $kll['id'] = $kill->getID(); $kll['victimshipimage'] = $kill->getVictimShipImage(32); $kll['victimshipname'] = $kill->getVictimShipName(); $kll['victimshipclass'] = $kill->getVictimShipClassName(); $kll['victim'] = $kill->getVictimName(); $kll['victimiskloss'] = $kill->getISKLoss(); if ($kll['victimiskloss'] > 1000000000) { $kll['victimiskloss'] = sprintf("%.01fb", $kll['victimiskloss'] / 1000000000); } elseif ($kll['victimiskloss'] > 1000000) { $kll['victimiskloss'] = sprintf("%.01fm", $kll['victimiskloss'] / 1000000); } elseif ($kll['victimiskloss'] > 1000) { $kll['victimiskloss'] = sprintf("%.0fk", $kll['victimiskloss'] / 1000); } $kll['victimcorp'] = $kill->getVictimCorpName(); $kll['victimalliancename'] = $kill->getVictimAllianceName(); $kll['fb'] = $kill->getFBPilotName(); $kll['fbcorp'] = $kill->getFBCorpName(); if ($kill->isClassified() && !Session::isAdmin()) { if (config::get('killlist_regionnames')) { $kll['region'] = Language::get("classified"); } $kll['systemsecurity'] = "-"; $kll['system'] = Language::get("classified"); } else { if (config::get('killlist_regionnames')) { $kll['region'] = $kill->getSystem()->getRegionName(); } $kll['systemsecurity'] = $kill->getSolarSystemSecurity(); $kll['system'] = $kill->getSolarSystemName(); } $kll['victimid'] = $kill->getVictimID(); $kll['victimcorpid'] = $kill->getVictimCorpID(); $kll['victimallianceid'] = $kill->getVictimAllianceID(); $kll['victimshipid'] = $kill->getVictimShipExternalID(); $kll['fbid'] = $kill->getFBPilotID(); $kll['fbcorpid'] = $kill->getFBCorpID(); $kll['inv'] = 0; if (config::get('killlist_involved')) { $kll['inv'] = $kill->getInvolvedPartyCount(); } $kll['timestamp'] = $kill->getTimeStamp(); if (config::get('killlist_alogo')) { // Need to return yet another value from killlists. $all = new Alliance($kill->getVictimAllianceID()); if (strcasecmp($all->getName(), "None") != 0) { $kll['allianceexists'] = true; $kll['victimallianceicon'] = $all->getPortraitURL(32); } else { $kll['allianceexists'] = true; $crp = new Corporation($kill->getVictimCorpID()); $kll['victimallianceicon'] = $crp->getPortraitURL(32); } } if (isset($kill->_tag)) { $kll['tag'] = $kill->_tag; } $kll['fbplext'] = $kill->getFBPilotExternalID(); $kll['plext'] = $kill->getFBPilotExternalID(); if (config::get('comments_count')) { $kll['commentcount'] = $kill->countComment(); } $kll['loss'] = false; $kll['kill'] = false; if ($this->combined_) { if (config::get('cfg_allianceid') && in_array($kill->getVictimAllianceID(), config::get('cfg_allianceid'))) { $kll['loss'] = true; } else { if (config::get('cfg_corpid') && in_array($kill->getVictimCorpID(), config::get('cfg_corpid'))) { $kll['loss'] = true; } else { if (config::get('cfg_pilotid') && in_array($kill->getVictimID(), config::get('cfg_pilotid'))) { $kll['loss'] = true; } } } $kll['kill'] = !$kll['loss']; } $kll['urldetail'] = edkURI::build($kdpage, array('kll_id', $kll['id'], true)); if (!$kill->isClassified()) { $kll['urlrelated'] = edkURI::build($krpage, array('kll_id', $kll['id'], true)); } $kll['victimextid'] = $kill->getVictimExternalID(); $kll['urlvictim'] = edkURI::page('pilot_detail', $kll['victimextid'] ? $kll['victimextid'] : $kll['victimid'], $kll['victimextid'] ? 'plt_ext_id' : 'plt_id'); $kll['urlfb'] = edkURI::page('pilot_detail', $kll['fbplext'] ? $kll['fbplext'] : $kll['fbid'], $kll['fbplext'] ? 'plt_ext_id' : 'plt_id'); if ($kll['allianceexists']) { $kll['urlvictimall'] = edkURI::page('alliance_detail', $kll['victimallianceid'], 'all_id'); } $kll['urlvictimcorp'] = edkURI::page('corp_detail', $kll['victimcorpid'], 'crp_id'); $kll['urlfbcorp'] = edkURI::page('corp_detail', $kll['fbcorpid'], 'crp_id'); event::call('killlist_table_kill', $kll); $kills[] = $kll; } event::call('killlist_table_kills', $kills); if (count($kills)) { $kl[] = array('kills' => $kills, 'date' => strtotime($prevdate)); } $smarty->assignByRef('killlist', $kl); $smarty->assign('killlist_iskloss', config::get('killlist_iskloss')); return $smarty->fetch(getcwd() . "/mods/highlight_capitals/templates/killlisttable.tpl"); }
/** * 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; }
/** * 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; }
/** * Exclude object from result * * @param Corporation $corporation Object to remove from the list of results * * @return CorporationQuery The current query, for fluid interface */ public function prune($corporation = null) { if ($corporation) { $this->addUsingAlias(CorporationPeer::ID, $corporation->getId(), Criteria::NOT_EQUAL); } return $this; }
/** * 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')); }
/** * 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; } }
/** * @return integer */ function getCorpID() { return $this->corp_->getID(); }
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param Corporation $obj A Corporation object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool($obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getId(); } // if key === null CorporationPeer::$instances[$key] = $obj; } }
/** * generate Balance of Power Table * @return String HTML for the Balance Of Power tab */ public function balanceOfPower() { global $smarty; $this->sides = array(); include $this->includeDir . "class.killlisttable.php"; $BadShips = $BadAllies = $GoodShips = $GoodAllies = array(); $numberOfFriendlyPilots = 0; $numberOfHostilePilots = 0; $pilotsCounted = array(); $involvedOwners = array(); $this->numberOfInvolvedOwners = 0; $ownerAlliances = config::get('cfg_allianceid'); $ownerCorps = config::get('cfg_corpid'); $ownerPilots = config::get('cfg_pilotid'); foreach ($this->pilots as $side => $pilotA) { foreach ($pilotA as $pilotId => $kll) { foreach ($kll as $pilota) { // determine numbers of involved Owners if (in_array($pilota["aid"], $ownerAlliances)) { $involvedOwners[$pilotId] = 1; } elseif (in_array($pilota["cid"], $ownerCorps)) { $involvedOwners[$pilotId] = 1; } elseif (in_array($pilotId, $ownerPilots)) { $involvedOwners[$pilotId] = 1; } $shippa = TestPilotName($pilota["ship"]); if ($side == 'a') { $GoodShips[$shippa]["shipClass"] = $pilota["shipClass"]; $GoodShips[$shippa]["sortWeight"] = getShipClassSortWeight($pilota["shipClassObject"]); $GoodShips[$shippa]["times"] += 1; $GoodShips[$shippa]["color"] = $pilota["color"]; if ($pilota["destroyed"] == 1) { $GoodShips[$shippa]["destroyed"] += 1; } else { $GoodShips[$shippa]["destroyed"] += 0; } // check if we already got that pilot if (in_array($pilota["name"], $pilotsCounted)) { continue; } $pilotsCounted[] = $pilota["name"]; $numberOfFriendlyPilots++; $GoodAllies[$pilota["alliance"]]["quantity"] += 1; $GoodAllies[$pilota["alliance"]]["corps"][$pilota["corp"]] += 1; // now set up sides for BR Setup tab // entity type: alliance if (strcasecmp($pilota["alliance"], "None") != 0) { $allianceName = addslashes($pilota["alliance"]); if (!isset($this->sides["a"][$pilota["alliance"]])) { $this->sides["a"][$allianceName]["type"] = "alliance"; $this->sides["a"][$allianceName]["id"] = $pilota["aid"]; $this->sides["a"][$allianceName]["numberOfPilots"] = 1; $this->sides["a"][$allianceName]["logoUrl"] = html_entity_decode(Alliance::getByID($pilota["aid"])->getPortraitURL(32)); $this->sides["a"][$allianceName]["infoUrl"] = html_entity_decode($pilota["alliance_url"]); } else { $this->sides["a"][$allianceName]["numberOfPilots"] += 1; } } else { $corpName = addslashes($pilota["corp"]); if (!isset($this->sides["a"][$pilota["corp"]])) { $this->sides["a"][$corpName]["type"] = "corp"; $this->sides["a"][$corpName]["id"] = $pilota["cid"]; $this->sides["a"][$corpName]["numberOfPilots"] = 1; $this->sides["a"][$corpName]["logoUrl"] = html_entity_decode(Corporation::getByID($pilota["cid"])->getPortraitURL(32)); $this->sides["a"][$corpName]["infoUrl"] = html_entity_decode($pilota["crp_url"]); } else { $this->sides["a"][$corpName]["numberOfPilots"] += 1; } } } else { $BadShips[$shippa]["shipClass"] = $pilota["shipClass"]; $BadShips[$shippa]["sortWeight"] = getShipClassSortWeight($pilota["shipClassObject"]); $BadShips[$shippa]["times"] += 1; $BadShips[$shippa]["color"] = $pilota["color"]; if ($pilota["destroyed"] == 1) { $BadShips[$shippa]["destroyed"] += 1; } else { $BadShips[$shippa]["destroyed"] += 0; } // check if we already got that pilot if (in_array($pilota["name"], $pilotsCounted)) { continue; } $pilotsCounted[] = $pilota["name"]; $numberOfHostilePilots++; // adjust numbers for the same pilots in different ships if ($pilota[0]["times"] > 1) { $numberOfHostilePilots -= $pilota[0]["times"] - 1; } $BadAllies[$pilota["alliance"]]["quantity"] += 1; $BadAllies[$pilota["alliance"]]["corps"][$pilota["corp"]] += 1; // now set up sides for BR Setup tab // entity type: alliance if (strcasecmp($pilota["alliance"], "None") != 0) { $allianceName = addslashes($pilota["alliance"]); if (!isset($this->sides["e"][$pilota["alliance"]])) { $this->sides["e"][$allianceName]["type"] = "alliance"; $this->sides["e"][$allianceName]["id"] = $pilota["aid"]; $this->sides["e"][$allianceName]["numberOfPilots"] = 1; $this->sides["e"][$allianceName]["logoUrl"] = html_entity_decode(Alliance::getByID($pilota["aid"])->getPortraitURL(32)); $this->sides["e"][$allianceName]["infoUrl"] = html_entity_decode($pilota["alliance_url"]); } else { $this->sides["e"][$allianceName]["numberOfPilots"] += 1; } } else { $corpName = addslashes($pilota["corp"]); if (!isset($this->sides["e"][$pilota["corp"]])) { $this->sides["e"][$corpName]["type"] = "corp"; $this->sides["e"][$corpName]["id"] = $pilota["cid"]; $this->sides["e"][$corpName]["numberOfPilots"] = 1; $this->sides["e"][$corpName]["logoUrl"] = html_entity_decode(Corporation::getByID($pilota["cid"])->getPortraitURL(32)); $this->sides["e"][$corpName]["infoUrl"] = html_entity_decode($pilota["crp_url"]); } else { $this->sides["e"][$corpName]["numberOfPilots"] += 1; } } } } } } $this->numberOfInvolvedOwners = count($involvedOwners); foreach ($involvedOwners as $involvedOwnerId => $one) { $this->involvedOwners[] = $involvedOwnerId; } // calculate percentages foreach ($GoodAllies as $name => &$info) { $info["percentage"] = round($info["quantity"] / $numberOfFriendlyPilots * 100, 1); arsort($info["corps"]); } foreach ($BadAllies as $name => &$info) { $info["percentage"] = round($info["quantity"] / $numberOfHostilePilots * 100, 1); arsort($info["corps"]); } if (!is_null($GoodShips)) { uasort($GoodShips, array($this, 'sortShipClasses')); } if (!is_null($GoodAllies)) { arsort($GoodAllies); } $smarty->assignByRef('GAlliesCount', count($GoodAllies)); $smarty->assignByRef('GoodAllies', $GoodAllies); $smarty->assignByRef('GoodShips', $GoodShips); if (!is_null($BadShips)) { uasort($BadShips, array($this, 'sortShipClasses')); } if (!is_null($BadAllies)) { arsort($BadAllies); } $smarty->assignByRef('BAlliesCount', count($BadAllies)); $smarty->assignByRef('BadAllies', $BadAllies); $smarty->assignByRef('BadShips', $BadShips); $smarty->assign("numberOfFriendlyPilots", $numberOfFriendlyPilots); $smarty->assign("numberOfHostilePilots", $numberOfHostilePilots); return $smarty->fetch($this->templateDir . "battle_balance.tpl"); }
$smarty->assign('img_host', IMG_HOST); $smarty->assign('kb_host', KB_HOST); $smarty->assignByRef('config', $config); $smarty->assign('is_IGB', IS_IGB); // Set the name of the board owner. $owners = array(); if (config::get('cfg_allianceid')) { foreach (config::get('cfg_allianceid') as $owner) { $alliance = new Alliance($owner); $owners[] = htmlentities($alliance->getName()); } unset($alliance); } if (config::get('cfg_corpid')) { foreach (config::get('cfg_corpid') as $owner) { $corp = new Corporation($owner); $owners[] = htmlentities($corp->getName()); } unset($corp); } if (config::get('cfg_pilotid')) { foreach (config::get('cfg_corpid') as $owner) { $pilot = new Pilot($owner); $owners[] = htmlentities($pilot->getName()); } unset($pilot); } if (!$owners) { $smarty->assign('kb_owner', false); } else { $smarty->assign('kb_owner', implode(',', $owners));
function thumbInt($int_id, $size, $type) { $this->size = $size; switch ($this->type) { case 'pilot': case '': $pilot = new Pilot($int_id); $this->id = $pilot->getExternalID(); if ($this->id) { $url = imageURL::getURL('Pilot', $this->id, $size); header(html_entity_decode("Location: {$url}")); die; } $this->type = 'pilot'; $this->encoding = 'jpeg'; $this->validate(); break; case 'corp': case 'npc': $this->type = 'corp'; $corp = new Corporation($int_id); if (!$corp->getExternalID()) { $this->id = 0; } $this->id = $corp->getExternalID(); if ($this->id) { $url = imageURL::getURL('Corporation', $this->id, $size); header("Location: {$url}"); die; } $this->encoding = 'png'; if ($this->type == 'npc') { $this->type = 'npc'; //$this->encoding = 'png'; } $this->validate(); break; default: $this->id = $str_id; $this->type = $type; $this->encoding = 'jpeg'; $this->validate(); } }
$pilot = new Pilot(intval($_GET['plt_id'])); $page = new Page('Administration - Change Pilots Corp (' . $pilot->getName() . ')'); $page->setAdmin(); if (!$pilot->exists()) { $html = "That pilot doesn't exist."; $page->generate($html); exit; } if ($_POST['confirm']) { $sql = "UPDATE `kb3_pilots` SET `plt_crp_id` = '" . intval($_POST['crp_id']) . "' WHERE `plt_id` =" . intval($_POST['plt_id']); $qry = DBFactory::getDBQuery(); $qry->execute($sql); $html .= "Pilot Moved"; } if ($_REQUEST['crp']) { $corp = new Corporation(intval($_GET['crp'])); $html .= "<form id=change method=post action=><table class=kb-subtable>"; $html .= "<tr><td><input name=crp_id type=hidden value=" . htmlentities($_GET['crp']) . ">"; $html .= "<input name=plt_id type=hidden value=" . htmlentities($_GET['plt_id']) . ">"; $html .= "Confirm move<b> " . $pilot->getName() . "</b> to <b>" . $corp->getName() . "</b></td></tr>"; $html .= "<tr><td><input type=submit name=confirm value=\"Move\"></td></tr>"; $html .= "</table>"; } if ($_POST['search']) { $qry = DBFactory::getDBQuery(); $sql = "SELECT * FROM `kb3_corps` WHERE crp_name LIKE '%" . $qry->escape($_POST['search']) . "%'"; $qry->execute($sql); //$html .= $sql ; $html .= "<div class=block-header2>Results</div>"; $html .= "<table class=kb-subtable>"; while ($row = $qry->getRow()) {
public function __construct($aInvolved, &$cKill, &$cKillboard) { $this->characterID = $aInvolved->characterID; $this->characterName = $aInvolved->characterName; $this->corporationID = $aInvolved->corporationID; $this->corporationName = $aInvolved->corporationName; $this->allianceID = $aInvolved->allianceID; $this->allianceName = $aInvolved->allianceName; $this->factionID = $aInvolved->factionID; $this->factionName = $aInvolved->factionName; $this->securityStatus = $aInvolved->securityStatus; $this->damageDone = $aInvolved->damageDone; $this->finalBlow = $aInvolved->finalBlow; $this->weaponTypeID = $aInvolved->weaponTypeID; $this->shipTypeID = $aInvolved->shipTypeID; $aCorp =& $cKillboard->getCorporation($this->corporationName); if (!is_object($aCorp)) { $cKillboard->corp[] = $aCorp = new Corporation(SHIP_KILL, $this->corporationID, $this->corporationName, $this->allianceID, $this->allianceName, $cKill); } else { if (!$cKill->isCorpAlreadyInvolved($this->corporationName)) { // Increment killcount $aCorp->killCount++; // If EVEKILL_SECS_ELAPSED_ASSUME_NEW_BATTLE seconds have elapsed since the last kill by this corp, assume it // is a new battle (and adds weight to the fact they are probably resident) if (is_null($aCorp->timeEarliestKill) || strtotime($cKill->timestamp) + EVEKILL_SECS_ELAPSED_ASSUME_NEW_BATTLE <= $aCorp->timeEarliestKill) { $aCorp->battle[] =& $cKill; } // Update kill times if (strtotime($cKill->timestamp) < $aCorp->timeEarliestKill || is_null($aCorp->timeEarliestKill)) { $aCorp->timeEarliestKill = strtotime($cKill->timestamp); } if (strtotime($cKill->timestamp) > $aCorp->timeLatestKill || is_null($aCorp->timeLatestKill)) { $aCorp->timeLatestKill = strtotime($cKill->timestamp); } // Add kill to this corp's kill database $aCorp->addKill($cKill, false); } // Increment involved parties and ships $aCorp->addInvolved(); } // Add the killers ship and weapon to their "use" database $aCorp->addShip($this->shipTypeID, SHIP_KILL); $aCorp->addWeapon($this->weaponTypeID); }
/** * Return HTML to describe the victim * * @global Smarty $smarty * @return string HTML to describe the victim */ function victim() { global $smarty; $smarty->assign('killID', $this->kill->getID()); $plt = new Pilot($this->kill->getVictimID()); $item = new dogma($this->kill->getVictimShip()->getID()); // itt_cat = 6 for ships. Assume != 6 is a structure. if ($item->get('itt_cat') != 6) { $corp = new Corporation($this->kill->getVictimCorpID()); $smarty->assign('victimPortrait', $corp->getPortraitURL(64)); $smarty->assign('victimExtID', 0); $smarty->assign('victimURL', edkURI::page('invtype', $item->getID())); } else { $smarty->assign('victimPortrait', $plt->getPortraitURL(64)); $smarty->assign('victimExtID', $plt->getExternalID()); $smarty->assign('victimURL', edkURI::page('pilot_detail', $this->kill->getVictimID(), 'plt_id')); } $smarty->assign('victimName', $this->kill->getVictimName()); $smarty->assign('victimCorpURL', edkURI::page('corp_detail', $this->kill->getVictimCorpID(), 'crp_id')); $smarty->assign('victimCorpName', $this->kill->getVictimCorpName()); $smarty->assign('victimAllianceURL', edkURI::page('alliance_detail', $this->kill->getVictimAllianceID(), 'all_id')); $smarty->assign('victimAllianceName', $this->kill->getVictimAllianceName()); $smarty->assign('victimDamageTaken', $this->kill->getDamageTaken()); return $smarty->fetch(get_tpl('kill_detail_victim')); }
/** * Filter the query by a related Corporation object * * @param Corporation|PropelObjectCollection $corporation The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return CourtQuery The current query, for fluid interface * @throws PropelException - if the provided filter is invalid. */ public function filterByCorporation($corporation, $comparison = null) { if ($corporation instanceof Corporation) { return $this->addUsingAlias(CourtPeer::CORPORATION_ID, $corporation->getId(), $comparison); } elseif ($corporation instanceof PropelObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this->addUsingAlias(CourtPeer::CORPORATION_ID, $corporation->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { throw new PropelException('filterByCorporation() only accepts arguments of type Corporation or PropelCollection'); } }
if ($row['sta_value'] >= -5) { $icon = 'bad'; } else { $icon = 'horrible'; } } } if ($typ == 'a') { $alliance = Alliance::getByID($id); $text = $alliance->getName(); $pid = $alliance->getUnique(); $link = edkURI::page('admin_standings', $typ . $row['sta_to'], 'del'); $permt[$typ][] = array('text' => $text, 'link' => $link, 'all_url' => $alliance->getDetailsURL(), 'all_img' => $alliance->getPortraitURL(32), 'value' => $val, 'comment' => $row['sta_comment'], 'id' => $id, 'pid' => $pid, 'typ' => $row['sta_to'], 'icon' => $icon); } else { if ($typ == 'c') { $corp = Corporation::getByID((int) $row['sta_to']); $text = $corp->getName(); $link = edkURI::page('admin_standings', $typ . $row['sta_to'], 'del'); $permt[$typ][] = array('text' => $text, 'link' => $link, 'crp_url' => $corp->getDetailsURL(), 'crp_img' => $corp->getPortraitURL(32), 'value' => $val, 'comment' => $row['sta_comment'], 'id' => $id, 'typ' => $typ, 'icon' => $icon); } } } $perm = array(); if ($permt['a']) { $perm[] = array('name' => 'Alliances', 'list' => $permt['a']); } if ($permt['c']) { $perm[] = array('name' => 'Corporations', 'list' => $permt['c']); } $smarty->assignByRef('standings', $perm); $page->setContent($smarty->fetch(get_tpl('standings')));
/** * * @param KillList $killList * @return string KillList as XML */ public static function killListToXML($killList) { global $idfeedversion; $qry = DBFactory::getDBQuery(); $date = gmdate('Y-m-d H:i:s'); $xml = "<?xml version='1.0' encoding='UTF-8'?>\n\t\t<eveapi version='2' edkapi='" . $idfeedversion . "'>\n\t\t</eveapi>"; $sxe = new SimpleXMLElement($xml); // Let's start making the xml. $sxe->addChild('currentTime', $date); $result = $sxe->addChild('result'); $kills = $result->addChild('rowset'); $kills->addAttribute('name', 'kills'); $kills->addAttribute('key', 'killID'); $kills->addAttribute('columns', 'killID,solarSystemID,killTime,moonID,hash,trust'); $count = 0; $timing = ''; while ($kill = $killList->getKill()) { if (config::get('km_cache_enabled') && CacheHandler::exists($kill->getID() . ".xml", 'mails')) { $cachedRow = new SimpleXMLElement(CacheHandler::get($kill->getID() . ".xml", 'mails')); IDFeed::addXMLElement($kills, $cachedRow); continue; } $count++; if ($kill->isClassified()) { continue; } //$kill = Kill::getByID($kill->getID()); $row = $kills->addChild('row'); $row->addAttribute('killID', intval($kill->getExternalID())); $row->addAttribute('killInternalID', intval($kill->getID())); $row->addAttribute('solarSystemID', $kill->getSystem()->getExternalID()); $row->addAttribute('killTime', $kill->getTimeStamp()); $row->addAttribute('moonID', '0'); $row->addAttribute('hash', bin2hex(IDFeed::getHash($kill, true))); $row->addAttribute('trust', 3); $victim = Pilot::getByID($kill->getVictimID()); $victimCorp = Corporation::getByID($kill->getVictimCorpID()); $victimAlliance = Alliance::getByID($kill->getVictimAllianceID()); $victimrow = $row->addChild('victim'); if ($victim->getName() == $kill->getVictimShipName()) { $victimrow->addAttribute('characterID', "0"); $victimrow->addAttribute('characterName', ""); } else { $victimrow->addAttribute('characterID', $victim->getExternalID()); $victimrow->addAttribute('characterName', $victim->getName()); } $victimrow->addAttribute('corporationID', $victimCorp->getExternalID()); $victimrow->addAttribute('corporationName', $victimCorp->getName()); if ($victimAlliance->isFaction()) { $victimrow->addAttribute('allianceID', 0); $victimrow->addAttribute('allianceName', ''); $victimrow->addAttribute('factionID', $victimAlliance->getFactionID()); $victimrow->addAttribute('factionName', $victimAlliance->getName()); } else { $victimrow->addAttribute('allianceID', $victimAlliance->getExternalID()); $victimrow->addAttribute('allianceName', $victimAlliance->getName()); $victimrow->addAttribute('factionID', 0); $victimrow->addAttribute('factionName', ''); } $victimrow->addAttribute('damageTaken', $kill->getDamageTaken()); $victimrow->addAttribute('shipTypeID', $kill->getVictimShipExternalID()); $involved = $row->addChild('rowset'); $involved->addAttribute('name', 'attackers'); $involved->addAttribute('columns', 'characterID,characterName,corporationID,corporationName,allianceID,allianceName,factionID,factionName,securityStatus,damageDone,finalBlow,weaponTypeID,shipTypeID'); $sql = "SELECT ind_sec_status, ind_all_id, ind_crp_id,\n\t\t\t\tind_shp_id, ind_wep_id, ind_order, ind_dmgdone, plt_id, plt_name,\n\t\t\t\tplt_externalid, crp_name, crp_external_id,\n\t\t\t\twtype.typeName AS wep_name FROM kb3_inv_detail\n\t\t\t\tJOIN kb3_pilots ON (plt_id = ind_plt_id)\n\t\t\t\tJOIN kb3_corps ON (crp_id = ind_crp_id)\n\t\t\t\tJOIN kb3_invtypes wtype ON (ind_wep_id = wtype.typeID)\n\t\t\t\tWHERE ind_kll_id = " . $kill->getID() . " ORDER BY ind_order ASC"; $qry->execute($sql); while ($inv = $qry->getRow()) { $invrow = $involved->addChild('row'); if (strpos($inv['plt_name'], '- ') !== false) { $inv['plt_name'] = substr($inv['plt_name'], strpos($inv['plt_name'], '- ') + 2); } else { if (strpos($inv['plt_name'], '#') !== false) { $name = explode("#", $inv['plt_name']); $inv['plt_name'] = $name[3]; } } if ($inv['plt_name'] == $inv['wep_name']) { $invrow->addAttribute('characterID', 0); $invrow->addAttribute('characterName', ""); $invrow->addAttribute('weaponTypeID', 0); $invrow->addAttribute('shipTypeID', $inv['ind_wep_id']); } else { $invrow->addAttribute('characterID', $inv['plt_externalid']); $invrow->addAttribute('characterName', $inv['plt_name']); $invrow->addAttribute('weaponTypeID', $inv['ind_wep_id']); $invrow->addAttribute('shipTypeID', $inv['ind_shp_id']); } $invrow->addAttribute('corporationID', $inv['crp_external_id']); $invrow->addAttribute('corporationName', $inv['crp_name']); $invAlliance = Alliance::getByID($inv['ind_all_id']); if ($invAlliance->isFaction()) { $invrow->addAttribute('allianceID', 0); $invrow->addAttribute('allianceName', ''); $invrow->addAttribute('factionID', $invAlliance->getFactionID()); $invrow->addAttribute('factionName', $invAlliance->getName()); } else { if (strcasecmp($invAlliance->getName(), "None") == 0) { $invrow->addAttribute('allianceID', 0); $invrow->addAttribute('allianceName', ""); } else { $invrow->addAttribute('allianceID', $invAlliance->getExternalID()); $invrow->addAttribute('allianceName', $invAlliance->getName()); } $invrow->addAttribute('factionID', 0); $invrow->addAttribute('factionName', ''); } $invrow->addAttribute('securityStatus', number_format($inv['ind_sec_status'], 1)); $invrow->addAttribute('damageDone', $inv['ind_dmgdone']); if ($inv['plt_id'] == $kill->getFBPilotID()) { $final = 1; } else { $final = 0; } $invrow->addAttribute('finalBlow', $final); } $sql = "SELECT * FROM kb3_items_destroyed WHERE itd_kll_id = " . $kill->getID(); $qry->execute($sql); $qry2 = DBFactory::getDBQuery(); $sql = "SELECT * FROM kb3_items_dropped WHERE itd_kll_id = " . $kill->getID(); $qry2->execute($sql); if ($qry->recordCount() || $qry2->recordCount()) { $items = $row->addChild('rowset'); $items->addAttribute('name', 'items'); $items->addAttribute('columns', 'typeID,flag,qtyDropped,qtyDestroyed, singleton'); while ($iRow = $qry->getRow()) { $itemRow = $items->addChild('row'); $itemRow->addAttribute('typeID', $iRow['itd_itm_id']); $itemRow->addAttribute('flag', $iRow['itd_itl_id']); if ($iRow['itd_itl_id'] == -1) { $itemRow->addAttribute('singleton', 2); } else { $itemRow->addAttribute('singleton', 0); } $itemRow->addAttribute('qtyDropped', 0); $itemRow->addAttribute('qtyDestroyed', $iRow['itd_quantity']); } while ($iRow = $qry2->getRow()) { $itemRow = $items->addChild('row'); $itemRow->addAttribute('typeID', $iRow['itd_itm_id']); $itemRow->addAttribute('flag', $iRow['itd_itl_id']); if ($iRow['itd_itl_id'] == -1) { $itemRow->addAttribute('singleton', 2); } else { $itemRow->addAttribute('singleton', 0); } $itemRow->addAttribute('qtyDropped', $iRow['itd_quantity']); $itemRow->addAttribute('qtyDestroyed', 0); } } if (config::get('km_cache_enabled')) { CacheHandler::put($kill->getID() . ".xml", $row->asXML(), 'mails'); } $timing .= $kill->getID() . ": " . (microtime(true) - $starttime) . "<br />"; } $sxe->addChild('cachedUntil', $date); return $sxe->asXML(); }
$html .= "<tr><td></td></tr>"; $html .= "<tr><td></td><td><input type=submit name=detail_submit value=\"Save\"></td></tr>"; $html .= "</table>"; $html .= "</form>"; $html .= "<div class=block-header2>Targets</div>"; $html .= "<table class=kb-table cellspacing=1>"; $html .= "<tr class=kb-table-header><td class=kb-table-cell width=160>Target</td><td class=kb-table-cell width=80 align=center>Corporation</td><td class=kb-table-cell width=80 align=center>Alliance</td><td class=kb-table-cell width=80 align=center>Region</td><td class=kb-table-cell width=80 align=center>System</td><td class=kb-table-cell width=80 align=center>Action</td></tr>"; $c = 0; while ($contracttarget = $contract->getContractTarget()) { $c++; $type = $contracttarget->getType(); $typeURL = false; $ctrTypeID = $contracttarget->getID(); switch ($type) { case "corp": $corp = new Corporation($ctrTypeID); $name = $corp->getName(); $typeURL = edkURI::page('corp_detail', $ctrTypeID, 'crp_id'); break; case "alliance": $alliance = new Alliance($ctrTypeID); $name = $alliance->getName(); $typeURL = edkURI::page('alliance_detail', $ctrTypeID, 'all_id'); break; case "region": $region = new Region($ctrTypeID); $name = $region->getName(); $typeURL = edkURI::page('detail_view', $ctrTypeID, 'region_id'); break; case "system": $system = new SolarSystem($ctrTypeID);
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; } }
/** * 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')); }
/** * Import zKillboard kills for the selected systems and alliances. */ public function getZkillboard($systems = '') { // If this is the initial call to the function, retrieve the list of systems from the DB. if ($systems == '') { $systems_object = Setting::where('key', 'systems')->firstOrFail(); $systems = $systems_object->value; } // Convert the comma-seperated string into an array. $systems_array = explode(',', $systems); // If there are more systems in the list than we want to pull at once, chop off the first X and call this function again. while (count($systems_array) > $this->api_system_limit) { $this->getZkillboard(implode(',', array_splice($systems_array, 0, $this->api_system_limit))); } // Retrieve the selected alliances from the database. $alliances = Setting::where('key', 'alliances')->firstOrFail(); // Build the API URL. $url = 'https://zkillboard.com/api/xml/losses/no-attackers/' . 'allianceID/' . preg_replace('/\\s+/', '', $alliances->value) . '/' . 'solarSystemID/' . preg_replace('/\\s+/', '', $systems) . '/'; // Send the request. $response = Request::get($url)->addHeader('Accept-Encoding', 'gzip')->addHeader('User-Agent', 'Eve Traders Handbook')->send(); if (isset($response->body) && strlen($response->body) > 0) { $body = simplexml_load_string(gzdecode($response->body)); $insert_count = 0; // Parse the response, inserting the losses into the database. foreach ($body->result->rowset->row as $row) { // First check whether this kill has not already been recorded. $kill = Kill::find($row['killID']); if (!isset($kill->killID)) { // Create and save the new kill record. $kill = new Kill(); $kill->killID = $row['killID']; $kill->solarSystemID = $row['solarSystemID']; $kill->characterID = $row->victim['characterID']; $kill->characterName = $row->victim['characterName']; $kill->allianceID = $row->victim['allianceID']; $kill->corporationID = $row->victim['corporationID']; $kill->shipTypeID = $row->victim['shipTypeID']; $kill->killTime = $row['killTime']; $kill->save(); $insert_count++; // Insert the alliance information into the database unless it already exists. $alliance = Alliance::find($kill->allianceID); if (!isset($alliance->id)) { $alliance = new Alliance(); $alliance->id = $kill->allianceID; $alliance->allianceName = $row->victim['allianceName']; $alliance->save(); } // Insert the corporation information into the database unless it already exists. $corporation = Corporation::find($kill->corporationID); if (!isset($corporation->id)) { $corporation = new Corporation(); $corporation->id = $kill->corporationID; $corporation->corporationName = $row->victim['corporationName']; $corporation->save(); } // Insert the ship type that was lost into the database unless it already exists. $ship = Ship::find($kill->shipTypeID); $type = Type::find($kill->shipTypeID); if (!isset($ship->id)) { $ship = new Ship(); $ship->id = $kill->shipTypeID; $ship->shipName = $type->typeName; $ship->save(); } // Insert the ship loss into the items database as well. if (stristr($ship->shipName, 'Capsule') === FALSE) { $item = new Item(); $item->killID = $row['killID']; $item->typeID = $kill->shipTypeID; $item->typeName = $type->typeName; $item->categoryName = $type->group->category['categoryName']; $item->metaGroupName = isset($type->metaType->metaGroup['metaGroupName']) ? $type->metaType->metaGroup['metaGroupName'] : ''; $item->allowManufacture = 1; $item->qty = 1; $item->save(); } // Add the category to the list of filters available on the site. $filter = Filter::find($type->group->category['categoryID']); if (!isset($filter->categoryID)) { $filter = new Filter(); $filter->categoryID = $type->group->category['categoryID']; $filter->categoryName = $type->group->category['categoryName']; $filter->iconID = $type->group->category['iconID']; $filter->save(); } // Loop through the items lost in the kill. Insert each one into the items table. if (isset($row->rowset->row)) { foreach ($row->rowset->row as $loss) { $typeID = (int) $loss['typeID']; $item = Item::where('typeID', '=', $typeID)->first(); // If this item already exists in the items table, we don't need to re-query all the additional // information, we can just copy it from an existing row. if (isset($item)) { // This type has already been seen. Duplicate the record and save the new instance. $clone = new Item(); $clone = $item->replicate(); // Update the right killID and quantity, and unset the primary key and date columns. $clone->killID = $row['killID']; $clone->qty = $loss['qtyDropped'] + $loss['qtyDestroyed']; unset($clone->id); unset($clone->created_at); unset($clone->updated_at); // Save the cloned row. $clone->save(); } else { // This is a never-before-seen lost item. Create a new row and look up all the related details. $item = new Item(); $type = Type::find($typeID); $item->killID = (int) $row['killID']; $item->typeID = $typeID; $item->typeName = $type->typeName; $item->categoryName = $type->group->category['categoryName']; $metaGroupName = isset($type->metaType->metaGroup['metaGroupName']) ? $type->metaType->metaGroup['metaGroupName'] : ''; if ($metaGroupName == 'Tech I' || $metaGroupName == '') { $metaLevel = DB::table('dgmTypeAttributes')->where('typeID', $typeID)->where('attributeID', 633)->first(); if (isset($metaLevel)) { $metaGroupName = 'Meta '; $metaGroupName .= isset($metaLevel->valueInt) ? $metaLevel->valueInt : $metaLevel->valueFloat; } } $item->metaGroupName = $metaGroupName; $blueprint = Type::where('typeName', $type->typeName . ' Blueprint')->count(); if ($blueprint > 0) { $item->allowManufacture = 1; } $item->qty = $loss['qtyDropped'] + $loss['qtyDestroyed']; $item->save(); // Add the category to the list of filters available on the site. $filter = Filter::find($type->group->category['categoryID']); if (!isset($filter->categoryID)) { $filter = new Filter(); $filter->categoryID = $type->group->category['categoryID']; $filter->categoryName = $type->group->category['categoryName']; $filter->iconID = $type->group->category['iconID']; $filter->save(); } } } } } } echo "Inserted {$insert_count} new kills! "; } else { echo "No response received from zKillboard API."; } }
/** * 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; }
foreach ($permissions as $typ => $ids) { foreach ($ids as $id) { if ($typ == 'a') { $alliance = new Alliance($id); $text = $alliance->getName(); $link = KB_HOST . '/?a=admin_postperm&del=' . $typ . $id . '&akey=' . session::makeKey(); $permt[$typ][] = array('text' => $text, 'link' => $link); } if ($typ == 'p') { $pilot = new Pilot($id); $text = $pilot->getName(); $link = KB_HOST . '/?a=admin_postperm&del=' . $typ . $id . '&akey=' . session::makeKey(); $permt[$typ][] = array('text' => $text, 'link' => $link); } if ($typ == 'c') { $corp = new Corporation($id); $text = $corp->getName(); $link = KB_HOST . '/?a=admin_postperm&del=' . $typ . $id . '&akey=' . session::makeKey(); $permt[$typ][] = array('text' => $text, 'link' => $link); } } } $perm = array(); if ($permt['a']) { $perm[] = array('name' => 'Alliances', 'list' => $permt['a']); } if ($permt['p']) { $perm[] = array('name' => 'Pilots', 'list' => $permt['p']); } if ($permt['c']) { $perm[] = array('name' => 'Corporations', 'list' => $permt['c']);
/** * 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; }