1
|
|
|
<?php |
2
|
|
|
function zKillRedis() |
3
|
|
|
{ |
4
|
|
|
try { |
5
|
|
|
// Initialize a new request for this URL |
6
|
|
|
$ch = curl_init("http://redisq.zkillboard.com/listen.php"); |
7
|
|
|
// Set the options for this request |
8
|
|
|
curl_setopt_array($ch, array( |
9
|
|
|
CURLOPT_FOLLOWLOCATION => true, // Yes, we want to follow a redirect |
10
|
|
|
CURLOPT_RETURNTRANSFER => true, // Yes, we want that curl_exec returns the fetched data |
11
|
|
|
CURLOPT_TIMEOUT => 8, |
12
|
|
|
CURLOPT_SSL_VERIFYPEER => true, // Do not verify the SSL certificate |
13
|
|
|
)); |
14
|
|
|
// Fetch the data from the URL |
15
|
|
|
$data = curl_exec($ch); |
16
|
|
|
// Close the connection |
17
|
|
|
curl_close($ch); |
18
|
|
|
$data = json_decode($data, TRUE); |
19
|
|
|
|
20
|
|
|
} catch (Exception $e) { |
21
|
|
|
return null; |
22
|
|
|
} |
23
|
|
|
return $data['package']; |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
function getStartMail($kmGroup) |
27
|
|
|
{ |
28
|
|
View Code Duplication |
if ($kmGroup['allianceID'] === '0' && $kmGroup['lossMails'] === 'true' && $kmGroup['corpID'] !== '0') { |
|
|
|
|
29
|
|
|
$url = "https://zkillboard.com/api/no-attackers/no-items/corporationID/{$kmGroup['corpID']}/limit/1/"; |
30
|
|
|
} |
31
|
|
View Code Duplication |
if ($kmGroup['allianceID'] === '0' && $kmGroup['lossMails'] === 'false' && $kmGroup['corpID'] !== '0') { |
|
|
|
|
32
|
|
|
$url = "https://zkillboard.com/api/no-attackers/no-items/kills/corporationID/{$kmGroup['corpID']}/limit/1/"; |
33
|
|
|
} |
34
|
|
View Code Duplication |
if ($kmGroup['allianceID'] !== '0' && $kmGroup['lossMails'] === 'true' && $kmGroup['allianceID'] !== '0') { |
|
|
|
|
35
|
|
|
$url = "https://zkillboard.com/api/no-attackers/no-items/allianceID/{$kmGroup['allianceID']}/limit/1/"; |
36
|
|
|
} |
37
|
|
View Code Duplication |
if ($kmGroup['allianceID'] !== '0' && $kmGroup['lossMails'] === 'false' && $kmGroup['allianceID'] !== '0') { |
|
|
|
|
38
|
|
|
$url = "https://zkillboard.com/api/no-attackers/no-items/kills/allianceID/{$kmGroup['allianceID']}/limit/1/"; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
if (!isset($url)) { // Make sure it's always set. |
42
|
|
|
return null; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
$kill = json_decode(downloadData($url), true); |
46
|
|
|
if (null !== $kill) { |
47
|
|
|
foreach ($kill as $mail) { |
48
|
|
|
$killID = $mail['killID']; |
49
|
|
|
setPermCache("{$kmGroup['name']}newestKillmailID", $killID); |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
function getStartBigMail() |
55
|
|
|
{ |
56
|
|
|
$url = 'https://zkillboard.com/api/kills/orderDirection/desc/iskValue/10000000000/'; |
57
|
|
|
|
58
|
|
|
if (!isset($url)) { // Make sure it's always set. |
59
|
|
|
return null; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
$kill = json_decode(downloadData($url), true); |
63
|
|
|
if (null !== $kill) { |
64
|
|
|
foreach ($kill as $mail) { |
65
|
|
|
$killID = $mail['killID']; |
66
|
|
|
setPermCache('bigKillNewestKillmailID', $killID); |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
} |
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.