<script>changerTitre²("Lister les mots interdits");</script>
<h1>Liste des mots interdits enregistrés </h1>
<?php 
if (!isConnected() || !getPersonneConnectee()->isPerAdmin()) {
    throw new ExceptionPerso("Vous n'avez pas les droits pour afficher cette page !", ExceptionPerso::ERR_DROITS);
}
$pdo = new Mypdo();
$motManager = new MotManager($pdo);
$mots = $motManager->getAllMotsObjets();
?>

<?php 
if (!isset($_GET["mot_id"])) {
    ?>
  <?php 
    if (count($mots) == 0) {
        ?>
 <h2>Aucun mot n'est enregistré !</h2>
    <img src="image/no-result.jpg" alt="Pas de résultat !"/><?php 
    } else {
        ?>
    <p>Il y a actuellement <?php 
        echo count($mots);
        ?>
 mot(s) enregistré(s).</p>

    <table class="sortable">
      <tr>
        <th>Numero</th>
        <th>Mot</th>
        <th>Modifier</th>
<?php

if (!isConnected() || !getPersonneConnectee()->isPerAdmin()) {
    throw new ExceptionPerso("Vous n'avez pas les droits pour afficher cette page !", ExceptionPerso::ERR_DROITS);
}
?>

<script>changerTitre("Ajouter un mot interdit");</script>
<h1> Ajouter un mot interdit </h1>

<?php 
if (empty($_POST)) {
    include "include/pages/form/ajouterMotInterdit.form.inc.php";
} else {
    $mot = new Mot($_POST);
    $pdo = new Mypdo();
    $motManager = new MotManager($pdo);
    $retour = $motManager->add($mot);
    if ($retour != 0) {
        afficherMessageSucces("Mot ajouté ! ");
        redirection(1, LISTER_MOTS_INTERDITS);
    } else {
        afficherMessageErreur("Erreur lors de l'ajout du mot..");
        redirection(5, LISTER_MOTS_INTERDITS);
    }
}
<script>changerTitre("Modifier un mot interdit");</script>
<h1>Modifier un mot interdit</h1>

<?php 
if (!isConnected() || !getPersonneConnectee()->isPerAdmin()) {
    throw new ExceptionPerso("Vous n'avez pas les droits pour afficher cette page !", ExceptionPerso::ERR_DROITS);
}
if (empty($_GET['mot_id']) || !is_numeric($_GET['mot_id'])) {
    throw new ExceptionPerso("Merci de ne pas modifier l'URL de la page !", ExceptionPerso::ERR_URL);
}
$pdo = new Mypdo();
$motManager = new MotManager($pdo);
$mot = $motManager->getMotById($_GET['mot_id']);
if (empty($_POST['mot_interdit'])) {
    include "include/pages/form/modifierMotInterdit.form.inc.php";
} else {
    $mot->setMotInterdit($_POST['mot_interdit']);
    $retour = $motManager->update($mot);
    if ($retour === true) {
        afficherMessageSucces("Mot mis à jour !");
        redirection(1, LISTER_MOTS_INTERDITS);
    } else {
        afficherMessageErreur("Le mot n'a pas pu être mis à jour..");
        redirection(5, LISTER_MOTS_INTERDITS);
    }
}
Пример #4
0
<?php

$db = new Mypdo();
$managerP = new PersonneManager($db);
$managerE = new EtudiantManager($db);
$managerC = new CitationManager($db);
$managerM = new MotManager($db);
//si premiere saisie de la citation
if (empty($_POST['listerEnseignants']) && empty($_POST['dateCit']) && empty($_POST['citation'])) {
    ?>
  <h1>Ajouter une citation</h1>
  <div class="divCentre" id="ajout">
    <form action="index.php?page=52" method="post" name="ajoutCit">
      <div class="texteFormulaire">
        <p>Enseignant :</p>
        <p>Date citation :</p>
        <p>Citation : </p>
      </div>

      <div class="champsFormulaire">
        <!-- liste deroulante de salaries -->
        <select class="zoneTexte" name="listerEnseignants"><?php 
    $listePersonnes = $managerP->getList();
    foreach ($listePersonnes as $personne) {
        echo "\n";
        if (!$managerE->isEtudiant($personne->getNumPers())) {
            ?>
              <option value="<?php 
            echo $personne->getNumPers();
            ?>
"><?php 
}
?>

<h1>Ajouter une citation</h1>

<?php 
if (empty($_POST['cit_libelle'])) {
    include "include/pages/form/ajouterCitation.form.inc.php";
    ?>
<br/><q><?php 
    echo getPhraseAleatoire();
    ?>
</q><?php 
} else {
    $citationManager = new CitationManager($pdo);
    $motManager = new MotManager($pdo);
    $listeMotsInterdits = $motManager->getAllMots();
    if (empty($_POST['cit_libelle'])) {
        throw new ExceptionPerso("Le contenu de la citation ne peut être vide !", ExceptionPerso::ERR_PEBCAK);
    }
    $motCitations = explode(" ", $_POST['cit_libelle']);
    $ajoutAutorise = true;
    $citationFinale = "";
    foreach ($motCitations as $mot) {
        $motclean = strtolower(clean_chaine($mot));
        if ($motManager->isMotExistant($motclean)) {
            $ajoutAutorise = false;
            $listeMotsInterditsDetectes[] = $mot;
            $citationFinale .= "---";
        } else {
            $citationFinale .= $mot;