Added .htaccess rules to deny access to hidden files. Escaped JSON output in views to prevent XSS attacks. Converted delete links and forms to use POST with CSRF tokens. Enforced POST method on sensitive routes. Added tests to verify these security controls.
78 lines
4.2 KiB
PHP
78 lines
4.2 KiB
PHP
<?php
|
|
use Plugi\Extensions\Form\DefinitionsRepository;
|
|
|
|
$formsRepository = new DefinitionsRepository();
|
|
$forms = $formsRepository->getAll();
|
|
|
|
?>
|
|
|
|
<section class="space-y-5">
|
|
<header class="flex flex-col gap-4 sm:flex-row sm:items-end sm:justify-between">
|
|
<div class="space-y-1">
|
|
<p class="text-xs font-semibold uppercase tracking-[0.18em] text-primary">Form extension</p>
|
|
<h2 class="text-xl font-bold tracking-tight text-base-content">Forms</h2>
|
|
<p class="text-sm text-base-content/60"><?= count($forms) ?> form<?= count($forms) !== 1 ? 's' : '' ?> available</p>
|
|
</div>
|
|
<a href="<?= phpb_url('website_manager', ['tab' => 'ext--form', 'action' => 'editForm']) ?>" class="btn btn-primary">
|
|
<i class="ph-duotone ph-plus" aria-hidden="true"></i>
|
|
New form
|
|
</a>
|
|
</header>
|
|
|
|
<?php if (empty($forms)): ?>
|
|
<div class="card border border-dashed border-base-300 bg-base-100 shadow-sm" role="status">
|
|
<div class="card-body items-center gap-3 px-5 py-12 text-center sm:py-16">
|
|
<span class="grid size-14 place-items-center rounded-2xl bg-primary/10 text-primary">
|
|
<i class="text-3xl ph-duotone ph-notebook" aria-hidden="true"></i>
|
|
</span>
|
|
<h3 class="card-title mt-1 text-lg">No forms yet</h3>
|
|
<p class="max-w-md text-sm leading-relaxed text-base-content/60">Create your first form to collect submissions from your website.</p>
|
|
<a href="<?= phpb_url('website_manager', ['tab' => 'ext--form', 'action' => 'editForm']) ?>" class="btn btn-primary mt-2">
|
|
<i class="ph-duotone ph-plus" aria-hidden="true"></i>
|
|
Create your first form
|
|
</a>
|
|
</div>
|
|
</div>
|
|
<?php else: ?>
|
|
<div class="overflow-x-auto rounded-box border border-base-300 bg-base-100">
|
|
<table class="table table-zebra w-full min-w-[36rem]">
|
|
<thead>
|
|
<tr>
|
|
<th class="w-16">ID</th>
|
|
<th><?= phpb_trans('website-manager.name') ?></th>
|
|
<th class="w-40 text-right"><?= phpb_trans('website-manager.actions') ?></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($forms as $form): ?>
|
|
<tr>
|
|
<td><span class="badge badge-ghost font-mono"><?= phpb_e($form['id']) ?></span></td>
|
|
<td>
|
|
<div class="font-medium"><?= phpb_e($form['name']) ?></div>
|
|
</td>
|
|
<td>
|
|
<div class="flex items-center justify-end gap-1">
|
|
<a href="<?= phpb_url('website_manager', ['tab' => 'ext--form', 'action' => 'listEntries', 'id' => $form['id']]) ?>" class="btn btn-ghost btn-square btn-sm" title="View entries" aria-label="View entries for <?= phpb_e($form['name']) ?>">
|
|
<i class="ph-duotone ph-eye text-lg" aria-hidden="true"></i>
|
|
</a>
|
|
<a href="<?= phpb_url('website_manager', ['tab' => 'ext--form', 'action' => 'editForm', 'id' => $form['id']]) ?>" class="btn btn-ghost btn-square btn-sm" title="<?= phpb_trans('website-manager.edit') ?>" aria-label="<?= phpb_trans('website-manager.edit') ?> <?= phpb_e($form['name']) ?>">
|
|
<i class="ph-duotone ph-pencil-line text-lg" aria-hidden="true"></i>
|
|
</a>
|
|
<form action="/ext--form/delete-form" method="post">
|
|
<?php phpb_csrf_field(); ?>
|
|
<input type="hidden" name="id" value="<?= phpb_e((string) $form['id']) ?>">
|
|
<button type="submit" class="btn btn-ghost btn-square btn-sm text-error" title="<?= phpb_trans('website-manager.remove') ?>" aria-label="<?= phpb_trans('website-manager.remove') ?> <?= phpb_e($form['name']) ?>">
|
|
<i class="ph-duotone ph-trash text-lg" aria-hidden="true"></i>
|
|
</button>
|
|
</form>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<?php endif; ?>
|
|
</section>
|
|
|