国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Home php教程 php手冊 修改了一個很不錯的php驗(yàn)證碼(支持中文)

修改了一個很不錯的php驗(yàn)證碼(支持中文)

Jun 13, 2016 pm 12:33 PM
php Chinese Revise support code English verify

php英文驗(yàn)證碼
captcha.class.php

復(fù)制代碼 代碼如下:


class Captcha
{
private $width;
private $height;
private $codeNum;
private $code;
private $im;
function __construct($width=80, $height=20, $codeNum=4)
{
$this->width = $width;
$this->height = $height;
$this->codeNum = $codeNum;
}
function showImg()
{
//創(chuàng)建圖片
$this->createImg();
//設(shè)置干擾元素
$this->setDisturb();
//設(shè)置驗(yàn)證碼
$this->setCaptcha();
//輸出圖片
$this->outputImg();
}
function getCaptcha()
{
return $this->code;
}
private function createImg()
{
$this->im = imagecreatetruecolor($this->width, $this->height);
$bgColor = imagecolorallocate($this->im, 0, 0, 0);
imagefill($this->im, 0, 0, $bgColor);
}
private function setDisturb()
{
$area = ($this->width * $this->height) / 20;
$disturbNum = ($area > 250) ? 250 : $area;
//加入點(diǎn)干擾
for ($i = 0; $i $color = imagecolorallocate($this->im, rand(0, 255), rand(0, 255), rand(0, 255));
imagesetpixel($this->im, rand(1, $this->width - 2), rand(1, $this->height - 2), $color);
}
//加入弧線
for ($i = 0; $i $color = imagecolorallocate($this->im, rand(128, 255), rand(125, 255), rand(100, 255));
imagearc($this->im, rand(0, $this->width), rand(0, $this->height), rand(30, 300), rand(20, 200), 50, 30, $color);
}
}
private function createCode()
{
$str = "23456789abcdefghijkmnpqrstuvwxyzABCDEFGHIJKMNPQRSTUVWXYZ";
for ($i = 0; $i codeNum; $i++) {
$this->code .= $str{rand(0, strlen($str) - 1)};
}
}
private function setCaptcha()
{
$this->createCode();
for ($i = 0; $i codeNum; $i++) {
$color = imagecolorallocate($this->im, rand(50, 250), rand(100, 250), rand(128, 250));
$size = rand(floor($this->height / 5), floor($this->height / 3));
$x = floor($this->width / $this->codeNum) * $i + 5;
$y = rand(0, $this->height - 20);
imagechar($this->im, $size, $x, $y, $this->code{$i}, $color);
}
}
private function outputImg()
{
if (imagetypes() & IMG_JPG) {
header('Content-type:image/jpeg');
imagejpeg($this->im);
} elseif (imagetypes() & IMG_GIF) {
header('Content-type: image/gif');
imagegif($this->im);
} elseif (imagetype() & IMG_PNG) {
header('Content-type: image/png');
imagepng($this->im);
} else {
die("Don't support image type!");
}
}
}


demo.php

復(fù)制代碼 代碼如下:


require_once 'captcha.class.php';
$captcha = new Captcha(80,30,4);
$captcha->showImg();


上面是支持英文的,腳本之家再附上一個支持中文的驗(yàn)證碼

復(fù)制代碼 代碼如下:


