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
|
|
|
// Find the groupID (GroupID can only be numeric...)
|
20
|
|
|
$groupID = (int) Db::queryField("SELECT groupID FROM ccp_invTypes WHERE groupID = :groupID", "groupID", array(":groupID" => (int) $group), 3600);
|
21
|
|
|
|
22
|
|
|
// If the groupID we get from above is zero, don't even bother anymore.....
|
23
|
|
|
if($groupID == 0)
|
24
|
|
|
$app->redirect("/");
|
25
|
|
|
|
26
|
|
|
// Now we figure out all the parameters
|
27
|
|
|
$parameters = Util::convertUriToParameters();
|
28
|
|
|
|
29
|
|
|
// Unset the group => id, and make it groupID => id
|
30
|
|
|
unset($parameters["group"]);
|
31
|
|
|
$parameters["groupID"] = $groupID;
|
32
|
|
|
$parameters["index"] = "vGroupID_dttm";
|
33
|
|
|
|
34
|
|
|
// Make sure that the pageType is correct..
|
35
|
|
|
$subPageTypes = array("page", "group", "month", "year", "ship");
|
36
|
|
|
if(in_array($pageType, $subPageTypes))
|
37
|
|
|
$pageType = "overview";
|
38
|
|
|
|
39
|
|
|
// Some defaults
|
40
|
|
|
@$page = max(1, $parameters["page"]);
|
|
|
|
|
41
|
|
|
$limit = 50;
|
42
|
|
|
$parameters["limit"] = $limit;
|
43
|
|
|
$parameters["page"] = $page;
|
44
|
|
|
|
45
|
|
|
// and now we fetch the info!
|
46
|
|
|
$detail = Info::getGroupDetails($groupID, $parameters);
|
|
|
|
|
47
|
|
|
|
48
|
|
|
// Define the page information and scope etc.
|
49
|
|
|
$pageName = isset($detail["groupName"]) ? $detail["groupName"] : "???";
|
50
|
|
|
$columnName = "groupID";
|
51
|
|
|
$mixedKills = $pageType == "overview" && UserConfig::get("mixKillsWithLosses", true);
|
52
|
|
|
|
53
|
|
|
// Load kills for the various pages.
|
54
|
|
|
$mixed = $pageType == "overview" ? Kills::getKills($parameters) : array();
|
55
|
|
|
$kills = $pageType == "kills" ? Kills::getKills($parameters) : array();
|
56
|
|
|
|
57
|
|
|
// Solo parameters
|
58
|
|
|
//$soloParams = $parameters;
|
59
|
|
|
//if (!isset($parameters["kills"])) {
|
60
|
|
|
// $soloParams["mixed"] = true;
|
61
|
|
|
//}
|
62
|
|
|
|
63
|
|
|
// Solo kills
|
64
|
|
|
//$soloKills = Kills::getKills($soloParams);
|
65
|
|
|
//$solo = Kills::mergeKillArrays($soloKills, array(), $limit, $columnName, $groupID);
|
66
|
|
|
|
67
|
|
|
$topLists = array();
|
68
|
|
|
$topKills = array();
|
69
|
|
|
if ($pageType == "top" || $pageType == "topalltime") {
|
70
|
|
|
$topParameters = $parameters; // array("limit" => 10, "kills" => true, "$columnName" => $groupID);
|
71
|
|
|
$topParameters["limit"] = 10;
|
72
|
|
|
|
73
|
|
|
if ($pageType != "topalltime") {
|
74
|
|
|
if (!isset($topParameters["year"])) {
|
75
|
|
|
$topParameters["year"] = date("Y");
|
76
|
|
|
}
|
77
|
|
|
|
78
|
|
|
if (!isset($topParameters["month"])) {
|
79
|
|
|
$topParameters["month"] = date("m");
|
80
|
|
|
}
|
81
|
|
|
|
82
|
|
|
}
|
83
|
|
|
if (!array_key_exists("kills", $topParameters) && !array_key_exists("losses", $topParameters)) {
|
84
|
|
|
$topParameters["kills"] = true;
|
85
|
|
|
}
|
86
|
|
|
|
87
|
|
|
$topLists[] = array("type" => "character", "data" => Stats::getTopPilots($topParameters, true));
|
88
|
|
|
$topLists[] = array("type" => "corporation", "data" => Stats::getTopCorps($topParameters, true));
|
89
|
|
|
$topLists[] = array("type" => "alliance", "data" => Stats::getTopAllis($topParameters, true));
|
90
|
|
|
$topLists[] = array("type" => "ship", "data" => Stats::getTopShips($topParameters, true));
|
91
|
|
|
$topLists[] = array("type" => "system", "data" => Stats::getTopSystems($topParameters, true));
|
92
|
|
|
$topLists[] = array("type" => "weapon", "data" => Stats::getTopWeapons($topParameters, true));
|
93
|
|
|
}
|
94
|
|
|
else
|
95
|
|
|
{
|
96
|
|
|
$p = $parameters;
|
97
|
|
|
$numDays = 7;
|
98
|
|
|
$p["limit"] = 10;
|
99
|
|
|
$p["pastSeconds"] = $numDays * 86400;
|
100
|
|
|
$p["kills"] = $pageType != "losses";
|
101
|
|
|
|
102
|
|
|
$topLists[] = Info::doMakeCommon("Top Characters", "characterID", Stats::getTopPilots($p));
|
103
|
|
|
$topLists[] = Info::doMakeCommon("Top Corporations", "corporationID", Stats::getTopCorps($p));
|
104
|
|
|
$topLists[] = Info::doMakeCommon("Top Systems", "solarSystemID", Stats::getTopSystems($p));
|
105
|
|
|
|
106
|
|
|
$p["limit"] = 5;
|
107
|
|
|
$topKills = Stats::getTopIsk($p);
|
108
|
|
|
}
|
109
|
|
|
|
110
|
|
|
// Mixed kills yo!
|
111
|
|
|
if ($mixedKills)
|
112
|
|
|
$kills = Kills::mergeKillArrays($mixed, array(), $limit, $columnName, $groupID);
|
113
|
|
|
|
114
|
|
|
// Find the next and previous groupID
|
115
|
|
|
$prevID = Db::queryField("select groupID from ccp_invTypes where groupID < :id order by groupID desc limit 1", "groupID", array(":id" => $groupID), 300);
|
116
|
|
|
$nextID = Db::queryField("select groupID from ccp_invTypes where groupID > :id order by groupID asc limit 1", "groupID", array(":id" => $groupID), 300);
|
117
|
|
|
|
118
|
|
|
$renderParams = array(
|
119
|
|
|
"pageName" => $pageName,
|
120
|
|
|
"kills" => $kills,
|
121
|
|
|
"detail" => $detail,
|
122
|
|
|
"page" => $page,
|
123
|
|
|
"topKills" => $topKills,
|
124
|
|
|
"mixed" => $mixedKills,
|
125
|
|
|
"key" => "group",
|
126
|
|
|
"id" => $groupID,
|
127
|
|
|
"pageType" => $pageType,
|
128
|
|
|
// "solo" => $solo,
|
129
|
|
|
"topLists" => $topLists,
|
130
|
|
|
"pager" => (sizeof($kills) >= $limit),
|
131
|
|
|
"datepicker" => true,
|
132
|
|
|
"prevID" => $prevID,
|
133
|
|
|
"nextID" => $nextID
|
134
|
|
|
);
|
135
|
|
|
|
136
|
|
|
$app->etag(md5(serialize($renderParams)));
|
137
|
|
|
$app->expires("+5 minutes");
|
138
|
|
|
$app->render("overview.html", $renderParams);
|
139
|
|
|
|
If you suppress an error, we recommend checking for the error condition explicitly: