|
1
|
|
|
<?php
|
|
2
|
|
|
/* zKillboard
|
|
3
|
|
|
* Copyright (C) 2012-2015 EVE-KILL Team and EVSCO.
|
|
4
|
|
|
*
|
|
5
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
6
|
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
7
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
|
|
* (at your option) any later version.
|
|
9
|
|
|
*
|
|
10
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
11
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
|
|
* GNU Affero General Public License for more details.
|
|
14
|
|
|
*
|
|
15
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
16
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
|
|
*/
|
|
18
|
|
|
|
|
19
|
|
|
class api_related implements apiEndpoint
|
|
20
|
|
|
{
|
|
21
|
|
|
public function getDescription()
|
|
22
|
|
|
{
|
|
23
|
|
|
return array("type" => "description", "message" =>
|
|
24
|
|
|
"Shows killmails that are related to a killmail done at a certain time, in a certain system."
|
|
25
|
|
|
);
|
|
26
|
|
|
}
|
|
27
|
|
|
|
|
28
|
|
|
public function getAcceptedParameters()
|
|
29
|
|
|
{
|
|
30
|
|
|
return array("type" => "parameters", "parameters" =>
|
|
31
|
|
|
array(
|
|
32
|
|
|
"systemID" => "The solarSystemID that the kills happened in.",
|
|
33
|
|
|
"timestamp" => "The timestamp for when the kills should've happened. (YYYYmmddHHii)",
|
|
34
|
|
|
"exHours" => "Amount of hours to span the battle over. 1 to 12."
|
|
35
|
|
|
)
|
|
36
|
|
|
);
|
|
37
|
|
|
}
|
|
38
|
|
|
public function execute($parameters)
|
|
39
|
|
|
{
|
|
40
|
|
|
$systemID = isset($parameters["solarSystemID"]) ? $parameters["solarSystemID"] : NULL;
|
|
41
|
|
|
$timestamp = isset($parameters["timestamp"]) ? (int) $parameters["timestamp"] : NULL;
|
|
42
|
|
|
$exHours = isset($parameters["exHours"]) ? (int) $parameters["exHours"] : 1;
|
|
43
|
|
|
|
|
44
|
|
|
if(!$systemID)
|
|
45
|
|
|
return array(
|
|
46
|
|
|
"type" => "error",
|
|
47
|
|
|
"message" => "solarSystemID isn't set."
|
|
48
|
|
|
);
|
|
49
|
|
|
if(!$timestamp)
|
|
|
|
|
|
|
50
|
|
|
return array(
|
|
51
|
|
|
"type" => "error",
|
|
52
|
|
|
"message" => "timestamp isn't set."
|
|
53
|
|
|
);
|
|
54
|
|
|
|
|
55
|
|
|
if($exHours < 1 || $exHours > 12)
|
|
56
|
|
|
return array(
|
|
57
|
|
|
"type" => "error",
|
|
58
|
|
|
"message" => "exHours is below 1 or above 12."
|
|
59
|
|
|
);
|
|
60
|
|
|
|
|
61
|
|
|
$params = array("solarSystemID" => $systemID, "relatedTime" => $timestamp, "exHours" => $exHours);
|
|
62
|
|
|
$md5 = md5(serialize($params));
|
|
63
|
|
|
$cache = Cache::get($md5);
|
|
64
|
|
|
if($cache)
|
|
|
|
|
|
|
65
|
|
|
return $cache;
|
|
66
|
|
|
|
|
67
|
|
|
$kills = Kills::getKills($params);
|
|
68
|
|
|
$data = Related::buildSummary($kills, $params, array());
|
|
69
|
|
|
Cache::set($md5, $data, 3600);
|
|
70
|
|
|
return $data;
|
|
71
|
|
|
}
|
|
72
|
|
|
}
|
|
73
|
|
|
|
In PHP, under loose comparison (like
==, or!=, orswitchconditions), values of different types might be equal.For
integervalues, zero is a special case, in particular the following results might be unexpected: