|
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
|
|
|
global $baseDir; |
|
20
|
|
|
|
|
21
|
|
|
$systemID = (int) $system; |
|
22
|
|
|
$relatedTime = (int) $time; |
|
23
|
|
|
|
|
24
|
|
|
$json_options = json_decode($options, true); |
|
25
|
|
|
if (!isset($json_options["A"])) $json_options["A"] = array(); |
|
26
|
|
|
if (!isset($json_options["B"])) $json_options["B"] = array(); |
|
27
|
|
|
|
|
28
|
|
|
$redirect = false; |
|
29
|
|
|
if (isset($_GET["left"])) |
|
30
|
|
|
{ |
|
31
|
|
|
$entity = $_GET["left"]; |
|
32
|
|
|
if (!isset($json_options["A"])) $json_options["A"] = array(); |
|
33
|
|
|
if (($key = array_search($entity, $json_options["B"])) !== false) unset($json_options["B"][$key]); |
|
34
|
|
|
if (!in_array($entity, $json_options["A"])) $json_options["A"][] = $entity; |
|
35
|
|
|
$redirect = true; |
|
36
|
|
|
} |
|
37
|
|
|
if (isset($_GET["right"])) |
|
38
|
|
|
{ |
|
39
|
|
|
$entity = $_GET["right"]; |
|
40
|
|
|
if (!isset($json_options["B"])) $json_options["B"] = array(); |
|
41
|
|
|
if (($key = array_search($entity, $json_options["A"])) !== false) unset($json_options["A"][$key]); |
|
42
|
|
|
if (!in_array($entity, $json_options["B"])) $json_options["B"][] = $entity; |
|
43
|
|
|
$redirect = true; |
|
44
|
|
|
} |
|
45
|
|
|
if ($redirect) |
|
46
|
|
|
{ |
|
47
|
|
|
$json = urlencode(json_encode($json_options)); |
|
48
|
|
|
$url = "/related/$systemID/$relatedTime/o/$json/"; |
|
49
|
|
|
$app->redirect($url, 302); |
|
50
|
|
|
die(); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
$systemName = Info::getSystemName($systemID); |
|
54
|
|
|
$regionName = Info::getRegionName(Info::getRegionIDFromSystemID($systemID)); |
|
55
|
|
|
$unixTime = strtotime($relatedTime); |
|
56
|
|
|
$time = date("Y-m-d H:i", $unixTime); |
|
57
|
|
|
|
|
58
|
|
|
if(isset($_GET["timeframe"])) |
|
59
|
|
|
$exHours = (int) $_GET["timeframe"] == 0 ? 1 : (int) $_GET["timeframe"]; |
|
60
|
|
|
else |
|
61
|
|
|
$exHours = 1; |
|
62
|
|
|
if (((int) $exHours) < 1 || ((int) $exHours > 12)) $exHours = 1; |
|
63
|
|
|
|
|
64
|
|
|
$key = "$systemID:$relatedTime:$exHours:" . json_encode($json_options); |
|
65
|
|
|
$data = Cache::get($key); |
|
66
|
|
|
if (!$data) |
|
|
|
|
|
|
67
|
|
|
{ |
|
68
|
|
|
$parameters = array("solarSystemID" => $systemID, "relatedTime" => $relatedTime, "exHours" => $exHours); |
|
69
|
|
|
$kills = Kills::getKills($parameters); |
|
70
|
|
|
$summary = Related::buildSummary($kills, $parameters, $json_options); |
|
71
|
|
|
$data = array("summary" => $summary, "systemName" => $systemName, "regionName" => $regionName, "time" => $time, "exHours" => $exHours, "solarSystemID" => $systemID, "relatedTime" => $relatedTime, "options" => json_encode($json_options)); |
|
72
|
|
|
Cache::set($key, $data, 600); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
$app->render("related.html", $data); |
|
76
|
|
|
|
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)or! empty(...)instead.