Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SAE4
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
Arrêt du service - 11/07 de 07h30 à 07h45 - Mise à jour de sécurité
Show more breadcrumbs
MATEJKA Milan
SAE4
Commits
89357b52
Commit
89357b52
authored
1 month ago
by
VoidOma
Browse files
Options
Downloads
Patches
Plain Diff
Correcyion secu admin_tournois, admin cree tournois
parent
98bdd8f5
No related branches found
No related tags found
1 merge request
!1
MergeRequest_1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
code_source/web_app/public/admin_creer_tournoi.php
+58
-39
58 additions, 39 deletions
code_source/web_app/public/admin_creer_tournoi.php
code_source/web_app/public/admin_tournois.php
+65
-54
65 additions, 54 deletions
code_source/web_app/public/admin_tournois.php
with
123 additions
and
93 deletions
code_source/web_app/public/admin_creer_tournoi.php
+
58
−
39
View file @
89357b52
<?php
<?php
require_once
'../includes/init.php'
;
// Connexion PDO et session
require_once
'../includes/init.php'
;
require_once
'../includes/header.php'
;
require_once
'../includes/header.php'
;
require_once
'../includes/navbar.php'
;
require_once
'../includes/navbar.php'
;
...
@@ -11,46 +11,65 @@ if (!isset($_SESSION['user']) || $_SESSION['user']['statut'] !== 'ADMINISTRATEUR
...
@@ -11,46 +11,65 @@ if (!isset($_SESSION['user']) || $_SESSION['user']['statut'] !== 'ADMINISTRATEUR
// Traitement du formulaire
// Traitement du formulaire
if
(
$_SERVER
[
'REQUEST_METHOD'
]
===
'POST'
)
{
if
(
$_SERVER
[
'REQUEST_METHOD'
]
===
'POST'
)
{
$nom
=
$_POST
[
'nom'
];
// Nettoyage des données
$date_debut
=
$_POST
[
'date_debut'
];
$nom
=
trim
(
$_POST
[
'nom'
]);
$date_fin
=
$_POST
[
'date_fin'
];
$date_debut
=
trim
(
$_POST
[
'date_debut'
]);
$lieu
=
$_POST
[
'lieu'
];
$date_fin
=
trim
(
$_POST
[
'date_fin'
]);
$type_surface
=
$_POST
[
'type_surface'
];
$lieu
=
trim
(
$_POST
[
'lieu'
]);
$categorie
=
$_POST
[
'categorie'
];
$type_surface
=
trim
(
$_POST
[
'type_surface'
]);
$categorie
=
trim
(
$_POST
[
'categorie'
]);
// Déterminer automatiquement l'âge minimum et maximum
// Vérification des champs obligatoires
$age_min
=
0
;
if
(
empty
(
$nom
)
||
empty
(
$date_debut
)
||
empty
(
$date_fin
)
||
empty
(
$lieu
)
||
empty
(
$type_surface
)
||
empty
(
$categorie
))
{
$age_max
=
0
;
echo
"<p>Veuillez remplir tous les champs obligatoires.</p>"
;
if
(
$categorie
===
'Junior'
)
{
}
elseif
(
!
in_array
(
$type_surface
,
[
'Terre battue'
,
'Gazon'
,
'Dur'
,
'Moquette'
]))
{
$age_min
=
8
;
echo
"<p>Surface non valide.</p>"
;
$age_max
=
17
;
}
elseif
(
!
in_array
(
$categorie
,
[
'Junior'
,
'Senior'
,
'Vétéran'
]))
{
}
elseif
(
$categorie
===
'Senior'
)
{
echo
"<p>Catégorie non valide.</p>"
;
$age_min
=
18
;
}
elseif
(
!
preg_match
(
'/^\d{4}-\d{2}-\d{2}$/'
,
$date_debut
)
||
!
preg_match
(
'/^\d{4}-\d{2}-\d{2}$/'
,
$date_fin
))
{
$age_max
=
40
;
echo
"<p>Les dates doivent être au format AAAA-MM-JJ.</p>"
;
}
elseif
(
$categorie
===
'Vétéran'
)
{
}
elseif
(
strtotime
(
$date_debut
)
>
strtotime
(
$date_fin
))
{
$age_min
=
41
;
echo
"<p>La date de début ne peut pas être postérieure à la date de fin.</p>"
;
$age_max
=
99
;
}
else
{
}
// Déterminer automatiquement l'âge min/max
$age_min
=
0
;
$age_max
=
0
;
switch
(
$categorie
)
{
case
'Junior'
:
$age_min
=
8
;
$age_max
=
17
;
break
;
case
'Senior'
:
$age_min
=
18
;
$age_max
=
40
;
break
;
case
'Vétéran'
:
$age_min
=
41
;
$age_max
=
99
;
break
;
}
$sql
=
"INSERT INTO tournoi (nom_tournoi, date_debut, date_fin, lieu, type_surface, categorie, age_min, age_max)
// Insertion en base de données
VALUES (:nom_tournoi, :date_debut, :date_fin, :lieu, :type_ surface, :categorie, :age_min, :age_max)"
;
$sql
=
"INSERT INTO tournoi (nom_tournoi, date_debut, date_fin, lieu, type_surface, categorie, age_min, age_max)
$stmt
=
$pdo
->
prepare
(
$sql
);
VALUES (:nom_tournoi, :date_debut, :date_fin, :lieu, :type_surface, :categorie, :age_min, :age_max)"
;
$stmt
->
execute
([
$stmt
=
$pdo
->
prepare
(
$sql
);
':nom_tournoi'
=>
$nom
,
$stmt
->
execute
([
':date_debut'
=>
$date_debut
,
':nom_tournoi'
=>
$nom
,
':date_fin'
=>
$date_fin
,
':date_debut'
=>
$date_debut
,
':lieu'
=>
$lieu
,
':date_fin'
=>
$date_fin
,
':type_surface'
=>
$type_surface
,
':lieu'
=>
$lieu
,
':categorie'
=>
$categorie
,
':type_surface'
=>
$type_surface
,
':age_min'
=>
$age_min
,
':categorie'
=>
$categorie
,
':age_max'
=>
$age_max
':age_min'
=>
$age_min
,
]);
':age_max'
=>
$age_max
]);
echo
"<script>
echo
"<script>
alert('Le tournoi a été créé avec succès.');
alert('Le tournoi a été créé avec succès.');
window.location.href = 'admin_tournois.php';
window.location.href = 'admin_tournois.php';
</script>"
;
</script>"
;
exit
;
exit
;
}
}
}
?>
?>
...
...
This diff is collapsed.
Click to expand it.
code_source/web_app/public/admin_tournois.php
+
65
−
54
View file @
89357b52
...
@@ -3,61 +3,72 @@ require_once '../includes/init.php'; // Connexion PDO et session
...
@@ -3,61 +3,72 @@ require_once '../includes/init.php'; // Connexion PDO et session
require_once
'../includes/header.php'
;
require_once
'../includes/header.php'
;
require_once
'../includes/navbar.php'
;
require_once
'../includes/navbar.php'
;
// Récupérer la liste des tournois
// Récupérer la liste des tournois en toute sécurité
$sql
=
"SELECT * FROM tournoi ORDER BY date_debut ASC"
;
try
{
$stmt
=
$pdo
->
query
(
$sql
);
$stmt
=
$pdo
->
query
(
"SELECT * FROM tournoi ORDER BY date_debut ASC"
);
$tournois
=
$stmt
->
fetchAll
();
$tournois
=
$stmt
->
fetchAll
(
PDO
::
FETCH_ASSOC
);
}
catch
(
PDOException
$e
)
{
echo
"<p>Erreur lors de la récupération des tournois : "
.
htmlspecialchars
(
$e
->
getMessage
())
.
"</p>"
;
require_once
'../includes/footer.php'
;
exit
;
}
?>
?>
<main
class=
"content-wrapper"
>
<main
class=
"content-wrapper"
>
<div
class=
"admin-section"
>
<div
class=
"admin-section"
>
<h2>
Liste des tournois
</h2>
<h2>
Liste des tournois
</h2>
<?php
if
(
!
isset
(
$_SESSION
[
'user'
]))
:
?>
<div
class=
"alert alert-warning"
>
<?php
if
(
!
isset
(
$_SESSION
[
'user'
]))
:
?>
<p
style=
"color : grey ; font-weight : bold"
>
Veuillez vous connecter pour voir plus de détails sur les tournois.
</p>
<div
class=
"alert alert-warning"
>
</div>
<p
style=
"color: grey; font-weight: bold;"
>
Veuillez vous connecter pour voir plus de détails sur les tournois.
</p>
<?php
endif
;
?>
</div>
<table
class=
"admin-table"
>
<?php
endif
;
?>
<thead>
<tr>
<table
class=
"admin-table"
>
<th>
Nom
</th>
<thead>
<th>
Date de début
</th>
<tr>
<th>
Date de fin
</th>
<th>
Nom
</th>
<th>
Lieu
</th>
<th>
Date de début
</th>
<th>
Surface
</th>
<th>
Date de fin
</th>
<th>
Catégorie
</th>
<th>
Lieu
</th>
<th>
Statut
</th>
<!-- Nouvelle colonne -->
<th>
Surface
</th>
<th>
Action
</th>
<th>
Catégorie
</th>
</tr>
<th>
Statut
</th>
</thead>
<th>
Action
</th>
<tbody>
</tr>
<?php
foreach
(
$tournois
as
$tournoi
)
:
?>
</thead>
<tr>
<tbody>
<td>
<?=
htmlspecialchars
(
$tournoi
[
'nom_tournoi'
])
?>
</td>
<?php
if
(
!
empty
(
$tournois
))
:
?>
<td>
<?=
htmlspecialchars
(
$tournoi
[
'date_debut'
])
?>
</td>
<?php
foreach
(
$tournois
as
$tournoi
)
:
?>
<td>
<?=
htmlspecialchars
(
$tournoi
[
'date_fin'
])
?>
</td>
<tr>
<td>
<?=
htmlspecialchars
(
$tournoi
[
'lieu'
])
?>
</td>
<td>
<?=
htmlspecialchars
(
$tournoi
[
'nom_tournoi'
])
?>
</td>
<td>
<?=
htmlspecialchars
(
$tournoi
[
'type_surface'
])
?>
</td>
<td>
<?=
htmlspecialchars
(
$tournoi
[
'date_debut'
])
?>
</td>
<td>
<?=
htmlspecialchars
(
$tournoi
[
'categorie'
])
?>
</td>
<td>
<?=
htmlspecialchars
(
$tournoi
[
'date_fin'
])
?>
</td>
<td>
<?=
htmlspecialchars
(
$tournoi
[
'statut'
])
?>
</td>
<!-- Affiche le statut -->
<td>
<?=
htmlspecialchars
(
$tournoi
[
'lieu'
])
?>
</td>
<td>
<td>
<?=
htmlspecialchars
(
$tournoi
[
'type_surface'
])
?>
</td>
<!-- Bouton "Détails" affiché uniquement si connecté -->
<td>
<?=
htmlspecialchars
(
$tournoi
[
'categorie'
])
?>
</td>
<?php
if
(
isset
(
$_SESSION
[
'user'
]))
:
?>
<td>
<?=
htmlspecialchars
(
$tournoi
[
'statut'
]
??
'Non défini'
)
?>
</td>
<a
href=
"details_tournoi.php?id=
<?=
htmlspecialchars
(
$tournoi
[
'idTournoi'
])
?>
"
class=
"btn2 btn2-info"
>
Détails
</a>
<td>
<?php
else
:
?>
<?php
if
(
isset
(
$_SESSION
[
'user'
]))
:
?>
<span
class=
"btn2 btn2-disabled"
>
Détails non disponibles
</span>
<a
href=
"details_tournoi.php?id=
<?=
urlencode
(
$tournoi
[
'idTournoi'
])
?>
"
class=
"btn2 btn2-info"
>
Détails
</a>
<?php
endif
;
?>
<?php
else
:
?>
</td>
<span
class=
"btn2 btn2-disabled"
>
Détails non disponibles
</span>
</tr>
<?php
endif
;
?>
<?php
endforeach
;
?>
</td>
</tbody>
</tr>
</table>
<?php
endforeach
;
?>
<?php
else
:
?>
<tr><td
colspan=
"8"
>
Aucun tournoi trouvé.
</td></tr>
<?php
endif
;
?>
</tbody>
</table>
<!-- Bouton de création (admin uniquement) -->
<?php
if
(
isset
(
$_SESSION
[
'user'
][
'statut'
])
&&
$_SESSION
[
'user'
][
'statut'
]
===
'ADMINISTRATEUR'
)
:
?>
<div
class=
"create-button-container"
>
<a
href=
"admin_creer_tournoi.php"
class=
"btn2 btn2-success"
>
Créer un tournoi
</a>
</div>
<?php
endif
;
?>
</div>
</main>
<!-- Afficher le bouton uniquement si l'utilisateur est administrateur -->
<?php
if
(
isset
(
$_SESSION
[
'user'
][
'statut'
])
&&
$_SESSION
[
'user'
][
'statut'
]
===
'ADMINISTRATEUR'
)
:
?>
<div
class=
"create-button-container"
>
<a
href=
"admin_creer_tournoi.php"
class=
"btn2 btn2-success"
>
Créer un tournoi
</a>
</div>
<?php
endif
;
?>
</div>
</main>
<?php
include
'../includes/footer.php'
;
?>
<?php
include
'../includes/footer.php'
;
?>
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment