captcha_non_gd.php

来自「这些都是我以前学习是用到的源码」· PHP 代码 · 共 343 行 · 第 1/5 页

PHP
343
字号
<?php/** ** @package VC* @version $Id: captcha_non_gd.php,v 1.6 2006/11/15 15:34:33 acydburn Exp $* @copyright (c) 2006 phpBB Group * @license http://opensource.org/licenses/gpl-license.php GNU Public License **//*** Main non-gd captcha class* @ignore* @package VC*/class captcha{	var $filtered_pngs;	var $width = 320;	var $height = 50;	/**	* Define filtered pngs on init	*/	function captcha()	{		// If we can we will generate a single filtered png, we avoid nastiness via emulation of some Zlib stuff		$this->define_filtered_pngs();	}	/**	* Create the image containing $code	*/	function execute($code)	{		$img_height = $this->height - 10;		$img_width = 0;		list($usec, $sec) = explode(' ', microtime()); 		mt_srand($sec * $usec);		$char_widths = $hold_chars = array();		$code_len = strlen($code);		for ($i = 0; $i < $code_len; $i++)		{			$char = $code[$i];			$width = mt_rand(0, 4);			$raw_width = $this->filtered_pngs[$char]['width'];			$char_widths[$i] = $width;			$img_width += $raw_width - $width;			// Split the char into chunks of $raw_width + 1 length			if (empty($hold_chars[$char]))			{				$hold_chars[$char] = str_split(base64_decode($this->filtered_pngs[$char]['data']), $raw_width + 1);			}		}		$offset_x = mt_rand(0, $this->width - $img_width);		$offset_y = mt_rand(0, $this->height - $img_height);		$image = '';		for ($i = 0; $i < $this->height; $i++)		{			$image .= chr(0);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?