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"
|
|
|
|
|
|
|
|
."Vous avez été sélectionné pour valider la question.\n"
|
|
|
|
."Vous pouvez cliquer sur le lien ci-dessous pour voir "
|
|
|
|
."les détails de la question et la valider si elle vous "
|
|
|
|
."semble juste.\n\n"
|
|
|
|
|
|
|
|
."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-23 16:18:23 +00:00
|
|
|
//*/
|
|
|
|
|
|
|
|
?>
|
|
|
|
|
|
|
|
<html>
|
2012-05-24 13:20:56 +00:00
|
|
|
<head>
|
|
|
|
<meta charset="utf8" />
|
|
|
|
<link rel="Stylesheet" href="style.css" />
|
2012-05-23 16:18:23 +00:00
|
|
|
</head>
|
|
|
|
<body>
|
2012-05-24 13:20:56 +00:00
|
|
|
<header>
|
|
|
|
<div id="main_title">
|
|
|
|
<a href="http://www.h2g2.com" target="_blank">
|
|
|
|
<img src="marvin-robot_normal.png" alt="" id="banner"/>
|
|
|
|
</a>
|
|
|
|
<h1>Nemubot Questions</h1>
|
|
|
|
</div>
|
|
|
|
</header>
|
|
|
|
|
|
|
|
<section>
|
|
|
|
<h2>Merci de votre participation</h2>
|
|
|
|
<p>
|
2012-05-24 14:22:35 +00:00
|
|
|
<?php
|
|
|
|
if (!$question)
|
|
|
|
{
|
|
|
|
echo "La question n'existe pas.";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
echo ("Votre question a bien été prise en compte.<br/>"
|
|
|
|
."Un email a été envoyé à une personne du chan pour "
|
|
|
|
."qu'elle valide votre question."
|
|
|
|
."</p>
|
|
|
|
<p>
|
2012-05-24 12:19:45 +00:00
|
|
|
Nemubot vous remercie de l'aider à agrandir sa base de donnée
|
2012-05-24 14:22:35 +00:00
|
|
|
</p>");
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
|
2012-05-24 13:20:56 +00:00
|
|
|
</section>
|
2012-05-23 16:18:23 +00:00
|
|
|
</body>
|
2012-05-24 13:20:56 +00:00
|
|
|
</html>
|