[code]<?php

$seconde = 0.1;
$baseimg = 'base.gif';
$tmpfolder = '/tmp/';
$resultaat = 'res/res.gif';
$laatstefile = 'laatste10.txt';

$fontsize = 12;

if ( !function_exists( 'file_put_contents' ) )
{
	
	function file_put_contents( $n , $d )
	{
		$f = @fopen( $n , 'w' );
		if ( !$f )
		{
			return false;
		} else
		{
			if ( is_array( $d ) )
			{
				foreach ( $d as $e )
				{
					fwrite( $f , $e );
				}
			} else
			{
				fwrite( $f , $d );
			}
			fclose( $f );
			return true;
		}
	}
}

if ( $_POST && isset( $_POST[ 'text' ] ) )
{
	$string = $_POST[ 'text' ];
	
	$baseim = imagecreatefromgif( $baseimg );
	$width = imagesx( $baseim );
	$height = imagesy( $baseim );
	imagedestroy($baseim);
	
	$last = ( 0 - $fontsize * strlen( $string ) );
	
	$exec = 'convert ';
	
	$offs = Array( );
	
	$offx = Array( );
	$offy = Array( );
	$left = Array( );
	$right = Array( );
	$up = Array( );
	$down = Array( );
	
	$reached = Array( );
	
	$x = 1;
	$final = 0;
	for ( $scroll = $width; $scroll >= $last; $scroll -= 5 )
	{
		$baseim = imagecreatefromgif( $baseimg );
		$width = imagesx( $baseim );
		$height = imagesy( $baseim );
		
		$white = imagecolorallocate( $baseim , 255 , 255 , 255 );
		$green = imagecolorallocate( $baseim , 255 , 198 , 98 );
		$black = imagecolorallocate( $baseim , 0 , 0 , 0 );
		$red = imagecolorallocate( $baseim , 200 , 50 , 0 );
		
		$off = 0;
		for ( $y = 0; $y < strlen( $string ); $y++ )
		{
			
			if ( ( $x - $y ) > 0 )
			{
				
				if ( $offs[ $y ] > 24 ) $reached[ $y ] = 1;
				if ( $offs[ $y ] <= 0 ) $reached[ $y ] = 0;
				
				if ( $reached[ $y ] == 1 ) $offs[ $y ] -= 8;
				else $offs[ $y ] += 8;
			}
			
			//imagestring( $baseim , 5 , $scroll + $off , $height - 20 - $offs[ $y ] , $string[ $y ], $red );
			imagettftext( $baseim , 20, 0, $scroll + $off, $height - 20 - $offs[ $y ] , $black , 'CALISTB.TTF' , $string[ $y ] );
			$off += $fontsize;
		}
		
		//imagestring( $baseim , 5 , $scroll , $height - 20 , $string, $green );
		//imagettftext( $baseim , 20, 0, $offx[ $y ], $height - 20 , $black , 'CALISTB.TTF' , $offx[ 0 ] );
		
		imagegif( $baseim , $tmpfolder . 'res_' . $x . '.gif' );
		imagedestroy($baseim);
		
		$exec .= '-delay ' . ( 100 * $seconde ) . 'x1000 ' . $tmpfolder . 'res_' . $x . '.gif ';
		$x++;
	}
	
	$exec .= '-dispose previous -loop 0 ' . $resultaat;
	@system( $exec );
	
	if ( !is_file( $laatstefile ) )
	{
		$Laatste = Array( );
		$Laatate[ 0 ] = '<b>' . date( 'd-m-Y H:i:s' ) . '</b> ' . $string . "\n";
	} else
	{
		$Laatste = file( $laatstefile );
		$Laatste[ count( $Laatste ) + 1 ] = '<b>' . date( 'd-m-Y H:i:s' ) . '</b> ' . $string . "\n";
		if ( count( $Laatste ) > 10 ) array_shift( $Laatste );
	}
	
	file_put_contents( $laatstefile , $Laatste );
}

?>
<html>
<head>
<title>Imagemagic</title>
</head>
<body>

<table border="1" cellpadding="3" cellspacing="0" width="400">
	<tr>
		<td align="center">
			<img src="<?php echo $resultaat;?>" />
		</td>
	</tr>
	<tr>
		<td align="center">

<form method="POST" action="index.php">
	Text: <input type="text" name="text" /><br />
	<input type="submit" value="Wijzigen" />
</form>

		</td>
	</tr>
	<tr>
		<td>
			<p align="center"><strong>Laatste 10 berichten</strong></p>
			<?php
			$Laatsten = file( $laatstefile );
			$Laatsten = array_reverse( $Laatsten );
			$x = 1;
			foreach( $Laatsten as $Laatste )
			{
				echo $x . '. ' . $Laatste . '<br />';
				$x++;
			}
			?>
		</td>
	</tr>
</table>

</body>
</html>[/code]