Lettersail: online English school for kids on MODX 3 (templates, chunks, snippets, plugins, scripts)
This commit is contained in:
commit
3799cf8de5
96 files changed
+4423
No files matched your search
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
require_once '/var/www/html/elements/lib/altcha/autoload.php';
|
||||
|
||||
use AltchaOrg\Altcha\Algorithm\Pbkdf2;
|
||||
use AltchaOrg\Altcha\Altcha;
|
||||
use AltchaOrg\Altcha\CreateChallengeOptions;
|
||||
|
||||
$secret = hash_hmac('sha256', 'lettersail-captcha', (string) $modx->getOption('site_id', null, 'lettersail'));
|
||||
$challenge = (new Altcha(hmacSignatureSecret: $secret))->createChallenge(
|
||||
new CreateChallengeOptions(
|
||||
algorithm: new Pbkdf2(),
|
||||
cost: 2000,
|
||||
counter: random_int(1000, 2000),
|
||||
expiresAt: time() + 1200,
|
||||
)
|
||||
)->toArray();
|
||||
|
||||
$stamp = (string) (int) (microtime(true) * 1000);
|
||||
setcookie('ls_t', $stamp . '.' . hash_hmac('sha256', $stamp, $secret), [
|
||||
'expires' => time() + 86400,
|
||||
'path' => '/',
|
||||
'secure' => true,
|
||||
'httponly' => true,
|
||||
'samesite' => 'Lax',
|
||||
]);
|
||||
|
||||
while (ob_get_level()) {
|
||||
ob_end_clean();
|
||||
}
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
header('Cache-Control: no-store');
|
||||
header('X-Robots-Tag: noindex');
|
||||
echo json_encode($challenge, JSON_UNESCAPED_UNICODE);
|
||||
exit;
|
||||
Reference in new issue
Block a user