diff options
| author | Natasha Moongrave <natasha@256phi.eu> | 2026-04-01 13:05:33 +0200 |
|---|---|---|
| committer | Natasha Moongrave <natasha@256phi.eu> | 2026-04-01 13:05:33 +0200 |
| commit | 30a3a504d9cfbb5d9159749608bdcdbac5243bbf (patch) | |
| tree | 46010f7992108d89660b1540ffaa775ecfc6ae9b | |
| parent | 84a00a9396e32524a0db82737cfa5239eba2891d (diff) | |
Modified the submission system for commissions to save to a json isntead of sending emaik
| -rw-r--r-- | Caddyfile | 4 | ||||
| -rw-r--r-- | src/Pages/commissions/commissions.php | 41 |
2 files changed, 27 insertions, 18 deletions
@@ -2,6 +2,10 @@ # Site's directory root * /var/www/html/src + # Block direct access to JSON data files + @jsonFiles path *.json + respond @jsonFiles 404 + # Enable the static file server. file_server diff --git a/src/Pages/commissions/commissions.php b/src/Pages/commissions/commissions.php index 77e1d4c..bb607e0 100644 --- a/src/Pages/commissions/commissions.php +++ b/src/Pages/commissions/commissions.php @@ -353,10 +353,10 @@ // Bot detected, silently ignore $success = true; } else { - $name = htmlspecialchars(trim($_POST['name'] ?? ''), ENT_QUOTES, 'UTF-8'); + $name = trim($_POST['name'] ?? ''); $email = filter_var(trim($_POST['email'] ?? ''), FILTER_SANITIZE_EMAIL); - $description = htmlspecialchars(trim($_POST['description'] ?? ''), ENT_QUOTES, 'UTF-8'); - $budget = htmlspecialchars(trim($_POST['budget'] ?? ''), ENT_QUOTES, 'UTF-8'); + $description = trim($_POST['description'] ?? ''); + $budget = trim($_POST['budget'] ?? ''); // Validation if (empty($name) || empty($email) || empty($description)) { @@ -366,23 +366,28 @@ } elseif (strlen($description) > 5000) { $error = 'Description is too long (max 5000 characters).'; } else { - // Compose email - $to = 'commission@256phi.eu'; - $subject = "Commission Request from $name"; - $body = "New commission request:\n\n"; - $body .= "Name: $name\n"; - $body .= "Email: $email\n"; - $body .= "Budget: $budget\n\n"; - $body .= "Description:\n$description\n"; - - $headers = "From: noreply@256phi.eu\r\n"; - $headers .= "Reply-To: $email\r\n"; - $headers .= "Content-Type: text/plain; charset=UTF-8\r\n"; - - if (mail($to, $subject, $body, $headers)) { + // Save to JSON file + $submissionsFile = __DIR__ . '/submissions.json'; + $submissions = []; + + if (file_exists($submissionsFile)) { + $submissions = json_decode(file_get_contents($submissionsFile), true) ?? []; + } + + $submissions[] = [ + 'id' => uniqid(), + 'date' => date('Y-m-d H:i:s'), + 'name' => $name, + 'email' => $email, + 'budget' => $budget, + 'description' => $description, + 'status' => 'new' + ]; + + if (file_put_contents($submissionsFile, json_encode($submissions, JSON_PRETTY_PRINT))) { $success = true; } else { - $error = 'Failed to send message. Please try emailing directly.'; + $error = 'Failed to save request. Please email me directly.'; } } } |
