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
|
|
|
global $rawKillmailParser; |
20
|
|
|
|
21
|
|
|
$error = ""; |
22
|
|
|
|
23
|
|
|
if($_POST) |
24
|
|
|
{ |
25
|
|
|
$keyid = Util::getPost("keyid"); |
26
|
|
|
$vcode = Util::getPost("vcode"); |
27
|
|
|
$killmail = Util::getPost("killmail"); |
28
|
|
|
$killmailurl = Util::getPost("killmailurl"); |
29
|
|
|
$rawKillmail = Util::getPost("rawkillmail"); |
30
|
|
|
|
31
|
|
|
// Apikey stuff |
32
|
|
|
if($keyid || $vcode) |
|
|
|
|
33
|
|
|
{ |
34
|
|
|
$check = Api::checkAPI($keyid, $vcode); |
35
|
|
|
if($check == "success") |
36
|
|
|
{ |
37
|
|
|
Db::execute("insert ignore into zz_api (keyID, vCode) values (:keyID, :vCode)", array(":keyID" => $keyid, ":vCode" => $vcode)); |
38
|
|
|
$error = "Your API Key has been added."; |
39
|
|
|
} |
40
|
|
|
else |
41
|
|
|
{ |
42
|
|
|
$error = $check; |
43
|
|
|
} |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
// Crest Killmail |
47
|
|
|
if ($killmailurl) |
|
|
|
|
48
|
|
|
{ |
49
|
|
|
// Looks like http://public-crest.eveonline.com/killmails/30290604/787fb3714062f1700560d4a83ce32c67640b1797/ |
50
|
|
|
$exploded = explode("/", $killmailurl); |
51
|
|
|
|
52
|
|
|
if (count($exploded) != 7) $error = "Invalid killmail link."; |
53
|
|
|
else |
54
|
|
|
{ |
55
|
|
|
if((int) $exploded[4] <= 0) $error = "Invalid killmail link"; |
56
|
|
|
elseif(strlen($exploded[5]) != 40) $error = "Invalid killmail link"; |
57
|
|
|
else |
58
|
|
|
{ |
59
|
|
|
$killID = (int) $exploded[4]; |
60
|
|
|
$hash = (string) $exploded[5]; |
61
|
|
|
$i = Db::execute("insert ignore into zz_crest_killmail (killID, hash) values (:killID, :hash)", array(":killID" => $killID, ":hash" => $hash)); |
62
|
|
|
Db::execute("update zz_crest_killmail set processed = 0 where processed = -1 and killID = :killID", array(":killID" => $killID)); |
63
|
|
|
|
64
|
|
|
$timer = new Timer(); |
65
|
|
|
do { |
66
|
|
|
// Has the kill been processed? |
67
|
|
|
$crestStatus = Db::queryField("select processed from zz_crest_killmail where killID = :killID", "processed", array(":killID" => $killID), 0); |
68
|
|
|
$processed = Db::queryField("select processed from zz_killmails where killID = :killID", "processed", array(":killID" => $killID), 0); |
69
|
|
|
if ($crestStatus == -1) $error = "There is an error with the killmail at the CREST endpoint. We'll let CCP know. Your kill has still been submitted and we'll process it as soon as the error has been fixed. Thank you."; |
70
|
|
|
else if ($processed == 1) $app->redirect("/detail/$killID/"); |
71
|
|
|
else if ($processed == 2) $error = "There was an error while processing the killmail. Please open a ticket and include the external killmail link so we can examine what happened. Thank you."; |
72
|
|
|
else if ($processed == 3) $error = "Only PvP mails are accepted, the mail you just submitted was a PvE killmail."; |
73
|
|
|
else if (date("Gi") < 105) $error = "Between 00:00 and 01:05 no kills are processed while we wait for CCP's Market CREST cache to clear... However, the kill has been stored and will be processed at 01:05"; |
74
|
|
|
else usleep(450000); |
75
|
|
|
} while ($timer->stop() < 60000 && $error == ""); |
76
|
|
|
if ($error == "") $error = "We waited 60 seconds for the kill to be processed but the server must be busy atm, please wait!"; |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
// Raw manual killmail |
82
|
|
|
if($rawKillmailParser && $rawKillmail) |
|
|
|
|
83
|
|
|
{ |
84
|
|
|
$userData = User::getUserInfo(); |
85
|
|
|
if(User::isLoggedIn()) |
86
|
|
|
{ |
87
|
|
|
$return = Parser::parseRaw($killmail, $userData["id"]); |
88
|
|
|
|
89
|
|
|
if(isset($return["success"])) |
90
|
|
|
$app->redirect("/detail/" . $return["success"] . "/"); |
91
|
|
|
|
92
|
|
|
if(isset($return["dupe"])) |
93
|
|
|
$app->redirect("/detail/" . $return["dupe"] . "/"); |
94
|
|
|
|
95
|
|
|
if(isset($return["error"])) |
96
|
|
|
$error = $return["error"]; |
97
|
|
|
} |
98
|
|
|
else |
99
|
|
|
$error = "sorry, you need to be logged in to post raw killmails"; |
100
|
|
|
} |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
if(!is_array($error)) $error = array($error); |
104
|
|
|
|
105
|
|
|
$app->render("postmail.html", array("message" => $error)); |
106
|
|
|
|
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: