Mynimal, does your feed
validate? Also, did you try to take out the "throw new Exception();" line that was causing the problem?
TimRogers, what confuses you about it the new version? - so i can improve it. The options are nearly identical which is why im unsure of why you don't like them. Heres a modified old version with the cut off as per request:
CODE
<?
// ******************************************************
// RSS Feed Script by Benjeeboy on Neowin
// Version Customized by TimRogers
// Shows you the latest forum posts on Neowin
// ******************************************************
// editable:
// $feedurl - the url of your feed
// $imageurl - your background image (if not png change imagecreatefrompng to imagecreatefromgif or other types)
// $fontcolor - the font color
// $fontsize - the font size
// $font - the ttf font file path ex: 'arial.ttf'
// $x - the x position of text
// $y - the y position of text
// $angle - text angle
// $maxwidth - the number of pixels of text to display
$feedurl = "http://www.neowin.net/backend.php?page=forum";
$fp = fopen($feedurl,"r");
$contents = ".";
while (!feof($fp))
$contents .= fread($fp,8192);
fclose($fp);
preg_match("#<rss.*?>.*?<channel.*?<item>\s*<title>\s*(.*?)\s*<\/title>#s",$contents,$matchdata);
$title = $matchdata[1];
$imageurl = "http://www.tim-rogers.co.uk/neowinforum/template.PNG";
$img = imagecreatefrompng($imageurl);
$font = 'seguibd.ttf';
$fontcolor = imagecolorallocate($img, 255, 255, 255);
$fontsize = 8;
$x = 65;
$y = 16;
$angle = 0;
$maxwidth=170;
$end='';
$toofarstr='...';
$textbounds = imagettfbbox($fontsize,$angle,$font,$title);
if ($maxwidth != NULL) // if its not -1, make it fit width-wise
{
while ( $textbounds[2] - $textbounds[0] > $maxwidth ) //it is wider than maxwidth
{
$title = substr($title,0,strlen($title)-1); // remove last character
$end = $toofarstr;
$textbounds = imagettfbbox($fontsize,$angle,$font,$title . $end);
}
}
imagettftext($img,$fontsize,$angle,$x,$y,$fontcolor,$font,$title . $end);
header('Content-type: image/png');
imagepng($img);
?>
Anyways, i plan on rewriting alot of it, because as it is i can't do much with it.