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 | /* 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 | $key = $input[0]; |
||
20 | if (!isset($input[1])) { |
||
21 | $app->redirect("/"); |
||
22 | } |
||
23 | |||
24 | $id = $input[1]; |
||
25 | $pageType = @$input[2]; |
||
26 | |||
27 | if (strlen("$id") > 11) { |
||
28 | $app->redirect("/"); |
||
29 | } |
||
30 | |||
31 | if ($pageType == "history") { |
||
32 | $app->redirect("../stats/"); |
||
33 | } |
||
34 | |||
35 | $validSubPages = array("page", "group", "month", "year", "ship"); |
||
36 | $validPageTypes = array("overview", "kills", "losses", "solo", "stats", "wars", "supers", "page", "api", "corpstats", "top", "topalltime"); |
||
37 | if (!in_array($pageType, $validPageTypes) && $pageType != "" && !in_array($pageType, $validSubPages)) { |
||
38 | $app->redirect("/$key/$id/"); |
||
39 | } |
||
40 | |||
41 | if ($pageType == "" || in_array($pageType, $validSubPages)) { |
||
42 | $pageType = "overview"; |
||
43 | } |
||
44 | |||
45 | $map = array( |
||
46 | "corporation" => array("column" => "corporation", "id" => "Info::getCorpId", "details" => "Info::getCorpDetails", "mixed" => true), |
||
47 | "character" => array("column" => "character", "id" => "Info::getCharId", "details" => "Info::getPilotDetails", "mixed" => true), |
||
48 | "alliance" => array("column" => "alliance", "id" => "Info::getAlliId", "details" => "Info::getAlliDetails", "mixed" => true), |
||
49 | "faction" => array("column" => "faction", "id" => "Info::getFactionId", "details" => "Info::getFactionDetails", "mixed" => true), |
||
50 | "system" => array("column" => "solarSystem", "id" => "Info::getSystemId", "details" => "Info::getSystemDetails", "mixed" => true), |
||
51 | "region" => array("column" => "region", "id" => "Info::getRegionId", "details" => "Info::getRegionDetails", "mixed" => true), |
||
52 | "group" => array("column" => "group", "id" => "Info::getGroupIDFromName", "details" => "Info::getGroupDetails", "mixed" => true), |
||
53 | "ship" => array("column" => "shipType", "id" => "Info::getShipId", "details" => "Info::getShipDetails", "mixed" => true), |
||
54 | ); |
||
55 | if (!array_key_exists($key, $map)) { |
||
56 | $app->notFound(); |
||
57 | } |
||
58 | |||
59 | if (!is_numeric($id)) { |
||
60 | $function = $map[$key]["id"]; |
||
61 | $id = call_user_func($function, $id); |
||
62 | if ($id > 0) { |
||
63 | $app->redirect("/" . $key . "/" . $id . "/", 301); |
||
64 | } else { |
||
65 | $app->notFound(); |
||
66 | } |
||
67 | |||
68 | } |
||
69 | |||
70 | if ($id <= 0) { |
||
71 | $app->notFound(); |
||
72 | } |
||
73 | |||
74 | $parameters = Util::convertUriToParameters(); |
||
75 | @$page = max(1, $parameters["page"]); |
||
0 ignored issues
–
show
|
|||
76 | global $loadGroupShips; // Can't think of another way to do this just yet |
||
77 | $loadGroupShips = $key == "group"; |
||
78 | |||
79 | $limit = 50; |
||
80 | $parameters["limit"] = $limit; |
||
81 | $parameters["page"] = $page; |
||
82 | try { |
||
83 | $detail = call_user_func($map[$key]["details"], $id, $parameters); |
||
84 | if (isset($detail["valid"]) && $detail["valid"] == false) { |
||
85 | $app->notFound(); |
||
86 | } |
||
87 | |||
88 | } catch (Exception $ex) { |
||
89 | $app->render("error.html", array("message" => "There was an error fetching information for the $key you specified.")); |
||
90 | return; |
||
91 | } |
||
92 | //$totalKills = isset($detail["shipsDestroyed"]) ? $detail["shipsDestroyed"] : 0; |
||
93 | //$totalLosses = isset($detail["shipsLost"]) ? $detail["shipsLost"] : 0; |
||
94 | $pageName = isset($detail[$map[$key]["column"] . "Name"]) ? $detail[$map[$key]["column"] . "Name"] : "???"; |
||
95 | $columnName = $map[$key]["column"] . "ID"; |
||
96 | $mixedKills = $pageType == "overview" && $map[$key]["mixed"] && UserConfig::get("mixKillsWithLosses", true); |
||
97 | |||
98 | $mixed = $pageType == "overview" ? Kills::getKills($parameters) : array(); |
||
99 | $kills = $pageType == "kills" ? Kills::getKills($parameters) : array(); |
||
100 | $losses = $pageType == "losses" ? Kills::getKills($parameters) : array(); |
||
101 | |||
102 | if ($pageType != "solo" || $key == "faction") { |
||
103 | $soloKills = array(); |
||
104 | //$soloCount = 0; |
||
105 | } else { |
||
106 | $soloParams = $parameters; |
||
107 | if (!isset($parameters["kills"]) || !isset($parameters["losses"])) { |
||
108 | $soloParams["mixed"] = true; |
||
109 | } |
||
110 | |||
111 | $soloKills = Kills::getKills($soloParams); |
||
112 | //$soloCount = Db::queryField("select count(killID) count from zz_participants where " . $map[$key]["column"] . "ID = :id and isVictim = 1 and number_involved = 1", "count", array(":id" => $id), 3600); |
||
113 | } |
||
114 | //$soloPages = ceil($soloCount / $limit); |
||
115 | $solo = Kills::mergeKillArrays($soloKills, array(), $limit, $columnName, $id); |
||
116 | |||
117 | $validAllTimePages = array("character", "corporation", "alliance"); |
||
118 | $topLists = array(); |
||
119 | $topKills = array(); |
||
120 | if ($pageType == "top" || ($pageType == "topalltime" && in_array($key, $validAllTimePages))) { |
||
121 | $topParameters = $parameters; // array("limit" => 10, "kills" => true, "$columnName" => $id); |
||
122 | $topParameters["limit"] = 10; |
||
123 | |||
124 | if ($pageType != "topalltime") { |
||
125 | if (!isset($topParameters["year"])) { |
||
126 | $topParameters["year"] = date("Y"); |
||
127 | } |
||
128 | |||
129 | if (!isset($topParameters["month"])) { |
||
130 | $topParameters["month"] = date("m"); |
||
131 | } |
||
132 | |||
133 | } |
||
134 | if (!array_key_exists("kills", $topParameters) && !array_key_exists("losses", $topParameters)) { |
||
135 | $topParameters["kills"] = true; |
||
136 | } |
||
137 | |||
138 | $topLists[] = array("type" => "character", "data" => Stats::getTopPilots($topParameters, true)); |
||
139 | $topLists[] = array("type" => "corporation", "data" => Stats::getTopCorps($topParameters, true)); |
||
140 | $topLists[] = array("type" => "alliance", "data" => Stats::getTopAllis($topParameters, true)); |
||
141 | $topLists[] = array("type" => "ship", "data" => Stats::getTopShips($topParameters, true)); |
||
142 | $topLists[] = array("type" => "system", "data" => Stats::getTopSystems($topParameters, true)); |
||
143 | $topLists[] = array("type" => "weapon", "data" => Stats::getTopWeapons($topParameters, true)); |
||
144 | |||
145 | if (isset($detail["factionID"]) && $detail["factionID"] != 0 && $key != "faction") { |
||
146 | $topParameters["!factionID"] = 0; |
||
147 | $topLists[] = array("name" => "Top Faction Characters", "type" => "character", "data" => Stats::getTopPilots($topParameters, true)); |
||
148 | $topLists[] = array("name" => "Top Faction Corporations", "type" => "corporation", "data" => Stats::getTopCorps($topParameters, true)); |
||
149 | $topLists[] = array("name" => "Top Faction Alliances", "type" => "alliance", "data" => Stats::getTopAllis($topParameters, true)); |
||
150 | } |
||
151 | } else { |
||
152 | $p = $parameters; |
||
153 | $numDays = 7; |
||
154 | $p["limit"] = 10; |
||
155 | $p["pastSeconds"] = $numDays * 86400; |
||
156 | $p["kills"] = $pageType != "losses"; |
||
157 | |||
158 | if ($key != "character") { |
||
159 | $topLists[] = Info::doMakeCommon("Top Characters", "characterID", Stats::getTopPilots($p)); |
||
160 | if ($key != "corporation") { |
||
161 | $topLists[] = Info::doMakeCommon("Top Corporations", "corporationID", Stats::getTopCorps($p)); |
||
162 | if ($key != "alliance") { |
||
163 | $topLists[] = Info::doMakeCommon("Top Alliances", "allianceID", Stats::getTopAllis($p)); |
||
164 | } |
||
165 | } |
||
166 | } |
||
167 | if ($key != "ship") { |
||
168 | $topLists[] = Info::doMakeCommon("Top Ships", "shipTypeID", Stats::getTopShips($p)); |
||
169 | } |
||
170 | |||
171 | if ($key != "system") { |
||
172 | $topLists[] = Info::doMakeCommon("Top Systems", "solarSystemID", Stats::getTopSystems($p)); |
||
173 | } |
||
174 | |||
175 | $p["limit"] = 5; |
||
176 | $topKills = Stats::getTopIsk($p); |
||
177 | } |
||
178 | |||
179 | $corpList = array(); |
||
180 | if ($pageType == "api") { |
||
181 | $corpList = Info::getCorps($id); |
||
182 | } |
||
183 | |||
184 | $corpStats = array(); |
||
185 | if ($pageType == "corpstats") { |
||
186 | $corpStats = Info::getCorpStats($id, $parameters); |
||
187 | } |
||
188 | |||
189 | $onlyHistory = array("character", "corporation", "alliance"); |
||
190 | if ($pageType == "stats" && in_array($key, $onlyHistory)) { |
||
191 | $detail["history"] = Summary::getMonthlyHistory($columnName, $id); |
||
192 | } else { |
||
193 | $detail["history"] = array(); |
||
194 | } |
||
195 | |||
196 | // Figure out if the character or corporation has any API keys in the database |
||
197 | $apiVerified = false; |
||
198 | if (in_array($key, array("character", "corporation"))) { |
||
199 | if ($key == "character") { |
||
200 | $count = Db::queryField("SELECT count(1) count FROM zz_api_characters WHERE characterID = :characterID", "count", array(":characterID" => $id)); |
||
201 | $apiVerified = $count > 0 ? 1 : 0; |
||
202 | } else { |
||
203 | $count = Db::queryField("select count(1) count from zz_api_characters where isDirector = 'T' and corporationID = :corpID", "count", array(":corpID" => $id)); |
||
204 | $apiVerified = $count > 0 ? 1 : 0; |
||
205 | } |
||
206 | } |
||
207 | |||
208 | $cnt = 0; |
||
209 | $cnid = 0; |
||
210 | $stats = array(); |
||
211 | $totalcount = ceil(count($detail["stats"]) / 4); |
||
212 | foreach ($detail["stats"] as $q) { |
||
213 | if ($cnt == $totalcount) { |
||
214 | $cnid++; |
||
215 | $cnt = 0; |
||
216 | } |
||
217 | $stats[$cnid][] = $q; |
||
218 | $cnt++; |
||
219 | } |
||
220 | if ($mixedKills) { |
||
221 | $kills = Kills::mergeKillArrays($mixed, array(), $limit, $columnName, $id); |
||
222 | } |
||
223 | |||
224 | $prevID = null; |
||
225 | $nextID = null; |
||
226 | if (in_array($key, array("character", "corporation", "alliance", "faction"))) { |
||
227 | if ($key == "faction") { |
||
228 | $table = "ccp_zfactions"; |
||
229 | } else { |
||
230 | $table = "zz_${key}s"; |
||
231 | } |
||
232 | |||
233 | $column = "${key}ID"; |
||
234 | $prevID = Db::queryField("select $column from $table where $column < :id order by $column desc limit 1", $column, array(":id" => $id), 300); |
||
235 | $nextID = Db::queryField("select $column from $table where $column > :id order by $column asc limit 1", $column, array(":id" => $id), 300); |
||
236 | } |
||
237 | |||
238 | $warID = (int) $id; |
||
239 | $extra = array(); |
||
240 | $extra["hasWars"] = Db::queryField("select count(distinct warID) count from zz_wars where aggressor = $warID or defender = $warID", "count"); |
||
241 | $extra["wars"] = array(); |
||
242 | if ($pageType == "wars" && $extra["hasWars"]) { |
||
243 | $extra["wars"][] = War::getNamedWars("Active Wars - Aggressor", "select * from zz_wars where aggressor = $warID and timeFinished is null order by timeStarted desc"); |
||
244 | $extra["wars"][] = War::getNamedWars("Active Wars - Defending", "select * from zz_wars where defender = $warID and timeFinished is null order by timeStarted desc"); |
||
245 | $extra["wars"][] = War::getNamedWars("Closed Wars - Aggressor", "select * from zz_wars where aggressor = $warID and timeFinished is not null order by timeFinished desc"); |
||
246 | $extra["wars"][] = War::getNamedWars("Closed Wars - Defending", "select * from zz_wars where defender = $warID and timeFinished is not null order by timeFinished desc"); |
||
247 | } |
||
248 | |||
249 | $filter = ""; |
||
250 | switch ($key) { |
||
251 | case "corporation": |
||
252 | case "alliance": |
||
253 | case "faction": |
||
254 | $filter = "{$key}ID = :id"; |
||
255 | } |
||
256 | if ($filter != "") { |
||
257 | //$minKillID = Db::queryField("select min(killID) killID from zz_participants where dttm >= date_sub(now(), interval 90 day) and dttm < date_sub(now(), interval 89 day)", "killID", array(), 900); |
||
258 | //if ($minKillID > 0) { |
||
259 | // $hasSupers = Db::queryField("select killID from zz_participants where isVictim = 0 and groupID in (30, 659) and $filter and killID > $minKillID limit 1", "killID", array(":id" => $id)); |
||
260 | //} else { |
||
261 | // $hasSupers = 0; |
||
262 | //} |
||
263 | |||
264 | $extra["hasSupers"] = 0; //$hasSupers > 0; |
||
265 | $extra["supers"] = array(); |
||
266 | if ($pageType == "supers" && $hasSupers) { |
||
267 | $months = 3; |
||
268 | $data = array(); |
||
269 | $data["titans"]["data"] = Db::query("select distinct characterID, count(distinct killID) kills, shipTypeID from zz_participants where killID >= $minKillID and isVictim = 0 and groupID = 30 and $filter group by characterID order by 2 desc", array(":id" => $id), 900); |
||
270 | $data["titans"]["title"] = "Titans"; |
||
271 | |||
272 | $data["moms"]["data"] = Db::query("select distinct characterID, count(distinct killID) kills, shipTypeID from zz_participants where killID >= $minKillID and isVictim = 0 and groupID = 659 and $filter group by characterID order by 2 desc", array(":id" => $id), 900); |
||
273 | $data["moms"]["title"] = "Supercarriers"; |
||
274 | |||
275 | Info::addInfo($data); |
||
276 | $extra["supers"] = $data; |
||
277 | $extra["hasSupers"] = sizeof($data["titans"]["data"]) || sizeof($data["moms"]["data"]); |
||
278 | } |
||
279 | } |
||
280 | |||
281 | $renderParams = array("pageName" => $pageName, "kills" => $kills, "losses" => $losses, "detail" => $detail, "page" => $page, "topKills" => $topKills, "mixed" => $mixedKills, "key" => $key, "id" => $id, "pageType" => $pageType, "solo" => $solo, "topLists" => $topLists, "corps" => $corpList, "corpStats" => $corpStats, "summaryTable" => $stats, "pager" => (sizeof($kills) + sizeof($losses) >= $limit), "datepicker" => true, "apiVerified" => $apiVerified, "prevID" => $prevID, "nextID" => $nextID, "extra" => $extra); |
||
282 | |||
283 | //$app->etag(md5(serialize($renderParams))); |
||
284 | //$app->expires("+5 minutes"); |
||
285 | $app->render("overview.html", $renderParams); |
||
286 |
If you suppress an error, we recommend checking for the error condition explicitly: