admin-portal/tech/tabs/03-third-parties/05_content.html.php
Frederico Falcao f2a6525224 init
2025-05-30 10:46:17 +01:00

114 lines
4.4 KiB
PHP

<?php /*
FILE: 05_content.html.php
Description: the main HTML/PHP content of this tab
*/
?>
<!-- 3rd parties Tab -->
<div class="tab-pane fade" id="third-parties">
<h5 class="mb-3">Password Manager</h5>
<!-- Add Password Form -->
<form method="post" action="?tab=third-parties" class="mb-4">
<div class="row g-2">
<div class="col-md-3"><input class="form-control" name="site" placeholder="Site / Service" required></div>
<div class="col-md-2"><input class="form-control" name="username" placeholder="Username / Email" required></div>
<div class="col-md-2"><input class="form-control" name="password" placeholder="Password" value="<?= htmlspecialchars($_POST['password'] ?? '') ?>" required></div>
<div class="col-md-2"><input class="form-control" name="otp_secret" placeholder="OTP secret (base32)"></div>
<div class="col-md-2"><input class="form-control" name="cc_number" placeholder="Card number"></div>
<div class="col-md-1"><input class="form-control" name="cc_exp" placeholder="MM/YY"></div>
<div class="col-md-1"><input class="form-control" name="ccv" placeholder="CCV"></div>
<div class="col-md-1"><input class="form-control" name="monthly" placeholder="€/mo"></div>
</div>
<div class="mt-2">
<button class="btn btn-secondary" name="generate_password">Generate password</button>
<button class="btn btn-primary" name="add_password">Save entry</button>
</div>
</form>
<!-- Passwords Table -->
<table id="pwTable" class="table table-bordered table-hover">
<thead class="table-light">
<tr>
<th>Site</th>
<th>User</th>
<th>Password</th>
<th>OTP</th>
<th>Card #</th>
<th>Exp</th>
<th>CCV</th>
<th>€/mo</th>
<th></th>
</tr>
</thead>
<tbody>
<?php
$pwList = getPasswordList($passwordFile, $passwordKey);
$itemsPerPage = 8;
foreach ($pwList as $i => $row):
?>
<tr>
<td><?= htmlspecialchars($row['site']) ?></td>
<td><?= htmlspecialchars($row['username']) ?></td>
<!-- password -->
<td class="position-relative">
<div class="input-group input-group-sm">
<input type="password" readonly class="form-control form-control-sm pw-field"
value="<?= htmlspecialchars($row['password']) ?>"
onclick="this.type='text'">
<button type="button" class="btn btn-outline-secondary btn-sm copy-pw-btn" title="Copy to clipboard">
<i class="bi bi-clipboard"></i>
</button>
</div>
</td>
<!-- OTP -->
<td class="text-nowrap">
<?= $row['otp_secret']? currentOtpCode($row['otp_secret']):'' ?>
</td>
<!-- card -->
<td>
<?= htmlspecialchars($row['cc_number']) ?>
</td>
<td><?= htmlspecialchars($row['cc_exp']) ?></td>
<!-- CCV -->
<td>
<?php if ($row['ccv']): ?>
<input type="password" readonly class="form-control form-control-sm"
value="<?= htmlspecialchars($row['ccv']) ?>"
onclick="this.type='text'">
<?php endif; ?>
</td>
<td><?= htmlspecialchars($row['monthly']) ?></td>
<!-- delete -->
<td class="text-center">
<form method="post" onsubmit="return confirm('Delete this entry?')">
<input type="hidden" name="delete_idx" value="<?= $i ?>">
<button class="btn btn-outline-danger "><i class="bi bi-trash"></i></button>
</form>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php
$totalItems = count($pwList);
$totalPages = (int)ceil($totalItems / $itemsPerPage);
if ($totalPages > 1): ?>
<nav aria-label="Password pagination">
<ul class="pagination justify-content-center" id="pwPagination" data-items-per-page="<?= $itemsPerPage ?>">
<?php for ($p = 1; $p <= $totalPages; $p++): ?>
<li class="page-item<?= $p === 1 ? ' active' : '' ?>">
<a class="page-link" href="#" data-page="<?= $p ?>"><?= $p ?></a>
</li>
<?php endfor; ?>
</ul>
</nav>
<?php endif; ?>
</div>