implement alternative image generator

This commit is contained in:
Daniel Seifert 2024-11-05 08:31:25 +01:00
parent 0607bbaa7c
commit 3010a4252d
16 changed files with 23 additions and 2 deletions

View File

@ -9,7 +9,7 @@
<div class="input-group"> <div class="input-group">
<span class="input-group-addon"> <span class="input-group-addon">
[{if $oCaptcha->isImageVisible()}] [{if $oCaptcha->isImageVisible()}]
<img src="[{$oCaptcha->getImageUrl()}]" alt=""> <img src="[{$oCaptcha->getBase64Image()}]" alt="">
[{else}] [{else}]
<span class="verificationCode" id="verifyTextCode">[{$oCaptcha->getText()}]</span> <span class="verificationCode" id="verifyTextCode">[{$oCaptcha->getText()}]</span>
[{/if}] [{/if}]

View File

@ -9,7 +9,7 @@
<div class="input-group"> <div class="input-group">
<span class="input-group-addon" style="padding-right:15px"> <span class="input-group-addon" style="padding-right:15px">
[{if $oCaptcha->isImageVisible()}] [{if $oCaptcha->isImageVisible()}]
<img src="[{$oCaptcha->getImageUrl()}]" alt=""> <img src="[{$oCaptcha->getBase64Image()}]" alt="">
[{else}] [{else}]
<span class="verificationCode" id="verifyTextCode">[{$oCaptcha->getText()}]</span> <span class="verificationCode" id="verifyTextCode">[{$oCaptcha->getText()}]</span>
[{/if}] [{/if}]

View File

@ -12,5 +12,8 @@
"oxideshop": { "oxideshop": {
"target-directory": "oe/captcha" "target-directory": "oe/captcha"
} }
},
"require": {
"mobicms/captcha": "^4.0"
} }
} }

View File

@ -4,6 +4,8 @@
*/ */
use OxidEsales\Eshop\Core\DatabaseProvider; use OxidEsales\Eshop\Core\DatabaseProvider;
use Mobicms\Captcha\Image;
use Mobicms\Captcha\ImageOptions;
/** /**
* Class handling CAPTCHA image * Class handling CAPTCHA image
@ -124,6 +126,20 @@ class oeCaptcha extends oxSuperCfg
return $url; return $url;
} }
public function getBase64Image()
{
$fontsPath = __DIR__ . '/../fonts';
$img = new Image($this->getText(), (new ImageOptions())->setFontsFolder($fontsPath)->setHeight(45)
->setWidth(160)
->adjustFont('baby_blocks.ttf', 13)
->adjustFont('ball.ttf', 20)
->adjustFont('chintzy.ttf', 18)
->adjustFont('platinumhubcapsspoked.ttf', 20)
->adjustFont('subway.ttf', 20)
);
return (string) $img;
}
/** /**
* Checks if image could be generated * Checks if image could be generated
* *

BIN
fonts/baby_blocks.ttf Normal file

Binary file not shown.

2
fonts/baby_blocks.txt Normal file
View File

@ -0,0 +1,2 @@
Developer: Ryan D. Neaveill
License: Unknown

BIN
fonts/ball.ttf Normal file

Binary file not shown.

BIN
fonts/betsy_flanagan.ttf Normal file

Binary file not shown.

BIN
fonts/bloktilt.ttf Normal file

Binary file not shown.

BIN
fonts/cangoods.ttf Normal file

Binary file not shown.

BIN
fonts/chintzy.ttf Normal file

Binary file not shown.

BIN
fonts/elevator_buttons.ttf Normal file

Binary file not shown.

BIN
fonts/karmaticarcade.ttf Normal file

Binary file not shown.

Binary file not shown.

BIN
fonts/subway.ttf Normal file

Binary file not shown.

BIN
fonts/tonight.ttf Normal file

Binary file not shown.