Hallo Leute,
ich hab das kleine Problem das wenn ich ein Bild mit PHP erzeuge, immer der html Code den ich als Text mit angebe mit ausgegeben wird. Kann mir da vll jemand sagen wie ich das ändern kann?
Hier der Code:
<?php $antiblock_message = str_replace("\r\n", "\n", '<b>Test</b>'); ?>
<?php
function imagestringbox($message) {
$font = 5;
$shadow = true;
$line_spacing = mt_rand(1, 5);
$lines = explode("\n", utf8_decode($message));
$line_count = count($lines);
$max_len = 0;
foreach ($lines as $line) {
$max_len = max($max_len, strlen($line));
}
$line_height = imagefontheight($font);
$image_height = ($line_height * $line_count) + ($line_spacing * ($line_count - 1));
$image_width = imagefontwidth($font) * $max_len;
$image = imagecreate($image_width, $image_height);
$random_color = mt_rand(250, 255);
imagecolorallocate($image, $random_color, $random_color, $random_color);
$line_spacing_i = 0;
for ($i = 0; $i < $line_count; $i++) {
if ($shadow) {
$shadow_color = imagecolorallocate($image, 200, 200, 200);
imagestring($image, 5, 1, $line_height * $i + $line_spacing_i + 1, $lines[$i], $shadow_color);
}
// text line
imagestring($image, 5, 0, $line_height * $i + $line_spacing_i, $lines[$i], imagecolorallocate($image, 0, 0, 0));
$line_spacing_i += $line_spacing;
}
ob_start();
imagepng($image);
$image_content = ob_get_contents();
ob_end_clean();
imagedestroy($image);
return '<img src="data:image/png;base64,' . base64_encode($image_content) . '" height="' . $image_height . '" width="' . $image_width . '" alt="" />';
}
?>
<?php $antiblock_message = imagestringbox($antiblock_message); ?>
Danke schon mal an alle fürs Helfen.
Mfg Dog