Ejemplo n.º 1
0
/**
 * @package EDK
 */
define('MPATH', dirname(__FILE__) . "/");
$im = imagecreatefrompng(MPATH . 'default.png');
$red = imagecolorallocate($im, 255, 10, 10);
$orange = imagecolorallocate($im, 150, 120, 20);
$blue = imagecolorallocate($im, 0, 0, 200);
$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);
$grey_trans = imagecolorallocatealpha($im, 50, 50, 50, 50);
$greyred_trans = imagecolorallocatealpha($im, 50, 10, 10, 50);
$name = $pilot->getName();
$list = new KillList();
$list->setOrdered(true);
$list->setLimit(1);
$list->setPodsNoobships(false);
$list->addInvolvedPilot($pilot);
$kill = $list->getKill();
// corp
$box = imagettfbbox(10, 0, MPATH . 'GUNSHIP2.TTF', $corp->getName());
$width = $box[4];
imagettftext($im, 10, 0, 319 - $width, 71, $black, MPATH . 'GUNSHIP2.TTF', $corp->getName());
imagettftext($im, 10, 0, 318 - $width, 70, $red, MPATH . 'GUNSHIP2.TTF', $corp->getName());
// player
$box = imagettfbbox(16, 0, MPATH . 'GUNSHIP2.TTF', $name);
$width = $box[4];
imagettftext($im, 16, 0, 319 - $width, 91, $black, MPATH . 'GUNSHIP2.TTF', $name);
imagettftext($im, 16, 0, 318 - $width, 90, $red, MPATH . 'GUNSHIP2.TTF', $name);
// time, victim, victim corp and ship killed
Ejemplo n.º 2
0
 /**
  *  Build the killlists that are needed for the options selected.
  */
 function killList()
 {
     global $smarty;
     if (isset($this->viewList[$this->view])) {
         return call_user_func_array($this->viewList[$this->view], array(&$this));
     }
     $scl_id = (int) edkURI::getArg('scl_id');
     $klist = new KillList();
     $klist->setOrdered(true);
     if ($this->view == 'losses') {
         involved::load($klist, 'loss');
     } else {
         involved::load($klist, 'kill');
     }
     $klist->addSystem($this->system);
     if (config::get('kill_classified')) {
         $klist->setEndDate(gmdate('Y-m-d H:i', strtotime('now - ' . config::get('kill_classified') . ' hours')));
     }
     if ($scl_id) {
         $klist->addVictimShipClass(intval($scl_id));
     } else {
         $klist->setPodsNoobShips(config::get('podnoobs'));
     }
     if ($this->view == 'recent' || !$this->view) {
         $klist->setLimit(20);
         $smarty->assign('klheader', config::get('killcount') . ' most recent kills');
     } else {
         if ($this->view == 'losses') {
             $smarty->assign('klheader', 'All losses');
         } else {
             $smarty->assign('klheader', 'All kills');
         }
     }
     $klist->setPageSplit(config::get('killcount'));
     $pagesplitter = new PageSplitter($klist->getCount(), config::get('killcount'));
     $table = new KillListTable($klist);
     $smarty->assign('klsplit', $pagesplitter->generate());
     $smarty->assign('kltable', $table->generate());
     $html = $smarty->fetch(get_tpl('system_detail'));
     return $html;
 }
Ejemplo 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'));
 }
Ejemplo n.º 4
0
 /**
  *  Build the killlists that are needed for the options selected.
  */
 function killList()
 {
     global $smarty;
     if (isset($this->viewList[$this->view])) {
         return call_user_func_array($this->viewList[$this->view], array(&$this));
     }
     $scl_id = (int) edkURI::getArg('scl_id');
     switch ($this->view) {
         case "kills":
             $list = new KillList();
             $list->setOrdered(true);
             $list->addInvolvedPilot($this->pilot);
             if ($scl_id) {
                 $list->addVictimShipClass($scl_id);
             }
             $list->setPageSplit(config::get('killcount'));
             $pagesplitter = new PageSplitter($list->getCount(), config::get('killcount'));
             $table = new KillListTable($list);
             $smarty->assign('splitter', $pagesplitter->generate());
             $smarty->assign('kills', $table->generate());
             return $smarty->fetch(get_tpl('detail_kl_kills'));
             break;
         case "losses":
             $list = new KillList();
             $list->setOrdered(true);
             $list->addVictimPilot($this->pilot);
             if ($scl_id) {
                 $list->addVictimShipClass($scl_id);
             } else {
                 $list->setPodsNoobships(config::get('podnoobs'));
             }
             $list->setPageSplit(config::get('killcount'));
             $pagesplitter = new PageSplitter($list->getCount(), config::get('killcount'));
             $table = new KillListTable($list);
             $smarty->assign('splitter', $pagesplitter->generate());
             $smarty->assign('losses', $table->generate());
             return $smarty->fetch(get_tpl('detail_kl_losses'));
             break;
         case "ships_weapons":
             $shiplist = new TopList_Ship();
             $shiplist->addInvolvedPilot($this->pilot);
             $shiplisttable = new TopTable_Ship($shiplist);
             $smarty->assign('ships', $shiplisttable->generate());
             $weaponlist = new TopList_Weapon();
             $weaponlist->addInvolvedPilot($this->pilot);
             $weaponlisttable = new TopTable_Weapon($weaponlist);
             $smarty->assign('weapons', $weaponlisttable->generate());
             return $smarty->fetch(get_tpl('detail_kl_ships_weapons'));
             break;
         case 'history':
             $pltsum = new pilotSummary($this->plt_id);
             $smarty->assign('title', Language::get('history'));
             $smarty->assign('summary', $pltsum->getMonthlySummary());
             return $smarty->fetch(get_tpl('detail_history'));
             break;
         default:
             $list = new KillList();
             $list->setOrdered(true);
             if (config::get('comments_count')) {
                 $list->setCountComments(true);
             }
             if (config::get('killlist_involved')) {
                 $list->setCountInvolved(true);
             }
             $list->setLimit(10);
             $list->addInvolvedPilot($this->pilot);
             if ($scl_id) {
                 $list->addVictimShipClass($scl_id);
             } else {
                 $list->setPodsNoobships(config::get('podnoobs'));
             }
             $table = new KillListTable($list);
             $smarty->assign('kills', $table->generate());
             $list = new KillList();
             $list->setOrdered(true);
             if (config::get('comments_count')) {
                 $list->setCountComments(true);
             }
             if (config::get('killlist_involved')) {
                 $list->setCountInvolved(true);
             }
             $list->setLimit(10);
             $list->addVictimPilot($this->pilot);
             if ($scl_id) {
                 $list->addVictimShipClass($scl_id);
             } else {
                 $list->setPodsNoobships(config::get('podnoobs'));
             }
             $table = new KillListTable($list);
             $smarty->assign('losses', $table->generate());
             return $smarty->fetch(get_tpl('detail_kl_default'));
             break;
     }
     return $html;
 }
 function killList()
 {
     if (isset($this->viewList[$this->view])) {
         return call_user_func_array($this->viewList[$this->view], array(&$this));
     }
     global $smarty;
     $klist = new KillList();
     $klist->setOrdered(true);
     // We'll be needing comment counts so set the killlist to retrieve them
     if (config::get('comments_count')) {
         $klist->setCountComments(true);
     }
     // We'll be needing involved counts so set the killlist to retrieve them
     if (config::get('killlist_involved')) {
         $klist->setCountInvolved(true);
     }
     // Set time limit to 1 day.
     $klist->setStartDate($this->period . " 00:00");
     $klist->setEndDate($this->period . " 23:59");
     // Select between kills, losses or both.
     if ($this->view == 'combined' || $this->view == '' && $this->showcombined) {
         involved::load($klist, 'combined');
     } elseif ($this->view == 'losses') {
         involved::load($klist, 'loss');
     } else {
         involved::load($klist, 'kill');
     }
     if ($this->scl_id) {
         $klist->addVictimShipClass($this->scl_id);
     } else {
         $klist->setPodsNoobShips(config::get('podnoobs'));
     }
     $table = new KillListTable($klist);
     if ($this->showcombined) {
         $table->setCombined(true);
     }
     $html = $table->generate();
     return $html;
 }
