{% extends request.ajax ? "layout_blank.html.twig" : "layout_default.html.twig" %}

{% import "macro_functions.html.twig" as mf %}

{% block meta_title %}{{ 'SpamChecker settings'|trans }}{% endblock %}

{% set active_menu = 'system' %}

{% block breadcrumbs %}
    <ul class="breadcrumb">
        <li class="breadcrumb-item">
            <a href="{{ '/'|alink }}">
                <svg class="icon">
                    <use xlink:href="#home"/>
                </svg>
            </a>
        </li>
        <li class="breadcrumb-item">
            <a href="{{ 'system'|alink }}">{{ 'Settings'|trans }}</a>
        </li>
        <li class="breadcrumb-item active" aria-current="page">{{ 'SpamChecker settings'|trans }}</li>
    </ul>
{% endblock %}

{% block content %}
    <div class="card">
        <div class="card-header">
            <h3 class="card-title">{{ 'SpamChecker settings'|trans }}</h3>
        </div>

        {% set params = admin.extension_config_get({ "ext": "mod_spamchecker" }) %}
        <form method="post" action="{{ 'api/admin/extension/config_save'|link }}" class="api-form"
              data-api-msg="{{ 'Configuration updated'|trans }}">
            <div class="card-body">
                <input type="hidden" name="CSRFToken" value="{{ CSRFToken }}">
                <input type="hidden" name="ext" value="mod_spamchecker">
                <div class="row">
                    <label class="col-md-3 col-form-label" for="block_ips_check">{{ 'Enable IP blocking'|trans }}</label>
                    <div class="row col-md-6 pt-2 ps-0">
                        <label class="form-check form-check-single form-switch ps-0 mb-2">
                            <input id="block_ips_check" class="form-check-input" name="block_ips" type="checkbox"
                                   {% if params.block_ips %}checked="checked"{% endif %}">
                        </label>
                        <div class="col ps-0">
                            <small class="form-hint">{{ 'Blocked IPs are not allowed to login, register or open public ticket. (One IP per line)'|trans }}</small>
                            <textarea id="block_ips" class="form-control" name="blocked_ips" rows="5" placeholder="127.0.0.1">{{ params.blocked_ips }}</textarea>
                            <label class="hidden" for="block_ips">Blocked IP list</label>
                        </div>
                    </div>
                </div>
            </div>

            <div class="card-body">
                <h3 class="card-title">{{ 'reCAPTCHA settings'|trans }}</h3>
                <p class="card-subtitle">
                    {{ 'Enable captcha for client registration and contact forms'|trans }}<br>
                    {{ 'Sign up for reCAPTCHA key for your domain at'|trans }}
                    <a href="https://www.google.com/recaptcha/about/" target="_blank">Google reCAPTCHA</a>
                </p>
                <div class="mb-3 row">
                    <label class="col-md-3 col-form-label" for="captcha_enabled">{{ 'Enable reCAPTCHA'|trans }}</label>
                    <div class="col-md-6 pt-2 ps-0">
                        <label class="form-check form-check-single form-switch ps-0">
                            <input id="captcha_enabled" class="form-check-input" name="captcha_enabled" type="checkbox"
                                   {% if params.captcha_enabled %}checked="checked"{% endif %}">
                        </label>
                    </div>
                </div>
                <div class="mb-3 row">
                    <label class="col-md-3 col-form-label">{{ 'reCAPTCHA version'|trans }}</label>
                    <div class="col-md-6 pt-2 ps-0">
                        <label class="form-check form-check-inline">
                            <input class="form-check-input" type="radio" name="captcha_version" value="2"
                                   {% if params.captcha_version == "2" %}checked="checked"{% endif %}>
                            <span class="form-check-label">{{ 'v2'|trans }}</span>
                        </label>
{#                        <label class="form-check form-check-inline">#}
{#                            <input class="form-check-input" type="radio" value="3" disabled#}
{#                                   {% if params.captcha_version == "3" %}checked="checked"{% endif %}>#}
{#                            <span class="form-check-label">{{ 'v3'|trans }}</span>#}
{#                        </label>#}
                    </div>
                </div>
                <div class="mb-3 row">
                    <label class="col-md-3 col-form-label" for="captcha_recaptcha_publickey">{{ 'reCAPTCHA Public key'|trans }}</label>
                    <div class="col-md-6 row">
                        <input class="form-control" type="text" id="captcha_recaptcha_publickey" name="captcha_recaptcha_publickey"
                               value="{{ params.captcha_recaptcha_publickey }}">
                    </div>
                </div>
                <div class="mb-3 row">
                    <label class="col-md-3 col-form-label" for="captcha_recaptcha_privatekey">{{ 'reCAPTCHA Secret key'|trans }}</label>
                    <div class="col-md-6 pt-2 row">
                        <input class="form-control" type="text" id="captcha_recaptcha_privatekey" name="captcha_recaptcha_privatekey"
                               value="{{ params.captcha_recaptcha_privatekey }}">
                    </div>
                </div>
            </div>

            <div class="card-body">
                <h3 class="card-title">{{ 'Stop Forum Spam settings'|trans }}</h3>
                <p class="card-subtitle">{{ 'If enabled, client IP will be checked on the <a href="https://stopforumspam.com/" target="_blank">Stop Forum Spam</a> database before registration'|trans|raw }}</p>
                <div class="mb-3 row">
                    <label class="col-md-3 col-form-label" for="sfs">{{ 'Enable Stop Forum Spam'|trans }}</label>
                    <div class="col-md-6 pt-2 ps-0">
                        <label class="form-check form-check-single form-switch ps-0">
                            <input id="sfs" class="form-check-input" name="sfs" type="checkbox"
                                   {% if params.sfs %}checked="checked"{% endif %}">
                        </label>
                    </div>
                </div>
            </div>

            <div class="card-body">
                <h3 class="card-title">{{ 'Temporary / disposable email protection'|trans }}</h3>
                <p class="card-subtitle">{{ 'If enabled, email addresses will be checked against a database of disposable email domains.'|trans }}</p>
                <p class="card-subtitle">{{ 'This database is updated daily and provided free of charge by the FakeFilter project under the BSD 3-Clause License.'|trans }}</p>
                <div class="mb-3 row">
                    <label class="col-md-3 col-form-label" for="check_temp_emails">{{ 'Check for temporary / disposable email addresses.'|trans }}</label>
                    <div class="col-md-6 pt-2 ps-0">
                        <label class="form-check form-check-single form-switch ps-0">
                            <input id="check_temp_emails" class="form-check-input" name="check_temp_emails" type="checkbox"
                                   {% if params.check_temp_emails %} checked="checked" {% endif %}">
                        </label>
                    </div>
                </div>
            </div>

            <div class="card-footer text-end">
                <button type="submit" class="btn btn-primary">{{ 'Update'|trans }}</button>
            </div>
        </form>
    </div>
{% endblock %}
