|
1 | 1 | <?php
|
2 |
| -/* |
| 2 | +/** |
3 | 3 | * By SkiMkino
|
4 | 4 | * GitHub: https://github.com/XMSMApi
|
5 | 5 | * License: GPLv3
|
|
8 | 8 |
|
9 | 9 | $host = $_GET['host'];
|
10 | 10 | $port = $_GET['port'];
|
11 |
| -$name = $_GET['sn']; |
12 |
| -$theme = $_GET['theme']; |
13 |
| -$fon = $_GET['font']; |
14 | 11 | $font = str_replace(':enand:', '&', $fon);
|
15 | 12 |
|
16 | 13 | require_once 'ApiQuery.php';
|
17 | 14 | require_once 'ApiPing.php';
|
18 | 15 |
|
19 | 16 | require_once 'closeTags.php';
|
20 | 17 |
|
21 |
| -if (isset($_GET['image'])) { |
22 |
| - header("Content-type: image/JPEG"); |
23 |
| - if (isset($theme)) { |
24 |
| - if ($theme == 'light') { |
25 |
| - $im = imagecreatefromjpeg('./theme/light.jpg'); |
26 |
| - $color = ImageColorAllocate($im, 255,255,153); |
27 |
| - } elseif ($theme == 'dark') { |
28 |
| - $im = imagecreatefromjpeg('./theme/dark.jpg'); |
29 |
| - $color = ImageColorAllocate($im, 127,255,170); |
30 |
| - } else { |
31 |
| - $im = imagecreatefromjpeg('./theme/defult.jpg'); |
32 |
| - $color = ImageColorAllocate($im, 0,204,255); |
33 |
| - } |
34 |
| - } else { |
35 |
| - $im = imagecreatefromjpeg('./theme/defult.jpg'); |
36 |
| - $color = ImageColorAllocate($im, 0,204,255); |
37 |
| - } |
38 |
| - |
39 |
| - //定义字体 |
40 |
| - if ($font == null) { |
41 |
| - $font = 'defult.ttf'; |
42 |
| - } |
43 |
| - |
44 |
| - //定义颜色&字体 |
45 |
| - $black = ImageColorAllocate($im, 0,0,0); |
46 |
| - $pink = ImageColorAllocate($im, 255,119,201); |
47 |
| - |
48 |
| - //Ping |
49 |
| - require_once 'ApiQuery.php'; |
50 |
| - require_once 'ApiPing.php'; |
51 |
| - |
52 |
| - //读取Info |
53 |
| - require_once 'closeTags.php'; |
54 |
| - |
55 |
| - $players = $InfoPing['players']['online'].'/'.$InfoPing['players']['max']; |
56 |
| - $version = explode(" ", $InfoPing['version']['name'], 2); |
57 |
| - |
58 |
| - //判定是否在线 |
59 |
| - if ($InfoPing !== false) { |
60 |
| - |
61 |
| - /* |
62 |
| - 在线 |
63 |
| - 输出 |
64 |
| - */ |
65 |
| - $Ping = $Timer * 1000; |
66 |
| - imagettftext($im, 20, 0, 12, 40, $color, $font, $name); |
67 |
| - imagettftext($im, 20, 0, 12, 72, $color, $font, ' Host:'.$host); |
68 |
| - imagettftext($im, 20, 0, 12, 104, $color, $font,' Port:'.$port); |
69 |
| - imagettftext($im, 20, 0, 12, 147, $color, $font,' Players:'.$players); |
70 |
| - imagettftext($im, 20, 0, 12, 185, $pink, $font,' Version:'.$version[1]); |
71 |
| - imagettftext($im, 20, 0, 12, 210, $pink, $font, ' Ping:'.$Ping.'ms'); |
72 |
| - imagettftext($im, 20, 0, 12, 250, $pink, $font, ' Powered By SkiMino'); |
73 |
| - ImageGif($im); |
74 |
| - ImageDestroy($im); |
75 |
| - } else { |
76 |
| - |
77 |
| - /* |
78 |
| - 离线&不存在 |
79 |
| - 输出 |
80 |
| - */ |
81 |
| - imagettftext($im, 20, 0, 12, 40, $color, $font, $name); |
82 |
| - imagettftext($im, 20, 0, 12, 72, $color, $font, ' Host:'.$host); |
83 |
| - imagettftext($im, 20, 0, 12, 104, $color, $font,' Port:'.$port); |
84 |
| - imagettftext($im, 20, 0, 12, 210, $pink, $font,' Offline/Not such Host'); |
85 |
| - imagettftext($im, 20, 0, 12, 250, $pink, $font, ' Powered By SkiMino'); |
86 |
| - ImageGif($im); |
87 |
| - ImageDestroy($im); |
88 |
| - } |
89 |
| -} else { |
| 18 | +if ($host != null) { |
90 | 19 | if (($Info = $Query->GetInfo()) !== false) {
|
91 | 20 |
|
92 | 21 | if ($Info['GameName'] == 'MINECRAFT') {
|
|
108 | 37 | }
|
109 | 38 |
|
110 | 39 | $json = array(
|
111 |
| - 'status' => 'Yes', |
| 40 | + 'status' => 'Online', |
112 | 41 | 'platform' => $platform,
|
113 | 42 | 'gametype' => $Info['GameType'],
|
114 |
| - 'icon' => $Info['favicon'], |
| 43 | + 'icon' => str_replace("\n", "", $Info['favicon']), |
115 | 44 | 'motd' => array(
|
116 | 45 | 'ingame' => $Info['HostName']
|
117 | 46 | ),
|
|
157 | 86 | );
|
158 | 87 | } else {
|
159 | 88 | $json = array(
|
160 |
| - 'status' => 'No', |
| 89 | + 'status' => 'Offline', |
161 | 90 | 'host' => $host,
|
162 | 91 | 'port' => $port
|
163 | 92 | );
|
164 | 93 | }
|
165 | 94 | echo json_code($json, 200);
|
| 95 | +} else { |
| 96 | + echo json_code('', 500, 'No set host'); |
166 | 97 | }
|
167 | 98 | ?>
|
0 commit comments