| 
      1
     | 
    
      //:Create an image from the textparameter
 
     | 
  
  
    | 
      2
     | 
    
      //:Use [[text2image?text=The text to create]]
 
     | 
  
  
    | 
      3
     | 
    
      //clean up old files..
 
     | 
  
  
    | 
      4
     | 
    
      $dir = WB_PATH.'/temp/';
 
     | 
  
  
    | 
      5
     | 
    
      $dp = opendir($dir) or die ('Could not open '.$dir);
     | 
  
  
    | 
      6
     | 
    
      while ($file = readdir($dp)) {
     | 
  
  
    | 
      7
     | 
    
      	if ((eregi('img_',$file)) && (filemtime($dir.$file)) < (strtotime('-10 minutes'))) {
     | 
  
  
    | 
      8
     | 
    
      		unlink($dir.$file);
 
     | 
  
  
    | 
      9
     | 
    
      	}
 
     | 
  
  
    | 
      10
     | 
    
      }
 
     | 
  
  
    | 
      11
     | 
    
      closedir($dp);
 
     | 
  
  
    | 
      12
     | 
    
      
 
     | 
  
  
    | 
      13
     | 
    
      $imgfilename = 'img_'.rand().'_'.time().'.jpg';
 
     | 
  
  
    | 
      14
     | 
    
      //create image
 
     | 
  
  
    | 
      15
     | 
    
      $padding = 0;
 
     | 
  
  
    | 
      16
     | 
    
      $font = 3;  	
 
     | 
  
  
    | 
      17
     | 
    
      
 
     | 
  
  
    | 
      18
     | 
    
      $height = imagefontheight($font) + ($padding * 2);
 
     | 
  
  
    | 
      19
     | 
    
      $width = imagefontwidth($font) * strlen($text) + ($padding * 2);
 
     | 
  
  
    | 
      20
     | 
    
      $image_handle = imagecreatetruecolor($width, $height);
 
     | 
  
  
    | 
      21
     | 
    
      $text_color = imagecolorallocate($image_handle, 0, 0, 0);
 
     | 
  
  
    | 
      22
     | 
    
      $background_color = imagecolorallocate($image_handle, 255, 255, 255);
 
     | 
  
  
    | 
      23
     | 
    
      $bg_height = imagesy($image_handle);
 
     | 
  
  
    | 
      24
     | 
    
      $bg_width = imagesx($image_handle);
 
     | 
  
  
    | 
      25
     | 
    
      imagefilledrectangle($image_handle, 0, 0, $bg_width, $bg_height, $background_color);
 
     | 
  
  
    | 
      26
     | 
    
      imagestring($image_handle, $font, $padding, $padding, $text, $text_color);
 
     | 
  
  
    | 
      27
     | 
    
      imagejpeg($image_handle,WB_PATH.'/temp/'.$imgfilename,100);
 
     | 
  
  
    | 
      28
     | 
    
      imagedestroy($image_handle);
 
     | 
  
  
    | 
      29
     | 
    
      
 
     | 
  
  
    | 
      30
     | 
    
      return '<img src="'.WB_URL.'/temp/'.$imgfilename.'" style="border:0px;margin:0px;padding:0px;vertical-align:middle;" />';
 
     |