<?php

/**
 * This file is part of JohnCMS Content Management System.
 *
 * @copyright JohnCMS Community
 * @license   https://opensource.org/licenses/GPL-3.0 GPL-3.0
 * @link      https://johncms.com JohnCMS Project
 */

/**
 * @var $title
 * @var $page_title
 * @var $data
 */

$this->layout(
    'system::layout/default',
    [
        'title'      => $title,
        'page_title' => $title,
    ]
);
$this->sectionReplace('sidebar-menu', $this->fetch('admin::sidebar-admin-menu', ['sec_menu' => ['ipban' => true]]));
?>

<?php if (! empty($data['success_message'])): ?>
    <?= $this->fetch(
        'system::app/alert',
        [
            'alert_type' => 'alert-success',
            'alert'      => $data['success_message'],
        ]
    ) ?>
<?php endif; ?>
<form action="<?= $data['form_action'] ?>" method="post">
    <div class="form-group">
        <label for="ip"><?= __('IP address') ?></label>
        <input type="text" name="ip" class="form-control" id="ip" placeholder="<?= __('IP address') ?>">
    </div>

    <h3><?= __('Ban type') ?></h3>
    <div class="custom-control custom-radio">
        <input type="radio" id="term1" name="term" value="1" class="custom-control-input" checked="checked">
        <label class="custom-control-label" for="term1"><?= __('Block') ?></label>
    </div>
    <div class="custom-control custom-radio">
        <input type="radio" id="term3" name="term" value="3" class="custom-control-input">
        <label class="custom-control-label" for="term3"><?= __('Registration') ?></label>
    </div>
    <div class="custom-control custom-radio">
        <input type="radio" id="term2" name="term" value="2" class="custom-control-input">
        <label class="custom-control-label" for="term2"><?= __('Redirect') ?></label>
    </div>

    <div class="form-group mt-2">
        <label for="url"><?= __('Redirect URL') ?></label>
        <input type="text" name="url" class="form-control" id="url" placeholder="<?= __('Redirect URL') ?>">
        <div class="small text-muted"><?= __('If the ban on Redirect, then specify the URL') ?></div>
    </div>

    <div class="form-group">
        <label for="reason"><?= __('Reason') ?></label>
        <textarea class="form-control" rows="<?= $user->config->fieldHeight ?>" name="reason" id="reason"></textarea>
    </div>

    <div class="alert alert-info">
        <b><?= __('Example:') ?></b><br>
        <div><span class="font-weight-bold">10.5.7.1</span> &mdash; <?= __('Ban one address') ?></div>
        <div><span class="font-weight-bold">10.5.7.1-10.5.7.100</span> &mdash; <?= __('Ban range of address') ?></div>
        <div><span class="font-weight-bold">10.5.*.*</span> &mdash; <?= __('Ban on a mask. There will banned from the entrie subnet, begining with address 0 and ending with 255') ?></div>
    </div>

    <div class="mt-3">
        <input type="submit" name="submit" value="<?= __('Save') ?>" class="btn btn-primary"/>
        <a href="/admin/ipban/" class="btn btn-secondary"><?= __('Cancel') ?></a>
    </div>
</form>
