1<?php
2/**
3 * Title: My New Page
4 * Icon: fa-cube
5 * Group: Other
6 * Order: 100
7 * Description: One line shown under the page title.
8 */
9
10/*
11 * ---------------------------------------------------------------------------
12 * How to add an admin page
13 * ---------------------------------------------------------------------------
14 *
15 * 1. Copy this file to admin/modules/<name>.php (no leading underscore -
16 * files starting with "_" are skipped by the registry).
17 * 2. Edit the docblock above. That IS the menu entry: Title, Icon
18 * (Font Awesome 4.7 class), Group and Order. Nothing else to register.
19 * 3. Write your logic and markup below. Available to you already:
20 *
21 * $config, $user_data, $session_user_id, $version from engine/init.php
22 * h(), intv() escaping helpers
23 * acp_url(), acp_site(), acp_redirect() links and redirects
24 * acp_csrf_field() CSRF token input
25 * acp_flash_success/error/info() messages across redirects
26 * acp_card_open/close(), acp_empty(), acp_stat() layout blocks
27 * db()->fetchOne/fetchAll($sql, $params) prepared SELECT, use ? placeholders
28 * db()->execute($sql, $params) prepared INSERT/UPDATE/DELETE
29 * db()->transaction(function ($db) { ... }) several writes, all or nothing
30 *
31 * Notes:
32 * - The working directory is the project root, so 'engine/cache/x' and
33 * other engine-relative paths work exactly as they do on a normal page.
34 * - Links to the public site need acp_site(): acp_site('index.php').
35 * - Do NOT include init.php, the header or the footer - index.php does that.
36 * - POST requests are CSRF-checked centrally, so every form needs
37 * <?= acp_csrf_field() ?> or it will be rejected with a 400.
38 * - Redirect after a successful POST with acp_redirect('<name>') so a
39 * refresh does not resubmit.
40 * - To give the menu entry a counter bubble, add a function named
41 * acp_badge_<name>() to admin/bootstrap.php returning an int.
42 */
43
44if (!defined('ACP_ROOT')) {
45 http_response_code(403);
46 die('Direct access denied.');
47}
48
49if ($_SERVER['REQUEST_METHOD'] === 'POST') {
50 // ... do the work ...
51 acp_flash_success('Saved.');
52 acp_redirect('_template');
53}
54?>
55
56<section class="acp-card">
57 <header class="acp-card-head">
58 <h2>Example form</h2>
59 <p>Delete everything below and write your own</p>
60 </header>
61 <div class="acp-card-body">
62 <form method="post">
63 <?= acp_csrf_field() ?>
64 <div class="acp-field">
65 <label class="acp-label" for="example">Something</label>
66 <input class="acp-input" id="example" name="example" placeholder="Type here">
67 </div>
68 <div class="acp-actions">
69 <button class="acp-btn" type="submit"><i class="fa fa-check"></i> Save</button>
70 </div>
71 </form>
72 </div>
73</section>
74