config.php: rework captcha configuration

This commit is contained in:
Zankaria
2024-08-15 16:11:28 +02:00
parent a275d04efa
commit fb92e5fb68
6 changed files with 72 additions and 69 deletions

View File

@@ -20,7 +20,7 @@
<script type="text/javascript" src="/js/mod/mod_snippets.js"></script>
{% endif %}
{% endif %}
{% if config.recaptcha %}<script src="//www.recaptcha.net/recaptcha/api.js"></script>
{% if config.captcha.provider == 'recaptcha' %}<script src="//www.recaptcha.net/recaptcha/api.js"></script>
<style type="text/css">{% verbatim %}
#recaptcha_area {
float: none !important;
@@ -50,6 +50,6 @@
padding: 0 !important;
}
{% endverbatim %}</style>{% endif %}
{% if config.hcaptcha %}
{% if config.captcha.provider.hcaptcha %}
<script src="https://js.hcaptcha.com/1/api.js" async defer></script>
{% endif %}

View File

@@ -223,15 +223,15 @@ function getCookie(cookie_name) {
}
{% endraw %}
{% if config.dynamic_captcha %}
{% if config.captcha.dynamic %}
function is_dynamic_captcha_enabled() {
let cookie = get_cookie('require-captcha');
return cookie === '1';
}
function get_captcha_pub_key() {
{% if config.recaptcha %}
return "{{ config.recaptcha_public }}";
{% if config.captcha.provider === 'recaptcha' %}
return "{{ config.captcha.recaptcha.sitekey }}";
{% else %}
return null;
{% endif %}

View File

@@ -72,8 +72,8 @@
{% endif %}
</td>
</tr>
{% if config.recaptcha %}
{% if config.dynamic_captcha %}
{% if config.captcha.provider == 'recaptcha' %}
{% if config.captcha.dynamic %}
<tr id="captcha" style="display: none;">
{% else %}
<tr>
@@ -83,19 +83,19 @@
{{ antibot.html() }}
</th>
<td>
<div class="g-recaptcha" data-sitekey="{{ config.recaptcha_public }}"></div>
<div class="g-recaptcha" data-sitekey="{{ config.captcha.recaptcha.sitekey }}"></div>
{{ antibot.html() }}
</td>
</tr>
{% endif %}
{% if config.hcaptcha %}
{% if config.captcha.provider == 'hcaptcha' %}
<tr>
<th>
{% trans %}Verification{% endtrans %}
{{ antibot.html() }}
</th>
<td>
<div class="h-captcha" data-sitekey="{{ config.hcaptcha_public }}"></div>
<div class="h-captcha" data-sitekey="{{ config.captcha.hcaptcha.sitekey }}"></div>
{{ antibot.html() }}
</td>
</tr>
@@ -106,11 +106,11 @@
{% trans %}Verification{% endtrans %}
</th>
<td>
<script>load_captcha("{{ config.captcha.provider_get }}", "{{ config.captcha.extra }}");</script>
<script>load_captcha("{{ config.captcha.secureimage.provider_get }}", "{{ config.secureimage.captcha.extra }}");</script>
<noscript>
<input class='captcha_text' type='text' name='captcha_text' size='32' maxlength='6' autocomplete='off'>
<div class="captcha_html">
<img src="/{{ config.captcha.provider_get }}?mode=get&raw=1">
<img src="/{{ config.captcha.secureimage.provider_get }}?mode=get&raw=1">
</div>
</noscript>
</td>
@@ -122,11 +122,11 @@
{% trans %}Verification{% endtrans %}
</th>
<td>
<script>load_captcha("{{ config.captcha.provider_get }}", "{{ config.captcha.extra }}");</script>
<script>load_captcha("{{ config.captcha.secureimage.provider_get }}", "{{ config.captcha.secureimage.extra }}");</script>
<noscript>
<input class='captcha_text' type='text' name='captcha_text' size='32' maxlength='6' autocomplete='off'>
<div class="captcha_html">
<img src="/{{ config.captcha.provider_get }}?mode=get&raw=1">
<img src="/{{ config.captcha.secureimage.provider_get }}?mode=get&raw=1">
</div>
</noscript>
</td>