Repository navigation
Expand file tree
/
Copy pathproxy.php
More file actions
73 lines (59 loc) · 2.38 KB
/
Copy pathproxy.php
File metadata and controls
73 lines (59 loc) · 2.38 KB
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
71
72
73
<?php
// FS25 WebStats — PHP Proxy
// Zet dit bestand op je webserver naast index.html
$FS25_HOST = 'http://JOUW_SERVER_IP:8080';
$FS25_CODE = 'JOUW_SERVER_CODE';
// ── Achtergrondafbeelding ─────────────────────────────────────────
// Vul hier een volledige URL in naar een afbeelding, of laat leeg
$BACKGROUND_URL = 'https://jouwdomein.nl/achtergrond.jpg';
$allowed = [
'stats' => '/feed/dedicated-server-stats.xml',
'map' => '/feed/dedicated-server-stats-map.jpg',
'careerSavegame' => '/feed/dedicated-server-savegame.html',
'vehicles' => '/feed/dedicated-server-savegame.html',
'economy' => '/feed/dedicated-server-savegame.html',
'background' => null, // wordt afgehandeld via $BACKGROUND_URL
];
$feed = isset($_GET['feed']) ? $_GET['feed'] : '';
// strip eventuele extra tekens (bijv. timestamp params die meekomen)
$feed = preg_replace('/[^a-zA-Z0-9_].*/', '', $feed);
if (!array_key_exists($feed, $allowed)) {
http_response_code(400);
die('Ongeldig feed verzoek.');
}
$path = $allowed[$feed];
// ── Achtergrond feed ──────────────────────────────────────────────
if ($feed === 'background') {
header('Access-Control-Allow-Origin: *');
header('Cache-Control: no-store, no-cache');
header('Content-Type: application/json; charset=utf-8');
echo json_encode(['url' => $BACKGROUND_URL]);
exit;
}
if (in_array($feed, ['careerSavegame', 'vehicles', 'economy'])) {
$url = $FS25_HOST . $path . '?code=' . $FS25_CODE . '&file=' . $feed;
} elseif ($feed === 'map') {
$url = $FS25_HOST . $path . '?code=' . $FS25_CODE . '&quality=60&size=512';
} else {
$url = $FS25_HOST . $path . '?code=' . $FS25_CODE;
}
$ctx = stream_context_create([
'http' => [
'timeout' => 10,
'header' => 'User-Agent: FS25-WebStats-Proxy/1.0',
]
]);
$data = @file_get_contents($url, false, $ctx);
if ($data === false) {
http_response_code(502);
die('Kon de FS25 server niet bereiken: ' . $url);
}
// Headers
header('Access-Control-Allow-Origin: *');
header('Cache-Control: no-store, no-cache');
if ($feed === 'map') {
header('Content-Type: image/jpeg');
} else {
header('Content-Type: text/xml; charset=utf-8');
}
echo $data;