require 'controleSaisies.php'; define('RE_ETUDIANT', "/^[0-9]{7}\$/"); // definir une RegExp bout par bout: $re = '[A-Z]\\w*'; $re = "{$re}(-{$re})*"; # Ne pas écrire "/^$re[.]", PHP fait une erreur #si on veut [.] mettre "/^" . $r . "[.]..... $re = "{$re}\\.{$re}@\\w+(\\.\\w+)*"; define('RE_MAIL_ETENDU', "/^({$re})|([^<]*<{$re}>)\$/"); $mail = saisie_fiable($_POST, 'mail', RE_MAIL_ETENDU); $num = saisie_fiable($_POST, 'numEt', RE_ETUDIANT); $title = "Etudiant"; if ($mail === True and $num === True) { $body = saisies_en_table($_POST, "Informations"); } else { if ($mail === False or $num === False) { $title = "Erreur {$title}"; $mail = $_POST['mail']; $num = $_POST['numEt']; } $body = "<form action='' method='post'><fieldset>\n" . "<label for='numEt'>Numéro d'Étudiant :</label>" . "<input id='numEt' name='numEt' value='" . htmlspecialchars($num) . "' />\n" . "<label for='mail'>Mail :</label>" . "<input id='mail' name='mail' value='" . htmlspecialchars($mail) . "' />\n" . "<input type='submit' value='Envoyer'>\n" . "</fieldset></form>\n"; } echo entete($title), "<body><h1>{$title}</h1>\n", $body, "</body></html>\n"; //test $t = array('*****@*****.**', '"c\'est moi" <*****@*****.**>', '<i>@foo.bar'); echo $t[0], ' ', saisie_fiable($t, 0, RE_MAIL_ETENDU), "\n"; echo $t[1], ' ', saisie_fiable($t, 1, RE_MAIL_ETENDU), "\n"; echo $t[2], ' ', saisie_fiable($t, 2, RE_MAIL_ETENDU), "\n"; ?>
<?php require_once '../3/controleSaisies.php'; function perm_rot($s, $p, $h, $a) { $h1 = "?s={$s}&h={$h}&p={$p}&a=" . ($a == 'all.css' ? 'all2.css' : 'all.css'); $h2 = "?s={$h}&h={$p}&p={$s}"; return "<ul>" . "<li><a href='{$h1}'>Permutation des styles</a></li>\n" . "<li><a href='{$h2}'>Rotation des périphériques</a></li>\n" . "</ul>\n"; } // Eviter les caracteres problematique pour HTML mais aussi Unix define('RE_FICHIER', '/^[^<>"\'\\/&]+$/'); // La fonction saisie_fiable retourne True ou False $s = saisie_fiable($_GET, 's', RE_FICHIER) ? $_GET['s'] : 'screen.css'; $h = saisie_fiable($_GET, 'h', RE_FICHIER) ? $_GET['h'] : 'handheld.css'; $p = saisie_fiable($_GET, 'p', RE_FICHIER) ? $_GET['p'] : 'print.css'; $a = saisie_fiable($_GET, 'a', RE_FICHIER) ? $_GET['a'] : ''; if ($a) { setcookie('all', $a); } else { $a = saisie_fiable($_COOKIE, 'all', RE_FICHIER, 'all.css'); } include "entete.php"; echo entete("EDT Screen: {$s}, Handheld {$h}, Print {$p}", array(array('rel' => 'stylesheet', 'href' => $a), array('rel' => 'stylesheet', 'href' => $p, 'media' => 'print'), array('rel' => 'stylesheet', 'href' => $h, 'media' => 'handheld'), array('rel' => 'stylesheet', 'href' => $s, 'media' => 'screen'))); echo "<body>\n"; echo perm_rot($s, $p, $h, $a); include 'edt.html'; echo "</body></html>\n";
<?php require_once "../TME2/entete.php"; require_once "../TD3/controleSaisies.php"; define('NOM_ENS', "/[a-zA-Z]+/"); $nom = saisie_fiable($_POST, 'nom', NOM_ENS); if ($nom == False or !is_readable($fichier = "/var/tmp/" . $_POST['nom'] . ".php")) { $title = (isset($_POST['nom']) ? "Erreur: " : "") . "Enseignement"; $body = "<form action='' method='post'><fieldset>\n" . "<label for='nomEn'>Nom d'enseignement :</label>" . "<input type='text' id='nomEn' name='nom'/>\n" . "</fieldset></form>\n"; echo entete($title), "<body><h1>{$title}</h1>\n", $body, "</body></html>\n"; } else { include 'select_groupe.php'; array_to_select($_POST['nom'], $groupes); }
<?php require_once "../TM/2/entete.php"; require_once '../TD3/controleSaisies.php'; require_once 'saisies_indexees.php'; require_once 'notesValides.php'; $nom = saisie_fiable($_POST, 'nom', '/^\\w+$/'); $groupe = saisie_fiable($_POST, 'num_groupe', '/^\\d+$/'); if ($nom == True && ($groupe = True)) { $nom = $_POST['nom']; $groupe = $_POST['num_groupe']; } else { $nom = ''; $groupe = ''; } function moyenne($notes) { $somme = 0; foreach ($notes as $note) { $somme += $note; } return $somme / count($notes); } if (!empty($_POST["notes"])) { $result = notesValides($_POST["notes"]); } $title = "Gestion de note"; if (count($result) == count($_POST["notes"])) { echo entete($title); echo "<body><h1>", $title, "</h1>"; echo "<div>Moyenne obtenue : ", moyenne($result), "</div>";