Subversion-Projekte lars-tiefland.content-management

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
 
3
/*
4
 * manual for this function can be found in
5
 * directory: /module/classes/browser_class.php
6
 * written by markus niewerth
7
 *
8
 * (c) 2002
9
 *
10
 * mail: markus@niewerth.com
11
 *
12
 * this function creates screens and copy some text or other Graphic
13
 * in the root image. you can use n fonttypes assigned from 1 to n
14
 * fonts can added @ this way: upload some ttf in dir /GD/TTF/
15
 * and add the type name in array($types).
16
 *
17
 * function was written by markus niewerth (2002).
18
 * mail: markus@niewerth.com
19
 * system requirements: linux/unix w. gd-1.8.4 or higher
20
 *
21
 * function use:
22
 * createScreen([int dst_img_big],[int dst_sm_logo],[int width],[int height],
23
 * [int imagename],[int fonttype],[int fontsize]);
24
 *
25
 * fonttypes:
26
 * [1] => arial.ttf  [2] => denmark.ttf  [3] => dexgothn.ttf
27
 * [4] => dotmatrix.ttf [5] => erasure.ttf [6] => eq.ttf
28
 * [7] => xfiles.ttf [8] => fesf____.ttf
29
*/
30
 
31
 
32
 
33
function createScreen($screen,$logo,$newWidth,$newHeight,$ttftext,$ftype,$fsize, $fdir="", $ftypes="")
34
{
35
	$IMpassed = true;
36
 
37
	if($newWidth>=4100 || $newHeight>=2000)
38
	{
39
		 return(false);
40
		 exit();
41
	}
42
 
43
	if(empty($ftype))
44
		$ftype = 3;
45
 
46
	if(empty($fsize))
47
		$fsize = 13;
48
 
49
	if(!$fdir)
50
	{
51
		$fdir   = $_SERVER['DOCUMENT_ROOT']."content-management/Online-Shop/gutschein/TTF/";   /*  ttf font directory */
52
		$ftypes = array (
53
							1 =>	 "arial.ttf",
54
									 "denmark.ttf",
55
									 "dexgothn.ttf",
56
									 "dotmatrix.ttf",
57
									 "erasure.ttf",
58
									 "eq.ttf",
59
									 "xfiles.ttf",
60
									 "fesf____.ttf",
61
									 "AARVC___.ttf",
62
									 "cut_above_the_rest.ttf");  									/*  supported ttf fonts */
63
	}
64
 
65
	$types  = array (1 => "gif", "jpeg", "png", "swf", "psd", "wbmp"); 		  		/* this is helpful for call_user_func */
66
	$font   = $fdir.$ftypes[$ftype];
67
	$size   = imageTTFBBox($fsize, 0, $font, $ttftext);								/* all font parameter */
68
 
69
	$imgsz  = @getimagesize("$screen");
70
	$imgszl = @getimagesize("$logo");
71
 
72
	if(!$imgsz)
73
		$IMpassed = false;
74
 
75
	// only the 3 first image array($types) are suppported
76
	if($imgsz[2]<= 3 && $IMpassed == true):
77
 
78
		$imgh   = @call_user_func("imagecreatefrom".$types[$imgsz[2]], $screen);   	/*  here we call a userdefenied function */
79
		$imgh2  = @call_user_func("imagecreatefrom".$types[$imgszl[2]], $logo);		/* here we call a userdefenied function */
80
 
81
		$imgCreate 	= imagecreate($newWidth, $newHeight);							/* create the new image stream */
82
 
83
		$x = $newWidth-$imgszl[0];    												/* place the copyright logo in x-coordination*/
84
		$y = $newHeight-$imgszl[1];	  												/* place the copyright logo in y-coordination*/
85
		$x=0;$y=0;
86
		$newname = rand(1,10000000000);
87
																					/* noc cahce header */
88
			header("Pragma: no-cache");
89
			header("Expires: 0");
90
			header("Content-Disposition:  filename=".$newname.".".$types[$imgsz[2]]."");
91
			header("Content-Description: PHP Generated Data");
92
			header("Content-type: image/".$types[$imgsz[2]]."");
93
		$white = imagecolorallocate($imgCreate, 0, 0, 0);
94
 
95
		if(imagecopyresized($imgCreate,$imgh, 0, 0, 0, 0, $newWidth, $newHeight, $imgsz[0], $imgsz[1])):
96
		  imagecopy($imgCreate,$imgh2, $x, $y, 0, 0, $imgszl[0], $imgszl[1]);
97
 
98
		$counter=1;
99
		if(is_array($ttftext))
100
		{
101
			foreach(array_keys($ttftext) AS $elem)
102
			{
103
				// echo $ttftext[$elem];
104
			  imageTTFText($imgCreate, $fsize, 0, 20, 100+(($fsize)*$counter+1), $white, $font, $ttftext[$elem]);
105
			  $counter++;
106
			}
107
		}else
108
			imageTTFText($imgCreate, $fsize, 0, 20, 120, $white, $font, $ttftext);
109
		  return(call_user_func("image".$types[$imgsz[2]], $imgCreate,'',100));   	/*here we call a userdefenied function */
110
		  ImageDestroy($imgCreate);
111
		else:
112
			$newname = split("[/]", $screen);
113
			header("Content-Type: application/octet-stream");
114
			header("Pragma: no-cache");
115
			header("Expires: 0");
116
			header("Content-Disposition:  filename=error.html");
117
			header("Content-Description: PHP Generated Data");
118
			header("Content-type: text/html");
119
		endif;
120
 
121
	elseif($imgsz[2] >= 4):
122
			$newname = split("[/]", $screen);
123
			header("Content-Type: application/octet-stream");
124
			header("Pragma: no-cache");
125
			header("Expires: 0");
126
			header("Content-Disposition:  filename=error");
127
			header("Content-Description: PHP Generated Data");
128
			header("Content-type: image/jpg");
129
	endif;
130
 
131
	if($IMpassed == false):
132
			print ("Achtung Fehlerhafte Bild Koordinaten. Das Bild kann nicht gelesen werden.");
133
			# header("Content-Type: application/octet-stream");
134
			header("Pragma: no-cache");
135
			header("Expires: 0");
136
			header("Content-Disposition:  filename=error.log");
137
			header("Content-Description: PHP Generated Data");
138
			header("Content-type: text/plain");
139
	endif;
140
}
141
 
142
 
143
/*
144
 * function end
145
 * here you can place some other misc.
146
 * like me. Or include this function.
147
*/
148
 
149
if(empty($cr))
150
{
151
	$cr = "";
152
}
153
$settings = parse_ini_file("settings.ini.php", TRUE);
154
 
155
$siteurl = $settings['directorys']['siteurl'];
156
$url     = $settings['directorys']['webpath'].$scr;
157
$crimage = $settings['directorys']['webpath'].$settings['directorys']['crimage'];
158
 
159
// print_r($settings);
160
createScreen($url,$crimage,$wd,$hg,$cr,$ft,$fs, $settings['directorys']['fdir'], $settings['ftypes']);
161
?>
162
 
163