<?
  
if (isset($_GET['source'])) {
    
highlight_file('index.php');
    exit();
  }

  if (!isset(
$_GET['text'])) {
?>
<html>
  <head>
    <title>Kenteken generator</title>
  </head>
  <body>
    <img src="?text=Kenteken" alt="Kenteken"><br>
    <img src="?text=generator" alt="generator"><br><br>
    <form><input type='text' name='text' value='sc-ri-pt'>
    <input type=submit value='Maak kenteken'></form>
    <small><a href="?source">Sourcecode</a></small>
  </body>
</html>
<?
    
exit();
  }

  
$find    = array('!','@','#','$','%','^','&','*','(',')',"_"," ");
  
$replace = array('1','2','3','4','5','6','7','8','9','0','-',".");

  
$text strtoupper($_GET['text']);
  
$text str_replace($find,$replace,$text);
  
$cachename "cache/" md5($text) . ".png";
  if (!
file_exists($cachename)) {
    
$bbox imagettfbbox(710"./Kenteken.ttf"$text);
    
$width=100 $bbox[2];
    
$voorkant imagecreatefrompng("voorkant.png");
    
$achterkant imagecreatefrompng("achterkant.png");
    
$tussenin imagecreatefrompng("tussenin.png");
    
$bord imagecreatetruecolor($width,133);
    
imagecopy($bord$voorkant000070133);
    
imagecopy($bord$achterkant$width-1500015133);
    
imagecopyresized($bord$tussenin70000$width 851331133);
    
$black imagecolorallocate($bord000);
    
$beveltop imagecolorallocate($bord24720771);
    
$bevelmiddle imagecolorallocate($bord248216103);
    
$beveldark imagecolorallocate($bord2061613);
    
imagettftext($bord71071103$beveltop"./Kenteken.ttf"$text);
    
imagettftext($bord71073105$bevelmiddle"./Kenteken.ttf"$text);
    
imagettftext($bord71077109$beveldark"./Kenteken.ttf"$text);
    
imagettftext($bord71075107$black"./Kenteken.ttf"$text);
    
$secmin=strrpos($text,'-',0);
    if (
$secmin) {
      
$bbox imagettfbbox(710"./Kenteken.ttf"
substr($text,0,$secmin+1));
      
$tekentje imagecreatefrompng("nl-teken.png");
      
imagecopy($bord$tekentje$bbox[4]+4919002833);
    }    
    
imagepng($bord$cachename);
  }
  
header("Content-type: image/png");
  
readfile($cachename);
?>