mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2025-06-29 23:11:12 +02:00
First week fixes
This commit is contained in:
@ -29,19 +29,24 @@ if ($team->isSelectedForFinal())
|
||||
class SaveSynthesis
|
||||
{
|
||||
private $dest;
|
||||
private $round;
|
||||
private $file;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->file = $_FILES["synthese"];
|
||||
$this->round = htmlspecialchars($_POST["round"]);
|
||||
$this->dest = DestType::fromName(strtoupper(htmlspecialchars($_POST["dest"])));
|
||||
}
|
||||
|
||||
public function makeVerifications()
|
||||
{
|
||||
global $LOCAL_PATH;
|
||||
global $LOCAL_PATH, $tournament;
|
||||
|
||||
ensure($this->dest != DestType::DEFENSEUR, "Le destinataire est invalide.");
|
||||
ensure($this->dest != DestType::DEFENSEUR, "La source est invalide.");
|
||||
ensure($this->round == 1 || $this->round == 2, "Le tour est invalide.");
|
||||
$now = date("Y-m-d H:i");
|
||||
ensure($this->round == 1 && $now < $tournament->getSynthesesDate() || $this->round == 2 && $now < $tournament->getSynthesesDate2(), "Vous ne pouvez plus rendre de note de synthèse pour le tour $this->round.");
|
||||
ensure($this->file["size"] <= 2e6, "Le fichier doit peser moins que 2 Mo.");
|
||||
ensure(!$this->file["error"], "Une erreur est survenue.");
|
||||
ensure(finfo_file(finfo_open(FILEINFO_MIME_TYPE), $this->file["tmp_name"]) == "application/pdf", "Le fichier doit être au format PDF.");
|
||||
@ -58,8 +63,8 @@ class SaveSynthesis
|
||||
if (!rename($this->file["tmp_name"], "$LOCAL_PATH/files/$id"))
|
||||
throw new AssertionError("Une erreur est survenue lors de l'envoi du fichier.");
|
||||
|
||||
$req = $DB->prepare("INSERT INTO `syntheses`(`file_id`, `team`, `tournament`, `dest`) VALUES (?, ?, ?, ?);");
|
||||
$req->execute([$id, $team->getId(), $team->isSelectedForFinal() ? $FINAL->getId() : $tournament->getId(), $this->dest]);
|
||||
$req = $DB->prepare("INSERT INTO `syntheses`(`file_id`, `team`, `tournament`, `round`, `dest`) VALUES (?, ?, ?, ?, ?);");
|
||||
$req->execute([$id, $team->getId(), $team->isSelectedForFinal() ? $FINAL->getId() : $tournament->getId(), $this->round, $this->dest]);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user