Image 图像函数
参见http://php.liukang.com/manual/zh/ref.image.php
// BY PHP 国度 www.phphot.be
//关闭报错
error_reporting(0);
//图片宽度
$x_size=60;
//图片高度
$y_size=20;
//生成4个随机字符
$nmsg=num_rand(4);
//支持安全通连接吗?
$S=$_SERVER['SERVER_PORT']=='443' ? 1:0;
//使用cookie记录随机码
//expire=0 cookie将会在会话结束后(一般是浏览器关闭)失效。
setCookie('ck_num',md5($nmsg),0,'/','',$S);
//创建宽:60*20的图片(画布)
$aimg = imagecreate($x_size,$y_size);
//设置图片背景色
$back = imagecolorallocate($aimg, 255, 255, 255);
//设置字体颜色
$border = imagecolorallocate($aimg, 0, 0, 0);
//从0,0点填充59*19的白色矩形区域
imagefilledrectangle($aimg, 0, 0, $x_size - 1, $y_size - 1, $back);
//从0,0点绘制59*19的黑色矩形边框
imagerectangle($aimg, 0, 0, $x_size - 1, $y_size - 1, $border);
for ($i=0;$i
imageString($aimg,5,$i*$x_size/4+3,2, $nmsg[$i],$border);
}
header("Content-type: image/png");
imagepng($aimg);
imagedestroy($aimg);exit;
function num_rand($lenth){
// 播下一个随机数发生器种子
//php自4.2.0起,,此参数变为可选项,当该项为空时,会被设为随时数
mt_srand((double)microtime() * 1000000);
//产生有4个随机数字的字符串
for($i=0;$i $randval.= mt_rand(0,9);
}
//对含有4个数字的字符串使用md5加密,长度是32位的
//从3长度为32的字符中,自最小数起或最大数32-$lenth起,取长度为$lenth的字符串
$randval=substr(md5($randval),mt_rand(0,32-$lenth),$lenth);
return $randval;
}
?>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Atom editor mac version download
The most popular open source editor

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 English version
Recommended: Win version, supports code prompts!
