This repository has been archived on 2020-08-21. You can view files and clone it, but cannot push or open issues or pull requests.
nemubot-askweb/confirmation.php

81 lines
1.7 KiB
PHP
Raw Normal View History

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");
header("Location: ./thanksConfirmation.php?id=" . $question->getId());
2012-05-24 13:20:56 +00:00
}
2012-05-23 16:18:23 +00:00
//*/
?>
<html>
<head>
<meta charset="utf8" />
2012-05-23 16:18:23 +00:00
</head>
<body>
2012-05-23 16:18:23 +00:00
</body>
</html>