myMVC_module_Captcha
1.0.0
Dieses MYMVC -Modul bietet ein Captcha -Bild, das Sie in Ihren eigenen HTML -Formularen verwenden können.
anadalemo.ttf ) in den Stammordner dieses Modulsfont.ttf um CD in den Modulordner Ihrer myMVC3.2.x -Kopie; z.B:
cd /var/www/myMVC/modules/ ; Klon myMVC_module_Captcha AS Captcha
git clone --branch 1.0.x https://github.com/gueff/myMVC_module_Captcha.git Captcha ; 1. Fügen Sie die folgende Route zu Ihrem primären Arbeitsmodul hinzu
// captcha route
MVC Route:: GET (
Captcha Model Index:: $ sRoute ,
' CaptchaControllerIndex::index '
);2. Fügen Sie Captcha -Check und Erstellung in den Controller Ihres primären Arbeitsmoduls hinzu
// check if captcha is valid
if ( true === Captcha Model Index:: captchaIsValid ())
{
// captcha is OK!
}
// create captcha for new
$ sCaptchaText = Captcha Model Index:: createCaptcha ();3. Fügen Sie diese Captcha -Formular zu Ihrer Frontend -Vorlage hinzu
< 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 > ? Hinweis: Stellen Sie sicher, dass Ihre Route POST -Methode ermöglicht
Ermöglichen Sie POST -Methode in Routen, die Sie von Captcha verwenden möchten.
MVCRoute::MIX(
['GET', 'POST'],
'/',
'FooControllerIndex::index',
$oDTRoutingAdditional->getPropertyJson()
);
Ändern Sie in der Umgebungs -Konfigurationsdatei Ihres Primärmoduls einfach die Eigenschaften der Captcha -Modellklasse.
Hier ist ein Beispiel
//-------------------------------------------------------------------------------------
// 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 ;