1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* zKillboard |
4
|
|
|
* Copyright (C) 2012-2015 EVE-KILL Team and EVSCO. |
5
|
|
|
* |
6
|
|
|
* This program is free software: you can redistribute it and/or modify |
7
|
|
|
* it under the terms of the GNU Affero General Public License as published by |
8
|
|
|
* the Free Software Foundation, either version 3 of the License, or |
9
|
|
|
* (at your option) any later version. |
10
|
|
|
* |
11
|
|
|
* This program is distributed in the hope that it will be useful, |
12
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14
|
|
|
* GNU Affero General Public License for more details. |
15
|
|
|
* |
16
|
|
|
* You should have received a copy of the GNU Affero General Public License |
17
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
18
|
|
|
*/ |
19
|
|
|
|
20
|
|
|
class Feed |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* Returns kills in json format according to the specified parameters |
24
|
|
|
* |
25
|
|
|
* @static |
26
|
|
|
* @param array $parameters |
27
|
|
|
* @return array |
28
|
|
|
*/ |
29
|
|
|
public static function getKills($parameters = array()) |
30
|
|
|
{ |
31
|
|
|
global $debug; |
32
|
|
|
$ip = IP::get(); |
|
|
|
|
33
|
|
|
|
34
|
|
|
$userAgent = @$_SERVER["HTTP_USER_AGENT"]; |
|
|
|
|
35
|
|
|
if(isset($parameters["limit"]) && $parameters["limit"] > 1000) |
36
|
|
|
$parameters["limit"] = 1000; |
37
|
|
|
if(isset($parameters["page"])) |
38
|
|
|
$parameters["limit"] = 1000; |
39
|
|
|
$kills = Kills::getKills($parameters, true, false); |
40
|
|
|
|
41
|
|
|
return self::getJSON($kills, $parameters); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Groups the kills together based on specified parameters |
46
|
|
|
* @static |
47
|
|
|
* @param array|null $kills |
48
|
|
|
* @param array $parameters |
49
|
|
|
* @return array |
50
|
|
|
*/ |
51
|
|
|
public static function getJSON($kills, $parameters) |
52
|
|
|
{ |
53
|
|
|
if ($kills == null) return array(); |
54
|
|
|
$retValue = array(); |
55
|
|
|
|
56
|
|
|
foreach ($kills as $kill) { |
57
|
|
|
$killID = $kill["killID"]; |
58
|
|
|
$jsonText = Killmail::get($killID); |
59
|
|
|
$json = json_decode($jsonText, true); |
60
|
|
|
$involvedCount = count($json["attackers"]); |
61
|
|
|
|
62
|
|
|
if (array_key_exists("no-items", $parameters)) |
63
|
|
|
unset($json["items"]); |
64
|
|
|
|
65
|
|
|
if (array_key_exists("finalblow-only", $parameters)) |
66
|
|
|
{ |
67
|
|
|
$data = $json["attackers"]; |
68
|
|
|
unset($json["attackers"]); |
69
|
|
|
foreach($data as $attacker) |
70
|
|
|
if($attacker["finalBlow"] == "1") |
71
|
|
|
$json["attackers"][] = $attacker; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
if (array_key_exists("no-attackers", $parameters)) |
75
|
|
|
unset($json["attackers"]); |
76
|
|
|
|
77
|
|
|
if(isset($json["_stringValue"])) |
78
|
|
|
unset($json["_stringValue"]); |
79
|
|
|
|
80
|
|
|
$json["zkb"]["involved"] = count($involvedCount); |
81
|
|
|
if(!isset($json["zkb"]["totalValue"])) |
82
|
|
|
$json["zkb"]["totalValue"] = Db::queryField("SELECT total_price FROM zz_participants WHERE killID = :killID AND isVictim = 1", "total_price", array(":killID" => $killID)); |
83
|
|
|
if(!isset($json["zkb"]["points"])) |
84
|
|
|
$json["zkb"]["points"] = Db::queryField("SELECT points FROM zz_participants WHERE killID = :killID AND isVictim = 1", "points", array(":killID" => $killID)); |
85
|
|
|
if(!isset($json["zkb"]["source"])) |
86
|
|
|
$json["zkb"]["source"] = Db::queryField("SELECT source FROM zz_killmails WHERE killID = :killID", "source", array(":killID" => $killID)); |
87
|
|
|
|
88
|
|
|
$retValue[] = json_encode($json); |
89
|
|
|
} |
90
|
|
|
return $retValue; |
91
|
|
|
} |
92
|
|
|
} |
93
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.