contact.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. * Contact page editor: heading, intro text and contact methods shown on the
  4. * public contact.php page.
  5. */
  6. require dirname(__DIR__) . '/app/bootstrap.php';
  7. auth_require();
  8. $site = site_get();
  9. if ($_SERVER['REQUEST_METHOD'] === 'POST') {
  10. csrf_verify();
  11. $site['contact_title'] = trim((string)($_POST['contact_title'] ?? ''));
  12. $site['contact_text'] = trim((string)($_POST['contact_text'] ?? ''));
  13. $site['contact_email'] = trim((string)($_POST['contact_email'] ?? ''));
  14. $site['contact_phone'] = trim((string)($_POST['contact_phone'] ?? ''));
  15. $site['contact_instagram'] = trim((string)($_POST['contact_instagram'] ?? ''));
  16. site_save($site);
  17. flash_set('Contact page saved.');
  18. redirect('contact.php');
  19. }
  20. admin_header('Contact', 'contact');
  21. flash_render();
  22. ?>
  23. <h1>Contact page</h1>
  24. <form method="post" class="card">
  25. <?= csrf_field() ?>
  26. <label for="ct">Heading</label>
  27. <input type="text" id="ct" name="contact_title" value="<?= e($site['contact_title'] ?? '') ?>">
  28. <label for="cx">Intro text</label>
  29. <textarea id="cx" name="contact_text"><?= e($site['contact_text'] ?? '') ?></textarea>
  30. <p class="help">Shown below the heading. Line breaks are kept.</p>
  31. <label for="ce">Email</label>
  32. <input type="text" id="ce" name="contact_email" value="<?= e($site['contact_email'] ?? '') ?>" placeholder="hello@example.com">
  33. <label for="cp">Phone</label>
  34. <input type="text" id="cp" name="contact_phone" value="<?= e($site['contact_phone'] ?? '') ?>" placeholder="+49 30 1234567">
  35. <label for="ci">Instagram</label>
  36. <input type="text" id="ci" name="contact_instagram" value="<?= e($site['contact_instagram'] ?? '') ?>" placeholder="@handle or full URL">
  37. <p class="help">Leave a field empty to hide it on the contact page.</p>
  38. <button type="submit">Save</button>
  39. <a class="btn btn-ghost" href="../contact.php" target="_blank" rel="noopener" style="margin-left:.6rem">View page ↗</a>
  40. </form>
  41. <?php admin_footer(); ?>