/*
轉(zhuǎn)載請注明來源于 ITBBS 。
修改請聯(lián)系作者信箱:Smartly@itbbs.cn
*/
Header("Content-type: image/PNG");
$str = "的一是在了不和有大這主中人上為們地個用工時要動國產(chǎn)以我到他會作來分生對于學(xué)下級就年階義發(fā)成部民可出能方進(jìn)同行面說種過命度革而多子后自社加小機(jī)也經(jīng)力線本電高量長黨得實(shí)家定深法表著水理化爭現(xiàn)所二起政三好十戰(zhàn)無農(nóng)使性前等反體合斗路圖把結(jié)第里正新開論之物從當(dāng)兩些還天資事隊批如應(yīng)形想制心樣干都向變關(guān)點(diǎn)育重其思與間內(nèi)去因件日利相由壓員氣業(yè)代全組數(shù)果期導(dǎo)平各基或月毛然問比展那它最及外沒看治提五解系林者米群頭意只明四道馬認(rèn)次文通但條較克又公孔領(lǐng)軍流入接席位情運(yùn)器并飛原油放立題質(zhì)指建區(qū)驗(yàn)活眾很教決特此常石強(qiáng)極土少已根共直團(tuán)統(tǒng)式轉(zhuǎn)別造切九你取西持總料連任志觀調(diào)七么山程百報更見必真保熱委手改管處己將修支識病象幾先老光專什六型具示復(fù)安帶每東增則完風(fēng)回南廣勞輪科北打積車計給節(jié)做務(wù)被整聯(lián)步類集號列溫裝即毫知軸研單色堅據(jù)速防史拉世設(shè)達(dá)爾場織歷花受求傳口斷況采精金界品判參層止邊清至萬確究書術(shù)狀廠須離再目海交權(quán)且兒青才證低越際八試規(guī)斯近注辦布門鐵需走議縣兵固除般引齒千勝細(xì)影濟(jì)白格效置推空配刀葉率述今選養(yǎng)德話查差半敵始片施響收華覺備名紅續(xù)均藥標(biāo)記難存測士身緊液派準(zhǔn)斤角降維板許破述技消底床田勢端感往神便賀村構(gòu)照容非搞亞磨族火段算適講按值美態(tài)黃易彪服早班麥削信排臺聲該擊素張密害侯草何樹肥繼右屬市嚴(yán)徑螺檢左頁抗蘇顯苦英快稱壞移約巴材省黑武培著河帝僅針怎植京助升王眼她抓含苗副雜普談圍食射源例致酸舊卻充足短劃劑宣環(huán)落首尺波承粉踐府魚隨考刻靠夠滿夫失包住促枝局菌桿周護(hù)巖師舉曲春元超負(fù)砂封換太模貧減陽揚(yáng)江析畝木言球朝醫(yī)校古呢稻宋聽唯輸滑站另衛(wèi)字鼓剛寫劉微略范供阿塊某功套友限項余倒卷創(chuàng)律雨讓骨遠(yuǎn)幫初皮播優(yōu)占死毒圈偉季訓(xùn)控激找叫云互跟裂糧粒母練塞鋼頂策雙留誤礎(chǔ)吸阻故寸盾晚絲女散焊功株親院冷徹彈錯散商視藝滅版烈零室輕血倍缺厘泵察絕富城沖噴壤簡否柱李望盤磁雄似困鞏益洲脫投送奴側(cè)潤蓋揮距觸星松送獲興獨(dú)官混紀(jì)依未突架寬冬章濕偏紋吃執(zhí)閥礦寨責(zé)熟穩(wěn)奪硬價努翻奇甲預(yù)職評讀背協(xié)損棉侵灰雖矛厚羅泥辟告卵箱掌氧恩愛停曾溶營終綱孟錢待盡俄縮沙退陳討奮械載胞幼哪剝迫旋征槽倒握擔(dān)仍呀鮮吧卡粗介鉆逐弱腳怕鹽末陰豐編印蜂急拿擴(kuò)傷飛露核緣游振操央伍域甚迅輝異序免紙夜鄉(xiāng)久隸缸夾念蘭映溝乙嗎儒殺汽磷艱晶插埃燃?xì)g鐵補(bǔ)咱芽永瓦傾陣碳演威附牙芽永瓦斜灌歐獻(xiàn)順豬洋腐請透司危括脈宜笑若尾束壯暴企菜穗楚漢愈綠拖牛份染既秋遍鍛玉夏療尖殖井費(fèi)州訪吹榮銅沿替滾客召旱悟刺腦措貫藏敢令隙爐殼硫煤迎鑄粘探臨薄旬善??v擇禮愿伏殘雷延煙句純漸耕跑澤慢栽魯赤繁境潮橫掉錐希池敗船假亮謂托伙哲懷割擺貢呈勁財儀沉煉麻罪祖息車穿貨銷齊鼠抽畫飼龍庫守筑房歌寒喜哥洗蝕廢納腹乎錄鏡婦惡脂莊擦險贊鐘搖典柄辯竹谷賣亂虛橋奧伯趕垂途額壁網(wǎng)截野遺靜謀弄掛課鎮(zhèn)妄盛耐援扎慮鍵歸符慶聚繞摩忙舞遇索顧膠羊湖釘仁音跡碎伸燈避泛亡答勇頻皇柳哈揭甘諾概憲濃島襲誰洪謝炮澆斑訊懂靈蛋閉孩釋乳巨徒私銀伊景坦累勻霉杜樂勒隔彎績招紹胡呼痛峰零柴簧午跳居尚丁秦稍追梁折耗堿殊崗?fù)谑先袆《押蘸尚睾馇谀て邱v案刊秧緩?fù)挂奂舸ㄑ╂湞O啦臉戶洛孢勃盟買楊宗焦賽旗濾硅炭股坐蒸凝竟陷槍黎救冒暗洞犯筒您宋弧爆謬涂味津臂障褐陸啊健尊豆拔莫抵桑坡縫警挑污冰柬嘴啥飯塑寄趙喊墊康遵牧遭幅園腔訂香肉弟屋敏恢忘衣孫齡嶺騙休借丹渡耳刨虎筆稀昆浪薩茶滴淺擁穴覆倫娘噸浸袖珠雌媽紫戲塔錘震歲貌潔剖牢鋒疑霸閃埔猛訴刷狠忽災(zāi)鬧喬唐漏聞沈熔氯荒莖男凡搶像漿旁玻亦忠唱蒙予紛捕鎖尤乘烏智淡允叛畜俘摸銹掃畢璃寶芯爺鑒秘凈蔣鈣肩騰枯拋軌堂拌爸循誘祝勵肯酒繩窮塘燥泡袋朗喂鋁軟渠顆慣貿(mào)糞綜墻趨彼屆墨礙啟逆卸航霧冠丙街萊貝輻腸付吉滲瑞驚頓擠秒懸姆爛森糖圣凹陶詞遲蠶億矩";
$imgWidth = 140;
$imgHeight = 40;
$authimg = imagecreate($imgWidth,$imgHeight);
$bgColor = ImageColorAllocate($authimg,255,255,255);
$fontfile = "heiti.ttf";
$white=imagecolorallocate($authimg,234,185,95);
imagearc($authimg, 150, 8, 20, 20, 75, 170, $white);
imagearc($authimg, 180, 7,50, 30, 75, 175, $white);
imageline($authimg,20,20,180,30,$white);
imageline($authimg,20,18,170,50,$white);
imageline($authimg,25,50,80,50,$white);
$noise_num = 800;
$line_num = 20;
imagecolorallocate($authimg,0xff,0xff,0xff);
$rectangle_color=imagecolorallocate($authimg,0xAA,0xAA,0xAA);
$noise_color=imagecolorallocate($authimg,0x00,0x00,0x00);
$font_color=imagecolorallocate($authimg,0x00,0x00,0x00);
$line_color=imagecolorallocate($authimg,0x00,0x00,0x00);
for($i=0;$iimagesetpixel($authimg,mt_rand(0,$imgWidth),mt_rand(0,$imgHeight),$noise_color);
}
for($i=0;$iimageline($authimg,mt_rand(0,$imgWidth),mt_rand(0,$imgHeight),mt_rand(0,$imgWidth),mt_rand(0,$imgHeight),$line_color);
}
$randnum=rand(0,strlen($str)-4);
if($randnum%2)$randnum+=1;
$str = substr($str,$randnum,8);?
$str = iconv("GB2312","UTF-8",$str);
ImageTTFText($authimg, 20, 0, 16, 30, $font_color, $fontfile, $str);
ImagePNG($authimg);
ImageDestroy($authimg);
?>

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Why We Comment: A PHP Guide Why We Comment: A PHP Guide Jul 15, 2025 am 02:48 AM

