Code: Select all
<?php
// Color support removed, because i didnt have the RGB values, and i like black more :P
// only (r) works...
$normTextFont = "E:\\Windows\\Fonts\\verdana.ttf";
$boldTextFont = "E:\\Windows\\Fonts\\verdanab.ttf";
$textSize = 10;
$content = file_get_contents("http://www.web2messenger.com/status/R4000.txt");
$content = explode("\n", $content);
$text = $content[0];
$text = str_replace("[c=","·+",$text);
$text = str_replace("[/c=","·-",$text);
$text = str_replace("]","",$text);
$text = str_replace("Â","",$text);
$psm = $content[1];
$psm = str_replace("[]","",$psm);
$psm = str_replace("[Music]"," (Music)",$psm);
$status = $content[2];
$status = substr($status, 0, strlen($status)-1);
/// end config
$img = imagecreatefrompng("bg.png");
$white = imagecolorallocate($img, 255, 255, 255);
$text = str_replace("(r)","·@r",$text);
$text = explode("·",$text);
$sections = array();
$bold = false;
$color = array(0, 0, 0);
foreach($text as $section){
$command = $section{0};
$sectionText = $section;
$emote = false;
switch($command){
case "+":
$n = $section{1};
// Color support removed, because i didnt have the RGB values, and i like black more :P
//$color = array($colors[$n][0], $colors[$n][1], $colors[$n][2]);
$sectionText = substr($section, 2);
break;
case "-":
// Color support removed, because i didnt have the RGB values, and i like black more :P
//$color = array(0, 0, 0);
$sectionText = substr($section, 2);
break;
case "@":
$emote = $section{1};
$sectionText = " " . substr($section, 2);
break;
case "#":
$sectionText = substr($section, 1);
if($bold == false) { $bold = true; } else { $bold = false; }
break;
case "0":
$sectionText = substr($section, 1);
break;
}
if($sectionText){
$sections[] = array('color' => $color, 'bold' => $bold, 'text' => $sectionText, 'emote' => $emote);
}
}
$width = 60;
$height = 55;
$maxWidth = 450;
$maxWidthPSM = 60;
foreach($sections as $section){
$bold = $section['bold'];
$color = imagecolorallocate($img, $section['color'][0], $section['color'][1], $section['color'][2]);
$text = $section['text'];
$emote = $section['emote'];
if($emote){
$copyimg = imagecreatefromgif("emotes/" . $emote . ".gif");
imagecopy($img, $copyimg, $width+3, $height-14, 0, 0, 19, 19);
}
if($bold == true) $textFont = $boldTextFont;
if($bold == false) $textFont = $normTextFont;
$size = imagettfbbox($textSize, 0, $textFont, $text);
if($width + $size[2] + 2 > $maxWidth) $text = "...";
ImageTTFText($img, $textSize, 0, $width, $height, $color, $textFont, $text);
$width += $size[2] + 2;
unset($color);
}
$color = imagecolorallocate($img, 0, 0, 0);
if(strlen($psm) > $maxWidthPSM-strlen($status)-3) { $psm = substr($psm, 0, $maxWidthPSM-strlen($status)-3) . "..."; }
ImageTTFText($img, $textSize-2, 0, 60, 70, $color, $normTextFont, "(" . trim($status) . ")".$psm);
ImageTTFText($img, 6, 0, 335, 105, $color, $normTextFont, "Generated by W2M and R4000");
header("Content-type: image/png");
imagepng($img);
?>