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

Revision 227, 3.8 KB (checked in by knifee, 13 years ago)

updated files.

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