Ejemplo n.º 6
0
 /**
  * Return the main killlists
  * @global Smarty $smarty
  * @return string HTML string for killlist tables
  */
 function killList()
 {
     if (isset($this->viewList[$this->view])) {
         return call_user_func_array($this->viewList[$this->view], array(&$this));
     }
     global $smarty;
     $klist = new KillList();
     $klist->setOrdered(true);
     // We'll be needing comment counts so set the killlist to retrieve them
     if (config::get('comments_count')) {
         $klist->setCountComments(true);
     }
     // We'll be needing involved counts so set the killlist to retrieve them
     if (config::get('killlist_involved')) {
         $klist->setCountInvolved(true);
     }
     // Select between kills, losses or both.
     if ($this->view == 'combined' || $this->view == '' && $this->showcombined) {
         involved::load($klist, 'combined');
     } else {
         if ($this->view == 'losses') {
             involved::load($klist, 'loss');
         } else {
             involved::load($klist, 'kill');
         }
     }
     if ($this->scl_id) {
         $klist->addVictimShipClass($this->scl_id);
     } else {
         $klist->setPodsNoobShips(config::get('podnoobs'));
     }
     // If no week is set then show the most recent kills. Otherwise
     // show all kills for the week using the page splitter.
     if (config::get("cfg_fillhome") && !$this->dateSet) {
         $klist->setLimit(config::get('killcount'));
         $table = new KillListTable($klist);
         if ($this->showcombined) {
             $table->setCombined(true);
         }
         $table->setLimit(config::get('killcount'));
         $html = $table->generate();
     } else {
         $this->loadTime($klist);
         //$klist->setWeek($this->week);
         //$klist->setYear($this->year);
         $klist->setPageSplit(config::get('killcount'));
         //$pagesplitter = new PageSplitter($klist->getCount(), config::get('killcount'));
         $table = new KillListTable($klist);
         if ($this->showcombined) {
             $table->setCombined(true);
         }
         //$pagesplit = $pagesplitter->generate();
         //$html = $pagesplit.$table->generate().$pagesplit;
         $html = $table->generate();
     }
     return $html;
 }
 public function __construct()
 {
     //get latest kill
     $kill_list = new KillList();
     $kill_list->setOrdered(true);
     $kill_list->setOrderBy('kll_timestamp DESC');
     $kill_list->setLimit(1);
     $kill_list->setPodsNoobShips(Config::get('podnoobs'));
     involved::load($kill_list);
     $this->kill = $kill_list->getKill();
     //are we replacing the kb banner?
     $bannerreplace = Config::get('mod_bannerpic_bannerreplace');
     if ($bannerreplace == 1) {
         Config::set('style_banner', 'bannerpic.jpg');
     }
     //if this is already cached we don't need to go any further..
     if (Config::get('mod_bannerpic_nocache') == 1) {
         $this->nocache = true;
     }
     $this->cache = KB_CACHEDIR . '/data/bannerpic' . $this->kill->getID() . '.jpg';
     $basepic = Config::get('mod_bannerpic_basepic');
     if (file_exists($basepic)) {
         $this->basepic = $basepic;
     }
     if (file_exists($this->cache) && !$this->nocache) {
         $this->img = imagecreatefromjpeg($this->cache);
         if ($bannerreplace == 1) {
             imagejpeg($this->img, 'banner/bannerpic.jpg', 100);
         }
         return;
     }
     //no kills?
     if ($this->kill === null) {
         $killstr = "No kills yet - how sad!";
         imagefttext($this->img, $this->lfont, 0, 20, 30, $red, $this->font, $killstr);
         imagejpeg($this->img);
         imagedestroy($this->img);
         return;
     }
     //killer
     $killername = $this->kill->getFBPilotName();
     //get victim info
     $victimid = $this->kill->getVictimExternalID();
     $victimname = $this->kill->getVictimName();
     $victimcorp = $this->kill->getVictimCorpName();
     $victimalli = $this->kill->getVictimAllianceName();
     //get the 64 x 64 victim portrait;
     $victimgfile = KB_HOST . '/?a=thumb&id=' . $victimid . '&size=64';
     $victimimg = imagecreatefromjpeg($victimgfile);
     $victimshipname = $this->kill->getVictimShipName();
     $url = KB_HOST . '/?a=thumb&id=' . $this->kill->getVictimShipExternalID() . '&size=64';
     $victimshipimg = imagecreatefromjpeg($url);
     //set variables for positions
     //Config::get('mod_bannerpic_basepic') == null ? Config::set('mod_bannerpic_basepic', $this->basepic) : $this->basepic = Config::get('mod_bannerpic_basepic');
     //victim picture
     $vicpicLeft = 1;
     Config::get('mod_bannerpic_vicpicleft') == null ? Config::set('mod_bannerpic_vicpicleft', $vicpicLeft) : ($vicpicLeft = Config::get('mod_bannerpic_vicpicleft'));
     $vicpicTop = 1;
     Config::get('mod_bannerpic_vicpictop') == null ? Config::set('mod_bannerpic_vicpictop', $vicpicTop) : ($vicpicTop = Config::get('mod_bannerpic_vicpictop'));
     $vicpicTrans = 100;
     Config::get('mod_bannerpic_vicpictrans') == null ? Config::set('mod_bannerpic_vicpictrans', $vicpicTrans) : ($vicpicTrans = Config::get('mod_bannerpic_vicpictrans'));
     //ship picture
     $shippicLeft = 70;
     Config::get('mod_bannerpic_shippicleft') == null ? Config::set('mod_bannerpic_shippicleft', $shippicLeft) : ($shippicLeft = Config::get('mod_bannerpic_shippicleft'));
     $shippicTop = 1;
     Config::get('mod_bannerpic_shippictop') == null ? Config::set('mod_bannerpic_shippictop', $shippicTop) : ($shippicTop = Config::get('mod_bannerpic_shippictop'));
     $shippicTrans = 100;
     Config::get('mod_bannerpic_shippictrans') == null ? Config::set('mod_bannerpic_shippictrans', $shippicTrans) : ($shippicTrans = Config::get('mod_bannerpic_shippictrans'));
     //killer
     $killstrLeft = 145;
     Config::get('mod_bannerpic_killstrleft') == null ? Config::set('mod_bannerpic_killstrleft', $killstrLeft) : ($killstrLeft = Config::get('mod_bannerpic_killstrleft'));
     $killstrTop = 15;
     Config::get('mod_bannerpic_killstrtop') == null ? Config::set('mod_bannerpic_killstrtop', $killstrTop) : ($killstrTop = Config::get('mod_bannerpic_killstrtop'));
     //victim corp
     $corpstrLeft = 145;
     Config::get('mod_bannerpic_corpstrleft') == null ? Config::set('mod_bannerpic_corpstrleft', $corpstrLeft) : ($corpstrLeft = Config::get('mod_bannerpic_corpstrleft'));
     $corpstrTop = 30;
     Config::get('mod_bannerpic_corpstrtop') == null ? Config::set('mod_bannerpic_corpstrtop', $corpstrTop) : ($corpstrTop = Config::get('mod_bannerpic_corpstrtop'));
     //victim alliance
     $allistrLeft = 145;
     Config::get('mod_bannerpic_allistrleft') == null ? Config::set('mod_bannerpic_allistrleft', $allistrLeft) : ($allistrLeft = Config::get('mod_bannerpic_allistrleft'));
     $allistrTop = 45;
     Config::get('mod_bannerpic_allistrtop') == null ? Config::set('mod_bannerpic_allistrtop', $allistrTop) : ($allistrTop = Config::get('mod_bannerpic_allistrtop'));
     //victim ship name
     $shipstrLeft = 145;
     Config::get('mod_bannerpic_shipstrleft') == null ? Config::set('mod_bannerpic_shipstrleft', $shipstrLeft) : ($shipstrLeft = Config::get('mod_bannerpic_shipstrleft'));
     $shipstrTop = 60;
     Config::get('mod_bannerpic_shipstrtop') == null ? Config::set('mod_bannerpic_shipstrtop', $shipstrTop) : ($shipstrTop = Config::get('mod_bannerpic_shipstrtop'));
     //border box colours
     $boxr = 186;
     Config::get('mod_bannerpic_boxr') == null ? Config::set('mod_bannerpic_boxr', $boxr) : ($boxr = Config::get('mod_bannerpic_boxr'));
     $boxg = 185;
     Config::get('mod_bannerpic_boxg') == null ? Config::set('mod_bannerpic_boxg', $boxg) : ($boxg = Config::get('mod_bannerpic_boxg'));
     $boxb = 183;
     Config::get('mod_bannerpic_boxb') == null ? Config::set('mod_bannerpic_boxb', $boxb) : ($boxb = Config::get('mod_bannerpic_boxb'));
     //text colours
     $textr = 255;
     Config::get('mod_bannerpic_textr') == null ? Config::set('mod_bannerpic_textr', $textr) : ($textr = Config::get('mod_bannerpic_textr'));
     $textg = 255;
     Config::get('mod_bannerpic_textg') == null ? Config::set('mod_bannerpic_textg', $textg) : ($textg = Config::get('mod_bannerpic_textg'));
     $textb = 255;
     Config::get('mod_bannerpic_textb') == null ? Config::set('mod_bannerpic_textb', $textb) : ($textb = Config::get('mod_bannerpic_textb'));
     //font
     Config::get('mod_bannerpic_fontfile') == null ? Config::set('mod_bannerpic_fontfile', $this->font) : ($this->font = Config::get('mod_bannerpic_fontfile'));
     Config::get('mod_bannerpic_fontfile') == null ? Config::set('mod_bannerpic_fontfilesize', $this->sfont) : ($this->sfont = Config::get('mod_bannerpic_fontsize'));
     $killstr = "{$victimname} was killed by {$killername}";
     $corpstr = "Corporation : {$victimcorp}";
     $allistr = "Alliance : {$victimalli}";
     $shipstr = "Ship : {$victimshipname}";
     //open base picture
     $this->img = imagecreatefromjpeg($this->basepic);
     $red = imagecolorallocate($this->img, 255, 0, 0);
     $black = imagecolorallocate($this->img, 0, 0, 0);
     $textcol = imagecolorallocate($this->img, $textr, $textg, $textb);
     $box = imagecreate(68, 68);
     $bxcol = imagecolorallocate($box, $boxr, $boxg, $boxb);
     //pics to base pic
     imagecopymerge($this->img, $box, $vicpicLeft, $vicpicTop, 0, 0, 68, 68, $vicpicTrans);
     imagecopymerge($this->img, $victimimg, $vicpicLeft + 2, $vicpicTop + 2, 0, 0, 64, 64, $vicpicTrans);
     imagecopymerge($this->img, $box, $shippicLeft, $shippicTop, 0, 0, 68, 68, 100);
     imagecopymerge($this->img, $victimshipimg, $shippicLeft + 2, $shippicTop + 2, 0, 0, 64, 64, 100);
     //add text to image
     imagefttext($this->img, $this->sfont, 0, $killstrLeft, $killstrTop, $textcol, $this->font, $killstr);
     imagefttext($this->img, $this->sfont, 0, $corpstrLeft, $corpstrTop, $textcol, $this->font, $corpstr);
     imagefttext($this->img, $this->sfont, 0, $allistrLeft, $allistrTop, $textcol, $this->font, $allistr);
     imagefttext($this->img, $this->sfont, 0, $shipstrLeft, $shipstrTop, $textcol, $this->font, $shipstr);
     //cache the file
     imagejpeg($this->img, $this->cache, 100);
     //if the board banner option is checked then put a copy in the banners dir.
     if ($bannerreplace == 1) {
         imagejpeg($this->img, 'banner/bannerpic.jpg', 100);
     }
     //destroy the images
     imagedestroy($box);
     imagedestroy($victimimg);
     imagedestroy($victimshipimg);
 }
