diff options
Diffstat (limited to 'src/Pages/commissions/commissions.php')
| -rw-r--r-- | src/Pages/commissions/commissions.php | 41 |
1 files changed, 23 insertions, 18 deletions
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.'; } } } |
