Exemplo n.º 1
0
 /**
  *
  * @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();
 }
Exemplo n.º 2
0
 /**
  * Add a new alliance to the database or update the details of an
  * existing alliance.
  *
  * @param string $name An alliance name for this object.
  * @param integer $externalid External ID if known.
  * @return type
  */
 static function add($name, $externalid = 0, $shortname = '', $executor_id = null, $member_count = 0, $start_date = null)
 {
     $qry = DBFactory::getDBQuery();
     $name = stripslashes($name);
     $qry->execute("select all_id, all_name, all_external_id" . " from kb3_alliances where all_name = '" . $qry->escape($name) . "'");
     if (!$qry->recordCount()) {
         $externalid = (int) $externalid;
         if (!$externalid && strcasecmp($name, 'None') != 0) {
             $myID = new API_NametoID();
             $myID->setNames($name);
             $myID->fetchXML();
             $myNames = $myID->getNameData();
             $externalid = (int) $myNames[0]['characterID'];
         }
         // If we have an external id then check it isn't already in use
         // If we find it then update the old alliance with the new name
         // then return.
         if ($externalid) {
             $qry->execute("SELECT * FROM kb3_alliances WHERE all_external_id = " . $externalid);
             if ($qry->recordCount() > 0) {
                 $row = $qry->getRow();
                 $qry->execute("UPDATE kb3_alliances SET all_name = '" . $qry->escape($name) . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tall_short_name = '" . $qry->escape($shortname) . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tall_executor_id = '" . $qry->escape($executor_id) . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tall_member_count = '" . $qry->escape($member_count) . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tall_start_date = '" . $qry->escape($start_date) . "'" . " WHERE all_external_id = " . $externalid);
                 $all = Cacheable::factory('Alliance', (int) $qry->getInsertID());
             } else {
                 $qry->execute("insert into kb3_alliances " . "(all_id, all_name, all_external_id) values " . "(null, '" . $qry->escape($name) . "', " . $externalid . ")");
             }
         } else {
             $qry->execute("insert into kb3_alliances " . "(all_id, all_name) values " . "(null, '" . $qry->escape($name) . "')");
         }
         $all = Alliance::getByID($qry->getInsertID());
         $all->name = $name;
         $all->externalid = (int) $externalid;
         $all->executed = true;
     } else {
         $row = $qry->getRow();
         $all = Alliance::getByID((int) $row['all_id']);
         $all->name = $row['all_name'];
         $all->externalid = (int) $row['all_external_id'];
         $all->executed = true;
     }
     return $all;
 }
Exemplo n.º 3
0
 public static function GenerateRow($pods = false, $header = true)
 {
     global $smarty;
     $klist = new KillList();
     $klist->setOrdered(true);
     $klist->setOrderBy("kll_isk_loss DESC");
     if ($pods == false) {
         $klist->setPodsNoobShips(false);
     } else {
         $klist->addVictimShipClass(2);
     }
     $klist->setLimit(self::NUM_DISPLAYED);
     if (isset($_GET["w"])) {
         self::$week = intval($_GET["w"]);
     }
     if (isset($_GET["m"])) {
         self::$month = intval($_GET["m"]);
     }
     if (isset($_GET["y"])) {
         self::$year = intval($_GET["y"]);
     }
     self::setTime(self::$week, self::$year, self::$month);
     $view = preg_replace('/[^a-zA-Z0-9_-]/', '', $_GET['view']);
     if (config::get('show_monthly')) {
         $start = makeStartDate(0, self::$year, self::$month);
         $end = makeEndDate(0, self::$year, self::$month);
         $klist->setStartDate(gmdate('Y-m-d H:i', $start));
         $klist->setEndDate(gmdate('Y-m-d H:i', $end));
         $smarty->assign("displaylist", date('F', mktime(0, 0, 0, self::$month, 1, self::$year)) . ", " . self::$year);
     } else {
         $klist->setWeek(self::$week);
         $klist->setYear(self::$year);
         $plist->setWeek(self::$week);
         $plist->setYear(self::$year);
         $smarty->assign("displaylist", "Week " . self::$week . ", " . self::$year);
     }
     if (config::get("exp_incloss")) {
         $smarty->assign("displaytype", "Kills and Losses");
         involved::load($klist, "combined");
     } else {
         $smarty->assign("displaytype", "Kills");
         involved::load($klist, "kill");
     }
     $kills = array();
     while ($kill = $klist->getKill()) {
         $kll = array();
         $plt = new Pilot($kill->getVictimID());
         if ($kill->isClassified() && !Session::isAdmin()) {
             $kll['systemsecurity'] = "-";
             $kll['system'] = Language::get("classified");
         } else {
             $kll['systemsecurity'] = $kill->getSolarSystemSecurity();
             $kll['system'] = $kill->getSolarSystemName();
         }
         $kll["id"] = $kill->getID();
         $kll["victim"] = $kill->getVictimName();
         $kll["victimid"] = $kill->getVictimID();
         $kll["victimship"] = $kill->getVictimShipName();
         $kll["victimshipid"] = $kill->getVictimShipExternalID();
         $kll["victimshipclass"] = $kill->getVictimShipClassName();
         $kll["victimcorp"] = $kill->getVictimCorpName();
         $kll["victimcorpid"] = $kill->getVictimCorpID();
         $alliance = Alliance::getByID($kill->getVictimAllianceID());
         if ($pods == false) {
             $kll["victimimageurl"] = $kill->getVictimShipImage(128);
         } else {
             $kll["victimimageurl"] = $plt->getPortraitURL(128);
         }
         $kll["victimallimage"] = $alliance->getPortraitURL(32);
         $kll["victimallname"] = $alliance->getName();
         if ((int) number_format($kill->getISKLoss(), 0, "", "") > 1000000000) {
             $kll["isklost"] = number_format($kill->getISKLoss() / 1000000000, 2, ".", "") . " Billion";
         } elseif ((int) number_format($kill->getISKLoss(), 0, "", "") > 1000000) {
             $kll["isklost"] = number_format($kill->getISKLoss() / 1000000, 2, ".", "") . " Million";
         } else {
             $kll["isklost"] = number_format($kill->getISKLoss(), 0, ".", ",");
         }
         if (config::get('cfg_allianceid') && in_array($kill->getVictimAllianceID(), config::get('cfg_allianceid'))) {
             $kll["class"] = "kl-loss";
             $kll["classlink"] = '<font color="#AA0000">&bull;</font>';
         } elseif (config::get('cfg_corpid') && in_array($kill->getVictimCorpID(), config::get('cfg_corpid'))) {
             $kll["class"] = "kl-loss";
             $kll["classlink"] = '<font color=\\"#AA0000\\">&bull;</font>';
         } elseif (config::get('cfg_pilotid') && in_array($kill->getVictimID(), config::get('cfg_pilotid'))) {
             $kll["class"] = "kl-loss";
             $kll["classlink"] = '<font color="#AA0000">&bull;</font>';
         } else {
             $kll["class"] = "kl-kill";
             $kll["classlink"] = '<font color="#00AA00">&bull;</font>';
         }
         $kills[] = $kll;
     }
     if ($header == true) {
         $smarty->assign("header", true);
     } else {
         $smarty->assign("header", false);
     }
     $smarty->assign("killlist", $kills);
     $smarty->assign("width", 100 / self::NUM_DISPLAYED);
     return $smarty->fetch(get_tpl('most_expensive_summary'));
 }
Exemplo n.º 4
0
    $id = (int) $row['sta_to'];
    if ($row['sta_value'] > 5) {
        $icon = 'high';
    } else {
        if ($row['sta_value'] > 0) {
            $icon = 'good';
        } else {
            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']) {
Exemplo n.º 5
0
 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']) . '&amp;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'];
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 6
0
 /**
  * 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");
 }
Exemplo n.º 7
0
if (config::get("cfg_corpid") || config::get("cfg_allianceid")) {
    $qry = DBFactory::getDBQuery();
    $ent = array();
    if (config::get("cfg_corpid")) {
        $ent[] = 'sta_from IN (' . join(',', config::get("cfg_corpid")) . ') AND sta_from_type=\'c\'';
    }
    if (config::get("cfg_allianceid")) {
        $ent[] = 'sta_from IN (' . join(',', config::get("cfg_allianceid")) . ') AND sta_from_type=\'a\'';
    }
    $qry->execute('SELECT * FROM kb3_standings WHERE (' . join(') OR (', $ent) . ') ORDER BY sta_value DESC');
    while ($row = $qry->getRow()) {
        $typ = $row['sta_to_type'];
        $val = sprintf("%01.1f", $row['sta_value']);
        $id = $typ . $row['sta_to'];
        if ($typ == 'a') {
            $alliance = Alliance::getByID($row['sta_to']);
            $text = $alliance->getName();
            $link = edkURI::page('admin_standings', $typ . $row['sta_to'], 'del');
            $permt[$typ][$row['sta_to']] = array('text' => $text, 'link' => $link, 'value' => $val, 'comment' => $row['sta_comment'], 'id' => $id);
        }
        if ($typ == 'c') {
            $corp = Corporation::getByID($row['sta_to']);
            $text = $corp->getName();
            $link = edkURI::page('admin_standings', $typ . $row['sta_to'], 'del');
            $permt[$typ][$row['sta_to']] = array('text' => $text, 'link' => $link, 'value' => $val, 'comment' => $row['sta_comment'], 'id' => $id);
        }
    }
}
$perm = array();
if ($permt['a']) {
    $perm[] = array('name' => 'Alliances', 'list' => $permt['a']);