Ejemplo n.º 8
0
    public function buildStats()
    {
        // this is a fast query to get the system and timestamp
        $rqry = DBFactory::getDBQuery();
        if ($this->adjacent) {
            $rsql = 'SELECT kll_timestamp, sjp_to as sys_id from kb3_kills
				join kb3_systems a ON (a.sys_id = kll_system_id)
				join kb3_system_jumps on (sjp_from = a.sys_id)
				where kll_id = ' . $this->kll_id . ' UNION
				SELECT kll_timestamp, kll_system_id as sys_id from kb3_kills
				where kll_id = ' . $this->kll_id;
        } else {
            $rsql = 'SELECT kll_timestamp, kll_system_id as sys_id from kb3_kills
				where kll_id = ' . $this->kll_id;
        }
        $rqry->execute($rsql);
        while ($rrow = $rqry->getRow()) {
            $this->systems[] = $rrow['sys_id'];
            $basetime = $rrow['kll_timestamp'];
        }
        // now we get all kills in that system for +-4 hours
        $query = 'SELECT kll.kll_timestamp AS ts FROM kb3_kills kll WHERE kll.kll_system_id IN (' . implode(',', $this->systems) . ') AND kll.kll_timestamp <= "' . date('Y-m-d H:i:s', strtotime($basetime) + config::get('fleet_battles_mod_maxtime') * 60 * 60) . '"' . ' AND kll.kll_timestamp >= "' . date('Y-m-d H:i:s', strtotime($basetime) - config::get('fleet_battles_mod_maxtime') * 60 * 60) . '"' . ' ORDER BY kll.kll_timestamp ASC';
        $qry = DBFactory::getDBQuery();
        $qry->execute($query);
        $ts = array();
        $timestampsRaw = array();
        while ($row = $qry->getRow()) {
            $time = strtotime($row['ts']);
            $ts[intval(date('H', $time))][] = $row['ts'];
            $timestampsRaw[] = $row["ts"];
        }
        // only for non-battles
        if (!$this->displayingBattle) {
            // this tricky thing looks for gaps of more than 1 hour and creates an intersection
            $baseh = date('H', strtotime($basetime));
            $maxc = count($ts);
            $times = array();
            for ($i = 0; $i < $maxc; $i++) {
                $h = ($baseh + $i) % 24;
                if (!isset($ts[$h])) {
                    break;
                }
                foreach ($ts[$h] as $timestamp) {
                    $times[] = $timestamp;
                }
            }
            for ($i = 0; $i < $maxc; $i++) {
                $h = ($baseh - $i) % 24;
                if ($h < 0) {
                    $h += 24;
                }
                if (!isset($ts[$h])) {
                    break;
                }
                foreach ($ts[$h] as $timestamp) {
                    $times[] = $timestamp;
                }
            }
            unset($ts);
            asort($times);
            // we got 2 resulting timestamps
            $this->firstts = array_shift($times);
            $this->lastts = array_pop($times);
        } else {
            // take the first and last timestamp from our original query
            $this->firstts = array_shift($timestampsRaw);
            $this->lastts = array_pop($timestampsRaw);
        }
        // get parameters for overriding start and end times
        // dirty hook for the enlightened circle ;)
        $overrideStartTime = str_replace('%20', ' ', edkURI::getArg('starttime'));
        $overrideEndTime = str_replace('%20', ' ', edkURI::getArg('endtime'));
        if ($overrideStartTime && strtotime($overrideStartTime)) {
            $this->firstts = $overrideStartTime;
        }
        if ($overrideEndTime && strtotime($overrideEndTime)) {
            $this->lastts = $overrideEndTime;
        }
        // unfiltered kill list (no ship class filter applied)
        $this->kslist = new KillList();
        $this->kslist->setOrdered(true);
        foreach ($this->systems as $system) {
            $this->kslist->addSystem($system);
        }
        $this->kslist->setStartDate($this->firstts);
        $this->kslist->setEndDate($this->lastts);
        involved::load($this->kslist, 'kill');
        // unfiltered loss list (no ship class filter applied)
        $this->lslist = new KillList();
        $this->lslist->setOrdered(true);
        foreach ($this->systems as $system) {
            $this->lslist->addSystem($system);
        }
        $this->lslist->setStartDate($this->firstts);
        $this->lslist->setEndDate($this->lastts);
        involved::load($this->lslist, 'loss');
        // filtered kill list (shipclass filter applied)
        $this->klist = new KillList();
        $this->klist->setOrdered(true);
        $this->klist->setCountComments(true);
        $this->klist->setCountInvolved(true);
        foreach ($this->systems as $system) {
            $this->klist->addSystem($system);
        }
        $this->klist->setStartDate($this->firstts);
        $this->klist->setEndDate($this->lastts);
        involved::load($this->klist, 'kill');
        // filtered loss list (ship class filter applied)
        $this->llist = new KillList();
        $this->llist->setOrdered(true);
        $this->llist->setCountComments(true);
        $this->llist->setCountInvolved(true);
        foreach ($this->systems as $system) {
            $this->llist->addSystem($system);
        }
        $this->llist->setStartDate($this->firstts);
        $this->llist->setEndDate($this->lastts);
        involved::load($this->llist, 'loss');
        // apply ship class filters
        if ($this->scl_id) {
            $this->klist->addVictimShipClass($this->scl_id);
            $this->llist->addVictimShipClass($this->scl_id);
        }
        // if manual side assignment is enabled
        if (config::get("fleet_battles_mod_sideassign")) {
            // get possible side assignments
            $sideAssignments = getSideAssignments($this->systems[0], $this->firstts, $this->lastts);
            $sideAssignmentMap = array();
            // apply
            foreach ($sideAssignments as $sideAssignment) {
                $this->isFixed = TRUE;
                $sideAssignmentMap[$sideAssignment["entity_type"]][$sideAssignment["entity_id"]] = $sideAssignment["side"];
                // entity is an alliance
                if ($sideAssignment["entity_type"] == "alliance") {
                    // alliance is an enemy
                    if ($sideAssignment["side"] == "e") {
                        $this->kslist->addVictimAlliance($sideAssignment["entity_id"]);
                        $this->lslist->addInvolvedAlliance($sideAssignment["entity_id"]);
                        $this->klist->addVictimAlliance($sideAssignment["entity_id"]);
                        $this->llist->addInvolvedAlliance($sideAssignment["entity_id"]);
                    } else {
                        $this->kslist->addInvolvedAlliance($sideAssignment["entity_id"]);
                        $this->lslist->addVictimAlliance($sideAssignment["entity_id"]);
                        // also add as involved alliance for blue-on-blue kills
                        $this->lslist->addInvolvedAlliance($sideAssignment["entity_id"]);
                        $this->klist->addInvolvedAlliance($sideAssignment["entity_id"]);
                        $this->llist->addVictimAlliance($sideAssignment["entity_id"]);
                        // also add as involved alliance for blue-on-blue kills
                        $this->llist->addInvolvedAlliance($sideAssignment["entity_id"]);
                    }
                } else {
                    // alliance is an enemy
                    if ($sideAssignment["side"] == "e") {
                        $this->kslist->addVictimCorp($sideAssignment["entity_id"]);
                        $this->lslist->addInvolvedCorp($sideAssignment["entity_id"]);
                        $this->klist->addVictimCorp($sideAssignment["entity_id"]);
                        $this->llist->addInvolvedCorp($sideAssignment["entity_id"]);
                    } else {
                        $this->kslist->addInvolvedCorp($sideAssignment["entity_id"]);
                        $this->lslist->addVictimCorp($sideAssignment["entity_id"]);
                        // also add as involved alliance for blue-on-blue kills
                        $this->lslist->addInvolvedCorp($sideAssignment["entity_id"]);
                        $this->klist->addInvolvedCorp($sideAssignment["entity_id"]);
                        $this->llist->addVictimCorp($sideAssignment["entity_id"]);
                        // also add as involved alliance for blue-on-blue kills
                        $this->llist->addInvolvedCorp($sideAssignment["entity_id"]);
                    }
                }
            }
        }
        // we need a summary table first
        $this->summaryTable = new KillSummaryTable($this->kslist, $this->lslist);
        $this->summaryTable->generate();
        $this->destroyed = array();
        $this->lossValues = array();
        $this->killValues = array();
        $this->pilots = array('a' => array(), 'e' => array());
        $this->klist->rewind();
        $this->damageOverview = array('a' => array(), 'e' => array());
        $totalKillIsk = $this->summaryTable->getTotalKillISK();
        while ($kill = $this->klist->getKill()) {
            handle_involved($kill, 'a', $this->pilots, $sideAssignmentMap, TRUE);
            handle_destroyed($kill, 'e', $this->destroyed, $this->pilots, $sideAssignmentMap, TRUE);
            // gather data for battle timeline and loss value lists
            // for better performance we use this loop so we won't have to loop over the same data again
            // ---------------------------------------------------------------------------------------
            // gathering kill values
            // ---------------------------------------------------------------------------------------
            // we dont want our own people on the enemy's side!
            if (in_array($kill->getVictimAllianceID(), config::get('cfg_allianceid')) || in_array($kill->getVictimCorpID(), config::get('cfg_corpid')) || in_array($kill->getVictimID(), config::get('cfg_pilotid'))) {
                continue;
            }
            $lossValueRaw = $kill->getISKLoss();
            $lossValue = self::formatIskValue($lossValueRaw);
            if ($totalKillIsk != 0) {
                $percentualLossValue = number_format($lossValueRaw / $totalKillIsk * 100, 2);
            } else {
                $percentualLossValue = 0.0;
            }
            if ($lossValueRaw > 0) {
                $this->killValues[] = array("victimName" => $kill->getVictimName(), "victimID" => $kill->getVictimID(), "victimUrl" => edkURI::page("pilot_detail", $kill->getVictimID(), "plt_id"), "victimShipName" => $kill->getVictimShipName(), "victimShipImage" => imageUrl::getURL("Ship", $kill->getVictimShipID(), 32), "victimShipClass" => $kill->getVictimShipClassName(), "victimCorpName" => $kill->getVictimCorpName(), "victimCorpID" => $kill->getVictimCorpID(), "victimCorpUrl" => edkURI::page("corp_detail", $kill->getVictimCorpID(), "crp_id"), "victimAllianceName" => $kill->getVictimAllianceName(), "victimAllianceID" => $kill->getVictimAllianceID(), "victimAllianceUrl" => edkURI::page("alliance_detail", $kill->getVictimAllianceID(), "all_id"), "killId" => $kill->getID(), "killUrl" => edkURI::page("kill_detail", $kill->getID(), "kll_id"), "lossValueRaw" => $lossValueRaw, "lossValue" => $lossValue, "lossValuePercentage" => $percentualLossValue);
            }
            // ---------------------------------------------------------------------------------------
            // gathering timeline data
            // ---------------------------------------------------------------------------------------
            $killTimestamp = strtotime($kill->getTimeStamp());
            // increase killtimestamp for pods so they appear AFTER the ship kill in the timeline
            $shipClassId = $kill->getVictimShip()->getClass()->getID();
            if ($shipClassId == 18 || $shipClassId == 2) {
                $killTimestamp += 1;
            }
            $this->timeLine[] = array("timestamp" => $killTimestamp, "loss" => NULL, "kill" => array("victimName" => $kill->getVictimName(), "victimID" => $kill->getVictimID(), "victimUrl" => edkURI::page("pilot_detail", $kill->getVictimID(), "plt_id"), "victimShipName" => $kill->getVictimShipName(), "victimShipImage" => imageUrl::getURL("Ship", $kill->getVictimShipID(), 32), "victimShipClass" => $kill->getVictimShipClassName(), "victimCorpName" => $kill->getVictimCorpName(), "victimCorpID" => $kill->getVictimCorpID(), "victimCorpUrl" => edkURI::page("corp_detail", $kill->getVictimCorpID(), "crp_id"), "victimAllianceName" => $kill->getVictimAllianceName(), "victimAllianceID" => $kill->getVictimAllianceID(), "victimAllianceUrl" => edkURI::page("alliance_detail", $kill->getVictimAllianceID(), "all_id"), "killId" => $kill->getID(), "killUrl" => edkURI::page("kill_detail", $kill->getID(), "kll_id")));
            // ---------------------------------------------------------------------------------------
            // gathering damage overview data
            // ---------------------------------------------------------------------------------------
            $this->damageOverview["a"][] = array("victimName" => $kill->getVictimName(), "victimID" => $kill->getVictimID(), "victimUrl" => edkURI::page("pilot_detail", $kill->getVictimID(), "plt_id"), "victimShipName" => $kill->getVictimShipName(), "victimShipImage" => imageUrl::getURL("Ship", $kill->getVictimShipID(), 32), "victimShipClass" => $kill->getVictimShipClassName(), "victimCorpName" => $kill->getVictimCorpName(), "victimCorpID" => $kill->getVictimCorpID(), "victimCorpUrl" => edkURI::page("corp_detail", $kill->getVictimCorpID(), "crp_id"), "victimAllianceName" => $kill->getVictimAllianceName(), "victimAllianceID" => $kill->getVictimAllianceID(), "victimAllianceUrl" => edkURI::page("alliance_detail", $kill->getVictimAllianceID(), "all_id"), "killId" => $kill->getID(), "killUrl" => edkURI::page("kill_detail", $kill->getID(), "kll_id"), "lossValueRaw" => $lossValueRaw, "lossValue" => $lossValue, "lossValuePercentage" => $percentualLossValue);
        }
        $this->llist->rewind();
        $totalLossIsk = $this->summaryTable->getTotalLossISK();
        while ($kill = $this->llist->getKill()) {
            handle_involved($kill, 'e', $this->pilots, $sideAssignmentMap, TRUE);
            handle_destroyed($kill, 'a', $this->destroyed, $this->pilots, $sideAssignmentMap, TRUE);
            // gather data for battle timeline and loss value lists
            // for better performance we use this loop so we won't have to loop over the same data again
            // ---------------------------------------------------------------------------------------
            // gathering loss values
            // ---------------------------------------------------------------------------------------
            $lossValueRaw = $kill->getISKLoss();
            $lossValue = self::formatIskValue($lossValueRaw);
            if ($totalLossIsk != 0) {
                $percentualLossValue = number_format($lossValueRaw / $totalLossIsk * 100, 2);
            } else {
                $percentualLossValue = 0.0;
            }
            if ($lossValueRaw > 0) {
                $this->lossValues[] = array("victimName" => $kill->getVictimName(), "victimID" => $kill->getVictimID(), "victimUrl" => edkURI::page("pilot_detail", $kill->getVictimID(), "plt_id"), "victimShipName" => $kill->getVictimShipName(), "victimShipImage" => imageUrl::getURL("Ship", $kill->getVictimShipID(), 32), "victimShipClass" => $kill->getVictimShipClassName(), "victimCorpName" => $kill->getVictimCorpName(), "victimCorpID" => $kill->getVictimCorpID(), "victimCorpUrl" => edkURI::page("corp_detail", $kill->getVictimCorpID(), "crp_id"), "victimAllianceName" => $kill->getVictimAllianceName(), "victimAllianceID" => $kill->getVictimAllianceID(), "victimAllianceUrl" => edkURI::page("alliance_detail", $kill->getVictimAllianceID(), "all_id"), "killId" => $kill->getID(), "killUrl" => edkURI::page("kill_detail", $kill->getID(), "kll_id"), "lossValueRaw" => $lossValueRaw, "lossValue" => $lossValue, "lossValuePercentage" => $percentualLossValue);
            }
            // ---------------------------------------------------------------------------------------
            // gathering timeline data
            // ---------------------------------------------------------------------------------------
            $killTimestamp = strtotime($kill->getTimeStamp());
            $shipClassId = $kill->getVictimShip()->getClass()->getID();
            $this->timeLine[] = array("timestamp" => strtotime($kill->getTimeStamp()), "loss" => array("victimName" => $kill->getVictimName(), "victimID" => $kill->getVictimID(), "victimUrl" => edkURI::page("pilot_detail", $kill->getVictimID(), "plt_id"), "victimShipName" => $kill->getVictimShipName(), "victimShipImage" => imageUrl::getURL("Ship", $kill->getVictimShipID(), 32), "victimShipClass" => $kill->getVictimShipClassName(), "victimCorpName" => $kill->getVictimCorpName(), "victimCorpID" => $kill->getVictimCorpID(), "victimCorpUrl" => edkURI::page("corp_detail", $kill->getVictimCorpID(), "crp_id"), "victimAllianceName" => $kill->getVictimAllianceName(), "victimAllianceID" => $kill->getVictimAllianceID(), "victimAllianceUrl" => edkURI::page("alliance_detail", $kill->getVictimAllianceID(), "all_id"), "killId" => $kill->getID(), "killUrl" => edkURI::page("kill_detail", $kill->getID(), "kll_id")), "kill" => NULL);
        }
        //echo "<pre>"; var_dump($this->pilots); echo "</pre>";
        // sort pilot ships, order pods after ships
        foreach ($this->pilots as $side => $pilot) {
            foreach ($pilot as $id => $kll) {
                usort($this->pilots[$side][$id], array($this, 'cmp_ts_func'));
            }
        }
        // sort arrays, ships with high points first
        uasort($this->pilots['a'], array($this, 'cmp_func'));
        uasort($this->pilots['e'], array($this, 'cmp_func'));
        // now get the pods out and mark the ships the've flown as podded
        foreach ($this->pilots as $side => $pilot) {
            foreach ($pilot as $id => $kll) {
                $max = count($kll);
                for ($i = 0; $i < $max; $i++) {
                    // add up total damage for each side
                    if ($side == "a") {
                        if (isset($kll[$i]["damage"])) {
                            $this->damageTotalFriendly += $kll[$i]["damage"];
                        }
                    } else {
                        if (isset($kll[$i]["damage"])) {
                            $this->damageTotalHostile += $kll[$i]["damage"];
                        }
                    }
                    // this kill has a pod as ship
                    if ($kll[$i]['shipClass'] == 'Capsule') {
                        // this pilot made previous kills in another ship
                        if (isset($kll[$i - 1]['sid'])) {
                            // this kill is a pod loss
                            if (isset($kll[$i]['destroyed'])) {
                                $this->pilots[$side][$id][$i - 1]['podded'] = true;
                                $this->pilots[$side][$id][$i - 1]['podid'] = $kll[$i]['kll_id'];
                                $this->pilots[$side][$id][$i - 1]['pod_url'] = edkURI::page("kill_detail", $kll[$i]['kll_id'], "kll_id");
                                unset($this->pilots[$side][$id][$i]);
                            } else {
                                // update stats for previously used ship
                                $this->pilots[$side][$id][$i - 1]['times'] += $this->pilots[$side][$id][$i]['times'];
                                $this->pilots[$side][$id][$i - 1]['damage'] += $this->pilots[$side][$id][$i]['damage'];
                                unset($this->pilots[$side][$id][$i]);
                            }
                        }
                    }
                }
            }
        }
        // update battles with current stats
        $this->updateBattles();
    }
