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

Revision 396, 3.6 KB (checked in by kovell, 11 years ago)

Fixes: HTML, killlists with multiple involved, thumbnail creation delays, mods using short php tags corrected (Tribalize) . Autoupgrade adds missing indexes on upgraded boards. page cache updating algorithm improved, feed log information cleaned up (Oleg)

Line 
1popup| <?php   
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);
91involved::load($kslist,'kill');
92
93$lslist = new KillList();
94$lslist->setOrdered(true);
95$lslist->addSystem($system);
96$lslist->setStartDate($firstts);
97$lslist->setEndDate($lastts);
98involved::load($lslist,'loss');
99
100$killsummary = new KillSummaryTable($kslist, $lslist);
101$killsummary->setBreak(6);
102$name = $system->getName()." ".substr($firstts,0, 16)." ". substr($lastts,-8,5);
103}
104?>
105<form>
106<table class="popup-table" height="100%" width="355px">
107<tr>
108        <td align="center"><strong>Forum Post</strong></td>
109</tr>
110<tr>
111        <td align="center"><input type="button" value="Close" onClick="ReverseContentDisplay('popup');"></td>
112</tr>
113<tr>
114<td valign="top" align="center">
115<textarea class="killmail" name="killmail" cols="100" rows="30" readonly="readonly">
116<?php 
117echo $name."\r\n";
118echo $killsummary->forum();?></textarea></td></tr>
119<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>
120</tr>
121
122</table>
123</form>
124
Note: See TracBrowser for help on using the browser.