PHPhasthreecommentstyles://,#forsingle-lineand/.../formulti-line.Usecommentstoexplainwhycodeexists,notwhatitdoes.MarkTODO/FIXMEitemsanddisablecodetemporarilyduringdebugging.Avoidover-commentingsimplelogic.Writeconcise,grammaticallycorrectcommentsandu

How to Install PHP on Windows How to Install PHP on Windows Jul 15, 2025 am 02:46 AM

The key steps to install PHP on Windows include: 1. Download the appropriate PHP version and decompress it. It is recommended to use ThreadSafe version with Apache or NonThreadSafe version with Nginx; 2. Configure the php.ini file and rename php.ini-development or php.ini-production to php.ini; 3. Add the PHP path to the system environment variable Path for command line use; 4. Test whether PHP is installed successfully, execute php-v through the command line and run the built-in server to test the parsing capabilities; 5. If you use Apache, you need to configure P in httpd.conf

PHP Syntax: The Basics PHP Syntax: The Basics Jul 15, 2025 am 02:46 AM

The basic syntax of PHP includes four key points: 1. The PHP tag must be ended, and the use of complete tags is recommended; 2. Echo and print are commonly used for output content, among which echo supports multiple parameters and is more efficient; 3. The annotation methods include //, # and //, to improve code readability; 4. Each statement must end with a semicolon, and spaces and line breaks do not affect execution but affect readability. Mastering these basic rules can help write clear and stable PHP code.

