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
|
|
|
/** |
20
|
|
|
* Parser for raw killmails from ingame EVE. |
21
|
|
|
*/ |
22
|
|
|
|
23
|
|
|
class War |
24
|
|
|
{ |
25
|
|
|
public static function getWars($id, $active = true, $combined = false) |
26
|
|
|
{ |
27
|
|
|
if (!self::isAlliance($id)) |
28
|
|
|
{ |
29
|
|
|
$alliID = Db::queryField("select allianceID from zz_corporations where corporationID = :id", "allianceID", array(":id" => $id)); |
30
|
|
|
if ($alliID != 0) $id = $alliID; |
31
|
|
|
} |
32
|
|
|
$active = $active ? "" : "not"; |
33
|
|
|
$aggressing = Db::query("select * from zz_wars where aggressor = :id and timeFinished is $active null", array(":id" => $id)); |
34
|
|
|
$defending = Db::query("select * from zz_wars where defender = :id and timeFinished is $active null", array(":id" => $id)); |
35
|
|
|
if ($combined) return array_merge($aggressing, $defending); |
36
|
|
|
return array("agr" => $aggressing, "dfd" => $defending); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
public static function getKillIDWarInfo($killID) |
40
|
|
|
{ |
41
|
|
|
$warID = Db::queryField("select warID from zz_warmails where killID = :killID", "warID", array(":killID" => $killID)); |
42
|
|
|
return self::getWarInfo($warID); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public static function getWarInfo($warID) |
46
|
|
|
{ |
47
|
|
|
$warInfo = array(); |
48
|
|
|
if ($warID == null) return $warInfo; |
49
|
|
|
$warInfo = Db::queryRow("select * from zz_wars where warID = :warID", array(":warID" => $warID)); |
50
|
|
|
|
51
|
|
|
$agr = $warInfo["aggressor"]; |
52
|
|
|
$agrIsAlliance = self::isAlliance($agr); |
53
|
|
|
$agrName = $agrIsAlliance ? Info::getAlliName($agr) : Info::getCorpName($agr); |
54
|
|
|
$warInfo["agrName"] = $agrName; |
55
|
|
|
$warInfo["agrLink"] = ($agrIsAlliance ? "/alliance/" : "/corporation/") . "$agr/"; |
56
|
|
|
|
57
|
|
|
$dfd = $warInfo["defender"]; |
58
|
|
|
$dfdIsAlliance = self::isAlliance($dfd); |
59
|
|
|
$dfdName = $dfdIsAlliance ? Info::getAlliName($dfd) : Info::getCorpName($dfd); |
60
|
|
|
$warInfo["dfdName"] = $dfdName; |
61
|
|
|
$warInfo["dfdLink"] = ($dfdIsAlliance ? "/alliance/" : "/corporation/") . "$dfd/"; |
62
|
|
|
|
63
|
|
|
$warInfo["dscr"] = "$agrName vs $dfdName"; |
64
|
|
|
return $warInfo; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
public static function isAlliance($entityID) |
68
|
|
|
{ |
69
|
|
|
return null != Db::queryField("select allianceID from zz_alliances where allianceID = :id", "allianceID", array(":id" => $entityID)); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
public static function getNamedWars($name, $query) |
73
|
|
|
{ |
74
|
|
|
$warIDs = Db::query($query); |
75
|
|
|
$wars = array(); |
76
|
|
|
foreach($warIDs as $row) |
77
|
|
|
{ |
78
|
|
|
$wars[] = War::getWarInfo($row["warID"]); |
|
|
|
|
79
|
|
|
} |
80
|
|
|
return array("name" => $name, "wars" => $wars); |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|
This check looks for accesses to local static members using the fully qualified name instead of
self::
.While this is perfectly valid, the fully qualified name of
Certificate::TRIPLEDES_CBC
could just as well be replaced byself::TRIPLEDES_CBC
. Referencing local members withself::
assured the access will still work when the class is renamed, makes it perfectly clear that the member is in fact local and will usually be shorter.