-
Notifications
You must be signed in to change notification settings - Fork 0
/
PocketMineBanner.php
82 lines (82 loc) · 4.12 KB
/
PocketMineBanner.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
header("Content-type: image/png");
require __DIR__ . '/MinecraftQuery.class.php';
$Query = new MinecraftQuery();
$font = './minecraft.ttf';
try{
switch($_REQUEST['id']){
case 0:
$Query->connect($_REQUEST['ip'], $_REQUEST['port'], 1);
$info = $Query->GetInfo();
$im = imagecreatefrompng("open.png");
$white = imagecolorallocate($im, 255, 255, 255);
imagefttext($im, 21, 0, 680, 60, $white, $font, $info['Players']);
imagefttext($im, 21, 0, 740, 60, $white, $font, $info['MaxPlayers']);
imagefttext($im, 21, 0, 30, 60, $white, $font, $info['HostName']);
imagepng($im);
imagedestroy($im);
break;
case 1:
$Query->connect($_REQUEST['ip'], $_REQUEST['port'], 1);
$info = $Query->GetInfo();
$im = imagecreatefrompng("banner1.png");
$white = imagecolorallocate($im, 255, 255, 255);
$green = imagecolorallocate($im, 127, 255, 0);
imagefttext($im, 21, 0, 10, 30, $white, $font, $info['HostName']);
imagefttext($im, 13, 0, 10, 50, $white, $font, "IP: ".$_REQUEST['ip']);
imagefttext($im, 13, 0, 10, 70, $white, $font, "Port: ".$info['HostPort']);
imagefttext($im, 13, 0, 10, 90, $green, $font, "Online: ".$info['Players']."/".$info['MaxPlayers']);
imagepng($im);
imagedestroy($im);
break;
case 2:
$Query->connect($_REQUEST['ip'], $_REQUEST['port'], 1);
$info = $Query->GetInfo();
$im = imagecreatefrompng("banner2.png");
$white = imagecolorallocate($im, 255, 255, 255);
$green = imagecolorallocate($im, 127, 255, 0);
imagefttext($im, 21, 0, 10, 30, $white, $font, $info['HostName']);
imagefttext($im, 13, 0, 10, 50, $white, $font, "IP: ".$_REQUEST['ip']);
imagefttext($im, 13, 0, 10, 70, $white, $font, "Port: ".$info['HostPort']);
imagefttext($im, 13, 0, 10, 90, $green, $font, "Online: ".$info['Players']."/".$info['MaxPlayers']);
imagepng($im);
imagedestroy($im);
break;
}
}
catch(MinecraftQueryException $e){
switch($_REQUEST['id']){
case 0:
$im = imagecreatefrompng("closed.png");
$white = imagecolorallocate($im, 255, 255, 255);
imagefttext($im, 21, 0, 690, 60, $white, $font, "-");
imagefttext($im, 21, 0, 750, 60, $white, $font, "-");
imagefttext($im, 21, 0, 30, 60, $white, $font, $_REQUEST['servername']);
imagepng($im);
imagedestroy($im);
break;
case 1:
$im = imagecreatefrompng("banner1.png");
$white = imagecolorallocate($im, 255, 255, 255);
$red = imagecolorallocate($im, 255, 0, 0);
imagefttext($im, 21, 0, 10, 30, $white, $font, $_REQUEST['servername']." - Offline");
imagefttext($im, 13, 0, 10, 50, $white, $font, "IP: ".$_REQUEST['ip']);
imagefttext($im, 13, 0, 10, 70, $white, $font, "Port: ".$_REQUEST['port']);
imagefttext($im, 13, 0, 10, 90, $red, $font, "Offline: - / -");
imagepng($im);
imagedestroy($im);
break;
case 2:
$im = imagecreatefrompng("banner2.png");
$white = imagecolorallocate($im, 255, 255, 255);
$red = imagecolorallocate($im, 255, 0, 0);
imagefttext($im, 21, 0, 10, 30, $white, $font, $_REQUEST['servername']." - Offline");
imagefttext($im, 13, 0, 10, 50, $white, $font, "IP: ".$_REQUEST['ip']);
imagefttext($im, 13, 0, 10, 70, $white, $font, "Port: ".$_REQUEST['port']);
imagefttext($im, 13, 0, 10, 90, $red, $font, "Offline: - / -");
imagepng($im);
imagedestroy($im);
break;
}
}
?>