Rev 57 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 57 | Rev 61 | ||
---|---|---|---|
Line 27... | Line 27... | ||
27 | /* |
27 | /* |
28 | * VNag - Nagios Framework for PHP |
28 | * VNag - Nagios Framework for PHP |
29 | * Developed by Daniel Marschall, ViaThinkSoft <www.viathinksoft.com> |
29 | * Developed by Daniel Marschall, ViaThinkSoft <www.viathinksoft.com> |
30 | * Licensed under the terms of the Apache 2.0 license |
30 | * Licensed under the terms of the Apache 2.0 license |
31 | * |
31 | * |
32 | * Revision 2022-09-12 |
32 | * Revision 2023-05-02 |
33 | */ |
33 | */ |
34 | 34 | ||
35 | declare(ticks=1); |
35 | declare(ticks=1); |
36 | 36 | ||
37 | class MinecraftJavaVersionCheck extends VNag { |
37 | class MinecraftJavaVersionCheck extends VNag { |
Line 58... | Line 58... | ||
58 | // These headers are important! Otherwise the request will be blocked by AkamaiGhost |
58 | // These headers are important! Otherwise the request will be blocked by AkamaiGhost |
59 | "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36", |
59 | "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36", |
60 | "Accept-Language: de-DE,de;q=0.9,en-DE;q=0.8,en;q=0.7,en-US;q=0.6", |
60 | "Accept-Language: de-DE,de;q=0.9,en-DE;q=0.8,en;q=0.7,en-US;q=0.6", |
61 | "Accept-Encoding: none" |
61 | "Accept-Encoding: none" |
62 | ); |
62 | ); |
63 | // curl 'https://www.minecraft.net/en-us/download/server' \ |
- | |
64 | // -H 'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36' \ |
- | |
- | 63 | ||
65 | // -H 'accept-language: de-DE,de;q=0.9,en-DE;q=0.8,en;q=0.7,en-US;q=0.6' \ |
64 | // TODO: Version is currently not shown anymore: https://bugs.mojang.com/browse/WEB-6497 |
66 | // --compressed |
65 | /* |
67 | $ch = curl_init(); |
66 | $ch = curl_init(); |
68 | curl_setopt($ch, CURLOPT_URL,"https://www.minecraft.net/en-us/download/server"); // TODO: make locale configurable? |
67 | curl_setopt($ch, CURLOPT_URL,"https://www.minecraft.net/en-us/download/server"); // TODO: make locale configurable? |
69 | curl_setopt($ch, CURLOPT_POST, 0); |
68 | curl_setopt($ch, CURLOPT_POST, 0); |
70 | curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); |
69 | curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); |
71 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
70 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
72 | $cont = curl_exec($ch); |
71 | $cont = curl_exec($ch); |
73 | curl_close($ch); |
72 | curl_close($ch); |
74 | - | ||
75 | if (!$cont) throw new Exception("Cannot detect latest available Minecraft version (HTTPS request failed)"); |
73 | if (!$cont) throw new Exception("Cannot detect latest available Minecraft version (HTTPS request failed)"); |
76 | - | ||
77 | preg_match_all('@minecraft_server\\.(.+)\\.jar@U', $cont, $m); |
74 | preg_match_all('@minecraft_server\\.(.+)\\.jar@U', $cont, $m); |
78 | - | ||
79 | if (!isset($m[1][0])) throw new Exception("Cannot detect latest available Minecraft version (regex pattern mismatch)"); |
75 | if (!isset($m[1][0])) throw new Exception("Cannot detect latest available Minecraft version (regex pattern mismatch)"); |
80 | - | ||
81 | return $m[1][0]; |
76 | return $m[1][0]; |
- | 77 | */ |
|
- | 78 | ||
- | 79 | for ($page=1; $page<=2; $page++) { |
|
- | 80 | $url = 'https://feedback.minecraft.net/hc/en-us/sections/360001186971-Release-Changelogs'; |
|
- | 81 | if ($page > 1) $url .= '?page='.$page; |
|
- | 82 | $url = 'https://webcache.googleusercontent.com/search?q=cache:'.urlencode($url); // Bypass CloudFlare... |
|
- | 83 | ||
- | 84 | $ch = curl_init(); |
|
- | 85 | curl_setopt($ch, CURLOPT_URL, $url); |
|
- | 86 | curl_setopt($ch, CURLOPT_POST, 0); |
|
- | 87 | curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); |
|
- | 88 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
|
- | 89 | $cont = curl_exec($ch); |
|
- | 90 | curl_close($ch); |
|
- | 91 | if (!$cont) throw new Exception("Cannot detect latest available Minecraft version (HTTPS request failed)"); |
|
- | 92 | preg_match_all('@>Minecraft: Java Edition \\- (.+)</@U', $cont, $m); |
|
- | 93 | if (isset($m[1][0])) return $m[1][0]; |
|
- | 94 | } |
|
- | 95 | throw new Exception("Cannot detect latest available Minecraft version (regex pattern mismatch)"); |
|
82 | } |
96 | } |
83 | 97 | ||
84 | protected function get_installed_minecraft_version($local_path) { |
98 | protected function get_installed_minecraft_version($local_path) { |
85 | if (substr($local_path,-4) == '.jar') { |
99 | if (substr($local_path,-4) == '.jar') { |
86 | $files = glob($local_path); |
100 | $files = glob($local_path); |