From 4b8c070f0a5a1777b35380cbef930fa3a9570f08 Mon Sep 17 00:00:00 2001 From: Baptiste Date: Tue, 14 Jun 2022 23:36:26 +0200 Subject: [PATCH] admin v1 --- admin/deco.php | 6 ++++ admin/enigma.php | 7 ++++ admin/gestion_des_acces.php | 65 +++++++++++++++++++++++++++++++++++++ admin/index.php | 55 +++++++++++++++++++++++++++++++ admin/planning.php | 8 +++++ admin/script.php | 50 ++++++++++++++++++++++++++++ admin/stats.php | 3 ++ admin/t.htaccess | 4 +++ admin/t.htpasswd | 1 + admin/vacances.php | 7 ++++ 10 files changed, 206 insertions(+) create mode 100644 admin/deco.php create mode 100644 admin/enigma.php create mode 100644 admin/gestion_des_acces.php create mode 100644 admin/index.php create mode 100644 admin/planning.php create mode 100644 admin/script.php create mode 100644 admin/stats.php create mode 100644 admin/t.htaccess create mode 100644 admin/t.htpasswd create mode 100644 admin/vacances.php diff --git a/admin/deco.php b/admin/deco.php new file mode 100644 index 0000000..079036f --- /dev/null +++ b/admin/deco.php @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/admin/enigma.php b/admin/enigma.php new file mode 100644 index 0000000..86afd23 --- /dev/null +++ b/admin/enigma.php @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/admin/gestion_des_acces.php b/admin/gestion_des_acces.php new file mode 100644 index 0000000..159fbb6 --- /dev/null +++ b/admin/gestion_des_acces.php @@ -0,0 +1,65 @@ +prepare("SELECT id FROM admin WHERE pseudo = ?"); + $req->execute(array($pseudo)); + $pseudo_exist = $req->rowCount(); + if ($pseudo_exist == 0) { + $req = $db->prepare("INSERT INTO admin(pseudo, mdp, perm) VALUES(?, ?, ?)"); + $req->execute(array($pseudo, password_hash($mdp, PASSWORD_DEFAULT), $perm)); + } else { + $error = "pseudo déja utilisé"; + } + } else { + $error = "le pseudo ne doit pas dépasser 50 char"; + } + } else { + $error = "Tout les champs doivent être complétés"; + } +} +?> + + + + + + Admin / Accès + + +
+ + + + +
+ ".$error.""; + } + ?> +

+ query('SELECT id, pseudo, perm FROM admin'); + while($admin = $req->fetch()) { + ?> + || || + + + + + \ No newline at end of file diff --git a/admin/index.php b/admin/index.php new file mode 100644 index 0000000..e6760ce --- /dev/null +++ b/admin/index.php @@ -0,0 +1,55 @@ +prepare("SELECT id, mdp FROM admin WHERE pseudo = ?"); + $req->execute(array($pseudo)); + $user_exist = $req->rowcount(); + if ($user_exist == 1) { + while ($user_login = $req->fetch()) { + $passwd = $user_login['mdp']; + if ((password_verify($password, $passwd)) == 1) { + $_SESSION['id'] = $user_login['id']; + header('Refresh:0'); + } else { + $error = "Mot de passe invalide !"; + } + } + } else { + $error = "Identifiant invalide !"; + } + } else { + $error = "Tout les champs doivent être complétés"; + } +} +?> + + + + + + Admin / index + + + +
+ + + +
+ ".$error.""; + } + ?> + + \ No newline at end of file diff --git a/admin/planning.php b/admin/planning.php new file mode 100644 index 0000000..bf9c89f --- /dev/null +++ b/admin/planning.php @@ -0,0 +1,8 @@ + \ No newline at end of file diff --git a/admin/script.php b/admin/script.php new file mode 100644 index 0000000..97a98d4 --- /dev/null +++ b/admin/script.php @@ -0,0 +1,50 @@ +prepare("SELECT pseudo, perm FROM admin WHERE id = ?"); + $req_user->execute(array($_SESSION['id'])); + $user_exist = $req_user->rowcount(); + $user = $req_user->fetch(); +} else { + $user_exist = 0; +} + + +if($user_exist != 1) { + if($page != "index") { + header('Location: index.php'); + } +} else { + switch ($user['perm']) { + case 0: + ?> + Index
+ Stats
+ Se déconnecter
+ + Index
+ Planning
+ Stats
+ Se déconnecter
+ + Index
+ Gestion des accès
+ Enigma
+ Planning
+ Stats
+ Vacances
+ Se déconnecter
+ \ No newline at end of file diff --git a/admin/stats.php b/admin/stats.php new file mode 100644 index 0000000..3e23ed7 --- /dev/null +++ b/admin/stats.php @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/admin/t.htaccess b/admin/t.htaccess new file mode 100644 index 0000000..9d9e63b --- /dev/null +++ b/admin/t.htaccess @@ -0,0 +1,4 @@ +AuthName "Vous ne passerez pas (sauf si vous passez)" +AuthType Basic +AuthUserFile ".htpasswd" +Require valid-user \ No newline at end of file diff --git a/admin/t.htpasswd b/admin/t.htpasswd new file mode 100644 index 0000000..6a113f0 --- /dev/null +++ b/admin/t.htpasswd @@ -0,0 +1 @@ +on_est_les_admine:$apr1$sl6wtfnm$kglXQc9t3n0DnNO0dbM./1 \ No newline at end of file diff --git a/admin/vacances.php b/admin/vacances.php new file mode 100644 index 0000000..86afd23 --- /dev/null +++ b/admin/vacances.php @@ -0,0 +1,7 @@ + \ No newline at end of file