forked from Flame1994/CosmicTracker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdateSystem.php
56 lines (51 loc) · 1.91 KB
/
updateSystem.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
<?php
// ============================================================================
// Handles character location. This script is called every 5 seconds to check
// if user has entered a new system. If so, return the system id.
// ============================================================================
include "php/routes.php";
session_start();
$url = file_get_contents("https://crest-tq.eveonline.com/");
$content = json_decode($url, true);
// Check if eve is online
$serviceStatus = $content['serviceStatus'];
$serverCount = $content['userCount_str'];
if ($serviceStatus != 'online') {
echo "logout";
} else {
if (isset($_SESSION['CharacterID'])) {
$charid = $_SESSION['CharacterID'];
$access = $_SESSION['AccessToken'];
$url2 = 'https://crest-tq.eveonline.com/characters/'.$charid.'/location/';
$options2 = array(
'http' => array(
'header' => "Authorization: Bearer ".$access."\r\n",
'method' => 'GET'
)
);
$context2 = stream_context_create($options2);
$result2 = file_get_contents($url2, false, $context2);
if ($result2 === FALSE) {
$_SESSION["CharacterSystemName"] = "";
$_SESSION["CharacterSystemID"] = "";
} else {
$content2 = json_decode($result2, true);
if ($content2 === FALSE || empty($content2) || is_null($content2)) {
$_SESSION["CharacterSystemName"] = "";
$_SESSION["CharacterSystemID"] = "";
} else {
// Set and save location
$main_system_id = $content2['solarSystem']['id'];
$main_system_name = $content2['solarSystem']['name'];
$system_href = $content2['solarSystem']['href'];
if ($main_system_name != $_SESSION["CharacterSystemName"]) {
$_SESSION["CharacterSystemName"] = $main_system_name;
$_SESSION["CharacterSystemID"] = $main_system_id;
echo $main_system_id;
} else {
}
}
}
}
}
?>