Fair enough, be like that!'); printf('
'); printf('

So you don\'t want to trust us? Fine, it\'s your call.

'); printf('

We\'ll leave you alone for 30 days to think about it. If in the meantime you decide you would like to trust us then simply add http://' . $_SERVER['SERVER_NAME'] . ' to your trusted sites, or click the padlock at the top of the screen.

'); printf('

This window will automatically close in a few seconds.

'); printf('
'); // ======================================================================== } elseif ($action == "chk-trust") { // ======================================================================== // $trustWnd is a flag which determines (best guess) whether the "A website is requesting your trust" // window was displayed or not. Broadly this is done by error-checking the call to open it. Out of game // there is no CCPEVE javascript object, so any call to it will error out, but ingame it will work. $trustWnd = ($_POST["twnd"] == "true") ? true : false; if ($trustWnd) { // Trust window *should* be visible printf('
Good! We\'re nearly done..
'); printf('
'); printf('

Now we\'re getting somewhere. A dialog should have appeared ' . 'on-screen asking you to confirm the trust settings for this website...

'); printf('

Trust website window

'); printf('

Just click on TRUST WEBSITE and you\'re done!

'); printf('

Cmon! Do it! I\'m here c\'mon kill me! Do it now!

'); printf('
'); } else { // No trust window, we're out of game or something else went wrong. printf('
Something went wrong..
'); printf('
'); printf('

It seems like you\'re not in the game.

'); printf('

Trusting websites in Eve actually involves... being in Eve. I know it\'s a bit unorthodox but please try again when you\'re actually playing the game.

'); printf('

If you\'re seeing this message in-game then something else went wrong, and I look like a bit of a fool. Try refreshing the page and if it happens again let me know.

'); printf('

This window will automatically close in a few seconds.

'); printf('
'); } // ======================================================================== } elseif ($action == "getloc") { // ======================================================================== printf(isset($_SERVER["HTTP_EVE_SOLARSYSTEMNAME"]) ? $_SERVER["HTTP_EVE_SOLARSYSTEMNAME"] : ""); // ======================================================================== } elseif ($action == "locusov") { // ======================================================================== $n_LocusID = strtoupper(trim(mysql_real_escape_string($_REQUEST["lid"]))); $aTempWH = new Wormhole($n_LocusID); if ($aTempWH->isValidLocus()) { if ($aTempWH->isWHLocus()) { $whTxt = sprintf('
%s
is a
%s%s
system with ', $aTempWH->getSysName(), $aTempWH->getClassCSS(), $aTempWH->getClassDesc(), ($aTempWH->hasAnomaly() ? sprintf(' %s', $aTempWH->getAnomalyName()) : '')); $staticInfoSQL = sprintf("SELECT it.typeName, COALESCE(whClass.valueFloat,whClass.valueInt) AS wormholeType FROM ".EVEDB_NAME.".invTypes it " . "LEFT JOIN ".EVEDB_NAME.".dgmTypeAttributes whClass USING(typeID) " . "WHERE it.typeID IN (SELECT typeID FROM ".WHDB_NAME.".staticMap WHERE constellationID = '%d') " . "AND whClass.attributeID = 1381 " . "ORDER BY FIND_IN_SET(wormholeType,'7,8,9,1,2,3,4,5,6')", $aTempWH->getConstellationID()); $rsStatics = mysql_query_cache($staticInfoSQL,$whConn); $whStatic = array(); if (is_array($rsStatics)) { if (count($rsStatics) > 1) { for ($s = 0; $s < count($rsStatics); $s++) { $whStatic[] = sprintf('
%s
(%s)
', getClassCSS($rsStatics[$s]["wormholeType"]), preg_replace("/Wormhole /i","",$rsStatics[$s]["typeName"]), getClassCSS($rsStatics[$s]["wormholeType"]), getClassDesc($rsStatics[$s]["wormholeType"],true)); } $whTxt .= implode(", ",$whStatic) . sprintf(" static%s.", sizeof($whStatic) > 1 ? "s" : ""); unset($whStatic); } elseif (count($rsStatics) == 1) { $whTxt .= sprintf('
%s
(%s)
static.', getClassCSS($rsStatics[0]["wormholeType"]), preg_replace("/Wormhole /i","",$rsStatics[0]["typeName"]), getClassCSS($rsStatics[0]["wormholeType"]), getClassDesc($rsStatics[0]["wormholeType"],true)); } } } else { // Not a wormhole $whTxt = sprintf('
%s
is a
%s
system.', $aTempWH->getSysName(), $aTempWH->getClassCSS(), $aTempWH->getClassDesc()); } } else { // Not a valid locus $whTxt = sprintf('
%s
is not a valid locus ID.', $n_LocusID); } echo $whTxt; // ======================================================================== } elseif ($action == "getlocii") { // ======================================================================== // Handler for the jQuery UI autocomplete code $locusID = strtoupper(trim(mysql_real_escape_string(isset($_REQUEST["term"]) ? $_REQUEST["term"] : ''))); $lociiSQL = sprintf("SELECT solarSystemName FROM ".EVEDB_NAME.".mapSolarSystems WHERE UPPER(solarSystemName) LIKE UPPER('%s%%') ORDER BY solarSystemName", $locusID); $rsLocii = mysql_query_cache($lociiSQL, $whConn, MEMCACHE_STATICDATA_TIMEOUT, true); if (is_array($rsLocii)) { if (!empty($rsLocii)) { $locusIDs = array(); //while ($lRow = mysql_fetch_object($rsLocii)) { for ($l = 0; $l < count($rsLocii); $l++) { array_push($locusIDs, $rsLocii[$l]["solarSystemName"]); } echo json_encode($locusIDs); } } // ======================================================================== } elseif ($action == "dotlandata") { // ======================================================================== $n_LocusID = strtoupper(trim(mysql_real_escape_string($_REQUEST["lid"]))); $aTempWH = new Wormhole($n_LocusID); if ($aTempWH->isValidLocus()) { // Try and get Dotlan data from cache if it is available and fresh $haveCache = false; $cacheFile = sprintf("%s/%s_dotlan.dat", realpath(CACHE_DIRECTORY), str_replace(" ","_",strtoupper($n_LocusID))); if (is_readable($cacheFile)) { if ((strtotime("+".DOTLAN_CACHE_LIFETIME." seconds", filemtime($cacheFile)) - time()) > 0) { // Found a valid cache file $haveCache = true; $pageHTML = unserialize(gzinflate(file_get_contents($cacheFile))); } else { // Found a cache file, but it's too old - delete and recreate it unlink($cacheFile); $haveCache = false; } } if (!$haveCache) { $dotlanURL = "http://evemaps.dotlan.net/system/" . str_replace(" ","_",strtoupper($n_LocusID)); try { $pageHTML = file_get_contents($dotlanURL); } catch (Exception $e) { printf('
Dotlan

Unable to gather Dotlan data at this time - error returned was: %s', $n_LocusID, $n_LocusID, str_replace("_"," ",$n_LocusID), $e->getMessage()); exit(1); } file_put_contents($cacheFile, gzdeflate(serialize($pageHTML))); } if ($pageHTML) { $dom = new DOMDocument(); $dom->preserveWhiteSpace = false; libxml_use_internal_errors(true); $dom->loadHTML($pageHTML); // First, get the jumps in last hour/24 hours $dlData = array('JumpGraphSrc' => '', 'NPCKillsGraphSrc' => '', 'ShipKillsGraphSrc' => '', 'PodKillsGraphSrc' => '', 'Jumps_1hr' => -1, 'Jumps_24hr' => -1, 'ShipKills_1hr' => -1, 'ShipKills_24hr' => -1, 'NPCKills_1hr' => -1, 'NPCKills_24hr' => -1, 'PodKills_1hr' => -1, 'PodKills_24hr' => -1); $nodes = $dom->getElementsByTagName('td'); for ($i = 0; $i < $nodes->length; $i++) { $td = $nodes->item($i); if (stristr($td->nodeValue,"Jumps 1h/24h")) { // Node - Jumps 1h/24h $dlDataAry["Jumps_1hr"] = is_numeric($nodes->item($i+1)->nodeValue) ? (int)$nodes->item($i+1)->nodeValue : -1; $dlDataAry["Jumps_24hr"] = is_numeric($nodes->item($i+2)->nodeValue) ? (int)$nodes->item($i+2)->nodeValue : -1; } elseif (stristr($td->nodeValue,"Ship Kills")) { // Node - Ship Kills 1h/24h $dlDataAry["ShipKills_1hr"] = is_numeric($nodes->item($i+1)->nodeValue) ? (int)$nodes->item($i+1)->nodeValue : -1; $dlDataAry["ShipKills_24hr"] = is_numeric($nodes->item($i+2)->nodeValue) ? (int)$nodes->item($i+2)->nodeValue : -1; } elseif (stristr($td->nodeValue,"NPC Kills")) { // Node - NPC Kills 1h/24h $dlDataAry["NPCKills_1hr"] = is_numeric($nodes->item($i+1)->nodeValue) ? (int)$nodes->item($i+1)->nodeValue : -1; $dlDataAry["NPCKills_24hr"] = is_numeric($nodes->item($i+2)->nodeValue) ? (int)$nodes->item($i+2)->nodeValue : -1; } elseif (stristr($td->nodeValue,"Pod Kills")) { // Node - Pod Kills 1h/24h $dlDataAry["PodKills_1hr"] = is_numeric($nodes->item($i+1)->nodeValue) ? (int)$nodes->item($i+1)->nodeValue : -1; $dlDataAry["PodKills_24hr"] = is_numeric($nodes->item($i+2)->nodeValue) ? (int)$nodes->item($i+2)->nodeValue : -1; } } $nodes = $dom->getElementsByTagName('img'); foreach ($nodes as $img) { if (stristr($img->getAttribute('src'),"chart.googleapis.com")) { if (stristr($img->getAttribute('alt'),"Jumps")) { $dlGraphSrc = $img->getAttribute('src'); $dlGraphSrc = str_ireplace('D5DF3D','CC9966',$dlGraphSrc); $dlGraphSrc = str_ireplace('chs=230x160','chs='.EVEMAPS_GRAPH_WIDTH.'x'.EVEMAPS_GRAPH_HEIGHT,$dlGraphSrc); $dlGraphSrc .= "&chxs=1,c2c2c2,10|0,c2c2c2,10"; $dlDataAry["JumpGraphSrc"] = $dlGraphSrc; //printf('

', $dlDataAry["JumpGraphSrc"], 240, 160); } elseif (stristr($img->getAttribute('alt'),"NPC Kills")) { // Note: The Jumps graph is the only one we actually display, the others we store in // a single graph which is displayed by another function. This is a little sloppy but // it preserves the layout of the page. $dlGraphSrc = $img->getAttribute('src'); $dlGraphSrc = str_ireplace('D5DF3D','82f882',$dlGraphSrc); $dlGraphSrc = str_ireplace('chs=230x160','chs='.EVEMAPS_GRAPH_WIDTH.'x'.EVEMAPS_GRAPH_HEIGHT,$dlGraphSrc); $dlGraphSrc .= "&chxs=1,c2c2c2,10|0,c2c2c2,10"; $dlDataAry["NPCKillsGraphSrc"] = $dlGraphSrc; } elseif (stristr($img->getAttribute('alt'),"Ship Kills")) { // Note: The Jumps graph is the only one we actually display, the others we store in // a single graph which is displayed by another function. This is a little sloppy but // it preserves the layout of the page. $dlGraphSrc = $img->getAttribute('src'); $dlGraphSrc = str_ireplace('D5DF3D','82f7f8',$dlGraphSrc); $dlGraphSrc = str_ireplace('chs=230x160','chs='.EVEMAPS_GRAPH_WIDTH.'x'.EVEMAPS_GRAPH_HEIGHT,$dlGraphSrc); $dlGraphSrc .= "&chxs=1,c2c2c2,10|0,c2c2c2,10"; $dlDataAry["ShipKillsGraphSrc"] = $dlGraphSrc; } elseif (stristr($img->getAttribute('alt'),"Pod Kills")) { // Note: The Jumps graph is the only one we actually display, the others we store in // a single graph which is displayed by another function. This is a little sloppy but // it preserves the layout of the page. $dlGraphSrc = $img->getAttribute('src'); $dlGraphSrc = str_ireplace('D5DF3D','dd60e8',$dlGraphSrc); $dlGraphSrc = str_ireplace('chs=230x160','chs='.EVEMAPS_GRAPH_WIDTH.'x'.EVEMAPS_GRAPH_HEIGHT,$dlGraphSrc); $dlGraphSrc .= "&chxs=1,c2c2c2,10|0,c2c2c2,10"; $dlDataAry["PodKillsGraphSrc"] = $dlGraphSrc; } } } printf('
Dotlan

', $n_LocusID, $n_LocusID, str_replace("_"," ",$n_LocusID)); if (!$aTempWH->isWHLocus()) { // only show jumps for non-wormholes - CCP removed jumps from WH systems printf('Jumps: %d / %d', urlencode($dlDataAry["JumpGraphSrc"]), $dlDataAry["Jumps_1hr"], $dlDataAry["Jumps_24hr"]); } printf('NPC Kills: %d / %dShip Kills: %d / %dPod Kills: %d / %d(last 1 / 24 hours)', urlencode($dlDataAry["NPCKillsGraphSrc"]), ($dlDataAry["NPCKills_1hr"] > 0) ? ' dlB dlAtv' : '', $dlDataAry["NPCKills_1hr"], $dlDataAry["NPCKills_24hr"], urlencode($dlDataAry["ShipKillsGraphSrc"]), ($dlDataAry["ShipKills_1hr"] > 0) ? ' dlB dlAtv' : '', $dlDataAry["ShipKills_1hr"], $dlDataAry["ShipKills_24hr"], urlencode($dlDataAry["PodKillsGraphSrc"]), ($dlDataAry["PodKills_1hr"] > 0) ? ' dlB' : '', $dlDataAry["PodKills_1hr"], $dlDataAry["PodKills_24hr"]); printf('

'); } } // ======================================================================== } elseif ($action == "intel_staticinfo") { // ======================================================================== // Get static info $staticType = strtoupper(trim(mysql_real_escape_string($_REQUEST["s"]))); $staticInfoSQL = sprintf("SELECT it.typeName, COALESCE(whClass.valueFloat,whClass.valueInt) AS wormholeType, COALESCE(whStableTime.valueFloat,whStableTime.valueInt) AS maxStableTime, COALESCE(whStableMass.valueFloat,whStableMass.valueInt) AS maxStableMass, COALESCE(whMassRegen.valueFloat,whMassRegen.valueInt) AS massRegeneration, COALESCE(whJumpMass.valueFloat,whJumpMass.valueInt) AS maxJumpMass, sm.sigSize AS signatureSize " . "FROM ".EVEDB_NAME.".invTypes it " . "LEFT JOIN ".EVEDB_NAME.".dgmTypeAttributes whClass USING(typeID) " . "LEFT JOIN ".EVEDB_NAME.".dgmTypeAttributes whStableTime USING(typeID) " . "LEFT JOIN ".EVEDB_NAME.".dgmTypeAttributes whStableMass USING(typeID) " . "LEFT JOIN ".EVEDB_NAME.".dgmTypeAttributes whMassRegen USING(typeID) " . "LEFT JOIN ".EVEDB_NAME.".dgmTypeAttributes whJumpMass USING(typeID) " . "LEFT JOIN ".WHDB_NAME.".sigDataMap sm USING(typeID) " . "WHERE UPPER(it.typeName) LIKE '%%%s' " . "AND whClass.attributeID = 1381 " . "AND whStableTime.attributeID = 1382 " . "AND whStableMass.attributeID = 1383 " . "AND whMassRegen.attributeID = 1384 " . "AND whJumpMass.attributeID = 1385 " . "ORDER BY FIND_IN_SET(wormholeType,'7,8,9,1,2,3,4,5,6')", $staticType); //printf("

%s

", $staticInfoSQL); $rsStaticInfo = mysql_query_cache($staticInfoSQL,$whConn); if (!empty($rsStaticInfo)) { printf('' . '' . '' . '' . '' . '' . '
Lifetime:%s hours
Max. stable mass:%s kg (%s b)
Mass variance (±10%%):%s kg
Max. jump mass:%s kg
Signature size:%s
', number_format($rsStaticInfo[0]["maxStableTime"]/60,0), number_format($rsStaticInfo[0]["maxStableMass"],0,'.',','), number_format($rsStaticInfo[0]["maxStableMass"]/1000/1000/1000,1,'.',','), number_format($rsStaticInfo[0]["maxStableMass"]*0.1,0,'.',','), number_format($rsStaticInfo[0]["maxJumpMass"],0,'.',','), is_null($rsStaticInfo[0]["signatureSize"]) ? "?" : $rsStaticInfo[0]["signatureSize"]); } else { printf("Could not find information for wormhole type %s", $staticType); } // ======================================================================== } elseif ($action == "intel_whinfo") { // ======================================================================== $n_LocusID = str_replace("_"," ",strtoupper(trim(mysql_real_escape_string($_REQUEST["lid"])))); $aTempWH = new Wormhole($n_LocusID); if ($aTempWH->isValidLocus()) { printf('' . '' . '' . '
Region:%s
Constellation:%s
', $aTempWH->getRegion(), $aTempWH->getConstellation()); printf(''); printf(''); foreach ($aTempWH->cCelestial as $aCelestial) { if ($aCelestial->isPlanet()) { printf('', $aCelestial->Name(), $aCelestial->typeID(), $aCelestial->planetType(), $aCelestial->typeID()); $aMoons = $aTempWH->getCelestialChildren($aCelestial->itemID()); $moonCount = 0; foreach ($aMoons as $cCelestial) { $moonCount += ($cCelestial->isMoon()) ? 1 : 0; } printf('',$moonCount); printf(''); } } printf('', $aTempWH->getPlanetCount(), $aTempWH->getMoonCount()); printf('
PlanetTypeMoons
%s%s%d
%d%d
'); } else { printf("

%s is not a valid locus ID.

", $n_LocusID); } // ======================================================================== } elseif ($action == "intel_whanom") { // ======================================================================== $n_LocusID = strtoupper(trim(mysql_real_escape_string($_REQUEST["lid"]))); $aTempWH = new Wormhole($n_LocusID); if ($aTempWH->isValidLocus() && $aTempWH->hasAnomaly()) { // Technically we should check isWHLocus() here, but maybe CCP will make non-wormholes have anoms? $anomalySQL = sprintf("SELECT dgmTypeAttributes.*, dgmAttributeTypes.attributeName, dgmAttributeTypes.displayName " . "FROM ".EVEDB_NAME.".dgmTypeAttributes INNER JOIN ".EVEDB_NAME.".dgmAttributeTypes USING(attributeID) " . "WHERE typeID = '%s'", $aTempWH->getAnomalyTypeID()); //print($anomalySQL); $rsAnomaly = mysql_query_cache($anomalySQL,$whConn); if (!empty($rsAnomaly)) { printf(''); printf(''); for ($a = 0; $a < count($rsAnomaly); $a++) { printf('', $rsAnomaly[$a]["displayName"], $aTempWH->getAnomEffect($rsAnomaly[$a]["attributeID"], $rsAnomaly[$a]["valueFloat"])); } printf('
EffectStrength
%s%s
'); } } // ======================================================================== } elseif ($action == "intel_dlgraph") { // ======================================================================== $n_GraphSrc = urldecode(trim($_REQUEST["gsrc"])); if (isset($n_GraphSrc)) { printf('
'); printf(' ', $n_GraphSrc, EVEMAPS_GRAPH_WIDTH, EVEMAPS_GRAPH_HEIGHT); printf('
'); } // ======================================================================== } elseif ($action == "intel_evekill_last") { // ======================================================================== $n_LocusID = strtoupper(trim(mysql_real_escape_string($_REQUEST["lid"]))); $aTempWH = new Wormhole($n_LocusID); if ($aTempWH->isValidLocus()) { $sDate = strtotime(sprintf("%d-%d-01", date("Y"), date("m"))); printf('
Eve-Kill
', $n_LocusID, str_replace("_"," ",$n_LocusID), str_replace("_"," ",$n_LocusID)); $aKillboard = new Killboard($n_LocusID, "lastkill", EVEKILL_CACHE_LIFETIME_LASTKILL, sprintf(EVEKILL_LASTKILL_URL, urlencode($n_LocusID), EVEKILL_EPIC_MASK, sprintf("%s_23.59.59", date("Y-m-t")), sprintf("%s_00.00.00", date("Y-m-d", $sDate))), CACHE_USE_CACHE_REFRESH_IF_EXPIRED, false); if ($aKillboard->isValidKB()) { $lastKill = $aKillboard->res_metrics["newestKill"]; if (!is_null($lastKill)) { printf('

Most recent kill recorded on %s%s (%s)%s lost a %s to %s (%s)%s in a %s%s.

', urldecode($lastKill->url), date("d M Y H:i", strtotime($lastKill->timestamp)), $lastKill->victimExternalID, $lastKill->victimName, $aKillboard->getEVEIDFromName($lastKill->victimCorpName, GET_CORPORATION_ID), $lastKill->victimCorpName, (strlen($lastKill->victimAllianceName) > 0 && $aKillboard->getEVEIDFromName($lastKill->victimAllianceName, GET_ALLIANCE_ID) != 0 && $aKillboard->getEVEIDFromName($lastKill->victimAllianceName, GET_ALLIANCE_ID) != NO_ALLIANCE_ALLIANCE_ID) ? sprintf(' [%s]', $aKillboard->getEVEIDFromName($lastKill->victimAllianceName, GET_ALLIANCE_ID), $lastKill->victimAllianceName) : "", $lastKill->victimShipName, $aKillboard->getEVEIDFromName($lastKill->FBPilotName, GET_CHARACTER_ID), $lastKill->FBPilotName, $aKillboard->getEVEIDFromName($lastKill->FBCorpName, GET_CORPORATION_ID), $lastKill->FBCorpName, (strlen($lastKill->FBAllianceName) > 0 && $aKillboard->getEVEIDFromName($lastKill->FBAllianceName, GET_ALLIANCE_ID) != 0 && $aKillboard->getEVEIDFromName($lastKill->FBAllianceName, GET_ALLIANCE_ID) != NO_ALLIANCE_ALLIANCE_ID) ? sprintf(' [%s]', $aKillboard->getEVEIDFromName($lastKill->FBAllianceName, GET_ALLIANCE_ID), $lastKill->FBAllianceName) : "", $aKillboard->getDBNameFromEVEID($lastKill->getFinalBlower()->shipTypeID), sizeof($lastKill->involved) > 1 ? sprintf(' and %d associate%s', $lastKill->internalID, sizeof($lastKill->involved)-1, sizeof($lastKill->involved)-1 > 1 ? "s" : "") : "" ); } else { // No kills found in the database (this should only occur when the killboard is empty) printf("

No kills recorded in this system in the past %d months.

", EVEKILL_ANALYSIS_MAX_MONTH_HISTORY); } } else { // Killboard was invalid, probably a problem querying evekill printf('

Unable to query Eve-Kill data at this time - please try again later.

'); } printf("
"); } // ======================================================================== } elseif ($action == "intel_evekill_analysis") { // ======================================================================== $n_LocusID = strtoupper(trim(mysql_real_escape_string($_REQUEST["lid"]))); $aTempWH = new Wormhole($n_LocusID); if ($aTempWH->isValidLocus()) { $sDate = strtotime(sprintf("%d-%d-01", date("Y"), date("m"))); printf('
Intel
', $n_LocusID); $aKillboard = new Killboard($n_LocusID, "analysis", EVEKILL_CACHE_LIFETIME_ANALYSIS, sprintf(EVEKILL_ANALYSIS_URL, urlencode($n_LocusID), EVEKILL_EPIC_MASK, EVEKILL_KILL_COUNT_FOR_INTEL, sprintf("%s_23.59.59", date("Y-m-t")), sprintf("%s_00.00.00", date("Y-m-d", $sDate))), CACHE_USE_CACHE_UPDATE_NEW_DATA, true); if ($aKillboard->isValidKB()) { if ($aTempWH->isWHLocus()) { if (false && ($_SERVER["REMOTE_ADDR"] == "94.169.97.53" || $_SERVER["REMOTE_ADDR"] = "80.45.72.211")) { printf('

DEBUG TABLE:
'); printf(''); foreach ($aKillboard->corp as $aCorp) { printf('', (!is_null($aCorp->residency["evicted"])) ? ' style="color: #FF3030;"' : ((sizeof($aCorp->residency["posactvy"]) > 0) ? ' style="color: #30FF30"' : ((sizeof($aCorp->residency["caplcuse"]) > 0) ? ' style="color: #FFFF30"' : "")), $aCorp->corporationName . " (" . $aCorp->corporationID . ")", $aCorp->allianceName . " (" . $aCorp->allianceID . ")", $aCorp->killCount, $aCorp->lossCount, sizeof($aCorp->battle), $aCorp->residency["score"], /* a */ ($aKillboard->totalAllianceResidencyScore($aCorp->allianceID) != 0) ? ($aCorp->residency["score"] / $aKillboard->totalAllianceResidencyScore($aCorp->allianceID)) * 100 : 0, /* t */ ($aKillboard->res_metrics["totalScore"] != 0) ? ($aCorp->residency["score"] / $aKillboard->res_metrics["totalScore"]) * 100 : 0, /* h */ ($aCorp->residency["score"] / $aKillboard->res_metrics["maxScore"]) * 100, /* as */($aKillboard->totalAllianceResidencyScore($aCorp->allianceID) != 0) ? ($aKillboard->totalAllianceResidencyScore($aCorp->allianceID) / $aKillboard->res_metrics["totalScore"]) * 100 : 0, /* p */ $aCorp->residency["z-perc"], !is_null($aCorp->timeEarliestKill) ? date("Y-m-d H:i:s", $aCorp->timeEarliestKill) : '-', !is_null($aCorp->timeLatestKill) ? date("Y-m-d H:i:s", $aCorp->timeLatestKill) : '-', !is_null($aCorp->timeEarliestLoss) ? date("Y-m-d H:i:s", $aCorp->timeEarliestLoss) : '-', !is_null($aCorp->timeLatestLoss) ? date("Y-m-d H:i:s", $aCorp->timeLatestLoss) : '-', $aCorp->involvedCount); } printf('
CORPALLIANCEKILLSLOSSESBATTLESSCOREtimeEarliestKilltimeLatestKilltimeEarliestLosstimeLatestLossinvolvedCount
%s%s%d%d%d%0.2f (a: %0.1f%%) (t: %0.1f%%) (h: %0.1f%%) (as: %0.1f%%) (p: %f%%)%s%s%s%s%d
'); printf('

'); } $aryResident = array(); $aryEvictee = array(); $residentCorps = array(); $residentCorpsInAlliance = 0; $occupiedAlliance = null; $tzArray = array(); $allianceOccupied = false; if ($aKillboard->corp[0]->residency["stddev"] >= SCORE_RES_STDDEV_TOO_LOW_THRESHOLD && $aKillboard->res_metrics["battleCount"] >= SCORE_BATTLE_COUNT_TOO_LOW_THRESHOLD) { dprintf('residency: std dev for system: %f (threshold: %f)', $aKillboard->corp[0]->residency["stddev"], SCORE_RES_STDDEV_TOO_LOW_THRESHOLD); foreach ($aKillboard->corp as $aCorp) { if (!$aCorp->isEvicted() && (sizeof($aCorp->battle) >= SCORE_MINIMUM_BATTLE_COUNT_FOR_RES && (($aCorp->residency["score"] / $aKillboard->res_metrics["maxScore"]) * 100) >= SCORE_RESIDENCY_THRESHOLD_PERC) || (($aKillboard->totalAllianceResidencyScore($aCorp->allianceID) != 0) ? ($aKillboard->totalAllianceResidencyScore($aCorp->allianceID) / $aKillboard->res_metrics["totalScore"]) * 100 : 0) >= SCORE_RES_ASSUME_ALLIANCE_OCCUPANCY) { $aryResident[] = $aCorp; // The current corp is assumed to be a resident - their residency score as a // percentage of the total residency score is sufficiently high enough. // Check to see whether or not we should show the alliance, or the corp. // Sometimes an alliance will have a dominant presence in more than one corp if ($aCorp->allianceID == (!is_null($occupiedAlliance) ? $occupiedAlliance->allianceID : -1) || (($aKillboard->totalAllianceResidencyScore($aCorp->allianceID) != 0) ? ($aKillboard->totalAllianceResidencyScore($aCorp->allianceID) / $aKillboard->res_metrics["totalScore"]) * 100 : 0) >= SCORE_RES_ASSUME_ALLIANCE_OCCUPANCY && $aKillboard->getAllianceCorpCount($aCorp) > 1) { $allianceOccupied = true; $residentCorpsInAlliance++; $occupiedAlliance = $aCorp; $residentCorps[] = sprintf('%s%s', $aCorp->corporationID, $aCorp->corporationName, (!$aCorp->isEvicted() ? sprintf(' (%s%0.1f%%)', (sizeof($residentCorps) == 0) ? "confidence: " : "", $aCorp->residency["z-perc"]) : '')); } else { // Not alliance controlled, individual corps are active though $residentCorps[] = sprintf('%s%s (%d kills, %d losses in %d battles)', $aCorp->corporationID, $aCorp->corporationName, ($aKillboard->isCorpInAlliance($aCorp) ? sprintf(' [%s]', $aCorp->allianceID, $aCorp->allianceName) : ''), $aCorp->killCount, $aCorp->lossCount, sizeof($aCorp->battle)); } } } if (sizeof($aryResident) > 0) { printf('

%s%s by ', ICON_RESIDENT_IMAGE, ((($aKillboard->res_metrics["totalScore"] != 0) ? ($aKillboard->res_metrics["topCorp"]->residency["score"] / $aKillboard->res_metrics["totalScore"]) * 100 : 0) >= SCORE_CERTIFIED_RESIDENCY_PERC) || ((($aKillboard->totalAllianceResidencyScore($aKillboard->res_metrics["topCorp"]->allianceID) != 0) ? ($aKillboard->totalAllianceResidencyScore($aKillboard->res_metrics["topCorp"]->allianceID) / $aKillboard->res_metrics["totalScore"]) * 100 : 0) >= SCORE_RES_ASSUME_ALLIANCE_OCCUPANCY) ? "Occupied" : "Probably occupied"); // ============================================================================== if ($allianceOccupied && $residentCorpsInAlliance > 1) { // ============================================================================== printf('the %s alliance
%s

', $occupiedAlliance->allianceID, $occupiedAlliance->allianceName, fimplode(', ',$residentCorps)); $topCorp = &$aKillboard->res_metrics["topCorp"]; if (!is_null($topCorp)) { // If top corp doesn't have any kills, they won't have any involved information, so show an alternate loss printout instead if ($topCorp->killCount == 0) { printf('

%sMost active are %s, with %d losses over %d battles. ', ICON_ACTIVITY_IMAGE, $topCorp->corporationID, $topCorp->corporationName, $topCorp->lossCount, sizeof($topCorp->battle)); } else { printf('

%sMost active are %s, with %d kills and %d losses, involving an average of %d ship%s. ', ICON_ACTIVITY_IMAGE, $topCorp->corporationID, $topCorp->corporationName, $topCorp->killCount, $topCorp->lossCount, floor($topCorp->involvedCount/$topCorp->killCount), floor($topCorp->involvedCount/$topCorp->killCount) > 1 ? "s" : ""); } // Get the top corp in alliance ship types $topCorpShips = $topCorp->shipTypes; if (is_array($topCorpShips)) { arsort($topCorpShips, SORT_NUMERIC); // $bigKillShips contains a list of ship typeIDs together with the number of // times they were used. In order to get the total count of ship CLASSES we // have to build a convoluted SQL query using UNIONs in order to add a column // containing the counts-per-ship, and then aggregating them into a // total-per-class, which is what we display. $bigShipJoinSQL = "LEFT JOIN ("; foreach($topCorpShips as $sName => $sUses) { $bigShipJoinSQL .= sprintf("SELECT %d AS typeID, %d AS useCnt%s", $sName, $sUses, ($sName != end(array_keys($topCorpShips)) ? " UNION " : "")); } $bigShipJoinSQL .= ") sK USING(typeID)"; $shipClassSQL = sprintf("SELECT ig.groupName, SUM(sK.useCnt) AS timesUsed FROM ".EVEDB_NAME.".invTypes it LEFT JOIN ".EVEDB_NAME.".invGroups ig USING(groupID) %s WHERE (it.typeID IN (%s) AND NOT it.typeID = 0) AND ig.anchorable = 0 GROUP BY ig.groupName ORDER BY timesUsed DESC", $bigShipJoinSQL, implode(",",array_keys($topCorpShips))); $rsShipClass = mysql_query_cache($shipClassSQL); if (is_array($rsShipClass)) { if (!empty($rsShipClass)) { $classCnt = 1; $classCount = count($rsShipClass); //$bigKillShipID = key($topCorpShips); printf('Their favourite ship class%s %s %s (%0.1f%% of total)', ($classCount > 1 && EVEKILL_MAX_SHIP_CLASSES_TO_SHOW > 1 ? "es" : ""), ($classCount > 1 && EVEKILL_MAX_SHIP_CLASSES_TO_SHOW > 1 ? "include" : "is"), $rsShipClass[0]["groupName"], (($rsShipClass[0]["timesUsed"]/$classCount)*100)); if ($classCount > 1 && EVEKILL_MAX_SHIP_CLASSES_TO_SHOW > 1) { $clAry = array(); for ($s = 1; $s < count($rsShipClass) && ($classCnt++ < EVEKILL_MAX_SHIP_CLASSES_TO_SHOW); $s++) { $clAry[] = sprintf('%s (%0.1f%%)', $rsShipClass[$s]["groupName"], (($rsShipClass[$s]["timesUsed"]/$classCount)*100)); } printf(", %s. ", (isset($clAry) ? implode(", ",$clAry) : "")); } else { printf(". "); } } } } printf("

"); } // ============================================================================== } else { // ============================================================================== // Occupied by one or more corps that are distinct from a single alliance printf("
%s. ", fimplode(', ',$residentCorps)); // If we only have one resident, get their ships if (sizeof($residentCorps) == 1) { $topCorp = &$aKillboard->res_metrics["topCorp"]; if (!is_null($topCorp)) { $topCorpShips = $topCorp->shipTypes; if (is_array($topCorpShips) && $topCorp->killCount > 0) { arsort($topCorpShips, SORT_NUMERIC); // $bigKillShips contains a list of ship typeIDs together with the number of // times they were used. In order to get the total count of ship CLASSES we // have to build a convoluted SQL query using UNIONs in order to add a column // containing the counts-per-ship, and then aggregating them into a // total-per-class, which is what we display. $bigShipJoinSQL = "LEFT JOIN ("; foreach($topCorpShips as $sName => $sKills) { $bigShipJoinSQL .= sprintf("SELECT %d AS typeID, %d AS useCnt%s", $sName, $sKills, ($sName != end(array_keys($topCorpShips)) ? " UNION " : "")); } $bigShipJoinSQL .= ") sK USING(typeID)"; $shipClassSQL = sprintf("SELECT ig.groupName, SUM(sK.useCnt) AS timesUsed FROM ".EVEDB_NAME.".invTypes it LEFT JOIN ".EVEDB_NAME.".invGroups ig USING(groupID) %s WHERE (it.typeID IN (%s) AND NOT it.typeID = 0) AND ig.anchorable = 0 GROUP BY ig.groupName ORDER BY timesUsed DESC", $bigShipJoinSQL, implode(",",array_keys($topCorpShips))); $rsShipClass = mysql_query_cache($shipClassSQL); if (is_array($rsShipClass)) { if (!empty($rsShipClass)) { $classCnt = 1; $classCount = count($rsShipClass); //$bigKillShipID = key($topCorpShips); printf('Their favourite ship class%s %s %s (%0.1f%% of total)', ($classCount > 1 && EVEKILL_MAX_SHIP_CLASSES_TO_SHOW > 1 ? "es" : ""), ($classCount > 1 && EVEKILL_MAX_SHIP_CLASSES_TO_SHOW > 1 ? "include" : "is"), $rsShipClass[0]["groupName"], (($rsShipClass[0]["timesUsed"]/$classCount)*100)); if ($classCount > 1 && EVEKILL_MAX_SHIP_CLASSES_TO_SHOW > 1) { $clAry = array(); for ($s = 1; $s < count($rsShipClass) && ($classCnt++ < EVEKILL_MAX_SHIP_CLASSES_TO_SHOW); $s++) { $clAry[] = sprintf('%s (%0.1f%%)', $rsShipClass[$s]["groupName"], (($rsShipClass[$s]["timesUsed"]/$classCount)*100)); } printf(", %s. ", (isset($clAry) ? implode(", ",$clAry) : "")); } else { printf(". "); } } } } // Eviction/inactivity check if ($aTempWH->isWHLocus() && (strtotime("+".EVEKILL_EVICTION_INACTIVE_MONTHS." months", strtotime($topCorp->battle[0]->timestamp))) - time() < 0) { printf('
NOTE: Their last battle here was over %d months ago, on %s - possibly inactive or have moved out?', EVEKILL_EVICTION_INACTIVE_MONTHS, date("d M Y H:i", strtotime($topCorp->battle[0]->timestamp))); } } } printf('

'); // ============================================================================== } // ============================================================================== } $tzArray = $aKillboard->getTimezoneActivity($aryResident); $addTZ = array(); if (is_array($tzArray)) { $topTZ = current($tzArray); printf('

%s%s are most active in system during the %s timezone (EVE%s) with %0.2f%% of all activity. ', ICON_TIMEZONE_IMAGE, ($allianceOccupied || sizeof($aryResident) > 1) ? "Collectively they" : "They", $topTZ["name"], sprintf("%s%d", ($topTZ["shift"] >= 0 ? "+" : ""), $topTZ["shift"]), $topTZ["r-perc"]); foreach($tzArray as $aTimezone) { if ($aTimezone == $topTZ) continue; $addTZ[] = sprintf('%s - %0.2f%%', $aTimezone["name"], $aTimezone["r-perc"]); } printf("(%s).

", implode(", ",$addTZ)); } // Work out whether the top corp has used capital ships in this system $capKills = $aKillboard->getActivityInvolvingCaps(); if (sizeof($capKills) > 0) { // Itemise capital ships, and link to eve-kill $capStr = array(); $killDB = array(); $lastKillID = 0; $cpCnt = 0; $capUseCount = 0; foreach($capKills as $aCap) { if (!in_array(sprintf("%s%s", $aKillboard->getShipNameForTypeID($aCap["typeID"]), (!$aCap["isShip"]) ? " (delegated)" : ""), $capStr)) { $capStr[] = sprintf('%s%s', $aKillboard->getShipNameForTypeID($aCap["typeID"]), (!$aCap["isShip"]) ? " (delegated)" : ""); } if (!strcasecmp($aCap["kill"]->url, $lastKillID) == 0) { if (++$cpCnt <= SHOW_MAX_CAPITAL_KILLMAILS) { $killDB[] = sprintf('%d', $aCap["kill"]->url, $cpCnt); } // We keep a running update of the current kill ID so as not to duplicate // capital sightings $lastKillID = $aCap["kill"]->url; } } printf('

%sCapital ship%s (%s) %s been used in combat in this wormhole on %d occasion%s - %s%s

', ICON_CAPUSE_IMAGE, (sizeof($capStr) > 1) ? "s" : "", implode(', ',$capStr), (sizeof($capStr) > 1) ? "have" : "has", $cpCnt, ($cpCnt > 1) ? "s" : "", (($cpCnt > SHOW_MAX_CAPITAL_KILLMAILS) ? sprintf('last %d: ', SHOW_MAX_CAPITAL_KILLMAILS) : ''), implode(', ',$killDB)); } } else { // We have no residents, assume unoccupied dprintf('residency: std dev for system: %f (threshold: %f)', $aKillboard->corp[0]->residency["stddev"], SCORE_RES_STDDEV_TOO_LOW_THRESHOLD); printf('

%sSystem may be unoccupied or contested%d seperate corporations have had %d isolated battles over a period of %d days.

', ICON_VACATED_IMAGE, sizeof($aKillboard->corp), $aKillboard->res_metrics["battleCount"], ((strtotime($aKillboard->res_metrics["newestKill"]->timestamp) - strtotime($aKillboard->res_metrics["oldestKill"]->timestamp)) / 60 / 60 / 24)); } $evicteeDB = array(); // Show instances where a corp recovered from a POS loss foreach ($aKillboard->corp as $eCorp) { if ($eCorp->isNPCCorporation()) continue; // Max evicters to show, changes depending on how many POSes have been lost $evicterMaxCnt = (sizeof($eCorp->residency["evicted"]["losses"] > 1) ? EVEKILL_MAX_EVICTERS_FOR_MULTIPOS_LOSS : EVEKILL_MAX_EVICTERS_TO_REPORT); if (!is_null($eCorp->residency["evicted"]) && ($eCorp->residency["evicted"]["ppl_score"] >= SCORE_RES_STILL_RES_THRESHOLD_SCORE || strtotime("+".EVEKILL_RECENT_EVICTION_IN_DAYS." days", strtotime($eCorp->getNewestEvictionPOSKill()->timestamp)) - time() >= 0)) { $aryKillers = array(); $killDB = array(); $pkCnt = 0; // Corp suffered a POS loss, but they recovered foreach($eCorp->residency["evicted"]["losses"] as $aPOSKill) { $aryKillers = array_merge($aryKillers, $aKillboard->getInvolvedCorpsOnKill($aPOSKill)); } // Remove duplicate corps from combined evicter array //$aryKillers = $aKillboard->filterUniqueCorps($aryKillers); $aryKillers = $aKillboard->beautifyCorps($aryKillers); $aryKillAry = array(); if (sizeof($aryKillers) > 0) { foreach($aryKillers as $allianceID => $allyData) { $evtCnt = 0; if ($allianceID !== NO_ALLIANCE_ALLIANCE_ID) { if (sizeof($allyData["corps"]) == 1) { // Only one corp recorded in the alliance, so just show them normally $corpData = current($allyData["corps"]); $aryKillAry[] = sprintf('%s%s', $corpData["corporationID"], $corpData["corporationName"], sprintf(' [%s]', $allyData["allianceID"], $allyData["allianceName"])); } else { $corpKillAry = array(); foreach($allyData["corps"] as $corporationID => $corpData) { if (++$evtCnt > EVEKILL_MAX_EVICTERS_TO_REPORT) continue; $corpKillAry[] = sprintf('%s', $corpData["corporationID"], $corpData["corporationName"]); } $aryKillAry[] = sprintf('%s%s%s (%s%s)', substr_compare($allyData["allianceName"], "the", 0, 3, true) === 0 ? "" : "the ", $allyData["allianceID"], $allyData["allianceName"], substr_compare($allyData["allianceName"], "alliance", strlen($allyData["allianceName"])-8, 8, true) === 0 ? "" : " alliance", ($evtCnt <= EVEKILL_MAX_EVICTERS_TO_REPORT) ? fimplode(", ", $corpKillAry) : implode(", ", $corpKillAry), ($evtCnt > EVEKILL_MAX_EVICTERS_TO_REPORT) ? sprintf(" and %d other%s", ($evtCnt - EVEKILL_MAX_EVICTERS_TO_REPORT), ($evtCnt - EVEKILL_MAX_EVICTERS_TO_REPORT > 1 ? "s" : "")) : ""); } } else { // Individual unallied corps $corpKillAry = array(); foreach($allyData["corps"] as $corporationID => $corpData) { $aryKillAry[] = sprintf('%s', $corpData["corporationID"], $corpData["corporationName"]); } } } /*$aryKillAry = array(); if (sizeof($aryKillers) > 0) { $evtCnt = 0; foreach($aryKillers as $aKiller) { if (++$evtCnt <= $evicterMaxCnt && !in_array($aKiller->corporationName, $aryKillAry) && $eCorp !== $aKiller) { $aryKillAry[] = sprintf('%s%s', $aKiller->corporationID, $aKiller->corporationName, (strlen($aKiller->allianceName) > 0 && ($aKillboard->getEVEIDFromName($aKiller->allianceName, GET_ALLIANCE_ID) != 0 && $aKillboard->getEVEIDFromName($aKiller->allianceName, GET_ALLIANCE_ID) != NO_ALLIANCE_ALLIANCE_ID)) ? sprintf(' [%s]', $aKillboard->getEVEIDFromName($aKiller->allianceName, GET_ALLIANCE_ID), $aKiller->allianceName) : ""); } } */ $oldPOSKillDT = new DateTime($eCorp->getOldestEvictionPOSKill()->timestamp); $newPOSKillDT = new DateTime($eCorp->getNewestEvictionPOSKill()->timestamp); if ($eCorp->residency["evicted"]["ppl_score"] >= SCORE_RES_STILL_RES_THRESHOLD_SCORE) { // EVICTION RECOVERY printf('

%s%s %s — to %s%s - but they appear to have recovered.

', ICON_COMBAT_IMAGE, $eCorp->corporationName, (sizeof($eCorp->residency["evicted"]["losses"]) == 1) ? sprintf('lost a POS on %s', $eCorp->getOldestEvictionPOSKill()->url, date("d M Y H:i", strtotime($eCorp->getOldestEvictionPOSKill()->timestamp))) : sprintf('lost %d POS between %s and %s', sizeof($eCorp->residency["evicted"]["losses"]), date(($oldPOSKillDT->diff($newPOSKillDT)->days === 0 ? "d M Y H:i" : "d M Y"), strtotime($eCorp->getOldestEvictionPOSKill()->timestamp)), date(($oldPOSKillDT->diff($newPOSKillDT)->days === 0 ? "d M Y H:i" : "d M Y"), strtotime($eCorp->getNewestEvictionPOSKill()->timestamp))), ($evtCnt <= $evicterMaxCnt) ? fimplode(', ',$aryKillAry) : implode(', ',$aryKillAry), ($evtCnt > $evicterMaxCnt) ? sprintf(" and %d other%s ", ($evtCnt - $evicterMaxCnt), ($evtCnt - $evicterMaxCnt > 1 ? "s" : "")) : ""); } elseif (strtotime("+".EVEKILL_RECENT_EVICTION_IN_DAYS." days", strtotime($eCorp->getNewestEvictionPOSKill()->timestamp)) - time() >= 0) { // RECENT EVICTION printf('

%sRECENT EVICTION ACTIVITY%s%s %s — to %s%s.

', ICON_EVICTING_IMAGE, $eCorp->corporationID, $eCorp->corporationName, (strlen($eCorp->allianceName) > 0 && ($aKillboard->getEVEIDFromName($eCorp->allianceName, GET_ALLIANCE_ID) != 0 && $aKillboard->getEVEIDFromName($eCorp->allianceName, GET_ALLIANCE_ID) != NO_ALLIANCE_ALLIANCE_ID)) ? sprintf(' [%s]', $aKillboard->getEVEIDFromName($eCorp->allianceName, GET_ALLIANCE_ID), $eCorp->allianceName) : "", (sizeof($eCorp->residency["evicted"]["losses"]) == 1) ? sprintf('have lost a POS on %s', $eCorp->getOldestEvictionPOSKill()->url, date("d M Y H:i", strtotime($eCorp->getOldestEvictionPOSKill()->timestamp))) : sprintf('have lost %d POS between %s and %s', sizeof($eCorp->residency["evicted"]["losses"]), date(($oldPOSKillDT->diff($newPOSKillDT)->days === 0 ? "d M Y H:i" : "d M Y"), strtotime($eCorp->getOldestEvictionPOSKill()->timestamp)), date(($oldPOSKillDT->diff($newPOSKillDT)->days === 0 ? "d M Y H:i" : "d M Y"), strtotime($eCorp->getNewestEvictionPOSKill()->timestamp))), ($evtCnt <= $evicterMaxCnt) ? fimplode(', ',$aryKillAry) : implode(', ',$aryKillAry), ($evtCnt > $evicterMaxCnt) ? sprintf(" and %d other%s", ($evtCnt - $evicterMaxCnt), ($evtCnt - $evicterMaxCnt > 1 ? "s" : "")) : ""); } } } elseif ($eCorp->isEvicted()) ($evicteeDB[] = $eCorp); } if (sizeof($evicteeDB) > 0) { foreach($evicteeDB as $eCorp) { // Max evicters to show, changes depending on how many POSes have been lost $evicterMaxCnt = (sizeof($eCorp->residency["evicted"]["losses"] > 1) ? EVEKILL_MAX_EVICTERS_FOR_MULTIPOS_LOSS : EVEKILL_MAX_EVICTERS_TO_REPORT); $aryKillers = array(); $killDB = array(); $pkCnt = 0; // Corp suffered a POS loss, but they recovered foreach($eCorp->residency["evicted"]["losses"] as $aPOSKill) { $aryKillers = array_merge($aryKillers, $aKillboard->getInvolvedCorpsOnKill($aPOSKill)); } // Remove duplicate corps from combined evicter array //$aryKillers = $aKillboard->filterUniqueCorps($aryKillers); $aryKillers = $aKillboard->beautifyCorps($aryKillers); $aryKillAry = array(); if (sizeof($aryKillers) > 0) { foreach($aryKillers as $allianceID => $allyData) { $evtCnt = 0; if ($allianceID !== NO_ALLIANCE_ALLIANCE_ID) { if (sizeof($allyData["corps"]) == 1) { // Only one corp recorded in the alliance, so just show them normally $corpData = current($allyData["corps"]); $aryKillAry[] = sprintf('%s%s', $corpData["corporationID"], $corpData["corporationName"], sprintf(' [%s]', $allyData["allianceID"], $allyData["allianceName"])); } else { $corpKillAry = array(); foreach($allyData["corps"] as $corporationID => $corpData) { if (++$evtCnt > EVEKILL_MAX_EVICTERS_TO_REPORT) continue; $corpKillAry[] = sprintf('%s', $corpData["corporationID"], $corpData["corporationName"]); } $aryKillAry[] = sprintf('%s%s%s (%s%s)', substr_compare($allyData["allianceName"], "the", 0, 3, true) === 0 ? "" : "the ", $allyData["allianceID"], $allyData["allianceName"], substr_compare($allyData["allianceName"], "alliance", strlen($allyData["allianceName"])-8, 8, true) === 0 ? "" : " alliance", ($evtCnt <= EVEKILL_MAX_EVICTERS_TO_REPORT) ? fimplode(", ", $corpKillAry) : implode(", ", $corpKillAry), ($evtCnt > EVEKILL_MAX_EVICTERS_TO_REPORT) ? sprintf(" and %d other%s", ($evtCnt - EVEKILL_MAX_EVICTERS_TO_REPORT), ($evtCnt - EVEKILL_MAX_EVICTERS_TO_REPORT > 1 ? "s" : "")) : ""); } } else { // Individual unallied corps $corpKillAry = array(); foreach($allyData["corps"] as $corporationID => $corpData) { $aryKillAry[] = sprintf('%s', $corpData["corporationID"], $corpData["corporationName"]); } } } $aryEvictee[] = sprintf('%s%s%s', $eCorp->corporationID, $eCorp->corporationName, (strlen($eCorp->allianceName) > 0 && ($aKillboard->getEVEIDFromName($eCorp->allianceName, GET_ALLIANCE_ID) != 0 && $aKillboard->getEVEIDFromName($eCorp->allianceName, GET_ALLIANCE_ID) != NO_ALLIANCE_ALLIANCE_ID)) ? sprintf(' [%s]', $aKillboard->getEVEIDFromName($eCorp->allianceName, GET_ALLIANCE_ID), $eCorp->allianceName) : "", (sizeof($evicteeDB) == 1) ? sprintf(' – %s on %s, by %s%s', sprintf('evicted', $eCorp->getNewestEvictionPOSKill()->url), date("d M Y H:i", strtotime($eCorp->getNewestEvictionPOSKill()->timestamp)), ($evtCnt <= $evicterMaxCnt) ? fimplode(', ',$aryKillAry) : implode(', ',$aryKillAry), ($evtCnt > $evicterMaxCnt) ? sprintf(" and %d other%s ", ($evtCnt - $evicterMaxCnt), ($evtCnt - $evicterMaxCnt > 1 ? "s" : "")) : "") : sprintf(' – %s on %s', sprintf('evicted', $eCorp->getNewestEvictionPOSKill()->url), date("d M Y H:i", strtotime($eCorp->getNewestEvictionPOSKill()->timestamp)))); } /* $aryKillAry = array(); if (sizeof($aryKillers) > 0) { $evtCnt = 0; foreach($aryKillers as $aKiller) { if (++$evtCnt <= $evicterMaxCnt && !in_array($aKiller->corporationName, $aryKillAry) && $eCorp !== $aKiller) { $aryKillAry[] = sprintf('%s%s', $aKiller->corporationID, $aKiller->corporationName, (strlen($aKiller->allianceName) > 0 && ($aKillboard->getEVEIDFromName($aKiller->allianceName, GET_ALLIANCE_ID) != 0 && $aKillboard->getEVEIDFromName($aKiller->allianceName, GET_ALLIANCE_ID) != NO_ALLIANCE_ALLIANCE_ID)) ? sprintf(' [%s]', $aKillboard->getEVEIDFromName($aKiller->allianceName, GET_ALLIANCE_ID), $aKiller->allianceName) : ""); } } $aryEvictee[] = sprintf('%s%s%s', $eCorp->corporationID, $eCorp->corporationName, (strlen($eCorp->allianceName) > 0 && ($aKillboard->getEVEIDFromName($eCorp->allianceName, GET_ALLIANCE_ID) != 0 && $aKillboard->getEVEIDFromName($eCorp->allianceName, GET_ALLIANCE_ID) != NO_ALLIANCE_ALLIANCE_ID)) ? sprintf(' [%s]', $aKillboard->getEVEIDFromName($eCorp->allianceName, GET_ALLIANCE_ID), $eCorp->allianceName) : "", (sizeof($evicteeDB) == 1) ? sprintf(' (%s on %s, by %s%s)', sprintf('evicted', $eCorp->getNewestEvictionPOSKill()->url), date("d M Y H:i", strtotime($eCorp->getNewestEvictionPOSKill()->timestamp)), ($evtCnt <= $evicterMaxCnt) ? fimplode(', ',$aryKillAry) : implode(', ',$aryKillAry), ($evtCnt > $evicterMaxCnt) ? sprintf(" and %d other%s ", ($evtCnt - $evicterMaxCnt), ($evtCnt - $evicterMaxCnt > 1 ? "s" : "")) : "") : sprintf(' (%s on %s)', sprintf('evicted', $eCorp->getNewestEvictionPOSKill()->url), date("d M Y H:i", strtotime($eCorp->getNewestEvictionPOSKill()->timestamp)))); } */ } if (sizeof($aryEvictee) > 0) { printf('

%sPrevious residents include: %s

', ICON_EVICTED_IMAGE, fimplode(", ",$aryEvictee)); } } } else { // Not a wormhole locus, just show the most active corp // Re-order corp table by kills descending usort($aKillboard->corp, 'kcmp'); $topCorp = current($aKillboard->corp); if (is_object($topCorp)) { printf('

Most active are %s, with %d kills and %d losses, involving an average of %d ships. ', $topCorp->corporationID, $topCorp->corporationName, $topCorp->killCount, $topCorp->lossCount, floor($topCorp->involvedCount/$topCorp->killCount)); // Get the top corp in alliance ship types $topCorpShips = $topCorp->shipTypes; if (is_array($topCorpShips)) { arsort($topCorpShips, SORT_NUMERIC); // $bigKillShips contains a list of ship typeIDs together with the number of // times they were used. In order to get the total count of ship CLASSES we // have to build a convoluted SQL query using UNIONs in order to add a column // containing the counts-per-ship, and then aggregating them into a // total-per-class, which is what we display. $bigShipJoinSQL = "LEFT JOIN ("; foreach($topCorpShips as $sName => $sKills) { $bigShipJoinSQL .= sprintf("SELECT %d AS typeID, %d AS useCnt%s", $sName, $sKills, ($sName != end(array_keys($topCorpShips)) ? " UNION " : "")); } $bigShipJoinSQL .= ") sK USING(typeID)"; $shipClassSQL = sprintf("SELECT ig.groupName, SUM(sK.useCnt) AS timesUsed FROM ".EVEDB_NAME.".invTypes it LEFT JOIN ".EVEDB_NAME.".invGroups ig USING(groupID) %s WHERE (it.typeID IN (%s) AND NOT it.typeID = 0) AND ig.anchorable = 0 GROUP BY ig.groupName ORDER BY timesUsed DESC", $bigShipJoinSQL, implode(",",array_keys($topCorpShips))); $rsShipClass = mysql_query_cache($shipClassSQL); if (is_array($rsShipClass)) { if (!empty($rsShipClass)) { $classCnt = 1; $classCount = count($rsShipClass); //$bigKillShipID = key($topCorpShips); printf('Their favourite ship class%s %s %s (%0.1f%% of total)', ($classCount > 1 && EVEKILL_MAX_SHIP_CLASSES_TO_SHOW > 1 ? "es" : ""), ($classCount > 1 && EVEKILL_MAX_SHIP_CLASSES_TO_SHOW > 1 ? "include" : "is"), $rsShipClass[0]["groupName"], (($rsShipClass[0]["timesUsed"]/$classCount)*100)); if ($classCount > 1 && EVEKILL_MAX_SHIP_CLASSES_TO_SHOW > 1) { $clAry = array(); for ($s = 1; $s < count($rsShipClass) && ($classCnt++ < EVEKILL_MAX_SHIP_CLASSES_TO_SHOW); $s++) { $clAry[] = sprintf('%s (%0.1f%%)', $rsShipClass[$s]["groupName"], (($rsShipClass[$s]["timesUsed"]/$classCount)*100)); } printf(", %s. ", (isset($clAry) ? implode(", ",$clAry) : "")); } else { printf(". "); } } } } } else { // No top corp, so not enough data to do anything! printf("

No kills recorded in this system in the past %d months. No intel analysis is possible.

", EVEKILL_ANALYSIS_MAX_MONTH_HISTORY); } } } else { // Killboard was invalid, probably a problem querying evekill printf('

Unable to query Eve-Kill data at this time - please try again later.

'); } dprintf("intel_evekill_analysis - Finished."); printf("
"); } // ======================================================================== } elseif ($action == "intel_pilotinfo") { // ======================================================================== $n_PilotID = trim(mysql_real_escape_string($_REQUEST["id"])); $n_PilotName = urldecode(trim($_REQUEST["name"])); // Note: The double-DIV is required because the AJAX re-AJAXer won't get the "rel" otherwise printf('
'); printf('
', sprintf(EVE_API_PILOT_IMAGE_LOOKUP_URL, $n_PilotID, EVE_API_IMAGE_XY), EVE_API_IMAGE_XY, EVE_API_IMAGE_XY); printf('
'); printf('
%s
', $n_PilotName); printf('', $n_PilotID, $n_PilotID, $n_PilotID); printf('

Eve-Kill

', sprintf(EVEKILL_PILOT_URL, $n_PilotID), $n_PilotName); printf('

BattleClinic

', sprintf(BATTLECLINIC_PILOT_URL, str_replace(" ","+",$n_PilotName)), $n_PilotName); printf('

EveWho

', sprintf(EVEWHO_PILOT_URL, str_replace(" ","+",$n_PilotName)), $n_PilotName); printf('

Eve-Gate

', sprintf(EVEGATE_PILOT_URL, $n_PilotName), str_replace(" ","+",$n_PilotName)); printf('
'); printf('
'); // ======================================================================== } elseif ($action == "intel_corpinfo") { // ======================================================================== $n_CorpID = trim(mysql_real_escape_string($_REQUEST["id"])); $n_CorpName = urldecode(trim($_REQUEST["name"])); // Note: The double-DIV is required because the AJAX re-AJAXer won't get the "rel" otherwise printf('
'); printf('
', sprintf(EVE_API_CORP_IMAGE_LOOKUP_URL, $n_CorpID, EVE_API_IMAGE_XY), EVE_API_IMAGE_XY, EVE_API_IMAGE_XY); printf('
'); printf('
%s
', $n_CorpName); printf('', $n_CorpID, $n_CorpID, $n_CorpID); printf('

Eve-Kill

', sprintf(EVEKILL_CORP_URL, $n_CorpID), $n_CorpName); printf('

BattleClinic

', sprintf(BATTLECLINIC_CORP_URL, str_replace(" ","+",$n_CorpName)), $n_CorpName); printf('

EveWho

', sprintf(EVEWHO_CORP_URL, str_replace(" ","+",$n_CorpName)), $n_CorpName); printf('

Dotlan

', sprintf(DOTLAN_CORP_URL, str_replace(" ","_",$n_CorpName)), $n_CorpName); printf('
'); printf('
'); // ======================================================================== } elseif ($action == "intel_allianceinfo") { // ======================================================================== $n_AllianceID = trim(mysql_real_escape_string($_REQUEST["id"])); $n_AllianceName = urldecode(trim($_REQUEST["name"])); // Note: The double-DIV is required because the AJAX re-AJAXer won't get the "rel" otherwise printf('
'); printf('
', sprintf(EVE_API_ALLIANCE_IMAGE_LOOKUP_URL, $n_AllianceID, EVE_API_IMAGE_XY), EVE_API_IMAGE_XY, EVE_API_IMAGE_XY); printf('
'); printf('
%s
', $n_AllianceName); printf('', $n_AllianceID, $n_AllianceID, $n_AllianceID); printf('

Eve-Kill

', sprintf(EVEKILL_ALLIANCE_URL, $n_AllianceID), $n_AllianceName); printf('

BattleClinic

', sprintf(BATTLECLINIC_ALLIANCE_URL, str_replace(" ","+",$n_AllianceName)), $n_AllianceName); printf('

EveWho

', sprintf(EVEWHO_ALLIANCE_URL, str_replace(" ","+",$n_AllianceName)), $n_AllianceName); printf('

Dotlan

', sprintf(DOTLAN_ALLIANCE_URL, str_replace(" ","_",$n_AllianceName)), $n_AllianceName); printf('
'); printf('
'); // ======================================================================== } elseif ($action == "intel_iteminfo") { // ======================================================================== $n_ID = trim(mysql_real_escape_string($_REQUEST["id"])); printf('', sprintf(EVE_API_ITEM_IMAGE_LOOKUP_URL, $n_ID, EVE_API_IMAGE_XY), EVE_API_IMAGE_XY, EVE_API_IMAGE_XY); // ======================================================================== } elseif ($action == "get_image") { // ======================================================================== $n_ImageURL = trim(mysql_real_escape_string($_REQUEST["url"])); printf('', $n_ImageURL); // ======================================================================== } // ======================================================================== // This is used with the sort function to function kbcmp($a, $b) { return $b['killCount'] - $a['killCount']; } function lbcmp($a, $b) { return $b['lossCount'] - $a['lossCount']; } function getClassCSS($sysClass) { switch ($sysClass) { case 1: case 2: case 3: case 4: case 5: case 6: return sprintf("wSec_WH%d", $sysClass); case 7: return sprintf("wSec_H"); case 8: return sprintf("wSec_L"); case 9: return sprintf("wSec_N"); } } function getClassDesc($sysClass,$shortHand) { switch ($sysClass) { case 1: case 2: case 3: case 4: case 5: case 6: return sprintf((($shortHand) ? "C%d" : "Wormhole Class %d"), $sysClass); case 7: return sprintf(($shortHand) ? "Highsec" : "Highsec"); case 8: return sprintf(($shortHand) ? "Lowsec" : "Lowsec"); case 9: return sprintf(($shortHand) ? "Null" : "Nullsec"); } } // Close database connection(s) db_close(); ?>