예제 #1
0
                printf('<p>Most recent <a href="%s" target="_blank">kill</a> recorded on <span class="h5">%s</span><span class="h4">&ndash;</span><span class="h5"><a href="javascript:void(0)" class="em" rel="gPilot;%d" title="Victim info">%s</a></span> (<span class="h5"><a href="javascript:void(0)" rel="gCorp;%d" title="Corporation info">%s</a></span>)%s lost a <span class="h5">%s</span> to <span class="h5"><a href="javascript:void(0)" class="em" rel="gPilot;%d" title="Final blow info">%s</a></span> (<span class="h5"><a href="javascript:void(0)" rel="gCorp;%d" title="Corporation info">%s</a></span>)%s in a <span class="h5">%s</span>%s.</p>', 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(' [<span class="h5"><a href="javascript:void(0)" rel="gAlliance;%d" title="Alliance info">%s</a></span>]', $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(' [<span class="h5"><a href="javascript:void(0)" rel="gAlliance;%d" title="Alliance info">%s</a></span>]', $aKillboard->getEVEIDFromName($lastKill->FBAllianceName, GET_ALLIANCE_ID), $lastKill->FBAllianceName) : "", $aKillboard->getDBNameFromEVEID($lastKill->getFinalBlower()->shipTypeID), sizeof($lastKill->involved) > 1 ? sprintf(' and <a href="javascript:void(0)" rel="gKillers;%d" title="Killers info">%d associate%s</a>', $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("<p>No kills recorded in this system in the past %d months.</p>", EVEKILL_ANALYSIS_MAX_MONTH_HISTORY);
            }
        } else {
            // Killboard was invalid, probably a problem querying evekill
            printf('<p class="fatalerror">Unable to query Eve-Kill data at this time - please try again later.</p>');
        }
        printf("</div>");
    }
    // ========================================================================
} 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('<div class="iHdr" rel="%s">Intel</div><span class="h4">&mdash;</span><div class="iData">', $n_LocusID);
        $aKillboard = new Killboard($n_LocusID, "analysis", EVEKILL_CACHE_LIFETIME_ANALYSIS, sprintf(ZKB_ANALYSIS_URL, getSystemID(urlencode($n_LocusID)), EVEKILL_KILL_COUNT_FOR_INTEL, sprintf("%s2359", date("Ymd")), sprintf("%s0000", date("Ymd", $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('<p><span style="font-weight: bold; font-size: 14px;">DEBUG TABLE:</span><br/><table style="border-collapse: separate; border-spacing: 2px; font-size: 10px;">');
                    printf('<tr style="font-weight: bold;"><td>CORP</td><td>ALLIANCE</td><td>KILLS</td><td>LOSSES</td><td>BATTLES</td><td>SCORE</td><td>timeEarliestKill</td><td>timeLatestKill</td><td>timeEarliestLoss</td><td>timeLatestLoss</td><td>involvedCount</td></tr>');
                    foreach ($aKillboard->corp as $aCorp) {
                        printf('<tr%s><td><strong>%s</strong></td><td>%s</td><td>%d</td><td>%d</td><td>%d</td><td><strong>%0.2f</strong> (a: %0.1f%%) (t: %0.1f%%) (h: %0.1f%%) (as: %0.1f%%) (p: %f%%)</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%d</td></tr>', !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"], $aKillboard->totalAllianceResidencyScore($aCorp->allianceID) != 0 ? $aCorp->residency["score"] / $aKillboard->totalAllianceResidencyScore($aCorp->allianceID) * 100 : 0, $aKillboard->res_metrics["totalScore"] != 0 ? $aCorp->residency["score"] / $aKillboard->res_metrics["totalScore"] * 100 : 0, $aCorp->residency["score"] / $aKillboard->res_metrics["maxScore"] * 100, $aKillboard->totalAllianceResidencyScore($aCorp->allianceID) != 0 ? $aKillboard->totalAllianceResidencyScore($aCorp->allianceID) / $aKillboard->res_metrics["totalScore"] * 100 : 0, $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('</table>');
                    printf('</p>');
                }
예제 #2
0
 private function calcResidency()
 {
     $oldestKill = $this->res_metrics["oldestKill"];
     $latestKill = $this->res_metrics["newestKill"];
     $rsAry = array();
     if ($oldestKill && $latestKill && sizeof($this->corp) > 0) {
         $sysKillTimeSpan = strtotime($latestKill->timestamp) - strtotime($oldestKill->timestamp);
         // Create new wormhole object, for checking capital use in lower class
         $aTempWH = new Wormhole($this->uniqID);
         foreach ($this->corp as $aCorp) {
             // NPC corporations can't be resident (obviously Sleepers are :) )
             if ($aCorp->isNPCCorporation()) {
                 continue;
             }
             // Create/update alliance object
             if (!($aCorp->allianceID == 0 || $aCorp->allianceID == NO_ALLIANCE_ALLIANCE_ID)) {
                 if (is_null($aAlliance =& $this->getAllianceRM($aCorp->allianceName))) {
                     $this->res_metrics["alliance"][] = array("alliance_name" => &$aCorp->allianceName, "corp_count" => 1);
                 } else {
                     $aAlliance["corp_count"]++;
                 }
             }
             // Weigh each battle according to how long ago it occured
             $battleCount = 0;
             foreach ($aCorp->battle as $aBattle) {
                 //dprintf("[%s] battle time: %s, <i>it</i>: %d, <i>k</i>: %f, <i>t</i>: %d, <i>N<sub>0</sub></i>: %d, expo. decay: %f", $aCorp->corporationName, $aBattle->timestamp, $sysKillTimeSpan, SCORE_EXPONENTIAL_DECAY_RATE, (strtotime($latestKill->timestamp) - strtotime($aBattle->timestamp)), SCORE_MAX_SCORE_FOR_BATTLE, $this->ed($sysKillTimeSpan, SCORE_EXPONENTIAL_DECAY_RATE, (strtotime($latestKill->timestamp) - strtotime($aBattle->timestamp)), SCORE_MAX_SCORE_FOR_BATTLE));
                 $aCorp->residency["score"] += $this->ed($sysKillTimeSpan, SCORE_EXPONENTIAL_DECAY_RATE, strtotime($latestKill->timestamp) - strtotime($aBattle->timestamp), SCORE_MAX_SCORE_FOR_BATTLE + ++$battleCount * SCORE_MULTIPLE_BATTLE_INCREMENT);
             }
             // Add weight to residency score for kills where corp's POS was either a killer or a victim
             $posKills = $this->getPOSCombatActivity($aCorp);
             if (sizeof($posKills) > 0) {
                 foreach ($posKills as $aPOSKill) {
                     dprintf('[%s] POS was involved in a %s on %s - <a href="%s" target="_blank">here</a>', $aCorp->corporationName, $aPOSKill["isVictim"] == 1 ? "LOSS" : "KILL", $aPOSKill["kill"]->timestamp, $aPOSKill["kill"]->url);
                     $aCorp->residency["score"] += $this->ed($sysKillTimeSpan, SCORE_EXPONENTIAL_DECAY_RATE, strtotime($latestKill->timestamp) - strtotime($aPOSKill["kill"]->timestamp), SCORE_SKEW_POS_COMBAT_ACTIVITY);
                     $aCorp->residency["posactvy"][] = $aPOSKill;
                 }
             }
             // If wormhole is class 4 or lower, and this corp has used a capital, it's a good
             // assumption that they are or have been resident at some point.
             if ($aTempWH->isValidLocus() && $aTempWH->isWHLocus()) {
                 if ($aTempWH->getSysClass() <= 4) {
                     $capUsageDB = $this->getActivityInvolvingCaps($aCorp->corporationName, true);
                     if (sizeof($capUsageDB) > 0) {
                         dprintf("[%s] Corp has used a cap %d times in a <= C4 wormhole", $aCorp->corporationName, sizeof($capUsageDB));
                         foreach ($capUsageDB as $aKillWithCap) {
                             $aCorp->residency["score"] += $this->ed($sysKillTimeSpan, SCORE_EXPONENTIAL_DECAY_RATE, strtotime($latestKill->timestamp) - strtotime($aKillWithCap["kill"]->timestamp), SCORE_SKEW_CAPITAL_USE_IN_LOWCLASS_WH);
                             $aCorp->residency["caplcuse"][] = $aKillWithCap["kill"];
                         }
                     }
                 }
                 // Skew for InterBus Customs Office activity
                 $IBCOKillDB = $this->getInterBusCOKills($aCorp);
                 if (sizeof($IBCOKillDB) > 0) {
                     dprintf("[%s] Corp has killed %d InterBus C.Os in this system", $aCorp->corporationName, sizeof($IBCOKillDB));
                     foreach ($IBCOKillDB as $aIBCOKill) {
                         $aCorp->residency["score"] += $this->ed($sysKillTimeSpan, SCORE_EXPONENTIAL_DECAY_RATE, strtotime($latestKill->timestamp) - strtotime($aIBCOKill->timestamp), SCORE_SKEW_INTERBUS_CO_KILL);
                         $aCorp->residency["ibcokills"][] = $aIBCOKill;
                     }
                 }
             }
             // Check eviction status for each corp
             if (!is_null($aCorp->residency["evicted"] = $this->calcEviction($aCorp, EVEKILL_ANALYSIS_MAX_MONTH_HISTORY))) {
                 if ($aCorp->residency["evicted"]["ppl_score"] >= SCORE_RES_STILL_RES_THRESHOLD_SCORE) {
                     dprintf("[%s] Corp lost tower(s), but appeared to rally and remain resident? (still res weight: %f)", $aCorp->corporationName, $aCorp->residency["evicted"]["ppl_score"]);
                     // Include this corps score in array for stddev calc
                     $rsAry[] = $aCorp->residency["score"];
                 } else {
                     // If evicted zero score to eliminate them from standard deviation checks to allow us to find the current resident
                     dprintf("[%s] Corp is evicted. (%f)", $aCorp->corporationName, $aCorp->residency["evicted"]["ppl_score"]);
                     //$aCorp->residency["score"] = 0;
                 }
             } else {
                 // Include this corps score in array for stddev calc
                 $rsAry[] = $aCorp->residency["score"];
             }
         }
         // Populate total residency score metric in killboard
         $this->res_metrics["totalScore"] = $this->getTotalResidencyScore();
         // Calculate stddev, z-score and percentile
         $resStdDev = sd($rsAry);
         foreach ($this->corp as $aCorp) {
             $aCorp->residency["stddev"] = $resStdDev;
             $aCorp->residency["z-score"] = ($aCorp->residency["score"] - $this->res_metrics["totalScore"] / sizeof($this->corp)) / $aCorp->residency["stddev"];
             $aCorp->residency["z-perc"] = cdf($aCorp->residency["z-score"]) * 100;
         }
         // Sort the corp table by residency score descending order
         usort($this->corp, 'rcmp');
     }
 }