function getkills()
 {
     $this->entry = array();
     // as there is no way to do this elegant in sql
     // i'll keep it in php
     $sql = "select scl_id, scl_class from kb3_ship_classes\n               where scl_class not in ('Drone','Unknown') order by scl_class";
     $qry = DBFactory::getDBQuery();
     $qry->execute($sql);
     while ($row = $qry->getRow()) {
         $this->entry[$row['scl_class']] = array('id' => $row['scl_id'], 'kills' => 0, 'kills_isk' => 0);
     }
     $startdate = makeStartDate($this->weekno, $this->yearno, $this->monthno, $this->startweekno, $this->startDate);
     $enddate = makeEndDate($this->weekno, $this->yearno, $this->monthno, $this->endDate);
     $sql = 'SELECT count(kll.kll_id) AS knb, scl_id, scl_class,';
     $sql .= ' sum(kll_isk_loss) AS kisk FROM kb3_kills kll
                 INNER JOIN kb3_ships shp ON ( shp.shp_id = kll.kll_ship_id )';
     $sql .= ' INNER JOIN kb3_ship_classes scl ON ( scl.scl_id = shp.shp_class )';
     if ($this->inv_crp) {
         $sql .= ' inner join kb3_inv_detail ind on ( ind.ind_crp_id in ( ' . join(',', $this->inv_crp) . ' ) and kll.kll_id = ind.ind_kll_id ) ';
     } else {
         if ($this->inv_all) {
             $sql .= ' inner join kb3_inv_detail ind on ( ind.ind_all_id in ( ' . join(',', $this->inv_all) . ' ) and kll.kll_id = ind.ind_kll_id ) ';
         }
     }
     $sqlop = " WHERE ";
     if ($this->system) {
         $sql .= $sqlop . " kll.kll_system_id in " . join(',', $this->system) . " ";
     }
     if ($startdate) {
         $sql .= $sqlop . " kll.kll_timestamp >= '" . gmdate('Y-m-d H:i', $startdate) . "' ";
         $sqlop = " AND ";
     }
     if ($enddate) {
         $sql .= $sqlop . " kll.kll_timestamp <= '" . gmdate('Y-m-d H:i', $enddate) . "' ";
     }
     $sql .= 'GROUP BY shp.shp_class';
     if ($this->inv_crp || $this->inv_all) {
         $sql .= ', kll.kll_id';
     }
     $sql .= ' order by scl.scl_class';
     $qry = DBFactory::getDBQuery();
     $qry->execute($sql);
     while ($row = $qry->getRow()) {
         $this->entry[$row['scl_class']]['kills'] = $row['knb'];
         $this->entry[$row['scl_class']]['kills_isk'] = $row['kisk'];
         $this->tkcount += $row['knb'];
         $this->tkisk += $row['kisk'];
     }
 }
 /**
  * Fetch all kills.
  */
 function getkills()
 {
     if ($this->setDateFilter() == "" && empty($this->system)) {
         if (count($this->inv_all) == 1 && !$this->inv_crp && !$this->inv_plt) {
             $allsum = new allianceSummary($this->inv_all[0]);
             $summary = $allsum->getSummary();
             foreach ($summary as $key => $row) {
                 $this->entry[$row['class_name']] = array('id' => $key, 'kills' => $row['killcount'], 'kills_isk' => $row['killisk'], 'losses' => $row['losscount'], 'losses_isk' => $row['lossisk']);
                 $this->tkcount += $row['killcount'];
                 $this->tkisk += $row['killisk'];
                 $this->tlcount += $row['losscount'];
                 $this->tlisk += $row['lossisk'];
                 if (!in_array($key, array(2, 3, 11))) {
                     $this->trkcount += $row['killcount'];
                 }
             }
             return;
         } elseif (count($this->inv_crp) == 1 && !$this->inv_all && !$this->inv_plt) {
             $crpsum = new corpSummary($this->inv_crp[0]);
             $summary = $crpsum->getSummary();
             foreach ($summary as $key => $row) {
                 $this->entry[$row['class_name']] = array('id' => $key, 'kills' => $row['killcount'], 'kills_isk' => $row['killisk'], 'losses' => $row['losscount'], 'losses_isk' => $row['lossisk']);
                 $this->tkcount += $row['killcount'];
                 $this->tkisk += $row['killisk'];
                 $this->tlcount += $row['losscount'];
                 $this->tlisk += $row['lossisk'];
                 if (!in_array($key, array(2, 3, 11))) {
                     $this->trkcount += $row['killcount'];
                 }
             }
             return;
         } elseif (count($this->inv_plt) == 1 && !$this->inv_all && !$this->inv_crp) {
             $pltsum = new pilotSummary($this->inv_plt[0]);
             $summary = $pltsum->getSummary();
             foreach ($summary as $key => $row) {
                 $this->entry[$row['class_name']] = array('id' => $key, 'kills' => $row['killcount'], 'kills_isk' => $row['killisk'], 'losses' => $row['losscount'], 'losses_isk' => $row['lossisk']);
                 $this->tkcount += $row['killcount'];
                 $this->tkisk += $row['killisk'];
                 $this->tlcount += $row['losscount'];
                 $this->tlisk += $row['lossisk'];
                 if (!in_array($key, array(-1, 2, 3, 11))) {
                     $this->trkcount += $row['killcount'];
                 }
             }
             $qry = DBFactory::getDBQuery();
             $qry->execute("SELECT plt_lpoints, plt_kpoints FROM kb3_pilots WHERE plt_id=" . $this->inv_plt[0]);
             if ($qry->recordCount()) {
                 $row = $qry->getRow();
                 $this->tlpoints = $row['plt_lpoints'];
                 $this->tkpoints = $row['plt_kpoints'];
             }
             return;
         }
     }
     $this->entry = array();
     // as there is no way to do this elegantly in sql
     // i'll keep it in php
     $sql = "select scl_id, scl_class from kb3_ship_classes\n               where scl_class not in ('Drone','Unknown') order by scl_class";
     $startdate = makeStartDate($this->weekno, $this->yearno, $this->monthno, $this->startweekno, $this->startDate);
     $enddate = makeEndDate($this->weekno, $this->yearno, $this->monthno, $this->endDate);
     $qry = DBFactory::getDBQuery();
     $qry->execute($sql);
     while ($row = $qry->getRow()) {
         $this->entry[$row['scl_class']] = array('id' => $row['scl_id'], 'kills' => 0, 'kills_isk' => 0, 'losses' => 0, 'losses_isk' => 0);
     }
     $sql = 'SELECT count(kll.kll_id) AS knb, scl_id, scl_class,';
     $sql .= ' sum(kll_isk_loss) AS kisk FROM kb3_kills kll
                 INNER JOIN kb3_ships shp ON ( shp.shp_id = kll.kll_ship_id )';
     $sql .= ' INNER JOIN kb3_ship_classes scl ON ( scl.scl_id = shp.shp_class )';
     $sqlop = " WHERE ";
     $invcount = count($this->inv_all) + count($this->inv_crp) + count($this->inv_plt);
     if ($invcount == 0) {
         if ($startdate) {
             $sql .= $sqlop . " kll.kll_timestamp >= '" . gmdate('Y-m-d H:i', $startdate) . "' ";
             $sqlop = " AND ";
         }
         if ($enddate) {
             $sql .= $sqlop . " kll.kll_timestamp <= '" . gmdate('Y-m-d H:i', $enddate) . "' ";
             $sqlop = " AND ";
         }
     } else {
         $sql .= "INNER JOIN (";
         $involved = array();
         if ($this->inv_all) {
             $invsql = "SELECT ina_kll_id as kll_id FROM kb3_inv_all\n\t\t\t\t\tWHERE ina_all_id in (" . implode(',', $this->inv_all) . ") ";
             if ($startdate) {
                 $invsql .= " AND ina_timestamp >= '" . gmdate('Y-m-d H:i', $startdate) . "' ";
             }
             if ($enddate) {
                 $invsql .= " AND ina_timestamp <= '" . gmdate('Y-m-d H:i', $enddate) . "' ";
             }
             $involved[] = $invsql;
         }
         if ($this->inv_crp) {
             $invsql = "SELECT inc_kll_id as kll_id FROM kb3_inv_crp\n\t\t\t\t\tWHERE inc_crp_id in (" . implode(',', $this->inv_crp) . ") ";
             if ($startdate) {
                 $invsql .= " AND inc_timestamp >= '" . gmdate('Y-m-d H:i', $startdate) . "' ";
             }
             if ($enddate) {
                 $invsql .= " AND inc_timestamp <= '" . gmdate('Y-m-d H:i', $enddate) . "' ";
             }
             $involved[] = $invsql;
         }
         if ($this->inv_plt) {
             $invsql = "SELECT ind_kll_id as kll_id FROM kb3_inv_detail\n\t\t\t\t\tWHERE ind_plt_id in (" . implode(',', $this->inv_plt) . ") ";
             if ($startdate) {
                 $invsql .= " AND ind_timestamp >= '" . gmdate('Y-m-d H:i', $startdate) . "' ";
             }
             if ($enddate) {
                 $invsql .= " AND ind_timestamp <= '" . gmdate('Y-m-d H:i', $enddate) . "' ";
             }
             $involved[] = $invsql;
         }
         $invtypecount = 0;
         if ($this->inv_all) {
             $invtypecount++;
         }
         if ($this->inv_crp) {
             $invtypecount++;
         }
         if ($this->inv_plt) {
             $invtypecount++;
         }
         $sql .= "(" . implode(") UNION (", $involved);
         if ($invtypecount == 1) {
             $sql .= " GROUP BY kll_id";
         }
         $sql .= ") ) inv ON inv.kll_id = kll.kll_id ";
     }
     if ($this->system) {
         $sql .= $sqlop . " kll.kll_system_id = " . join(',', $this->system) . " ";
         $sqlop = " AND ";
     }
     $sql .= 'GROUP BY scl_class order by scl_class';
     $qry = DBFactory::getDBQuery();
     $qry->execute($sql);
     while ($row = $qry->getRow()) {
         $this->entry[$row['scl_class']]['kills'] = $row['knb'];
         $this->entry[$row['scl_class']]['kills_isk'] = $row['kisk'];
         $this->tkcount += $row['knb'];
         $this->tkisk += $row['kisk'];
     }
     // LEFT JOIN to kb3_inv_all or kb3_inv_crp if only one type of entity
     // otherwise LEFT JOIN to kb3_inv_detail
     $sql = 'SELECT count( kll_id) AS lnb, scl_id, scl_class,';
     $sql .= ' sum(kll_isk_loss) AS lisk FROM kb3_kills kll
                 INNER JOIN kb3_ships shp ON ( shp.shp_id = kll.kll_ship_id )';
     $sql .= ' INNER JOIN kb3_ship_classes scl ON ( scl.scl_id = shp.shp_class )';
     if ($this->inv_all) {
         if (!($this->inv_crp || $this->inv_plt)) {
             $sql .= ' LEFT JOIN kb3_inv_all ina ON (kll.kll_id = ina.ina_kll_id AND kll.kll_all_id = ina.ina_all_id)';
         } else {
             $sql .= ' LEFT JOIN kb3_inv_detail ind ON (kll.kll_id = ind.ind_kll_id AND (kll.kll_all_id = ind.ind_all_id ';
             if ($this->inv_crp) {
                 $sql .= ' OR kll.kll_crp_id = ind.ind_crp_id';
             }
             if ($this->inv_plt) {
                 $sql .= ' OR kll.kll_victim_id = ind.ind_plt_id';
             }
             $sql .= ') )';
         }
     } elseif ($this->inv_crp) {
         if (!$this->inv_plt) {
             $sql .= ' LEFT JOIN kb3_inv_crp inc ON (kll.kll_id = inc.inc_kll_id AND kll.kll_crp_id = inc.inc_crp_id)';
         } else {
             $sql .= ' LEFT JOIN kb3_inv_detail ind ON (kll.kll_id = ind.ind_kll_id AND (kll.kll_crp_id = ind.ind_crp_id';
             $sql .= ' OR kll.kll_victim_id = ind.ind_plt_id))';
         }
     }
     $sqlop = ' WHERE ';
     if ($this->setDateFilter()) {
         $sql .= $sqlop . $this->setDateFilter();
         $sqlop = " AND ";
     }
     if ($invcount) {
         if ($this->inv_all && !($this->inv_crp || $this->inv_plt)) {
             $sql .= $sqlop . ' ina.ina_kll_id IS NULL ';
             $sqlop = " AND ";
         } else {
             if ($this->inv_crp && !($this->inv_plt || $this->inv_all)) {
                 $sql .= $sqlop . ' inc.inc_kll_id IS NULL ';
                 $sqlop = " AND ";
             } else {
                 if (!($this->inv_plt && !($this->inv_crp || $this->inv_all))) {
                     $sql .= $sqlop . ' ind.ind_kll_id IS NULL ';
                     $sqlop = " AND ";
                 }
             }
         }
         $invP = array();
         if ($this->inv_all) {
             $invP[] = 'kll.kll_all_id IN ( ' . implode(',', $this->inv_all) . ' ) ';
         }
         if ($this->inv_crp) {
             $invP[] = 'kll.kll_crp_id IN ( ' . implode(',', $this->inv_crp) . ' ) ';
         }
         if ($this->inv_plt) {
             $invP[] = 'kll.kll_victim_id IN ( ' . implode(',', $this->inv_plt) . ' ) ';
         }
         if ($invP) {
             $sql .= $sqlop . " (" . implode(' OR ', $invP) . ") ";
             $sqlop = " AND ";
         }
     }
     if ($this->system) {
         $sql .= $sqlop . " kll.kll_system_id = " . join(',', $this->system) . " ";
     }
     $sql .= 'GROUP BY scl_class order by scl_class';
     $qry = DBFactory::getDBQuery();
     $qry->execute($sql);
     while ($row = $qry->getRow()) {
         $this->entry[$row['scl_class']]['losses'] = $row['lnb'];
         $this->entry[$row['scl_class']]['losses_isk'] = $row['lisk'];
         $this->tlcount += $row['lnb'];
         $this->tlisk += $row['lisk'];
     }
 }
 function loadTime(&$object)
 {
     if ($this->week) {
         $object->setWeek($this->week);
         $object->setYear($this->year);
     } elseif ($this->month) {
         $start = makeStartDate($this->week, $this->year, $this->month);
         $end = makeEndDate($this->week, $this->year, $this->month);
         $object->setStartDate(gmdate('Y-m-d H:i', $start));
         $object->setEndDate(gmdate('Y-m-d H:i', $end));
         //die('start='.gmdate('Y-m-d H:i',$start).'end='.gmdate('Y-m-d H:i',$end));
     }
 }
 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'));
 }
