function generate() { global $smarty; $this->toplist->generate(); $i = 1; $rows = array(); while ($row = $this->toplist->getRow()) { $pilot = Pilot::getByID($row['plt_id']); $uri = edkURI::build(array('a', 'kill_detail', true), array('kll_id', $row['kll_id'], true)); if ($row['plt_externalid']) { $img = imageURL::getURL('Pilot', $row['plt_externalid'], 32); } else { $img = $pilot->getPortraitURL(32); } $ship = Ship::getByID($row['ship']); $shipUri = edkURI::build(array('a', 'invtype', true), array('id', $row['ship'], true)); if ((int) number_format($row["isk"], 0, "", "") > 1000000000) { $isk = number_format($row["isk"] / 1000000000, 2, ".", "") . " b"; } elseif ((int) number_format($row["isk"], 0, "", "") > 1000000) { $isk = number_format($row["isk"] / 1000000, 2, ".", "") . " M"; } else { $isk = number_format($row["isk"], 0, ".", ","); } $rows[] = array('rank' => $i, 'name' => $pilot->getName(), 'uri' => $uri, 'portrait' => $img, 'shipImage' => $ship->getImage(32), 'shipName' => $ship->getName(), 'shipId' => $row['ship'], 'shipURI' => $shipUri, 'isk' => $isk); $i++; } $smarty->assign('tl_name', 'Pilot'); $smarty->assign('tl_type', $this->entity_); $smarty->assignByRef('tl_rows', $rows); return $smarty->fetch(getcwd() . '/mods/most_expensive_toplist/templates/toplisttable_expensive.tpl'); }
function details() { global $smarty; $item = new dogma($this->typeID); if (!$item->isValid()) { $this->page->setTitle('Error'); return 'This ID is not a valid dogma ID.'; } $this->page->setTitle('Item details - ' . $item->get('typeName')); $this->page->addHeader('<meta name="robots" content="noindex, nofollow" />'); $smarty->assignByRef('item', $item); if ($item->get('itt_cat') == 6) { //we have a ship, so get it from the db $ship = Ship::getByID($item->get('typeID')); $smarty->assign('shipImage', $ship->getImage(64)); $smarty->assign('armour', array('armorHP', 'armorEmDamageResonance', 'armorExplosiveDamageResonance', 'armorKineticDamageResonance', 'armorThermalDamageResonance')); $smarty->assign('shield', array('shieldCapacity', 'shieldRechargeRate', 'shieldEmDamageResonance', 'shieldExplosiveDamageResonance', 'shieldKineticDamageResonance', 'shieldThermalDamageResonance')); $smarty->assign('propulsion', array('maxVelocity', 'agility', 'droneCapacity', 'capacitorCapacity', 'rechargeRate')); $smarty->assign('fitting', array('hiSlots', 'medSlots', 'lowSlots', 'rigSlots', 'upgradeCapacity', 'droneBandwidth', 'launcherSlotsLeft', 'turretSlotsLeft', 'powerOutput', 'cpuOutput')); $smarty->assign('targetting', array('maxTargetRange', 'scanResolution', 'maxLockedTargets', 'scanRadarStrength', 'scanLadarStrength', 'scanMagnetometricStrength', 'scanGravimetricStrength', 'signatureRadius')); $smarty->assign('miscellaneous', array('techLevel', 'propulsionFusionStrength', 'propulsionIonStrength', 'propulsionMagpulseStrength', 'propulsionPlasmaStrength')); $html = $smarty->fetch(get_tpl('invtype_ship')); } else { $i = new Item($this->typeID); $smarty->assign('itemImage', $i->getIcon(64, false)); $smarty->assign('akey', session::isAdmin() ? session::makeKey() : false); $html = $smarty->fetch(get_tpl('invtype_item')); } return $html; }
function generate() { global $smarty; $this->toplist->generate(); while ($row = $this->toplist->getRow()) { $ship = Ship::getByID($row['shp_id']); $shipclass = $ship->getClass(); $shipclass->getName(); $rows[] = array('rank' => false, 'name' => $ship->getName(), 'subname' => $shipclass->getName(), 'uri' => edkURI::page('invtype', $ship->getID()), 'portrait' => $ship->getImage(32), 'count' => $row['cnt']); } $smarty->assign('tl_name', Language::get('ship')); $smarty->assign('tl_type', Language::get('kills')); $smarty->assignByRef('tl_rows', $rows); return $smarty->fetch(get_tpl('toplisttable')); }
/** * Return the victim's Ship. * @return Ship */ function getVictimShip() { return Ship::getByID($this->victimshipid); }
/** * @param SimpleXMLElement $inv * @param Kill $kill * @param string $time YYYY-mm-dd hh:ss * @return boolean false on error */ private function processInvolved($inv, &$kill, $time) { if (!(int) $inv['shipTypeID'] && !(int) $inv['weaponTypeID'] && !(int) $inv['characterID'] && !(string) $inv['characterName']) { $this->parsemsg[] = "Involved party blank."; return false; } $npc = false; $ship = Ship::getByID((int) $inv['shipTypeID']); $weapon = Cacheable::factory('Item', (int) $inv['weaponTypeID']); $alliance = new Alliance(); if ((int) $inv['allianceID']) { $alliance = Alliance::add(strval($inv['allianceName']), (int) $inv['allianceID']); } else { if ((int) $inv['factionID']) { $alliance = Alliance::add(strval($inv['factionName']), (int) $inv['factionID']); } else { $alliance = Alliance::add("None"); } } // get alliance from corp if ship is any kind of tower $shipClassID = $ship->getClass()->getID(); if ($shipClassID == 35 || $shipClassID == 36 || $shipClassID == 37) { $corpByName = Corporation::lookup(strval($inv['corporationName'])); if ($corpByName) { $alliance = $corpByName->getAlliance(); } } $corp = Corporation::add(strval($inv['corporationName']), $alliance, $time, (int) $inv['corporationID']); $charid = (int) $inv['characterID']; $charname = (string) $inv['characterName']; // Allow for blank names for consistency with CCP API. if (preg_match("/(Mobile (Large|Medium|Small) Warp Disruptor I?I?|\\w+ Control Tower( \\w+)?)/", $charname)) { $charname = $inv['corporationName'] . ' - ' . $charname; $charid = 0; } else { if ($charname == "" && preg_match("/(Mobile \\w+ Warp|\\w+ Control Tower( \\w+)?)/", $weapon->getName())) { $charname = $inv['corporationName'] . ' - ' . $weapon->getName(); $charid = 0; } else { if ($charname == "" && !$charid) { // NPC ship $ship = Ship::lookup("Unknown"); $weapon = Item::getByID((int) $inv['shipTypeID']); $charname = $weapon->getName(); $npc = true; $charid = $weapon->getID(); } else { if ($charname == "" && $charid) { // Bugged kill $this->parsemsg[] = "Involved party has blank pilot name."; return false; } } } } $pilot = Pilot::add((string) $charname, $corp, $time, $charid); $iparty = new InvolvedParty($pilot->getID(), $corp->getID(), $alliance->getID(), (double) $inv['securityStatus'], $ship->getID(), $weapon->getID(), (int) $inv['damageDone']); $kill->addInvolvedParty($iparty); if ((int) $inv['finalBlow'] == 1) { $kill->setFBPilotID($pilot->getID()); } $this->npcOnly = $this->npcOnly && $npc; return true; }
/** * Look up a Ship by name. * * @param string $name a string containing a ship name. */ static function lookup($name) { static $cache_name = array(); static $pqry = null; static $id = 0; static $shp_name = ""; static $scl_id = 0; static $typeName = ""; if (isset($cache_name[$name])) { return $cache_name[$name]; } if ($name == "Unknown") { $cache_name[$name] = Ship::getByID(0); return $cache_name[$name]; } if ($pqry === null) { $pqry = new DBPreparedQuery(); $pqry->prepare("SELECT typeID, typeName, shp_class" . " FROM kb3_ships RIGHT JOIN kb3_invtypes ON shp_id=typeID" . " WHERE typeName = ?"); } $shp_name = $name = trim(stripslashes($name)); $pqry->bind_param('s', $shp_name); $pqry->bind_result($id, $typeName, $scl_id); if (!$pqry->execute() || !$pqry->recordCount()) { return false; } else { $pqry->fetch(); } if ($scl_id == null && $id) { $qry = DBFactory::getDBQuery(); $qry->execute("INSERT INTO kb3_ships (shp_id, shp_class) values({$id}, 18)"); $scl_id = 18; // "Unknown" } $shipclass = ShipClass::getByID($scl_id); $cache_name[$name] = new Ship($id, null, $typeName, $shipclass); return $cache_name[$name]; }
/** * @return string HTML string for the summary overview of the battle. */ public function overview() { global $smarty; $smarty->assignByRef('pilots_a', $this->pilots['a']); $smarty->assignByRef('pilots_e', $this->pilots['e']); $pod = Ship::getByID(670); $smarty->assign('podpic', $pod->getImage(32)); $smarty->assign('friendlycnt', count($this->pilots['a'])); $smarty->assign('hostilecnt', count($this->pilots['e'])); if ($classified) { $smarty->assign('system', 'Classified System'); } else { if (!$this->adjacent) { $smarty->assign('system', $this->kill->getSolarSystemName()); } else { $sysnames = array(); foreach ($this->systems as $sys_id) { $system = SolarSystem::getByID($sys_id); $sysnames[] = $system->getName(); } $smarty->assign('system', implode(', ', $sysnames)); } } $smarty->assign('firstts', $this->firstts); $smarty->assign('lastts', $this->lastts); $smarty->assign('killURL', edkURI::page('kill_detail')); return $smarty->fetch(get_tpl('kill_related_battle_overview')); }
function involvedSetup() { global $smarty; $fetchExternalIDs = array(); // involved $i = 1; $this->involved = array(); $this->ownKill = false; $invlimit = config::get('kd_involvedlimit'); if (!is_numeric($invlimit)) { $this->nolimit = 1; } foreach ($this->kill->getInvolved() as $inv) { $corp = Corporation::getByID($inv->getCorpID()); $alliance = Alliance::getByID($inv->getAllianceID()); $ship = Ship::getByID($inv->getShipID()); $alliance_name = $alliance->getName(); if (!isset($this->invAllies[$alliance_name])) { $this->invAllies[$alliance_name] = array('quantity' => 1, 'corps' => array()); } else { $this->invAllies[$alliance_name]["quantity"] += 1; } $corp_name = $corp->getName(); if (!isset($this->invAllies[$alliance_name]["corps"][$corp_name])) { $this->invAllies[$alliance_name]["corps"][$corp_name] = 1; } else { $this->invAllies[$alliance_name]["corps"][$corp_name] += 1; } $ship_name = $ship->getName(); if (!isset($this->invShips[$ship_name])) { $this->invShips[$ship_name] = 1; } else { $this->invShips[$ship_name] += 1; } if (in_array($alliance->getID(), config::get('cfg_allianceid'))) { $this->ownKill = true; } else { if (in_array($corp->getID(), config::get('cfg_corpid'))) { $this->ownKill = true; } else { if (in_array($inv->getPilotID(), config::get('cfg_pilotid'))) { $this->ownKill = true; } } } if (!$this->nolimit && $i > $invlimit) { if ($i == $invlimit + 1) { $smarty->assign('limited', true); $smarty->assign('moreInvolved', $this->kill->getInvolvedPartyCount() - $invlimit); $smarty->assign('unlimitURL', '?' . htmlentities($_SERVER['QUERY_STRING']) . '&nolimit'); } } $pilot = Pilot::getByID($inv->getPilotID()); $weapon = Item::getByID($inv->getWeaponID()); $record = array(); $record['shipImage'] = $ship->getImage(64); $record['shipName'] = $ship->getName(); $record['shipID'] = $ship->getID(); if ($ship->getID()) { $record['shipURL'] = edkURI::page('invtype', $ship->getID()); $record['shipClass'] = $ship->getClass()->getName(); } else { $record['shipURL'] = false; $record['shipClass'] = false; } $record['corpURL'] = edkURI::build(array('a', 'corp_detail', true), array('crp_id', $corp->getID(), true)); $record['corpName'] = $corp->getName(); if ($alliance && strcasecmp($alliance->getName(), "None") != 0) { $record['alliURL'] = edkURI::build(array('a', 'alliance_detail', true), array('all_id', $alliance->getID(), true)); } else { $record['alliURL'] = false; } $record['alliName'] = $alliance->getName(); $record['damageDone'] = $inv->getDamageDone(); //detects NPC type things and runs a few conversions (Rats, Towers, Bubbles) $tpilot = $pilot->getName(); if (preg_match("/-/", $tpilot)) { // a tower or bubble. But! Since we have placed the corp name in front of the // item's name, we need to quickly check which base item it was again. $namestart = strripos($tpilot, '-') + 2; //we're interested in the last dash $tpilot = substr($tpilot, $namestart); } if (!$pilot->getID() || $tpilot == $weapon->getName()) { $record['pilotURL'] = edkURI::page('invtype', $weapon->getID()); $record['pilotName'] = $weapon->getName(); $record['secStatus'] = 0; $record['portrait'] = $corp->getPortraitURL(64); $record['externalID'] = $corp->getExternalID(true); if ($record['externalID'] == 0) { $fetchExternalIDs[] = $corp->getName(); } $record['typeID'] = 2; //type number for corporations. $record['pilotURL'] = edkURI::page('invtype', $weapon->getID()); $record['shipImage'] = imageURL::getURL('Ship', $weapon->getID(), 64); $record['shipURL'] = false; $record['shipName'] = $weapon->getName(); $record['weaponURL'] = false; $record['weaponID'] = false; $record['weaponName'] = "Unknown"; } else { if ($pilot->getExternalID(true)) { $record['pilotURL'] = edkURI::build(array('a', 'pilot_detail', true), array('plt_ext_id', $pilot->getExternalID(), true)); } else { $record['pilotURL'] = edkURI::build(array('a', 'pilot_detail', true), array('plt_id', $pilot->getID(), true)); } $record['typeID'] = 1377; //type number for characters. $record['pilotName'] = $pilot->getName(); $record['secStatus'] = $inv->getSecStatus(); $record['portrait'] = $pilot->getPortraitURL(64); $record['externalID'] = $pilot->getExternalID(true); //get the external ID from the pilot class - if not found then add it to a list of pilots //and check the api in bulk if (!$record['externalID']) { $fetchExternalIDs[] = $pilot->getName(); } if ($weapon->getName() != "Unknown" && $weapon->getName() != $ship->getName()) { $record['weaponName'] = $weapon->getName(); $record['weaponID'] = $weapon->getID(); $record['weaponURL'] = edkURI::page('invtype', $weapon->getID()); } else { $record['weaponName'] = "Unknown"; } } $setOtherInvolved = true; if ($inv->getPilotID() == $this->kill->getFBPilotID()) { //Final Blow pilot $this->finalblow = $record; $setOtherInvolved = false; } if ($inv->getPilotID() == $this->kill->getTDPilotID()) { //Top Damage pilot $this->topdamage = $record; $setOtherInvolved = false; } if ($setOtherInvolved) { //other involved pilot $this->involved[] = $record; } ++$i; } //prod CCP for the entire list of names if (count($fetchExternalIDs) > 0) { $names = new API_NametoID(); $names->setNames(implode(',', $fetchExternalIDs)); $names->fetchXML(); $nameIDPair = $names->getNameData(); //fill in the pilot external IDs.. could potentially be slow //but it beats the alternative. Do nothing if no names need loading. if (count($nameIDPair) > 0) { foreach ($nameIDPair as $idpair) { //store the IDs $invovledPilots = $this->kill->getInvolved(); if (isset($this->finalblow)) { $invovledPilots[] = $this->finalblow; } if (isset($this->topdamage)) { $invovledPilots[] = $this->topdamage; } foreach ($invovledPilots as $inv) { $pilot = Cacheable::factory('Pilot', $inv->getPilotID()); $corp = Cacheable::factory('Corporation', $inv->getCorpID()); if ($idpair['name'] == $corp->getName()) { $corp->setExternalID($idpair['characterID']); } else { if ($idpair['name'] == $pilot->getName()) { $pilot->setCharacterID($idpair['characterID']); } } } //as we've already populated the structures for the template //we need to quickly retrofit it. foreach ($this->involved as $inv) { $pname = $inv['pilotName']; $cname = $inv['corpName']; if ($cname == $idpair['name']) { $inv['externalID'] = $idpair['characterID']; } else { if ($pname == $idpair['name']) { $inv['externalID'] = $idpair['characterID']; } } } //same for Final Blow/Top Damage if ($this->finalblow['corpName'] == $idpair['name'] && isset($this->finalblow)) { $this->finalblow['externalID'] = $idpair['characterID']; } else { if ($this->topdamage['pilotName'] == $idpair['name'] && isset($this->topdamage)) { $this->topdamage['externalID'] = $idpair['characterID']; } } } } } }
/** * @return string HTML string for the summary overview of the battle. */ public function overview() { global $smarty; $smarty->assignByRef('pilots_a', $this->pilots['a']); $smarty->assignByRef('pilots_e', $this->pilots['e']); $pod = Ship::getByID(670); $smarty->assign('podpic', $pod->getImage(32)); $smarty->assign('friendlycnt', count($this->pilots['a'])); $smarty->assign('hostilecnt', count($this->pilots['e'])); if ($this->kill->isClassified()) { $smarty->assign('system', 'Classified System'); } else { if (!$this->adjacent) { $smarty->assign('system', $this->kill->getSolarSystemName()); } else { $sysnames = array(); foreach ($this->systems as $sys_id) { $system = SolarSystem::getByID($sys_id); $sysnames[] = $system->getName(); } $smarty->assign('system', implode(', ', $sysnames)); } } $smarty->assign('firstts', $this->firstts); $smarty->assign('lastts', $this->lastts); $smarty->assign("battleOverviewTableTemplate", $this->templateDir . "battle_overview_table.tpl"); return $smarty->fetch($this->templateDir . "battle_overview.tpl"); }