-
Notifications
You must be signed in to change notification settings - Fork 1
/
parse-xml.php
70 lines (44 loc) · 1.28 KB
/
parse-xml.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
// Sovereignty
$xml = simplexml_load_file('https://api.eveonline.com/map/Sovereignty.xml.aspx');
$alliances = array();
$data = array();
foreach($xml->result->rowset->row as $row) {
$alliance = (int) $row['allianceID'];
if ($alliance < 1) {
continue;
}
$alliances[] = $alliance;
$data[(int) $row['solarSystemID']] = $alliance;
}
// Remove dups
array_unique($alliances);
file_put_contents('public/shared/sovereignty.json', json_encode($data));
// Kills
$xml = simplexml_load_file('https://api.eveonline.com/map/Kills.xml.aspx');
$data = array();
foreach($xml->result->rowset->row as $row) {
$shipkills = (int) $row['shipKills'];
if ($shipkills < 1) {
continue;
}
$data[(int) $row['solarSystemID']] = $shipkills;
}
file_put_contents('public/shared/kills.json', json_encode($data));
// Alliances
$xml = simplexml_load_file('https://api.eveonline.com/eve/AllianceList.xml.aspx');
$data = array();
foreach($xml->result->rowset->row as $row) {
$alliance = (int) $row['allianceID'];
if ($alliance < 1) {
continue;
}
if (! in_array($alliance, $alliances)) {
continue;
}
$data[$alliance] = (object) array(
'name' => (string) $row['name'],
'shortName' => (string) $row['shortName'],
);
}
file_put_contents('public/shared/alliances.json', json_encode($data));