ViperBlade
New Member
- Messages
- 186
- Reaction score
- 0
- Points
- 0
I have apache installed on my PC and the code I'm about to provide works fine. It's supposed to be a grey background with white text.
For some reason it doesn't work when I upload it to my account's space. It gives the grey background but no text.
For some reason it doesn't work when I upload it to my account's space. It gives the grey background but no text.
PHP:
<?
// Some basic setup
$imageWidth = 300;
$imageHeight = 32;
$textFont = "arialbd.ttf";
$textSize = 15;
error_reporting(0);
$server = "http://viperblade.no-ip.org";
$port = "80";
$timeout = "0.1";
$TScheck = fsockopen($server, $port, $errno, $errstr, $timeout);
if ($TScheck)
{
$textString = "ViperBlade's PC is on!";
}
else
{
$textString = "Nobody's home right now";
}
// Set the headers content type
header("Content-type: image/png");
// Create the image
$image = imagecreatetruecolor($imageWidth, $imageHeight);
// Create some colors
$white = imagecolorallocate($image, 255, 255, 255);
$black = imagecolorallocate($image, 44, 144, 44);
// Fill the background of our image
imagefilledrectangle($image, 0, 0, $imageWidth, $imageHeight, $black);
// Get box info
$box = imagettfbbox($textSize, 0, $textFont, $textString);
//Find out the width and height of the text box
$textW = $box[2] - $box[0];
$textH = $box[5] - $box[3];
// Calculate the positions
$positionLeft = ($imageWidth - $textW)/2;
$positionTop = (($imageHeight - $textH)/2)-2;
// Add some text
imagettftext($image, $textSize, 0, $positionLeft, $positionTop, $white, $textFont, $textString);
// Output the image to the browser
imagepng($image);
// Destroy the image
imagedestroy($image);
?>