Dynamic PHP Banner

Status
Not open for further replies.
Joined
Nov 24, 2008
Messages
2,528
Reaction score
1,435
Hello... there was a person who made a service for this, and refused to provide the source code... so being myself, I went and found a tutorial and made my own!

PHP:
<?php

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

$font = 'arial.ttf'; 
$handle = imagecreatefrompng('template.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); 

?>

You need to put that in a .php file, it can be called anything... change "http://www.blazehotel.ino/online.cfm" to the link to your user online script, and then you need to change "template.png" to a link which contains your background for the banner... as you will see at , I have created a small black box where the users online goes.. and with the script it looks like - Job done. I will offer absolutely NO support for this! If you know how to configure / use it, good, if not, I don't care!


Good day to you, sir(s)!


If you get a white screen, Kryptos provided a fix on page 4! Thanks Kryptos!
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);
?>
 
Last edited:
no it was 0cean haha and nice hejula (y)

it is "ugly as hell" though but you can make ur own banner at the same size and it will work right?
 
Last edited:
What's this?:
<br />
<b>Warning</b>: imagettftext() [<a href='function.imagettftext'>function.imagettftext</a>]: Invalid font filename in <b>C:\xampp\htdocs\banner\index.php</b> on line <b>10</b><br />
 
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
 
Last edited:
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

Does it really re-generate the image / re-draw the image when someone enters the hotel?!

OMFG SO FKING NIIICE!!!
 
Hejula, do you use heroine? Cuz if you can't remember what you did 3 months ago your probably addicted to that stuff.
 
Someuser, do you actually have a brain?

You know, some people can't remember the last week, cuz they have bad "memory"

You probably have good memory if you can remember the most of things u did 3 months ago...
 
Status
Not open for further replies.
Back