|
1 | | -# Inquiry Management System |
| 1 | +# Inquiry Management System v0.5.0 |
2 | 2 |
|
3 | | -Version: **v0.4.0** |
| 3 | +A lightweight **pure PHP + MySQL** inquiry hub for collecting form submissions from multiple websites and managing them in one backend. |
4 | 4 |
|
5 | | -A pure PHP + MySQL inquiry management system for collecting inquiry forms from multiple websites into one centralized backend. |
| 5 | +## What is included in v0.5.0 |
6 | 6 |
|
7 | | -## v0.4.0 Highlights |
| 7 | +- Multi-site inquiry receive API |
| 8 | +- Site management with token and signature secret rotation |
| 9 | +- Field mapping JSON per site |
| 10 | +- Inquiry list, detail page, note management and status flow |
| 11 | +- CSV export with selectable export fields |
| 12 | +- Spam rule center |
| 13 | +- Blocked IP management |
| 14 | +- Blocked email / domain management |
| 15 | +- Email notification center |
| 16 | +- Dashboard with 7-day trend, top forms and country summary |
| 17 | +- System logs |
| 18 | +- GitHub Actions ZIP build workflow |
8 | 19 |
|
9 | | -- Added per-site **Field Mapping JSON** so different form field names can map into the system's standard fields |
10 | | -- Added **Admin Note** editing on the inquiry detail page |
11 | | -- Added **Spam Rule Center** in the backend for honeypot, links, duplicates, rate limits, keywords, and disposable email domains |
12 | | -- Added filtering by **Has Note** in inquiry list |
13 | | -- API now stores mapped payload data into `extra_data` when field mapping is applied |
14 | | - |
15 | | -## Environment |
16 | | - |
17 | | -- PHP 8.1+ |
18 | | -- MySQL 5.7+ or MySQL 8+ |
19 | | -- Apache or Nginx |
20 | | - |
21 | | -## Installation |
22 | | - |
23 | | -1. Create a database, for example: `inquiry_system` |
24 | | -2. Import: |
25 | | - - `database/schema.sql` |
26 | | - - `database/seed.sql` |
27 | | -3. Update database settings in `config/database.php` |
28 | | -4. Point your web root to `public/` |
29 | | -5. Open the project in your browser |
30 | | - |
31 | | -## Upgrading from v0.3.0 |
32 | | - |
33 | | -If you already have a v0.3.0 database, run: |
34 | | - |
35 | | -- `database/upgrade-v0.4.0.sql` |
36 | | - |
37 | | -This adds: |
38 | | - |
39 | | -- `field_mapping_json` on `inquiry_sites` |
40 | | -- default `spam_rules` in `system_settings` |
41 | | - |
42 | | -## Default Admin Account |
| 20 | +## Default admin account |
43 | 21 |
|
44 | 22 | - Username: `admin` |
45 | 23 | - Password: `Admin@123456` |
46 | 24 |
|
47 | | -## Main Backend Routes |
48 | | - |
49 | | -- `/login` |
50 | | -- `/dashboard` |
51 | | -- `/inquiries` |
52 | | -- `/inquiries/export` |
53 | | -- `/sites` |
54 | | -- `/sites/edit?id=1` |
55 | | -- `/logs` |
56 | | -- `/tools/blacklist-ips` |
57 | | -- `/tools/spam-rules` |
58 | | -- `/profile` |
| 25 | +## New in this version |
59 | 26 |
|
60 | | -## API Routes |
| 27 | +### 1. Email notifications |
61 | 28 |
|
62 | | -### Health Check |
| 29 | +You can now configure notification delivery from: |
63 | 30 |
|
64 | | -`GET /api/v1/health` |
| 31 | +- `Tools > Email Notifications` |
65 | 32 |
|
66 | | -### Submit Inquiry |
| 33 | +Supported modes: |
67 | 34 |
|
68 | | -`POST /api/v1/inquiries/submit` |
| 35 | +- `log_only`: safe testing mode, writes notification attempts to system logs |
| 36 | +- `mail`: uses native PHP `mail()` |
69 | 37 |
|
70 | | -Supported payload types: |
| 38 | +### 2. Email and domain blacklist |
71 | 39 |
|
72 | | -- `application/json` |
73 | | -- standard form POST |
| 40 | +You can now block: |
74 | 41 |
|
75 | | -### Minimum payload |
| 42 | +- a specific sender email |
| 43 | +- an entire email domain |
76 | 44 |
|
77 | | -```json |
78 | | -{ |
79 | | - "site_key": "a_main", |
80 | | - "api_token": "token_a_main_2026", |
81 | | - "name": "John Smith", |
82 | | - "email": "john@example.com", |
83 | | - "content": "I want more information about your products." |
84 | | -} |
85 | | -``` |
| 45 | +Manage them from: |
86 | 46 |
|
87 | | -### Optional fields |
| 47 | +- `Tools > Blocked Emails` |
88 | 48 |
|
89 | | -- `form_key` |
90 | | -- `title` |
91 | | -- `country` |
92 | | -- `phone` |
93 | | -- `address` |
94 | | -- `from_company` |
95 | | -- `source_url` |
96 | | -- `referer_url` |
97 | | -- `language` |
98 | | -- `browser` |
99 | | -- `device_type` |
100 | | -- `submitted_at` |
101 | | -- `client_ip` |
102 | | -- `extra_data` (array) |
| 49 | +### 3. Better export control |
103 | 50 |
|
104 | | -Unknown fields will also be merged into `extra_data` automatically. |
| 51 | +The inquiry list page now lets you choose which CSV columns should be exported. |
105 | 52 |
|
106 | | -## Field Mapping JSON |
| 53 | +### 4. Dashboard enhancements |
107 | 54 |
|
108 | | -You can configure a site-level JSON mapping in the backend to transform external field names into the system's standard fields before validation and storage. |
| 55 | +The dashboard now shows: |
109 | 56 |
|
110 | | -Example: |
| 57 | +- 7-day inquiry trend |
| 58 | +- top forms |
| 59 | +- top countries |
| 60 | +- current notification configuration summary |
111 | 61 |
|
112 | | -```json |
113 | | -{ |
114 | | - "name": ["fullname", "your_name"], |
115 | | - "email": ["user_email", "contact_email"], |
116 | | - "title": ["subject"], |
117 | | - "content": ["message", "comments"], |
118 | | - "from_company": ["company", "company_name"], |
119 | | - "phone": ["mobile", "tel"] |
120 | | -} |
121 | | -``` |
122 | | - |
123 | | -## Signed Request Mode |
124 | | - |
125 | | -For sites with **Require HMAC signature** enabled: |
126 | | - |
127 | | -- Header: `X-Timestamp` = unix timestamp in seconds |
128 | | -- Header: `X-Signature` = `hash_hmac('sha256', X-Timestamp + "\n" + raw_body, signature_secret)` |
129 | | - |
130 | | -Recommended usage: |
131 | | - |
132 | | -1. Your website backend builds the final request body |
133 | | -2. Your website backend signs the raw body with the site's signature secret |
134 | | -3. Your website backend sends the request to the central inquiry system |
135 | | - |
136 | | -## Spam Rule Center |
137 | | - |
138 | | -The backend now includes a configurable spam rule center for: |
139 | | - |
140 | | -- honeypot field check |
141 | | -- link threshold check |
142 | | -- duplicate submission check |
143 | | -- IP rate limit |
144 | | -- email rate limit |
145 | | -- keyword-based spam detection |
146 | | -- disposable email domain detection |
147 | | - |
148 | | -## Example Files |
149 | | - |
150 | | -- `examples/php-forwarder.php` |
151 | | -- `examples/php-signed-forwarder.php` |
152 | | -- `examples/javascript-fetch-example.js` |
| 62 | +## Installation |
153 | 63 |
|
154 | | -## GitHub Actions |
| 64 | +### Fresh install |
155 | 65 |
|
156 | | -Workflow file: |
| 66 | +1. Create a MySQL database |
| 67 | +2. Import: |
| 68 | + - `database/schema.sql` |
| 69 | + - `database/seed.sql` |
| 70 | +3. Update `config/database.php` |
| 71 | +4. Point your web root to `public/` |
157 | 72 |
|
158 | | -- `.github/workflows/build-release.yml` |
| 73 | +### Upgrade from v0.4.0 |
159 | 74 |
|
160 | | -It creates a ZIP package automatically when you push a tag like: |
| 75 | +Run: |
161 | 76 |
|
162 | | -```bash |
163 | | -git tag v0.4.0 |
164 | | -git push origin v0.4.0 |
165 | | -``` |
| 77 | +- `database/upgrade-v0.5.0.sql` |
166 | 78 |
|
167 | | -## Notes |
| 79 | +## API endpoint |
168 | 80 |
|
169 | | -Recommended production flow: |
| 81 | +- `POST /api/v1/inquiries/submit` |
| 82 | +- `GET /api/v1/health` |
170 | 83 |
|
171 | | -1. Website form submits to the current website backend |
172 | | -2. The current website backend maps and forwards the payload to this central system |
173 | | -3. This system validates, filters, stores, and manages the inquiry |
| 84 | +## Notes about outbound mail |
174 | 85 |
|
175 | | -This is safer than exposing tokens directly in front-end JavaScript. |
| 86 | +When using `transport = mail`, the hosting environment must already support outbound email for PHP `mail()`. |
| 87 | +If your server does not support it yet, use `log_only` first to verify the notification workflow safely. |
0 commit comments