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