From 8a515d6f9f7f6d2ae250ebb765320d2ec9402c73 Mon Sep 17 00:00:00 2001 From: Kryscau <73716731+kryscau@users.noreply.github.com> Date: Tue, 17 Jun 2025 21:07:09 +0200 Subject: [PATCH] Update & Error Pages --- _conf/db.php | 27 +++- _conf/env.php | 13 +- _conf/global.php | 1 + _conf/index.php | 5 + _conf/protect.php | 15 ++ admin/--edit-pwd | 153 ------------------ admin/assets/css/index.php | 5 + admin/assets/index.php | 5 + admin/assets/js/index.php | 5 + admin/edit/index.php | 5 + .../{edit-services.php => edit/services.php} | 8 - assets/css/index.php | 5 + assets/index.php | 5 + error/401.html | 41 +++++ error/403.html | 39 +++++ error/404.html | 41 +++++ error/405.html | 41 +++++ error/408.html | 41 +++++ error/413.html | 41 +++++ error/414.html | 41 +++++ error/415.html | 39 +++++ error/429.html | 41 +++++ error/500.html | 41 +++++ error/501.html | 37 +++++ error/502.html | 41 +++++ error/503.html | 41 +++++ error/504.html | 41 +++++ services.php | 10 +- 28 files changed, 647 insertions(+), 181 deletions(-) create mode 100644 _conf/index.php create mode 100644 _conf/protect.php delete mode 100644 admin/--edit-pwd create mode 100644 admin/assets/css/index.php create mode 100644 admin/assets/index.php create mode 100644 admin/assets/js/index.php create mode 100644 admin/edit/index.php rename admin/{edit-services.php => edit/services.php} (98%) create mode 100644 assets/css/index.php create mode 100644 assets/index.php create mode 100644 error/401.html create mode 100644 error/403.html create mode 100644 error/404.html create mode 100644 error/405.html create mode 100644 error/408.html create mode 100644 error/413.html create mode 100644 error/414.html create mode 100644 error/415.html create mode 100644 error/429.html create mode 100644 error/500.html create mode 100644 error/501.html create mode 100644 error/502.html create mode 100644 error/503.html create mode 100644 error/504.html diff --git a/_conf/db.php b/_conf/db.php index f215f29..ef40ac8 100644 --- a/_conf/db.php +++ b/_conf/db.php @@ -1,19 +1,30 @@ $env['DB_HOST'] ?? 'localhost', + 'name' => $env['DB_NAME'] ?? 'my_webapp', + 'user' => $env['DB_USER'] ?? 'my_webapp', + 'pass' => $env['DB_PASSWORD'] ?? '', + 'port' => $env['DB_PORT'] ?? '3306', +]; -if (!$db['host'] || !$db['name'] || !$db['user'] || !$db['pass'] || !$db['port']) { +if (!$db['host'] || !$db['name'] || !$db['user']) { die("DB configuration error: missing parameters. Please check your environment variables."); } +$db['dsn'] = 'mysql:host=' . $db['host'] . ';' + . 'port=' . $db['port'] . ';' + . 'dbname=' . $db['name'] . ';charset=utf8mb4'; -$db['dsn'] = 'mysql:host=' . $db['host'] . ';port='. $db['port'] .';dbname=' . $db['name'] . ';charset=utf8mb4'; +try { + $pdo = new PDO($db['dsn'], $db['user'], $db['pass']); + $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); +} catch (PDOException $e) { + die("Database connection error: " . $e->getMessage()); +} -?> \ No newline at end of file +?> diff --git a/_conf/env.php b/_conf/env.php index af3ca11..52b5e61 100644 --- a/_conf/env.php +++ b/_conf/env.php @@ -1,24 +1,31 @@ \ No newline at end of file diff --git a/_conf/global.php b/_conf/global.php index cd012f8..0b8eb3f 100644 --- a/_conf/global.php +++ b/_conf/global.php @@ -1,5 +1,6 @@ \ No newline at end of file diff --git a/_conf/protect.php b/_conf/protect.php new file mode 100644 index 0000000..54d0801 --- /dev/null +++ b/_conf/protect.php @@ -0,0 +1,15 @@ + \ No newline at end of file diff --git a/admin/--edit-pwd b/admin/--edit-pwd deleted file mode 100644 index 5c61159..0000000 --- a/admin/--edit-pwd +++ /dev/null @@ -1,153 +0,0 @@ -Le mot de passe ne peut pas être vide!'; - } else { - // Générer le hash avec bcrypt - $hash = password_hash($new_password, PASSWORD_BCRYPT); - - try { - // Connexion à la base de données - $pdo = new PDO("mysql:host=$db_host;dbname=$db_name;charset=utf8mb4", $db_user, $db_pass); - $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - - // Vérifier si la table admin existe - $tables = $pdo->query("SHOW TABLES LIKE 'admin'")->fetchAll(); - - if (count($tables) === 0) { - // Créer la table admin si elle n'existe pas - $pdo->exec("CREATE TABLE IF NOT EXISTS `admin` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `password_hash` varchar(255) NOT NULL, - PRIMARY KEY (`id`) - ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"); - - // Insérer le nouveau mot de passe - $stmt = $pdo->prepare("INSERT INTO admin (password_hash) VALUES (?)"); - $stmt->execute([$hash]); - } else { - // Vérifier si un enregistrement existe déjà - $count = $pdo->query("SELECT COUNT(*) FROM admin")->fetchColumn(); - - if ($count > 0) { - // Mettre à jour le mot de passe existant - $stmt = $pdo->prepare("UPDATE admin SET password_hash = ? WHERE id = 1"); - $stmt->execute([$hash]); - } else { - // Insérer un nouveau mot de passe - $stmt = $pdo->prepare("INSERT INTO admin (password_hash) VALUES (?)"); - $stmt->execute([$hash]); - } - } - - $message = '
Mot de passe mis à jour avec succès!
-Votre nouveau mot de passe: ' . htmlspecialchars($new_password) . '
-Hash généré: ' . $hash . '
IMPORTANT: Supprimez ce fichier immédiatement après utilisation!
-
+ Access denied.
+
+ You need to log in to view this page.
+
+ Sorry, you don’t have permission to access this page. +
+
+ Oops! The page you’re looking for doesn’t exist or has been moved.
+
+ Let’s get you back on track.
+
+ The method used is not allowed for this resource.
+
+ Please check and try another method.
+
+ Your request took too long to complete.
+
+ Please try again.
+
+ The data you sent is too big.
+
+ Try reducing the size and retrying.
+
+ The URL is too long to be processed.
+
+ Please shorten the link or try a different one.
+
+ The media type you sent is not supported by this server. +
+
+ Slow down! You’ve sent too many requests.
+
+ Please wait and try again later.
+
+ Whoops! Something went wrong on our side.
+
+ We’re on it, try again soon.
+
This feature is not supported by the server yet.
+
+ Bad response from an upstream server.
+
+ Please try again later.
+
+ The server is temporarily unavailable.
+
+ Please try again shortly.
+
+ The server took too long to respond.
+
+ Please try again later.
+