Ejemplo n.º 9
0
 /**
  *  Build the killlists that are needed for the options selected.
  *
  * @global Smarty $smarty
  * @return string
  */
 function killList()
 {
     global $smarty;
     if ($this->view == '') {
         $smarty->assign('view', Language::get('recent'));
     } else {
         $smarty->assign('view', $this->view);
     }
     $args = array(array('a', 'alliance_detail', true), array('all_id', $this->all_id, true));
     if (isset($this->viewList[$this->view])) {
         return call_user_func_array($this->viewList[$this->view], array(&$this));
     }
     $scl_id = (int) edkURI::getArg('scl_id');
     switch ($this->view) {
         default:
             $list = new KillList();
             $list->setOrdered(true);
             if (config::get('comments_count')) {
                 $list->setCountComments(true);
             }
             if (config::get('killlist_involved')) {
                 $list->setCountInvolved(true);
             }
             $list->setLimit(10);
             $list->addInvolvedAlliance($this->alliance);
             if ($scl_id) {
                 $list->addVictimShipClass($scl_id);
             } else {
                 $list->setPodsNoobShips(config::get('podnoobs'));
             }
             $ktab = new KillListTable($list);
             $ktab->setLimit(10);
             $smarty->assign('kills', $ktab->generate());
             $list = new KillList();
             $list->setOrdered(true);
             if (config::get('comments_count')) {
                 $list->setCountComments(true);
             }
             if (config::get('killlist_involved')) {
                 $list->setCountInvolved(true);
             }
             $list->setLimit(10);
             $list->addVictimAlliance($this->alliance);
             if ($scl_id) {
                 $list->addVictimShipClass($scl_id);
             } else {
                 $list->setPodsNoobShips(config::get('podnoobs'));
             }
             $ltab = new KillListTable($list);
             $ltab->setLimit(10);
             $smarty->assign('losses', $ltab->generate());
             return $smarty->fetch(get_tpl('detail_kl_default'));
             break;
         case "kills":
             $list = new KillList();
             $list->setOrdered(true);
             $list->addInvolvedAlliance($this->alliance);
             if ($scl_id) {
                 $list->addVictimShipClass($scl_id);
             }
             $list->setPageSplit(config::get('killcount'));
             $pagesplitter = new PageSplitter($list->getCount(), config::get('killcount'));
             $table = new KillListTable($list);
             $smarty->assign('kills', $table->generate());
             $smarty->assign('splitter', $pagesplitter->generate());
             return $smarty->fetch(get_tpl('detail_kl_kills'));
             break;
         case "losses":
             $list = new KillList();
             $list->setOrdered(true);
             $list->setPodsNoobShips(config::get('podnoobs'));
             $list->addVictimAlliance($this->alliance);
             if ($scl_id) {
                 $list->addVictimShipClass($scl_id);
             }
             $list->setPageSplit(config::get('killcount'));
             $pagesplitter = new PageSplitter($list->getCount(), config::get('killcount'));
             $table = new KillListTable($list);
             $smarty->assign('losses', $table->generate());
             $smarty->assign('splitter', $pagesplitter->generate());
             return $smarty->fetch(get_tpl('detail_kl_losses'));
             break;
         case "corp_kills":
             $smarty->assign('title', Language::get('topkillers'));
             $smarty->assign('month', $this->monthname);
             $smarty->assign('year', $this->year);
             $smarty->assign('pmonth', $this->pmonth);
             $smarty->assign('pyear', $this->pyear);
             $smarty->assign('nmonth', $this->nmonth);
             $smarty->assign('nyear', $this->nyear);
             $smarty->assign('all_id', $this->all_id);
             $smarty->assign('url_previous', edkURI::build($args, array('view', 'corp_kills', true), array('y', $this->pyear, true), array('m', $this->pmonth, true)));
             $smarty->assign('url_next', edkURI::build($args, array('view', 'corp_kills', true), array('y', $this->nyear, true), array('m', $this->nmonth, true)));
             $list = new TopList_CorpKills();
             $list->addInvolvedAlliance($this->alliance);
             $list->setPodsNoobShips(config::get('podnoobs'));
             $list->setMonth($this->month);
             $list->setYear($this->year);
             $table = new TopTable_Corp($list, Language::get('kills'));
             $smarty->assign('monthly_stats', $table->generate());
             $list = new TopList_CorpKills();
             $list->addInvolvedAlliance($this->alliance);
             $list->setPodsNoobShips(config::get('podnoobs'));
             $table = new TopTable_Corp($list, Language::get('kills'));
             $smarty->assign('total_stats', $table->generate());
             return $smarty->fetch(get_tpl('detail_kl_monthly'));
             break;
         case "corp_kills_class":
             $smarty->assign('title', Language::get('topdestroyedships'));
             // Get all ShipClasses
             $sql = "select scl_id, scl_class from kb3_ship_classes\n\t\t\t\t\twhere scl_class not in ('Drone','Unknown') order by scl_class";
             $qry = DBFactory::getDBQuery();
             $qry->execute($sql);
             while ($row = $qry->getRow()) {
                 $shipclass[] = new Shipclass($row['scl_id']);
             }
             $newrow = true;
             $ships = array();
             foreach ($shipclass as $shp) {
                 $list = new TopList_CorpKills();
                 $list->addInvolvedAlliance($this->alliance);
                 $list->addVictimShipClass($shp);
                 $table = new TopTable_Corp($list, Language::get('kills'));
                 $content = $table->generate();
                 $ships[] = array('name' => $shp->getName(), 'table' => $content);
             }
             $smarty->assignByRef('ships', $ships);
             return $smarty->fetch(get_tpl('detail_kl_ships'));
             break;
         case "kills_class":
             $smarty->assign('title', Language::get('topdestroyedships'));
             // Get all ShipClasses
             $sql = "select scl_id, scl_class from kb3_ship_classes\n\t\t\t\t\twhere scl_class not in ('Drone','Unknown') order by scl_class";
             $qry = DBFactory::getDBQuery();
             $qry->execute($sql);
             while ($row = $qry->getRow()) {
                 $shipclass[] = new Shipclass($row['scl_id']);
             }
             foreach ($shipclass as $shp) {
                 $list = new TopList_Kills();
                 $list->addInvolvedAlliance($this->alliance);
                 $list->addVictimShipClass($shp);
                 $table = new TopTable_Pilot($list, Language::get('kills'));
                 $content = $table->generate();
                 $ships[] = array('name' => $shp->getName(), 'table' => $content);
             }
             $smarty->assignByRef('ships', $ships);
             return $smarty->fetch(get_tpl('detail_kl_ships'));
             break;
         case "corp_losses_class":
             $smarty->assign('title', Language::get('toplostships'));
             // Get all ShipClasses
             $sql = "select scl_id, scl_class from kb3_ship_classes\n\t\t\t\t\twhere scl_class not in ('Drone','Unknown') order by scl_class";
             $qry = DBFactory::getDBQuery();
             $qry->execute($sql);
             while ($row = $qry->getRow()) {
                 $shipclass[] = new Shipclass($row['scl_id']);
             }
             foreach ($shipclass as $shp) {
                 $list = new TopList_CorpLosses();
                 $list->addVictimAlliance($this->alliance);
                 $list->addVictimShipClass($shp);
                 $table = new TopTable_Corp($list, Language::get('losses'));
                 $content = $table->generate();
                 $ships[] = array('name' => $shp->getName(), 'table' => $content);
             }
             $smarty->assignByRef('ships', $ships);
             return $smarty->fetch(get_tpl('detail_kl_ships'));
             break;
         case "losses_class":
             $smarty->assign('title', Language::get('toplostships'));
             // Get all ShipClasses
             $sql = "select scl_id, scl_class from kb3_ship_classes\n\t\t\t\t\twhere scl_class not in ('Drone','Unknown') order by scl_class";
             $qry = DBFactory::getDBQuery();
             $qry->execute($sql);
             while ($row = $qry->getRow()) {
                 $shipclass[] = new Shipclass($row['scl_id']);
             }
             foreach ($shipclass as $shp) {
                 $list = new TopList_Losses();
                 $list->addVictimAlliance($this->alliance);
                 $list->addVictimShipClass($shp);
                 $table = new TopTable_Pilot($list, Language::get('losses'));
                 $content = $table->generate();
                 $ships[] = array('name' => $shp->getName(), 'table' => $content);
             }
             $smarty->assignByRef('ships', $ships);
             return $smarty->fetch(get_tpl('detail_kl_ships'));
             break;
         case "corp_losses":
             $smarty->assign('title', Language::get('toplosers'));
             $smarty->assign('month', $this->monthname);
             $smarty->assign('year', $this->year);
             $smarty->assign('pmonth', $this->pmonth);
             $smarty->assign('pyear', $this->pyear);
             $smarty->assign('nmonth', $this->nmonth);
             $smarty->assign('nyear', $this->nyear);
             $smarty->assign('all_id', $this->all_id);
             $smarty->assign('url_previous', edkURI::build($args, array('view', 'corp_losses', true), array('y', $this->pyear, true), array('m', $this->pmonth, true)));
             $smarty->assign('url_next', edkURI::build($args, array('view', 'corp_losses', true), array('y', $this->nyear, true), array('m', $this->nmonth, true)));
             $list = new TopList_CorpLosses();
             $list->addVictimAlliance($this->alliance);
             $list->setPodsNoobShips(config::get('podnoobs'));
             $list->setMonth($this->month);
             $list->setYear($this->year);
             $table = new TopTable_Corp($list, Language::get('losses'));
             $smarty->assign('monthly_stats', $table->generate());
             $list = new TopList_CorpLosses();
             $list->addVictimAlliance($this->alliance);
             $list->setPodsNoobShips(config::get('podnoobs'));
             $table = new TopTable_Corp($list, Language::get('losses'));
             $smarty->assign('total_stats', $table->generate());
             return $smarty->fetch(get_tpl('detail_kl_monthly'));
             break;
         case "pilot_kills":
             $smarty->assign('title', Language::get('topkillers'));
             $smarty->assign('month', $this->monthname);
             $smarty->assign('year', $this->year);
             $smarty->assign('pmonth', $this->pmonth);
             $smarty->assign('pyear', $this->pyear);
             $smarty->assign('nmonth', $this->nmonth);
             $smarty->assign('nyear', $this->nyear);
             $smarty->assign('all_id', $this->all_id);
             $smarty->assign('url_previous', edkURI::build($args, array('view', 'pilot_kills', true), array('y', $this->pyear, true), array('m', $this->pmonth, true)));
             $smarty->assign('url_next', edkURI::build($args, array('view', 'pilot_kills', true), array('y', $this->nyear, true), array('m', $this->nmonth, true)));
             $list = new TopList_Kills();
             $list->setLimit(30);
             $list->addInvolvedAlliance($this->alliance);
             $list->setPodsNoobShips(config::get('podnoobs'));
             $list->setMonth($this->month);
             $list->setYear($this->year);
             $table = new TopTable_Pilot($list, Language::get('kills'));
             $smarty->assign('monthly_stats', $table->generate());
             $list = new TopList_Kills();
             $list->setLimit(30);
             $list->addInvolvedAlliance($this->alliance);
             $list->setPodsNoobShips(config::get('podnoobs'));
             $table = new TopTable_Pilot($list, Language::get('kills'));
             $smarty->assign('total_stats', $table->generate());
             return $smarty->fetch(get_tpl('detail_kl_monthly'));
             break;
         case "pilot_scores":
             $smarty->assign('title', Language::get('topscorers'));
             $smarty->assign('month', $this->monthname);
             $smarty->assign('year', $this->year);
             $smarty->assign('pmonth', $this->pmonth);
             $smarty->assign('pyear', $this->pyear);
             $smarty->assign('nmonth', $this->nmonth);
             $smarty->assign('nyear', $this->nyear);
             $smarty->assign('all_id', $this->all_id);
             $smarty->assign('url_previous', edkURI::build($args, array('view', 'pilot_scores', true), array('y', $this->pyear, true), array('m', $this->pmonth, true)));
             $smarty->assign('url_next', edkURI::build($args, array('view', 'pilot_scores', true), array('y', $this->nyear, true), array('m', $this->nmonth, true)));
             $list = new TopList_Score();
             $list->addInvolvedAlliance($this->alliance);
             $list->setMonth($this->month);
             $list->setYear($this->year);
             $table = new TopTable_Pilot($list, Language::get('top_points'));
             $smarty->assign('monthly_stats', $table->generate());
             $list = new TopList_Score();
             $list->addInvolvedAlliance($this->alliance);
             $table = new TopTable_Pilot($list, Language::get('top_points'));
             $smarty->assign('total_stats', $table->generate());
             return $smarty->fetch(get_tpl('detail_kl_monthly'));
             break;
         case "pilot_losses":
             $smarty->assign('title', Language::get('toplosers'));
             $smarty->assign('month', $this->monthname);
             $smarty->assign('year', $this->year);
             $smarty->assign('pmonth', $this->pmonth);
             $smarty->assign('pyear', $this->pyear);
             $smarty->assign('nmonth', $this->nmonth);
             $smarty->assign('nyear', $this->nyear);
             $smarty->assign('all_id', $this->all_id);
             $smarty->assign('url_previous', edkURI::build($args, array('view', 'pilot_losses', true), array('y', $this->pyear, true), array('m', $this->pmonth, true)));
             $smarty->assign('url_next', edkURI::build($args, array('view', 'pilot_losses', true), array('y', $this->nyear, true), array('m', $this->nmonth, true)));
             $list = new TopList_Losses();
             $list->addVictimAlliance($this->alliance);
             $list->setPodsNoobShips(config::get('podnoobs'));
             $list->setMonth($this->month);
             $list->setYear($this->year);
             $table = new TopTable_Pilot($list, Language::get('losses'));
             $smarty->assign('monthly_stats', $table->generate());
             $list = new TopList_Losses();
             $list->addVictimAlliance($this->alliance);
             $list->setPodsNoobShips(config::get('podnoobs'));
             $table = new TopTable_Pilot($list, Language::get('losses'));
             $smarty->assign('total_stats', $table->generate());
             return $smarty->fetch(get_tpl('detail_kl_monthly'));
             break;
         case "ships_weapons":
             $view = "ships_weapons";
             $shiplist = new TopList_Ship();
             $shiplist->addInvolvedAlliance($this->alliance);
             $shiplisttable = new TopTable_Ship($shiplist);
             $smarty->assign('ships', $shiplisttable->generate());
             $weaponlist = new TopList_Weapon();
             $weaponlist->addInvolvedAlliance($this->alliance);
             $weaponlisttable = new TopTable_Weapon($weaponlist);
             $smarty->assign('title', Language::get('ships_weapons'));
             $smarty->assign('weapons', $weaponlisttable->generate());
             return $smarty->fetch(get_tpl('detail_kl_ships_weapons'));
             break;
         case 'violent_systems':
             $smarty->assign('title', Language::get('topmostviolentsys'));
             $smarty->assign('month', $this->monthname);
             $smarty->assign('year', $this->year);
             $smarty->assign('pmonth', $this->pmonth);
             $smarty->assign('pyear', $this->pyear);
             $smarty->assign('nmonth', $this->nmonth);
             $smarty->assign('nyear', $this->nyear);
             $smarty->assign('all_id', $this->all_id);
             $smarty->assign('url_previous', edkURI::build($args, array('view', 'violent_systems', true), array('y', $this->pyear, true), array('m', $this->pmonth, true)));
             $smarty->assign('url_next', edkURI::build($args, array('view', 'violent_systems', true), array('y', $this->nyear, true), array('m', $this->nmonth, true)));
             $startdate = gmdate('Y-m-d H:i', makeStartDate(0, $this->year, $this->month));
             $enddate = gmdate('Y-m-d H:i', makeEndDate(0, $this->year, $this->month));
             $sql = "select sys.sys_name, sys.sys_sec, sys.sys_id, count(kll.kll_id) as kills\n\t\t\t\t\t\t\tfrom kb3_systems sys, kb3_kills kll, kb3_inv_all ina\n\t\t\t\t\t\t\twhere kll.kll_system_id = sys.sys_id\n\t\t\t\t\t\t\tand ina.ina_kll_id = kll.kll_id\n\t\t\t\t\t\t\tand ina.ina_all_id = " . $this->all_id;
             $sql .= "   and kll.kll_timestamp > '{$startdate}'\n\t\t\t\t\t\t\tand kll.kll_timestamp < '{$enddate}'\n\t\t\t\t\t\t\tand ina.ina_timestamp > '{$startdate}'\n\t\t\t\t\t\t\tand ina.ina_timestamp < '{$enddate}'\n\t\t\t\t\t\t\tgroup by sys.sys_id\n\t\t\t\t\t\t\torder by kills desc, sys.sys_name asc\n\t\t\t\t\t\t\tlimit 25";
             $qry = DBFactory::getDBQuery();
             $qry->execute($sql);
             $odd = false;
             $counter = 1;
             $syslist = array();
             while ($row = $qry->getRow()) {
                 if (!$odd) {
                     $odd = true;
                     $rowclass = 'kb-table-row-odd';
                 } else {
                     $odd = false;
                     $rowclass = 'kb-table-row-even';
                 }
                 $syslist[] = array("counter" => $counter, "url" => "?a=system_detail&amp;sys_id=" . $row['sys_id'], "name" => $row['sys_name'], "sec" => roundsec($row['sys_sec']), "kills" => (int) $row['kills']);
                 $counter++;
             }
             $smarty->assignByRef('syslist', $syslist);
             $smarty->assign('monthly_stats', $smarty->fetch(get_tpl(violent_systems)));
             $sql = "select sys.sys_name, sys.sys_id, sys.sys_sec, count(kll.kll_id) as kills\n\t\t\t\t\t\t\tfrom kb3_systems sys, kb3_kills kll, kb3_inv_all ina\n\t\t\t\t\t\t\twhere kll.kll_system_id = sys.sys_id\n\t\t\t\t\t\t\tand ina.ina_kll_id = kll.kll_id\n\t\t\t\t\t\t\tand ina.ina_all_id = " . $this->all_id;
             $sql .= " group by sys.sys_id\n\t\t\t\t\t\t\torder by kills desc, sys.sys_name asc\n\t\t\t\t\t\t\tlimit 25";
             $qry = DBFactory::getDBQuery();
             $qry->execute($sql);
             $odd = false;
             $counter = 1;
             $syslist = array();
             while ($row = $qry->getRow()) {
                 if (!$odd) {
                     $odd = true;
                     $rowclass = 'kb-table-row-odd';
                 } else {
                     $odd = false;
                     $rowclass = 'kb-table-row-even';
                 }
                 $syslist[] = array("counter" => $counter, "url" => "?a=system_detail&amp;sys_id=" . $row['sys_id'], "name" => $row['sys_name'], "sec" => roundsec($row['sys_sec']), "kills" => (int) $row['kills']);
                 $counter++;
             }
             $smarty->assignByRef('syslist', $syslist);
             $smarty->assign('total_stats', $smarty->fetch(get_tpl(violent_systems)));
             return $smarty->fetch(get_tpl('detail_kl_monthly'));
             break;
         case 'corp_list':
             return $this->corpList();
             break;
         case 'history':
             $allsum = new allianceSummary($this->alliance);
             $smarty->assign('title', Language::get('history'));
             $smarty->assign('summary', $allsum->getMonthlySummary());
             return $smarty->fetch(get_tpl('detail_history'));
             break;
     }
     return '';
 }
