Compare commits
12 Commits
main
...
bdc3e430b6
| Author | SHA1 | Date | |
|---|---|---|---|
| bdc3e430b6 | |||
| 5dad311827 | |||
| 09e55a2b28 | |||
| cf7a51459c | |||
| 6451778bb8 | |||
| 11386eed58 | |||
| a8f617fa83 | |||
| ca49c90ffa | |||
| d82343a051 | |||
| d5c03b6d86 | |||
| 43e09b46ec | |||
| 6dd596e7b3 |
@@ -3,7 +3,7 @@
|
|||||||
<body>
|
<body>
|
||||||
<?php
|
<?php
|
||||||
echo "<h1>hello world !!!</h1>";
|
echo "<h1>hello world !!!</h1>";
|
||||||
//phpinfo();
|
phpinfo();
|
||||||
?>
|
?>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ $clients = [
|
|||||||
"Arnaud"
|
"Arnaud"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
var_dump($clients);
|
||||||
|
|
||||||
$produits = [
|
$produits = [
|
||||||
20 => "Chemise",
|
20 => "Chemise",
|
||||||
3 => "Pantalon",
|
3 => "Pantalon",
|
||||||
@@ -23,4 +25,27 @@ print_r($clients);
|
|||||||
print_r($produits);
|
print_r($produits);
|
||||||
print_r($array);
|
print_r($array);
|
||||||
echo "</pre>";
|
echo "</pre>";
|
||||||
|
|
||||||
|
// Exercice 2.1
|
||||||
|
$tab = [];
|
||||||
|
$somme = 0;
|
||||||
|
for ($i = 0; $i < 10; $i++) {
|
||||||
|
$somme += $i; // somme des entiers de 0 à i
|
||||||
|
$tab[$i] = $somme; // la clé i contient cette somme
|
||||||
|
}
|
||||||
|
print_r($tab);
|
||||||
|
|
||||||
|
|
||||||
|
// Exercice 2.2
|
||||||
|
for ($debut = 1; $debut <= 50; $debut += 10) {
|
||||||
|
echo "<p>";
|
||||||
|
for ($i = $debut; $i < $debut + 10; $i++) {
|
||||||
|
if ($i % 2 === 0) {
|
||||||
|
echo "<strong>$i</strong> ";
|
||||||
|
} else {
|
||||||
|
echo "<em>$i</em> ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo "</p>";
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
include './include/data.inc.php';
|
include_once './include/data.inc.php';
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="fr">
|
<html lang="fr">
|
||||||
@@ -28,9 +28,26 @@ include './include/data.inc.php';
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
<?php include_once './include/data.inc.php'; ?>
|
||||||
|
<?php foreach ($data as $person) : ?>
|
||||||
|
<?php
|
||||||
|
$poids = (float) $person['Poids'];
|
||||||
|
$tailleM = (float) $person['Taille'] / 100;
|
||||||
|
|
||||||
<!-- À compléter -->
|
$imc = null;
|
||||||
|
if ($tailleM > 0) {
|
||||||
|
$imc = $poids / ($tailleM * $tailleM);
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<tr class="<?= $imc < 18.5 ? 'underweight' : ($imc < 25 ? 'normal' : 'warning') ?>">
|
||||||
|
<td><?= $person['Nom'] ?></td>
|
||||||
|
<td><?= $person['Prenom'] ?></td>
|
||||||
|
<td><?= $person['Email'] ?></td>
|
||||||
|
<td><?= $person['Taille'] ?></td>
|
||||||
|
<td><?= $person['Poids'] ?></td>
|
||||||
|
<td><?= round($imc, 2) ?></td>
|
||||||
|
</tr>
|
||||||
|
<?php endforeach; ?>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</main>
|
</main>
|
||||||
|
|||||||
@@ -1,3 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
// Generate random values for two six-sided dice.
|
||||||
|
$die1 = mt_rand(1, 6);
|
||||||
|
$die2 = mt_rand(1, 6);
|
||||||
|
$sum = $die1 + $die2;
|
||||||
|
|
||||||
|
// Map dice values to matching SVG filenames.
|
||||||
|
$diceImages = [
|
||||||
|
1 => 'dice-six-faces-one.svg',
|
||||||
|
2 => 'dice-six-faces-two.svg',
|
||||||
|
3 => 'dice-six-faces-three.svg',
|
||||||
|
4 => 'dice-six-faces-four.svg',
|
||||||
|
5 => 'dice-six-faces-five.svg',
|
||||||
|
6 => 'dice-six-faces-six.svg',
|
||||||
|
];
|
||||||
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="fr">
|
<html lang="fr">
|
||||||
<head>
|
<head>
|
||||||
@@ -13,12 +29,12 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<main>
|
<main>
|
||||||
<h5><a href=""> Tirage aléatoire</a></h5>
|
<h5><a href="./">Tirage aléatoire</a></h5>
|
||||||
<article class="is-center">
|
<article class="is-center">
|
||||||
<img src='./img/dice-six-faces-five.svg'>
|
<img src="./img/<?= $diceImages[$die1] ?>" alt="Dé 1 : <?= $die1 ?>">
|
||||||
<img src='./img/dice-six-faces-one.svg'>
|
<img src="./img/<?= $diceImages[$die2] ?>" alt="Dé 2 : <?= $die2 ?>">
|
||||||
</article>
|
</article>
|
||||||
<h5>Somme = </h5>
|
<h5>Somme = <?= $sum ?></h5>
|
||||||
</main>
|
</main>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
include './include/favoris.inc.php';
|
include_once './include/favoris.inc.php';
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="fr">
|
<html lang="fr">
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
include './include/fonction.php';
|
include_once './include/fonction.php';
|
||||||
$alphabet = "@#!*^&azertyuiopqsdfghjkklmwxcvbnAZERTYUIOPLMKJHGFDSQWXCVBN1234567890";
|
$alphabet = "@#!*^&azertyuiopqsdfghjkklmwxcvbnAZERTYUIOPLMKJHGFDSQWXCVBN1234567890";
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
include 'include/controller.php';
|
include_once 'include/controller.php';
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
|
||||||
|
<html lang="fr">
|
||||||
<head>
|
<head>
|
||||||
<link
|
<link
|
||||||
rel="stylesheet"
|
rel="stylesheet"
|
||||||
@@ -11,14 +12,14 @@ include 'include/controller.php';
|
|||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css" integrity="sha512-SnH5WK+bZxgPHs44uWIX+LLJAJ9/2PkPKZ5QiAj6Ta86w+fsb2TkcmfRyVX3pBnMFcV7oQPJkl9QevSCWr3W6A==" crossorigin="anonymous" referrerpolicy="no-referrer" />
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css" integrity="sha512-SnH5WK+bZxgPHs44uWIX+LLJAJ9/2PkPKZ5QiAj6Ta86w+fsb2TkcmfRyVX3pBnMFcV7oQPJkl9QevSCWr3W6A==" crossorigin="anonymous" referrerpolicy="no-referrer" />
|
||||||
<link rel="stylesheet" href="./css/style.css">
|
<link rel="stylesheet" href="./css/style.css">
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<title></title>
|
<title>Exercice 1</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<main>
|
<main>
|
||||||
<ul>
|
<ul>
|
||||||
<?php
|
<?php
|
||||||
echo "<li>$prenom $nom</li>";
|
echo '<li>' . htmlspecialchars($prenom . ' ' . $nom, ENT_QUOTES, 'UTF-8') . '</li>';
|
||||||
echo "<li><i class='fa-brands $icon fa-2x'></i></li>";
|
echo '<li>' . htmlspecialchars($systeme, ENT_QUOTES, 'UTF-8') . " <i class='fa-brands $icon fa-2x'></i></li>";
|
||||||
?>
|
?>
|
||||||
</ul>
|
</ul>
|
||||||
</main>
|
</main>
|
||||||
|
|||||||
@@ -1,2 +1,27 @@
|
|||||||
<?php
|
<?php
|
||||||
// TODO
|
|
||||||
|
$nom = '';
|
||||||
|
$prenom = '';
|
||||||
|
$systeme = '';
|
||||||
|
$icon = 'fa-circle-question';
|
||||||
|
|
||||||
|
$systemes = [
|
||||||
|
1 => ['nom' => 'Linux', 'icon' => 'fa-linux'],
|
||||||
|
2 => ['nom' => 'Windows', 'icon' => 'fa-windows'],
|
||||||
|
3 => ['nom' => 'macOS', 'icon' => 'fa-apple'],
|
||||||
|
4 => ['nom' => 'Android', 'icon' => 'fa-android'],
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
|
$nomSaisi = trim((string) filter_input(INPUT_POST, 'nom', FILTER_UNSAFE_RAW));
|
||||||
|
$prenomSaisi = trim((string) filter_input(INPUT_POST, 'prenom', FILTER_UNSAFE_RAW));
|
||||||
|
$os = filter_input(INPUT_POST, 'os', FILTER_VALIDATE_INT);
|
||||||
|
|
||||||
|
$nom = ucfirst(strtolower($nomSaisi));
|
||||||
|
$prenom = ucfirst(strtolower($prenomSaisi));
|
||||||
|
|
||||||
|
if (isset($systemes[$os])) {
|
||||||
|
$systeme = $systemes[$os]['nom'];
|
||||||
|
$icon = $systemes[$os]['icon'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,2 +1,21 @@
|
|||||||
<?php
|
<?php
|
||||||
// TODO
|
|
||||||
|
$table = filter_input(INPUT_GET, 'table', FILTER_VALIDATE_INT);
|
||||||
|
$tableSaisie = filter_input(INPUT_GET, 'table', FILTER_UNSAFE_RAW);
|
||||||
|
$tableSaisie = is_string($tableSaisie) ? trim($tableSaisie) : '';
|
||||||
|
|
||||||
|
$lignes = [];
|
||||||
|
$messageErreur = '';
|
||||||
|
|
||||||
|
if ($tableSaisie !== '') {
|
||||||
|
if ($table === false || $table === null) {
|
||||||
|
$messageErreur = 'Veuillez saisir un entier valide.';
|
||||||
|
} else {
|
||||||
|
for ($multiplicateur = 1; $multiplicateur <= 10; $multiplicateur++) {
|
||||||
|
$lignes[] = [
|
||||||
|
'multiplicateur' => $multiplicateur,
|
||||||
|
'resultat' => $table * $multiplicateur,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
include 'include/controller.php';
|
include_once 'include/controller.php';
|
||||||
?>
|
?>
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html>
|
<html lang="fr">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<link
|
<link
|
||||||
@@ -10,14 +10,38 @@ include 'include/controller.php';
|
|||||||
href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.classless.min.css"
|
href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.classless.min.css"
|
||||||
/>
|
/>
|
||||||
<link rel="stylesheet" href="./css/style.css">
|
<link rel="stylesheet" href="./css/style.css">
|
||||||
|
<title>Exercice 2</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<main>
|
<main>
|
||||||
<h4>Table de multiplication</h4>
|
<h4>Table de multiplication</h4>
|
||||||
<form method="GET">
|
<form method="GET">
|
||||||
<input type=number name="table" placeholder="table">
|
<input
|
||||||
|
type="number"
|
||||||
|
name="table"
|
||||||
|
placeholder="table"
|
||||||
|
value="<?php echo htmlspecialchars($tableSaisie, ENT_QUOTES, 'UTF-8'); ?>"
|
||||||
|
>
|
||||||
<button type="submit">ENVOYER</button>
|
<button type="submit">ENVOYER</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<?php if ($messageErreur !== '') : ?>
|
||||||
|
<p><?php echo htmlspecialchars($messageErreur, ENT_QUOTES, 'UTF-8'); ?></p>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<?php if ($table !== false && $table !== null) : ?>
|
||||||
|
<ul>
|
||||||
|
<?php foreach ($lignes as $ligne) : ?>
|
||||||
|
<li>
|
||||||
|
<?php echo htmlspecialchars((string) $table, ENT_QUOTES, 'UTF-8'); ?>
|
||||||
|
x
|
||||||
|
<?php echo htmlspecialchars((string) $ligne['multiplicateur'], ENT_QUOTES, 'UTF-8'); ?>
|
||||||
|
=
|
||||||
|
<?php echo htmlspecialchars((string) $ligne['resultat'], ENT_QUOTES, 'UTF-8'); ?>
|
||||||
|
</li>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</ul>
|
||||||
|
<?php endif; ?>
|
||||||
</main>
|
</main>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
include 'include/controller.php';
|
include_once 'include/controller.php';
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="fr">
|
<html lang="fr">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<title></title>
|
<title>Exercice 3</title>
|
||||||
<link
|
<link
|
||||||
rel="stylesheet"
|
rel="stylesheet"
|
||||||
href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.min.css"
|
href="https://cdn.jsdelivr.net/npm/@picocss/pico.min.css"
|
||||||
/>
|
/>
|
||||||
<link rel="stylesheet" href="./css/style.css">
|
<link rel="stylesheet" href="./css/style.css">
|
||||||
</head>
|
</head>
|
||||||
@@ -18,17 +18,42 @@ include 'include/controller.php';
|
|||||||
<h3>Calculatrice</h3>
|
<h3>Calculatrice</h3>
|
||||||
<form method="POST">
|
<form method="POST">
|
||||||
<div class="grid">
|
<div class="grid">
|
||||||
<input placeholder="un nombre" type="number" step="any" name="op1" value ="" required>
|
<input
|
||||||
|
placeholder="un nombre"
|
||||||
|
type="number"
|
||||||
|
step="any"
|
||||||
|
name="op1"
|
||||||
|
value="<?php echo htmlspecialchars($valeurOp1, ENT_QUOTES, 'UTF-8'); ?>"
|
||||||
|
required
|
||||||
|
>
|
||||||
<select name="operation" required>
|
<select name="operation" required>
|
||||||
<option value="+">+</option>
|
<option value="+" <?php echo $operation === '+' ? 'selected' : ''; ?>>+</option>
|
||||||
<option value="-">-</option>
|
<option value="-" <?php echo $operation === '-' ? 'selected' : ''; ?>>-</option>
|
||||||
<option value="x">x</option>
|
<option value="x" <?php echo $operation === 'x' ? 'selected' : ''; ?>>x</option>
|
||||||
<option value="/">/</option>
|
<option value="/" <?php echo $operation === '/' ? 'selected' : ''; ?>>/</option>
|
||||||
</select>
|
</select>
|
||||||
<input placeholder="un nombre" type="number" step="any" name="op2" required>
|
<input
|
||||||
|
placeholder="un nombre"
|
||||||
|
type="number"
|
||||||
|
step="any"
|
||||||
|
name="op2"
|
||||||
|
value="<?php echo htmlspecialchars($valeurOp2, ENT_QUOTES, 'UTF-8'); ?>"
|
||||||
|
required
|
||||||
|
>
|
||||||
<button type="submit" name="soumis">Calculer</button>
|
<button type="submit" name="soumis">Calculer</button>
|
||||||
</grid>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<?php if ($messageErreur !== '') : ?>
|
||||||
|
<p><?php echo htmlspecialchars($messageErreur, ENT_QUOTES, 'UTF-8'); ?></p>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<?php if ($aCalcule) : ?>
|
||||||
|
<p>
|
||||||
|
Résultat :
|
||||||
|
<?php echo htmlspecialchars($valeurOp1, ENT_QUOTES, 'UTF-8'); ?>
|
||||||
|
</p>
|
||||||
|
<?php endif; ?>
|
||||||
</main>
|
</main>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -1,2 +1,56 @@
|
|||||||
<?php
|
<?php
|
||||||
//TODO
|
|
||||||
|
$op1Saisi = filter_input(INPUT_POST, 'op1', FILTER_UNSAFE_RAW);
|
||||||
|
$op2Saisi = filter_input(INPUT_POST, 'op2', FILTER_UNSAFE_RAW);
|
||||||
|
$operationSaisie = filter_input(INPUT_POST, 'operation', FILTER_UNSAFE_RAW);
|
||||||
|
|
||||||
|
$op1Saisi = is_string($op1Saisi) ? trim($op1Saisi) : '';
|
||||||
|
$op2Saisi = is_string($op2Saisi) ? trim($op2Saisi) : '';
|
||||||
|
$operationSaisie = is_string($operationSaisie) ? trim($operationSaisie) : '+';
|
||||||
|
|
||||||
|
$operationsAutorisees = ['+', '-', 'x', '/'];
|
||||||
|
$operation = in_array($operationSaisie, $operationsAutorisees, true) ? $operationSaisie : '+';
|
||||||
|
|
||||||
|
$resultat = null;
|
||||||
|
$messageErreur = '';
|
||||||
|
$aCalcule = false;
|
||||||
|
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
|
$op1 = filter_var($op1Saisi, FILTER_VALIDATE_FLOAT);
|
||||||
|
$op2 = filter_var($op2Saisi, FILTER_VALIDATE_FLOAT);
|
||||||
|
|
||||||
|
if ($op1 === false || $op2 === false) {
|
||||||
|
$messageErreur = 'Veuillez saisir deux nombres valides.';
|
||||||
|
} elseif (!in_array($operation, $operationsAutorisees, true)) {
|
||||||
|
$messageErreur = 'Veuillez choisir une opération valide.';
|
||||||
|
} elseif ($operation === '/' && (float) $op2 == 0.0) {
|
||||||
|
$messageErreur = 'La division par zéro est impossible.';
|
||||||
|
} else {
|
||||||
|
$aCalcule = true;
|
||||||
|
|
||||||
|
switch ($operation) {
|
||||||
|
case '+':
|
||||||
|
$resultat = $op1 + $op2;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '-':
|
||||||
|
$resultat = $op1 - $op2;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'x':
|
||||||
|
$resultat = $op1 * $op2;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '/':
|
||||||
|
$resultat = $op1 / $op2;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
$messageErreur = 'Veuillez choisir une opération valide.';
|
||||||
|
$aCalcule = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$valeurOp1 = $aCalcule ? (string) $resultat : $op1Saisi;
|
||||||
|
$valeurOp2 = $op2Saisi;
|
||||||
|
|||||||
@@ -2,3 +2,13 @@ button{
|
|||||||
|
|
||||||
float:right;
|
float:right;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.bonne-reponse {
|
||||||
|
color: #1b7f3a;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mauvaise-reponse {
|
||||||
|
color: #c62828;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,17 +1,81 @@
|
|||||||
|
<?php
|
||||||
|
$nombreQuestions = 0;
|
||||||
|
$score = 0;
|
||||||
|
$questionsTraitees = 0;
|
||||||
|
$message = 'Aucun resultat a afficher.';
|
||||||
|
$resultatsParQuestion = [];
|
||||||
|
|
||||||
|
$nombreQuestionsSaisi = filter_input(INPUT_POST, 'nbq', FILTER_VALIDATE_INT);
|
||||||
|
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] === 'POST' && $nombreQuestionsSaisi !== false && $nombreQuestionsSaisi !== null) {
|
||||||
|
$nombreQuestions = $nombreQuestionsSaisi;
|
||||||
|
$message = '';
|
||||||
|
|
||||||
|
for ($index = 1; $index <= $nombreQuestions; $index++) {
|
||||||
|
$reponse = filter_input(INPUT_POST, 'question' . $index, FILTER_UNSAFE_RAW);
|
||||||
|
|
||||||
|
if ($reponse !== null) {
|
||||||
|
$questionsTraitees++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($reponse === 'vrai') {
|
||||||
|
$score++;
|
||||||
|
$resultatsParQuestion[] = [
|
||||||
|
'numero' => $index,
|
||||||
|
'classe' => 'bonne-reponse',
|
||||||
|
'message' => 'Bonne reponse',
|
||||||
|
];
|
||||||
|
} else {
|
||||||
|
$resultatsParQuestion[] = [
|
||||||
|
'numero' => $index,
|
||||||
|
'classe' => 'mauvaise-reponse',
|
||||||
|
'message' => 'Mauvaise reponse',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="fr">
|
||||||
<head>
|
<head>
|
||||||
<link rel="stylesheet" href="./css/style.css">
|
<link rel="stylesheet" href="./css/style.css">
|
||||||
<link
|
<link
|
||||||
rel="stylesheet"
|
rel="stylesheet"
|
||||||
href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.classless.min.css"
|
href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.classless.min.css"
|
||||||
/>
|
/>
|
||||||
<title></title>
|
<meta charset="UTF-8" />
|
||||||
|
<title>Exercice 4</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<main>
|
<main>
|
||||||
<h4>Réponses</h4>
|
<h4>Resultat du quizz</h4>
|
||||||
</div>
|
<?php if ($message !== '') : ?>
|
||||||
|
<p><?php echo htmlspecialchars($message, ENT_QUOTES, 'UTF-8'); ?></p>
|
||||||
|
<?php else : ?>
|
||||||
|
<p>
|
||||||
|
Vous avez obtenu
|
||||||
|
<?php echo htmlspecialchars((string) $score, ENT_QUOTES, 'UTF-8'); ?>
|
||||||
|
bonne(s) reponse(s) sur
|
||||||
|
<?php echo htmlspecialchars((string) $nombreQuestions, ENT_QUOTES, 'UTF-8'); ?>.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Questions repondues :
|
||||||
|
<?php echo htmlspecialchars((string) $questionsTraitees, ENT_QUOTES, 'UTF-8'); ?>.
|
||||||
|
</p>
|
||||||
|
<ul>
|
||||||
|
<?php foreach ($resultatsParQuestion as $resultatQuestion) : ?>
|
||||||
|
<li>
|
||||||
|
Question <?php echo htmlspecialchars((string) $resultatQuestion['numero'], ENT_QUOTES, 'UTF-8'); ?> :
|
||||||
|
<span class="<?php echo htmlspecialchars($resultatQuestion['classe'], ENT_QUOTES, 'UTF-8'); ?>">
|
||||||
|
<?php echo htmlspecialchars($resultatQuestion['message'], ENT_QUOTES, 'UTF-8'); ?>
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</ul>
|
||||||
|
<?php endif; ?>
|
||||||
|
<p>
|
||||||
|
<a href="quizz.html">Revenir au quizz</a>
|
||||||
|
</p>
|
||||||
</main>
|
</main>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
include 'include/controller.php';
|
include_once 'include/controller.php';
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="fr">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<link
|
<link
|
||||||
@@ -11,13 +11,35 @@ include 'include/controller.php';
|
|||||||
href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.classless.min.css"
|
href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.classless.min.css"
|
||||||
/>
|
/>
|
||||||
<link rel="stylesheet" href="./css/style.css">
|
<link rel="stylesheet" href="./css/style.css">
|
||||||
|
<title>Exercice 5</title>
|
||||||
<title></title>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<main>
|
<main>
|
||||||
|
<h3>Conjugaison</h3>
|
||||||
|
|
||||||
|
<?php if ($messageErreur !== '') : ?>
|
||||||
|
<p><?php echo htmlspecialchars($messageErreur, ENT_QUOTES, 'UTF-8'); ?></p>
|
||||||
|
<?php else : ?>
|
||||||
|
<p>
|
||||||
|
Verbe :
|
||||||
|
<?php echo htmlspecialchars($verbe, ENT_QUOTES, 'UTF-8'); ?>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<?php foreach ($conjugaisons as $conjugaison) : ?>
|
||||||
|
<section>
|
||||||
|
<h4><?php echo htmlspecialchars($conjugaison['temps'], ENT_QUOTES, 'UTF-8'); ?></h4>
|
||||||
|
<ul>
|
||||||
|
<?php foreach ($conjugaison['formes'] as $forme) : ?>
|
||||||
|
<li><?php echo htmlspecialchars($forme, ENT_QUOTES, 'UTF-8'); ?></li>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</ul>
|
||||||
|
</section>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<a href="ex5.html">Retour au formulaire</a>
|
||||||
|
</p>
|
||||||
</main>
|
</main>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -1,12 +1,64 @@
|
|||||||
<?php
|
<?php
|
||||||
$terminaisons = array(
|
$terminaisons = array(
|
||||||
"present"=>array("e","es","e","ons","ez","ent"),
|
'present' => array('e', 'es', 'e', 'ons', 'ez', 'ent'),
|
||||||
"futur"=>array("erai","eras","era","erons","erez","eront"),
|
'futur' => array('erai', 'eras', 'era', 'erons', 'erez', 'eront'),
|
||||||
"imparfait"=>array("ais","ais","ait","ions","iez","aient")
|
'imparfait' => array('ais', 'ais', 'ait', 'ions', 'iez', 'aient')
|
||||||
);
|
);
|
||||||
|
|
||||||
$pronoms=array("je","tu","il","nous","vous","ils");
|
$libellesTemps = array(
|
||||||
|
'present' => 'Present',
|
||||||
|
'futur' => 'Futur',
|
||||||
|
'imparfait' => 'Imparfait'
|
||||||
|
);
|
||||||
|
|
||||||
$verbe = filter_input(INPUT_POST,"verbe",FILTER_SANITIZE_STRING);
|
$pronoms = array('je', 'tu', 'il', 'nous', 'vous', 'ils');
|
||||||
|
|
||||||
|
$verbeSaisi = filter_input(INPUT_POST, 'verbe', FILTER_UNSAFE_RAW);
|
||||||
|
$verbeSaisi = is_string($verbeSaisi) ? trim($verbeSaisi) : '';
|
||||||
|
$verbe = strtolower($verbeSaisi);
|
||||||
|
|
||||||
|
$tempsChoisis = filter_input(INPUT_POST, 'temps', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
|
||||||
|
$tempsChoisis = is_array($tempsChoisis) ? $tempsChoisis : array();
|
||||||
|
|
||||||
|
$messageErreur = '';
|
||||||
|
$conjugaisons = array();
|
||||||
|
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
|
if ($verbe === '') {
|
||||||
|
$messageErreur = 'Veuillez saisir un verbe.';
|
||||||
|
} elseif (strlen($verbe) < 3 || substr($verbe, -2) !== 'er') {
|
||||||
|
$messageErreur = 'Veuillez saisir un verbe du premier groupe.';
|
||||||
|
} elseif ($tempsChoisis === array()) {
|
||||||
|
$messageErreur = 'Veuillez choisir au moins un temps.';
|
||||||
|
} else {
|
||||||
$radical = substr($verbe, 0, strlen($verbe) - 2);
|
$radical = substr($verbe, 0, strlen($verbe) - 2);
|
||||||
|
|
||||||
|
foreach ($tempsChoisis as $temps) {
|
||||||
|
if (!isset($terminaisons[$temps], $libellesTemps[$temps])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$formes = array();
|
||||||
|
|
||||||
|
foreach ($pronoms as $index => $pronom) {
|
||||||
|
$forme = $radical . $terminaisons[$temps][$index];
|
||||||
|
|
||||||
|
if ($pronom === 'je' && preg_match('/^[aeiouh]/', $forme) === 1) {
|
||||||
|
$formes[] = "j'" . $forme;
|
||||||
|
} else {
|
||||||
|
$formes[] = $pronom . ' ' . $forme;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$conjugaisons[] = array(
|
||||||
|
'temps' => $libellesTemps[$temps],
|
||||||
|
'formes' => $formes
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($conjugaisons === array()) {
|
||||||
|
$messageErreur = 'Aucun temps valide n a ete transmis.';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,3 +8,6 @@ color:#2E8B57;
|
|||||||
.Loss{
|
.Loss{
|
||||||
color:#FF6347;
|
color:#FF6347;
|
||||||
}
|
}
|
||||||
|
.Draw{
|
||||||
|
color:#DAA520;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,20 +1,31 @@
|
|||||||
<?php
|
<?php
|
||||||
$images = ["rock.png", "paper.png", "scissors.png"];
|
$images = ["rock.png", "paper.png", "scissors.png"];
|
||||||
$isPlaying = true;
|
$rules = [
|
||||||
|
0 => [0 => "Draw", 1 => "Loss", 2 => "Win"],
|
||||||
|
1 => [0 => "Win", 1 => "Draw", 2 => "Loss"],
|
||||||
|
2 => [0 => "Loss", 1 => "Win", 2 => "Draw"],
|
||||||
|
];
|
||||||
|
|
||||||
$playerChoice = 0;
|
$playerChoice = filter_input(
|
||||||
$computerChoice = 1;
|
INPUT_GET,
|
||||||
|
'choice',
|
||||||
|
FILTER_VALIDATE_INT,
|
||||||
|
['options' => ['min_range' => 0, 'max_range' => 2]]
|
||||||
|
);
|
||||||
|
|
||||||
$message = "Win";
|
$isPlaying = ($playerChoice !== null && $playerChoice !== false);
|
||||||
$class = "Win";
|
|
||||||
|
|
||||||
|
if ($isPlaying) {
|
||||||
|
$computerChoice = mt_rand(0, 2);
|
||||||
|
$message = $rules[$playerChoice][$computerChoice];
|
||||||
|
$class = $message;
|
||||||
$imagePlayer = $images[$playerChoice];
|
$imagePlayer = $images[$playerChoice];
|
||||||
$imageComputer = $images[$computerChoice];
|
$imageComputer = $images[$computerChoice];
|
||||||
|
|
||||||
include './views/header.php';
|
|
||||||
if ($isPlaying){
|
|
||||||
include './views/game.php';
|
|
||||||
include './views/message.php';
|
|
||||||
}
|
}
|
||||||
include './views/footer.php';
|
|
||||||
?>
|
include_once './views/header.php';
|
||||||
|
if ($isPlaying) {
|
||||||
|
include_once './views/game.php';
|
||||||
|
include_once './views/message.php';
|
||||||
|
}
|
||||||
|
include_once './views/footer.php';
|
||||||
|
|||||||
@@ -1,14 +1,37 @@
|
|||||||
<?php
|
<?php
|
||||||
include './modeles/modeleFilms.php';
|
include_once './modeles/modeleFilms.php';
|
||||||
|
|
||||||
$films = getFilms();
|
$currentPage = filter_input(
|
||||||
|
INPUT_GET,
|
||||||
|
'page',
|
||||||
|
FILTER_VALIDATE_INT,
|
||||||
|
['options' => ['min_range' => 1]]
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($currentPage === null || $currentPage === false) {
|
||||||
|
$currentPage = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$perPage = 10;
|
||||||
|
$data = getFilms($currentPage, $perPage);
|
||||||
|
$films = $data['films'];
|
||||||
|
$errorMessage = $data['error'];
|
||||||
|
$totalFilms = $data['total'];
|
||||||
|
$totalPages = max(1, (int) ceil($totalFilms / $perPage));
|
||||||
|
|
||||||
|
if ($currentPage > $totalPages && $totalFilms > 0) {
|
||||||
|
$currentPage = $totalPages;
|
||||||
|
$data = getFilms($currentPage, $perPage);
|
||||||
|
$films = $data['films'];
|
||||||
|
$errorMessage = $data['error'];
|
||||||
|
$totalFilms = $data['total'];
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// on "charge" la vue
|
// on "charge" la vue
|
||||||
//
|
//
|
||||||
|
|
||||||
include './vues/header.php';
|
include_once './vues/header.php';
|
||||||
include './vues/vueFilms.php';
|
include_once './vues/vueFilms.php';
|
||||||
include './vues/footer.php';
|
include_once './vues/footer.php';
|
||||||
?>
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,69 @@
|
|||||||
<?php
|
<?php
|
||||||
function _getConnection()
|
function getConnection()
|
||||||
{
|
{
|
||||||
static $_conn = NULL;
|
static $conn = null;
|
||||||
if ($_conn === NULL){
|
|
||||||
$_conn = mysqli_connect("localhost","","","");
|
if ($conn === null) {
|
||||||
|
$host = getenv('DB_HOST') ?: 'https://dwarves.iut-fbleau.fr';
|
||||||
|
$login = getenv('DB_USER') ?: getenv('USER') ?: getenv('USERNAME') ?: 'root';
|
||||||
|
$password = getenv('DB_PASSWORD') ?: $login;
|
||||||
|
$database = getenv('DB_NAME') ?: $login;
|
||||||
|
$conn = mysqli_connect($host, $login, $password, $database);
|
||||||
|
|
||||||
|
if ($conn !== false) {
|
||||||
|
mysqli_set_charset($conn, 'utf8mb4');
|
||||||
}
|
}
|
||||||
return $_conn;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $conn;
|
||||||
|
}
|
||||||
|
|
||||||
function getFilms()
|
function getFilms($page = 1, $perPage = 10)
|
||||||
{
|
{
|
||||||
// A completer
|
$conn = getConnection();
|
||||||
|
if ($conn === false) {
|
||||||
|
return [
|
||||||
|
'films' => [],
|
||||||
|
'total' => 0,
|
||||||
|
'error' => 'Connexion MySQL impossible.',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$page = max(1, (int) $page);
|
||||||
|
$perPage = max(1, (int) $perPage);
|
||||||
|
$offset = ($page - 1) * $perPage;
|
||||||
|
|
||||||
|
$sql = "SELECT SQL_CALC_FOUND_ROWS
|
||||||
|
F.idFilm,
|
||||||
|
F.titre,
|
||||||
|
F.annee,
|
||||||
|
G.code AS genre,
|
||||||
|
A.prenom,
|
||||||
|
A.nom
|
||||||
|
FROM Film AS F
|
||||||
|
INNER JOIN Artiste AS A ON F.idMes = A.idArtiste
|
||||||
|
INNER JOIN Genre AS G ON F.genre = G.code
|
||||||
|
ORDER BY F.titre ASC
|
||||||
|
LIMIT {$offset}, {$perPage}";
|
||||||
|
|
||||||
|
$result = mysqli_query($conn, $sql);
|
||||||
|
if ($result === false) {
|
||||||
|
return [
|
||||||
|
'films' => [],
|
||||||
|
'total' => 0,
|
||||||
|
'error' => 'Exécution de la requête impossible.',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$films = mysqli_fetch_all($result, MYSQLI_ASSOC);
|
||||||
|
|
||||||
|
$totalResult = mysqli_query($conn, 'SELECT FOUND_ROWS() AS total');
|
||||||
|
$totalRow = $totalResult ? mysqli_fetch_assoc($totalResult) : ['total' => 0];
|
||||||
|
$total = isset($totalRow['total']) ? (int) $totalRow['total'] : 0;
|
||||||
|
|
||||||
|
return [
|
||||||
|
'films' => $films,
|
||||||
|
'total' => $total,
|
||||||
|
'error' => null,
|
||||||
|
];
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|||||||
@@ -4,6 +4,9 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<h2>Films</h2>
|
<h2>Films</h2>
|
||||||
|
<?php if (!empty($errorMessage)) { ?>
|
||||||
|
<article><?php echo htmlspecialchars($errorMessage, ENT_QUOTES, 'UTF-8'); ?></article>
|
||||||
|
<?php } ?>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -16,17 +19,46 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
<?php
|
<?php
|
||||||
foreach ($films as $film) {
|
foreach ($films as $film) {
|
||||||
|
$titre = htmlspecialchars($film['titre'], ENT_QUOTES, 'UTF-8');
|
||||||
|
$annee = htmlspecialchars((string) $film['annee'], ENT_QUOTES, 'UTF-8');
|
||||||
|
$genre = htmlspecialchars($film['genre'], ENT_QUOTES, 'UTF-8');
|
||||||
|
$realisateur = htmlspecialchars($film['prenom'] . ' ' . $film['nom'], ENT_QUOTES, 'UTF-8');
|
||||||
|
|
||||||
echo "
|
echo "
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href='#'>{$film['titre']}</a></td>
|
<td><a href='#'>{$titre}</a></td>
|
||||||
<td>{$film['annee']}</td>
|
<td>{$annee}</td>
|
||||||
<td>{$film['genre']}</td>
|
<td>{$genre}</td>
|
||||||
<td>{$film['prenom']} {$film['nom']}</td>
|
<td>{$realisateur}</td>
|
||||||
</tr>";
|
</tr>";
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
<?php if ($totalPages > 1) { ?>
|
||||||
|
<nav>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<?php if ($currentPage > 1) { ?>
|
||||||
|
<a href="?page=<?php echo $currentPage - 1; ?>">Précédent</a>
|
||||||
|
<?php } else { ?>
|
||||||
|
<span>Précédent</span>
|
||||||
|
<?php } ?>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<ul>
|
||||||
|
<li>Page <?php echo $currentPage; ?> / <?php echo $totalPages; ?></li>
|
||||||
|
</ul>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<?php if ($currentPage < $totalPages) { ?>
|
||||||
|
<a href="?page=<?php echo $currentPage + 1; ?>">Suivant</a>
|
||||||
|
<?php } else { ?>
|
||||||
|
<span>Suivant</span>
|
||||||
|
<?php } ?>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user