CAPTCHA for journal subscription
This commit is contained in:
parent
754f42d2a6
commit
52065707df
2 changed files with 46 additions and 0 deletions
24
altcha_asset.php
Normal file
24
altcha_asset.php
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
<?php
|
||||||
|
$url = 'http://127.0.0.1:9000/public/static/altcha.umd.js';
|
||||||
|
$context = stream_context_create([
|
||||||
|
'http' => [
|
||||||
|
'method' => 'GET',
|
||||||
|
'timeout' => 6,
|
||||||
|
'ignore_errors' => true,
|
||||||
|
'header' => "User-Agent: MVLog-contact/1.0\r\n",
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
$response = @file_get_contents($url, false, $context);
|
||||||
|
$status = 0;
|
||||||
|
if (isset($http_response_header[0]) && preg_match('/\s(\d{3})\s/', $http_response_header[0], $m)) {
|
||||||
|
$status = (int)$m[1];
|
||||||
|
}
|
||||||
|
if ($response === false || $status !== 200) {
|
||||||
|
http_response_code(502);
|
||||||
|
header('Content-Type: text/plain; charset=utf-8');
|
||||||
|
echo 'ALTCHA asset unavailable';
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
header('Content-Type: application/javascript; charset=utf-8');
|
||||||
|
header('Cache-Control: public, max-age=86400');
|
||||||
|
echo $response;
|
||||||
22
altcha_challenge.php
Normal file
22
altcha_challenge.php
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
<?php
|
||||||
|
header('Content-Type: application/json; charset=utf-8');
|
||||||
|
$url = 'http://127.0.0.1:9000/api/public/captcha/altcha';
|
||||||
|
$context = stream_context_create([
|
||||||
|
'http' => [
|
||||||
|
'method' => 'GET',
|
||||||
|
'timeout' => 6,
|
||||||
|
'ignore_errors' => true,
|
||||||
|
'header' => "User-Agent: MVLog-contact/1.0\r\n",
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
$response = @file_get_contents($url, false, $context);
|
||||||
|
$status = 0;
|
||||||
|
if (isset($http_response_header[0]) && preg_match('/\s(\d{3})\s/', $http_response_header[0], $m)) {
|
||||||
|
$status = (int)$m[1];
|
||||||
|
}
|
||||||
|
if ($response === false || $status !== 200) {
|
||||||
|
http_response_code(502);
|
||||||
|
echo json_encode(['error' => 'Captcha challenge unavailable']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
echo $response;
|
||||||
Loading…
Add table
Add a link
Reference in a new issue