/** * Return the SolarSystem this kill took place in. * @return SolarSystem */ function getSystem() { if (isset($this->solarsystem)) { return $this->solarsystem; } else { $this->solarsystem = SolarSystem::getByID($this->solarsystemid); } return $this->solarsystem; }
/** * get battles which's timeframe is in or overlaps with the given time interval * @param long $systemId * @param String $timestampStart * @param String $timestampEnd */ public static function getBattlesInTimeframe($systemId, $timestampStart, $timestampEnd) { $qry = DBFactory::getDBQuery(); $System = SolarSystem::getByID($systemId); $sql = "\n SELECT\n battle_id, start, end\n FROM kb3_battles_cache\n WHERE (( start >= '{$timestampStart}' AND start <= '{$timestampEnd}')\n OR (end >= '{$timestampStart}' AND end <= '{$timestampEnd}'))\n AND system = '{$System->getName()}'\n "; $battles = array(); $qry->execute($sql); while ($row = $qry->getRow()) { $battles[] = $row; } return $battles; }
/** * @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')); }
/** * @param SimpleXMLElement $row The row for a single kill. */ private function processKill($row) { $skip = false; $dup = false; $errorstring = ""; $internalID = (int) $row['killInternalID']; $externalID = (int) $row['killID']; $id = 0; if (config::get('filter_apply') && config::get('filter_date') > strtotime(strval($row['killTime']))) { $skip = true; } else { $kill = new Kill(); if ($externalID) { $kill->setExternalID($externalID); $id = $kill->getDupe(); //speedy dup check based on external id only if ($id > 0) { //duplicate found $qry = DBFactory::getDBQuery(true); $qry->execute("INSERT IGNORE INTO kb3_mails (`kll_id`," . " `kll_timestamp`, `kll_external_id`, `kll_modified_time`)" . "VALUES({$id}, '" . $kill->getTimeStamp() . "', {$externalID}, UTC_TIMESTAMP())"); $qry->execute("UPDATE kb3_kills SET kb3_kills.kll_external_id = {$externalID} WHERE kb3_kills.kll_id = {$id} AND kb3_kills.kll_external_id IS NULL"); $dup = true; } } if (!$dup) { $kill->setTimeStamp(strval($row['killTime'])); $sys = SolarSystem::getByID((int) $row['solarSystemID']); if (!$sys->getName()) { $errorstring .= " Invalid solar system"; $skip = true; } $kill->setSolarSystem($sys); if (!$this->processVictim($row, $kill, strval($row['killTime']))) { $errorstring .= " Invalid victim."; $skip = true; } if (!$skip) { //skipping intensive involved party processing $this->npcOnly = true; //there's no real check for this anymore? foreach ($row->rowset[0]->row as $inv) { if (!$this->processInvolved($inv, $kill, strval($row['killTime']))) { $errorstring .= " Invalid involved party."; $skip = true; break; } } // Don't post NPC only kills if configured. if ($this->npcOnly && Config::get('post_no_npc_only')) { $errorstring .= " NPC Only mail."; $skip = true; } if (!$skip) { //skipping intensive items processing if (isset($row->rowset[1]->row[0])) { foreach ($row->rowset[1]->row as $item) { $this->processItem($item, $kill); } } $authorized = false; if (config::get('cfg_allianceid') && in_array($kill->getVictimAllianceID(), config::get('cfg_allianceid'))) { $authorized = true; } else { if (config::get('cfg_corpid') && in_array($kill->getVictimCorpID(), config::get('cfg_corpid'))) { $authorized = true; } else { if (config::get('cfg_pilotid') && in_array($kill->getVictimID(), config::get('cfg_pilotid'))) { $authorized = true; } } } foreach ($kill->getInvolved() as $inv) { if (config::get('cfg_allianceid') && in_array($inv->getAllianceID(), config::get('cfg_allianceid'))) { $authorized = true; } else { if (config::get('cfg_corpid') && in_array($inv->getCorpID(), config::get('cfg_corpid'))) { $authorized = true; } else { if (config::get('cfg_pilotid') && in_array($inv->getPilotID(), config::get('cfg_pilotid'))) { $authorized = true; } } } } if (!$authorized) { $skip = true; } else { $id = $kill->add(); if ($kill->getDupe(true)) { $dup = true; } else { $this->posted[] = array($externalID, $internalID, $id); // Prepare text for the log. if ($this->url) { $logaddress = "ID:" . $this->url; if (strpos($logaddress, "?")) { $logaddress = substr($logaddress, 0, strpos($logaddress, "?")); } if ($kill->getExternalID()) { $logaddress .= "?a=kill_detail&kll_ext_id=" . $kill->getExternalID(); } else { if ($internalID) { $logaddress .= "?a=kill_detail&kll_id=" . $internalID; } } } else { if ($this->name) { $logaddress = $this->name; if ($kill->getExternalID()) { $logaddress .= ":kll_ext_id=" . $kill->getExternalID(); } else { if ($internalID) { $logaddress .= ":kll_id=" . $internalID; } } } else { $logaddress = "ID: local input"; } } logger::logKill($id, $logaddress); } } } } } } if ($skip) { $this->skipped[] = array($externalID, $internalID, $id); if ($errorstring) { $errorstring .= " Kill not added. killID = {$externalID}" . ($internalID ? ", killInternalID = {$internalID}." : "."); $this->parsemsg[] = $errorstring; } } if ($dup) { $this->duplicate[] = array($externalID, $internalID, $id); } if ($this->lastReturned < $externalID) { $this->lastReturned = $externalID; } if ($this->lastInternalReturned < $internalID) { $this->lastInternalReturned = $internalID; } }
/** * adds meta tags for Twitter Summary Card and OpenGraph tags * to the HTML header */ function metaTags() { $referenceSystem = SolarSystem::getByID(reset($this->systems)); // meta tag: title $metaTagTitle = $referenceSystem->getName() . " | " . $referenceSystem->getRegionName() . " | Battle Report"; $this->page->addHeader('<meta name="og:title" content="' . $metaTagTitle . '">'); $this->page->addHeader('<meta name="twitter:title" content="' . $metaTagTitle . '">'); // build description $date = gmdate("Y-m-d", strtotime($this->firstts)); $startTime = gmdate("H:i", strtotime($this->firstts)); $endTime = gmdate("H:i", strtotime($this->lastts)); $totalIskDestroyedM = round(($this->summaryTable->getTotalKillISK() + $this->summaryTable->getTotalLossISK()) / 1000000, 2); $metaTagDescription = "Battle Report for " . $referenceSystem->getName() . " (" . $referenceSystem->getRegionName() . ") from " . $date . " (" . $startTime . " - " . $endTime . "): "; $metaTagDescription .= "Involved Pilots: " . (count($this->pilots['a']) + count($this->pilots['e'])) . ", Total ISK destroyed: " . $totalIskDestroyedM . "M ISK"; $this->page->addHeader('<meta name="description" content="' . $metaTagDescription . '">'); $this->page->addHeader('<meta name="og:description" content="' . $metaTagDescription . '">'); // meta tag: image $this->page->addHeader('<meta name="og:image" content="' . imageURL::getURL('Type', 3802, 64) . '">'); $this->page->addHeader('<meta name="twitter:image" content="' . imageURL::getURL('Type', 3802, 64) . '">'); $this->page->addHeader('<meta name="og:site_name" content="EDK - ' . config::get('cfg_kbtitle') . '">'); // meta tag: URL $this->page->addHeader('<meta name="og:url" content="' . edkURI::build(array('kll_id', $this->kll_id, true)) . '">'); // meta tag: Twitter summary $this->page->addHeader('<meta name="twitter:card" content="summary">'); }