using the code i have what is the best way to save a png generated to my server. Next i need to know how it can auto refreshed by remaking the png and overwriting the existing one.
<?php
$source = file_get_contents("http://ops.warrock.net/showclan.aspx?c=$clanpage");
clanInfoImage($source);
function clanInfoImage($clan_page_info) {
$pattern = '/Record: ([0-9-]+).*?World Rank: ([0-9]+).*?Regional Rank: ([0-9]+)/s';
preg_match($pattern, $clan_page_info, $matches);
list(, $record, $world_rank, $regional_rank) = $matches;
$top100 = "100";
// load the image from the file specified:
if ($world_rank > $top100) {
$im = imagecreatefrompng("1.png");
} else {
$im = imagecreatefrompng("1.png");
}
// if there's an error, stop processing the page:
if(!$im)
{
die("");
}
// define some colours to use with the image
$yellow = imagecolorallocate($im, 255, 255, 0);
$black = imagecolorallocate($im, 0, 0, 0);
// get the width and the height of the image
$width = imagesx($im);
$height = imagesy($im);
// draw a black rectangle across the bottom, say, 20 pixels of the image:
// now we want to write in the centre of the rectangle:
$font = 2; // store the int ID of the system font we're using in $font
$text1 = $record; // store the text we're going to write in $text
// calculate the left position of the text:
$leftTextPos = ( $width - imagefontwidth($font)*strlen($text) )/2.2;
// finally, write the string:
imagestring($im, $font, $leftTextPos, $height-46, $text1, $yellow);
$font = 2; // store the int ID of the system font we're using in $font
$text2 = $world_rank; // store the text we're going to write in $text
// calculate the left position of the text:
$leftTextPos = ( $width - imagefontwidth($font)*strlen($text) )/2;
// finally, write the string:
imagestring($im, $font, $leftTextPos, $height-31, $text2, $yellow);
$font = 2; // store the int ID of the system font we're using in $font
$text3 = $regional_rank; // store the text we're going to write in $text
// calculate the left position of the text:
$leftTextPos = ( $width - imagefontwidth($font)*strlen($text3) )/1.85;
// finally, write the string:
imagestring($im, $font, $leftTextPos, $height-17, $text3, $yellow);
// output the image
// tell the browser what we're sending it
Header('Content-type: image/png');
// output the image as a png
imagepng($im);
// tidy up
imagedestroy($im);
}
?>
Also on the subject is it possible to add an image from another location onto the image generated