root/dev/common/corp_detail.php @ 195

Revision 190, 16.0 KB (checked in by exi, 15 years ago)

This is a big update...
Moved all admin scripts to common/admin.
Moved all includes and classes to common/includes.
Edited all include-paths to reflect the movement.
Fixed a bug with the session system allowing every registered user to access admin pages.
Replaced calls to date() to use a wrapper so gmdate can be used.
Replaced some calls to $config with calls to the static object.
Fixed a big which caused the portrait_grab to not download a new picute.
Added a classified-state to kills.
Removed the sync_server server script in this tree.
Added code to help modules find the includes to index.php.

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