From 4a1e4b696ed6ccfa311ba1d173965a8446925dd2 Mon Sep 17 00:00:00 2001 From: Pontoporeia Date: Tue, 2 May 2023 20:17:58 +0200 Subject: [PATCH] rewrite v1.0 --- .gitignore | 3 +- assets/{fonts => }/Combinedd.otf | Bin assets/icon.svg | 65 ++++++++++++ assets/icons.svg | 1 - assets/posterg.css | 38 +++++-- error.log | 172 +++++++++++++++++++++++++++++++ formulaire.php | 29 ++++-- index.php | 16 +-- thanks.php | 2 + 9 files changed, 301 insertions(+), 25 deletions(-) rename assets/{fonts => }/Combinedd.otf (100%) create mode 100644 assets/icon.svg delete mode 100755 assets/icons.svg diff --git a/.gitignore b/.gitignore index c52feaf..3f18970 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /vendor/ /composer.lock ### Data et Mémoire### -data \ No newline at end of file +data/yaml/ +data/content/ \ No newline at end of file diff --git a/assets/fonts/Combinedd.otf b/assets/Combinedd.otf similarity index 100% rename from assets/fonts/Combinedd.otf rename to assets/Combinedd.otf diff --git a/assets/icon.svg b/assets/icon.svg new file mode 100644 index 0000000..4bb0557 --- /dev/null +++ b/assets/icon.svg @@ -0,0 +1,65 @@ + + + + + + + + + + diff --git a/assets/icons.svg b/assets/icons.svg deleted file mode 100755 index f45a356..0000000 --- a/assets/icons.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/assets/posterg.css b/assets/posterg.css index 7900234..14f7f27 100644 --- a/assets/posterg.css +++ b/assets/posterg.css @@ -1,8 +1,26 @@ @font-face { font-family: police1; - src: url("./fonts/Combinedd.otf"); + src: url("./Combinedd.otf"); } +/* Dark theme */ +/* UTILE POUR FORCER UN MODE LIGHT */ +@media (prefers-color-scheme: dark) { + :root, + ::backdrop { + --bg: #fff; + --accent-bg: #f5f7ff; + --text: #212121; + --text-light: #585858; + --border: #898EA4; + --accent: #0d47a1; + --code: #d81b60; + --preformatted: #444; + --marked: #ffdd33; + --disabled: #efefef; + } +} + body{ background-color: white; } @@ -10,15 +28,18 @@ /* ENTÊTE */ header { - font-family: 'police1'; - background: linear-gradient(315deg, rgba(77, 168, 112, 1) 0%, rgba(193, 4, 252, 1) 66%); - + background: linear-gradient(280deg, rgba(77, 168, 112, 1) 0%, rgba(193, 4, 252, 1) 85%); text-decoration: none; outline: none; font-size: 2rem; } + body > header h1 { + color: white; + margin: 3rem auto auto auto; + } + /* FORMULAIRE */ form label { @@ -44,8 +65,8 @@ } input { - font-family: police1; - font-weight: bold; + /* font-family: police1; */ + /* font-weight: bold; */ background-color: none; color: rgb(193, 4, 252); border: 1px solid rgb(193, 4, 252); @@ -72,10 +93,7 @@ input { margin-top: 2rem; } - body > header h1 { - color: white; - margin: 3rem auto auto auto; - } + diff --git a/error.log b/error.log index 50e4fc6..7e96795 100644 --- a/error.log +++ b/error.log @@ -2,3 +2,175 @@ Stack trace: #0 {main} thrown in /home/lockpick/Projects/posterg-formulaire/formulaire.php on line 42 +[02-May-2023 17:27:08 UTC] FILES array: Array +( + [files] => Array + ( + [name] => undefinedMega_2023-04-24.pdf + [full_path] => undefinedMega_2023-04-24.pdf + [type] => application/pdf + [tmp_name] => /tmp/phptz5xyY + [error] => 0 + [size] => 64998 + ) + +) + +[02-May-2023 17:29:09 UTC] FILES array: Array +( + [files] => Array + ( + [name] => undefinedMega_2023-04-24.pdf + [full_path] => undefinedMega_2023-04-24.pdf + [type] => application/pdf + [tmp_name] => /tmp/phpbgEPg4 + [error] => 0 + [size] => 64998 + ) + +) + +[02-May-2023 17:29:24 UTC] FILES array: Array +( + [files] => Array + ( + [name] => Array + ( + [0] => UdeM_Guide-ecriture-inclusive.pdf + [1] => undefinedMega_2023-04-24.pdf + ) + + [full_path] => Array + ( + [0] => UdeM_Guide-ecriture-inclusive.pdf + [1] => undefinedMega_2023-04-24.pdf + ) + + [type] => Array + ( + [0] => application/pdf + [1] => application/pdf + ) + + [tmp_name] => Array + ( + [0] => /tmp/php5XBNaE + [1] => /tmp/phpGrs9Dq + ) + + [error] => Array + ( + [0] => 0 + [1] => 0 + ) + + [size] => Array + ( + [0] => 579957 + [1] => 64998 + ) + + ) + +) + +[02-May-2023 17:29:24 UTC] Processing file: UdeM_Guide-ecriture-inclusive.pdf +[02-May-2023 17:29:24 UTC] File successfully moved: data/content///UdeM_Guide-ecriture-inclusive.pdf +[02-May-2023 17:29:24 UTC] Processing file: undefinedMega_2023-04-24.pdf +[02-May-2023 17:29:24 UTC] File successfully moved: data/content///undefinedMega_2023-04-24.pdf +[02-May-2023 17:31:08 UTC] FILES array: Array +( + [files] => Array + ( + [name] => Array + ( + [0] => UdeM_Guide-ecriture-inclusive.pdf + [1] => undefinedMega_2023-04-24.pdf + ) + + [full_path] => Array + ( + [0] => UdeM_Guide-ecriture-inclusive.pdf + [1] => undefinedMega_2023-04-24.pdf + ) + + [type] => Array + ( + [0] => application/pdf + [1] => application/pdf + ) + + [tmp_name] => Array + ( + [0] => /tmp/phpQbhzwi + [1] => /tmp/phpm8u5q7 + ) + + [error] => Array + ( + [0] => 0 + [1] => 0 + ) + + [size] => Array + ( + [0] => 579957 + [1] => 64998 + ) + + ) + +) + +[02-May-2023 17:31:08 UTC] Processing file: UdeM_Guide-ecriture-inclusive.pdf +[02-May-2023 17:31:08 UTC] File successfully moved: data/content/2024/Théophile Gervreau-Mercier/UdeM_Guide-ecriture-inclusive.pdf +[02-May-2023 17:31:08 UTC] Processing file: undefinedMega_2023-04-24.pdf +[02-May-2023 17:31:08 UTC] File successfully moved: data/content/2024/Théophile Gervreau-Mercier/undefinedMega_2023-04-24.pdf +[02-May-2023 17:31:34 UTC] FILES array: Array +( + [files] => Array + ( + [name] => Array + ( + [0] => UdeM_Guide-ecriture-inclusive.pdf + [1] => undefinedMega_2023-04-24.pdf + ) + + [full_path] => Array + ( + [0] => UdeM_Guide-ecriture-inclusive.pdf + [1] => undefinedMega_2023-04-24.pdf + ) + + [type] => Array + ( + [0] => application/pdf + [1] => application/pdf + ) + + [tmp_name] => Array + ( + [0] => /tmp/phpC8OF8o + [1] => /tmp/phpGoliAt + ) + + [error] => Array + ( + [0] => 0 + [1] => 0 + ) + + [size] => Array + ( + [0] => 579957 + [1] => 64998 + ) + + ) + +) + +[02-May-2023 17:31:34 UTC] Processing file: UdeM_Guide-ecriture-inclusive.pdf +[02-May-2023 17:31:34 UTC] File successfully moved: data/content/2025/Théophile Gervreau-Mercier/UdeM_Guide-ecriture-inclusive.pdf +[02-May-2023 17:31:34 UTC] Processing file: undefinedMega_2023-04-24.pdf +[02-May-2023 17:31:34 UTC] File successfully moved: data/content/2025/Théophile Gervreau-Mercier/undefinedMega_2023-04-24.pdf diff --git a/formulaire.php b/formulaire.php index b2c628d..065e855 100644 --- a/formulaire.php +++ b/formulaire.php @@ -5,6 +5,9 @@ ini_set('display_errors', 0); ini_set('log_errors', 1); ini_set('error_log', 'error.log'); +// Log the content of the $_FILES array +error_log("FILES array: " . print_r($_FILES, true)); + require_once 'vendor/autoload.php'; use Symfony\Component\Yaml\Yaml; use Behat\Transliterator\Transliterator; @@ -51,30 +54,43 @@ $maxFileSize = 5 * 1024 * 1024; // 5 MB // Process uploaded files if (is_array($files["name"])) { for ($i = 0; $i < count($files["name"]); $i++) { + // Log the file being processed + error_log("Processing file: " . $files["name"][$i]); + // Check for file upload errors + if ($files["error"][$i] !== UPLOAD_ERR_OK) { + error_log("File upload error: " . $files["name"][$i]); + continue; + } + // Check MIME type and file extension $finfo = new finfo(FILEINFO_MIME_TYPE); $mimeType = $finfo->file($files["tmp_name"][$i]); $fileExtension = pathinfo($files["name"][$i], PATHINFO_EXTENSION); if (!in_array($mimeType, $allowedMimeTypes) || !in_array($fileExtension, $allowedExtensions)) { - echo "Invalid file type or extension: " . $files["name"][$i] . "
"; + error_log("Invalid file type or extension: " . $files["name"][$i]); continue; } // Check file size if ($files["size"][$i] > $maxFileSize) { - echo "File is too large: " . $files["name"][$i] . "
"; + error_log("File is too large: " . $files["name"][$i]); continue; } - // Move and set permissions for the uploaded file $targetFile = $targetDir . basename($files["name"][$i]); - move_uploaded_file($files["tmp_name"][$i], $targetFile); - chmod($targetFile, 0644); - $uploadedFiles[] = $targetFile; + if (move_uploaded_file($files["tmp_name"][$i], $targetFile)) { + // Log successful file move + error_log("File successfully moved: " . $targetFile); + chmod($targetFile, 0644); + $uploadedFiles[] = $targetFile; + } else { + error_log("Failed to move uploaded file: " . $files["name"][$i]); + } } } + // Prepare form data for YAML $formData = [ 'auteurice' => $auteurice, @@ -100,3 +116,4 @@ file_put_contents($yamlFilePath, $yamlData); // Redirect to the thank you page header('Location: thanks.php?file=' . urlencode($yamlFilePath)); +?> \ No newline at end of file diff --git a/index.php b/index.php index 6b8f038..9a2054f 100644 --- a/index.php +++ b/index.php @@ -9,6 +9,7 @@ +
@@ -19,16 +20,16 @@
- + - - + + - + @@ -44,7 +45,7 @@ - @@ -64,7 +65,7 @@ - @@ -74,7 +75,8 @@ Si tu veux importer un dossier, créer une archive zip. -
+ +
diff --git a/thanks.php b/thanks.php index c54296d..db97f51 100644 --- a/thanks.php +++ b/thanks.php @@ -22,6 +22,8 @@ $data = Yaml::parseFile($yamlFile); + +