<?php$aData[0] = "零";$aData[1] = "一";$aData[2] = "二";$aData[3] = "三";$aData[4] = "四";$aData[5] = "五";$aData[6] = "六";$aData[7] = "七";$aData[8] = "八";$aData[9] = "九";$font = "/usr/share/fonts/truetype/msjhbd.ttf";foreach ($aData as $num => $str) { $im = ImageCreate(24, 24); $background = ImageColorAllocate($im, 255, 255, 255); $fontcolor = ImageColorAllocate($im, 0, 0, 0); ImageTTFText($im, 16, 0, 2, 21, $fontcolor, $font, $str); ImagePNG($im, $num.'.png'); ImageDestroy($im);}?>
function showImage() { // Delete those cached authimage files that never used $this->deleteExpiredAuthImage($this->expiredTime);define( "AUTHIMAGE_IMAGE_FOLDER", PLOG_CLASS_PATH."plugins/authimage/image/" ); $code = $this->generateCode(); $encrypt = $this->encrypt($code, $this->key); $background = AUTHIMAGE_BACKGROUND_FOLDER.$this->default; $tempFile = $this->cacheFolder."/".$encrypt.".gif"; $len = strlen($code); $image = ImageCreate(24 * $len, 24); $im_bg = ImageCreateFromGIF($background); if ($im_bg) { list($bg_width, $bg_height, $bg_type, $bg_attr) = @GetImageSize($background); if (function_exists('ImageCopyReSampled')) ImageCopyReSampled($image, $im_bg, 0, 0, 0, 0, 24 * $len, 24, $bg_width, $bg_height); else ImageCopyReSized($image, $im_bg, 0, 0, 0, 0, 24 * $len, 24, $bg_width, $bg_height); ImageDestroy($im_bg); } for ($i = 0; $i < $len; $i++) { $im_num = @ImageCreateFromPNG(AUTHIMAGE_IMAGE_FOLDER.$code[$i].'.png'); if ($im_num) { ImageColorTransparent($im_num, ImageColorAt($im_num, 0, 0)); ImageCopy($image, $im_num, 24 * $i, 0, 0, 0, 24, 24); ImageDestroy($im_num); } } ImagePNG($image, $tempFile); ImageDestroy($image); $temp = fopen($tempFile,"rb"); $buffer = fread($temp,filesize($tempFile)); fclose($temp); // Now zero-length the file. No need for its content anymore. $temp = fopen($tempFile,"w"); fwrite($temp, NULL); fclose($temp); // Now chmod it so it can be deleted later by the user chmod($tempFile, 0666); header("Content-type: image/png"); echo $buffer; }
function showImage() { // Delete those cached authimage files that never used $this->deleteExpiredAuthImage($this->expiredTime); $code = $this->generateCode(); $encrypt = $this->encrypt($code, $this->key); $background = AUTHIMAGE_BACKGROUND_FOLDER.$this->default; if ($this->default == 'random.gif') { $files = glob(AUTHIMAGE_BACKGROUND_FOLDER.'*.gif'); $cnt = count($files); $choose = rand(0, $cnt-1); $background = $files[$choose]; } $tempFile = $this->cacheFolder."/".$encrypt.".gif"; if (function_exists('ImageRotate')) $size = 36; else $size = 24; $len = strlen($code); $image = ImageCreate($size * $len, $size); $im_bg = ImageCreateFromGIF($background); if ($im_bg) { list($bg_width, $bg_height, $bg_type, $bg_attr) = @GetImageSize($background); if (function_exists('ImageCopyReSampled')) ImageCopyReSampled($image, $im_bg, 0, 0, 0, 0, $size * $len, $size, $bg_width, $bg_height); else ImageCopyReSized($image, $im_bg, 0, 0, 0, 0, $size * $len, $size, $bg_width, $bg_height); ImageDestroy($im_bg); } for ($i = 0; $i < $len; $i++) { $im_num = @ImageCreateFromPNG(AUTHIMAGE_IMAGE_FOLDER.$code[$i].'.png'); if (function_exists('ImageRotate')) { $im_rotate = ImageRotate($im_num, rand(-45, 45), 0); ImageDestroy($im_num); $im_num = ImageCreate($size, $size); if (function_exists('ImageCopyReSampled')) ImageCopyReSampled($im_num, $im_rotate, 0, 0, 0, 0, $size, $size, imagesx($im_rotate), imagesy($im_rotate)); else ImageCopyReSized($im_num, $im_rotate, 0, 0, 0, 0, $size, $size, imagesx($im_rotate), imagesy($im_rotate)); ImageDestroy($im_rotate); } if ($im_num) { ImageColorTransparent($im_num, ImageColorAt($image,0, 0)); ImageCopy($image, $im_num, $size * $i, 0, 0, 0, $size, $size); ImageDestroy($im_num); } } ImagePNG($image, $tempFile); ImageDestroy($image); $temp = fopen($tempFile,"rb"); $buffer = fread($temp,filesize($tempFile)); fclose($temp); // Now zero-length the file. No need for its content anymore. $temp = fopen($tempFile,"w"); fwrite($temp, NULL); fclose($temp); // Now chmod it so it can be deleted later by the user chmod($tempFile, 0666); header("Content-type: image/png"); echo $buffer; }