$biggest) { $biggest = strlen($array[$a]); } } return $biggest; } require_once('core/connect.php'); header('Content-Type: image/png'); $id = htmlentities($_GET['id'],ENT_QUOTES); if(!empty($id)) { $quotequerystring = "SELECT `name`,`quote` FROM `quotes` WHERE `id` =" . $id . " LIMIT 1"; } else { $querystring = "SELECT `id` FROM `quotes` WHERE `approved` =1"; if(!$query = @mysql_query($querystring)) { die('database error: "1"'); } $num = mysql_num_rows($query); $rnd = rand(0,$num-1); $quotequerystring = "SELECT `name`,`quote` FROM `quotes` WHERE `approved` =1 LIMIT " . $rnd . ",1"; } if(!$quotequery = @mysql_query($quotequerystring)) { die('database error: "2"'); } $row = mysql_fetch_array($quotequery); if(empty($row['quote'])) { die('no quote found!'); } $name = '-- ' . $row['name']; $quote = '"' . html_entity_decode($row['quote'],ENT_QUOTES) . '"'; $quote = wordwrap($quote,50,"\n",1); $quote = explode("\n",$quote); $width = check($quote) * imagefontwidth(4) + 15; if($width < 150) { $width = 150; } $im = imagecreate($width, count($quote)*15 + 33); $background = imagecolorallocate($im, 0, 0, 0); $text = imagecolorallocate($im, 255, 255, 255); imagefill($im, 0, 0, $background); for ($i = 0, $l = 3; $i < count($quote); $i++, $l += 15) { imagestring($im, 4, 5, $l, $quote[$i], $text); } $offset = imagesx($im) - ((strlen($name) * imagefontwidth(2)) + 12); imagestring($im, 2, $offset, (imagesy($im) - 18), $name, $text); imagerectangle($im, 0, 0, (imagesx($im) - 1), (imagesy($im) - 1), $background); imagerectangle($im, 1, 1, (imagesx($im) - 2), (imagesy($im) - 2), $text); imagepng($im); imagedestroy($im); ?>