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 | /** |
||
3 | * The MIT License (MIT) |
||
4 | * |
||
5 | * Copyright (c) 2016 Robert Sardinia |
||
6 | * |
||
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
||
8 | * of this software and associated documentation files (the "Software"), to deal |
||
9 | * in the Software without restriction, including without limitation the rights |
||
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||
11 | * copies of the Software, and to permit persons to whom the Software is |
||
12 | * furnished to do so, subject to the following conditions: |
||
13 | * |
||
14 | * The above copyright notice and this permission notice shall be included in all |
||
15 | * copies or substantial portions of the Software. |
||
16 | * |
||
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
||
23 | * SOFTWARE. |
||
24 | */ |
||
25 | |||
26 | |||
27 | use discord\discord; |
||
28 | |||
29 | /** |
||
30 | * Class notifications |
||
31 | * @property string allianceOnly |
||
32 | */ |
||
33 | class notifications |
||
0 ignored issues
–
show
|
|||
34 | { |
||
35 | public $config; |
||
36 | public $discord; |
||
37 | public $logger; |
||
38 | private $toDiscordChannel; |
||
39 | private $newestNotificationID; |
||
40 | private $maxID; |
||
41 | private $apiKey; |
||
42 | private $numberOfKeys; |
||
43 | private $fuelChannel; |
||
44 | private $fuelSkip; |
||
45 | private $guild; |
||
46 | |||
47 | /** |
||
48 | * @param $config |
||
49 | * @param $discord |
||
50 | * @param $logger |
||
51 | */ |
||
52 | public function init($config, $discord, $logger) |
||
53 | { |
||
54 | $this->config = $config; |
||
55 | $this->discord = $discord; |
||
56 | $this->logger = $logger; |
||
57 | $this->toDiscordChannel = $config['plugins']['notifications']['channelID']; |
||
58 | $this->allianceOnly = strtolower($config['plugins']['notifications']['allianceOnly']); |
||
59 | $this->fuelChannel = $config['plugins']['fuel']['channelID']; |
||
60 | $this->fuelSkip = $config['plugins']['fuel']['skip']; |
||
61 | $this->newestNotificationID = getPermCache('newestNotificationID'); |
||
62 | $this->maxID = 0; |
||
63 | $this->apiKey = $config['eve']['apiKeys']; |
||
64 | $this->guild = $config['bot']['guild']; |
||
65 | |||
66 | //check if allianceOnly is set |
||
67 | if (null === $this->allianceOnly) { |
||
68 | $this->allianceOnly = 'false'; |
||
69 | } |
||
70 | |||
71 | //Get number of keys |
||
72 | $x = 0; |
||
73 | View Code Duplication | foreach ($this->apiKey as $apiKey) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
74 | //Check if api is set |
||
75 | if ($apiKey['keyID'] === '' || $apiKey['vCode'] === '' || $apiKey['characterID'] === null) { |
||
76 | continue; |
||
77 | } |
||
78 | $x++; |
||
79 | } |
||
80 | $this->numberOfKeys = $x; |
||
81 | } |
||
82 | |||
83 | /** |
||
84 | * |
||
85 | */ |
||
86 | public function tick() |
||
87 | { |
||
88 | // What was the servers last reported state |
||
89 | $lastStatus = getPermCache('serverState'); |
||
90 | if ($lastStatus === 'online') { |
||
91 | foreach ($this->apiKey as $apiKey) { |
||
92 | //Check if api is set |
||
93 | if ($apiKey['keyID'] === '' || $apiKey['vCode'] === '' || $apiKey['characterID'] === null) { |
||
94 | continue; |
||
95 | } |
||
96 | //Get |
||
97 | $lastChecked = getPermCache('notificationsLastChecked'); |
||
98 | if ($lastChecked <= time()) { |
||
99 | $lastCheckedAPI = getPermCache("notificationsLastChecked{$apiKey['keyID']}"); |
||
100 | if ($lastCheckedAPI <= time()) { |
||
101 | $this->logger->addInfo("Notifications: Checking API Key {$apiKey['keyID']} for notifications.."); |
||
102 | $this->getNotifications($apiKey['keyID'], $apiKey['vCode'], $apiKey['characterID']); |
||
103 | } |
||
104 | } |
||
105 | } |
||
106 | } |
||
107 | } |
||
108 | |||
109 | /** |
||
110 | * @param $keyID |
||
111 | * @param $vCode |
||
112 | * @param $characterID |
||
113 | * @return null |
||
114 | */ |
||
115 | private function getNotifications($keyID, $vCode, $characterID) |
||
116 | { |
||
117 | try { |
||
118 | $url = "https://api.eveonline.com/char/Notifications.xml.aspx?keyID={$keyID}&vCode={$vCode}&characterID={$characterID}"; |
||
119 | $xml = makeApiRequest($url); |
||
120 | date_default_timezone_set('UTC'); |
||
121 | $cached = $xml->cachedUntil[0]; |
||
122 | $baseUnix = strtotime($cached); |
||
123 | $cacheClr = $baseUnix - 13500; |
||
124 | if (null === $this->fuelChannel) { |
||
125 | $this->fuelChannel = $this->toDiscordChannel; |
||
126 | } |
||
127 | //Set timer for next key based on number of keys |
||
128 | $nextKey = (1900 / (int)$this->numberOfKeys) + time(); |
||
129 | $nextKeyTime = gmdate('Y-m-d H:i:s', $nextKey); |
||
130 | setPermCache('notificationsLastChecked', $nextKey); |
||
131 | //Set cache timer for api key |
||
132 | View Code Duplication | if ($cacheClr <= time()) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
133 | $weirdTime = time() + 1830; |
||
134 | setPermCache("notificationsLastChecked{$keyID}", $weirdTime); |
||
135 | } else { |
||
136 | setPermCache("notificationsLastChecked{$keyID}", $cacheClr); |
||
137 | } |
||
138 | $data = json_decode(json_encode(simplexml_load_string(downloadData($url), |
||
139 | 'SimpleXMLElement', LIBXML_NOCDATA)), true); |
||
140 | // If there is no data, just quit.. |
||
141 | if (empty($data['result']['rowset']['row'])) { |
||
142 | return null; |
||
143 | } |
||
144 | $data = $data['result']['rowset']['row']; |
||
145 | $fixedData = array(); |
||
146 | // Sometimes there is only ONE notification, so.. yeah.. |
||
147 | if (isset($data['@attributes'])) { |
||
148 | $fixedData[] = $data['@attributes']; |
||
149 | } |
||
150 | if (count($data) > 1) { |
||
151 | foreach ($data as $multiNotif) { |
||
152 | $fixedData[] = $multiNotif['@attributes']; |
||
153 | } |
||
154 | } |
||
155 | foreach ($fixedData as $notification) { |
||
156 | $notificationID = $notification['notificationID']; |
||
157 | $typeID = $notification['typeID']; |
||
158 | $sentDate = $notification['sentDate']; |
||
159 | $channelID = $this->toDiscordChannel; |
||
160 | if ($notificationID > $this->newestNotificationID) { |
||
161 | $notificationString = $this->getNotificationText($keyID, $vCode, $characterID, $notificationID); |
||
162 | $notificationArray = explode("\n", $this->getNotificationText($keyID, $vCode, $characterID, $notificationID)); |
||
163 | switch ($typeID) { |
||
164 | case 1: // Old |
||
165 | $msg = 'skip'; |
||
166 | break; |
||
167 | case 2: // biomassed |
||
168 | $msg = 'skip'; |
||
169 | break; |
||
170 | case 3: // medal awarded |
||
171 | $msg = 'skip'; |
||
172 | break; |
||
173 | case 4: // alliance bill |
||
174 | $msg = 'skip'; |
||
175 | break; |
||
176 | View Code Duplication | case 5: // War Declared |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
177 | preg_match('/(?<=againstID: )\S+/i', $notificationString, $defAllianceID); |
||
178 | $defAllianceName = allianceName($defAllianceID[0]); |
||
179 | if ($defAllianceName === '' || ' ' || null) { |
||
180 | $defAllianceName = corpName($defAllianceID[0]); |
||
181 | } |
||
182 | preg_match('/(?<=declaredByID: )\S+/i', $notificationString, $aggAllianceID); |
||
183 | $aggAllianceName = allianceName($aggAllianceID[0]); |
||
184 | if ($aggAllianceName === '' || ' ' || null) { |
||
185 | $aggAllianceName = corpName($aggAllianceID[0]); |
||
186 | } |
||
187 | if ($aggAllianceName === null || '' || $defAllianceName === null || '') { |
||
188 | $msg = '@everyone | War declared. Fighting begins in roughly 24 hours.'; |
||
189 | } else { |
||
190 | $msg = "@everyone | War declared by {$aggAllianceName} against {$defAllianceName}. Fighting begins in roughly 24 hours."; |
||
191 | } |
||
192 | break; |
||
193 | case 6: // Corp joins war (Not enough info in api to say who the 3rd party is) |
||
194 | $defAllianceID = trim(explode(': ', $notificationArray[0])[1]); |
||
195 | $aggAllianceID = trim(explode(': ', $notificationArray[2])[1]); |
||
196 | $defAllianceName = allianceName($defAllianceID); |
||
197 | $aggAllianceName = allianceName($aggAllianceID); |
||
198 | $msg = "The war between {$aggAllianceName} and {$defAllianceName} has been joined by a third party. This new group may begin fighting in roughly 24 hours."; |
||
199 | break; |
||
200 | case 7: // War Declared corp |
||
201 | $defCorpID = trim(explode(': ', $notificationArray[0])[1]); |
||
202 | $aggCorpID = trim(explode(': ', $notificationArray[2])[1]); |
||
203 | $defCorpName = corpName($defCorpID); |
||
204 | $aggCorpName = corpName($aggCorpID); |
||
205 | $msg = "@everyone | War declared by {$aggCorpName} against {$defCorpName}. Fighting begins in roughly 24 hours."; |
||
206 | break; |
||
207 | View Code Duplication | case 8: // Alliance war invalidated by CONCORD |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
208 | preg_match('/(?<=againstID: )\S+/i', $notificationString, $defAllianceID); |
||
209 | $defAllianceName = allianceName($defAllianceID[0]); |
||
210 | if ($defAllianceName === 'Unknown' || '' || ' ' || null) { |
||
211 | $defAllianceName = corpName($defAllianceID[0]); |
||
212 | } |
||
213 | preg_match('/(?<=declaredByID: )\S+/i', $notificationString, $aggAllianceID); |
||
214 | $aggAllianceName = allianceName($aggAllianceID[0]); |
||
215 | if ($aggAllianceName === 'Unknown' || '' || ' ' || null) { |
||
216 | $aggAllianceName = corpName($aggAllianceID[0]); |
||
217 | } |
||
218 | if ($aggAllianceName === null || '' || $defAllianceName === null || '') { |
||
219 | $msg = 'The war has been invalidated. Fighting ends in roughly 24 hours.'; |
||
220 | } else { |
||
221 | $msg = "The war between {$aggAllianceName} and {$defAllianceName} has been invalidated. Fighting ends in roughly 24 hours."; |
||
222 | } |
||
223 | break; |
||
224 | case 9: // Pilot bill |
||
225 | $msg = 'skip'; |
||
226 | break; |
||
227 | case 10: // Bill issued |
||
228 | $msg = 'skip'; |
||
229 | break; |
||
230 | case 11: // Bill stuff |
||
231 | $msg = 'skip'; |
||
232 | break; |
||
233 | case 12: // Bill Stuff |
||
234 | $msg = 'skip'; |
||
235 | break; |
||
236 | case 13: // Bill issued |
||
237 | $msg = 'skip'; |
||
238 | break; |
||
239 | case 14: // Bounty payment |
||
240 | $msg = 'skip'; |
||
241 | break; |
||
242 | case 16: // Mail |
||
243 | $msg = 'skip'; |
||
244 | break; |
||
245 | case 17: // Corp app |
||
246 | $msg = 'skip'; |
||
247 | break; |
||
248 | case 18: // Corp app |
||
249 | $msg = 'skip'; |
||
250 | break; |
||
251 | case 19: // corp tax changed |
||
252 | $corpID = trim(explode(': ', $notificationArray[0])[1]); |
||
253 | $corpName = corpName($corpID); |
||
254 | $oldTax = trim(explode(': ', $notificationArray[2])[1]); |
||
255 | $newTax = trim(explode(': ', $notificationArray[1])[1]); |
||
256 | $msg = "{$corpName} tax changed from {$oldTax}% to {$newTax}%"; |
||
257 | if ($this->allianceOnly === 'true') { |
||
258 | $msg = 'skip'; |
||
259 | } |
||
260 | break; |
||
261 | case 20: // Corp news? |
||
262 | $msg = 'skip'; |
||
263 | break; |
||
264 | case 21: // member left corp |
||
265 | $msg = 'skip'; |
||
266 | break; |
||
267 | case 22: // ceo resign |
||
268 | preg_match('/(?<=newCeoID: )\S+/i', $notificationString, $newCeoID); |
||
269 | preg_match('/(?<=oldCeoID: )\S+/i', $notificationString, $oldCeoID); |
||
270 | preg_match('/(?<=corpID: )\S+/i', $notificationString, $corpID); |
||
271 | $newCeoName = characterName($newCeoID); |
||
272 | $oldCeoName = characterName($oldCeoID); |
||
273 | $corpName = corpName($corpID); |
||
274 | $msg = "$oldCeoName has resigned as CEO for $corpName, $newCeoName has been appointed as the new CEO."; |
||
275 | break; |
||
276 | case 25: // corp vote |
||
277 | $msg = 'skip'; |
||
278 | break; |
||
279 | View Code Duplication | case 27: // Corp declares war |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
280 | preg_match('/(?<=againstID: )\S+/i', $notificationString, $defAllianceID); |
||
281 | $defAllianceName = allianceName($defAllianceID[0]); |
||
282 | if ($defAllianceName === '' || ' ' || null) { |
||
283 | $defAllianceName = corpName($defAllianceID[0]); |
||
284 | } |
||
285 | preg_match('/(?<=declaredByID: )\S+/i', $notificationString, $aggAllianceID); |
||
286 | $aggAllianceName = allianceName($aggAllianceID[0]); |
||
287 | if ($aggAllianceName === '' || ' ' || null) { |
||
288 | $aggAllianceName = corpName($aggAllianceID[0]); |
||
289 | } |
||
290 | if ($aggAllianceName === null || '' || $defAllianceName === null || '') { |
||
291 | $msg = '@everyone | War declared. Fighting begins in roughly 24 hours.'; |
||
292 | } else { |
||
293 | $msg = "**{$aggAllianceName}** has declared war on **{$defAllianceName}**. |
||
294 | Within 24 hours fighting can legally occur between those involved. If war is due to a corporation at war joining or leaving an alliance, then the war starts immediately instead."; |
||
295 | } |
||
296 | break; |
||
297 | View Code Duplication | case 29: // War Surrender |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
298 | preg_match('/(?<=againstID: )\S+/i', $notificationString, $defCorpID); |
||
299 | $defCorpName = allianceName($defCorpID[0]); |
||
300 | if ($defCorpName === '' || ' ' || null) { |
||
301 | $defCorpName = corpName($defCorpID[0]); |
||
302 | } |
||
303 | preg_match('/(?<=declaredByID: )\S+/i', $notificationString, $aggCorpID); |
||
304 | $aggCorpName = allianceName($aggCorpID[0]); |
||
305 | if ($aggCorpName === '' || ' ' || null) { |
||
306 | $aggCorpName = corpName($aggCorpID[0]); |
||
307 | } |
||
308 | if ($aggCorpName === null || '' || $defCorpName === null || '') { |
||
309 | $msg = 'A war has ended. Fighting ends in roughly 24 hours.'; |
||
310 | } else { |
||
311 | $msg = "The war between **{$aggCorpName}** and **{$defCorpName}** has ended. Fighting ends in roughly 24 hours."; |
||
312 | } |
||
313 | break; |
||
314 | View Code Duplication | case 30: // Corp retracts war |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
315 | preg_match('/(?<=againstID: )\S+/i', $notificationString, $defAllianceID); |
||
316 | $defAllianceName = allianceName($defAllianceID[0]); |
||
317 | if ($defAllianceName === '' || ' ' || null) { |
||
318 | $defAllianceName = corpName($defAllianceID[0]); |
||
319 | } |
||
320 | preg_match('/(?<=declaredByID: )\S+/i', $notificationString, $aggAllianceID); |
||
321 | $aggAllianceName = allianceName($aggAllianceID[0]); |
||
322 | if ($aggAllianceName === '' || ' ' || null) { |
||
323 | $aggAllianceName = corpName($aggAllianceID[0]); |
||
324 | } |
||
325 | if ($aggAllianceName === null || '' || $defAllianceName === null || '') { |
||
326 | $msg = '@everyone | War has been retracted. Fighting ends in roughly 24 hours.'; |
||
327 | } else { |
||
328 | $msg = "The war between **{$aggAllianceName}** and **{$defAllianceName}** is coming to an end. **{$aggAllianceName}** has retracted the war against **{$defAllianceName}**. The war will be declared as being over after approximately 24 hours."; |
||
329 | } |
||
330 | break; |
||
331 | case 31: // Alliance war invalidated by CONCORD |
||
332 | $aggAllianceID = trim(explode(': ', $notificationArray[2])[1]); |
||
333 | $aggAllianceName = allianceName($aggAllianceID); |
||
334 | $msg = "War with {$aggAllianceName} has been invalidated. Fighting ends in roughly 24 hours."; |
||
335 | break; |
||
336 | case 34: // Noob ship |
||
337 | $msg = 'skip'; |
||
338 | break; |
||
339 | case 35: // Insurance payment |
||
340 | $msg = 'skip'; |
||
341 | break; |
||
342 | case 36: // Insurance |
||
343 | $msg = 'skip'; |
||
344 | break; |
||
345 | View Code Duplication | case 41: // System lost |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
346 | preg_match('/(?<=solarsystemID: )\S+/i', $notificationString, $solarSystemID); |
||
347 | $systemName = getSystemName($solarSystemID[0]); |
||
348 | $allianceID = trim(explode(': ', $notificationArray[0])[1]); |
||
349 | $allianceName = allianceName($allianceID); |
||
350 | $msg = "{$allianceName} has lost control of **{$systemName}**"; |
||
351 | break; |
||
352 | View Code Duplication | case 43: // System captured |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
353 | preg_match('/(?<=solarsystemID: )\S+/i', $notificationString, $solarSystemID); |
||
354 | $systemName = getSystemName($solarSystemID[0]); |
||
355 | $allianceID = trim(explode(': ', $notificationArray[0])[1]); |
||
356 | $allianceName = allianceName($allianceID); |
||
357 | $msg = "{$allianceName} now controls **{$systemName}**"; |
||
358 | break; |
||
359 | case 45: // Tower anchoring |
||
360 | $msg = 'skip'; |
||
361 | break; |
||
362 | case 50: // Office Expired |
||
363 | $msg = 'skip'; |
||
364 | break; |
||
365 | case 52: // clone revoked |
||
366 | $msg = 'skip'; |
||
367 | break; |
||
368 | case 54: // insurance |
||
369 | $msg = 'skip'; |
||
370 | break; |
||
371 | case 55: // insurance |
||
372 | $msg = 'skip'; |
||
373 | break; |
||
374 | case 57: // jump clone destruction |
||
375 | $msg = 'skip'; |
||
376 | break; |
||
377 | case 69: // agent info |
||
378 | $msg = 'skip'; |
||
379 | break; |
||
380 | case 71: // Mission Expiration |
||
381 | $msg = 'skip'; |
||
382 | break; |
||
383 | case 73: // special mission |
||
384 | $msg = 'skip'; |
||
385 | break; |
||
386 | case 75: // POS / POS Module under attack |
||
387 | $aggAllianceID = trim(explode(': ', $notificationArray[0])[1]); |
||
388 | $aggAllianceName = allianceName($aggAllianceID); |
||
389 | $aggCorpID = trim(explode(': ', $notificationArray[1])[1]); |
||
390 | $aggCorpName = corpName($aggCorpID); |
||
391 | $aggID = trim(explode(': ', $notificationArray[2])[1]); |
||
392 | $aggCharacterName = characterName($aggID); |
||
393 | $moonID = trim(explode(': ', $notificationArray[5])[1]); |
||
394 | $moonName = apiMoonName($moonID); |
||
395 | $typeID = trim(explode(': ', $notificationArray[8])[1]); |
||
396 | $typeName = getTypeName($typeID); |
||
397 | preg_match('/(?<=solarsystemID: )\S+/i', $notificationString, $solarSystemID); |
||
398 | $systemName = getSystemName($solarSystemID[0]); |
||
399 | $msg = "**{$typeName}** under attack in **{$systemName} - {$moonName}** by {$aggCharacterName} ({$aggCorpName} / {$aggAllianceName})."; |
||
400 | if ($this->allianceOnly === 'true') { |
||
401 | $msg = 'skip'; |
||
402 | } |
||
403 | break; |
||
404 | case 76: // Tower resource alert |
||
405 | $moonID = trim(explode(': ', $notificationArray[2])[1]); |
||
406 | $moonName = apiMoonName($moonID); |
||
407 | preg_match('/(?<=solarsystemID: )\S+/i', $notificationString, $solarSystemID); |
||
408 | $systemName = getSystemName($solarSystemID[0]); |
||
409 | $blocksRemaining = trim(explode(': ', $notificationArray[6])[1]); |
||
410 | $typeID = trim(explode(': ', $notificationArray[7])[1]); |
||
411 | $channelID = $this->fuelChannel; |
||
412 | $typeName = getTypeName($typeID); |
||
413 | $msg = "POS in {$systemName} - {$moonName} needs fuel. Only {$blocksRemaining} {$typeName}'s remaining."; |
||
414 | if ($this->fuelSkip === 'true' || $this->allianceOnly === 'true') { |
||
415 | $msg = 'skip'; |
||
416 | } |
||
417 | |||
418 | break; |
||
419 | case 88: // IHUB is being attacked |
||
420 | $aggAllianceID = trim(explode(': ', $notificationArray[0])[1]); |
||
421 | $aggAllianceName = allianceName($aggAllianceID); |
||
422 | $aggCorpID = trim(explode(': ', $notificationArray[0])[1]); |
||
423 | $aggCorpName = corpName($aggCorpID); |
||
424 | $aggID = trim(explode(': ', $notificationArray[1])[1]); |
||
425 | $aggCharacterName = characterName($aggID); |
||
426 | $armorValue = trim(explode(': ', $notificationArray[3])[1]); |
||
427 | $hullValue = trim(explode(': ', $notificationArray[4])[1]); |
||
428 | $shieldValue = trim(explode(': ', $notificationArray[5])[1]); |
||
429 | preg_match('/(?<=solarsystemID: )\S+/i', $notificationString, $solarSystemID); |
||
430 | $systemName = getSystemName($solarSystemID[0]); |
||
431 | $msg = "IHUB under attack in **{$systemName}** by {$aggCharacterName} ({$aggCorpName} / {$aggAllianceName}). Status: Hull: {$hullValue}, Armor: {$armorValue}, Shield: {$shieldValue}"; |
||
432 | break; |
||
433 | case 89: // Sov level? |
||
434 | $msg = 'skip'; |
||
435 | break; |
||
436 | case 90: // Sov level? |
||
437 | $msg = 'skip'; |
||
438 | break; |
||
439 | case 93: // Customs office is being attacked |
||
440 | $aggAllianceID = trim(explode(': ', $notificationArray[0])[1]); |
||
441 | $aggAllianceName = allianceName($aggAllianceID); |
||
442 | $aggCorpID = trim(explode(': ', $notificationArray[0])[1]); |
||
443 | $aggCorpName = corpName($aggCorpID); |
||
444 | $aggID = trim(explode(': ', $notificationArray[2])[1]); |
||
445 | $aggCharacterName = characterName($aggID); |
||
446 | $shieldValue = trim(explode(': ', $notificationArray[5])[1]); |
||
447 | preg_match('/(?<=solarsystemID: )\S+/i', $notificationString, $solarSystemID); |
||
448 | $systemName = getSystemName($solarSystemID[0]); |
||
449 | $msg = "Customs Office under attack in **{$systemName}** by {$aggCharacterName} ({$aggCorpName} / {$aggAllianceName}). Shield Status: {$shieldValue}"; |
||
450 | if ($this->allianceOnly === 'true') { |
||
451 | $msg = 'skip'; |
||
452 | } |
||
453 | break; |
||
454 | case 94: // POCO Reinforced |
||
455 | $msg = 'Customs Office reinforced.'; |
||
456 | break; |
||
457 | case 95: // IHub Transfer |
||
458 | $msg = 'skip'; |
||
459 | break; |
||
460 | case 100: // Aggressor corp joins war |
||
461 | preg_match('/(?<=defenderID: )\S+/i', $notificationString, $defCorpID); |
||
462 | $defCorpName = allianceName($defCorpID[0]); |
||
463 | if ($defCorpName === 'Unknown' || '' || ' ' || null) { |
||
464 | $defCorpName = corpName($defCorpID[0]); |
||
465 | } |
||
466 | preg_match('/(?<=aggressorID: )\S+/i', $notificationString, $aggCorpID); |
||
467 | $aggCorpName = allianceName($aggCorpID[0]); |
||
468 | if ($aggCorpName === 'Unknown' || '' || ' ' || null) { |
||
469 | $aggCorpName = corpName($aggCorpID[0]); |
||
470 | } |
||
471 | $msg = "{$aggCorpName} has joined the war against {$defCorpName}."; |
||
472 | break; |
||
473 | case 101: // corp joins war |
||
474 | preg_match('/(?<=defenderID: )\S+/i', $notificationString, $defCorpID); |
||
475 | $defCorpName = allianceName($defCorpID[0]); |
||
476 | if ($defCorpName === 'Unknown' || '' || ' ' || null) { |
||
477 | $defCorpName = corpName($defCorpID[0]); |
||
478 | } |
||
479 | preg_match('/(?<=aggressorID: )\S+/i', $notificationString, $aggCorpID); |
||
480 | $aggCorpName = allianceName($aggCorpID[0]); |
||
481 | if ($aggCorpName === 'Unknown' || '' || ' ' || null) { |
||
482 | $aggCorpName = corpName($aggCorpID[0]); |
||
483 | } |
||
484 | preg_match('/(?<=allyID: )\S+/i', $notificationString, $thirdCorpID); |
||
485 | $thirdCorpName = allianceName($thirdCorpID[0]); |
||
486 | if ($thirdCorpName === 'Unknown' || '' || ' ' || null) { |
||
487 | $thirdCorpName = corpName($thirdCorpID[0]); |
||
488 | } |
||
489 | $msg = "{$thirdCorpName} has joined the war involving {$defCorpName} and {$aggCorpName}."; |
||
490 | break; |
||
491 | case 102: // War support offer? I think? |
||
492 | $msg = 'skip'; |
||
493 | break; |
||
494 | case 103: // War support offer? I think? |
||
495 | $msg = 'skip'; |
||
496 | break; |
||
497 | case 111: // Bounty |
||
498 | $msg = 'skip'; |
||
499 | break; |
||
500 | case 112: // Bounty |
||
501 | $msg = 'skip'; |
||
502 | break; |
||
503 | case 113: // Bounty |
||
504 | $msg = 'skip'; |
||
505 | break; |
||
506 | case 114: // Bounty |
||
507 | $msg = 'skip'; |
||
508 | break; |
||
509 | case 115: // Kill right |
||
510 | $msg = 'skip'; |
||
511 | break; |
||
512 | case 116: // Kill right |
||
513 | $msg = 'skip'; |
||
514 | break; |
||
515 | case 117: // Kill right |
||
516 | $msg = 'skip'; |
||
517 | break; |
||
518 | case 118: // Kill right |
||
519 | $msg = 'skip'; |
||
520 | break; |
||
521 | case 119: // Kill right |
||
522 | $msg = 'skip'; |
||
523 | break; |
||
524 | case 120: // Kill right |
||
525 | $msg = 'skip'; |
||
526 | break; |
||
527 | case 123: // Surrender (Need XML) |
||
528 | $msg = 'skip'; |
||
529 | break; |
||
530 | case 128: // Corp App |
||
531 | $msg = 'skip'; |
||
532 | break; |
||
533 | case 129: // App denied |
||
534 | $msg = 'skip'; |
||
535 | break; |
||
536 | case 130: // Corp app withdrawn? |
||
537 | $msg = 'skip'; |
||
538 | break; |
||
539 | case 135: // ESS stolen |
||
540 | $msg = 'skip'; |
||
541 | break; |
||
542 | case 138: // Clone activation |
||
543 | $msg = 'skip'; |
||
544 | break; |
||
545 | case 139: // Clone activation |
||
546 | $msg = 'skip'; |
||
547 | break; |
||
548 | case 140: // Kill report |
||
549 | $msg = 'skip'; |
||
550 | break; |
||
551 | case 141: // Kill report |
||
552 | $msg = 'skip'; |
||
553 | break; |
||
554 | case 146: // ff legality changed |
||
555 | preg_match('/(?<=corpID: )\S+/i', $notificationString, $corpID); |
||
556 | $corpName = allianceName($corpID[0]); |
||
557 | if ($corpName === 'Unknown' || '' || ' ' || null) { |
||
558 | $corpName = corpName($corpID[0]); |
||
559 | } |
||
560 | $msg = "{$corpName} has changed the legality for friendly fire."; |
||
561 | break; |
||
562 | View Code Duplication | case 147: // Entosis has started |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
563 | preg_match('/(?<=solarsystemID: )\S+/i', $notificationString, $solarSystemID); |
||
564 | $systemName = getSystemName($solarSystemID[0]); |
||
565 | $typeID = trim(explode(': ', $notificationArray[1])[1]); |
||
566 | $typeName = getTypeName($typeID); |
||
567 | $msg = "Entosis has started in **{$systemName}** on **{$typeName}** (Date: **{$sentDate}**)"; |
||
568 | break; |
||
569 | View Code Duplication | case 148: // Entosis enabled a module ?????? |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
570 | preg_match('/(?<=solarsystemID: )\S+/i', $notificationString, $solarSystemID); |
||
571 | $systemName = getSystemName($solarSystemID[0]); |
||
572 | $typeID = trim(explode(': ', $notificationArray[1])[1]); |
||
573 | $typeName = getTypeName($typeID); |
||
574 | $msg = "Entosis has enabled a module in **{$systemName}** on **{$typeName}** (Date: **{$sentDate}**)"; |
||
575 | break; |
||
576 | View Code Duplication | case 149: // Entosis disabled a module |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
577 | preg_match('/(?<=solarsystemID: )\S+/i', $notificationString, $solarSystemID); |
||
578 | $systemName = getSystemName($solarSystemID[0]); |
||
579 | $typeID = trim(explode(': ', $notificationArray[1])[1]); |
||
580 | $typeName = getTypeName($typeID); |
||
581 | $msg = "Entosis has disabled a module in **{$systemName}** on **{$typeName}** (Date: **{$sentDate}**)"; |
||
582 | break; |
||
583 | case 152: // Sov bill |
||
584 | $msg = 'skip'; |
||
585 | break; |
||
586 | View Code Duplication | case 160: // Entosis successful |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
587 | preg_match('/(?<=solarsystemID: )\S+/i', $notificationString, $solarSystemID); |
||
588 | $systemName = getSystemName($solarSystemID[0]); |
||
589 | $msg = "Hostile entosis successful. A structure in **{$systemName}** has entered reinforced mode."; |
||
590 | break; |
||
591 | View Code Duplication | case 161: // Command Nodes Decloaking |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
592 | preg_match('/(?<=solarsystemID: )\S+/i', $notificationString, $solarSystemID); |
||
593 | $systemName = getSystemName($solarSystemID[0]); |
||
594 | $msg = "Command nodes decloaking for **{$systemName}**"; |
||
595 | break; |
||
596 | View Code Duplication | case 162: // TCU Destroyed |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
597 | preg_match('/(?<=solarsystemID: )\S+/i', $notificationString, $solarSystemID); |
||
598 | $systemName = getSystemName($solarSystemID[0]); |
||
599 | $msg = "Entosis successful, TCU in **{$systemName}** has been destroyed."; |
||
600 | break; |
||
601 | View Code Duplication | case 163: // Outpost freeport |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
602 | preg_match('/(?<=solarsystemID: )\S+/i', $notificationString, $solarSystemID); |
||
603 | $systemName = getSystemName($solarSystemID[0]); |
||
604 | $msg = "Station in **{$systemName}** has now entered freeport mode."; |
||
605 | break; |
||
606 | View Code Duplication | case 165: // System became Capital |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
607 | preg_match('/(?<=solarsystemID: )\S+/i', $notificationString, $solarSystemID); |
||
608 | $systemName = getSystemName($solarSystemID[0]); |
||
609 | $allianceID = trim(explode(': ', $notificationArray[0])[1]); |
||
610 | $allianceName = allianceName($allianceID); |
||
611 | $msg = "**{$systemName}** is now the capital for {$allianceName}."; |
||
612 | break; |
||
613 | View Code Duplication | case 167: // Initiate Self-destruct on TCU |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
614 | preg_match('/(?<=solarsystemID: )\S+/i', $notificationString, $solarSystemID); |
||
615 | $systemName = getSystemName($solarSystemID[0]); |
||
616 | $msg = "TCU in **{$systemName}** has initiated a self destruct sequence."; |
||
617 | break; |
||
618 | View Code Duplication | case 169: // TCU Self-Destructed |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
619 | preg_match('/(?<=solarsystemID: )\S+/i', $notificationString, $solarSystemID); |
||
620 | $systemName = getSystemName($solarSystemID[0]); |
||
621 | $msg = "TCU in **{$systemName}** has self destructed."; |
||
622 | break; |
||
623 | View Code Duplication | case 181: // citadel low on fuel |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
624 | preg_match('/(?<=solarsystemID: )\S+/i', $notificationString, $solarSystemID); |
||
625 | $systemName = getSystemName($solarSystemID[0]); |
||
626 | $msg = "Citadel in **{$systemName}** is low on fuel."; |
||
627 | if ($this->fuelSkip === 'true' || $this->allianceOnly === 'true') { |
||
628 | $msg = 'skip'; |
||
629 | } |
||
630 | break; |
||
631 | case 182: // Citadel being anchored |
||
632 | preg_match('/(?<=ownerCorpName: )[^\r\n]+/i', $notificationString, $corpName); |
||
633 | $corpName = $corpName[0]; |
||
634 | preg_match('/(?<=solarsystemID: )\S+/i', $notificationString, $solarSystemID); |
||
635 | $systemName = getSystemName($solarSystemID[0]); |
||
636 | $msg = "Citadel owned by **{$corpName}** is being anchored in **{$systemName}**."; |
||
637 | break; |
||
638 | case 184: // Citadel under attack |
||
639 | $aggID = trim(explode(': ', $notificationArray[7])[1]); |
||
640 | $aggCharacterName = characterName($aggID); |
||
641 | $aggAllianceID = trim(explode(': ', $notificationArray[0])[1]); |
||
642 | $aggAllianceName = allianceName($aggAllianceID); |
||
643 | $aggCorpID = trim(explode('- ', $notificationArray[11])[1]); |
||
644 | $aggCorpName = corpName($aggCorpID); |
||
645 | preg_match('/(?<=solarsystemID: )\S+/i', $notificationString, $solarSystemID); |
||
646 | $systemName = getSystemName($solarSystemID[0]); |
||
647 | $msg = "@everyone | Citadel under attack in **{$systemName}** by **{$aggCharacterName}** ({$aggCorpName} / {$aggAllianceName})."; |
||
648 | break; |
||
649 | View Code Duplication | case 185: // Citadel online |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
650 | preg_match('/(?<=solarsystemID: )\S+/i', $notificationString, $solarSystemID); |
||
651 | $systemName = getSystemName($solarSystemID[0]); |
||
652 | $msg = "Citadel now online in **{$systemName}**."; |
||
653 | break; |
||
654 | View Code Duplication | case 188: // Citadel destroyed |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
655 | $corpID = trim(explode('- ', $notificationArray[3])[1]); |
||
656 | $corpName = corpName($corpID); |
||
657 | preg_match('/(?<=solarsystemID: )\S+/i', $notificationString, $solarSystemID); |
||
658 | $systemName = getSystemName($solarSystemID[0]); |
||
659 | $msg = "Citadel owned by **{$corpName}** in **{$systemName}** has been destroyed."; |
||
660 | break; |
||
661 | View Code Duplication | case 198: // citadel out of fuel |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
662 | preg_match('/(?<=solarsystemID: )\S+/i', $notificationString, $solarSystemID); |
||
663 | $systemName = getSystemName($solarSystemID[0]); |
||
664 | $msg = "Citadel in **{$systemName}** has run out of fuel."; |
||
665 | if ($this->fuelSkip === 'true' || $this->allianceOnly === 'true') { |
||
666 | $msg = 'skip'; |
||
667 | } |
||
668 | break; |
||
669 | case 199: // citadel delivery |
||
670 | $msg = 'skip'; |
||
671 | break; |
||
672 | case 1030: // ?? |
||
673 | $msg = 'skip'; |
||
674 | break; |
||
675 | case 1031: // plex delivery |
||
676 | $msg = 'skip'; |
||
677 | break; |
||
678 | default: // Unknown typeID |
||
679 | $string = implode(' ', $notificationArray); |
||
680 | $msg = "typeID {$typeID} is an unmapped notification, please create a Github issue with this entire message and please include what the in-game notification is. {$string}"; |
||
681 | break; |
||
682 | } |
||
683 | |||
684 | if ($msg === 'skip') { |
||
685 | return null; |
||
686 | } |
||
687 | $this->logger->addInfo('Notifications: Notification queued'); |
||
688 | priorityQueueMessage($msg, $channelID, $this->guild); |
||
689 | // Find the maxID so we don't output this message again in the future |
||
690 | $this->maxID = max($notificationID, $this->maxID); |
||
691 | $this->newestNotificationID = $this->maxID; |
||
692 | setPermCache('newestNotificationID', $this->maxID); |
||
693 | } |
||
694 | } |
||
695 | $this->logger->addInfo("Notifications: Next Notification Check At: {$nextKeyTime} EVE Time"); |
||
696 | } catch (Exception $e) { |
||
697 | $this->logger->addInfo('Notifications: Notification Error: ' . $e->getMessage()); |
||
698 | } |
||
699 | return null; |
||
700 | } |
||
701 | |||
702 | /** |
||
703 | * @param $keyID |
||
704 | * @param $vCode |
||
705 | * @param $characterID |
||
706 | * @param $notificationID |
||
707 | * @return string |
||
708 | */ |
||
709 | private function getNotificationText($keyID, $vCode, $characterID, $notificationID) |
||
710 | { |
||
711 | $url = "https://api.eveonline.com/char/NotificationTexts.xml.aspx?keyID={$keyID}&vCode={$vCode}&characterID={$characterID}&IDs={$notificationID}"; |
||
712 | $data = json_decode(json_encode(simplexml_load_string(downloadData($url), |
||
713 | 'SimpleXMLElement', LIBXML_NOCDATA)), true); |
||
714 | $data = $data['result']['rowset']['row']; |
||
715 | return $data; |
||
716 | } |
||
717 | } |
||
718 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.