Discovery of php

This commit is contained in:
Bertrand 2012-05-23 14:05:08 +02:00
parent 87e8bf2cc0
commit 25f8396455

View File

@ -1,4 +1,79 @@
<!DOCTYPE html>
<?php
error_reporting(E_ALL);
define("FILENAME", "questions_file.nemubot");
include("Question.class.php");
include("QuestionsFile.class.php");
if (isset ($_POST['send']))
{
//Gets parameters: course, question and answers
$course = "";
$answers = array();
foreach ($_POST as $key => $value)
{
if ($key == "question")
$question = $value;
else if ($key == "course")
$course = $value;
else if (preg_match("#^answer#", $key))
$answers[] = $value;
}
//Check we have at least a question and an answer
if (empty($question))
die("Veuillez indiquer une question !");
else if (count($answers) <= 0)
die("Veuillez indiquer au moins une réponse correcte !");
else
{
$quest = Question::new_Question($question, $answers, $course);
/* $quest->print_test();*/
// @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?)
// @TODO: Update the question and save the file
// @TODO: Send mail to the selected validator
/* This code works, perhaps should be placed in a method in Question class?
$to = "bertrand.cournaud@gmail.com";
$subject = "[Nemubot] Validation d'une question";
$headers = "From: Nemubot <bot@nemunai.re>";
$message = "Bonjour,\n";
if (mail($to, $subject, $message, $headers))
{
echo ("Email sent");
}
else
echo ("Error with the email");
//*/
}
}
else
header("Location: ./");
?>
<html>
<head>
<meta charset="utf8" />
@ -25,76 +100,15 @@
<h3>La partie ci dessous est uniquement réservée au debug</h3>
Merci de ne pas en tenir compte
</p>
<?php
error_reporting(E_ALL);
define("FILENAME", "questions_file.nemubot");
include("Question.class.php");
include("QuestionsFile.class.php");
if (isset ($_POST['send']))
{
//Gets parameters: course, question and answers
$course = "";
$answers = array();
foreach ($_POST as $key => $value)
{
if ($key == "question")
$question = $value;
else if ($key == "course")
$course = $value;
else if (preg_match("#^answer#", $key))
$answers[] = $value;
}
//Check we have at least a question and an answer
if (empty($question))
die("Veuillez indiquer une question !");
else if (count($answers) <= 0)
die("Veuillez indiquer au moins une réponse correcte !");
else
{
$quest = Question::new_Question($question, $answers, $course);
$quest->print_test();
// @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?)
// @TODO: Update the question and save the file
// @TODO: Send mail to the selected validator
/* This code works, perhaps should be placed in a method in Question class?
$to = "bertrand.cournaud@gmail.com";
$subject = "[Nemubot] Validation d'une question";
$headers = "From: Nemubot <bot@nemunai.re>";
$message = "Bonjour,\n";
if (mail($to, $subject, $message, $headers))
{
echo ("Email sent");
}
else
echo ("Error with the email");
//*/
}
}
else
header("Location: ./");
?>
<p>
Rappels de la questions<br/>
<?php $quest->print_test() ?>
</p>
<p>
URL de validation:<br/>
<a href='http://178.170.101.82/~Cccompany/nemubot_askweb/validation.php?id=
<?php echo $quest->getId() ?>'>Valider la question</a>
</p>
</body>
</html>