{*
 * KPI Skimmer Cron - Admin configure template
 * File: /modules/kpiskimmercron/views/templates/admin/configure.tpl
 * Compatible: PS 1.7 / 8.x (Bootstrap)
 *}

<div class="panel">
  <h3><i class="icon icon-shield"></i> {l s='Security monitor – Skimmer checker' mod='kpiskimmercron'}</h3>

  <p>
    {l s='This module checks the active theme head.tpl for known digital skimmer patterns and sends an email alert if detected.' mod='kpiskimmercron'}
  </p>

  <hr>

  <h4>{l s='Cron URL' mod='kpiskimmercron'}</h4>
  <p class="help-block">
    {l s='Call this URL from your server cron (GET). Keep the token secret.' mod='kpiskimmercron'}
  </p>

  <div class="alert alert-info" style="word-break: break-all;">
    <code>{$cron_url|escape:'html':'UTF-8'}</code>
  </div>

  <p class="help-block">
    {l s='Recommended schedule: hourly. The module includes a cooldown to avoid sending repeated alerts while the infection persists.' mod='kpiskimmercron'}
  </p>
</div>

<form method="post" action="{$current_index|escape:'html':'UTF-8'}&configure={$module_name|escape:'html':'UTF-8'}&token={$admin_token|escape:'html':'UTF-8'}" class="defaultForm form-horizontal">
  <div class="panel">
    <h3><i class="icon icon-cogs"></i> {l s='Alert settings' mod='kpiskimmercron'}</h3>

    <div class="form-group">
      <label class="control-label col-lg-3">
        {l s='Alert email' mod='kpiskimmercron'}
      </label>
      <div class="col-lg-9">
        <input type="email"
               name="KPISKIMMER_EMAIL"
               value="{$kpiskimmer_email|escape:'html':'UTF-8'}"
               class="form-control"
               required>
        <p class="help-block">
          {l s='Email address that will receive the alert if a skimmer pattern is detected.' mod='kpiskimmercron'}
        </p>
      </div>
    </div>

    <div class="form-group">
      <label class="control-label col-lg-3">
        {l s='Cooldown (minutes)' mod='kpiskimmercron'}
      </label>
      <div class="col-lg-9">
        <input type="number"
               name="KPISKIMMER_COOLDOWN_MIN"
               value="{$kpiskimmer_cooldown_min|intval}"
               class="form-control"
               min="0"
               step="1">
        <p class="help-block">
          {l s='Minimum time between two alert emails (prevents spam if the malware remains in place). Set 0 to disable.' mod='kpiskimmercron'}
        </p>
      </div>
    </div>

    <div class="panel-footer">
      <button type="submit" name="submitKpiSkimmerCron" class="btn btn-default pull-right">
        <i class="process-icon-save"></i> {l s='Save' mod='kpiskimmercron'}
      </button>
    </div>
  </div>
</form>

<form method="post" action="{$current_index|escape:'html':'UTF-8'}&configure={$module_name|escape:'html':'UTF-8'}&token={$admin_token|escape:'html':'UTF-8'}" class="defaultForm form-horizontal">
  <div class="panel">
    <h3><i class="icon icon-flask"></i> {l s='Manual test' mod='kpiskimmercron'}</h3>

    <p class="help-block">
      {l s='Run a scan immediately (this can force an alert depending on your module logic).' mod='kpiskimmercron'}
    </p>

    <div class="panel-footer">
      <button type="submit" name="submitKpiSkimmerTest" class="btn btn-default">
        <i class="process-icon-refresh"></i> {l s='Run scan now' mod='kpiskimmercron'}
      </button>
    </div>
  </div>
</form>

{if isset($last_result) && $last_result}
  <div class="panel">
    <h3><i class="icon icon-info"></i> {l s='Last result' mod='kpiskimmercron'}</h3>

    {if $last_result.ok}
      <div class="alert alert-success">
        <strong>OK</strong> {$last_result.message|escape:'html':'UTF-8'}
      </div>
    {else}
      <div class="alert alert-danger">
        <strong>ERROR</strong> {$last_result.message|escape:'html':'UTF-8'}
      </div>
    {/if}
  </div>
{/if}

<div class="panel">
  <h3><i class="icon icon-warning-sign"></i> {l s='Security note' mod='kpiskimmercron'}</h3>
  <p>
    {l s='This check is pattern-based and may not detect heavily obfuscated variants. Use it as an early warning and perform a full security audit if an alert is triggered.' mod='kpiskimmercron'}
  </p>
</div>
