PageRenderTime 58ms CodeModel.GetById 22ms app.highlight 29ms RepoModel.GetById 1ms app.codeStats 1ms

/miles/GlobalMBA/mba/sns_00/upload/bbs/include/seccode.class.php

#
PHP | 422 lines | 388 code | 28 blank | 6 comment | 98 complexity | 0f5912d87899170b7ca6ebf68732cd4e MD5 | raw file
  1<?php
  2
  3/*
  4	[Discuz!] (C)2001-2009 Comsenz Inc.
  5	This is NOT a freeware, use is subject to license terms
  6
  7	$Id: seccode.class.php 16698 2008-11-14 07:58:56Z cnteacher $
  8*/
  9
 10if(!defined('IN_DISCUZ')) {
 11	exit('Access Denied');
 12}
 13
 14class seccode {
 15
 16	var $code;
 17	var $type 	= 0;
 18	var $width 	= 150;
 19	var $height 	= 60;
 20	var $background	= 1;
 21	var $adulterate	= 1;
 22	var $ttf 	= 0;
 23	var $angle 	= 0;
 24	var $color 	= 1;
 25	var $size 	= 0;
 26	var $shadow 	= 1;
 27	var $animator 	= 0;
 28	var $fontpath	= '';
 29	var $datapath	= '';
 30	var $includepath= '';
 31
 32	var $fontcolor;
 33	var $im;
 34
 35	function display() {
 36		$this->type == 2 && !extension_loaded('ming') && $this->type = 0;
 37		$this->width = $this->width >= 100 && $this->width <= 200 ? $this->width : 150;
 38		$this->height = $this->height >= 50 && $this->height <= 80 ? $this->height : 60;
 39		seccodeconvert($this->code);
 40		if($this->type < 2 && function_exists('imagecreate') && function_exists('imagecolorset') && function_exists('imagecopyresized') &&
 41			function_exists('imagecolorallocate') && function_exists('imagechar') && function_exists('imagecolorsforindex') &&
 42			function_exists('imageline') && function_exists('imagecreatefromstring') && (function_exists('imagegif') || function_exists('imagepng') || function_exists('imagejpeg'))) {
 43			$this->image();
 44		} elseif($this->type == 2 && extension_loaded('ming')) {
 45			$this->flash();
 46		} elseif($this->type == 3) {
 47			$this->audio();
 48		} else {
 49			$this->bitmap();
 50		}
 51	}
 52
 53	function image() {
 54		$bgcontent = $this->background();
 55
 56		if($this->animator == 1 && function_exists('imagegif')) {
 57			include_once $this->includepath.'gifmerge.class.php';
 58			$trueframe = mt_rand(1, 9);
 59
 60			for($i = 0; $i <= 9; $i++) {
 61				$this->im = imagecreatefromstring($bgcontent);
 62				$x[$i] = $y[$i] = 0;
 63				$this->adulterate && $this->adulterate();
 64				if($i == $trueframe) {
 65					$this->ttf && function_exists('imagettftext') || $this->type == 1 ? $this->ttffont() : $this->giffont();
 66					$d[$i] = mt_rand(250, 400);
 67				} else {
 68					$this->adulteratefont();
 69					$d[$i] = mt_rand(5, 15);
 70				}
 71				ob_start();
 72				imagegif($this->im);
 73				imagedestroy($this->im);
 74				$frame[$i] = ob_get_contents();
 75				ob_end_clean();
 76			}
 77			$anim = new GifMerge($frame, 255, 255, 255, 0, $d, $x, $y, 'C_MEMORY');
 78			dheader('Content-type: image/gif');
 79			echo $anim->getAnimation();
 80		} else {
 81			$this->im = imagecreatefromstring($bgcontent);
 82			$this->adulterate && $this->adulterate();
 83			$this->ttf && function_exists('imagettftext') || $this->type == 1 ? $this->ttffont() : $this->giffont();
 84
 85			if(function_exists('imagepng')) {
 86				dheader('Content-type: image/png');
 87				imagepng($this->im);
 88			} else {
 89				dheader('Content-type: image/jpeg');
 90				imagejpeg($this->im, '', 100);
 91			}
 92			imagedestroy($this->im);
 93		}
 94	}
 95
 96	function background() {
 97		$this->im = imagecreatetruecolor($this->width, $this->height);
 98		$backgroundcolor = imagecolorallocate($this->im, 255, 255, 255);
 99		$backgrounds = $c = array();
100		if($this->background && function_exists('imagecreatefromjpeg') && function_exists('imagecolorat') &&	function_exists('imagecopymerge') &&
101			function_exists('imagesetpixel') && function_exists('imageSX') && function_exists('imageSY')) {
102			if($handle = @opendir($this->datapath.'background/')) {
103				while($bgfile = @readdir($handle)) {
104					if(preg_match('/\.jpg$/i', $bgfile)) {
105						$backgrounds[] = $this->datapath.'background/'.$bgfile;
106					}
107				}
108				@closedir($handle);
109			}
110			if($backgrounds) {
111				$imwm = imagecreatefromjpeg($backgrounds[array_rand($backgrounds)]);
112				$colorindex = imagecolorat($imwm, 0, 0);
113				$this->c = imagecolorsforindex($imwm, $colorindex);
114				$colorindex = imagecolorat($imwm, 1, 0);
115				imagesetpixel($imwm, 0, 0, $colorindex);
116				$c[0] = $c['red'];$c[1] = $c['green'];$c[2] = $c['blue'];
117				imagecopymerge($this->im, $imwm, 0, 0, mt_rand(0, 200 - $this->width), mt_rand(0, 80 - $this->height), imageSX($imwm), imageSY($imwm), 100);
118				imagedestroy($imwm);
119			}
120		}
121		if(!$this->background || !$backgrounds) {
122			for($i = 0;$i < 3;$i++) {
123				$start[$i] = mt_rand(200, 255);$end[$i] = mt_rand(100, 150);$step[$i] = ($end[$i] - $start[$i]) / $this->width;$c[$i] = $start[$i];
124			}
125			for($i = 0;$i < $this->width;$i++) {
126				$color = imagecolorallocate($this->im, $c[0], $c[1], $c[2]);
127				imageline($this->im, $i, 0, $i-$angle, $this->height, $color);
128				$c[0] += $step[0];$c[1] += $step[1];$c[2] += $step[2];
129			}
130			$c[0] -= 20;$c[1] -= 20;$c[2] -= 20;
131		}
132		ob_start();
133		if(function_exists('imagepng')) {
134			imagepng($this->im);
135		} else {
136			imagejpeg($this->im, '', 100);
137		}
138		imagedestroy($this->im);
139		$bgcontent = ob_get_contents();
140		ob_end_clean();
141		$this->fontcolor = $c;
142		return $bgcontent;
143	}
144
145	function adulterate() {
146		$linenums = $this->height / 10;
147		for($i=0; $i <= $linenums; $i++) {
148			$color = $this->color ? imagecolorallocate($this->im, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255)) : imagecolorallocate($this->im, $this->fontcolor[0], $this->fontcolor[1], $this->fontcolor[2]);
149			$x = mt_rand(0, $this->width);
150			$y = mt_rand(0, $this->height);
151			if(mt_rand(0, 1)) {
152				imagearc($this->im, $x, $y, mt_rand(0, $this->width), mt_rand(0, $this->height), mt_rand(0, 360), mt_rand(0, 360), $color);
153			} else {
154				imageline($this->im, $x, $y, $linex + mt_rand(0, $linemaxlong), $liney + mt_rand(0, mt_rand($this->height, $this->width)), $color);
155			}
156		}
157	}
158
159	function adulteratefont() {
160		$seccodeunits = 'BCEFGHJKMPQRTVWXY2346789';
161		$x = $this->width / 4;
162		$y = $this->height / 10;
163		$text_color = imagecolorallocate($this->im, $this->fontcolor[0], $this->fontcolor[1], $this->fontcolor[2]);
164		for($i = 0; $i <= 3; $i++) {
165			$adulteratecode = $seccodeunits[mt_rand(0, 23)];
166			imagechar($this->im, 5, $x * $i + mt_rand(0, $x - 10), mt_rand($y, $this->height - 10 - $y), $adulteratecode, $text_color);
167		}
168	}
169
170	function ttffont() {
171		$seccode = $this->code;
172		$charset = $GLOBALS['charset'];
173		$seccoderoot = $this->type ? $this->fontpath.'ch/' : $this->fontpath.'en/';
174		$dirs = opendir($seccoderoot);
175		$seccodettf = array();
176		while($entry = readdir($dirs)) {
177			if($entry != '.' && $entry != '..' && in_array(strtolower(fileext($entry)), array('ttf', 'ttc'))) {
178				$seccodettf[] = $entry;
179			}
180		}
181		if(empty($seccodettf)) {
182			$this->giffont();
183			return;
184		}
185		$seccodelength = 4;
186		if($this->type && !empty($seccodettf)) {
187			if(strtoupper($charset) != 'UTF-8') {
188				include $this->includepath.'chinese.class.php';
189				$cvt = new Chinese($charset, 'utf8');
190				$seccode = $cvt->Convert($seccode);
191			}
192			$seccode = array(substr($seccode, 0, 3), substr($seccode, 3, 3));
193			$seccodelength = 2;
194		}
195		$widthtotal = 0;
196		for($i = 0; $i < $seccodelength; $i++) {
197			$font[$i]['font'] = $seccoderoot.$seccodettf[array_rand($seccodettf)];
198			$font[$i]['angle'] = $this->angle ? mt_rand(-30, 30) : 0;
199			$font[$i]['size'] = $this->type ? $this->width / 7 : $this->width / 6;
200			$this->size && $font[$i]['size'] = mt_rand($font[$i]['size'] - $this->width / 40, $font[$i]['size'] + $this->width / 20);
201			$box = imagettfbbox($font[$i]['size'], 0, $font[$i]['font'], $seccode[$i]);
202			$font[$i]['zheight'] = max($box[1], $box[3]) - min($box[5], $box[7]);
203			$box = imagettfbbox($font[$i]['size'], $font[$i]['angle'], $font[$i]['font'], $seccode[$i]);
204			$font[$i]['height'] = max($box[1], $box[3]) - min($box[5], $box[7]);
205			$font[$i]['hd'] = $font[$i]['height'] - $font[$i]['zheight'];
206			$font[$i]['width'] = (max($box[2], $box[4]) - min($box[0], $box[6])) + mt_rand(0, $this->width / 8);
207			$font[$i]['width'] = $font[$i]['width'] > $this->width / $seccodelength ? $this->width / $seccodelength : $font[$i]['width'];
208			$widthtotal += $font[$i]['width'];
209		}
210		$x = mt_rand($font[0]['angle'] > 0 ? cos(deg2rad(90 - $font[0]['angle'])) * $font[0]['zheight'] : 1, $this->width - $widthtotal);
211		!$this->color && $text_color = imagecolorallocate($this->im, $this->fontcolor[0], $this->fontcolor[1], $this->fontcolor[2]);
212		for($i = 0; $i < $seccodelength; $i++) {
213			if($this->color) {
214				$this->fontcolor = array(mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
215				$this->shadow && $text_shadowcolor = imagecolorallocate($this->im, 255 - $this->fontcolor[0], 255 - $this->fontcolor[1], 255 - $this->fontcolor[2]);
216				$text_color = imagecolorallocate($this->im, $this->fontcolor[0], $this->fontcolor[1], $this->fontcolor[2]);
217			} elseif($this->shadow) {
218				$text_shadowcolor = imagecolorallocate($this->im, 255 - $this->fontcolor[0], 255 - $this->fontcolor[1], 255 - $this->fontcolor[2]);
219			}
220			$y = $font[0]['angle'] > 0 ? mt_rand($font[$i]['height'], $this->height) : mt_rand($font[$i]['height'] - $font[$i]['hd'], $this->height - $font[$i]['hd']);
221			$this->shadow && imagettftext($this->im, $font[$i]['size'], $font[$i]['angle'], $x + 1, $y + 1, $text_shadowcolor, $font[$i]['font'], $seccode[$i]);
222			imagettftext($this->im, $font[$i]['size'], $font[$i]['angle'], $x, $y, $text_color, $font[$i]['font'], $seccode[$i]);
223			$x += $font[$i]['width'];
224		}
225	}
226
227	function giffont() {
228		$seccode = $this->code;
229		$seccodedir = array();
230		if(function_exists('imagecreatefromgif')) {
231			$seccoderoot = $this->datapath.'gif/';
232			$dirs = opendir($seccoderoot);
233			while($dir = readdir($dirs)) {
234				if($dir != '.' && $dir != '..' && file_exists($seccoderoot.$dir.'/9.gif')) {
235					$seccodedir[] = $dir;
236				}
237			}
238		}
239		$widthtotal = 0;
240		for($i = 0; $i <= 3; $i++) {
241			$this->imcodefile = $seccodedir ? $seccoderoot.$seccodedir[array_rand($seccodedir)].'/'.strtolower($seccode[$i]).'.gif' : '';
242			if(!empty($this->imcodefile) && file_exists($this->imcodefile)) {
243				$font[$i]['file'] = $this->imcodefile;
244				$font[$i]['data'] = getimagesize($this->imcodefile);
245				$font[$i]['width'] = $font[$i]['data'][0] + mt_rand(0, 6) - 4;
246				$font[$i]['height'] = $font[$i]['data'][1] + mt_rand(0, 6) - 4;
247				$font[$i]['width'] += mt_rand(0, $this->width / 5 - $font[$i]['width']);
248				$widthtotal += $font[$i]['width'];
249			} else {
250				$font[$i]['file'] = '';
251				$font[$i]['width'] = 8 + mt_rand(0, $this->width / 5 - 5);
252				$widthtotal += $font[$i]['width'];
253			}
254		}
255		$x = mt_rand(1, $this->width - $widthtotal);
256		for($i = 0; $i <= 3; $i++) {
257			$this->color && $this->fontcolor = array(mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
258			if($font[$i]['file']) {
259				$this->imcode = imagecreatefromgif($font[$i]['file']);
260				if($this->size) {
261					$font[$i]['width'] = mt_rand($font[$i]['width'] - $this->width / 20, $font[$i]['width'] + $this->width / 20);
262					$font[$i]['height'] = mt_rand($font[$i]['height'] - $this->width / 20, $font[$i]['height'] + $this->width / 20);
263				}
264				$y = mt_rand(0, $this->height - $font[$i]['height']);
265				if($this->shadow) {
266					$this->imcodeshadow = $this->imcode;
267					imagecolorset($this->imcodeshadow, 0 , 255 - $this->fontcolor[0], 255 - $this->fontcolor[1], 255 - $this->fontcolor[2]);
268					imagecopyresized($this->im, $this->imcodeshadow, $x + 1, $y + 1, 0, 0, $font[$i]['width'], $font[$i]['height'], $font[$i]['data'][0], $font[$i]['data'][1]);
269				}
270				imagecolorset($this->imcode, 0 , $this->fontcolor[0], $this->fontcolor[1], $this->fontcolor[2]);
271				imagecopyresized($this->im, $this->imcode, $x, $y, 0, 0, $font[$i]['width'], $font[$i]['height'], $font[$i]['data'][0], $font[$i]['data'][1]);
272			} else {
273				$y = mt_rand(0, $this->height - 20);
274				if($this->shadow) {
275					$text_shadowcolor = imagecolorallocate($this->im, 255 - $this->fontcolor[0], 255 - $this->fontcolor[1], 255 - $this->fontcolor[2]);
276					imagechar($this->im, 5, $x + 1, $y + 1, $seccode[$i], $text_shadowcolor);
277				}
278				$text_color = imagecolorallocate($this->im, $this->fontcolor[0], $this->fontcolor[1], $this->fontcolor[2]);
279				imagechar($this->im, 5, $x, $y, $seccode[$i], $text_color);
280			}
281			$x += $font[$i]['width'];
282		}
283	}
284
285	function flash() {
286		$spacing = 5;
287		$codewidth = ($this->width - $spacing * 5) / 4;
288		$strforswdaction = '';
289		for($i = 0; $i <= 3; $i++) {
290			$strforswdaction .= $this->swfcode($codewidth, $spacing, $this->code[$i], $i+1);
291		}
292
293		ming_setScale(20.00000000);
294		ming_useswfversion(6);
295		$movie = new SWFMovie();
296		$movie->setDimension($this->width, $this->height);
297		$movie->setBackground(255, 255, 255);
298		$movie->setRate(31);
299
300		$fontcolor = '0x'.(sprintf('%02s', dechex (mt_rand(0, 255)))).(sprintf('%02s', dechex (mt_rand(0, 128)))).(sprintf('%02s', dechex (mt_rand(0, 255))));
301		$strAction = "
302		_root.createEmptyMovieClip ( 'triangle', 1 );
303		with ( _root.triangle ) {
304		lineStyle( 3, $fontcolor, 100 );
305		$strforswdaction
306		}
307		";
308		$movie->add(new SWFAction( str_replace("\r", "", $strAction) ));
309		header('Content-type: application/x-shockwave-flash');
310		$movie->output();
311	}
312
313	function swfcode($width, $d, $code, $order) {
314		$str = '';
315		$height = $this->height - $d * 2;
316		$x_0 = ($order * ($width + $d) - $width);
317		$x_1 = $x_0 + $width / 2;
318		$x_2 = $x_0 + $width;
319		$y_0 = $d;
320		$y_2 = $y_0 + $height;
321		$y_1 = $y_2 / 2;
322		$y_0_5 = $y_2 / 4;
323		$y_1_5 = $y_1 + $y_0_5;
324		switch($code) {
325			case 'B':$str .= 'moveTo('.$x_1.', '.$y_0.');lineTo('.$x_0.', '.$y_0.');lineTo('.$x_0.', '.$y_2.');lineTo('.$x_1.', '.$y_2.');lineTo('.$x_2.', '.$y_1_5.');lineTo('.$x_1.', '.$y_1.');lineTo('.$x_2.', '.$y_0_5.');lineTo('.$x_1.', '.$y_0.');moveTo('.$x_0.', '.$y_1.');lineTo('.$x_1.', '.$y_1.');';break;
326			case 'C':$str .= 'moveTo('.$x_2.', '.$y_0.');lineTo('.$x_0.', '.$y_0.');lineTo('.$x_0.', '.$y_2.');lineTo('.$x_2.', '.$y_2.');';break;
327			case 'E':$str .= 'moveTo('.$x_2.', '.$y_0.');lineTo('.$x_0.', '.$y_0.');lineTo('.$x_0.', '.$y_2.');lineTo('.$x_2.', '.$y_2.');moveTo('.$x_0.', '.$y_1.');lineTo('.$x_1.', '.$y_1.');';break;
328			case 'F':$str .= 'moveTo('.$x_2.', '.$y_0.');lineTo('.$x_0.', '.$y_0.');lineTo('.$x_0.', '.$y_2.');moveTo('.$x_0.', '.$y_1.');lineTo('.$x_1.', '.$y_1.');';break;
329			case 'G':$str .= 'moveTo('.$x_2.', '.$y_0.');lineTo('.$x_0.', '.$y_0.');lineTo('.$x_0.', '.$y_2.');lineTo('.$x_2.', '.$y_2.');lineTo('.$x_2.', '.$y_1.');lineTo('.$x_1.', '.$y_1.');';break;
330			case 'H':$str .= 'moveTo('.$x_0.', '.$y_0.');lineTo('.$x_0.', '.$y_2.');moveTo('.$x_2.', '.$y_0.');lineTo('.$x_2.', '.$y_2.');moveTo('.$x_0.', '.$y_1.');lineTo('.$x_2.', '.$y_1.');';break;
331			case 'J':$str .= 'moveTo('.$x_1.', '.$y_0.');lineTo('.$x_2.', '.$y_0.');lineTo('.$x_2.', '.$y_2.');lineTo('.$x_0.', '.$y_2.');lineTo('.$x_0.', '.$y_1_5.');';break;
332			case 'K':$str .= 'moveTo('.$x_2.', '.$y_0.');lineTo('.$x_1.', '.$y_1.');lineTo('.$x_0.', '.$y_1.');lineTo('.$x_0.', '.$y_0.');lineTo('.$x_0.', '.$y_2.');moveTo('.$x_1.', '.$y_1.');lineTo('.$x_2.', '.$y_2.');';break;
333			case 'M':$str .= 'moveTo('.$x_0.', '.$y_2.');lineTo('.$x_0.', '.$y_0.');lineTo('.$x_1.', '.$y_1.');lineTo('.$x_2.', '.$y_0.');lineTo('.$x_2.', '.$y_2.');';break;
334			case 'P':$str .= 'moveTo('.$x_0.', '.$y_1.');lineTo('.$x_1.', '.$y_1.');lineTo('.$x_2.', '.$y_0_5.');lineTo('.$x_1.', '.$y_0.');lineTo('.$x_0.', '.$y_0.');lineTo('.$x_0.', '.$y_2.');';break;
335			case 'Q':$str .= 'moveTo('.$x_2.', '.$y_2.');lineTo('.$x_0.', '.$y_2.');lineTo('.$x_0.', '.$y_0.');lineTo('.$x_2.', '.$y_0.');lineTo('.$x_2.', '.$y_2.');lineTo('.$x_1.', '.$y_1.');';break;
336			case 'R':$str .= 'moveTo('.$x_0.', '.$y_1.');lineTo('.$x_1.', '.$y_1.');lineTo('.$x_2.', '.$y_0_5.');lineTo('.$x_1.', '.$y_0.');lineTo('.$x_0.', '.$y_0.');lineTo('.$x_0.', '.$y_2.');moveTo('.$x_1.', '.$y_1.');lineTo('.$x_2.', '.$y_2.');';break;
337			case 'T':$str .= 'moveTo('.$x_0.', '.$y_0.');lineTo('.$x_2.', '.$y_0.');moveTo('.$x_1.', '.$y_0.');lineTo('.$x_1.', '.$y_2.');';break;
338			case 'V':$str .= 'moveTo('.$x_0.', '.$y_0.');lineTo('.$x_1.', '.$y_2.');lineTo('.$x_2.', '.$y_0.');';break;
339			case 'W':$str .= 'moveTo('.$x_0.', '.$y_0.');lineTo('.$x_0.', '.$y_2.');lineTo('.$x_1.', '.$y_1.');lineTo('.$x_2.', '.$y_2.');lineTo('.$x_2.', '.$y_0.');';break;
340			case 'X':$str .= 'moveTo('.$x_0.', '.$y_0.');lineTo('.$x_2.', '.$y_2.');moveTo('.$x_2.', '.$y_0.');lineTo('.$x_0.', '.$y_2.');';break;
341			case 'Y':$str .= 'moveTo('.$x_0.', '.$y_0.');lineTo('.$x_1.', '.$y_1.');lineTo('.$x_2.', '.$y_0.');moveTo('.$x_1.', '.$y_1.');lineTo('.$x_1.', '.$y_2.');';break;
342			case '2':$str .= 'moveTo('.$x_0.', '.$y_0.');lineTo('.$x_2.', '.$y_0.');lineTo('.$x_2.', '.$y_1.');lineTo('.$x_0.', '.$y_1.');lineTo('.$x_0.', '.$y_2.');lineTo('.$x_2.', '.$y_2.');';break;
343			case '3':$str .= 'moveTo('.$x_0.', '.$y_0.');lineTo('.$x_2.', '.$y_0.');lineTo('.$x_2.', '.$y_2.');lineTo('.$x_0.', '.$y_2.');moveTo('.$x_0.', '.$y_1.');lineTo('.$x_2.', '.$y_1.');';break;
344			case '4':$str .= 'moveTo('.$x_2.', '.$y_0.');lineTo('.$x_2.', '.$y_2.');moveTo('.$x_0.', '.$y_0.');lineTo('.$x_0.', '.$y_1.');lineTo('.$x_2.', '.$y_1.');';break;
345			case '6':$str .= 'moveTo('.$x_2.', '.$y_0.');lineTo('.$x_0.', '.$y_0.');lineTo('.$x_0.', '.$y_2.');lineTo('.$x_2.', '.$y_2.');lineTo('.$x_2.', '.$y_1.');lineTo('.$x_0.', '.$y_1.');';break;
346			case '7':$str .= 'moveTo('.$x_0.', '.$y_0.');lineTo('.$x_2.', '.$y_0.');lineTo('.$x_2.', '.$y_2.');';break;
347			case '8':$str .= 'moveTo('.$x_0.', '.$y_0.');lineTo('.$x_0.', '.$y_2.');lineTo('.$x_2.', '.$y_2.');lineTo('.$x_2.', '.$y_0.');lineTo('.$x_0.', '.$y_0.');moveTo('.$x_0.', '.$y_1.');lineTo('.$x_2.', '.$y_1.');';break;
348			case '9':$str .= 'moveTo('.$x_2.', '.$y_1.');lineTo('.$x_0.', '.$y_1.');lineTo('.$x_0.', '.$y_0.');lineTo('.$x_2.', '.$y_0.');lineTo('.$x_2.', '.$y_2.');lineTo('.$x_0.', '.$y_2.');';break;
349		}
350		return $str;
351	}
352
353	function audio() {
354		header('Content-type: audio/mpeg');
355		for($i = 0;$i <= 3; $i++) {
356			readfile($this->datapath.'sound/'.strtolower($this->code[$i]).'.mp3');
357		}
358	}
359
360	function bitmap() {
361		$numbers = array
362			(
363			'B' => array('00','fc','66','66','66','7c','66','66','fc','00'),
364			'C' => array('00','38','64','c0','c0','c0','c4','64','3c','00'),
365			'E' => array('00','fe','62','62','68','78','6a','62','fe','00'),
366			'F' => array('00','f8','60','60','68','78','6a','62','fe','00'),
367			'G' => array('00','78','cc','cc','de','c0','c4','c4','7c','00'),
368			'H' => array('00','e7','66','66','66','7e','66','66','e7','00'),
369			'J' => array('00','f8','cc','cc','cc','0c','0c','0c','7f','00'),
370			'K' => array('00','f3','66','66','7c','78','6c','66','f7','00'),
371			'M' => array('00','f7','63','6b','6b','77','77','77','e3','00'),
372			'P' => array('00','f8','60','60','7c','66','66','66','fc','00'),
373			'Q' => array('00','78','cc','cc','cc','cc','cc','cc','78','00'),
374			'R' => array('00','f3','66','6c','7c','66','66','66','fc','00'),
375			'T' => array('00','78','30','30','30','30','b4','b4','fc','00'),
376			'V' => array('00','1c','1c','36','36','36','63','63','f7','00'),
377			'W' => array('00','36','36','36','77','7f','6b','63','f7','00'),
378			'X' => array('00','f7','66','3c','18','18','3c','66','ef','00'),
379			'Y' => array('00','7e','18','18','18','3c','24','66','ef','00'),
380			'2' => array('fc','c0','60','30','18','0c','cc','cc','78','00'),
381			'3' => array('78','8c','0c','0c','38','0c','0c','8c','78','00'),
382			'4' => array('00','3e','0c','fe','4c','6c','2c','3c','1c','1c'),
383			'6' => array('78','cc','cc','cc','ec','d8','c0','60','3c','00'),
384			'7' => array('30','30','38','18','18','18','1c','8c','fc','00'),
385			'8' => array('78','cc','cc','cc','78','cc','cc','cc','78','00'),
386			'9' => array('f0','18','0c','6c','dc','cc','cc','cc','78','00')
387			);
388
389		foreach($numbers as $i => $number) {
390			for($j = 0; $j < 6; $j++) {
391				$a1 = substr('012', mt_rand(0, 2), 1).substr('012345', mt_rand(0, 5), 1);
392				$a2 = substr('012345', mt_rand(0, 5), 1).substr('0123', mt_rand(0, 3), 1);
393				mt_rand(0, 1) == 1 ? array_push($numbers[$i], $a1) : array_unshift($numbers[$i], $a1);
394				mt_rand(0, 1) == 0 ? array_push($numbers[$i], $a1) : array_unshift($numbers[$i], $a2);
395			}
396		}
397
398		$bitmap = array();
399		for($i = 0; $i < 20; $i++) {
400			for($j = 0; $j <= 3; $j++) {
401				$bytes = $numbers[$this->code[$j]][$i];
402				$a = mt_rand(0, 14);
403				array_push($bitmap, $bytes);
404			}
405		}
406
407		for($i = 0; $i < 8; $i++) {
408			$a = substr('012345', mt_rand(0, 2), 1) . substr('012345', mt_rand(0, 5), 1);
409			array_unshift($bitmap, $a);
410			array_push($bitmap, $a);
411		}
412
413		$image = pack('H*', '424d9e000000000000003e000000280000002000000018000000010001000000'.
414				'0000600000000000000000000000000000000000000000000000FFFFFF00'.implode('', $bitmap));
415
416		dheader('Content-Type: image/bmp');
417		echo $image;
418	}
419
420}
421
422?>