diff --git a/TODO b/TODO index 86764c2..b2254ea 100644 --- a/TODO +++ b/TODO @@ -4,9 +4,12 @@ # # #=====================================================# +-> Display on #epitagueule the new questions + and the rejected questions (using the ID) + + +<==================== DONE ===========================> -> Multiple possible answer -> Send email for confirmation -> One answer / one word -> Special ID for a question --> Display on #epitagueule the new questions - and the rejected questions (using the ID) diff --git a/confirmation.php b/confirmation.php index f6fa956..a9d8cc2 100644 --- a/confirmation.php +++ b/confirmation.php @@ -20,7 +20,7 @@ else $validationAddress = "/validation.php?id=".$question->getId(); // Uncomment the following part for random email -/* + while ($dest_mail == $question->get_validator()) { $file = fopen('email.txt', 'r'); @@ -34,7 +34,7 @@ else } fclose($file); } -*/ + /* This code works, perhaps should be placed in a method in Question class?*/ $to = $dest_mail; $subject = "[Nemubot] Validation d'une question"; diff --git a/email.txt b/email.txt index de1823e..aa23940 100644 --- a/email.txt +++ b/email.txt @@ -1,6 +1,5 @@ -2 +4 bertrand.cournaud@gmail.com bertrand.cournaud@epita.fr - ircquizz@23.tf ircquizz@p0m.fr diff --git a/questions.php b/questions.php index 0810211..e544f1c 100755 --- a/questions.php +++ b/questions.php @@ -9,6 +9,26 @@ define("FILENAME", "questions_file.nemubot"); include("Question.class.php"); include("QuestionsFile.class.php"); +function isInList($mail) +{ + $file = fopen('email.txt', 'r'); + $number = fgets($file); + $i = 0; + $file_mail = fgets($file); + + while ($i < $number) + { + if (trim($mail) == trim($file_mail)) + { + return true; + } + + $file_mail = fgets($file); + $i++; + } + + return false; +} // Change this variable depending on the server $confirmationAddress = "confirmation.php?id="; @@ -33,7 +53,7 @@ if (isset ($_POST['send'])) die("Veuillez indiquer une question !"); else if (count($answers) <= 0) die("Veuillez indiquer au moins une réponse correcte !"); - else if (count($_POST['email']) <= 0) + else if (count($_POST['email']) <= 0 || !isInList($_POST['email'])) die("Veuillez indiquer une adresse mail valide"); else { @@ -61,6 +81,11 @@ if (isset ($_POST['send'])) ."Une nouvelle question a été proposée à Nemubot en utilisant cette adresse email.\n\n" + ."Rappels de la questions:\n" + .'Cours concerné : ' . $course . "\n" + .'La question est : ' . $question . "\n" + .'Les réponses sont : ' . print_r($answers, true) . "\n" + ."Si vous avez effectivement posé cette question, merci " ."de cliquer sur le lien ci-dessous pour confirmer.\n" ."Si vous ne comprenez rien à cet email ou que vous n'avez pas "