ForceType application/x-httpd-php ---------------------------------------- * db.txt --> Jokes, sperated by double-linebreak * kreegee.png --> Logo */ $stime = microtime(); list($usec, $sec) = explode(' ', $stime); mt_srand($sec + ((float) $usec * 100000)); $db = implode ('', file('db.txt')); //open database /* if the sript output all quotes, replace the following line with * $jokes = split("\n\n",$db); //split into jokes... */ $jokes = split("\n\r\n",$db); //split into jokes... if($select){$i = $select-1;} //check if a joke is selected else {$i = mt_rand(0,count($jokes)-1);} //if not choose a random one $joke = split("\n",chop($jokes[$i])); //split joke into lines $line = 0; //current line $width=400; $height=count($joke)*15+10; $image = ImageCreate($width, $height); $black = ImageColorAllocate($image, 0, 0, 0); $white = ImageColorAllocate($image, 255, 255, 255); $mred = ImageColorAllocate($image, 155, 0, 0); ImageFilledRectangle($image, 0, 0, $width, $height, $white); //background ImageLine($image, 1, 1, $width, 1, $mred); //border top ImageLine($image, 1, 1, 1, $height, $mred); //border left ImageLine($image, $width-1, 1, $width-1, $height, $mred); //border right ImageLine($image, 1, $height-1, $width, $height-1, $mred); //border bottom for ($i=count($joke); $i>0; $i--){ imagestring ($image, 2,7, 5+$line*15, chop($joke[$line]), $black); $line++;} $kreegee = ImageCreateFromPNG("kreegee.png"); $ix = imagesx($kreegee); $iy = imagesy($kreegee); imagecopy($image, $kreegee, $width-$ix-2, $height-$iy-2,0,0,$ix,$iy); ImageDestroy($kreegee); $stime = explode(" ",$stime); //benchmark $stime = $stime[1] + $stime[0]; $starttime = $stime; $etime = microtime(); $etime = explode(" ",$etime); $etime = $etime[1] + $etime[0]; $endtime = $etime; $totaltime = ($endtime - $starttime)*1000; // Benchmark statistic // imagestring ($image, 1,2, $height-8, round($totaltime,1)." ms", $black); header("Content-type: image/png"); //send header Imagepng($image); //print picture ImageDestroy($image); //"destroy" picture ?>