2012-05-23 16:18:23 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
|
|
|
|
<?php
|
|
|
|
include("Question.class.php");
|
|
|
|
include("QuestionsFile.class.php");
|
|
|
|
|
|
|
|
|
|
|
|
$id = $_GET['id'];
|
|
|
|
|
|
|
|
$file = new QuestionsFile("questions.xml");
|
|
|
|
$question = $file->get_question($id);
|
|
|
|
|
2012-05-24 13:20:56 +00:00
|
|
|
if (!$question)
|
|
|
|
{
|
|
|
|
echo "Mauvais ID\n";
|
|
|
|
}
|
|
|
|
else
|
2012-05-24 12:19:45 +00:00
|
|
|
{
|
2012-05-24 13:20:56 +00:00
|
|
|
$dest_mail = $question->get_validator();
|
2012-05-24 18:20:14 +00:00
|
|
|
$validationAddress = "/validation.php?id=".$question->getId();
|
2012-05-23 16:18:23 +00:00
|
|
|
|
2012-05-24 13:20:56 +00:00
|
|
|
// Uncomment the following part for random email
|
2012-05-24 21:14:19 +00:00
|
|
|
|
2012-05-24 13:20:56 +00:00
|
|
|
while ($dest_mail == $question->get_validator())
|
|
|
|
{
|
|
|
|
$file = fopen('email.txt', 'r');
|
|
|
|
$number = fgets($file);
|
2012-05-23 16:18:23 +00:00
|
|
|
|
2012-05-24 13:20:56 +00:00
|
|
|
$random = rand(1, $number);
|
2012-05-23 16:18:23 +00:00
|
|
|
|
2012-05-24 13:20:56 +00:00
|
|
|
for ($i = 0; $i < $random; $i++)
|
|
|
|
{
|
|
|
|
$dest_mail = fgets($file);
|
|
|
|
}
|
|
|
|
fclose($file);
|
|
|
|
}
|
2012-05-24 21:14:19 +00:00
|
|
|
|
2012-05-23 16:18:23 +00:00
|
|
|
/* This code works, perhaps should be placed in a method in Question class?*/
|
2012-05-24 13:20:56 +00:00
|
|
|
$to = $dest_mail;
|
|
|
|
$subject = "[Nemubot] Validation d'une question";
|
|
|
|
$headers = "From: Nemubot <bot@nemunai.re>";
|
|
|
|
$message = "Bonjour,\n"
|
|
|
|
."Une nouvelle question a été proposée à Nemubot.\n\n"
|
|
|
|
|
2012-06-09 21:05:59 +00:00
|
|
|
."Vous avez été sélectionné pour valider la question.\n\n"
|
|
|
|
|
|
|
|
."Rappels de la questions:\n"
|
|
|
|
.'Cours concerné : ' . $question->getCourse() . "\n"
|
|
|
|
.'La question est : ' . $question->getQuestion() . "\n"
|
|
|
|
.'Les réponses sont : ' . print_r($question->getAnswer(), true) . "\n"
|
|
|
|
|
2012-05-24 13:20:56 +00:00
|
|
|
|
|
|
|
."Adresse de confirmation de la question:\n"
|
2012-05-24 12:19:45 +00:00
|
|
|
. "http://".$_SERVER["SERVER_NAME"]
|
2012-05-24 14:03:32 +00:00
|
|
|
. dirname($_SERVER["REQUEST_URI"]) . $validationAddress
|
2012-05-24 12:19:45 +00:00
|
|
|
|
2012-05-24 13:20:56 +00:00
|
|
|
. "\n\n Merci beaucoup de votre participation\n"
|
2012-05-24 12:19:45 +00:00
|
|
|
|
2012-05-24 13:20:56 +00:00
|
|
|
."Cordialement,\n\n"
|
2012-05-24 12:19:45 +00:00
|
|
|
|
2012-05-24 13:20:56 +00:00
|
|
|
."-- \nNemubot.";
|
2012-05-23 16:18:23 +00:00
|
|
|
|
2012-05-24 13:20:56 +00:00
|
|
|
|
|
|
|
if (mail($to, $subject, $message, $headers))
|
|
|
|
{
|
|
|
|
echo ("Email sent to: " . $dest_mail);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
echo ("Error with the email");
|
2012-05-25 09:48:49 +00:00
|
|
|
|
|
|
|
header("Location: ./thanksConfirmation.php?id=" . $question->getId());
|
2012-05-24 13:20:56 +00:00
|
|
|
}
|
2012-05-23 16:18:23 +00:00
|
|
|
//*/
|
|
|
|
|
|
|
|
?>
|
|
|
|
|
|
|
|
<html>
|
2012-05-25 09:48:49 +00:00
|
|
|
<head>
|
|
|
|
<meta charset="utf8" />
|
2012-05-23 16:18:23 +00:00
|
|
|
</head>
|
2012-05-24 14:22:35 +00:00
|
|
|
|
2012-05-25 09:48:49 +00:00
|
|
|
<body>
|
2012-05-23 16:18:23 +00:00
|
|
|
</body>
|
2012-05-25 09:48:49 +00:00
|
|
|
</html>
|