PageRenderTime 48ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

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