-
Notifications
You must be signed in to change notification settings - Fork 1
/
bub.php
114 lines (105 loc) · 3.08 KB
/
bub.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
/*Belmaquote 1.0 USerbar version
Parameters:
u - usernameik
s - string to be displayed, 0x0D for newline, :tt: = TT
b - border width in pixels
t - background texture without .png (ground, sky... rnd)
*/
include("func.php");
addUbCounter();
$str = "";
$utimes = stateTimes($_GET["u"]);
if ($utimes != NULL) {
//kalkulate tt
$tt = 0;
for ($x = 0;$x < 54;$x++) {
$cTime = $utimes[$x+1][1];
if ($cTime == 0) $cTime = 60000;
$tt += $cTime;
}
$str = formatElmaTime($tt);
} else {
$str = "N/A";
}
$s = ":tt:";
if ($_GET["s"] != "") $s = $_GET["s"];
$str = str_replace(":tt:", $str, $s);
//Put all ASCII chars in a buffer
$chars = array();
$charW = array();
$charH = array();
for ($x = 32;$x <= 128;$x++) {
if (file_exists("bfont/" . $x . ".png")) {
$chars[$x] = imagecreatefrompng("bfont/" . $x . ".png");
list($cW, $cH, $cT, $cA) = getimagesize("bfont/" . $x . ".png");
$charW[$x] = $cW;
$charH[$x] = $cH;
}
}
//Read vshifts
$vShift = array();
$lines = file("bfont/vshifts.txt");
$i = 0;
foreach ($lines as $line_num => $line) {
$vShift[$i] = substr($line, 0, strpos($line, " "));
$i++;
}
$i = 0;
$j = 0;
$maxi = 0;
for ($x = 0;$x < strlen($str);$x++) {
$num = ord(substr($str, $x, 1));
if ($num == 13) {
$j += 12;
$i = 0;
} else {
$i += $charW[$num]+1;
if ($num == 32) $i += 2;
if ($maxi < $i) $maxi = $i;
}
}
$border = 5;
if (isset($_GET["b"])) $border = $_GET["b"];
if ($border < 0) $border = 0; if ($border > 500) $border = 500;
$borderx = $border-2;
$bordery = $border;
$imgW = $borderx*2+$maxi;
$imgH = $bordery*2+$j+12-2;
if (isset($_GET["w"]) && $_GET["w"] > 0 && $_GET["w"] < 2048) $imgW = $_GET["w"];
if (isset($_GET["h"]) && $_GET["h"] > 0 && $_GET["h"] < 2048) $imgH = $_GET["h"];
$img = imagecreatetruecolor($imgW, $imgH);
Imagefilledrectangle($img, 0, 0, $imgW, $imgH, ImageColorAllocate($img, 0, 0, 0));
$texture = "ground";
if (isset($_GET["t"]) && (file_exists("img/" . $_GET["t"] . ".png") || $_GET["t"] == "rnd")) $texture = $_GET["t"];
if ($texture == "rnd") {
$tx = array();
$tx[0] = "ground"; $tx[1] = "sky"; $tx[2] = "brick";
$tx[3] = "stone1"; $tx[4] = "stone2"; $tx[5] = "stone3";
$texture = $tx[rand(0, 5)];
}
$tex = imagecreatefrompng("img/" . $texture . ".png");
list($texW, $texH, $texT, $texA) = getimagesize("img/" . $texture . ".png");
for ($y = 0;$y < ceil($imgH/$texH);$y++) {
for ($x = 0;$x < ceil($imgW/$texW);$x++) {
imagecopy($img, $tex, $x*$texW, $y*$texH, 0, 0, $texW, $texH);
}
}
$i = 0;
$j = 0;
for ($x = 0;$x < strlen($str);$x++) {
$num = ord(substr($str, $x, 1));
if ($num == 13) {
$j += 12;
$i = 0;
} else {
imagecopy($img, $chars[$num], $borderx+$i, $bordery+$vShift[$num]+$j, 0, 0, $charW[$num], $charH[$num]);
$i += $charW[$num]+1;
if ($num == 32) $i += 2;
}
}
header("Content-Type: image/png");
imagepng($img);
imagedestroy($tex);
imagedestroy($img);
?>