<?php
/**
 * [UQcms System] Copyright uqcms.com
 * QQ: 2200631718
 * Author: gj.name
 * This is NOT a freeware
*/  defined('IN_UQ') or exit('Access Denied'); class vcode { function __construct($width = '100', $height = '36'){ $this->width = $width; $this->height = $height; $this->font = array( UQCMS_PATH.'public/font/lucon.ttf' ); } function create_bg(){ $this->images = imagecreatetruecolor($this->width,$this->height); $bg_color = imagecolorallocate($this->images, mt_rand(237,255), mt_rand(253,255), mt_rand(247,255)); imagerectangle($this->images, 0, 0, 1, 1, $bg_color); imagefilledrectangle($this->images,0, $this->height, $this->width,0 ,$bg_color); } private function create_font() { $code_num = strlen($this->code); $font_width = ($this->width) / $code_num; for($i=0;$i < $code_num;$i++){ $font_color = imagecolorallocate($this->images, mt_rand(10,76), mt_rand(95,174), mt_rand(167,240)); imagettftext($this->images, '20', mt_rand(-10,10), $i*20+ mt_rand(1,10), $this->height-8, $font_color, $this->font[array_rand($this->font)], $this->code[$i] ); } } function get_img($code){ $this->code = $code; $this->create_bg(); $this->create_font(); header('Content-type:image/png'); imagepng($this->images); imagedestroy($this->images); } } 