Project

General

Profile

« Previous | Next » 

Revision 1301

Added by Dietmar about 14 years ago

Tickets #932 change deprecated eregi functions
Tickets #948 fixed Multiple use of same parametrised droplet - parameter handling
Upgrade Droplets to Version 1.0.3
update some headerinfos
non existing pages, will be created if clicking save in page settings

View differences:

Text2Image.php
1
//:Create an image from the textparameter
2
//:Use [[text2image?text=The text to create]]
3
//clean up old files..
-$dir = WB_PATH.'/temp/';
-$dp = opendir($dir) or die ('Could not open '.$dir);
-while ($file = readdir($dp)) {
-	if ((eregi('img_',$file)) && (filemtime($dir.$file)) < (strtotime('-10 minutes'))) {
-		unlink($dir.$file);
-	}
-}
-closedir($dp);
-
-$imgfilename = 'img_'.rand().'_'.time().'.jpg';
-//create image
-$padding = 0;
-$font = 3;  	
-
-$height = imagefontheight($font) + ($padding * 2);
-$width = imagefontwidth($font) * strlen($text) + ($padding * 2);
-$image_handle = imagecreatetruecolor($width, $height);
-$text_color = imagecolorallocate($image_handle, 0, 0, 0);
-$background_color = imagecolorallocate($image_handle, 255, 255, 255);
-$bg_height = imagesy($image_handle);
-$bg_width = imagesx($image_handle);
-imagefilledrectangle($image_handle, 0, 0, $bg_width, $bg_height, $background_color);
-imagestring($image_handle, $font, $padding, $padding, $text, $text_color);
-imagejpeg($image_handle,WB_PATH.'/temp/'.$imgfilename,100);
-imagedestroy($image_handle);
-
+//:Create an image from the textparameter
1
//:Use [[text2image?text=The text to create]]
2
//clean up old files..
3
$dir = WB_PATH.'/temp/';
4
$dp = opendir($dir) or die ('Could not open '.$dir);
5
while ($file = readdir($dp)) {
6
	if ((preg_match('/img_/',$file)) && (filemtime($dir.$file)) <  (strtotime('-10 minutes'))) {
7
		unlink($dir.$file);
8
	}
9
}
10
closedir($dp);
11

  
12
$imgfilename = 'img_'.rand().'_'.time().'.jpg';
13
//create image
14
$padding = 0;
15
$font = 3;  	
16

  
17
$height = imagefontheight($font) + ($padding * 2);
18
$width = imagefontwidth($font) * strlen($text) + ($padding * 2);
19
$image_handle = imagecreatetruecolor($width, $height);
20
$text_color = imagecolorallocate($image_handle, 0, 0, 0);
21
$background_color = imagecolorallocate($image_handle, 255, 255, 255);
22
$bg_height = imagesy($image_handle);
23
$bg_width = imagesx($image_handle);
24
imagefilledrectangle($image_handle, 0, 0, $bg_width, $bg_height, $background_color);
25
imagestring($image_handle, $font, $padding, $padding, $text, $text_color);
26
imagejpeg($image_handle,WB_PATH.'/temp/'.$imgfilename,100);
27
imagedestroy($image_handle);
28

  
4 29
return '<img src="'.WB_URL.'/temp/'.$imgfilename.'" style="border:0px;margin:0px;padding:0px;vertical-align:middle;" />';

Also available in: Unified diff