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
|
|
|
class Social |
20
|
|
|
{ |
21
|
|
|
public static function beSocial($killID) |
22
|
|
|
{ |
23
|
|
|
global $beSocial; |
24
|
|
|
if (!isset($beSocial)) |
25
|
|
|
$beSocial = false; |
26
|
|
|
|
27
|
|
|
if ($beSocial == false) |
|
|
|
|
28
|
|
|
return; |
29
|
|
|
|
30
|
|
|
if ($killID < 0) |
31
|
|
|
return; |
32
|
|
|
|
33
|
|
|
$ircMin = 5000000000; |
34
|
|
|
$twitMin = 10000000000; |
35
|
|
|
|
36
|
|
|
$count = Db::queryField("select count(*) count from zz_social where killID = :killID", "count", array(":killID" => $killID), 0); |
37
|
|
|
if ($count != 0) |
38
|
|
|
return; |
39
|
|
|
|
40
|
|
|
// Get victim info |
41
|
|
|
$victimInfo = Db::queryRow("select * from zz_participants where dttm >= date_sub(now(), interval 1 day) and killID = :killID and isVictim = 1", array(":killID" => $killID)); |
42
|
|
|
if ($victimInfo == null) |
43
|
|
|
return; |
44
|
|
|
|
45
|
|
|
$totalPrice = $victimInfo["total_price"]; |
46
|
|
|
|
47
|
|
|
Info::addInfo($victimInfo); |
48
|
|
|
|
49
|
|
|
// Reduce spam of freighters and jump freighters |
50
|
|
|
$shipGroupID = $victimInfo["groupID"]; |
51
|
|
|
if (in_array($shipGroupID, array(513, 902))) |
52
|
|
|
{ |
53
|
|
|
$shipPrice = Price::getItemPrice($victimInfo["shipTypeID"], $victimInfo["dttm"]); |
54
|
|
|
$ircMin += $shipPrice; |
55
|
|
|
$twitMin += $shipPrice; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
$worthIt = false; |
59
|
|
|
$worthIt |= $totalPrice >= $ircMin; |
60
|
|
|
if (!$worthIt) |
61
|
|
|
return; |
62
|
|
|
|
63
|
|
|
$tweetIt = false; |
64
|
|
|
$tweetIt |= $totalPrice >= $twitMin; |
65
|
|
|
|
66
|
|
|
global $fullAddr, $twitterName; |
67
|
|
|
$url = "$fullAddr/kill/$killID/"; |
68
|
|
|
|
69
|
|
|
if ($url == "") |
70
|
|
|
$url = "$fullAddr/kill/$killID/"; |
71
|
|
|
|
72
|
|
|
$message = "|g|" . $victimInfo["shipName"] . "|n| worth |r|" . Util::formatIsk($totalPrice) . " ISK|n| was destroyed! $url"; |
73
|
|
|
|
74
|
|
|
if (!isset($victimInfo["characterName"])) |
75
|
|
|
$victimInfo["characterName"] = $victimInfo["corporationName"]; |
76
|
|
|
|
77
|
|
|
if (strlen($victimInfo["characterName"]) < 25) |
78
|
|
|
{ |
79
|
|
|
$name = $victimInfo["characterName"]; |
80
|
|
|
if (Util::endsWith($name, "s")) |
81
|
|
|
$name .= "'"; |
82
|
|
|
else |
83
|
|
|
$name .= "'s"; |
84
|
|
|
|
85
|
|
|
$message = "$name $message"; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
Db::execute("insert into zz_social (killID) values (:killID)", array(":killID" => $killID)); |
89
|
|
|
|
90
|
|
|
Log::irc("$message"); |
91
|
|
|
$message = Log::stripIRCColors($message); |
92
|
|
|
|
93
|
|
|
$message .= " #tweetfleet #eveonline"; |
94
|
|
|
if (strlen($message) > 120) |
95
|
|
|
$message = str_replace(" worth ", ": ", $message); |
96
|
|
|
|
97
|
|
|
if (strlen($message) > 120) |
98
|
|
|
$message = str_replace(" was destroyed!", "", $message); |
99
|
|
|
|
100
|
|
|
if ($tweetIt && strlen($message) <= 120) |
101
|
|
|
{ |
102
|
|
|
$ret = Twit::sendMessage($message); |
103
|
|
|
$twit = "https://twitter.com/{$twitterName}/status/" . $ret->id; |
104
|
|
|
Log::irc("Message was also tweeted: |g|$twit"); |
105
|
|
|
} |
106
|
|
|
} |
107
|
|
|
} |
108
|
|
|
|
When comparing two booleans, it is generally considered safer to use the strict comparison operator.