?????????? ????????? - ??????????????? - /home/agenciai/public_html/php_mailer/list-edit.php
???????
<?php require_once 'config.php'; requireLogin(); if (!isset($_GET['id'])) { header('Location: lists.php'); exit; } $listId = $_GET['id']; $lists = getEmailLists(); if (!isset($lists[$listId])) { header('Location: lists.php?error=List+not+found'); exit; } $currentList = $lists[$listId]; $subscribers = $currentList['subscribers'] ?? []; // Handle adding a subscriber if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['new_email'])) { $newEmail = trim(strtolower($_POST['new_email'])); $newName = trim($_POST['new_name'] ?? ''); if (!filter_var($newEmail, FILTER_VALIDATE_EMAIL)) { $error = "Invalid email address."; } else { // Check if email already exists $emailExists = false; foreach ($subscribers as $sub) { if (strtolower($sub['email']) === $newEmail) { $emailExists = true; break; } } if ($emailExists) { $error = "Email already exists in this list."; } else { $subscribers[] = [ 'email' => $newEmail, 'name' => $newName, 'added' => date('Y-m-d H:i:s') ]; $lists[$listId]['subscribers'] = $subscribers; saveEmailLists($lists); header('Location: list-edit.php?id=' . $listId . '&success=Subscriber+added'); exit; } } } // Handle removing a subscriber if (isset($_GET['remove_email'])) { $emailToRemove = $_GET['remove_email']; $newSubscribers = []; foreach ($subscribers as $sub) { if ($sub['email'] !== $emailToRemove) { $newSubscribers[] = $sub; } } $lists[$listId]['subscribers'] = $newSubscribers; saveEmailLists($lists); header('Location: list-edit.php?id=' . $listId . '&success=Subscriber+removed'); exit; } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Manage List: <?= htmlspecialchars($currentList['name']) ?></title> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet"> </head> <body class="bg-light"> <div class="container py-5"> <div class="row justify-content-center"> <div class="col-md-10"> <div class="d-flex justify-content-between align-items-center mb-4"> <h2>Manage List: <?= htmlspecialchars($currentList['name']) ?></h2> <a href="lists.php" class="btn btn-secondary">Back to Lists</a> </div> <!-- Add Subscriber Form --> <div class="card mb-4"> <div class="card-header"> <h5 class="mb-0">Add Subscriber</h5> </div> <div class="card-body"> <form method="POST"> <div class="row"> <div class="col-md-6"> <div class="mb-3"> <label class="form-label">Email Address *</label> <input type="email" class="form-control" name="new_email" required> </div> </div> <div class="col-md-6"> <div class="mb-3"> <label class="form-label">Name (Optional)</label> <input type="text" class="form-control" name="new_name"> </div> </div> </div> <button type="submit" class="btn btn-primary">Add Subscriber</button> </form> </div> </div> <!-- Subscribers List --> <div class="card"> <div class="card-header d-flex justify-content-between align-items-center"> <h5 class="mb-0">Subscribers (<?= count($subscribers) ?>)</h5> </div> <div class="card-body"> <?php if (empty($subscribers)): ?> <p class="text-muted">No subscribers yet. Add your first subscriber above.</p> <?php else: ?> <div class="table-responsive"> <table class="table table-striped"> <thead> <tr> <th>Email</th> <th>Name</th> <th>Added</th> <th>Action</th> </tr> </thead> <tbody> <?php foreach ($subscribers as $sub): ?> <tr> <td><?= htmlspecialchars($sub['email']) ?></td> <td><?= htmlspecialchars($sub['name']) ?></td> <td><?= $sub['added'] ?></td> <td> <a href="list-edit.php?id=<?= $listId ?>&remove_email=<?= urlencode($sub['email']) ?>" class="btn btn-sm btn-outline-danger" onclick="return confirm('Remove this subscriber?')">Remove</a> </td> </tr> <?php endforeach; ?> </tbody> </table> </div> <?php endif; ?> </div> </div> </div> </div> </div> </body> </html>
| ver. 1.6 |
Github
|
.
| PHP 8.2.30 | ??????????? ?????????: 0 |
proxy
|
phpinfo
|
???????????