This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
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 Summary |
||
21 | { |
||
22 | |||
23 | /** |
||
24 | * @param array $data |
||
25 | * @param integer $id |
||
26 | * @param array $parameters |
||
27 | * @return array |
||
28 | */ |
||
29 | public static function getPilotSummary(&$data, $id, $parameters = array()) |
||
30 | { |
||
31 | return self::getSummary('pilot', 'characterID', $data, $id, $parameters); |
||
32 | } |
||
33 | |||
34 | /** |
||
35 | * @param string $type |
||
36 | * @param string $column |
||
37 | * @param array $data |
||
38 | * @param integer $id |
||
39 | * @param array $parameters |
||
40 | * @return array |
||
41 | */ |
||
42 | public static function getSummary($type, $column, &$data, $id, $parameters = array(), $overRide = false) |
||
43 | { |
||
44 | $key = "summary:$type:$column:$id:$overRide:" . json_encode($parameters); |
||
45 | $mc = Cache::get($key); |
||
46 | if ($mc) return $mc; |
||
0 ignored issues
–
show
|
|||
47 | |||
48 | $rank = Db::queryRow("select * from zz_ranks where type = :type and typeID = :id", array(":type" => $type, ":id" => $id), 300); |
||
49 | $recentRank = Db::queryField("select overallRank from zz_ranks_recent where type = :type and typeID = :id", "overallRank", array(":type" => $type, ":id" => $id), 300); |
||
50 | $progress = Db::queryRow("select * from zz_ranks_progress where type = :type and typeID = :id and dttm >= date(date_sub(now(), interval 7 day)) order by dttm limit 1", array(":type" => $type, ":id" => $id), 300); |
||
51 | $previousRank = $nextRank = null; |
||
0 ignored issues
–
show
$nextRank is not used, you could remove the assignment.
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently. $myVar = 'Value';
$higher = false;
if (rand(1, 6) > 3) {
$higher = true;
} else {
$higher = false;
}
Both the ![]() $previousRank is not used, you could remove the assignment.
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently. $myVar = 'Value';
$higher = false;
if (rand(1, 6) > 3) {
$higher = true;
} else {
$higher = false;
}
Both the ![]() |
|||
52 | if ($progress) { |
||
0 ignored issues
–
show
The expression
$progress of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.
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 ![]() |
|||
53 | $r = $progress["overallRank"]; |
||
54 | if ($r) { |
||
55 | $progress["previous"] = Db::queryRow("select * from zz_ranks_progress where type = :type and overallRank = :rank and dttm >= date(date_sub(now(), interval 7 day)) order by dttm limit 1", array(":type" => $type, ":rank" => ($r - 1)), 300); |
||
56 | $progress["next"] = Db::queryRow("select * from zz_ranks_progress where type = :type and overallRank = :rank and dttm >= date(date_sub(now(), interval 7 day)) order by dttm limit 1", array(":type" => $type, ":rank" => ($r + 1)), 300); |
||
57 | Info::addInfo($progress); |
||
58 | } |
||
59 | } |
||
60 | |||
61 | if ($overRide) { |
||
62 | $rank = $recentRank = array(); |
||
63 | |||
64 | $tables = array(); |
||
65 | $whereClauses = array(); |
||
66 | if (!isset($parameters["kills"]) && !isset($parameters["losses"])) $parameters["mixed"] = true; |
||
67 | Filters::buildFilters($tables, $whereClauses, $whereClauses, $parameters, true); |
||
68 | |||
69 | $whereStatement = implode(" and ", $whereClauses); |
||
70 | |||
71 | $query = "select groupID, sum(if(isVictim, 0, 1)) destroyed, sum(if(isVictim, 0, total_price)) iskDestroyed, sum(if(isVictim, 0, points)) pointsDestroyed, sum(if(isVictim, 1, 0)) lost, sum(if(isVictim, total_price, 0)) iskLost, sum(if(isVictim, points, 0)) pointsLost from (select vGroupID groupID, isVictim, total_price, points from zz_participants p where $whereStatement group by killID) as foo group by groupID"; |
||
72 | $stats = Db::query($query); |
||
73 | } else { |
||
74 | if ($type == "system" || $type == "region") $stats = Db::query("select groupID, lost destroyed, 0 lost, pointsLost pointsDestroyed, 0 pointsLost, iskLost iskDestroyed, 0 iskLost from zz_stats where type='$type' and typeID = $id", array(":id" => $id), 300); |
||
75 | else $stats = Db::query("select groupID, destroyed, lost, pointsDestroyed, pointsLost, iskDestroyed, iskLost from zz_stats where type='$type' and typeID = :id", array(":id" => $id), 0); |
||
76 | } |
||
77 | |||
78 | $infoStats = array(); |
||
79 | |||
80 | $data["shipsDestroyed"] = 0; |
||
81 | $data["shipsLost"] = 0; |
||
82 | $data["pointsDestroyed"] = 0; |
||
83 | $data["pointsLost"] = 0; |
||
84 | $data["iskDestroyed"] = 0; |
||
85 | $data["iskLost"] = 0; |
||
86 | |||
87 | foreach ($stats as $stat) { |
||
88 | $infoStat = Info::addInfo($stat); |
||
89 | if ($infoStat["groupID"] == 0) $infoStat["groupName"] = "Unknown"; |
||
90 | $infoStats[$infoStat["groupName"]] = $infoStat; |
||
91 | $data["shipsDestroyed"] += $infoStat["destroyed"]; |
||
92 | $data["shipsLost"] += $infoStat["lost"]; |
||
93 | $data["iskDestroyed"] += $infoStat["iskDestroyed"]; |
||
94 | $data["iskLost"] += $infoStat["iskLost"]; |
||
95 | $data["pointsDestroyed"] += $infoStat["pointsDestroyed"]; |
||
96 | $data["pointsLost"] += $infoStat["pointsLost"]; |
||
97 | } |
||
98 | unset($stats); |
||
99 | ksort($infoStats); |
||
100 | $data["stats"] = $infoStats; |
||
101 | if ($rank != null && $recentRank != null) $rank["recentRank"] = $recentRank; |
||
102 | if ($rank != null && $progress != null) $data["progress"] = $progress; |
||
103 | if ($rank != null) $data["ranks"] = $rank; |
||
104 | Cache::set($key, $data, 300); |
||
105 | return $data; |
||
106 | } |
||
107 | |||
108 | /** |
||
109 | * @param array $data |
||
110 | * @param integer $id |
||
111 | * @param array $parameters |
||
112 | * @return array |
||
113 | */ |
||
114 | public static function getCorpSummary(&$data, $id, $parameters = array()) |
||
115 | { |
||
116 | return self::getSummary('corp', 'corporationID', $data, $id, $parameters); |
||
117 | } |
||
118 | |||
119 | /** |
||
120 | * @param array $data |
||
121 | * @param integer $id |
||
122 | * @param array $parameters |
||
123 | * @return array |
||
124 | */ |
||
125 | public static function getAlliSummary(&$data, $id, $parameters = array()) |
||
126 | { |
||
127 | return self::getSummary('alli', 'allianceID', $data, $id, $parameters); |
||
128 | } |
||
129 | |||
130 | /** |
||
131 | * @param array $data |
||
132 | * @param integer $id |
||
133 | * @param array $parameters |
||
134 | * @return array |
||
135 | */ |
||
136 | public static function getFactionSummary(&$data, $id, $parameters = array()) |
||
137 | { |
||
138 | return self::getSummary('faction', 'factionID', $data, $id, $parameters); |
||
139 | } |
||
140 | |||
141 | /** |
||
142 | * @param array $data |
||
143 | * @param integer $id |
||
144 | * @param array $parameters |
||
145 | * @return array |
||
146 | */ |
||
147 | public static function getShipSummary(&$data, $id, $parameters = array()) |
||
148 | { |
||
149 | return self::getSummary('ship', 'shipTypeID', $data, $id, $parameters); |
||
150 | } |
||
151 | |||
152 | /** |
||
153 | * @param array $data |
||
154 | * @param integer $id |
||
155 | * @param array $parameters |
||
156 | * @return array |
||
157 | */ |
||
158 | public static function getGroupSummary(&$data, $id, $parameters = array()) |
||
159 | { |
||
160 | return self::getSummary('group', 'groupID', $data, $id, $parameters); |
||
161 | } |
||
162 | |||
163 | /** |
||
164 | * @param array $data |
||
165 | * @param integer $id |
||
166 | * @param array $parameters |
||
167 | * @return array |
||
168 | */ |
||
169 | public static function getRegionSummary(&$data, $id, $parameters = array()) |
||
170 | { |
||
171 | return self::getSummary('region', 'regionID', $data, $id, $parameters); |
||
172 | } |
||
173 | |||
174 | /** |
||
175 | * @param array $data |
||
176 | * @param integer $id |
||
177 | * @param array $parameters |
||
178 | * @return array |
||
179 | */ |
||
180 | public static function getSystemSummary(&$data, $id, $parameters = array()) |
||
181 | { |
||
182 | return self::getSummary('system', 'solarSystemID', $data, $id, $parameters); |
||
183 | } |
||
184 | |||
185 | /** |
||
186 | * @param $type |
||
187 | * @param $typeID |
||
188 | * @return array |
||
189 | */ |
||
190 | public static function getMonthlyHistory($type, $typeID) |
||
191 | { |
||
192 | return Db::query("select year, month, sum(if(isVictim, 0, 1)) destroyed, sum(if(isVictim, 0, total_price)) iskDestroyed, sum(if(isVictim, 0, points)) pointsDestroyed, sum(if(isVictim, 1, 0)) lost, sum(if(isVictim, total_price, 0)) iskLost, sum(if(isVictim, points, 0)) pointsLost from (select year(dttm) year, month(dttm) month, isVictim, total_price, points from zz_participants p where $type = $typeID group by killID) as foo group by year, month order by year desc, month desc", array(), 3600); |
||
193 | } |
||
194 | |||
195 | /** |
||
196 | * @param $kills |
||
197 | * @param array $parameters |
||
198 | * @param $key |
||
199 | * @return array |
||
200 | */ |
||
201 | public static function buildSummary(&$kills, $parameters = array(), $key) |
||
202 | { |
||
203 | if ($kills == null || !is_array($kills) || sizeof($kills) == 0) return array(); |
||
204 | |||
205 | $sem = Semaphore::fetch($parameters["solarSystemID"]); |
||
206 | |||
207 | $key = "related:$key"; |
||
208 | $mc = Cache::get($key); |
||
209 | if ($mc) { |
||
0 ignored issues
–
show
The expression
$mc of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.
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 ![]() |
|||
210 | Semaphore::release($sem); |
||
211 | return $mc; |
||
212 | } |
||
213 | |||
214 | $teamAKills = array(); |
||
215 | $teamBKills = array(); |
||
216 | $teamAList = array(); |
||
217 | $teamBList = array(); |
||
218 | $killHash = array(); |
||
219 | |||
220 | self::determineSides($kills, $teamAKills, $teamBKills); |
||
221 | foreach ($kills as $kill) { |
||
222 | self::addRelatedPilots($killHash, $kill, $kill["victim"]); |
||
223 | } |
||
224 | //$teamAEntities = self::getEntities($teamAKills); |
||
225 | //$teamBEntities = self::getEntities($teamBKills); |
||
226 | //$killHash = array_keys($killHash); |
||
227 | |||
228 | $teamATotals = self::getStatsKillList($teamAKills); |
||
229 | $teamBTotals = self::getStatsKillList($teamBKills); |
||
230 | |||
231 | self::hashPilots($teamBKills, $teamBList, $teamAList); |
||
232 | self::hashPilots($teamAKills, $teamAList, $teamBList); |
||
233 | |||
234 | $teamATotals["pilotCount"] = self::getUniquePilotCount($teamAList); |
||
235 | $teamBTotals["pilotCount"] = self::getUniquePilotCount($teamBList); |
||
236 | |||
237 | foreach ($teamAList as $a => $value) if (in_array($a, array_keys($teamBList))) unset($teamAList[$a]); |
||
238 | foreach ($teamBList as $b => $value) if (in_array($b, array_keys($teamAList))) unset($teamBList[$b]); |
||
239 | |||
240 | uksort($teamAList, "self::shipGroupSort"); |
||
241 | uksort($teamBList, "self::shipGroupSort"); |
||
242 | |||
243 | $teamAList = self::addInfo($teamAList, $killHash); |
||
244 | $teamBList = self::addInfo($teamBList, $killHash); |
||
245 | |||
246 | |||
247 | $retValue = array( |
||
248 | "teamA" => array( |
||
249 | "list" => $teamAList, |
||
250 | "kills" => $teamAKills, |
||
251 | "totals" => $teamATotals, |
||
252 | ), |
||
253 | "teamB" => array( |
||
254 | "list" => $teamBList, |
||
255 | "kills" => $teamBKills, |
||
256 | "totals" => $teamBTotals, |
||
257 | ), |
||
258 | ); |
||
259 | |||
260 | //$teamAScore = log($retValue["teamA"]["totals"]["total_price"] + 1) * (log($retValue["teamA"]["totals"]["total_points"]) + 1); |
||
261 | //$teamBScore = log($retValue["teamB"]["totals"]["total_price"] + 1) * (log($retValue["teamA"]["totals"]["total_points"]) + 1); |
||
262 | /*if ($teamBScore > $teamAScore) { |
||
263 | $temp = $retValue["teamB"]; |
||
264 | $retValue["teamB"] = $retValue["teamA"]; |
||
265 | $retValue["teamA"] = $temp; |
||
266 | }*/ |
||
267 | |||
268 | Semaphore::release($sem); |
||
269 | Cache::set($key, $retValue, 900); |
||
270 | return $retValue; |
||
271 | } |
||
272 | |||
273 | /*private static function getEntities(&$kills) |
||
274 | { |
||
275 | $retValue = array(); |
||
276 | $retValue["chars"] = array(); |
||
277 | $retValue["corps"] = array(); |
||
278 | $retValue["allis"] = array(); |
||
279 | $retValue["factions"] = array(); |
||
280 | foreach ($kills as $kill) { |
||
281 | $victim = $kill["victim"]; |
||
282 | $retValue["chars"][$victim["characterID"]] = true; |
||
283 | $retValue["corps"][$victim["corporationID"]] = true; |
||
284 | if ($victim["allianceID"] != 0) $retValue["allis"][$victim["allianceID"]] = true; |
||
285 | if ($victim["factionID"] != 0) $retValue["factions"][$victim["factionID"]] = true; |
||
286 | } |
||
287 | $retValue["chars"] = array_keys($retValue["chars"]); |
||
288 | $retValue["corps"] = array_keys($retValue["corps"]); |
||
289 | $retValue["allis"] = array_keys($retValue["allis"]); |
||
290 | $retValue["factions"] = array_keys($retValue["factions"]); |
||
291 | return $retValue; |
||
292 | }*/ |
||
293 | |||
294 | /** |
||
295 | * @param $kills |
||
296 | * @param $teamA |
||
297 | * @param $teamB |
||
298 | */ |
||
299 | private static function determineSides(&$kills, &$teamA, &$teamB) |
||
300 | { |
||
301 | $chars = array(); |
||
302 | $corps = array(); |
||
303 | $allis = array(); |
||
304 | foreach ($kills as $kill) { |
||
305 | $victim = $kill["victim"]; |
||
306 | $price = $kill["info"]["total_price"]; |
||
307 | $points = $kill["info"]["points"]; |
||
308 | self::increment($chars, $victim["characterID"], $price, $points); |
||
309 | self::increment($corps, $victim["corporationID"], $price, $points); |
||
310 | self::increment($allis, $victim["allianceID"], $price, $points); |
||
311 | } |
||
312 | if (sizeof($allis)) self::filterKills($kills, $teamB, $teamA, "allianceID", $allis); |
||
313 | else if (sizeof($corps)) self::filterKills($kills, $teamB, $teamA, "corporationID", $corps); |
||
314 | else if (sizeof($chars)) self::filterKills($kills, $teamB, $teamA, "characterID", $chars); |
||
315 | } |
||
316 | |||
317 | /** |
||
318 | * @param $array |
||
319 | * @param $key |
||
320 | * @param $price |
||
321 | * @param $points |
||
322 | */ |
||
323 | private static function increment(&$array, $key, $price, $points) |
||
324 | { |
||
325 | if ($key == 0) return; |
||
326 | if (!isset($array["$key"])) { |
||
327 | $array["$key"] = array(); |
||
328 | $array["$key"]["count"] = 0; |
||
329 | $array["$key"]["price"] = 0; |
||
330 | $array["$key"]["points"] = 0; |
||
331 | } |
||
332 | $array["$key"]["count"]++; |
||
333 | $array["$key"]["price"] += $price; |
||
334 | $array["$key"]["points"] += $points; |
||
335 | } |
||
336 | |||
337 | /** |
||
338 | * @param array $kills |
||
339 | * @param array $array1 |
||
340 | * @param array $array2 |
||
341 | * @param string $key |
||
342 | * @param array $keyArray |
||
343 | */ |
||
344 | private static function filterKills(&$kills, &$array1, &$array2, $key, $keyArray) |
||
345 | { |
||
346 | $valueArray = array(); |
||
347 | foreach ($keyArray as $rowKey => $row) { |
||
348 | $valueArray[$rowKey] = log($row["count"]) * $row["price"]; |
||
349 | } |
||
350 | arsort($valueArray); |
||
351 | $keys = array_keys($valueArray); |
||
352 | $keyValue = $keys[0]; |
||
353 | foreach ($kills as $killID => $kill) { |
||
354 | $victim = $kill["victim"]; |
||
355 | if ($victim[$key] == $keyValue) $array1[$killID] = $kill; |
||
356 | else if ($victim[$key] == 0) $array1[$killID] = $kill; |
||
357 | else $array2[$killID] = $kill; |
||
358 | } |
||
359 | } |
||
360 | |||
361 | /** |
||
362 | * @param array $array |
||
363 | * @param array $kill |
||
364 | * @param array $pilot |
||
365 | */ |
||
366 | protected static function addRelatedPilots(&$array, &$kill, &$pilot) |
||
367 | { |
||
368 | $characterID = $pilot['characterID']; |
||
369 | $corporationID = $pilot['corporationID']; |
||
370 | $allianceID = $pilot["allianceID"]; |
||
371 | $shipTypeID = $pilot['shipTypeID']; |
||
372 | |||
373 | if ($characterID == 0) return; |
||
374 | |||
375 | if ($shipTypeID != 670 && $shipTypeID != 0) { |
||
376 | $podHash = "670|$corporationID|$characterID|$allianceID"; |
||
377 | $s0Hash = "0|$corporationID|$characterID|$allianceID"; |
||
378 | unset($array[$podHash]); |
||
379 | unset($array[$s0Hash]); |
||
380 | } |
||
381 | $hash = "$shipTypeID|$corporationID|$characterID|$allianceID"; |
||
382 | $array[$hash] = array("kill" => $kill, "pilot" => $pilot); |
||
383 | } |
||
384 | |||
385 | /** |
||
386 | * @param array $kills |
||
387 | * @return array |
||
388 | */ |
||
389 | private static function getStatsKillList(&$kills) |
||
390 | { |
||
391 | $totalPrice = 0; |
||
392 | $totalPoints = 0; |
||
393 | $groupIDs = array(); |
||
394 | $totalShips = 0; |
||
395 | foreach ($kills as $kill) { |
||
396 | $info = $kill["info"]; |
||
397 | $victim = $kill["victim"]; |
||
398 | $totalPrice += $info["total_price"]; |
||
399 | $totalPoints += $info["points"]; |
||
400 | $groupID = $victim["groupID"]; |
||
401 | if (!isset($groupIDs[$groupID])) { |
||
402 | $groupIDs[$groupID] = array(); |
||
403 | $groupIDs[$groupID]["count"] = 0; |
||
404 | $groupIDs[$groupID]["isk"] = 0; |
||
405 | $groupIDs[$groupID]["points"] = 0; |
||
406 | } |
||
407 | $groupIDs[$groupID]["groupID"] = $groupID; |
||
408 | $groupIDs[$groupID]["count"]++; |
||
409 | $groupIDs[$groupID]["isk"] += $info["total_price"]; |
||
410 | $groupIDs[$groupID]["points"] += $info["points"]; |
||
411 | $totalShips++; |
||
412 | } |
||
413 | Info::addInfo($groupIDs); |
||
414 | return array( |
||
415 | "total_price" => $totalPrice, "groupIDs" => $groupIDs, "totalShips" => $totalShips, |
||
416 | "total_points" => $totalPoints |
||
417 | ); |
||
418 | } |
||
419 | |||
420 | /** |
||
421 | * @param array $kills |
||
422 | * @param array $teamBs |
||
423 | * @param array $teamAs |
||
424 | */ |
||
425 | protected static function hashPilots($kills, &$teamBs, &$teamAs) |
||
426 | { |
||
427 | $pilotsAdded = array(); |
||
428 | ksort($kills); |
||
429 | |||
430 | $validEntities = array(); |
||
431 | $validEntities["factions"] = array(); |
||
432 | $validEntities["allis"] = array(); |
||
433 | $validEntities["corps"] = array(); |
||
434 | // Preprocess the opposition |
||
435 | foreach ($kills as $killID => $kill) { |
||
436 | $victim = $kill['victim']; |
||
437 | |||
438 | if ($victim["factionID"] != 0) $validEntities["factions"][] = $victim["factionID"]; |
||
439 | if ($victim["allianceID"] != 0) $validEntities["allis"][] = $victim["allianceID"]; |
||
440 | if ($victim["corporationID"] != 0) $validEntities["corps"][] = $victim["corporationID"]; |
||
441 | } |
||
442 | |||
443 | foreach ($kills as $killID => $kill) { |
||
444 | $victim = $kill['victim']; |
||
445 | $characterID = $victim["characterID"]; |
||
446 | $shipTypeID = $victim["shipTypeID"]; |
||
447 | if (($shipTypeID == 0 || $shipTypeID == 670) && in_array($characterID, $pilotsAdded)) continue; |
||
448 | if ($shipTypeID != 670 && $shipTypeID != 0) $pilotsAdded[] = $characterID; |
||
449 | self::addRelatedPilots($teamBs, $kill, $victim); |
||
450 | |||
451 | $attackers = Db::query("select * from zz_participants where killID = :killID and isVictim = '0'", |
||
452 | array(":killID" => $killID), 3600); |
||
453 | foreach ($attackers as $attacker) { |
||
454 | $shipTypeID = $attacker["shipTypeID"]; |
||
455 | |||
456 | if ($attacker["factionID"] != 0 && in_array($attacker["factionID"], $validEntities["factions"])) continue; |
||
457 | if ($attacker["allianceID"] != 0 && in_array($attacker["allianceID"], $validEntities["allis"])) continue; |
||
458 | if (in_array($attacker["corporationID"], $validEntities["corps"])) continue; |
||
459 | |||
460 | if ($shipTypeID != 0 && $shipTypeID != 670) self::addRelatedPilots($teamAs, $kill, $attacker); |
||
461 | if (!in_array($attacker["characterID"], $pilotsAdded)) $pilotsAdded[] = $attacker["characterID"]; |
||
462 | } |
||
463 | foreach ($attackers as $attacker) { |
||
0 ignored issues
–
show
|
|||
464 | //if (!in_array($attacker["characterID"], $pilotsAdded)) self::addRelatedPilots($teamAs, $kill, $attacker); |
||
465 | } |
||
466 | } |
||
467 | } |
||
468 | |||
469 | /** |
||
470 | * @param array $array |
||
471 | * @return int |
||
472 | */ |
||
473 | private static function getUniquePilotCount($array) |
||
474 | { |
||
475 | $uniquePilots = array(); |
||
476 | foreach ($array as $hash => $kill) { |
||
477 | $split = explode("|", $hash); |
||
478 | $characterID = $split[2]; |
||
479 | if ($characterID > 0) $uniquePilots["$characterID"] = true; |
||
480 | } |
||
481 | return sizeof($uniquePilots); |
||
482 | } |
||
483 | |||
484 | /** |
||
485 | * @param array $array |
||
486 | * @param array $killHash |
||
487 | * @return array |
||
488 | */ |
||
489 | private static function addInfo($array, $killHash) |
||
490 | { |
||
491 | $results = array(); |
||
492 | foreach ($array as $hash => $kill) { |
||
493 | $split = explode("|", $hash); |
||
494 | $row = array(); |
||
495 | $row["shipTypeID"] = $split[0]; |
||
496 | $row["corporationID"] = $split[1]; |
||
497 | $row["characterID"] = $split[2]; |
||
498 | $row["allianceID"] = $split[3]; |
||
499 | $row["destroyed"] = in_array($hash, array_keys($killHash)) ? $killHash[$hash]["kill"]["victim"]["killID"] : 0; |
||
500 | $podHash = "670|" . $row["corporationID"] . "|" . $row["characterID"] . "|" . $row["allianceID"]; |
||
501 | $row["podded"] = in_array($podHash, $killHash) ? 1 : 0; |
||
502 | Info::addInfo($row); |
||
503 | $results[] = $row; |
||
504 | } |
||
505 | return $results; |
||
506 | } |
||
507 | |||
508 | /** |
||
509 | * @param array $a |
||
510 | * @param array $b |
||
511 | * @return int|null|string |
||
512 | */ |
||
513 | public static function shipGroupSort($a, $b) |
||
514 | { |
||
515 | $split1 = explode("|", $a); |
||
516 | $split2 = explode("|", $b); |
||
517 | $shipTypeID1 = $split1[0]; |
||
518 | $shipTypeID2 = $split2[0]; |
||
519 | |||
520 | $volumeID1 = Db::queryField("select volume from ccp_invTypes where typeID = :typeID", "volume", |
||
521 | array(":typeID" => $shipTypeID1)); |
||
522 | $volumeID2 = Db::queryField("select volume from ccp_invTypes where typeID = :typeID", "volume", |
||
523 | array(":typeID" => $shipTypeID2)); |
||
524 | |||
525 | if ($volumeID1 != $volumeID2) return $volumeID2 - $volumeID1; |
||
526 | |||
527 | if ($shipTypeID1 == $shipTypeID2) { |
||
528 | if ($split1[1] == $split2[1]) { |
||
529 | return $split1[2] - $split2[2]; |
||
530 | } |
||
531 | return $split1[1] - $split2[1]; |
||
532 | } |
||
533 | |||
534 | $groupID1 = Db::queryField("select groupID from ccp_invTypes where typeID = :typeID", "groupID", |
||
535 | array(":typeID" => $shipTypeID1)); |
||
536 | $groupID2 = Db::queryField("select groupID from ccp_invTypes where typeID = :typeID", "groupID", |
||
537 | array(":typeID" => $shipTypeID2)); |
||
538 | if ($groupID1 == $groupID2) { |
||
539 | return $shipTypeID2 - $shipTypeID1; |
||
540 | } |
||
541 | if ($groupID1 == $groupID2) return 0; |
||
542 | return $groupID2 - $groupID1; |
||
543 | } |
||
544 | } |
||
545 |
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.