12306 인증 코드는 중국어 영숫자, 사용자 정의 글꼴을 지원합니다. PHP 인증 코드 코드
코드 복사 코드는 다음과 같습니다.
/*
* PHP GD Lib의 보안 문자 클래스 기반
* @author Design
* @version 1.0
* @demo
* include('captchaClass.php');
* $captchaDemo=new Captcha();
* $captchaDemo->createImage()
*/
class Captcha{
// @인증 코드 이미지 높이 정의
private $height;
//@인증 코드 이미지 너비 정의
private $width
//@인증 코드 문자 수 정의
private $textNum;
//@인증 코드 문자 내용 정의
private $textContent;
//@문자 색상 정의
private $fontColor;//@임의의 텍스트 색상 정의
private $randFontColor
//@글꼴 크기 정의
private $fontSize;
//@글꼴 정의
private $fontFamily
//@배경 색상 정의
private $bgColor ;
//@임의의 배경색 정의
private $randBgColor;
//@문자 언어 정의
private $textLang;//@간섭 지점 수 정의
private $noisePoint;
//@간섭선 수 정의
private $noiseLine;
//@왜곡 여부 정의
private $distortion
//@왜곡 정의 이미지 소스
private $distortionImage
//@테두리 유무 정의
private $showBorder
//@인증 코드 이미지 소스 정의
private $image; //@생성자 생성자
public function Captcha(){
$this->textNum=4;
$this->f
$this->f//중국어 글꼴 설정 , Linux 디렉토리로 변경 가능
$this->noisePoint=30
$this->noiseLine=3; $this->distortion=false;
$this->showBorder=false;
}
//@이미지 너비 설정
공용 함수 setWidth($w){
$ this->width=$w;
}
//@이미지 높이 설정
public function setHeight($h){
$this->height=$h; }
//@문자 수 설정
public function setTextNumber($textN){
$this->textNum=$textN;
}
//@문자 색상 설정
공용 함수 setFontColor($fc){
$this ->f
}
//@글꼴 크기 설정
공용 함수 setFontSize($n){
$this-> ;f
}
//@글꼴 설정
public function setFontFamily($ffUrl){
$this->f
}
//@문자 언어 설정
공용 함수 setTextLang($lang){
$this-> textLang=$lang;
}
//@이미지 배경 설정
공용 함수 setBgColor($bc){
$this ->bgColor=sscanf($bc,'#%2x%2x %2x')
}
//@노이즈 포인트 수 설정
공개 함수 setNoisePoint($n){
$this->noisePoint=$n;
}
//@간섭선 개수 설정
public function setNoiseLine($n){
$this->noiseLine= $n;
}
//@왜곡 여부 설정
공개 함수 setDistortion($b){
$this->distortion=$b; @테두리 표시 여부 설정
공개 함수 setShowBorder($border){
$this-> ;showBorder=$border
}
//@초기화 확인 코드 이미지
공개 함수 initImage(){
if(empty($this->width)){$this-> width=floor($this->fontSize*1.3)*$this->textNum 10;}
if(empty($this->height)){$this->height=$this-> ;fontSize*2;}
$this->image=imagecreatetruecolor($this->width, $this->height);
if(empty($this->bgColor)){
$this->randBgColor=imagecolorallocate($this->image,mt_rand(100,255),mt_rand( 100,255),mt_rand(100,255));
}else{
$this->randBgColor= imagecolorallocate($this->image,$this->bgColor[0],$this->bgColor [1],$this->bgColor[2]);
}
imagefill($ this->image,0,0,$this->randBgColor)
}
//@임의의 문자 생성
public function randText($type){
$string=''
switch($type){
case 'en':
$str=' ABCDEFGHJKLMNPQRSTUVWXY3456789';
for($i=0;$i<$this->textNum;$i ){
$string=$string.','.$str[mt_rand(0,29)] ;
}
break;
case 'cn':
for($i =0;$i<$this->textNum;$i ) {
$string=$string .','.chr(rand(0xB0,0xCC)).chr(rand(0xA1,0xBB))
}
$string=iconv('GB2312','UTF-8',$string) ; //인코딩을 utf8로 변환
break;
}
return substr($string, 1)
//@인증 코드로 텍스트 출력
){
$textArray=explode(',',$this->randText($this-> ;textLang))
$this->textC
if(empty($this-> ;fontColor)){
$this->randF
}else{
$this ->randF
}
for($i=0;$i<$this-> ;textNum;$i ){
$angle=mt_rand(-1,1)*mt_rand(1, 20)
imagettftext($this->image,$this->fontSize,$angle, 5 $i*floor($this->fontSize*1.3),floor($this->height* 0.75),$this->randFontColor,$this->fontFamily,$textArray[$i]);
}
}
//@간섭점 생성
공용 함수 createNoisePoint() {
for($i=0;$i<$this->noisePoint;$i ){
$pointColor=imagecolorallocate($this->image,mt_rand(0,255),mt_rand(0,255), mt_rand(0,255))
imagesetpixel($this->image,mt_rand(0,$this-) >width),mt_rand(0,$this->height),$pointColor)
}
}
//@간섭선 생성
공용 함수 createNoiseLine(){
for($i=0;$i<$this->noiseLine;$i ) {
$lineColor=imagecolorallocate( $this->image,mt_rand(0,255),mt_rand(0,255),20)
imageline($this->image,0,mt_rand(0,$this->width),$this-> ;width,mt_rand(0,$this->height),$lineColor)
}
}
//@Distorted text
public functionistortionText(){
$this- >distorti
imagefill($this->distortionImage,0,0,$this->randBgColor)
for($x=0;$x<$this->width;$x ) {
for($y=0;$y<$this->height;$y ){
$rgbColor=imagecolorat($this->image,$x,$y)
imagesetpixel($this->distortionImage,(int)($x sin($y/$this->height*2*M_PI-M_PI*0.5)*3),$y,$rgbColor)
}
}
$this->image=$this->distortionImage;
}
//@인증 코드 이미지 생성
public function createImage(){
$this- >initImage(); //기본 이미지 생성
$this->createText(); //인증코드 문자 출력
if($this->distortion){$this->distortionText () ;} //왜곡된 텍스트
$this->createNoisePoint(); //간섭점 생성
$this->createNoiseLine() //간섭선 생성
if($this- > showBorder){imageretangle($this->image,0,0,$this->width-1,$this->height-1,$this->randFontColor);} //테두리 추가
imagepng($this->image);
imagedestroy($this->image)
if($this->distortion){imagedestroy($this->$distortionImage);}
return $this->textContent;
}
}
?>사용법:
//session_start()
header("Content - type:image/png");
include('captcha5_class.php');
$captcha5=new Captcha();
//@인증 코드 너비 설정
//$captcha5 -> ;setWidth(200)
//@인증코드 높이 설정
//$captcha5->setHeight(50)
//@문자수 설정
$captcha5 ->setTextNumber (5);
//@문자 색상 설정
//$captcha5->setFontColor('#ff9900')
//@글꼴 크기 설정
//$ captcha5-> setFontSize(25);
//@글꼴 설정
$captcha5->setFontFamily('c:windowsfontsSTXINGKA.TTF')
//@언어 설정
$captcha5- >setTextLang( 'cn');//@배경색 설정
//$captcha5->setBgColor('#000000')
//@간섭점 개수 설정
//$captcha5- >setNoisePoint(600)
//@간섭선 수 설정
//$captcha5->setNoiseLine(10)
//@설정 여부 설정 distort
//$captcha5-> ;setDistortion(true);
//@테두리 표시 여부 설정
$captcha5->setShowBorder(true)//인증코드 출력
$code=$captcha5->createImage( )
//$_SESSION['captchaCode']['content']=$code
//$_SESSION['captchaCode'][' 시간']=마이크로타임();
?> ;
위 내용은 12306 인증 코드를 소개하고 있으며, 12306 인증 코드의 내용을 포함하여 중국어 영숫자 및 사용자 정의 글꼴을 지원합니다. PHP 튜토리얼에 관심이 있는 친구들에게 도움이 되기를 바랍니다.

핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

AI Hentai Generator
AI Hentai를 무료로 생성하십시오.

인기 기사

뜨거운 도구

메모장++7.3.1
사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

드림위버 CS6
시각적 웹 개발 도구

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)

뜨거운 주제











Laravel은 직관적 인 플래시 방법을 사용하여 임시 세션 데이터 처리를 단순화합니다. 응용 프로그램에 간단한 메시지, 경고 또는 알림을 표시하는 데 적합합니다. 데이터는 기본적으로 후속 요청에만 지속됩니다. $ 요청-

PHP 클라이언트 URL (CURL) 확장자는 개발자를위한 강력한 도구이며 원격 서버 및 REST API와의 원활한 상호 작용을 가능하게합니다. PHP CURL은 존경받는 다중 프로모토콜 파일 전송 라이브러리 인 Libcurl을 활용하여 효율적인 execu를 용이하게합니다.

Laravel은 간결한 HTTP 응답 시뮬레이션 구문을 제공하여 HTTP 상호 작용 테스트를 단순화합니다. 이 접근법은 테스트 시뮬레이션을보다 직관적으로 만들면서 코드 중복성을 크게 줄입니다. 기본 구현은 다양한 응답 유형 단축키를 제공합니다. Illuminate \ support \ Facades \ http를 사용하십시오. http :: 가짜 ([ 'google.com'=> 'Hello World', 'github.com'=> [ 'foo'=> 'bar'], 'forge.laravel.com'=>

Alipay PHP ...

고객의 가장 긴급한 문제에 실시간 인스턴트 솔루션을 제공하고 싶습니까? 라이브 채팅을 통해 고객과 실시간 대화를 나누고 문제를 즉시 해결할 수 있습니다. 그것은 당신이 당신의 관습에 더 빠른 서비스를 제공 할 수 있도록합니다.

기사는 PHP 5.3에 도입 된 PHP의 LSB (Late STATIC BING)에 대해 논의하여 정적 방법의 런타임 해상도가보다 유연한 상속을 요구할 수있게한다. LSB의 실제 응용 프로그램 및 잠재적 성능

이 기사에서는 프레임 워크에 사용자 정의 기능 추가, 아키텍처 이해, 확장 지점 식별 및 통합 및 디버깅을위한 모범 사례에 중점을 둡니다.

PHP 개발에서 PHP의 CURL 라이브러리를 사용하여 JSON 데이터를 보내면 종종 외부 API와 상호 작용해야합니다. 일반적인 방법 중 하나는 컬 라이브러리를 사용하여 게시물을 보내는 것입니다 ...