Example #5
0
 /**
  * Convert given date ranges to SQL date range.
  * @return mixed string containing SQL date filter.
  */
 public function getDateFilter()
 {
     $sql = '';
     $qstartdate = makeStartDate($this->weekno_, $this->yearno_, $this->monthno_, $this->startweekno_, $this->startDate_);
     $qenddate = makeEndDate($this->weekno_, $this->yearno_, $this->monthno_, $this->endDate_);
     if ($this->inv_all_ || $this->inv_crp_ || $this->inv_plt_) {
         if ($qstartdate) {
             $sql .= " kll.kll_timestamp >= '" . gmdate('Y-m-d H:i', $qstartdate) . "' AND ";
         }
         if ($qenddate) {
             $sql .= " kll.kll_timestamp <= '" . gmdate('Y-m-d H:i', $qenddate) . "' AND ";
         }
         if ($qstartdate) {
             $sql .= " ind.ind_timestamp >= '" . gmdate('Y-m-d H:i', $qstartdate) . "' ";
         }
         if ($qstartdate && $qenddate) {
             $sql .= " AND ";
         }
         if ($qenddate) {
             $sql .= " ind.ind_timestamp <= '" . gmdate('Y-m-d H:i', $qenddate) . "' ";
         }
     } else {
         if ($qstartdate) {
             $sql .= " kll.kll_timestamp >= '" . gmdate('Y-m-d H:i', $qstartdate) . "' ";
         }
         if ($qstartdate && $qenddate) {
             $sql .= " AND ";
         }
         if ($qenddate) {
             $sql .= " kll.kll_timestamp <= '" . gmdate('Y-m-d H:i', $qenddate) . "' ";
         }
     }
     return $sql;
 }
