Пример #1
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 '';
 }
Пример #2
0
    function generate()
    {
        $this->cachefile = $this->getCacheFileName();
        $this->checkCache();
        if ($this->mode_ == "map") {
            $sql = 'SELECT sys.sys_x, sys.sys_y, sys.sys_z, sys.sys_sec, sys.sys_id, sjp.sjp_to, reg.reg_id
					FROM (kb3_systems sys, kb3_constellations con, kb3_regions reg)
					LEFT JOIN kb3_system_jumps sjp on sjp.sjp_from = sys.sys_id
					WHERE con.con_id = sys.sys_con_id
					AND reg.reg_id = con.con_reg_id';
            $caption = $this->regname_;
        } elseif ($this->mode_ == "region") {
            $sql = 'SELECT sys.sys_x, sys.sys_y, sys.sys_z, sys.sys_sec, sys.sys_name, sys.sys_id, sjp.sjp_to, con_id
					FROM (kb3_systems sys, kb3_constellations con)
					LEFT JOIN kb3_system_jumps sjp ON sjp.sjp_from = sys.sys_id
					WHERE con.con_id = sys.sys_con_id
					AND con.con_reg_id = ' . $this->regionid_;
            $caption = $this->conname_;
        } elseif ($this->mode_ == "cons") {
            $sql = 'SELECT sys.sys_x, sys.sys_y, sys.sys_z, sys.sys_sec, sys.sys_name, sys.sys_id, sjp.sjp_to, con.con_name
					FROM (kb3_systems sys, kb3_constellations con)
					LEFT JOIN kb3_system_jumps sjp ON sjp.sjp_from = sys.sys_id
					WHERE con.con_id = sys.sys_con_id
					AND con.con_id = ' . $this->conid_;
            $caption = $this->sysname_ . " (" . roundsec($this->syssec_) . ")";
        }
        if ($this->systemid_ >= 31000007) {
            $sql .= " AND sys.sys_id >= 31000007";
        } else {
            $sql .= " AND sys.sys_id < 31000007";
        }
        $qry = DBFactory::getDBQuery();
        $qry->execute($sql) or die($qry->getErrorMsg());
        $img = imagecreatetruecolor($this->imgwidth_, $this->imgheight_);
        $white = imagecolorallocate($img, 255, 255, 255);
        $red = imagecolorallocate($img, 255, 0, 0);
        $bgcolor = imagecolorallocate($img, $this->bgcolor_[0], $this->bgcolor_[1], $this->bgcolor_[2]);
        imagefilledrectangle($img, 0, 0, $this->imgwidth_, $this->imgheight_, $bgcolor);
        $color = $white;
        $fov = 0;
        $i = 0;
        $minx = 0;
        $minz = 0;
        $maxx = 0;
        $maxz = 0;
        $mini = 0;
        $maxi = 0;
        $pi = 0;
        $sc = 0;
        while ($row = $qry->getRow()) {
            $i = $row['sys_id'];
            if ($i < $mini || $mini == 0) {
                $mini = $i;
            }
            if ($i > $maxi || $maxi == 0) {
                $maxi = $i;
            }
            $x = $row['sys_x'] * $this->ly_;
            $z = $row['sys_z'] * $this->ly_;
            if ($x < $minx || $minx == 0) {
                $minx = $x;
            }
            if ($x > $maxx || $maxx == 0) {
                $maxx = $x;
            }
            if ($z < $minz || $minz == 0) {
                $minz = $z;
            }
            if ($z > $maxz || $maxz == 0) {
                $maxz = $z;
            }
            $sys[$i][0] = $x;
            $sys[$i][1] = $z;
            if ($this->showlines_) {
                if ($i == $pi || $pi == 0) {
                    $sys[$i][2][$sc] = $row['sjp_to'];
                    $sc++;
                } else {
                    $sc = 0;
                }
            }
            if ($this->mode_ == "map" && $this->regionid_ == $row['reg_id']) {
                $sys[$i][9] = true;
            } elseif ($this->mode_ == "region" && $this->conid_ == $row['con_id']) {
                $sys[$i][7] = $row['con_id'];
            } elseif ($this->mode_ == "cons") {
                $sys[$i][5] = $row['sys_name'];
            }
            $sys[$i][6] = $row['sys_sec'];
            $pi = $i;
        }
        unset($qry);
        $dx = abs($maxx - $minx);
        $dz = abs($maxz - $minz);
        $xscale = 1 / ($dx / ($this->imgwidth_ - $this->offset_ * 2));
        $yscale = 1 / ($dz / ($this->imgheight_ - $this->offset_ * 2));
        if ($_GET['debug'] == 'admovrd') {
            echo "dx:" . $dx . " dz:" . $dz . "<br/> xscale:" . $xscale . " " . $yscale . "<br/>";
            echo "minx:" . $minx . " maxx:" . $maxx . "<br/>";
            echo "minz:" . $minz . " maxz:" . $maxz . "<br/>" . $sql . "<br/>\n";
            echo nl2br(print_r($this, 1));
            echo nl2br(print_r($qry, 1));
        }
        // draw lines
        if ($this->showlines_) {
            $n = $mini;
            while ($n <= $maxi) {
                if (!isset($sys[$n])) {
                    $n++;
                    continue;
                }
                $px = $this->offset_ + ($sys[$n][0] - $minx) * $xscale;
                $py = $this->offset_ + ($sys[$n][1] - $minz) * $yscale;
                $line_col = imagecolorallocate($img, $this->linecolor_[0], $this->linecolor_[1], $this->linecolor_[2]);
                if (isset($sys[$n][2])) {
                    foreach ($sys[$n][2] as $sys_to) {
                        if (isset($sys[$sys_to])) {
                            $px_to = $this->offset_ + ($sys[$sys_to][0] - $minx) * $xscale;
                            $py_to = $this->offset_ + ($sys[$sys_to][1] - $minz) * $yscale;
                            imageline($img, $px, $py, $px_to, $py_to, $line_col);
                        }
                    }
                }
                $n++;
            }
        }
        // draw systems
        $n = $mini;
        while ($n <= $maxi) {
            if (!isset($sys[$n])) {
                $n++;
                continue;
            }
            $px = round($this->offset_ + ($sys[$n][0] - $minx) * $xscale);
            $py = round($this->offset_ + ($sys[$n][1] - $minz) * $yscale);
            if ($this->mode_ == "map") {
                if (isset($sys[$n][9])) {
                    $color = imagecolorallocate($img, $this->hlcolor_[0], $this->hlcolor_[1], $this->hlcolor_[2]);
                } else {
                    $color = $this->secColor($img, $sys[$n][6]);
                }
            }
            if ($this->mode_ == "region") {
                if (isset($sys[$n][7])) {
                    $color = imagecolorallocate($img, $this->hlcolor_[0], $this->hlcolor_[1], $this->hlcolor_[2]);
                } else {
                    $color = $this->secColor($img, $sys[$n][6]);
                }
            }
            if ($this->mode_ == "cons") {
                if ($n == $this->systemid_) {
                    $color = imagecolorallocate($img, $this->hlcolor_[0], $this->hlcolor_[1], $this->hlcolor_[2]);
                } else {
                    $color = $this->secColor($img, $sys[$n][6]);
                }
            }
            if ($this->showsysnames_) {
                $tlen = 5 * strlen($sys[$n][5]);
                if ($px + $tlen > $this->imgwidth_ - 20) {
                    $sx = $px - $tlen;
                } else {
                    $sx = $px + 5;
                }
                if ($py + 5 > $this->imgheight_ - 20) {
                    $sy = $py - 5;
                } else {
                    $sy = $py + 5;
                }
                imagestring($img, 1, $sx, $sy, $sys[$n][5], $color);
                // imagettftext ( $img, 6, 0,
                // $sx,
                // $sy,
                // $color,
                // "../fonts/04B_03__.TTF",
                // $sys[$n][5] );
            }
            $ed = $xscale * 0.75;
            if ($ed > 5) {
                $ed = 5;
            }
            // bug compat: imagefilledellipse doesnt draw ellipses with 1px size
            // on some installations
            if ($ed < 1) {
                imagesetpixel($img, $px, $py, $color);
            } elseif ($ed < 3) {
                imagesetpixel($img, $px, $py, $color);
                imagesetpixel($img, $px + 1, $py, $color);
                imagesetpixel($img, $px - 1, $py, $color);
                imagesetpixel($img, $px, $py - 1, $color);
                imagesetpixel($img, $px, $py + 1, $color);
            } else {
                imagefilledellipse($img, $px, $py, $ed, $ed, $color);
            }
            $n++;
        }
        $captioncolor = imagecolorallocate($img, $this->captioncolor_[0], $this->captioncolor_[1], $this->captioncolor_[2]);
        if (strlen($this->title_) > 0) {
            $title = $this->title_ . " " . $caption;
        } else {
            $title = $caption;
        }
        imagestring($img, 1, 2, 2, $title, $captioncolor);
        imagepng($img, $this->cachefile);
        header("Content-type: image/png");
        imagepng($img);
    }
Пример #3
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;
 }