python if else example python if else example Jul 15, 2025 am 02:55 AM

The key to writing Python's ifelse statements is to understand the logical structure and details. 1. The infrastructure is to execute a piece of code if conditions are established, otherwise the else part is executed, else is optional; 2. Multi-condition judgment is implemented with elif, and it is executed sequentially and stopped once it is met; 3. Nested if is used for further subdivision judgment, it is recommended not to exceed two layers; 4. A ternary expression can be used to replace simple ifelse in a simple scenario. Only by paying attention to indentation, conditional order and logical integrity can we write clear and stable judgment codes.

PHP 8 Installation Guide PHP 8 Installation Guide Jul 16, 2025 am 03:41 AM

The steps to install PHP8 on Ubuntu are: 1. Update the software package list; 2. Install PHP8 and basic components; 3. Check the version to confirm that the installation is successful; 4. Install additional modules as needed. Windows users can download and decompress the ZIP package, then modify the configuration file, enable extensions, and add the path to environment variables. macOS users recommend using Homebrew to install, and perform steps such as adding tap, installing PHP8, setting the default version and verifying the version. Although the installation methods are different under different systems, the process is clear, so you can choose the right method according to the purpose.

Your First PHP Script: A Practical Introduction Your First PHP Script: A Practical Introduction Jul 16, 2025 am 03:42 AM

How to start writing your first PHP script? First, set up the local development environment, install XAMPP/MAMP/LAMP, and use a text editor to understand the server's running principle. Secondly, create a file called hello.php, enter the basic code and run the test. Third, learn to use PHP and HTML to achieve dynamic content output. Finally, pay attention to common errors such as missing semicolons, citation issues, and file extension errors, and enable error reports for debugging.

What is PHP and What is it Used For? What is PHP and What is it Used For? Jul 16, 2025 am 03:45 AM

PHPisaserver-sidescriptinglanguageusedforwebdevelopment,especiallyfordynamicwebsitesandCMSplatformslikeWordPress.Itrunsontheserver,processesdata,interactswithdatabases,andsendsHTMLtobrowsers.Commonusesincludeuserauthentication,e-commerceplatforms,for

how to handle undefined index in PHP how to handle undefined index in PHP Jul 15, 2025 am 02:08 AM

The "undefinedindex" error occurs because a key that does not exist in the array is accessed. Solutions include: 1. Use isset() to check whether the key exists, which is suitable for processing user input; 2. Use array_key_exists() to determine whether the key is set, and it can be recognized even if the value is null; 3. Use the empty merge operator?? to set the default value to avoid directly accessing undefined keys; in addition, you need to pay attention to common problems such as the spelling of form field names, the database result is empty, the array unpacking is not verified, the child keys are not checked in foreach, and the session_start() is not called.

See all articles