TP4 ok
This commit is contained in:
1
2020-2021/TD4/export/.gitignore
vendored
Normal file
1
2020-2021/TD4/export/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
*.png
|
51
2020-2021/TD4/export/index.html
Normal file
51
2020-2021/TD4/export/index.html
Normal file
@ -0,0 +1,51 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr-FR">
|
||||
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<meta charset="utf-8">
|
||||
<title></title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
|
||||
<!-- General Style -->
|
||||
<style type="text/css">
|
||||
#colorlib-notfound,
|
||||
#colorlib-notfound .colorlib-notfound-bg {
|
||||
background-image: url("https://stuff.junkjumper-projects.com/wp-content/uploads/2019/10/404.png") !important;
|
||||
background-repeat: no-repeat;
|
||||
background-size: contain;
|
||||
}
|
||||
|
||||
.colorlib-copyright {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
margin: 0 auto;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.colorlib-copyright span {
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.colorlib-copyright a {
|
||||
opacity: 1;
|
||||
}
|
||||
</style>
|
||||
<!-- End General Style -->
|
||||
|
||||
<link rel="stylesheet" id="template_01-main-css" href="src/style.css" type="text/css" media="all">
|
||||
<link rel="stylesheet" id="Montserrat-css" href="src/css_002.css" type="text/css" media="all">
|
||||
<link rel="stylesheet" id="Titillium-css" href="src/css.css" type="text/css" media="all">
|
||||
</head>
|
||||
|
||||
<body class="colorlib-body">
|
||||
<div id="colorlib-notfound">
|
||||
<div class="colorlib-notfound">
|
||||
<a href="https://www.junkjumper-projects.com/" id="colorlib_404_customizer_button_text">Back to homepage</a>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
@ -1,84 +1,148 @@
|
||||
<!DOCTYPE html>
|
||||
<?php
|
||||
/**
|
||||
* @Author: JunkJumper
|
||||
* @Link: https://github.com/JunkJumper
|
||||
* @Copyright: Creative Common 4.0 (CC BY 4.0)
|
||||
* @Create Time: 05-10-2020 10:26
|
||||
* @Description: M314 - TD3
|
||||
*/
|
||||
|
||||
|
||||
$entree = "./Voitures.txt";
|
||||
|
||||
function openFile($input) {
|
||||
$voitures = fopen($input, "r");
|
||||
$lecture = file($input);
|
||||
}
|
||||
|
||||
function closeFile($input) {
|
||||
fclose($input);
|
||||
}
|
||||
|
||||
function displayLines($input) {
|
||||
openFile($input);
|
||||
|
||||
while(! feof($input)) {
|
||||
$line = fgets($input);
|
||||
echo $line. '<br />';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<html>
|
||||
<html lang="fr">
|
||||
|
||||
<head>
|
||||
<title>M314 - TD4</title>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
|
||||
<title>M314 - TD4 - Manipulation de fichiers et de répertoire</title>
|
||||
<meta name="description" content="Page avec formulaire pour Wallpaper Francoponies 2020" />
|
||||
<meta name="author" content="JunkJumper" />
|
||||
<!-- Bootstrap core CSS -->
|
||||
<link href="https://www.junkjumper-projects.com/FP/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
|
||||
<!-- Additional CSS Files -->
|
||||
<link href="https://fonts.googleapis.com/css?family=Lato:100,300,400,700,900" rel="stylesheet" />
|
||||
<link rel="stylesheet" href="https://www.junkjumper-projects.com/FP/assets/css/tooplate-style.css" />
|
||||
<link rel="stylesheet" href="https://www.junkjumper-projects.com/FP/assets/css/fontawesome.css" />
|
||||
<!-- Favicon -->
|
||||
<link rel="icon" type="image/png" href="https://www.junkjumper-projects.com/umming_lines_paint.png" />
|
||||
<h1>M314 - TD4 – Manipulation de fichiers et de répertoire</h1>
|
||||
<meta charset="UTF-8" />
|
||||
</head>
|
||||
|
||||
<?php
|
||||
echo displayLines($entree);
|
||||
?>
|
||||
|
||||
<body>
|
||||
<a href="..">
|
||||
<button class="button blue">Retour à la page précédente</button>
|
||||
</a>
|
||||
<div id="page-wraper">
|
||||
<!-- Sidebar Menu -->
|
||||
<div class="responsive-nav">
|
||||
<i class="fa fa-bars" id="menu-toggle"></i>
|
||||
<div id="menu" class="menu">
|
||||
<i class="fa fa-times" id="menu-close"></i>
|
||||
<div class="container">
|
||||
<div class="image">
|
||||
<a href="https://www.junkjumper-projects.com/" target="_blank"><img src="https://www.junkjumper-projects.com/umming_lines_paint.png" alt="Logo Francoponies" id="logo" class="zoom" /></a>
|
||||
</div></a>
|
||||
<div class="author-content">
|
||||
</div>
|
||||
<nav class="main-nav" role="navigation">
|
||||
<ul class="main-menu">
|
||||
<li><a href="#section3">Formulaire</a></li>
|
||||
</ul>
|
||||
<li><a href="./results.csv">Voir résultats</a></li>
|
||||
<li>
|
||||
<a href="..">
|
||||
Retour à la page précédente
|
||||
</a>
|
||||
</li>
|
||||
</nav>
|
||||
<a href="https://about.junkjumper-projects.com/" target="_blank">Page par JunkJumper</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<section class="section my-work" data-section="section3">
|
||||
<div class="container">
|
||||
<div class="section-heading">
|
||||
|
||||
<h2>Le Formulaire</h2>
|
||||
<div class="line-dec"></div>
|
||||
</div>
|
||||
<div id="form">
|
||||
<form enctype="multipart/form-data" action="./traitement.php" method="post">
|
||||
|
||||
<fieldset>
|
||||
Pseudo discord (Pseudo#1234) : <input id="discord" name="discord" type="text" placeholder="Pseudo#1234" class="form-control input-md" required=""><br />
|
||||
Nom de votre OC :<input id="oc" name="oc" type="text" placeholder="monOC" class="form-control input-md" required=""><br />
|
||||
Race de votre OC :<select id="race" name="race" class="form-control">
|
||||
<option value="">Choissez une race</option>
|
||||
<option value="terrestre">Terrestre</option>
|
||||
<option value="licorne">Licorne</option>
|
||||
<option value="pegase">Pégase</option>
|
||||
<option value="alicorne">Alicorne</option>
|
||||
<option value="griphon">Griphon</option>
|
||||
<option value="changelin">Changelin</option>
|
||||
<option value="yak">Yak</option>
|
||||
<option value="dragon">Dragon</option>
|
||||
<option value="seapony">Seapony</option>
|
||||
<option value="seapony">Kirin</option>
|
||||
</select><br />
|
||||
Image de votre OC :<input name="fichier" type="file" id="fichier_a_uploader" /><br /><br />
|
||||
<input type="submit" value="Envoyer" /><br />
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
<!--
|
||||
<img src="./src/end.png" id="end" />
|
||||
-->
|
||||
</div>
|
||||
|
||||
</section>
|
||||
</div>
|
||||
<!-- Scripts -->
|
||||
<!-- Bootstrap core JavaScript -->
|
||||
<script src="https://www.junkjumper-projects.com/FP/vendor/jquery/jquery.min.js"></script>
|
||||
<script src="https://www.junkjumper-projects.com/FP/vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
|
||||
|
||||
<script src="https://www.junkjumper-projects.com/FP/assets/js/isotope.min.js"></script>
|
||||
<script src="https://www.junkjumper-projects.com/FP/assets/js/owl-carousel.js"></script>
|
||||
<script src="https://www.junkjumper-projects.com/FP/assets/js/lightbox.js"></script>
|
||||
<script src="https://www.junkjumper-projects.com/FP/assets/js/custom.js"></script>
|
||||
<script>
|
||||
//according to loftblog tut
|
||||
$(".main-menu li:first").addClass("active");
|
||||
|
||||
var showSection = function showSection(section, isAnimate) {
|
||||
var direction = section.replace(/#/, ""),
|
||||
reqSection = $(".section").filter(
|
||||
'[data-section="' + direction + '"]'
|
||||
),
|
||||
reqSectionPos = reqSection.offset().top - 0;
|
||||
|
||||
if (isAnimate) {
|
||||
$("body, html").animate({
|
||||
scrollTop: reqSectionPos
|
||||
},
|
||||
800
|
||||
);
|
||||
} else {
|
||||
$("body, html").scrollTop(reqSectionPos);
|
||||
}
|
||||
};
|
||||
|
||||
var checkSection = function checkSection() {
|
||||
$(".section").each(function() {
|
||||
var $this = $(this),
|
||||
topEdge = $this.offset().top - 80,
|
||||
bottomEdge = topEdge + $this.height(),
|
||||
wScroll = $(window).scrollTop();
|
||||
if (topEdge < wScroll && bottomEdge > wScroll) {
|
||||
var currentId = $this.data("section"),
|
||||
reqLink = $("a").filter("[href*=\\#" + currentId + "]");
|
||||
reqLink
|
||||
.closest("li")
|
||||
.addClass("active")
|
||||
.siblings()
|
||||
.removeClass("active");
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$(".main-menu").on("click", "a", function(e) {
|
||||
e.preventDefault();
|
||||
showSection($(this).attr("href"), true);
|
||||
});
|
||||
|
||||
$(window).scroll(function() {
|
||||
checkSection();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
<style>
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
color: #4c6e8a;
|
||||
}
|
||||
|
||||
.button {
|
||||
border: none;
|
||||
color: white;
|
||||
padding: 15px 32px;
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
display: inline-block;
|
||||
font-size: 16px;
|
||||
margin: 4px 2px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.blue {
|
||||
background-color: #4c6e8a;
|
||||
}
|
||||
|
||||
b {
|
||||
color: red;
|
||||
}
|
||||
|
||||
strong.mandatory {
|
||||
color : red;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</html>
|
||||
</html>
|
||||
|
||||
|
2
2020-2021/TD4/results.csv
Normal file
2
2020-2021/TD4/results.csv
Normal file
@ -0,0 +1,2 @@
|
||||
Discord;Nom OC;Race;Image
|
||||
JunkJumper#3773;UmmingBird;pegase;https://www.junkjumper-projects.com/FP/export/UmmingBirdummin-nsfw.png
|
|
BIN
2020-2021/TD4/src/bg.png
Normal file
BIN
2020-2021/TD4/src/bg.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 676 KiB |
BIN
2020-2021/TD4/src/end.png
Normal file
BIN
2020-2021/TD4/src/end.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 166 KiB |
150
2020-2021/TD4/traitement.php
Normal file
150
2020-2021/TD4/traitement.php
Normal file
@ -0,0 +1,150 @@
|
||||
<?php
|
||||
|
||||
/************************************************************
|
||||
* Partie debug *
|
||||
*************************************************************/
|
||||
|
||||
//Array ([discord]-[oc]-[race]-[avatar])
|
||||
$tab = $_REQUEST;
|
||||
$die = false;
|
||||
$message = "";
|
||||
|
||||
|
||||
//print_r($tab);
|
||||
//echo '<br />'; //ok on recup dans $tab[nomVar]
|
||||
//print_r($_FILES['fichier']);
|
||||
//echo '<br />';
|
||||
|
||||
|
||||
/************************************************************
|
||||
* Partie check valeurs *
|
||||
*************************************************************/
|
||||
|
||||
$nom = strtr(
|
||||
$$_REQUEST['oc'],
|
||||
'ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ',
|
||||
'AAAAAACEEEEIIIIOOOOOUUUUYaaaaaaceeeeiiiioooooouuuuyy'
|
||||
);
|
||||
$nom = preg_replace('/([^.a-z0-9]+)/i', '-', $nom );
|
||||
|
||||
|
||||
if($_REQUEST['oc'] == "") {
|
||||
$die = true;
|
||||
$message = $message ."Vous n'avez pas renseigné le nom de votre OC !".'<br />';
|
||||
}
|
||||
|
||||
|
||||
if($_REQUEST['race'] == "") {
|
||||
$die = true;
|
||||
$message = $message ."Vous n'avez pas renseigné une race !".'<br />';
|
||||
}
|
||||
|
||||
|
||||
/************************************************************
|
||||
* Partie gestion des images *
|
||||
*************************************************************/
|
||||
|
||||
$dossier = './export/';
|
||||
$fichier = basename($_FILES['fichier']['name']);
|
||||
$taille_maxi = 10485760;
|
||||
$taille = filesize($_FILES['fichier']['tmp_name']);
|
||||
$extensions = array('.png');
|
||||
$extension = strrchr($_FILES['fichier']['name'], '.');
|
||||
|
||||
|
||||
|
||||
|
||||
//Début des vérifications de sécurité...
|
||||
if (!in_array($extension, $extensions)) { //Si l'extension n'est pas dans le tableau
|
||||
$erreur = 'Vous devez uploader un fichier de type png';
|
||||
$die = true;
|
||||
}
|
||||
if ($taille > $taille_maxi) {
|
||||
$erreur = 'Le fichier est trop gros...';
|
||||
$die = true;
|
||||
}
|
||||
|
||||
if (!isset($erreur)) { //S'il n'y a pas d'erreur, on upload
|
||||
//On formate le nom du fichier ici...
|
||||
$fichier = strtr(
|
||||
$fichier,
|
||||
'ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ',
|
||||
'AAAAAACEEEEIIIIOOOOOUUUUYaaaaaaceeeeiiiioooooouuuuyy'
|
||||
);
|
||||
$fichier = preg_replace('/([^.a-z0-9]+)/i', '-', $fichier);
|
||||
if (move_uploaded_file($_FILES['fichier']['tmp_name'], $dossier .$_REQUEST['oc'] .$fichier) && (!$die) ) { //Si la fonction renvoie TRUE, c'est que ça a fonctionné...
|
||||
$path = $dossier .$_REQUEST['oc'] .$fichier;
|
||||
$message = 'Upload effectué avec succès !';
|
||||
$envoi = true;
|
||||
} else { //Sinon (la fonction renvoie FALSE).
|
||||
$message = $message .' Echec de l\'upload ! Vérifiez bien les conditions d\'envoi !';
|
||||
$die = true;
|
||||
}
|
||||
} else {
|
||||
//echo $erreur;
|
||||
}
|
||||
|
||||
/************************************************************
|
||||
* Partie export CSV *
|
||||
*************************************************************/
|
||||
|
||||
//Discord;oc;race;avatar
|
||||
if ($envoi) {
|
||||
$write = fopen('results.csv', 'a');
|
||||
fputs($write, "\n" .$tab['discord'] .";" .$tab['oc'] .";" .$tab['race'] .";https://www.junkjumper-projects.com/FP/" .substr($path, 2));
|
||||
fclose($write);
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
<!--
|
||||
/************************************************************
|
||||
* Partie HTML *
|
||||
*************************************************************/-->
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link href="./assets/css/display.css" rel="stylesheet">
|
||||
<link href="https://fonts.googleapis.com/css?family=Lato:100,300,400,700,900" rel="stylesheet" />
|
||||
<link rel="icon" type="image/png" href="assets/images/FP.png" />
|
||||
|
||||
<?php
|
||||
if($die) {
|
||||
echo '<script>setTimeout(function() {window.location.href = "index.php";}, 4975);</script>';
|
||||
} else {
|
||||
echo '<script>setTimeout(function() {window.location.href = "index.php";}, 4975);</script>';
|
||||
}
|
||||
?>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="mid-mid">
|
||||
|
||||
<center>
|
||||
<p>
|
||||
<?php
|
||||
$erreur = $erreur .$message;
|
||||
if (!$die) {
|
||||
echo '<img src="./assets/images/ok.gif" alt="ok" width="70%" /><br /><br />' ;
|
||||
echo $message;
|
||||
} else {
|
||||
echo '<img src="./assets/images/err.png" alt="erreur" width="30%" /><br /><br />';
|
||||
echo $erreur;
|
||||
}
|
||||
?>
|
||||
<br /><br />
|
||||
<div class="radial-timer s-animate">
|
||||
<div class="radial-timer-half"></div>
|
||||
<div class="radial-timer-half"></div>
|
||||
</div><br /><br /> Vous allez être redirigé vers la page précédente dans quelques instants<br \>
|
||||
</p>
|
||||
</center>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
Reference in New Issue
Block a user