myMVC_module_Captcha
1.0.0
이 MyMVC 모듈은 자신의 HTML 양식으로 사용할 수있는 보안물 이미지를 제공합니다.
anadalemo.ttf )와 같은 실제 유형 글꼴의 라이센스 사본을이 모듈의 루트 폴더에 복사하십시오.font.ttf 로 바꿉니다 myMVC3.2.x 사본의 모듈 폴더에 CD; 예 : :
cd /var/www/myMVC/modules/ ; 클론 myMVC_module_Captcha Captcha 로 복제합니다
git clone --branch 1.0.x https://github.com/gueff/myMVC_module_Captcha.git Captcha ; 1. 기본 작업 모듈에 다음 경로를 추가하십시오.
// captcha route
MVC Route:: GET (
Captcha Model Index:: $ sRoute ,
' CaptchaControllerIndex::index '
);2. 기본 작업 모듈의 컨트롤러에 보안 문자 점검 및 생성 추가
// check if captcha is valid
if ( true === Captcha Model Index:: captchaIsValid ())
{
// captcha is OK!
}
// create captcha for new
$ sCaptchaText = Captcha Model Index:: createCaptcha ();3. 이 보안관 포름을 프론트 엔드 템플릿에 추가하십시오
< form action ="" method =" post " >
<!-- captcha -->
< label for =" captcha " > Captcha </ label >
< img src =" {CaptchaModelIndex::$sRoute} " >
< input type =" text "
name =" {CaptchaModelIndex::$sPostFieldName} "
maxlength =" {CaptchaModelIndex::$iCaptchaTextLength} "
value =""
placeholder =" captcha code "
autofocus
>
<!-- /captcha -->
< button type =" submit " > submit </ button >
</ form > ? 참고 : 경로에서 POST 메소드가 허용되도록하십시오
보안 문자를 사용하려는 경로에서 POST 메소드를 허용하십시오.
MVCRoute::MIX(
['GET', 'POST'],
'/',
'FooControllerIndex::index',
$oDTRoutingAdditional->getPropertyJson()
);
기본 모듈의 환경 구성 파일에서는 CARTCHA 모델 클래스의 속성을 변경합니다.
여기 예입니다
//-------------------------------------------------------------------------------------
// Module Captcha
// load Class
require_once $ aConfig [ ' MVC_MODULES_DIR ' ] . ' /Captcha/Model/Index.php ' ;
// declare a custom route
Captcha Model Index:: $ sRoute = ' /captcha/MyFormularXY/ ' ;
// add some extra chars to choose from...
Captcha Model Index:: $ sChar .= ' _!=)(/&%$[].:,;+*~# ' ;
// ...if you changed the $sChar, do not forget to adjust sanitizing rule
Captcha Model Index:: $ sCharSanitizePattern = " /[^ \ p{L}} \ p{M} \ p{S} \ p{N} \ p{P}']+/u " ;
// auto-name template input var (name="") like Route
Captcha Model Index:: $ sPostFieldName = str_replace ( ' / ' , '' , Captcha Model Index:: $ sRoute );
// set SessionName like $sPostFieldName
Captcha Model Index:: $ sSessionName = Captcha Model Index:: $ sPostFieldName ;