aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNatasha Moongrave <natasha@256phi.eu>2026-04-01 13:05:33 +0200
committerNatasha Moongrave <natasha@256phi.eu>2026-04-01 13:05:33 +0200
commit30a3a504d9cfbb5d9159749608bdcdbac5243bbf (patch)
tree46010f7992108d89660b1540ffaa775ecfc6ae9b
parent84a00a9396e32524a0db82737cfa5239eba2891d (diff)
Modified the submission system for commissions to save to a json isntead of sending emaik
-rw-r--r--Caddyfile4
-rw-r--r--src/Pages/commissions/commissions.php41
2 files changed, 27 insertions, 18 deletions
diff --git a/Caddyfile b/Caddyfile
index ff902c8..404b190 100644
--- a/Caddyfile
+++ b/Caddyfile
@@ -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.';
}
}
}