Dynamic PHP Banner

Status
Not open for further replies.
Use this:
PHP:
<?php

header('Content-type: image/png');
$onlineurl = file_get_contents('http://www.blazehotel.info/online.cfm'); // Users online file ****? lol

$font = 'Espar_Arial_Classic.ttf'; //Use your own
$handle = imagecreatefrompng('banner.png'); // Background Image
$bg_color = imagecolorallocate ($handle, 135, 206, 250);
$txt_color = imagecolorallocate ($handle, 239, 244, 241);
imagettftext($handle, 12, 0, 130, 16, $txt_color, $font, "$onlineurl Users Online!");
imagepng ($handle);
imagedestroy($handle);
?>
it should work(tested it with PHP 5.3.5).
 
Last edited:
Use this:
PHP:
<?php

header('Content-type: image/png');
$onlineurl = file_get_contents('http://www.blazehotel.info/online.cfm'); // Users online file ****? lol

$font = 'Espar_Arial_Classic.ttf'; //Use your own
$handle = imagecreatefrompng('banner.png'); // Background Image
$bg_color = imagecolorallocate ($handle, 135, 206, 250);
$txt_color = imagecolorallocate ($handle, 239, 244, 241);
imagettftext($handle, 12, 0, 130, 16, $txt_color, $font, "$onlineurl Users Online!");
imagepng ($handle);
imagedestroy($handle);
?>
it should work(tested it with PHP 5.3.5).

ok, it's better than the old one.
Thanks °_°
 
Why do i get this message

<code>The image "http://ispazhotel.sytes.net/online/" can not be displayed, because it contains errors.</code>
 
To be totally honest, I didn't make this to please the community, I wanted to share this whilst making me remember it, if that makes sense. I know that I will want something like this in say 3 months time, but I will forget how to do it, and if it is on here, I can always come and refresh my memory!


Oh, and this is better than Edward's because it doesn't place the stats over the image... anyone can do that? This actually re-generates the image when someone logs into your hotel


@ntl200 - The simple answer is yes... you need to edit this "12, 0, 130, 16" to move the image, the 12 is the font size, not sure what the 0 is.. lmfao, the 130 means that the text is 130px? from the left corner, and the 16 means it is 16px? from the top! I put the ? after px as I'm not sure what measurement it is working in :L I've never really done anything like this before!



EDIT: If you have trouble placing the online.php/cfm thing, pm me the banner and I can align it for you! :) (screw the no support.. I get a higher post count if I offer support) :L

The "0" in "12, 0, 130, 16" is the angle in degrees :P
 
Status
Not open for further replies.
Back