Ejemplo n.º 10
0
 /**
  *  Build the killlists that are needed for the options selected.
  */
 function killList()
 {
     global $smarty;
     if (isset($this->viewList[$this->view])) {
         return call_user_func_array($this->viewList[$this->view], array(&$this));
     }
     $args = array();
     if ($this->crp_external_id) {
         $args[] = array('crp_ext_id', $this->crp_external_id, true);
     } else {
         $args[] = array('crp_id', $this->crp_id, true);
     }
     $pyear = array('y', $this->pyear, true);
     $nyear = array('y', $this->nyear, true);
     $pmonth = array('m', $this->pmonth, true);
     $nmonth = array('m', $this->nmonth, true);
     switch ($this->view) {
         case "":
             $list = new KillList();
             $list->setOrdered(true);
             $list->setLimit(10);
             $list->addInvolvedCorp($this->crp_id);
             if ($this->scl_id) {
                 $list->addVictimShipClass($this->scl_id);
             } else {
                 $list->setPodsNoobShips(config::get('podnoobs'));
             }
             if (config::get('comments_count')) {
                 $list->setCountComments(true);
             }
             if (config::get('killlist_involved')) {
                 $list->setCountInvolved(true);
             }
             $ktab = new KillListTable($list);
             $ktab->setLimit(10);
             $smarty->assign('kills', $ktab->generate());
             $list = new KillList();
             $list->setOrdered(true);
             $list->setLimit(10);
             $list->addVictimCorp($this->crp_id);
             if ($this->scl_id) {
                 $list->addVictimShipClass($this->scl_id);
             } else {
                 $list->setPodsNoobShips(config::get('podnoobs'));
             }
             if (config::get('comments_count')) {
                 $list->setCountComments(true);
             }
             if (config::get('killlist_involved')) {
                 $list->setCountInvolved(true);
             }
             $ltab = new KillListTable($list);
             $ltab->setLimit(10);
             $smarty->assign('losses', $ltab->generate());
             return $smarty->fetch(get_tpl('detail_kl_default'));
             break;
         case "kills":
             $list = new KillList();
             $list->setOrdered(true);
             $list->addInvolvedCorp($this->crp_id);
             if ($this->scl_id) {
                 $list->addVictimShipClass($this->scl_id);
             } else {
                 $list->setPodsNoobShips(config::get('podnoobs'));
             }
             $list->setPageSplit(config::get('killcount'));
             $pagesplitter = new PageSplitter($list->getCount(), config::get('killcount'));
             $table = new KillListTable($list);
             $smarty->assign('splitter', $pagesplitter->generate());
             $smarty->assign('kills', $table->generate());
             return $smarty->fetch(get_tpl('detail_kl_kills'));
             break;
         case "losses":
             $list = new KillList();
             $list->setOrdered(true);
             $list->addVictimCorp($this->crp_id);
             if ($this->scl_id) {
                 $list->addVictimShipClass($this->scl_id);
             } else {
                 $list->setPodsNoobShips(config::get('podnoobs'));
             }
             $list->setPageSplit(config::get('killcount'));
             $pagesplitter = new PageSplitter($list->getCount(), config::get('killcount'));
             $table = new KillListTable($list);
             $smarty->assign('splitter', $pagesplitter->generate());
             $smarty->assign('losses', $table->generate());
             return $smarty->fetch(get_tpl('detail_kl_losses'));
             break;
         case "pilot_kills":
             $smarty->assign('title', 'Top Killers');
             $smarty->assign('month', $this->monthname);
             $smarty->assign('year', $this->year);
             $smarty->assign('pmonth', $this->pmonth);
             $smarty->assign('pyear', $this->pyear);
             $smarty->assign('nmonth', $this->nmonth);
             $smarty->assign('nyear', $this->nyear);
             $smarty->assign('crp_id', $this->crp_id);
             $smarty->assign('url_previous', edkURI::build($args, array('view', 'pilot_kills', true), $pyear, $pmonth));
             $smarty->assign('url_next', edkURI::build($args, array('view', 'pilot_kills', true), $nyear, $nmonth));
             $list = new TopList_Kills();
             $list->setLimit(30);
             $list->addInvolvedCorp($this->crp_id);
             $list->setPodsNoobShips(config::get('podnoobs'));
             $list->setMonth($this->month);
             $list->setYear($this->year);
             $table = new TopTable_Pilot($list, "Kills");
             $smarty->assign('monthly_stats', $table->generate());
             $list = new TopList_Kills();
             $list->setLimit(30);
             $list->addInvolvedCorp($this->crp_id);
             $list->setPodsNoobShips(config::get('podnoobs'));
             $table = new TopTable_Pilot($list, "Kills");
             $smarty->assign('total_stats', $table->generate());
             return $smarty->fetch(get_tpl('detail_kl_monthly'));
             break;
         case "pilot_scores":
             $smarty->assign('title', 'Top Scorers');
             $smarty->assign('month', $this->monthname);
             $smarty->assign('year', $this->year);
             $smarty->assign('pmonth', $this->pmonth);
             $smarty->assign('pyear', $this->pyear);
             $smarty->assign('nmonth', $this->nmonth);
             $smarty->assign('nyear', $this->nyear);
             $smarty->assign('crp_id', $this->crp_id);
             $smarty->assign('url_previous', edkURI::build($args, array('view', 'pilot_scores', true), $pyear, $pmonth));
             $smarty->assign('url_next', edkURI::build($args, array('view', 'pilot_scores', true), $nyear, $nmonth));
             $list = new TopList_Score();
             $list->addInvolvedCorp($this->crp_id);
             $list->setPodsNoobShips(config::get('podnoobs'));
             $list->setMonth($this->month);
             $list->setYear($this->year);
             $table = new TopTable_Pilot($list, "Points");
             $smarty->assign('monthly_stats', $table->generate());
             $list = new TopList_Score();
             $list->addInvolvedCorp($this->crp_id);
             $list->setPodsNoobShips(config::get('podnoobs'));
             $table = new TopTable_Pilot($list, "Points");
             $smarty->assign('total_stats', $table->generate());
             return $smarty->fetch(get_tpl('detail_kl_monthly'));
             break;
         case "pilot_solo":
             $smarty->assign('title', 'Top Solokillers');
             $smarty->assign('month', $this->monthname);
             $smarty->assign('year', $this->year);
             $smarty->assign('pmonth', $this->pmonth);
             $smarty->assign('pyear', $this->pyear);
             $smarty->assign('nmonth', $this->nmonth);
             $smarty->assign('nyear', $this->nyear);
             $smarty->assign('crp_id', $this->crp_id);
             $smarty->assign('url_previous', edkURI::build($args, array('view', 'pilot_solo', true), $pyear, $pmonth));
             $smarty->assign('url_next', edkURI::build($args, array('view', 'pilot_solo', true), $nyear, $nmonth));
             $list = new TopList_SoloKiller();
             $list->addInvolvedCorp($this->crp_id);
             $list->setPodsNoobShips(config::get('podnoobs'));
             $list->setMonth($this->month);
             $list->setYear($this->year);
             $table = new TopTable_Pilot($list, "Solokills");
             $smarty->assign('monthly_stats', $table->generate());
             $list = new TopList_SoloKiller();
             $list->addInvolvedCorp($this->crp_id);
             $list->setPodsNoobShips(config::get('podnoobs'));
             $table = new TopTable_Pilot($list, "Solokills");
             $smarty->assign('total_stats', $table->generate());
             return $smarty->fetch(get_tpl('detail_kl_monthly'));
             break;
         case "pilot_damage":
             $smarty->assign('title', 'Top Damagedealers');
             $smarty->assign('month', $this->monthname);
             $smarty->assign('year', $this->year);
             $smarty->assign('pmonth', $this->pmonth);
             $smarty->assign('pyear', $this->pyear);
             $smarty->assign('nmonth', $this->nmonth);
             $smarty->assign('nyear', $this->nyear);
             $smarty->assign('crp_id', $this->crp_id);
             $smarty->assign('url_previous', edkURI::build($args, array('view', 'pilot_damage', true), $pyear, $pmonth));
             $smarty->assign('url_next', edkURI::build($args, array('view', 'pilot_damage', true), $nyear, $nmonth));
             $list = new TopList_DamageDealer();
             $list->addInvolvedCorp($this->crp_id);
             $list->setPodsNoobShips(config::get('podnoobs'));
             $list->setMonth($this->month);
             $list->setYear($this->year);
             $table = new TopTable_Pilot($list, "Kills");
             $smarty->assign('monthly_stats', $table->generate());
             $list = new TopList_DamageDealer();
             $list->addInvolvedCorp($this->crp_id);
             $list->setPodsNoobShips(config::get('podnoobs'));
             $table = new TopTable_Pilot($list, "Kills");
             $smarty->assign('total_stats', $table->generate());
             return $smarty->fetch(get_tpl('detail_kl_monthly'));
             break;
         case "pilot_griefer":
             $smarty->assign('title', 'Top Griefers');
             $smarty->assign('month', $this->monthname);
             $smarty->assign('year', $this->year);
             $smarty->assign('pmonth', $this->pmonth);
             $smarty->assign('pyear', $this->pyear);
             $smarty->assign('nmonth', $this->nmonth);
             $smarty->assign('nyear', $this->nyear);
             $smarty->assign('crp_id', $this->crp_id);
             $smarty->assign('url_previous', edkURI::build($args, array('view', 'pilot_griefer', true), $pyear, $pmonth));
             $smarty->assign('url_next', edkURI::build($args, array('view', 'pilot_griefer', true), $nyear, $nmonth));
             $list = new TopList_Kills();
             $list->addVictimShipClass(20);
             // freighter
             $list->addVictimShipClass(22);
             // exhumer
             $list->addVictimShipClass(7);
             // industrial
             $list->addVictimShipClass(12);
             // barge
             $list->addVictimShipClass(14);
             // transport
             $list->addInvolvedCorp($this->crp_id);
             $list->setMonth($this->month);
             $list->setYear($this->year);
             $table = new TopTable_Pilot($list, "Kills");
             $smarty->assign('monthly_stats', $table->generate());
             $list = new TopList_Kills();
             $list->addVictimShipClass(20);
             // freighter
             $list->addVictimShipClass(22);
             // exhumer
             $list->addVictimShipClass(7);
             // industrial
             $list->addVictimShipClass(12);
             // barge
             $list->addVictimShipClass(14);
             // transport
             $list->addInvolvedCorp($this->crp_id);
             $table = new TopTable_Pilot($list, "Kills");
             $smarty->assign('total_stats', $table->generate());
             return $smarty->fetch(get_tpl('detail_kl_monthly'));
             break;
         case "pilot_losses":
             $smarty->assign('title', 'Top Losers');
             $smarty->assign('month', $this->monthname);
             $smarty->assign('year', $this->year);
             $smarty->assign('pmonth', $this->pmonth);
             $smarty->assign('pyear', $this->pyear);
             $smarty->assign('nmonth', $this->nmonth);
             $smarty->assign('nyear', $this->nyear);
             $smarty->assign('crp_id', $this->crp_id);
             $smarty->assign('url_previous', edkURI::build($args, array('view', 'pilot_losses', true), $pyear, $pmonth));
             $smarty->assign('url_next', edkURI::build($args, array('view', 'pilot_losses', true), $nyear, $nmonth));
             $list = new TopList_Losses();
             $list->addVictimCorp($this->crp_id);
             $list->setPodsNoobShips(config::get('podnoobs'));
             $list->setMonth($this->month);
             $list->setYear($this->year);
             $table = new TopTable_Pilot($list, "Losses");
             $smarty->assign('monthly_stats', $table->generate());
             $list = new TopList_Losses();
             $list->addVictimCorp($this->crp_id);
             $list->setPodsNoobShips(config::get('podnoobs'));
             $table = new TopTable_Pilot($list, "Losses");
             $smarty->assign('total_stats', $table->generate());
             return $smarty->fetch(get_tpl('detail_kl_monthly'));
             break;
         case "ships_weapons":
             $shiplist = new TopList_Ship();
             $shiplist->addInvolvedCorp($this->crp_id);
             $shiplisttable = new TopTable_Ship($shiplist);
             $smarty->assign('ships', $shiplisttable->generate());
             $weaponlist = new TopList_Weapon();
             $weaponlist->addInvolvedCorp($this->crp_id);
             $weaponlisttable = new TopTable_Weapon($weaponlist);
             $smarty->assign('weapons', $weaponlisttable->generate());
             return $smarty->fetch(get_tpl('detail_kl_ships_weapons'));
             break;
         case 'history':
             $crpsum = new corpSummary($this->crp_id);
             $smarty->assign('title', Language::get('history'));
             $smarty->assign('summary', $crpsum->getMonthlySummary());
             return $smarty->fetch(get_tpl('detail_history'));
             break;
         case 'violent_systems':
             $smarty->assign('title', 'Most violent systems');
             $smarty->assign('month', $this->monthname);
             $smarty->assign('year', $this->year);
             $smarty->assign('pmonth', $this->pmonth);
             $smarty->assign('pyear', $this->pyear);
             $smarty->assign('nmonth', $this->nmonth);
             $smarty->assign('nyear', $this->nyear);
             $smarty->assign('crp_id', $this->crp_id);
             $smarty->assign('url_previous', edkURI::build($args, array('view', 'violent_systems', true), $pyear, $pmonth));
             $smarty->assign('url_next', edkURI::build($args, array('view', 'violent_systems', true), $nyear, $nmonth));
             $startdate = gmdate('Y-m-d H:i', makeStartDate(0, $this->year, $this->month));
             $enddate = gmdate('Y-m-d H:i', makeEndDate(0, $this->year, $this->month));
             $sql = "select sys.sys_name, sys.sys_sec, sys.sys_id, count(kll.kll_id) as kills\n\t\t\t\t\t\t\tfrom kb3_systems sys, kb3_kills kll, kb3_inv_crp inc\n\t\t\t\t\t\t\twhere kll.kll_system_id = sys.sys_id\n\t\t\t\t\t\t\tand inc.inc_kll_id = kll.kll_id\n\t\t\t\t\t\t\tand inc.inc_crp_id = " . $this->crp_id;
             $sql .= "   and kll.kll_timestamp > '{$startdate}'\n\t\t\t\t\t\t\tand kll.kll_timestamp < '{$enddate}'\n\t\t\t\t\t\t\tand inc.inc_timestamp > '{$startdate}'\n\t\t\t\t\t\t\tand inc.inc_timestamp < '{$enddate}'\n\t\t\t\t\t\t\tgroup by sys.sys_id\n\t\t\t\t\t\t\torder by kills desc, sys.sys_name asc\n\t\t\t\t\t\t\tlimit 25";
             $qry = DBFactory::getDBQuery();
             $qry->execute($sql);
             $odd = false;
             $counter = 1;
             $syslist = array();
             while ($row = $qry->getRow()) {
                 if (!$odd) {
                     $odd = true;
                     $rowclass = 'kb-table-row-odd';
                 } else {
                     $odd = false;
                     $rowclass = 'kb-table-row-even';
                 }
                 $syslist[] = array("counter" => $counter, "url" => edkURI::build(array(array('a', 'system_detail', true), array('sys_id', $row['sys_id'], true))), "name" => $row['sys_name'], "sec" => roundsec($row['sys_sec']), "kills" => $row['kills']);
                 $counter++;
             }
             $smarty->assignByRef('syslist', $syslist);
             $smarty->assign('monthly_stats', $smarty->fetch(get_tpl('violent_systems')));
             $sql = "select sys.sys_name, sys.sys_id, sys.sys_sec, count(kll.kll_id) as kills\n\t\t\t\t\t\t\tfrom kb3_systems sys, kb3_kills kll, kb3_inv_crp inc\n\t\t\t\t\t\t\twhere kll.kll_system_id = sys.sys_id\n\t\t\t\t\t\t\tand inc.inc_kll_id = kll.kll_id\n\t\t\t\t\t\t\tand inc.inc_crp_id = " . $this->crp_id;
             $sql .= " group by sys.sys_id\n\t\t\t\t\t\t\torder by kills desc, sys.sys_name asc\n\t\t\t\t\t\t\tlimit 25";
             $qry = DBFactory::getDBQuery();
             $qry->execute($sql);
             $odd = false;
             $counter = 1;
             $syslist = array();
             while ($row = $qry->getRow()) {
                 if (!$odd) {
                     $odd = true;
                     $rowclass = 'kb-table-row-odd';
                 } else {
                     $odd = false;
                     $rowclass = 'kb-table-row-even';
                 }
                 $syslist[] = array("counter" => $counter, "url" => edkURI::build(array(array('a', 'system_detail', true), array('sys_id', $row['sys_id'], true))), "name" => $row['sys_name'], "sec" => roundsec($row['sys_sec']), "kills" => $row['kills']);
                 $counter++;
             }
             $smarty->assignByRef('syslist', $syslist);
             $smarty->assign('total_stats', $smarty->fetch(get_tpl('violent_systems')));
             return $smarty->fetch(get_tpl('detail_kl_monthly'));
             break;
     }
     return $html;
 }