Confirmation AND validation step
This commit is contained in:
parent
7ab305ef62
commit
ad66d30c23
@ -50,6 +50,16 @@ class Question
|
||||
return $q;
|
||||
}
|
||||
|
||||
public function set_validator($val)
|
||||
{
|
||||
$this->validator = $val;
|
||||
}
|
||||
|
||||
public function get_validator()
|
||||
{
|
||||
return $this->validator;
|
||||
}
|
||||
|
||||
public function print_test()
|
||||
{
|
||||
echo 'Cours concerné : ' . $this->course . "<br>";
|
||||
|
@ -11,7 +11,7 @@ include("QuestionsFile.class.php");
|
||||
|
||||
|
||||
// Change this variable depending on the server
|
||||
$validationAddress = "validation.php?id=";
|
||||
$confirmationAddress = "confirmation.php?id=";
|
||||
|
||||
if (isset ($_POST['send']))
|
||||
{
|
||||
@ -33,22 +33,17 @@ 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)
|
||||
die("Veuillez indiquer une adresse mail valide");
|
||||
else
|
||||
{
|
||||
$quest = Question::new_Question($question, $answers, $course);
|
||||
/* $quest->print_test();*/
|
||||
$quest->set_validator($_POST['email']);
|
||||
|
||||
// @TODO: Create/Load a QuestionFile and add the question (it must be unique)
|
||||
$file = new QuestionsFile('questions.xml');
|
||||
$file->add_question($quest);
|
||||
$file->save();
|
||||
/*
|
||||
echo "<br/>";
|
||||
echo "<br/> C'est ici pour valider";
|
||||
echo "<br/>"
|
||||
. "http://178.170.101.82/~Cccompany/nemubot_askweb/validation.php?id="
|
||||
. $quest->getId();
|
||||
*/
|
||||
|
||||
// @TODO: Find a validator (from the list of previous senders for example?)
|
||||
|
||||
@ -60,41 +55,14 @@ if (isset ($_POST['send']))
|
||||
|
||||
echo 'Mail of user : ' . $_POST['email'] . "<br/>";
|
||||
|
||||
$file = fopen('email.txt', 'r');
|
||||
$number = fgets($file);
|
||||
|
||||
$random = rand(1, $number);
|
||||
|
||||
for ($i = 0; $i < $random; $i++)
|
||||
{
|
||||
$line = fgets($file);
|
||||
echo $line . "<br/>";
|
||||
}
|
||||
|
||||
/* Oui, c'est moche de le réecrire 2 fois mais ma première belle
|
||||
tentative s'est soldée par un echec
|
||||
*/
|
||||
|
||||
while ($line == $_POST['email'])
|
||||
{
|
||||
$random = rand(1, $number);
|
||||
|
||||
for ($i = 0; $i < $random; $i++)
|
||||
{
|
||||
$line = fgets($file);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
echo 'Adresse mail: ' . $line . "<br/>";
|
||||
fclose($file);
|
||||
|
||||
/* This code works, perhaps should be placed in a method in Question class?
|
||||
$to = $line;
|
||||
$subject = "[Nemubot] Validation d'une question";
|
||||
$to = $_POST['email'];
|
||||
$subject = "[Nemubot] Confirmation de question";
|
||||
$headers = "From: Nemubot <bot@nemunai.re>";
|
||||
$message = 'Bonjour,\n Adresse de validation:
|
||||
$validationAddress . $quest->getId()';
|
||||
$message = "Bonjour,\n" .
|
||||
"Êtes vous la personne qui a posté une nouvelle question ?\n" .
|
||||
"Adresse de validation:
|
||||
$confirmationAddress . $quest->getId()";
|
||||
|
||||
if (mail($to, $subject, $message, $headers))
|
||||
{
|
||||
@ -144,7 +112,7 @@ else
|
||||
<p>
|
||||
URL de validation:<br/>
|
||||
<a href=<?php echo
|
||||
$validationAddress . $quest->getId() ?>>Valider la question</a>
|
||||
$confirmationAddress . $quest->getId() ?>>Valider la question</a>
|
||||
</p>
|
||||
|
||||
</body>
|
||||
|
@ -26,7 +26,7 @@ $question->print_test();
|
||||
lien ci dessous.<br/>
|
||||
|
||||
<input type="button" value="Valider la question"
|
||||
onclick="<?php $question->validate() ?>"/>
|
||||
onclick="<?php $question->validated(); $file->save() ?>"/>
|
||||
|
||||
|
||||
</body>
|
||||
|
Reference in New Issue
Block a user