Skip to content

Commit d66870b

Browse files
committed
Updated scripts
1 parent 43ac76d commit d66870b

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

Scripts/config.php

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
<?php
22

3-
//Token vars
3+
//protocol
4+
$protocol = "http";
5+
6+
//Traccar vars
47
$TraccarAPIToken = "YOUR_TRACCAR_API_TOKEN";
5-
$FreeTakServerAPIToken = "Bearer token";
8+
$TraccarIP = "127.0.0.1";
9+
$TraccarPort = "8082";
10+
11+
//FTS vars
12+
$FTSAPIToken = "Bearer token";
13+
$FTSIP = "127.0.0.1";
14+
$FTSAPIPort = "19023";
615

716
//`Test Service` button config
817
$How = "nonCoT";

Scripts/index.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ function testFunction(){
125125
role: "<?php echo$Role;?>",
126126
team: "<?php echo$Team;?>"};//JSON object
127127

128-
xhr.open('POST', 'http://127.0.0.1:19023/ManagePresence/postPresence', true); // open a GET request
128+
xhr.open('POST', '<?php echo$protocol;?>://<?php echo$TraccarIP;?>:<?php echo$TraccarPort;?>/ManagePresence/postPresence', true); // open a GET request
129129
xhr.setRequestHeader('Content-Type', 'application/json;charset=UTF-8');//application/json;charset=UTF-8
130130
xhr.setRequestHeader('Authorization', Authorization);//application/json;charset=UTF-8
131131
xhr.send(JSON.stringify(json)); // send the request to the server.

Scripts/serverUpdater.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
header('Connection: keep-alive');
88

99
//get the session cookie
10-
$session = json_encode(get_TraccarSession("http://127.0.0.1:8082/api/session?token=$TraccarAPIToken"));
10+
$session = json_encode(get_TraccarSession("$protocol://$TraccarIP:$TraccarPort/api/session?token=$TraccarAPIToken"));
1111

1212
$api_result = json_decode($session, true);
1313
$JSESSIONID = $api_result['JSESSIONID'];
1414

1515
//get the Traccar positions
16-
$positions = get_TraccarPosition("http://127.0.0.1:8082/api/positions?token=$TraccarAPIToken",$JSESSIONID);
16+
$positions = get_TraccarPosition("$protocol://$TraccarIP:$TraccarPort/api/positions?token=$TraccarAPIToken",$JSESSIONID);
1717

1818
$json = json_decode($positions);
1919

@@ -30,7 +30,7 @@
3030
// );
3131

3232
//forward the positions to the FTS API endpoint
33-
$result = get_FTSAPI($item->id, $item->latitude, $item->longitude);
33+
$result = get_FTSAPI($item->id, $item->latitude, $item->longitude, $protocol, $FTSIP, $FTSAPIPort, $FTSAPIToken);
3434

3535
$markers[] = json_encode(
3636
array(
@@ -83,7 +83,7 @@ function get_TraccarPosition($url,$JSESSIONID) {
8383
return $file;
8484
}
8585

86-
function get_FTSAPI($id, $latitude, $longitude, $FreeTakServerAPIToken) {
86+
function get_FTSAPI($id, $latitude, $longitude, $protocol, $FTSIP, $FTSAPIPort, $FTSAPIToken) {
8787

8888
//generate GUID
8989
$guid = vsprintf('%s%s-%s-4000-8%.3s-%s%s%s0',str_split(dechex( microtime(true) * 1000 ) . bin2hex( random_bytes(8) ),4));
@@ -99,14 +99,14 @@ function get_FTSAPI($id, $latitude, $longitude, $FreeTakServerAPIToken) {
9999
"team" => "Red"
100100
);
101101

102-
$ch = curl_init("http://127.0.0.1:19023/ManagePresence/postPresence");
102+
$ch = curl_init("$protocol://$FTSIP:$FTSAPIPort/ManagePresence/postPresence");
103103
//set cURL options
104104
curl_setopt(
105105
$ch,
106106
CURLOPT_HTTPHEADER,
107107
array(
108108
'Content-Type: application/json',
109-
'Authorization: '.$FreeTakServerAPIToken
109+
'Authorization: '.$FTSAPIToken
110110
)
111111
);
112112
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

0 commit comments

Comments
 (0)