root/dev/mods/forum_post/forum_post.php @ 204

Revision 204, 3.9 KB (checked in by knifee, 15 years ago)

forum summery mod. adds admin option to view a e-o forum ready summery to campaign/contract page and related kills page.

Admin options allow colours/styles to be added to the summery, isk totals per class to be turned on/off and the ship class to placed at the start or end of each line.

Line 
1popup| <?       
2require_once('common/includes/class.killlist.php');
3require_once('common/includes/class.killlisttable.php');
4require_once('mods/forum_post/class.killsummarytable.php');
5require_once('common/includes/class.contract.php');
6require_once('common/includes/class.toplist.php');
7
8require_once('common/includes/class.page.php');
9require_once('common/includes/class.corp.php');
10require_once('common/includes/class.alliance.php');
11
12if(isset($_GET['ctr_id'])){
13$ctr_id = $_GET['ctr_id'];
14$contract = new Contract($ctr_id);
15$klist = $contract->getKillList();
16$llist = $contract->getLossList();
17$killsummary = new KillSummaryTable($klist, $llist);
18$killsummary->setBreak(6);
19        if ($_GET['view'] == ""){
20                $killsummary->setFilter(false);
21        }
22$name = $contract->getName();
23}
24
25if(isset($_GET['kll_id']))
26{
27// this is a fast query to get the system and timestamp
28$rqry = new DBQuery();
29$rsql = 'SELECT kll_timestamp, kll_system_id from kb3_kills where kll_id = '.$kll_id;
30$rqry->execute($rsql);
31$rrow = $rqry->getRow();
32$system = new SolarSystem($rrow['kll_system_id']);
33
34// now we get all kills in that system for +-12 hours
35$query = 'SELECT kll.kll_timestamp AS ts FROM kb3_kills kll WHERE kll.kll_system_id='.$rrow['kll_system_id'].'
36            AND kll.kll_timestamp <= date_add( \''.$rrow['kll_timestamp'].'\', INTERVAL \'12\' HOUR )
37            AND kll.kll_timestamp >= date_sub( \''.$rrow['kll_timestamp'].'\', INTERVAL \'12\' HOUR )
38            ORDER BY kll.kll_timestamp ASC';
39$qry = new DBQuery();
40$qry->execute($query);
41$ts = array();
42while ($row = $qry->getRow())
43{
44    $time = strtotime($row['ts']);
45    $ts[intval(date('H', $time))][] = $row['ts'];
46}
47
48// this tricky thing looks for gaps of more than 1 hour and creates an intersection
49$baseh = date('H', strtotime($rrow['kll_timestamp']));
50$maxc = count($ts);
51$times = array();
52for ($i = 0; $i < $maxc; $i++)
53{
54    $h = ($baseh+$i) % 24;
55    if (!isset($ts[$h]))
56    {
57        break;
58    }
59    foreach ($ts[$h] as $timestamp)
60    {
61        $times[] = $timestamp;
62    }
63}
64for ($i = 0; $i < $maxc; $i++)
65{
66    $h = ($baseh-$i) % 24;
67    if ($h < 0)
68    {
69        $h += 24;
70    }
71    if (!isset($ts[$h]))
72    {
73        break;
74    }
75    foreach ($ts[$h] as $timestamp)
76    {
77        $times[] = $timestamp;
78    }
79}
80unset($ts);
81asort($times);
82
83// we got 2 resulting timestamps
84$firstts = array_shift($times);
85$lastts = array_pop($times);
86
87$kslist = new KillList();
88$kslist->setOrdered(true);
89$kslist->addSystem($system);
90$kslist->setStartDate($firstts);
91$kslist->setEndDate($lastts);
92if (CORP_ID)
93    $kslist->addInvolvedCorp(new Corporation(CORP_ID));
94if (ALLIANCE_ID)
95    $kslist->addInvolvedAlliance(new Alliance(ALLIANCE_ID));
96
97$lslist = new KillList();
98$lslist->setOrdered(true);
99$lslist->addSystem($system);
100$lslist->setStartDate($firstts);
101$lslist->setEndDate($lastts);
102if (CORP_ID)
103    $lslist->addVictimCorp(new Corporation(CORP_ID));
104if (ALLIANCE_ID)
105    $lslist->addVictimAlliance(new Alliance(ALLIANCE_ID));
106
107$killsummary = new KillSummaryTable($kslist, $lslist);
108$killsummary->setBreak(6);
109$name = $system->getName()." ".substr($firstts,0, 16)." ". substr($lastts,-8,5);
110}
111?>
112<form>
113<table class="popup-table" height="100%" width="355px">
114<tr>
115        <td align="center"><strong>Forum Post</strong></td>
116</tr>
117<tr>
118        <td align="center"><input type="button" value="Close" onClick="ReverseContentDisplay('popup');"></td>
119</tr>
120<tr>
121<td valign="top" align="center">
122<textarea class="killmail" name="killmail" cols="100" rows="30" readonly="readonly">
123<?php 
124echo $name."\r\n";
125echo $killsummary->forum();?></textarea></td></tr>
126<tr><td align="center"><input type="button" value="Select All" onClick="this.form.killmail.select();this.form.killmail.focus(); document.execCommand('Copy')">&nbsp;<input type="button" value="Close" onClick="ReverseContentDisplay('popup');"></td>
127</tr>
128
129</table>
130</form>
131
Note: See TracBrowser for help on using the browser.