root/dev/common/alliance_detail.php @ 155

Revision 155, 14.7 KB (checked in by exi, 16 years ago)

Added option to paint systems on maps based on security rating.
Added most violent systems statistic to corp and alliance details.
Some fixes for files with short php tags.
Fixed a bug which prevented sql errors to halt page generation if enabled in config.
Added system details as whole page instead of a js popup for maps.
Battle summaries should now work if the hour of the kill is less than 10.
Removed obsolete stats.php.

Line 
1<?php
2require_once("db.php");
3require_once("class.page.php");
4require_once("class.corp.php");
5require_once("class.alliance.php");
6require_once("class.killlist.php");
7require_once("class.killlisttable.php");
8require_once("class.killsummarytable.php");
9require_once("class.box.php");
10require_once("class.toplist.php");
11
12$alliance = new Alliance(intval($_GET['all_id']));
13$page = new Page("Alliance details - " . $alliance->getName());
14
15$html .= "<table class=kb-table width=\"100%\" border=\"0\" cellspacing=1><tr class=kb-table-row-even><td rowspan=8 width=128 align=center bgcolor=black>";
16
17if (file_exists("img/alliances/".$alliance->getUnique().".png"))
18{
19    $html .= "<img src=\"".IMG_URL."/alliances/".$alliance->getUnique().".png\" border=\"0\"></td>";
20}
21else
22{
23    $html .= "<img src=\"".IMG_URL."/alliances/default.gif\" border=\"0\"></td>";
24}
25$kill_summary = new KillSummaryTable();
26$kill_summary->addInvolvedAlliance($alliance);
27$kill_summary->setBreak(6);
28$summary_html = $kill_summary->generate();
29
30$html .= "<td class=kb-table-cell width=180><b>Kills:</b></td><td class=kl-kill>".$kill_summary->getTotalKills()."</td></tr>";
31$html .= "<tr class=kb-table-row-even><td class=kb-table-cell><b>Losses:</b></td><td class=kl-loss>".$kill_summary->getTotalLosses()."</td></tr>";
32$html .= "<tr class=kb-table-row-even><td class=kb-table-cell><b>Damage done (ISK):</b></td><td class=kl-kill>".round($kill_summary->getTotalKillISK()/1000000, 2)."M</td></tr>";
33$html .= "<tr class=kb-table-row-even><td class=kb-table-cell><b>Damage received (ISK):</b></td><td class=kl-loss>".round($kill_summary->getTotalLossISK()/1000000, 2)."M</td></tr>";
34if ($kill_summary->getTotalKillISK())
35{
36    $efficiency = round($kill_summary->getTotalKillISK() / ($kill_summary->getTotalKillISK() + $kill_summary->getTotalLossISK()) * 100, 2);
37}
38else
39{
40    $efficiency = 0;
41}
42
43$html .= "<tr class=kb-table-row-even><td class=kb-table-cell><b>Efficiency:</b></td><td class=kb-table-cell><b>" . $efficiency . "%</b></td></tr>";
44
45$html .= "</table>";
46$html .= "<br/>";
47
48if ($_GET['view'] == "" || $_GET['view'] == "kills" || $_GET['view'] == "losses")
49{
50    $html .= $summary_html;
51}
52
53switch ($_GET['view'])
54{
55    case "":
56        $html .= "<div class=kb-kills-header>10 Most recent kills</div>";
57
58        $list = new KillList();
59        $list->setOrdered(true);
60        $list->setLimit(10);
61        $list->setPodsNoobships(true);
62        $list->addInvolvedAlliance($alliance);
63        if ($_GET['scl_id'])
64            $list->addVictimShipClass(new ShipClass($_GET['scl_id']));
65
66        $ktab = new KillListTable($list);
67        $ktab->setLimit(10);
68        $ktab->setDayBreak(false);
69        $html .= $ktab->generate();
70
71        $html .= "<div class=kb-losses-header>10 Most recent losses</div>";
72
73        $list = new KillList();
74        $list->setOrdered(true);
75        $list->setLimit(10);
76        $list->setPodsNoobships(true);
77        $list->addVictimAlliance($alliance);
78        if ($_GET['scl_id'])
79            $list->addVictimShipClass(new ShipClass($_GET['scl_id']));
80
81        $ltab = new KillListTable($list);
82        $ltab->setLimit(10);
83        $ltab->setDayBreak(false);
84        $html .= $ltab->generate();
85
86        break;
87    case "kills":
88        $html .= "<div class=kb-kills-header>All kills</div>";
89
90        $list = new KillList();
91        $list->setOrdered(true);
92        $list->addInvolvedAlliance($alliance);
93        if ($_GET['scl_id'])
94            $list->addVictimShipClass(new ShipClass($_GET['scl_id']));
95        $pagesplitter = new PageSplitter($list->getCount(), 30);
96        $list->setPageSplitter($pagesplitter);
97        $table = new KillListTable($list);
98        $table->setDayBreak(false);
99        $html .= $table->generate();
100        $html .= $pagesplitter->generate();
101
102        break;
103    case "losses":
104        $html .= "<div class=kb-losses-header>All losses</div>";
105
106        $list = new KillList();
107        $list->setOrdered(true);
108        $list->setPodsNoobships(true);
109        $list->addVictimAlliance($alliance);
110        if ($_GET['scl_id'])
111            $list->addVictimShipClass(new ShipClass($_GET['scl_id']));
112        $pagesplitter = new PageSplitter($list->getCount(), 30);
113        $list->setPageSplitter($pagesplitter);
114
115        $table = new KillListTable($list);
116        $table->setDayBreak(false);
117        $html .= $table->generate();
118        $html .= $pagesplitter->generate();
119
120        break;
121    case "corp_kills":
122        $html .= "<div class=block-header2>Top killers</div>";
123
124        $html .= "<table class=kb-subtable><tr><td valign=top width=440>";
125        $html .= "<div class=block-header>This month</div>";
126
127        $list = new TopCorpKillsList();
128        $list->addInvolvedAlliance($alliance);
129        $list->setPodsNoobShips(false);
130        $list->setMonth(date("m"));
131        $list->setYear(date("Y"));
132        $table = new TopCorpTable($list, "Kills");
133        $html .= $table->generate();
134
135        $html .= "</td><td valign=top width=400>";
136        $html .= "<div class=block-header>All time</div>";
137
138        $list = new TopCorpKillsList();
139        $list->addInvolvedAlliance($alliance);
140        $list->setPodsNoobShips(false);
141        $table = new TopCorpTable($list, "Kills");
142        $html .= $table->generate();
143
144        $html .= "</td></tr></table>";
145
146        break;
147    case "corp_losses":
148        $html .= "<div class=block-header2>Top losers</div>";
149
150        $html .= "<table class=kb-subtable><tr><td valign=top width=440>";
151        $html .= "<div class=block-header>This month</div>";
152
153        $list = new TopCorpLossesList();
154        $list->addVictimAlliance($alliance);
155        $list->setPodsNoobShips(false);
156        $list->setMonth(date("m"));
157        $list->setYear(date("Y"));
158        $table = new TopCorpTable($list, "Losses");
159        $html .= $table->generate();
160
161        $html .= "</td><td valign=top width=400>";
162        $html .= "<div class=block-header>All time</div>";
163
164        $list = new TopCorpLossesList();
165        $list->addVictimAlliance($alliance);
166        $list->setPodsNoobShips(false);
167        $table = new TopCorpTable($list, "Losses");
168        $html .= $table->generate();
169
170        $html .= "</td></tr></table>";
171
172        break;
173    case "pilot_kills":
174        $html .= "<div class=block-header2>Top killers</div>";
175
176        $html .= "<table class=kb-subtable><tr><td valign=top width=440>";
177        $html .= "<div class=block-header>This month</div>";
178
179        $list = new TopKillsList();
180        $list->addInvolvedAlliance($alliance);
181        $list->setPodsNoobShips(false);
182        $list->setMonth(date("m"));
183        $list->setYear(date("Y"));
184        $table = new TopPilotTable($list, "Kills");
185        $html .= $table->generate();
186
187        $html .= "</td><td valign=top width=400>";
188        $html .= "<div class=block-header>All time</div>";
189
190        $list = new TopKillsList();
191        $list->addInvolvedAlliance($alliance);
192        $list->setPodsNoobShips(false);
193        $table = new TopPilotTable($list, "Kills");
194        $html .= $table->generate();
195
196        $html .= "</td></tr></table>";
197
198        break;
199    case "pilot_scores":
200        $html .= "<div class=block-header2>Top scorers</div>";
201
202        $html .= "<table class=kb-subtable><tr><td valign=top width=440>";
203        $html .= "<div class=block-header>This month</div>";
204
205        $list = new TopScoreList();
206        $list->addInvolvedAlliance($alliance);
207        $list->setPodsNoobShips(true);
208        $list->setMonth(date("m"));
209        $list->setYear(date("Y"));
210        $table = new TopPilotTable($list, "Points");
211        $html .= $table->generate();
212
213        $html .= "</td><td valign=top width=400>";
214        $html .= "<div class=block-header>All time</div>";
215
216        $list = new TopScoreList();
217        $list->addInvolvedAlliance($alliance);
218        $list->setPodsNoobShips(true);
219        $table = new TopPilotTable($list, "Points");
220        $html .= $table->generate();
221
222        $html .= "</td></tr></table>";
223
224        break;
225    case "pilot_losses":
226        $html .= "<div class=block-header2>Top losers</div>";
227
228        $html .= "<table class=kb-subtable><tr><td valign=top width=440>";
229        $html .= "<div class=block-header>This month</div>";
230
231        $list = new TopLossesList();
232        $list->addVictimAlliance($alliance);
233        $list->setPodsNoobShips(false);
234        $list->setMonth(date("m"));
235        $list->setYear(date("Y"));
236        $table = new TopPilotTable($list, "Losses");
237        $html .= $table->generate();
238
239        $html .= "</td><td valign=top width=400>";
240        $html .= "<div class=block-header>All time</div>";
241
242        $list = new TopLossesList();
243        $list->addVictimAlliance($alliance);
244        $list->setPodsNoobShips(false);
245        $table = new TopPilotTable($list, "Losses");
246        $html .= $table->generate();
247
248        $html .= "</td></tr></table>";
249
250        break;
251    case "ships_weapons":
252        $html .= "<div class=block-header2>Ships & weapons used</div>";
253
254        $html .= "<table class=kb-subtable><tr><td valign=top width=400>";
255        $shiplist = new TopShipList();
256        $shiplist->addInvolvedAlliance($alliance);
257        $shiplisttable = new TopShipListTable($shiplist);
258        $html .= $shiplisttable->generate();
259        $html .= "</td><td valign=top align=right width=400>";
260
261        $weaponlist = new TopWeaponList();
262        $weaponlist->addInvolvedAlliance($alliance);
263        $weaponlisttable = new TopWeaponListTable($weaponlist);
264        $html .= $weaponlisttable->generate();
265        $html .= "</td></tr></table>";
266
267        break;
268    case 'violent_systems':
269        $html .= "<div class=block-header2>Most violent systems</div>";
270        $html .= "<table width=\"99%\"><tr><td align=center valign=top>";
271
272        $html .= "<div class=block-header>This month</div>";
273        $html .= "<table class=kb-table>";
274        $html .= "<tr class=kb-table-header><td>#</td><td width=180>System</td><td width=40 align=center >Kills</td></tr>";
275
276        $sql = "select sys.sys_name, sys.sys_sec, sys.sys_id, count(distinct kll.kll_id) as kills
277                    from kb3_systems sys, kb3_kills kll, kb3_inv_detail inv
278                    where kll.kll_system_id = sys.sys_id
279                    and inv.ind_kll_id = kll.kll_id";
280
281        if (CORP_ID)
282            $sql .= " and inv.ind_crp_id in (".CORP_ID.")";
283        if (ALLIANCE_ID)
284            $sql .= " and inv.ind_all_id = ".ALLIANCE_ID;
285
286        $sql .= "   and date_format( kll.kll_timestamp, \"%c\" ) = ".date("m")."
287                    and date_format( kll.kll_timestamp, \"%Y\" ) = ".date("Y")."
288                    group by sys.sys_name
289                    order by kills desc
290                    limit 25";
291
292        $qry = new DBQuery();
293        $qry->execute($sql);
294        $odd = false;
295        $counter = 1;
296        while ($row = $qry->getRow())
297        {
298            if (!$odd)
299            {
300                $odd = true;
301                $rowclass = 'kb-table-row-odd';
302            }
303            else
304            {
305                $odd = false;
306                $rowclass = 'kb-table-row-even';
307            }
308
309            $html .= "<tr class=".$rowclass."><td><b>".$counter.".</b></td><td class=kb-table-cell width=180><b><a href=\"?a=system_detail&amp;sys_id=".$row['sys_id']."\">".$row['sys_name']."</a></b> (".roundsec($row['sys_sec']).")</td><td align=center>".$row['kills']."</td></tr>";
310            $counter++;
311        }
312
313        $html .= "</table>";
314
315        $html .= "</td><td align=center valign=top>";
316        $html .= "<div class=block-header>All-Time</div>";
317        $html .= "<table class=kb-table>";
318        $html .= "<tr class=kb-table-header><td>#</td><td width=180>System</td><td width=40 align=center>Kills</td></tr>";
319
320        $sql = "select sys.sys_name, sys.sys_id, sys.sys_sec, count(distinct kll.kll_id) as kills
321                    from kb3_systems sys, kb3_kills kll, kb3_inv_detail inv
322                    where kll.kll_system_id = sys.sys_id
323                    and inv.ind_kll_id = kll.kll_id";
324
325        if (CORP_ID)
326            $sql .= " and inv.ind_crp_id in (".CORP_ID.")";
327        if (ALLIANCE_ID)
328            $sql .= " and inv.ind_all_id = ".ALLIANCE_ID;
329
330        $sql .= " group by sys.sys_name
331                    order by kills desc
332                    limit 25";
333
334        $qry = new DBQuery();
335        $qry->execute($sql);
336        $odd = false;
337        $counter = 1;
338        while ($row = $qry->getRow())
339        {
340            if (!$odd)
341            {
342                $odd = true;
343                $rowclass = 'kb-table-row-odd';
344            }
345            else
346            {
347                $odd = false;
348                $rowclass = 'kb-table-row-even';
349            }
350
351            $html .= "<tr class=".$rowclass."><td><b>".$counter.".</b></td><td class=kb-table-cell><b><a href=\"?a=system_detail&amp;sys_id=".$row['sys_id']."\">".$row['sys_name']."</a></b> (".roundsec($row['sys_sec']).")</td><td align=center>".$row['kills']."</td></tr>";
352            $counter++;
353        }
354        $html .= "</table>";
355        $html .= "</td></tr></table>";
356    break;
357}
358
359$menubox = new Box("Menu");
360$menubox->setIcon("menu-item.gif");
361$menubox->addOption("caption","Kills & losses");
362$menubox->addOption("link","Recent activity", "?a=alliance_detail&all_id=" . $alliance->getID());
363$menubox->addOption("link","Kills", "?a=alliance_detail&all_id=" . $alliance->getID() . "&view=kills");
364$menubox->addOption("link","Losses", "?a=alliance_detail&all_id=" . $alliance->getID() . "&view=losses");
365$menubox->addOption("caption","Corp statistics");
366$menubox->addOption("link","Top killers", "?a=alliance_detail&all_id=" . $alliance->getID() . "&view=corp_kills");
367$menubox->addOption("link","Top losers", "?a=alliance_detail&all_id=" . $alliance->getID() . "&view=corp_losses");
368
369$menubox->addOption("caption","Pilot statistics");
370$menubox->addOption("link","Top killers", "?a=alliance_detail&all_id=" . $alliance->getID() . "&view=pilot_kills");
371if ($config->getConfig('kill_points'))
372{
373    $menubox->addOption('link', "Top scorers", "?a=alliance_detail&all_id=" . $alliance->getID() . "&view=pilot_scores");
374}
375$menubox->addOption("link","Top losers", "?a=alliance_detail&all_id=" . $alliance->getID() . "&view=pilot_losses");
376$menubox->addOption("caption","Global statistics");
377$menubox->addOption("link","Ships & weapons", "?a=alliance_detail&all_id=" . $alliance->getID() . "&view=ships_weapons");
378$menubox->addOption("link","Most violent systems", "?a=alliance_detail&all_id=" . $alliance->getID() . "&view=violent_systems");
379$page->addContext($menubox->generate());
380
381$page->setContent($html);
382$page->generate();
383?>
Note: See TracBrowser for help on using the browser.