Example #6
0
 /**
  * Set start and end dates on any object passed in.
  * @param mixed $object Accepts any object with setStartDate & setEndDate
  */
 function loadTime(&$object)
 {
     if ($this->day) {
         $object->setStartDate("{$this->year}-{$this->month}-{$this->day}" . " 00:00");
         $object->setEndDate("{$this->year}-{$this->month}-{$this->day}" . " 23:59");
     } else {
         if ($this->week) {
             $object->setWeek($this->week);
             $object->setYear($this->year);
         } elseif ($this->month) {
             $start = makeStartDate($this->week, $this->year, $this->month);
             $end = makeEndDate($this->week, $this->year, $this->month);
             $object->setStartDate(gmdate('Y-m-d H:i', $start));
             $object->setEndDate(gmdate('Y-m-d H:i', $end));
         }
     }
 }
Example #7
0
 function getDateFilter($field = "kll.kll_timestamp")
 {
     $sql = "";
     if (is_null($this->finalStartDate)) {
         $this->finalStartDate = makeStartDate($this->weekno_, $this->yearno_, $this->monthno_, $this->startweekno_, $this->startDate_);
         $this->finalEndDate = makeEndDate($this->weekno_, $this->yearno_, $this->monthno_, $this->endDate_);
     }
     if ($this->finalStartDate || $this->finalEndDate) {
         if ($this->finalStartDate) {
             $sql .= " {$field} >= '" . gmdate('Y-m-d H:i', $this->finalStartDate) . "' ";
         }
         if ($this->finalStartDate && $this->finalEndDate) {
             $sql .= " AND ";
         }
         if ($this->finalEndDate) {
             $sql .= " {$field} <= '" . gmdate('Y-m-d H:i', $this->finalEndDate) . "' ";
         }
     }
     return $sql;
 }
Example #8
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 '';
 }
Example #9
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;
 }