Phase 1 : envoi des vidéos (en cours)

This commit is contained in:
galaxyoyo 2019-09-13 00:11:41 +02:00
parent 51282d13ea
commit 0fdae19f2d
2 changed files with 22 additions and 1 deletions

View File

@ -12,7 +12,7 @@ $error_message = null;
if (isset($_POST["upload"])) {
$new_video = new NewVideo($_POST);
try {
$new_video->makeVerfications();
$new_video->makeVerifications();
$new_video->uploadVideo();
} catch (AssertionError $e) {
$has_error = true;
@ -31,8 +31,18 @@ class NewVideo
public function makeVerifications()
{
ensure(preg_match("#(https?)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?#", $this->link), "Ce n'est pas une URL valide.");
}
public function uploadVideo()
{
global $DB, $YEAR, $team;
$req = $DB->prepare("INSERT INTO `videos`(`team`, `problem`, `link`, `reason`, `year`) VALUES (?, ?, ?, ?, ?)");
$req->execute([$team->getId(), $team->getProblem(), $this->link, "SOLUTION", $YEAR]);
}
}
$videos_req = $DB->query("SELECT * FROM `videos` WHERE `year` = $YEAR;");
require_once "server_files/views/envoyer_video.php";

View File

@ -8,6 +8,17 @@ elseif (isset($new_video))
echo "<h2>Votre vidéo a bien été envoyée !</h2>";
?>
<?php
while (($data = $videos_req->fetch()) !== false) {
$link = $data["link"];
echo "<a href=\"$link\">$link</a><br />";
if (preg_match("#https?\://www\.youtube\.com\/watch\?v=(.*)#", $link, $matches)) {
$code = $matches[1];
echo "<center><iframe width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/$code\" frameborder=\"0\" allow=\"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen></iframe></center><br />";
}
}
?>
<form method="POST">
<table style="width: 100%;">
<tbody>